From 6e38faaf3146dbe3f4239b179a48dd1dea6b45b8 Mon Sep 17 00:00:00 2001 From: sunag Date: Thu, 29 Aug 2024 01:30:11 -0300 Subject: [PATCH] Updated builds. --- build/three.webgpu.js | 1492 ++++++++++++++++++++----------------- build/three.webgpu.min.js | 2 +- 2 files changed, 793 insertions(+), 701 deletions(-) diff --git a/build/three.webgpu.js b/build/three.webgpu.js index 5aee911add1738..646ee1853f9391 100644 --- a/build/three.webgpu.js +++ b/build/three.webgpu.js @@ -24276,6 +24276,7 @@ function getCacheKey$1( object, force = false ) { if ( object.isNode === true ) { cacheKey += object.id; + object = object.getSelf(); } @@ -24517,7 +24518,7 @@ const defaultBuildStages = [ 'setup', 'analyze', 'generate' ]; const shaderStages = [ ...defaultShaderStages, 'compute' ]; const vectorComponents = [ 'x', 'y', 'z', 'w' ]; -const NodeClasses = new Map(); +const Nodes$1 = new Map(); let _nodeId = 0; @@ -25047,34 +25048,39 @@ class Node extends EventDispatcher { } -function registerNodeClass( type, nodeClass ) { +Node.type = /*@__PURE__*/ registerNode( '', Node ); - const nodeType = type + 'Node'; +function registerNode( type, nodeClass ) { - if ( typeof nodeClass !== 'function' || ! type ) throw new Error( `TSL.Node: Node class ${ type } is not a class` ); + const suffix = 'Node'; + const nodeType = type + suffix; - if ( NodeClasses.has( nodeType ) ) { + if ( typeof nodeClass !== 'function' ) throw new Error( `TSL.Node: Node class ${ type } is not a class` ); + + if ( Nodes$1.has( nodeType ) ) { console.warn( `TSL.Node: Redefinition of node class ${ nodeType }` ); return; } - if ( type.slice( - 4 ) === 'Node' ) { + if ( type.slice( - suffix.length ) === suffix ) { - console.warn( `TSL.Node: Node class ${ nodeType } should not have 'Node' suffix.` ); + console.warn( `TSL.Node: Node class ${ nodeType } should not have '${ suffix }' suffix.` ); return; } - NodeClasses.set( nodeType, nodeClass ); + Nodes$1.set( nodeType, nodeClass ); nodeClass.type = nodeType; + return nodeType; + } function createNodeFromType( type ) { - const Class = NodeClasses.get( type ); + const Class = Nodes$1.get( type ); if ( Class !== undefined ) { @@ -25114,7 +25120,7 @@ class ArrayElementNode extends Node { // @TODO: If extending from TempNode it br } -registerNodeClass( 'ArrayElement', ArrayElementNode ); +ArrayElementNode.type = /*@__PURE__*/ registerNode( 'ArrayElement', ArrayElementNode ); class ConvertNode extends Node { @@ -25176,7 +25182,7 @@ class ConvertNode extends Node { } -registerNodeClass( 'Convert', ConvertNode ); +ConvertNode.type = /*@__PURE__*/ registerNode( 'Convert', ConvertNode ); class TempNode extends Node { @@ -25231,7 +25237,7 @@ class TempNode extends Node { } -registerNodeClass( 'Temp', TempNode ); +TempNode.type = /*@__PURE__*/ registerNode( 'Temp', TempNode ); class JoinNode extends TempNode { @@ -25288,7 +25294,7 @@ class JoinNode extends TempNode { } -registerNodeClass( 'Join', JoinNode ); +JoinNode.type = /*@__PURE__*/ registerNode( 'Join', JoinNode ); const stringVectorComponents = vectorComponents.join( '' ); @@ -25396,7 +25402,7 @@ class SplitNode extends Node { } -registerNodeClass( 'Split', SplitNode ); +SplitNode.type = /*@__PURE__*/ registerNode( 'Split', SplitNode ); class SetNode extends TempNode { @@ -25453,7 +25459,7 @@ class SetNode extends TempNode { } -registerNodeClass( 'Set', SetNode ); +SetNode.type = /*@__PURE__*/ registerNode( 'Set', SetNode ); class FlipNode extends TempNode { @@ -25513,7 +25519,7 @@ class FlipNode extends TempNode { } -registerNodeClass( 'Flip', FlipNode ); +FlipNode.type = /*@__PURE__*/ registerNode( 'Flip', FlipNode ); class InputNode extends Node { @@ -25592,7 +25598,7 @@ class InputNode extends Node { } -registerNodeClass( 'Input', InputNode ); +InputNode.type = /*@__PURE__*/ registerNode( 'Input', InputNode ); class ConstNode extends InputNode { @@ -25620,7 +25626,7 @@ class ConstNode extends InputNode { } -registerNodeClass( 'Const', ConstNode ); +ConstNode.type = /*@__PURE__*/ registerNode( 'Const', ConstNode ); // @@ -26260,7 +26266,7 @@ addMethodChaining( 'toMat4', mat4 ); // basic nodes -const element = nodeProxy( ArrayElementNode ); +const element = /*@__PURE__*/ nodeProxy( ArrayElementNode ); const convert = ( node, types ) => nodeObject( new ConvertNode( nodeObject( node ), types ) ); const split = ( node, channels ) => nodeObject( new SplitNode( nodeObject( node ), channels ) ); @@ -26310,14 +26316,14 @@ class UniformGroupNode extends Node { } -registerNodeClass( 'UniformGroup', UniformGroupNode ); +UniformGroupNode.type = /*@__PURE__*/ registerNode( 'UniformGroup', UniformGroupNode ); const uniformGroup = ( name ) => new UniformGroupNode( name ); const sharedUniformGroup = ( name ) => new UniformGroupNode( name, true ); -const frameGroup = sharedUniformGroup( 'frame' ); -const renderGroup = sharedUniformGroup( 'render' ); -const objectGroup = uniformGroup( 'object' ); +const frameGroup = /*@__PURE__*/ sharedUniformGroup( 'frame' ); +const renderGroup = /*@__PURE__*/ sharedUniformGroup( 'render' ); +const objectGroup = /*@__PURE__*/ uniformGroup( 'object' ); class UniformNode extends InputNode { @@ -26409,7 +26415,7 @@ class UniformNode extends InputNode { } -registerNodeClass( 'Uniform', UniformNode ); +UniformNode.type = /*@__PURE__*/ registerNode( 'Uniform', UniformNode ); const uniform = ( arg1, arg2 ) => { @@ -26468,39 +26474,39 @@ class PropertyNode extends Node { } -registerNodeClass( 'Property', PropertyNode ); +PropertyNode.type = /*@__PURE__*/ registerNode( 'Property', PropertyNode ); const property = ( type, name ) => nodeObject( new PropertyNode( type, name ) ); const varyingProperty = ( type, name ) => nodeObject( new PropertyNode( type, name, true ) ); -const diffuseColor = nodeImmutable( PropertyNode, 'vec4', 'DiffuseColor' ); -const emissive = nodeImmutable( PropertyNode, 'vec3', 'EmissiveColor' ); -const roughness = nodeImmutable( PropertyNode, 'float', 'Roughness' ); -const metalness = nodeImmutable( PropertyNode, 'float', 'Metalness' ); -const clearcoat = nodeImmutable( PropertyNode, 'float', 'Clearcoat' ); -const clearcoatRoughness = nodeImmutable( PropertyNode, 'float', 'ClearcoatRoughness' ); -const sheen = nodeImmutable( PropertyNode, 'vec3', 'Sheen' ); -const sheenRoughness = nodeImmutable( PropertyNode, 'float', 'SheenRoughness' ); -const iridescence = nodeImmutable( PropertyNode, 'float', 'Iridescence' ); -const iridescenceIOR = nodeImmutable( PropertyNode, 'float', 'IridescenceIOR' ); -const iridescenceThickness = nodeImmutable( PropertyNode, 'float', 'IridescenceThickness' ); -const alphaT = nodeImmutable( PropertyNode, 'float', 'AlphaT' ); -const anisotropy = nodeImmutable( PropertyNode, 'float', 'Anisotropy' ); -const anisotropyT = nodeImmutable( PropertyNode, 'vec3', 'AnisotropyT' ); -const anisotropyB = nodeImmutable( PropertyNode, 'vec3', 'AnisotropyB' ); -const specularColor = nodeImmutable( PropertyNode, 'color', 'SpecularColor' ); -const specularF90 = nodeImmutable( PropertyNode, 'float', 'SpecularF90' ); -const shininess = nodeImmutable( PropertyNode, 'float', 'Shininess' ); -const output = nodeImmutable( PropertyNode, 'vec4', 'Output' ); -const dashSize = nodeImmutable( PropertyNode, 'float', 'dashSize' ); -const gapSize = nodeImmutable( PropertyNode, 'float', 'gapSize' ); -const pointWidth = nodeImmutable( PropertyNode, 'float', 'pointWidth' ); -const ior = nodeImmutable( PropertyNode, 'float', 'IOR' ); -const transmission = nodeImmutable( PropertyNode, 'float', 'Transmission' ); -const thickness = nodeImmutable( PropertyNode, 'float', 'Thickness' ); -const attenuationDistance = nodeImmutable( PropertyNode, 'float', 'AttenuationDistance' ); -const attenuationColor = nodeImmutable( PropertyNode, 'color', 'AttenuationColor' ); -const dispersion = nodeImmutable( PropertyNode, 'float', 'Dispersion' ); +const diffuseColor = /*@__PURE__*/ nodeImmutable( PropertyNode, 'vec4', 'DiffuseColor' ); +const emissive = /*@__PURE__*/ nodeImmutable( PropertyNode, 'vec3', 'EmissiveColor' ); +const roughness = /*@__PURE__*/ nodeImmutable( PropertyNode, 'float', 'Roughness' ); +const metalness = /*@__PURE__*/ nodeImmutable( PropertyNode, 'float', 'Metalness' ); +const clearcoat = /*@__PURE__*/ nodeImmutable( PropertyNode, 'float', 'Clearcoat' ); +const clearcoatRoughness = /*@__PURE__*/ nodeImmutable( PropertyNode, 'float', 'ClearcoatRoughness' ); +const sheen = /*@__PURE__*/ nodeImmutable( PropertyNode, 'vec3', 'Sheen' ); +const sheenRoughness = /*@__PURE__*/ nodeImmutable( PropertyNode, 'float', 'SheenRoughness' ); +const iridescence = /*@__PURE__*/ nodeImmutable( PropertyNode, 'float', 'Iridescence' ); +const iridescenceIOR = /*@__PURE__*/ nodeImmutable( PropertyNode, 'float', 'IridescenceIOR' ); +const iridescenceThickness = /*@__PURE__*/ nodeImmutable( PropertyNode, 'float', 'IridescenceThickness' ); +const alphaT = /*@__PURE__*/ nodeImmutable( PropertyNode, 'float', 'AlphaT' ); +const anisotropy = /*@__PURE__*/ nodeImmutable( PropertyNode, 'float', 'Anisotropy' ); +const anisotropyT = /*@__PURE__*/ nodeImmutable( PropertyNode, 'vec3', 'AnisotropyT' ); +const anisotropyB = /*@__PURE__*/ nodeImmutable( PropertyNode, 'vec3', 'AnisotropyB' ); +const specularColor = /*@__PURE__*/ nodeImmutable( PropertyNode, 'color', 'SpecularColor' ); +const specularF90 = /*@__PURE__*/ nodeImmutable( PropertyNode, 'float', 'SpecularF90' ); +const shininess = /*@__PURE__*/ nodeImmutable( PropertyNode, 'float', 'Shininess' ); +const output = /*@__PURE__*/ nodeImmutable( PropertyNode, 'vec4', 'Output' ); +const dashSize = /*@__PURE__*/ nodeImmutable( PropertyNode, 'float', 'dashSize' ); +const gapSize = /*@__PURE__*/ nodeImmutable( PropertyNode, 'float', 'gapSize' ); +const pointWidth = /*@__PURE__*/ nodeImmutable( PropertyNode, 'float', 'pointWidth' ); +const ior = /*@__PURE__*/ nodeImmutable( PropertyNode, 'float', 'IOR' ); +const transmission = /*@__PURE__*/ nodeImmutable( PropertyNode, 'float', 'Transmission' ); +const thickness = /*@__PURE__*/ nodeImmutable( PropertyNode, 'float', 'Thickness' ); +const attenuationDistance = /*@__PURE__*/ nodeImmutable( PropertyNode, 'float', 'AttenuationDistance' ); +const attenuationColor = /*@__PURE__*/ nodeImmutable( PropertyNode, 'color', 'AttenuationColor' ); +const dispersion = /*@__PURE__*/ nodeImmutable( PropertyNode, 'float', 'Dispersion' ); class AssignNode extends TempNode { @@ -26618,9 +26624,9 @@ class AssignNode extends TempNode { } -registerNodeClass( 'Assign', AssignNode ); +AssignNode.type = /*@__PURE__*/ registerNode( 'Assign', AssignNode ); -const assign = nodeProxy( AssignNode ); +const assign = /*@__PURE__*/ nodeProxy( AssignNode ); addMethodChaining( 'assign', assign ); @@ -26703,7 +26709,7 @@ class FunctionCallNode extends TempNode { } -registerNodeClass( 'FunctionCall', FunctionCallNode ); +FunctionCallNode.type = /*@__PURE__*/ registerNode( 'FunctionCall', FunctionCallNode ); const call = ( func, ...params ) => { @@ -26970,29 +26976,29 @@ class OperatorNode extends TempNode { } -registerNodeClass( 'Operator', OperatorNode ); +OperatorNode.type = /*@__PURE__*/ registerNode( 'Operator', OperatorNode ); -const add = nodeProxy( OperatorNode, '+' ); -const sub = nodeProxy( OperatorNode, '-' ); -const mul = nodeProxy( OperatorNode, '*' ); -const div = nodeProxy( OperatorNode, '/' ); -const modInt = nodeProxy( OperatorNode, '%' ); -const equal = nodeProxy( OperatorNode, '==' ); -const notEqual = nodeProxy( OperatorNode, '!=' ); -const lessThan = nodeProxy( OperatorNode, '<' ); -const greaterThan = nodeProxy( OperatorNode, '>' ); -const lessThanEqual = nodeProxy( OperatorNode, '<=' ); -const greaterThanEqual = nodeProxy( OperatorNode, '>=' ); -const and = nodeProxy( OperatorNode, '&&' ); -const or = nodeProxy( OperatorNode, '||' ); -const not = nodeProxy( OperatorNode, '!' ); -const xor = nodeProxy( OperatorNode, '^^' ); -const bitAnd = nodeProxy( OperatorNode, '&' ); -const bitNot = nodeProxy( OperatorNode, '~' ); -const bitOr = nodeProxy( OperatorNode, '|' ); -const bitXor = nodeProxy( OperatorNode, '^' ); -const shiftLeft = nodeProxy( OperatorNode, '<<' ); -const shiftRight = nodeProxy( OperatorNode, '>>' ); +const add = /*@__PURE__*/ nodeProxy( OperatorNode, '+' ); +const sub = /*@__PURE__*/ nodeProxy( OperatorNode, '-' ); +const mul = /*@__PURE__*/ nodeProxy( OperatorNode, '*' ); +const div = /*@__PURE__*/ nodeProxy( OperatorNode, '/' ); +const modInt = /*@__PURE__*/ nodeProxy( OperatorNode, '%' ); +const equal = /*@__PURE__*/ nodeProxy( OperatorNode, '==' ); +const notEqual = /*@__PURE__*/ nodeProxy( OperatorNode, '!=' ); +const lessThan = /*@__PURE__*/ nodeProxy( OperatorNode, '<' ); +const greaterThan = /*@__PURE__*/ nodeProxy( OperatorNode, '>' ); +const lessThanEqual = /*@__PURE__*/ nodeProxy( OperatorNode, '<=' ); +const greaterThanEqual = /*@__PURE__*/ nodeProxy( OperatorNode, '>=' ); +const and = /*@__PURE__*/ nodeProxy( OperatorNode, '&&' ); +const or = /*@__PURE__*/ nodeProxy( OperatorNode, '||' ); +const not = /*@__PURE__*/ nodeProxy( OperatorNode, '!' ); +const xor = /*@__PURE__*/ nodeProxy( OperatorNode, '^^' ); +const bitAnd = /*@__PURE__*/ nodeProxy( OperatorNode, '&' ); +const bitNot = /*@__PURE__*/ nodeProxy( OperatorNode, '~' ); +const bitOr = /*@__PURE__*/ nodeProxy( OperatorNode, '|' ); +const bitXor = /*@__PURE__*/ nodeProxy( OperatorNode, '^' ); +const shiftLeft = /*@__PURE__*/ nodeProxy( OperatorNode, '<<' ); +const shiftRight = /*@__PURE__*/ nodeProxy( OperatorNode, '>>' ); addMethodChaining( 'add', add ); addMethodChaining( 'sub', sub ); @@ -27285,75 +27291,75 @@ MathNode.REFRACT = 'refract'; MathNode.SMOOTHSTEP = 'smoothstep'; MathNode.FACEFORWARD = 'faceforward'; -registerNodeClass( 'Math', MathNode ); - -const EPSILON = float( 1e-6 ); -const INFINITY = float( 1e6 ); -const PI = float( Math.PI ); -const PI2 = float( Math.PI * 2 ); - -const all = nodeProxy( MathNode, MathNode.ALL ); -const any = nodeProxy( MathNode, MathNode.ANY ); -const equals = nodeProxy( MathNode, MathNode.EQUALS ); - -const radians = nodeProxy( MathNode, MathNode.RADIANS ); -const degrees = nodeProxy( MathNode, MathNode.DEGREES ); -const exp = nodeProxy( MathNode, MathNode.EXP ); -const exp2 = nodeProxy( MathNode, MathNode.EXP2 ); -const log = nodeProxy( MathNode, MathNode.LOG ); -const log2 = nodeProxy( MathNode, MathNode.LOG2 ); -const sqrt = nodeProxy( MathNode, MathNode.SQRT ); -const inverseSqrt = nodeProxy( MathNode, MathNode.INVERSE_SQRT ); -const floor = nodeProxy( MathNode, MathNode.FLOOR ); -const ceil = nodeProxy( MathNode, MathNode.CEIL ); -const normalize = nodeProxy( MathNode, MathNode.NORMALIZE ); -const fract = nodeProxy( MathNode, MathNode.FRACT ); -const sin = nodeProxy( MathNode, MathNode.SIN ); -const cos = nodeProxy( MathNode, MathNode.COS ); -const tan = nodeProxy( MathNode, MathNode.TAN ); -const asin = nodeProxy( MathNode, MathNode.ASIN ); -const acos = nodeProxy( MathNode, MathNode.ACOS ); -const atan = nodeProxy( MathNode, MathNode.ATAN ); -const abs = nodeProxy( MathNode, MathNode.ABS ); -const sign = nodeProxy( MathNode, MathNode.SIGN ); -const length = nodeProxy( MathNode, MathNode.LENGTH ); -const negate = nodeProxy( MathNode, MathNode.NEGATE ); -const oneMinus = nodeProxy( MathNode, MathNode.ONE_MINUS ); -const dFdx = nodeProxy( MathNode, MathNode.DFDX ); -const dFdy = nodeProxy( MathNode, MathNode.DFDY ); -const round = nodeProxy( MathNode, MathNode.ROUND ); -const reciprocal = nodeProxy( MathNode, MathNode.RECIPROCAL ); -const trunc = nodeProxy( MathNode, MathNode.TRUNC ); -const fwidth = nodeProxy( MathNode, MathNode.FWIDTH ); -const bitcast = nodeProxy( MathNode, MathNode.BITCAST ); -const transpose = nodeProxy( MathNode, MathNode.TRANSPOSE ); - -const atan2 = nodeProxy( MathNode, MathNode.ATAN2 ); -const min$1 = nodeProxy( MathNode, MathNode.MIN ); -const max$1 = nodeProxy( MathNode, MathNode.MAX ); -const mod = nodeProxy( MathNode, MathNode.MOD ); -const step = nodeProxy( MathNode, MathNode.STEP ); -const reflect = nodeProxy( MathNode, MathNode.REFLECT ); -const distance = nodeProxy( MathNode, MathNode.DISTANCE ); -const difference = nodeProxy( MathNode, MathNode.DIFFERENCE ); -const dot = nodeProxy( MathNode, MathNode.DOT ); -const cross = nodeProxy( MathNode, MathNode.CROSS ); -const pow = nodeProxy( MathNode, MathNode.POW ); -const pow2 = nodeProxy( MathNode, MathNode.POW, 2 ); -const pow3 = nodeProxy( MathNode, MathNode.POW, 3 ); -const pow4 = nodeProxy( MathNode, MathNode.POW, 4 ); -const transformDirection = nodeProxy( MathNode, MathNode.TRANSFORM_DIRECTION ); +MathNode.type = /*@__PURE__*/ registerNode( 'Math', MathNode ); + +const EPSILON = /*@__PURE__*/ float( 1e-6 ); +const INFINITY = /*@__PURE__*/ float( 1e6 ); +const PI = /*@__PURE__*/ float( Math.PI ); +const PI2 = /*@__PURE__*/ float( Math.PI * 2 ); + +const all = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ALL ); +const any = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ANY ); +const equals = /*@__PURE__*/ nodeProxy( MathNode, MathNode.EQUALS ); + +const radians = /*@__PURE__*/ nodeProxy( MathNode, MathNode.RADIANS ); +const degrees = /*@__PURE__*/ nodeProxy( MathNode, MathNode.DEGREES ); +const exp = /*@__PURE__*/ nodeProxy( MathNode, MathNode.EXP ); +const exp2 = /*@__PURE__*/ nodeProxy( MathNode, MathNode.EXP2 ); +const log = /*@__PURE__*/ nodeProxy( MathNode, MathNode.LOG ); +const log2 = /*@__PURE__*/ nodeProxy( MathNode, MathNode.LOG2 ); +const sqrt = /*@__PURE__*/ nodeProxy( MathNode, MathNode.SQRT ); +const inverseSqrt = /*@__PURE__*/ nodeProxy( MathNode, MathNode.INVERSE_SQRT ); +const floor = /*@__PURE__*/ nodeProxy( MathNode, MathNode.FLOOR ); +const ceil = /*@__PURE__*/ nodeProxy( MathNode, MathNode.CEIL ); +const normalize = /*@__PURE__*/ nodeProxy( MathNode, MathNode.NORMALIZE ); +const fract = /*@__PURE__*/ nodeProxy( MathNode, MathNode.FRACT ); +const sin = /*@__PURE__*/ nodeProxy( MathNode, MathNode.SIN ); +const cos = /*@__PURE__*/ nodeProxy( MathNode, MathNode.COS ); +const tan = /*@__PURE__*/ nodeProxy( MathNode, MathNode.TAN ); +const asin = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ASIN ); +const acos = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ACOS ); +const atan = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ATAN ); +const abs = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ABS ); +const sign = /*@__PURE__*/ nodeProxy( MathNode, MathNode.SIGN ); +const length = /*@__PURE__*/ nodeProxy( MathNode, MathNode.LENGTH ); +const negate = /*@__PURE__*/ nodeProxy( MathNode, MathNode.NEGATE ); +const oneMinus = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ONE_MINUS ); +const dFdx = /*@__PURE__*/ nodeProxy( MathNode, MathNode.DFDX ); +const dFdy = /*@__PURE__*/ nodeProxy( MathNode, MathNode.DFDY ); +const round = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ROUND ); +const reciprocal = /*@__PURE__*/ nodeProxy( MathNode, MathNode.RECIPROCAL ); +const trunc = /*@__PURE__*/ nodeProxy( MathNode, MathNode.TRUNC ); +const fwidth = /*@__PURE__*/ nodeProxy( MathNode, MathNode.FWIDTH ); +const bitcast = /*@__PURE__*/ nodeProxy( MathNode, MathNode.BITCAST ); +const transpose = /*@__PURE__*/ nodeProxy( MathNode, MathNode.TRANSPOSE ); + +const atan2 = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ATAN2 ); +const min$1 = /*@__PURE__*/ nodeProxy( MathNode, MathNode.MIN ); +const max$1 = /*@__PURE__*/ nodeProxy( MathNode, MathNode.MAX ); +const mod = /*@__PURE__*/ nodeProxy( MathNode, MathNode.MOD ); +const step = /*@__PURE__*/ nodeProxy( MathNode, MathNode.STEP ); +const reflect = /*@__PURE__*/ nodeProxy( MathNode, MathNode.REFLECT ); +const distance = /*@__PURE__*/ nodeProxy( MathNode, MathNode.DISTANCE ); +const difference = /*@__PURE__*/ nodeProxy( MathNode, MathNode.DIFFERENCE ); +const dot = /*@__PURE__*/ nodeProxy( MathNode, MathNode.DOT ); +const cross = /*@__PURE__*/ nodeProxy( MathNode, MathNode.CROSS ); +const pow = /*@__PURE__*/ nodeProxy( MathNode, MathNode.POW ); +const pow2 = /*@__PURE__*/ nodeProxy( MathNode, MathNode.POW, 2 ); +const pow3 = /*@__PURE__*/ nodeProxy( MathNode, MathNode.POW, 3 ); +const pow4 = /*@__PURE__*/ nodeProxy( MathNode, MathNode.POW, 4 ); +const transformDirection = /*@__PURE__*/ nodeProxy( MathNode, MathNode.TRANSFORM_DIRECTION ); const cbrt = ( a ) => mul( sign( a ), pow( abs( a ), 1.0 / 3.0 ) ); const lengthSq = ( a ) => dot( a, a ); -const mix = nodeProxy( MathNode, MathNode.MIX ); +const mix = /*@__PURE__*/ nodeProxy( MathNode, MathNode.MIX ); const clamp = ( value, low = 0, high = 1 ) => nodeObject( new MathNode( MathNode.CLAMP, nodeObject( value ), nodeObject( low ), nodeObject( high ) ) ); const saturate = ( value ) => clamp( value ); -const refract = nodeProxy( MathNode, MathNode.REFRACT ); -const smoothstep = nodeProxy( MathNode, MathNode.SMOOTHSTEP ); -const faceForward = nodeProxy( MathNode, MathNode.FACEFORWARD ); +const refract = /*@__PURE__*/ nodeProxy( MathNode, MathNode.REFRACT ); +const smoothstep = /*@__PURE__*/ nodeProxy( MathNode, MathNode.SMOOTHSTEP ); +const faceForward = /*@__PURE__*/ nodeProxy( MathNode, MathNode.FACEFORWARD ); -const rand = Fn( ( [ uv ] ) => { +const rand = /*@__PURE__*/ Fn( ( [ uv ] ) => { const a = 12.9898, b = 78.233, c = 43758.5453; const dt = dot( uv.xy, vec2( a, b ) ), sn = mod( dt, PI ); @@ -27541,9 +27547,9 @@ class ConditionalNode extends Node { } -registerNodeClass( 'Conditional', ConditionalNode ); +ConditionalNode.type = /*@__PURE__*/ registerNode( 'Conditional', ConditionalNode ); -const select = nodeProxy( ConditionalNode ); +const select = /*@__PURE__*/ nodeProxy( ConditionalNode ); addMethodChaining( 'select', select ); @@ -27619,9 +27625,9 @@ class ContextNode extends Node { } -registerNodeClass( 'Context', ContextNode ); +ContextNode.type = /*@__PURE__*/ registerNode( 'Context', ContextNode ); -const context = nodeProxy( ContextNode ); +const context = /*@__PURE__*/ nodeProxy( ContextNode ); const label = ( node, name ) => context( node, { label: name } ); addMethodChaining( 'context', context ); @@ -27672,9 +27678,9 @@ class VarNode extends Node { } -registerNodeClass( 'Var', VarNode ); +VarNode.type = /*@__PURE__*/ registerNode( 'Var', VarNode ); -const temp = nodeProxy( VarNode ); +const temp = /*@__PURE__*/ nodeProxy( VarNode ); addMethodChaining( 'temp', temp ); // @TODO: Will be removed in the future addMethodChaining( 'toVar', ( ...params ) => temp( ...params ).append() ); @@ -27772,9 +27778,9 @@ class VaryingNode extends Node { } -registerNodeClass( 'Varying', VaryingNode ); +VaryingNode.type = /*@__PURE__*/ registerNode( 'Varying', VaryingNode ); -const varying = nodeProxy( VaryingNode ); +const varying = /*@__PURE__*/ nodeProxy( VaryingNode ); addMethodChaining( 'varying', varying ); @@ -27804,28 +27810,31 @@ const getColorSpaceMethod = ( source, target ) => { class ColorSpaceNode extends TempNode { - constructor( colorSpace, colorNode ) { + constructor( colorNode, target = null, source = null ) { super( 'vec4' ); - this.colorSpace = colorSpace; this.colorNode = colorNode; + this.target = target; + this.source = source; } setup( builder ) { - const { colorSpace, colorNode } = this; + const { renderer, context } = builder; - if ( colorSpace === ColorSpaceNode.LINEAR_TO_LINEAR ) { + const source = this.source || context.outputColorSpace || renderer.outputColorSpace; + const target = this.target || context.outputColorSpace || renderer.outputColorSpace; + const colorNode = this.colorNode; - return colorNode; + if ( source === target ) return colorNode; - } + const colorSpace = getColorSpaceMethod( source, target ); let outputNode = null; - const colorSpaceFn = builder.renderer.nodes.library.getColorSpaceFunction( colorSpace ); + const colorSpaceFn = renderer.nodes.library.getColorSpaceFunction( colorSpace ); if ( colorSpaceFn !== null ) { @@ -27845,15 +27854,13 @@ class ColorSpaceNode extends TempNode { } -ColorSpaceNode.LINEAR_TO_LINEAR = 'LinearToLinear'; +ColorSpaceNode.type = /*@__PURE__*/ registerNode( 'ColorSpace', ColorSpaceNode ); -registerNodeClass( 'ColorSpace', ColorSpaceNode ); +const linearSRGBToColorSpace = ( node, colorSpace = null ) => nodeObject( new ColorSpaceNode( nodeObject( node ), colorSpace, LinearSRGBColorSpace ) ); +const colorSpaceToLinearSRGB = ( node, colorSpace = null ) => nodeObject( new ColorSpaceNode( nodeObject( node ), LinearSRGBColorSpace, colorSpace ) ); -const linearToColorSpace = ( node, colorSpace ) => nodeObject( new ColorSpaceNode( getColorSpaceMethod( LinearSRGBColorSpace, colorSpace ), nodeObject( node ) ) ); -const colorSpaceToLinear = ( node, colorSpace ) => nodeObject( new ColorSpaceNode( getColorSpaceMethod( colorSpace, LinearSRGBColorSpace ), nodeObject( node ) ) ); - -addMethodChaining( 'linearToColorSpace', linearToColorSpace ); -addMethodChaining( 'colorSpaceToLinear', colorSpaceToLinear ); +addMethodChaining( 'linearSRGBToColorSpace', linearSRGBToColorSpace ); +addMethodChaining( 'colorSpaceToLinearSRGB', colorSpaceToLinearSRGB ); let ReferenceElementNode$1 = class ReferenceElementNode extends ArrayElementNode { @@ -27986,7 +27993,7 @@ class ReferenceBaseNode extends Node { } -registerNodeClass( 'ReferenceBase', ReferenceBaseNode ); +ReferenceBaseNode.type = /*@__PURE__*/ registerNode( 'ReferenceBase', ReferenceBaseNode ); class RendererReferenceNode extends ReferenceBaseNode { @@ -28008,7 +28015,7 @@ class RendererReferenceNode extends ReferenceBaseNode { } -registerNodeClass( 'RendererReference', RendererReferenceNode ); +RendererReferenceNode.type = /*@__PURE__*/ registerNode( 'RendererReference', RendererReferenceNode ); const rendererReference = ( name, type, renderer ) => nodeObject( new RendererReferenceNode( name, type, renderer ) ); @@ -28063,7 +28070,7 @@ class ToneMappingNode extends TempNode { } -registerNodeClass( 'ToneMapping', ToneMappingNode ); +ToneMappingNode.type = /*@__PURE__*/ registerNode( 'ToneMapping', ToneMappingNode ); const toneMapping = ( mapping, exposure, color ) => nodeObject( new ToneMappingNode( mapping, nodeObject( exposure ), nodeObject( color ) ) ); const toneMappingExposure = /*@__PURE__*/ rendererReference( 'toneMappingExposure', 'float' ); @@ -28212,7 +28219,7 @@ class BufferAttributeNode extends InputNode { } -registerNodeClass( 'BufferAttribute', BufferAttributeNode ); +BufferAttributeNode.type = /*@__PURE__*/ registerNode( 'BufferAttribute', BufferAttributeNode ); const bufferAttribute = ( array, type, stride, offset ) => nodeObject( new BufferAttributeNode( array, type, stride, offset ) ); const dynamicBufferAttribute = ( array, type, stride, offset ) => bufferAttribute( array, type, stride, offset ).setUsage( DynamicDrawUsage ); @@ -28296,7 +28303,7 @@ class ComputeNode extends Node { } -registerNodeClass( 'Compute', ComputeNode ); +ComputeNode.type = /*@__PURE__*/ registerNode( 'Compute', ComputeNode ); const compute = ( node, count, workgroupSize ) => nodeObject( new ComputeNode( nodeObject( node ), count, workgroupSize ) ); @@ -28338,7 +28345,7 @@ class CacheNode extends Node { } -registerNodeClass( 'Cache', CacheNode ); +CacheNode.type = /*@__PURE__*/ registerNode( 'Cache', CacheNode ); const cache = ( node, ...params ) => nodeObject( new CacheNode( nodeObject( node ), ...params ) ); @@ -28379,9 +28386,9 @@ class BypassNode extends Node { } -registerNodeClass( 'Bypass', BypassNode ); +BypassNode.type = /*@__PURE__*/ registerNode( 'Bypass', BypassNode ); -const bypass = nodeProxy( BypassNode ); +const bypass = /*@__PURE__*/ nodeProxy( BypassNode ); addMethodChaining( 'bypass', bypass ); @@ -28415,10 +28422,10 @@ class RemapNode extends Node { } -registerNodeClass( 'Remap', RemapNode ); +RemapNode.type = /*@__PURE__*/ registerNode( 'Remap', RemapNode ); -const remap = nodeProxy( RemapNode, null, null, { doClamp: false } ); -const remapClamp = nodeProxy( RemapNode ); +const remap = /*@__PURE__*/ nodeProxy( RemapNode, null, null, { doClamp: false } ); +const remapClamp = /*@__PURE__*/ nodeProxy( RemapNode ); addMethodChaining( 'remap', remap ); addMethodChaining( 'remapClamp', remapClamp ); @@ -28452,9 +28459,9 @@ class ExpressionNode extends Node { } -registerNodeClass( 'Expression', ExpressionNode ); +ExpressionNode.type = /*@__PURE__*/ registerNode( 'Expression', ExpressionNode ); -const expression = nodeProxy( ExpressionNode ); +const expression = /*@__PURE__*/ nodeProxy( ExpressionNode ); const Discard = ( conditional ) => ( conditional ? select( conditional, expression( 'discard' ) ) : expression( 'discard' ) ).append(); const Return = () => expression( 'return' ).append(); @@ -28494,7 +28501,7 @@ class RenderOutputNode extends TempNode { if ( outputColorSpace === SRGBColorSpace ) { - outputNode = outputNode.linearToColorSpace( outputColorSpace ); + outputNode = outputNode.linearSRGBToColorSpace( outputColorSpace ); } @@ -28504,7 +28511,7 @@ class RenderOutputNode extends TempNode { } -registerNodeClass( 'RenderOutput', RenderOutputNode ); +RenderOutputNode.type = /*@__PURE__*/ registerNode( 'RenderOutput', RenderOutputNode ); const renderOutput = ( color, toneMapping = null, outputColorSpace = null ) => nodeObject( new RenderOutputNode( nodeObject( color ), toneMapping, outputColorSpace ) ); @@ -28633,7 +28640,7 @@ class AttributeNode extends Node { } -registerNodeClass( 'Attribute', AttributeNode ); +AttributeNode.type = /*@__PURE__*/ registerNode( 'Attribute', AttributeNode ); const attribute = ( name, nodeType ) => nodeObject( new AttributeNode( name, nodeType ) ); @@ -28663,9 +28670,9 @@ class TextureSizeNode extends Node { } -registerNodeClass( 'TextureSize', TextureSizeNode ); +TextureSizeNode.type = /*@__PURE__*/ registerNode( 'TextureSize', TextureSizeNode ); -const textureSize = nodeProxy( TextureSizeNode ); +const textureSize = /*@__PURE__*/ nodeProxy( TextureSizeNode ); class MaxMipLevelNode extends UniformNode { @@ -28709,9 +28716,9 @@ class MaxMipLevelNode extends UniformNode { } -registerNodeClass( 'MaxMipLevel', MaxMipLevelNode ); +MaxMipLevelNode.type = /*@__PURE__*/ registerNode( 'MaxMipLevel', MaxMipLevelNode ); -const maxMipLevel = nodeProxy( MaxMipLevelNode ); +const maxMipLevel = /*@__PURE__*/ nodeProxy( MaxMipLevelNode ); class TextureNode extends UniformNode { @@ -28977,9 +28984,9 @@ class TextureNode extends UniformNode { let snippet = propertyName; const nodeType = this.getNodeType( builder ); - if ( builder.needsColorSpaceToLinear( texture ) ) { + if ( builder.needsColorSpaceToLinearSRGB( texture ) ) { - snippet = colorSpaceToLinear( expression( snippet, nodeType ), texture.colorSpace ).setup( builder ).build( builder, nodeType ); + snippet = colorSpaceToLinearSRGB( expression( snippet, nodeType ), texture.colorSpace ).setup( builder ).build( builder, nodeType ); } @@ -29131,30 +29138,30 @@ class TextureNode extends UniformNode { } -registerNodeClass( 'Texture', TextureNode ); +TextureNode.type = /*@__PURE__*/ registerNode( 'Texture', TextureNode ); -const texture = nodeProxy( TextureNode ); +const texture = /*@__PURE__*/ nodeProxy( TextureNode ); const textureLoad = ( ...params ) => texture( ...params ).setSampler( false ); //export const textureLevel = ( value, uv, level ) => texture( value, uv ).level( level ); const sampler = ( aTexture ) => ( aTexture.isNode === true ? aTexture : texture( aTexture ) ).convert( 'sampler' ); -const cameraGroup = /*#__PURE__*/ sharedUniformGroup( 'camera' ).onRenderUpdate( () => { +const cameraGroup = /*@__PURE__*/ sharedUniformGroup( 'camera' ).onRenderUpdate( () => { cameraGroup.needsUpdate = true; } ); -const cameraNear = /*#__PURE__*/ uniform( 'float' ).label( 'cameraNear' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.near ); -const cameraFar = /*#__PURE__*/ uniform( 'float' ).label( 'cameraFar' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.far ); -const cameraLogDepth = /*#__PURE__*/ uniform( 'float' ).label( 'cameraLogDepth' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => 2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) ); -const cameraProjectionMatrix = /*#__PURE__*/ uniform( 'mat4' ).label( 'cameraProjectionMatrix' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.projectionMatrix ); -const cameraProjectionMatrixInverse = /*#__PURE__*/ uniform( 'mat4' ).label( 'cameraProjectionMatrixInverse' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.projectionMatrixInverse ); -const cameraViewMatrix = /*#__PURE__*/ uniform( 'mat4' ).label( 'cameraViewMatrix' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.matrixWorldInverse ); -const cameraWorldMatrix = /*#__PURE__*/ uniform( 'mat4' ).label( 'cameraWorldMatrix' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.matrixWorld ); -const cameraNormalMatrix = /*#__PURE__*/ uniform( 'mat3' ).label( 'cameraNormalMatrix' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.normalMatrix ); -const cameraPosition = /*#__PURE__*/ uniform( new Vector3() ).label( 'cameraPosition' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera }, self ) => self.value.setFromMatrixPosition( camera.matrixWorld ) ); +const cameraNear = /*@__PURE__*/ uniform( 'float' ).label( 'cameraNear' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.near ); +const cameraFar = /*@__PURE__*/ uniform( 'float' ).label( 'cameraFar' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.far ); +const cameraLogDepth = /*@__PURE__*/ uniform( 'float' ).label( 'cameraLogDepth' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => 2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) ); +const cameraProjectionMatrix = /*@__PURE__*/ uniform( 'mat4' ).label( 'cameraProjectionMatrix' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.projectionMatrix ); +const cameraProjectionMatrixInverse = /*@__PURE__*/ uniform( 'mat4' ).label( 'cameraProjectionMatrixInverse' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.projectionMatrixInverse ); +const cameraViewMatrix = /*@__PURE__*/ uniform( 'mat4' ).label( 'cameraViewMatrix' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.matrixWorldInverse ); +const cameraWorldMatrix = /*@__PURE__*/ uniform( 'mat4' ).label( 'cameraWorldMatrix' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.matrixWorld ); +const cameraNormalMatrix = /*@__PURE__*/ uniform( 'mat3' ).label( 'cameraNormalMatrix' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera } ) => camera.normalMatrix ); +const cameraPosition = /*@__PURE__*/ uniform( new Vector3() ).label( 'cameraPosition' ).setGroup( cameraGroup ).onRenderUpdate( ( { camera }, self ) => self.value.setFromMatrixPosition( camera.matrixWorld ) ); class Object3DNode extends Node { @@ -29288,15 +29295,15 @@ Object3DNode.SCALE = 'scale'; Object3DNode.VIEW_POSITION = 'viewPosition'; Object3DNode.DIRECTION = 'direction'; -registerNodeClass( 'Object3D', Object3DNode ); +Object3DNode.type = /*@__PURE__*/ registerNode( 'Object3D', Object3DNode ); -const objectDirection = nodeProxy( Object3DNode, Object3DNode.DIRECTION ); -const objectViewMatrix = nodeProxy( Object3DNode, Object3DNode.VIEW_MATRIX ); -const objectNormalMatrix = nodeProxy( Object3DNode, Object3DNode.NORMAL_MATRIX ); -const objectWorldMatrix = nodeProxy( Object3DNode, Object3DNode.WORLD_MATRIX ); -const objectPosition = nodeProxy( Object3DNode, Object3DNode.POSITION ); -const objectScale = nodeProxy( Object3DNode, Object3DNode.SCALE ); -const objectViewPosition = nodeProxy( Object3DNode, Object3DNode.VIEW_POSITION ); +const objectDirection = /*@__PURE__*/ nodeProxy( Object3DNode, Object3DNode.DIRECTION ); +const objectViewMatrix = /*@__PURE__*/ nodeProxy( Object3DNode, Object3DNode.VIEW_MATRIX ); +const objectNormalMatrix = /*@__PURE__*/ nodeProxy( Object3DNode, Object3DNode.NORMAL_MATRIX ); +const objectWorldMatrix = /*@__PURE__*/ nodeProxy( Object3DNode, Object3DNode.WORLD_MATRIX ); +const objectPosition = /*@__PURE__*/ nodeProxy( Object3DNode, Object3DNode.POSITION ); +const objectScale = /*@__PURE__*/ nodeProxy( Object3DNode, Object3DNode.SCALE ); +const objectViewPosition = /*@__PURE__*/ nodeProxy( Object3DNode, Object3DNode.VIEW_POSITION ); class ModelNode extends Object3DNode { @@ -29316,24 +29323,24 @@ class ModelNode extends Object3DNode { } -registerNodeClass( 'Model', ModelNode ); +ModelNode.type = /*@__PURE__*/ registerNode( 'Model', ModelNode ); -const modelDirection = nodeImmutable( ModelNode, ModelNode.DIRECTION ); -const modelViewMatrix = nodeImmutable( ModelNode, ModelNode.VIEW_MATRIX ).label( 'modelViewMatrix' ).toVar( 'ModelViewMatrix' ); -const modelNormalMatrix = nodeImmutable( ModelNode, ModelNode.NORMAL_MATRIX ); -const modelWorldMatrix = nodeImmutable( ModelNode, ModelNode.WORLD_MATRIX ); -const modelPosition = nodeImmutable( ModelNode, ModelNode.POSITION ); -const modelScale = nodeImmutable( ModelNode, ModelNode.SCALE ); -const modelViewPosition = nodeImmutable( ModelNode, ModelNode.VIEW_POSITION ); -const modelWorldMatrixInverse = uniform( new Matrix4() ).onObjectUpdate( ( { object }, self ) => self.value.copy( object.matrixWorld ).invert() ); +const modelDirection = /*@__PURE__*/ nodeImmutable( ModelNode, ModelNode.DIRECTION ); +const modelViewMatrix = /*@__PURE__*/ nodeImmutable( ModelNode, ModelNode.VIEW_MATRIX ).label( 'modelViewMatrix' ).toVar( 'ModelViewMatrix' ); +const modelNormalMatrix = /*@__PURE__*/ nodeImmutable( ModelNode, ModelNode.NORMAL_MATRIX ); +const modelWorldMatrix = /*@__PURE__*/ nodeImmutable( ModelNode, ModelNode.WORLD_MATRIX ); +const modelPosition = /*@__PURE__*/ nodeImmutable( ModelNode, ModelNode.POSITION ); +const modelScale = /*@__PURE__*/ nodeImmutable( ModelNode, ModelNode.SCALE ); +const modelViewPosition = /*@__PURE__*/ nodeImmutable( ModelNode, ModelNode.VIEW_POSITION ); +const modelWorldMatrixInverse = /*@__PURE__*/ uniform( new Matrix4() ).onObjectUpdate( ( { object }, self ) => self.value.copy( object.matrixWorld ).invert() ); -const positionGeometry = /*#__PURE__*/ attribute( 'position', 'vec3' ); -const positionLocal = /*#__PURE__*/ positionGeometry.varying( 'positionLocal' ); -const positionPrevious = /*#__PURE__*/ positionGeometry.varying( 'positionPrevious' ); -const positionWorld = /*#__PURE__*/ modelWorldMatrix.mul( positionLocal ).xyz.varying( 'v_positionWorld' ); -const positionWorldDirection = /*#__PURE__*/ positionLocal.transformDirection( modelWorldMatrix ).varying( 'v_positionWorldDirection' ).normalize().toVar( 'positionWorldDirection' ); -const positionView = /*#__PURE__*/ modelViewMatrix.mul( positionLocal ).xyz.varying( 'v_positionView' ); -const positionViewDirection = /*#__PURE__*/ positionView.negate().varying( 'v_positionViewDirection' ).normalize().toVar( 'positionViewDirection' ); +const positionGeometry = /*@__PURE__*/ attribute( 'position', 'vec3' ); +const positionLocal = /*@__PURE__*/ positionGeometry.varying( 'positionLocal' ); +const positionPrevious = /*@__PURE__*/ positionGeometry.varying( 'positionPrevious' ); +const positionWorld = /*@__PURE__*/ modelWorldMatrix.mul( positionLocal ).xyz.varying( 'v_positionWorld' ); +const positionWorldDirection = /*@__PURE__*/ positionLocal.transformDirection( modelWorldMatrix ).varying( 'v_positionWorldDirection' ).normalize().toVar( 'positionWorldDirection' ); +const positionView = /*@__PURE__*/ modelViewMatrix.mul( positionLocal ).xyz.varying( 'v_positionView' ); +const positionViewDirection = /*@__PURE__*/ positionView.negate().varying( 'v_positionViewDirection' ).normalize().toVar( 'positionViewDirection' ); class FrontFacingNode extends Node { @@ -29365,14 +29372,14 @@ class FrontFacingNode extends Node { } -registerNodeClass( 'FrontFacing', FrontFacingNode ); +FrontFacingNode.type = /*@__PURE__*/ registerNode( 'FrontFacing', FrontFacingNode ); -const frontFacing = nodeImmutable( FrontFacingNode ); -const faceDirection = float( frontFacing ).mul( 2.0 ).sub( 1.0 ); +const frontFacing = /*@__PURE__*/ nodeImmutable( FrontFacingNode ); +const faceDirection = /*@__PURE__*/ float( frontFacing ).mul( 2.0 ).sub( 1.0 ); -const normalGeometry = /*#__PURE__*/ attribute( 'normal', 'vec3' ); +const normalGeometry = /*@__PURE__*/ attribute( 'normal', 'vec3' ); -const normalLocal = /*#__PURE__*/ ( Fn( ( builder ) => { +const normalLocal = /*@__PURE__*/ ( Fn( ( builder ) => { if ( builder.geometry.hasAttribute( 'normal' ) === false ) { @@ -29386,11 +29393,11 @@ const normalLocal = /*#__PURE__*/ ( Fn( ( builder ) => { }, 'vec3' ).once() )().toVar( 'normalLocal' ); -const normalFlat = /*#__PURE__*/ positionView.dFdx().cross( positionView.dFdy() ).normalize().toVar( 'normalFlat' ); +const normalFlat = /*@__PURE__*/ positionView.dFdx().cross( positionView.dFdy() ).normalize().toVar( 'normalFlat' ); let normalViewVarying = null; -const normalView = /*#__PURE__*/ ( Fn( ( builder ) => { +const normalView = /*@__PURE__*/ ( Fn( ( builder ) => { let node; @@ -29408,18 +29415,18 @@ const normalView = /*#__PURE__*/ ( Fn( ( builder ) => { }, 'vec3' ).once() )().toVar( 'normalView' ); -const normalWorld = /*#__PURE__*/ varying( normalView.transformDirection( cameraViewMatrix ), 'v_normalWorld' ).normalize().toVar( 'normalWorld' ); +const normalWorld = /*@__PURE__*/ varying( normalView.transformDirection( cameraViewMatrix ), 'v_normalWorld' ).normalize().toVar( 'normalWorld' ); -const transformedNormalView = /*#__PURE__*/ ( Fn( ( builder ) => { +const transformedNormalView = /*@__PURE__*/ ( Fn( ( builder ) => { return builder.context.setupNormal(); }, 'vec3' ).once() )().mul( faceDirection ).toVar( 'transformedNormalView' ); -const transformedNormalWorld = /*#__PURE__*/ transformedNormalView.transformDirection( cameraViewMatrix ).normalize().toVar( 'transformedNormalWorld' ); +const transformedNormalWorld = /*@__PURE__*/ transformedNormalView.transformDirection( cameraViewMatrix ).normalize().toVar( 'transformedNormalWorld' ); -const transformedClearcoatNormalView = /*#__PURE__*/ ( Fn( ( builder ) => { +const transformedClearcoatNormalView = /*@__PURE__*/ ( Fn( ( builder ) => { return builder.context.setupClearcoatNormal(); @@ -29427,11 +29434,11 @@ const transformedClearcoatNormalView = /*#__PURE__*/ ( Fn( ( builder ) => { const materialRefractionRatio = /*@__PURE__*/ uniform( 0 ).onReference( ( { material } ) => material ).onRenderUpdate( ( { material } ) => material.refractionRatio ); -const reflectView = /*#__PURE__*/ positionViewDirection.negate().reflect( transformedNormalView ); -const refractView = /*#__PURE__*/ positionViewDirection.negate().refract( transformedNormalView, materialRefractionRatio ); +const reflectView = /*@__PURE__*/ positionViewDirection.negate().reflect( transformedNormalView ); +const refractView = /*@__PURE__*/ positionViewDirection.negate().refract( transformedNormalView, materialRefractionRatio ); -const reflectVector = /*#__PURE__*/ reflectView.transformDirection( cameraViewMatrix ).toVar( 'reflectVector' ); -const refractVector = /*#__PURE__*/ refractView.transformDirection( cameraViewMatrix ).toVar( 'reflectVector' ); +const reflectVector = /*@__PURE__*/ reflectView.transformDirection( cameraViewMatrix ).toVar( 'reflectVector' ); +const refractVector = /*@__PURE__*/ refractView.transformDirection( cameraViewMatrix ).toVar( 'reflectVector' ); class CubeTextureNode extends TextureNode { @@ -29497,9 +29504,9 @@ class CubeTextureNode extends TextureNode { } -registerNodeClass( 'CubeTexture', CubeTextureNode ); +CubeTextureNode.type = /*@__PURE__*/ registerNode( 'CubeTexture', CubeTextureNode ); -const cubeTexture = nodeProxy( CubeTextureNode ); +const cubeTexture = /*@__PURE__*/ nodeProxy( CubeTextureNode ); class BufferNode extends UniformNode { @@ -29528,7 +29535,7 @@ class BufferNode extends UniformNode { } -registerNodeClass( 'Buffer', BufferNode ); +BufferNode.type = /*@__PURE__*/ registerNode( 'Buffer', BufferNode ); const buffer = ( value, type, count ) => nodeObject( new BufferNode( value, type, count ) ); @@ -29666,7 +29673,7 @@ class UniformArrayNode extends BufferNode { } -registerNodeClass( 'UniformArray', UniformArrayNode ); +UniformArrayNode.type = /*@__PURE__*/ registerNode( 'UniformArray', UniformArrayNode ); const uniformArray = ( values, nodeType ) => nodeObject( new UniformArrayNode( values, nodeType ) ); @@ -29826,7 +29833,7 @@ class ReferenceNode extends Node { } -registerNodeClass( 'Reference', ReferenceNode ); +ReferenceNode.type = /*@__PURE__*/ registerNode( 'Reference', ReferenceNode ); const reference = ( name, type, object ) => nodeObject( new ReferenceNode( name, type, object ) ); const referenceBuffer = ( name, type, count, object ) => nodeObject( new ReferenceNode( name, type, object, count ) ); @@ -29863,11 +29870,11 @@ class MaterialReferenceNode extends ReferenceNode { } -registerNodeClass( 'MaterialReference', MaterialReferenceNode ); +MaterialReferenceNode.type = /*@__PURE__*/ registerNode( 'MaterialReference', MaterialReferenceNode ); const materialReference = ( name, type, material ) => nodeObject( new MaterialReferenceNode( name, type, material ) ); -const tangentGeometry = /*#__PURE__*/ Fn( ( builder ) => { +const tangentGeometry = /*@__PURE__*/ Fn( ( builder ) => { if ( builder.geometry.hasAttribute( 'tangent' ) === false ) { @@ -29879,27 +29886,27 @@ const tangentGeometry = /*#__PURE__*/ Fn( ( builder ) => { } )(); -const tangentLocal = /*#__PURE__*/ tangentGeometry.xyz.toVar( 'tangentLocal' ); -const tangentView = /*#__PURE__*/ modelViewMatrix.mul( vec4( tangentLocal, 0 ) ).xyz.varying( 'v_tangentView' ).normalize().toVar( 'tangentView' ); -const tangentWorld = /*#__PURE__*/ tangentView.transformDirection( cameraViewMatrix ).varying( 'v_tangentWorld' ).normalize().toVar( 'tangentWorld' ); -const transformedTangentView = /*#__PURE__*/ tangentView.toVar( 'transformedTangentView' ); -const transformedTangentWorld = /*#__PURE__*/ transformedTangentView.transformDirection( cameraViewMatrix ).normalize().toVar( 'transformedTangentWorld' ); +const tangentLocal = /*@__PURE__*/ tangentGeometry.xyz.toVar( 'tangentLocal' ); +const tangentView = /*@__PURE__*/ modelViewMatrix.mul( vec4( tangentLocal, 0 ) ).xyz.varying( 'v_tangentView' ).normalize().toVar( 'tangentView' ); +const tangentWorld = /*@__PURE__*/ tangentView.transformDirection( cameraViewMatrix ).varying( 'v_tangentWorld' ).normalize().toVar( 'tangentWorld' ); +const transformedTangentView = /*@__PURE__*/ tangentView.toVar( 'transformedTangentView' ); +const transformedTangentWorld = /*@__PURE__*/ transformedTangentView.transformDirection( cameraViewMatrix ).normalize().toVar( 'transformedTangentWorld' ); const getBitangent = ( crossNormalTangent ) => crossNormalTangent.mul( tangentGeometry.w ).xyz; -const bitangentGeometry = /*#__PURE__*/ varying( getBitangent( normalGeometry.cross( tangentGeometry ) ), 'v_bitangentGeometry' ).normalize().toVar( 'bitangentGeometry' ); -const bitangentLocal = /*#__PURE__*/ varying( getBitangent( normalLocal.cross( tangentLocal ) ), 'v_bitangentLocal' ).normalize().toVar( 'bitangentLocal' ); -const bitangentView = /*#__PURE__*/ varying( getBitangent( normalView.cross( tangentView ) ), 'v_bitangentView' ).normalize().toVar( 'bitangentView' ); -const bitangentWorld = /*#__PURE__*/ varying( getBitangent( normalWorld.cross( tangentWorld ) ), 'v_bitangentWorld' ).normalize().toVar( 'bitangentWorld' ); -const transformedBitangentView = /*#__PURE__*/ getBitangent( transformedNormalView.cross( transformedTangentView ) ).normalize().toVar( 'transformedBitangentView' ); -const transformedBitangentWorld = /*#__PURE__*/ transformedBitangentView.transformDirection( cameraViewMatrix ).normalize().toVar( 'transformedBitangentWorld' ); +const bitangentGeometry = /*@__PURE__*/ varying( getBitangent( normalGeometry.cross( tangentGeometry ) ), 'v_bitangentGeometry' ).normalize().toVar( 'bitangentGeometry' ); +const bitangentLocal = /*@__PURE__*/ varying( getBitangent( normalLocal.cross( tangentLocal ) ), 'v_bitangentLocal' ).normalize().toVar( 'bitangentLocal' ); +const bitangentView = /*@__PURE__*/ varying( getBitangent( normalView.cross( tangentView ) ), 'v_bitangentView' ).normalize().toVar( 'bitangentView' ); +const bitangentWorld = /*@__PURE__*/ varying( getBitangent( normalWorld.cross( tangentWorld ) ), 'v_bitangentWorld' ).normalize().toVar( 'bitangentWorld' ); +const transformedBitangentView = /*@__PURE__*/ getBitangent( transformedNormalView.cross( transformedTangentView ) ).normalize().toVar( 'transformedBitangentView' ); +const transformedBitangentWorld = /*@__PURE__*/ transformedBitangentView.transformDirection( cameraViewMatrix ).normalize().toVar( 'transformedBitangentWorld' ); -const TBNViewMatrix = mat3( tangentView, bitangentView, normalView ); +const TBNViewMatrix = /*@__PURE__*/ mat3( tangentView, bitangentView, normalView ); -const parallaxDirection = positionViewDirection.mul( TBNViewMatrix )/*.normalize()*/; +const parallaxDirection = /*@__PURE__*/ positionViewDirection.mul( TBNViewMatrix )/*.normalize()*/; const parallaxUV = ( uv, scale ) => uv.sub( parallaxDirection.mul( scale ) ); -const transformedBentNormalView = ( () => { +const transformedBentNormalView = /*@__PURE__*/ ( () => { // https://google.github.io/filament/Filament.md.html#lighting/imagebasedlights/anisotropy @@ -29915,7 +29922,7 @@ const transformedBentNormalView = ( () => { // Normal Mapping Without Precomputed Tangents // http://www.thetenthplanet.de/archives/1180 -const perturbNormal2Arb = Fn( ( inputs ) => { +const perturbNormal2Arb = /*@__PURE__*/ Fn( ( inputs ) => { const { eye_pos, surf_norm, mapN, uv } = inputs; @@ -29997,9 +30004,9 @@ class NormalMapNode extends TempNode { } -registerNodeClass( 'NormalMap', NormalMapNode ); +NormalMapNode.type = /*@__PURE__*/ registerNode( 'NormalMap', NormalMapNode ); -const normalMap = nodeProxy( NormalMapNode ); +const normalMap = /*@__PURE__*/ nodeProxy( NormalMapNode ); // Bump Mapping Unparametrized Surfaces on the GPU by Morten S. Mikkelsen // https://mmikk.github.io/papers3d/mm_sfgrad_bump.pdf @@ -30066,7 +30073,7 @@ class BumpMapNode extends TempNode { } -const bumpMap = nodeProxy( BumpMapNode ); +const bumpMap = /*@__PURE__*/ nodeProxy( BumpMapNode ); const _propertyCache = new Map(); @@ -30441,49 +30448,49 @@ MaterialNode.DISPERSION = 'dispersion'; MaterialNode.LIGHT_MAP = 'light'; MaterialNode.AO_MAP = 'ao'; -registerNodeClass( 'Material', MaterialNode ); - -const materialAlphaTest = nodeImmutable( MaterialNode, MaterialNode.ALPHA_TEST ); -const materialColor = nodeImmutable( MaterialNode, MaterialNode.COLOR ); -const materialShininess = nodeImmutable( MaterialNode, MaterialNode.SHININESS ); -const materialEmissive = nodeImmutable( MaterialNode, MaterialNode.EMISSIVE ); -const materialOpacity = nodeImmutable( MaterialNode, MaterialNode.OPACITY ); -const materialSpecular = nodeImmutable( MaterialNode, MaterialNode.SPECULAR ); - -const materialSpecularIntensity = nodeImmutable( MaterialNode, MaterialNode.SPECULAR_INTENSITY ); -const materialSpecularColor = nodeImmutable( MaterialNode, MaterialNode.SPECULAR_COLOR ); - -const materialSpecularStrength = nodeImmutable( MaterialNode, MaterialNode.SPECULAR_STRENGTH ); -const materialReflectivity = nodeImmutable( MaterialNode, MaterialNode.REFLECTIVITY ); -const materialRoughness = nodeImmutable( MaterialNode, MaterialNode.ROUGHNESS ); -const materialMetalness = nodeImmutable( MaterialNode, MaterialNode.METALNESS ); -const materialNormal = nodeImmutable( MaterialNode, MaterialNode.NORMAL ).context( { getUV: null } ); -const materialClearcoat = nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT ); -const materialClearcoatRoughness = nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT_ROUGHNESS ); -const materialClearcoatNormal = nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT_NORMAL ).context( { getUV: null } ); -const materialRotation = nodeImmutable( MaterialNode, MaterialNode.ROTATION ); -const materialSheen = nodeImmutable( MaterialNode, MaterialNode.SHEEN ); -const materialSheenRoughness = nodeImmutable( MaterialNode, MaterialNode.SHEEN_ROUGHNESS ); -const materialAnisotropy = nodeImmutable( MaterialNode, MaterialNode.ANISOTROPY ); -const materialIridescence = nodeImmutable( MaterialNode, MaterialNode.IRIDESCENCE ); -const materialIridescenceIOR = nodeImmutable( MaterialNode, MaterialNode.IRIDESCENCE_IOR ); -const materialIridescenceThickness = nodeImmutable( MaterialNode, MaterialNode.IRIDESCENCE_THICKNESS ); -const materialTransmission = nodeImmutable( MaterialNode, MaterialNode.TRANSMISSION ); -const materialThickness = nodeImmutable( MaterialNode, MaterialNode.THICKNESS ); -const materialIOR = nodeImmutable( MaterialNode, MaterialNode.IOR ); -const materialAttenuationDistance = nodeImmutable( MaterialNode, MaterialNode.ATTENUATION_DISTANCE ); -const materialAttenuationColor = nodeImmutable( MaterialNode, MaterialNode.ATTENUATION_COLOR ); -const materialLineScale = nodeImmutable( MaterialNode, MaterialNode.LINE_SCALE ); -const materialLineDashSize = nodeImmutable( MaterialNode, MaterialNode.LINE_DASH_SIZE ); -const materialLineGapSize = nodeImmutable( MaterialNode, MaterialNode.LINE_GAP_SIZE ); -const materialLineWidth = nodeImmutable( MaterialNode, MaterialNode.LINE_WIDTH ); -const materialLineDashOffset = nodeImmutable( MaterialNode, MaterialNode.LINE_DASH_OFFSET ); -const materialPointWidth = nodeImmutable( MaterialNode, MaterialNode.POINT_WIDTH ); -const materialDispersion = nodeImmutable( MaterialNode, MaterialNode.DISPERSION ); -const materialLightMap = nodeImmutable( MaterialNode, MaterialNode.LIGHT_MAP ); -const materialAOMap = nodeImmutable( MaterialNode, MaterialNode.AO_MAP ); -nodeImmutable( MaterialNode, MaterialNode.REFRACTION_RATIO ); -const materialAnisotropyVector = uniform( new Vector2() ).onReference( function ( frame ) { +MaterialNode.type = /*@__PURE__*/ registerNode( 'Material', MaterialNode ); + +const materialAlphaTest = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.ALPHA_TEST ); +const materialColor = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.COLOR ); +const materialShininess = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.SHININESS ); +const materialEmissive = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.EMISSIVE ); +const materialOpacity = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.OPACITY ); +const materialSpecular = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.SPECULAR ); + +const materialSpecularIntensity = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.SPECULAR_INTENSITY ); +const materialSpecularColor = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.SPECULAR_COLOR ); + +const materialSpecularStrength = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.SPECULAR_STRENGTH ); +const materialReflectivity = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.REFLECTIVITY ); +const materialRoughness = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.ROUGHNESS ); +const materialMetalness = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.METALNESS ); +const materialNormal = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.NORMAL ).context( { getUV: null } ); +const materialClearcoat = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT ); +const materialClearcoatRoughness = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT_ROUGHNESS ); +const materialClearcoatNormal = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.CLEARCOAT_NORMAL ).context( { getUV: null } ); +const materialRotation = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.ROTATION ); +const materialSheen = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.SHEEN ); +const materialSheenRoughness = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.SHEEN_ROUGHNESS ); +const materialAnisotropy = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.ANISOTROPY ); +const materialIridescence = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.IRIDESCENCE ); +const materialIridescenceIOR = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.IRIDESCENCE_IOR ); +const materialIridescenceThickness = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.IRIDESCENCE_THICKNESS ); +const materialTransmission = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.TRANSMISSION ); +const materialThickness = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.THICKNESS ); +const materialIOR = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.IOR ); +const materialAttenuationDistance = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.ATTENUATION_DISTANCE ); +const materialAttenuationColor = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.ATTENUATION_COLOR ); +const materialLineScale = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.LINE_SCALE ); +const materialLineDashSize = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.LINE_DASH_SIZE ); +const materialLineGapSize = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.LINE_GAP_SIZE ); +const materialLineWidth = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.LINE_WIDTH ); +const materialLineDashOffset = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.LINE_DASH_OFFSET ); +const materialPointWidth = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.POINT_WIDTH ); +const materialDispersion = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.DISPERSION ); +const materialLightMap = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.LIGHT_MAP ); +const materialAOMap = /*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.AO_MAP ); +/*@__PURE__*/ nodeImmutable( MaterialNode, MaterialNode.REFRACTION_RATIO ); +const materialAnisotropyVector = /*@__PURE__*/ uniform( new Vector2() ).onReference( function ( frame ) { return frame.material; @@ -30519,9 +30526,9 @@ class ModelViewProjectionNode extends TempNode { } -registerNodeClass( 'ModelViewProjection', ModelViewProjectionNode ); +ModelViewProjectionNode.type = /*@__PURE__*/ registerNode( 'ModelViewProjection', ModelViewProjectionNode ); -const modelViewProjection = nodeProxy( ModelViewProjectionNode ); +const modelViewProjection = /*@__PURE__*/ nodeProxy( ModelViewProjectionNode ); class IndexNode extends Node { @@ -30589,12 +30596,12 @@ IndexNode.INSTANCE = 'instance'; IndexNode.INVOCATION_LOCAL = 'invocationLocal'; IndexNode.DRAW = 'draw'; -registerNodeClass( 'Index', IndexNode ); +IndexNode.type = /*@__PURE__*/ registerNode( 'Index', IndexNode ); -const vertexIndex = nodeImmutable( IndexNode, IndexNode.VERTEX ); -const instanceIndex = nodeImmutable( IndexNode, IndexNode.INSTANCE ); -const invocationLocalIndex = nodeImmutable( IndexNode, IndexNode.INVOCATION_LOCAL ); -const drawIndex = nodeImmutable( IndexNode, IndexNode.DRAW ); +const vertexIndex = /*@__PURE__*/ nodeImmutable( IndexNode, IndexNode.VERTEX ); +const instanceIndex = /*@__PURE__*/ nodeImmutable( IndexNode, IndexNode.INSTANCE ); +const invocationLocalIndex = /*@__PURE__*/ nodeImmutable( IndexNode, IndexNode.INVOCATION_LOCAL ); +const drawIndex = /*@__PURE__*/ nodeImmutable( IndexNode, IndexNode.DRAW ); class InstancedInterleavedBuffer extends InterleavedBuffer { @@ -30766,9 +30773,9 @@ class InstanceNode extends Node { } -registerNodeClass( 'Instance', InstanceNode ); +InstanceNode.type = /*@__PURE__*/ registerNode( 'Instance', InstanceNode ); -const instance = nodeProxy( InstanceNode ); +const instance = /*@__PURE__*/ nodeProxy( InstanceNode ); class BatchNode extends Node { @@ -30879,9 +30886,9 @@ class BatchNode extends Node { } -registerNodeClass( 'Batch', BatchNode ); +BatchNode.type = /*@__PURE__*/ registerNode( 'Batch', BatchNode ); -const batch = nodeProxy( BatchNode ); +const batch = /*@__PURE__*/ nodeProxy( BatchNode ); const _frameId = new WeakMap(); @@ -31052,7 +31059,7 @@ class SkinningNode extends Node { } -registerNodeClass( 'Skinning', SkinningNode ); +SkinningNode.type = /*@__PURE__*/ registerNode( 'Skinning', SkinningNode ); const skinning = ( skinnedMesh ) => nodeObject( new SkinningNode( skinnedMesh ) ); const skinningReference = ( skinnedMesh ) => nodeObject( new SkinningNode( skinnedMesh, true ) ); @@ -31244,16 +31251,16 @@ class LoopNode extends Node { } -registerNodeClass( 'Loop', LoopNode ); +LoopNode.type = /*@__PURE__*/ registerNode( 'Loop', LoopNode ); const Loop = ( ...params ) => nodeObject( new LoopNode( nodeArray( params, 'int' ) ) ).append(); const Continue = () => expression( 'continue' ).append(); const Break = () => expression( 'break' ).append(); -const _morphTextures = new WeakMap(); +const _morphTextures = /*@__PURE__*/ new WeakMap(); const _morphVec4 = /*@__PURE__*/ new Vector4(); -const getMorph = Fn( ( { bufferMap, influence, stride, width, depth, offset } ) => { +const getMorph = /*@__PURE__*/ Fn( ( { bufferMap, influence, stride, width, depth, offset } ) => { const texelIndex = int( vertexIndex ).mul( stride ).add( offset ); @@ -31487,9 +31494,9 @@ class MorphNode extends Node { } -registerNodeClass( 'Morph', MorphNode ); +MorphNode.type = /*@__PURE__*/ registerNode( 'Morph', MorphNode ); -const morphReference = nodeProxy( MorphNode ); +const morphReference = /*@__PURE__*/ nodeProxy( MorphNode ); const sortLights = ( lights ) => { @@ -31714,9 +31721,9 @@ class LightsNode extends Node { } -registerNodeClass( 'Lights', LightsNode ); +LightsNode.type = /*@__PURE__*/ registerNode( 'Lights', LightsNode ); -const lights = nodeProxy( LightsNode ); +const lights = /*@__PURE__*/ nodeProxy( LightsNode ); class LightingNode extends Node { @@ -31736,7 +31743,7 @@ class LightingNode extends Node { } -registerNodeClass( 'Lighting', LightingNode ); +LightingNode.type = /*@__PURE__*/ registerNode( 'Lighting', LightingNode ); class AONode extends LightingNode { @@ -31756,7 +31763,7 @@ class AONode extends LightingNode { } -registerNodeClass( 'AO', AONode ); +AONode.type = /*@__PURE__*/ registerNode( 'AO', AONode ); class LightingContextNode extends ContextNode { @@ -31813,9 +31820,9 @@ class LightingContextNode extends ContextNode { } -registerNodeClass( 'LightingContext', LightingContextNode ); +LightingContextNode.type = /*@__PURE__*/ registerNode( 'LightingContext', LightingContextNode ); -const lightingContext = nodeProxy( LightingContextNode ); +const lightingContext = /*@__PURE__*/ nodeProxy( LightingContextNode ); class IrradianceNode extends LightingNode { @@ -31835,7 +31842,7 @@ class IrradianceNode extends LightingNode { } -registerNodeClass( 'Irradiance', IrradianceNode ); +IrradianceNode.type = /*@__PURE__*/ registerNode( 'Irradiance', IrradianceNode ); let resolution, viewportResult; @@ -31943,12 +31950,12 @@ ViewportNode.RESOLUTION = 'resolution'; ViewportNode.VIEWPORT = 'viewport'; ViewportNode.UV = 'uv'; -registerNodeClass( 'Viewport', ViewportNode ); +ViewportNode.type = /*@__PURE__*/ registerNode( 'Viewport', ViewportNode ); -const viewportCoordinate = nodeImmutable( ViewportNode, ViewportNode.COORDINATE ); -const viewportResolution = nodeImmutable( ViewportNode, ViewportNode.RESOLUTION ); -const viewport = nodeImmutable( ViewportNode, ViewportNode.VIEWPORT ); -const viewportUV = nodeImmutable( ViewportNode, ViewportNode.UV ); +const viewportCoordinate = /*@__PURE__*/ nodeImmutable( ViewportNode, ViewportNode.COORDINATE ); +const viewportResolution = /*@__PURE__*/ nodeImmutable( ViewportNode, ViewportNode.RESOLUTION ); +const viewport = /*@__PURE__*/ nodeImmutable( ViewportNode, ViewportNode.VIEWPORT ); +const viewportUV = /*@__PURE__*/ nodeImmutable( ViewportNode, ViewportNode.UV ); const viewportTopLeft = /*@__PURE__*/ ( Fn( () => { // @deprecated, r168 @@ -32028,10 +32035,10 @@ class ViewportTextureNode extends TextureNode { } -registerNodeClass( 'ViewportTexture', ViewportTextureNode ); +ViewportTextureNode.type = /*@__PURE__*/ registerNode( 'ViewportTexture', ViewportTextureNode ); -const viewportTexture = nodeProxy( ViewportTextureNode ); -const viewportMipTexture = nodeProxy( ViewportTextureNode, null, null, { generateMipmaps: true } ); +const viewportTexture = /*@__PURE__*/ nodeProxy( ViewportTextureNode ); +const viewportMipTexture = /*@__PURE__*/ nodeProxy( ViewportTextureNode, null, null, { generateMipmaps: true } ); let sharedDepthbuffer = null; @@ -32051,9 +32058,9 @@ class ViewportDepthTextureNode extends ViewportTextureNode { } -registerNodeClass( 'ViewportDepthTexture', ViewportDepthTextureNode ); +ViewportDepthTextureNode.type = /*@__PURE__*/ registerNode( 'ViewportDepthTexture', ViewportDepthTextureNode ); -const viewportDepthTexture = nodeProxy( ViewportDepthTextureNode ); +const viewportDepthTexture = /*@__PURE__*/ nodeProxy( ViewportDepthTextureNode ); class ViewportDepthNode extends Node { @@ -32143,7 +32150,7 @@ ViewportDepthNode.DEPTH_BASE = 'depthBase'; ViewportDepthNode.DEPTH = 'depth'; ViewportDepthNode.LINEAR_DEPTH = 'linearDepth'; -registerNodeClass( 'ViewportDepth', ViewportDepthNode ); +ViewportDepthNode.type = /*@__PURE__*/ registerNode( 'ViewportDepth', ViewportDepthNode ); // NOTE: viewZ, the z-coordinate in camera space, is negative for points in front of the camera @@ -32161,11 +32168,11 @@ const viewZToPerspectiveDepth = ( viewZ, near, far ) => near.add( viewZ ).mul( f // maps perspective depth in [ 0, 1 ] to viewZ const perspectiveDepthToViewZ = ( depth, near, far ) => near.mul( far ).div( far.sub( near ).mul( depth ).sub( far ) ); -const depthBase = nodeProxy( ViewportDepthNode, ViewportDepthNode.DEPTH_BASE ); +const depthBase = /*@__PURE__*/ nodeProxy( ViewportDepthNode, ViewportDepthNode.DEPTH_BASE ); -const depth = nodeImmutable( ViewportDepthNode, ViewportDepthNode.DEPTH ); -const linearDepth = nodeProxy( ViewportDepthNode, ViewportDepthNode.LINEAR_DEPTH ); -const viewportLinearDepth = linearDepth( viewportDepthTexture() ); +const depth = /*@__PURE__*/ nodeImmutable( ViewportDepthNode, ViewportDepthNode.DEPTH ); +const linearDepth = /*@__PURE__*/ nodeProxy( ViewportDepthNode, ViewportDepthNode.LINEAR_DEPTH ); +const viewportLinearDepth = /*@__PURE__*/ linearDepth( viewportDepthTexture() ); depth.assign = ( value ) => depthBase( value ); @@ -32299,12 +32306,14 @@ class ClippingNode extends Node { ClippingNode.ALPHA_TO_COVERAGE = 'alphaToCoverage'; ClippingNode.DEFAULT = 'default'; -registerNodeClass( 'Clipping', ClippingNode ); +ClippingNode.type = /*@__PURE__*/ registerNode( 'Clipping', ClippingNode ); const clipping = () => nodeObject( new ClippingNode() ); const clippingAlpha = () => nodeObject( new ClippingNode( ClippingNode.ALPHA_TO_COVERAGE ) ); +const NodeMaterials = new Map(); + class NodeMaterial extends Material { constructor() { @@ -32902,6 +32911,48 @@ class NodeMaterial extends Material { } +NodeMaterial.type = /*@__PURE__*/ registerNodeMaterial( '', NodeMaterial ); + +function registerNodeMaterial( type, nodeMaterialClass ) { + + const suffix = 'NodeMaterial'; + const nodeMaterialType = type + suffix; + + if ( typeof nodeMaterialClass !== 'function' ) throw new Error( `THREE.Node: NodeMaterial class "${ type }" is not a class.` ); + + if ( NodeMaterials.has( nodeMaterialType ) ) { + + console.warn( `THREE.Node: Redefinition of NodeMaterial class "${ nodeMaterialType }".` ); + return; + + } + + if ( type.slice( - suffix.length ) === suffix ) { + + console.warn( `THREE.NodeMaterial: NodeMaterial class ${ nodeMaterialType } should not have '${ suffix }' suffix.` ); + return; + + } + + NodeMaterials.set( nodeMaterialType, nodeMaterialClass ); + nodeMaterialClass.type = nodeMaterialType; + + return nodeMaterialType; + +} + +function createNodeMaterialFromType( type ) { + + const Material = NodeMaterials.get( type ); + + if ( Material !== undefined ) { + + return new Material(); + + } + +} + const _defaultValues$e = /*@__PURE__*/ new PointsMaterial(); class InstancedPointsNodeMaterial extends NodeMaterial { @@ -32920,6 +32971,8 @@ class InstancedPointsNodeMaterial extends NodeMaterial { this.pointColorNode = null; + this.pointWidthNode = null; + this.setDefaultValues( _defaultValues$e ); this.setupShaders(); @@ -32946,7 +32999,7 @@ class InstancedPointsNodeMaterial extends NodeMaterial { //vUv = uv; varying( vec2(), 'vUv' ).assign( uv() ); // @TODO: Analyze other way to do this - const instancePosition = attribute( 'instancePosition' ); + const instancePosition = attribute( 'instancePosition' ).xyz; // camera space const mvPos = property( 'vec4', 'mvPos' ); @@ -32960,7 +33013,9 @@ class InstancedPointsNodeMaterial extends NodeMaterial { // offset in ndc space const offset = property( 'vec2', 'offset' ); offset.assign( positionGeometry.xy ); - offset.assign( offset.mul( materialPointWidth ) ); + + offset.mulAssign( this.pointWidthNode ? this.pointWidthNode : materialPointWidth ); + offset.assign( offset.div( viewport.z ) ); offset.y.assign( offset.y.mul( aspect ) ); @@ -33050,6 +33105,8 @@ class InstancedPointsNodeMaterial extends NodeMaterial { } +InstancedPointsNodeMaterial.type = /*@__PURE__*/ registerNodeMaterial( 'InstancedPoints', InstancedPointsNodeMaterial ); + const _defaultValues$d = /*@__PURE__*/ new LineBasicMaterial(); class LineBasicNodeMaterial extends NodeMaterial { @@ -33070,6 +33127,8 @@ class LineBasicNodeMaterial extends NodeMaterial { } +LineBasicNodeMaterial.type = /*@__PURE__*/ registerNodeMaterial( 'LineBasic', LineBasicNodeMaterial ); + const _defaultValues$c = /*@__PURE__*/ new LineDashedMaterial(); class LineDashedNodeMaterial extends NodeMaterial { @@ -33112,6 +33171,8 @@ class LineDashedNodeMaterial extends NodeMaterial { } +LineDashedNodeMaterial.type = /*@__PURE__*/ registerNodeMaterial( 'LineDashed', LineDashedNodeMaterial ); + const _defaultValues$b = /*@__PURE__*/ new LineDashedMaterial(); class Line2NodeMaterial extends NodeMaterial { @@ -33531,6 +33592,8 @@ class Line2NodeMaterial extends NodeMaterial { } +Line2NodeMaterial.type = /*@__PURE__*/ registerNodeMaterial( 'Line2', Line2NodeMaterial ); + const directionToColor = ( node ) => nodeObject( node ).mul( 0.5 ).add( 0.5 ); const colorToDirection = ( node ) => nodeObject( node ).mul( 2.0 ).sub( 1 ); @@ -33562,6 +33625,8 @@ class MeshNormalNodeMaterial extends NodeMaterial { } +MeshNormalNodeMaterial.type = /*@__PURE__*/ registerNodeMaterial( 'MeshNormal', MeshNormalNodeMaterial ); + class EquirectUVNode extends TempNode { constructor( dirNode = positionWorldDirection ) { @@ -33585,9 +33650,9 @@ class EquirectUVNode extends TempNode { } -registerNodeClass( 'EquirectUV', EquirectUVNode ); +EquirectUVNode.type = /*@__PURE__*/ registerNode( 'EquirectUV', EquirectUVNode ); -const equirectUV = nodeProxy( EquirectUVNode ); +const equirectUV = /*@__PURE__*/ nodeProxy( EquirectUVNode ); // @TODO: Consider rename WebGLCubeRenderTarget to just CubeRenderTarget @@ -33756,7 +33821,7 @@ class CubeMapNode extends TempNode { } -registerNodeClass( 'CubeMap', CubeMapNode ); +CubeMapNode.type = /*@__PURE__*/ registerNode( 'CubeMap', CubeMapNode ); function isEquirectangularMapReady$1( image ) { @@ -33798,7 +33863,7 @@ function mapTextureMapping( texture, mapping ) { } -const cubeMapNode = nodeProxy( CubeMapNode ); +const cubeMapNode = /*@__PURE__*/ nodeProxy( CubeMapNode ); class BasicEnvironmentNode extends LightingNode { @@ -33820,7 +33885,7 @@ class BasicEnvironmentNode extends LightingNode { } -registerNodeClass( 'BasicEnvironment', BasicEnvironmentNode ); +BasicEnvironmentNode.type = /*@__PURE__*/ registerNode( 'BasicEnvironment', BasicEnvironmentNode ); class BasicLightMapNode extends LightingNode { @@ -33844,7 +33909,7 @@ class BasicLightMapNode extends LightingNode { } -registerNodeClass( 'BasicLightMap', BasicLightMapNode ); +BasicLightMapNode.type = /*@__PURE__*/ registerNode( 'BasicLightMap', BasicLightMapNode ); class LightingModel { @@ -33992,7 +34057,9 @@ class MeshBasicNodeMaterial extends NodeMaterial { } -const F_Schlick = Fn( ( { f0, f90, dotVH } ) => { +MeshBasicNodeMaterial.type = /*@__PURE__*/ registerNodeMaterial( 'MeshBasic', MeshBasicNodeMaterial ); + +const F_Schlick = /*@__PURE__*/ Fn( ( { f0, f90, dotVH } ) => { // Original approximation by Christophe Schlick '94 // float fresnel = pow( 1.0 - dotVH, 5.0 ); @@ -34005,7 +34072,7 @@ const F_Schlick = Fn( ( { f0, f90, dotVH } ) => { } ); // validated -const BRDF_Lambert = Fn( ( inputs ) => { +const BRDF_Lambert = /*@__PURE__*/ Fn( ( inputs ) => { return inputs.diffuseColor.mul( 1 / Math.PI ); // punctual light @@ -34013,13 +34080,13 @@ const BRDF_Lambert = Fn( ( inputs ) => { const G_BlinnPhong_Implicit = () => float( 0.25 ); -const D_BlinnPhong = Fn( ( { dotNH } ) => { +const D_BlinnPhong = /*@__PURE__*/ Fn( ( { dotNH } ) => { return shininess.mul( float( 0.5 ) ).add( 1.0 ).mul( float( 1 / Math.PI ) ).mul( dotNH.pow( shininess ) ); } ); -const BRDF_BlinnPhong = Fn( ( { lightDirection } ) => { +const BRDF_BlinnPhong = /*@__PURE__*/ Fn( ( { lightDirection } ) => { const halfDir = lightDirection.add( positionViewDirection ).normalize(); @@ -34103,6 +34170,8 @@ class MeshLambertNodeMaterial extends NodeMaterial { } +MeshLambertNodeMaterial.type = /*@__PURE__*/ registerNodeMaterial( 'MeshLambert', MeshLambertNodeMaterial ); + const _defaultValues$7 = /*@__PURE__*/ new MeshPhongMaterial(); class MeshPhongNodeMaterial extends NodeMaterial { @@ -34165,7 +34234,9 @@ class MeshPhongNodeMaterial extends NodeMaterial { } -const getGeometryRoughness = Fn( () => { +MeshPhongNodeMaterial.type = /*@__PURE__*/ registerNodeMaterial( 'MeshPhong', MeshPhongNodeMaterial ); + +const getGeometryRoughness = /*@__PURE__*/ Fn( () => { const dxy = normalView.dFdx().abs().max( normalView.dFdy().abs() ); const geometryRoughness = dxy.x.max( dxy.y ).max( dxy.z ); @@ -34174,7 +34245,7 @@ const getGeometryRoughness = Fn( () => { } ); -const getRoughness = Fn( ( inputs ) => { +const getRoughness = /*@__PURE__*/ Fn( ( inputs ) => { const { roughness } = inputs; @@ -34190,7 +34261,7 @@ const getRoughness = Fn( ( inputs ) => { // Moving Frostbite to Physically Based Rendering 3.0 - page 12, listing 2 // https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf -const V_GGX_SmithCorrelated = Fn( ( { alpha, dotNL, dotNV } ) => { +const V_GGX_SmithCorrelated = /*@__PURE__*/ Fn( ( { alpha, dotNL, dotNV } ) => { const a2 = alpha.pow2(); @@ -34211,7 +34282,7 @@ const V_GGX_SmithCorrelated = Fn( ( { alpha, dotNL, dotNV } ) => { // https://google.github.io/filament/Filament.md.html#materialsystem/anisotropicmodel/anisotropicspecularbrdf -const V_GGX_SmithCorrelated_Anisotropic = Fn( ( { alphaT, alphaB, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL } ) => { +const V_GGX_SmithCorrelated_Anisotropic = /*@__PURE__*/ Fn( ( { alphaT, alphaB, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL } ) => { const gv = dotNL.mul( vec3( alphaT.mul( dotTV ), alphaB.mul( dotBV ), dotNV ).length() ); const gl = dotNV.mul( vec3( alphaT.mul( dotTL ), alphaB.mul( dotBL ), dotNL ).length() ); @@ -34237,7 +34308,7 @@ const V_GGX_SmithCorrelated_Anisotropic = Fn( ( { alphaT, alphaB, dotTV, dotBV, // Microfacet Models for Refraction through Rough Surfaces - equation (33) // http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html // alpha is "roughness squared" in Disney’s reparameterization -const D_GGX = Fn( ( { alpha, dotNH } ) => { +const D_GGX = /*@__PURE__*/ Fn( ( { alpha, dotNH } ) => { const a2 = alpha.pow2(); @@ -34254,11 +34325,11 @@ const D_GGX = Fn( ( { alpha, dotNH } ) => { ] } ); // validated -const RECIPROCAL_PI = float( 1 / Math.PI ); +const RECIPROCAL_PI = /*@__PURE__*/ float( 1 / Math.PI ); // https://google.github.io/filament/Filament.md.html#materialsystem/anisotropicmodel/anisotropicspecularbrdf -const D_GGX_Anisotropic = Fn( ( { alphaT, alphaB, dotNH, dotTH, dotBH } ) => { +const D_GGX_Anisotropic = /*@__PURE__*/ Fn( ( { alphaT, alphaB, dotNH, dotTH, dotBH } ) => { const a2 = alphaT.mul( alphaB ); const v = vec3( alphaB.mul( dotTH ), alphaT.mul( dotBH ), a2.mul( dotNH ) ); @@ -34280,7 +34351,7 @@ const D_GGX_Anisotropic = Fn( ( { alphaT, alphaB, dotNH, dotTH, dotBH } ) => { } ); // GGX Distribution, Schlick Fresnel, GGX_SmithCorrelated Visibility -const BRDF_GGX = Fn( ( inputs ) => { +const BRDF_GGX = /*@__PURE__*/ Fn( ( inputs ) => { const { lightDirection, f0, f90, roughness, f, USE_IRIDESCENCE, USE_ANISOTROPY } = inputs; @@ -34331,7 +34402,7 @@ const BRDF_GGX = Fn( ( inputs ) => { // split-sum approximation used in indirect specular lighting. // via 'environmentBRDF' from "Physically Based Shading on Mobile" // https://www.unrealengine.com/blog/physically-based-shading-on-mobile -const DFGApprox = Fn( ( { roughness, dotNV } ) => { +const DFGApprox = /*@__PURE__*/ Fn( ( { roughness, dotNV } ) => { const c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 ); @@ -34354,7 +34425,7 @@ const DFGApprox = Fn( ( { roughness, dotNV } ) => { ] } ); -const EnvironmentBRDF = Fn( ( inputs ) => { +const EnvironmentBRDF = /*@__PURE__*/ Fn( ( inputs ) => { const { dotNV, specularColor, specularF90, roughness } = inputs; @@ -34363,7 +34434,7 @@ const EnvironmentBRDF = Fn( ( inputs ) => { } ); -const Schlick_to_F0 = Fn( ( { f, f90, dotVH } ) => { +const Schlick_to_F0 = /*@__PURE__*/ Fn( ( { f, f90, dotVH } ) => { const x = dotVH.oneMinus().saturate(); const x2 = x.mul( x ); @@ -34382,7 +34453,7 @@ const Schlick_to_F0 = Fn( ( { f, f90, dotVH } ) => { } ); // https://github.com/google/filament/blob/master/shaders/src/brdf.fs -const D_Charlie = Fn( ( { roughness, dotNH } ) => { +const D_Charlie = /*@__PURE__*/ Fn( ( { roughness, dotNH } ) => { const alpha = roughness.pow2(); @@ -34403,7 +34474,7 @@ const D_Charlie = Fn( ( { roughness, dotNH } ) => { } ); // https://github.com/google/filament/blob/master/shaders/src/brdf.fs -const V_Neubelt = Fn( ( { dotNV, dotNL } ) => { +const V_Neubelt = /*@__PURE__*/ Fn( ( { dotNV, dotNL } ) => { // Neubelt and Pettineo 2013, "Crafting a Next-gen Material Pipeline for The Order: 1886" return float( 1.0 ).div( float( 4.0 ).mul( dotNL.add( dotNV ).sub( dotNL.mul( dotNV ) ) ) ); @@ -34417,7 +34488,7 @@ const V_Neubelt = Fn( ( { dotNV, dotNL } ) => { ] } ); -const BRDF_Sheen = Fn( ( { lightDirection } ) => { +const BRDF_Sheen = /*@__PURE__*/ Fn( ( { lightDirection } ) => { const halfDir = lightDirection.add( positionViewDirection ).normalize(); @@ -34438,7 +34509,7 @@ const BRDF_Sheen = Fn( ( { lightDirection } ) => { // by Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt // code: https://github.com/selfshadow/ltc_code/ -const LTC_Uv = Fn( ( { N, V, roughness } ) => { +const LTC_Uv = /*@__PURE__*/ Fn( ( { N, V, roughness } ) => { const LUT_SIZE = 64.0; const LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; @@ -34463,7 +34534,7 @@ const LTC_Uv = Fn( ( { N, V, roughness } ) => { ] } ); -const LTC_ClippedSphereFormFactor = Fn( ( { f } ) => { +const LTC_ClippedSphereFormFactor = /*@__PURE__*/ Fn( ( { f } ) => { // Real-Time Area Lighting: a Journey from Research to Production (p.102) // An approximation of the form factor of a horizon-clipped rectangle. @@ -34480,7 +34551,7 @@ const LTC_ClippedSphereFormFactor = Fn( ( { f } ) => { ] } ); -const LTC_EdgeVectorFormFactor = Fn( ( { v1, v2 } ) => { +const LTC_EdgeVectorFormFactor = /*@__PURE__*/ Fn( ( { v1, v2 } ) => { const x = v1.dot( v2 ); const y = x.abs().toVar(); @@ -34503,7 +34574,7 @@ const LTC_EdgeVectorFormFactor = Fn( ( { v1, v2 } ) => { ] } ); -const LTC_Evaluate = Fn( ( { N, V, P, mInv, p0, p1, p2, p3 } ) => { +const LTC_Evaluate = /*@__PURE__*/ Fn( ( { N, V, P, mInv, p0, p1, p2, p3 } ) => { // bail if point is on back side of plane of light // assumes ccw winding order of light vertices @@ -34607,7 +34678,7 @@ const bicubic = ( textureNode, texelSize, lod ) => { }; -const textureBicubic = Fn( ( [ textureNode, lodNode = float( 3 ) ] ) => { +const textureBicubic = /*@__PURE__*/ Fn( ( [ textureNode, lodNode = float( 3 ) ] ) => { const fLodSize = vec2( textureNode.size( int( lodNode ) ) ); const cLodSize = vec2( textureNode.size( int( lodNode.add( 1.0 ) ) ) ); @@ -34624,7 +34695,7 @@ const textureBicubic = Fn( ( [ textureNode, lodNode = float( 3 ) ] ) => { // Transmission // -const getVolumeTransmissionRay = Fn( ( [ n, v, thickness, ior, modelMatrix ] ) => { +const getVolumeTransmissionRay = /*@__PURE__*/ Fn( ( [ n, v, thickness, ior, modelMatrix ] ) => { // Direction of refracted light. const refractionVector = vec3( refract( v.negate(), normalize( n ), div( 1.0, ior ) ) ); @@ -34651,7 +34722,7 @@ const getVolumeTransmissionRay = Fn( ( [ n, v, thickness, ior, modelMatrix ] ) = ] } ); -const applyIorToRoughness = Fn( ( [ roughness, ior ] ) => { +const applyIorToRoughness = /*@__PURE__*/ Fn( ( [ roughness, ior ] ) => { // Scale roughness with IOR so that an IOR of 1.0 results in no microfacet refraction and // an IOR of 1.5 results in the default amount of microfacet refraction. @@ -34666,9 +34737,9 @@ const applyIorToRoughness = Fn( ( [ roughness, ior ] ) => { ] } ); -const singleViewportMipTexture = viewportMipTexture(); +const singleViewportMipTexture = /*@__PURE__*/ viewportMipTexture(); -const getTransmissionSample = Fn( ( [ fragCoord, roughness, ior ] ) => { +const getTransmissionSample = /*@__PURE__*/ Fn( ( [ fragCoord, roughness, ior ] ) => { const transmissionSample = singleViewportMipTexture.uv( fragCoord ); //const transmissionSample = viewportMipTexture( fragCoord ); @@ -34679,7 +34750,7 @@ const getTransmissionSample = Fn( ( [ fragCoord, roughness, ior ] ) => { } ); -const volumeAttenuation = Fn( ( [ transmissionDistance, attenuationColor, attenuationDistance ] ) => { +const volumeAttenuation = /*@__PURE__*/ Fn( ( [ transmissionDistance, attenuationColor, attenuationDistance ] ) => { If( attenuationDistance.notEqual( 0 ), () => { @@ -34704,7 +34775,7 @@ const volumeAttenuation = Fn( ( [ transmissionDistance, attenuationColor, attenu ] } ); -const getIBLVolumeRefraction = Fn( ( [ n, v, roughness, diffuseColor, specularColor, specularF90, position, modelMatrix, viewMatrix, projMatrix, ior, thickness, attenuationColor, attenuationDistance, dispersion ] ) => { +const getIBLVolumeRefraction = /*@__PURE__*/ Fn( ( [ n, v, roughness, diffuseColor, specularColor, specularF90, position, modelMatrix, viewMatrix, projMatrix, ior, thickness, attenuationColor, attenuationDistance, dispersion ] ) => { let transmittedLight, transmittance; @@ -34784,7 +34855,7 @@ const getIBLVolumeRefraction = Fn( ( [ n, v, roughness, diffuseColor, specularCo // // XYZ to linear-sRGB color space -const XYZ_TO_REC709 = mat3( +const XYZ_TO_REC709 = /*@__PURE__*/ mat3( 3.2404542, - 0.9692660, 0.0556434, - 1.5371385, 1.8760108, - 0.2040259, - 0.4985314, 0.0415560, 1.0572252 @@ -34827,7 +34898,7 @@ const evalSensitivity = ( OPD, shift ) => { }; -const evalIridescence = Fn( ( { outsideIOR, eta2, cosTheta1, thinFilmThickness, baseF0 } ) => { +const evalIridescence = /*@__PURE__*/ Fn( ( { outsideIOR, eta2, cosTheta1, thinFilmThickness, baseF0 } ) => { // Force iridescenceIOR -> outsideIOR when thinFilmThickness -> 0.0 const iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) ); @@ -34907,7 +34978,7 @@ const evalIridescence = Fn( ( { outsideIOR, eta2, cosTheta1, thinFilmThickness, // This is a curve-fit approxmation to the "Charlie sheen" BRDF integrated over the hemisphere from // Estevez and Kulla 2017, "Production Friendly Microfacet Sheen BRDF". The analysis can be found // in the Sheen section of https://drive.google.com/file/d/1T0D1VSyR4AllqIJTQAraEIzjlb5h4FKH/view?usp=sharing -const IBLSheenBRDF = Fn( ( { normal, viewDir, roughness } ) => { +const IBLSheenBRDF = /*@__PURE__*/ Fn( ( { normal, viewDir, roughness } ) => { const dotNV = normal.dot( viewDir ).saturate(); @@ -35231,25 +35302,25 @@ class PhysicalLightingModel extends LightingModel { // These defines must match with PMREMGenerator -const cubeUV_r0 = float( 1.0 ); -const cubeUV_m0 = float( - 2.0 ); -const cubeUV_r1 = float( 0.8 ); -const cubeUV_m1 = float( - 1.0 ); -const cubeUV_r4 = float( 0.4 ); -const cubeUV_m4 = float( 2.0 ); -const cubeUV_r5 = float( 0.305 ); -const cubeUV_m5 = float( 3.0 ); -const cubeUV_r6 = float( 0.21 ); -const cubeUV_m6 = float( 4.0 ); +const cubeUV_r0 = /*@__PURE__*/ float( 1.0 ); +const cubeUV_m0 = /*@__PURE__*/ float( - 2.0 ); +const cubeUV_r1 = /*@__PURE__*/ float( 0.8 ); +const cubeUV_m1 = /*@__PURE__*/ float( - 1.0 ); +const cubeUV_r4 = /*@__PURE__*/ float( 0.4 ); +const cubeUV_m4 = /*@__PURE__*/ float( 2.0 ); +const cubeUV_r5 = /*@__PURE__*/ float( 0.305 ); +const cubeUV_m5 = /*@__PURE__*/ float( 3.0 ); +const cubeUV_r6 = /*@__PURE__*/ float( 0.21 ); +const cubeUV_m6 = /*@__PURE__*/ float( 4.0 ); -const cubeUV_minMipLevel = float( 4.0 ); -const cubeUV_minTileSize = float( 16.0 ); +const cubeUV_minMipLevel = /*@__PURE__*/ float( 4.0 ); +const cubeUV_minTileSize = /*@__PURE__*/ float( 16.0 ); // These shader functions convert between the UV coordinates of a single face of // a cubemap, the 0-5 integer index of a cube face, and the direction vector for // sampling a textureCube (not generally normalized ). -const getFace = Fn( ( [ direction ] ) => { +const getFace = /*@__PURE__*/ Fn( ( [ direction ] ) => { const absDirection = vec3( abs( direction ) ).toVar(); const face = float( - 1.0 ).toVar(); @@ -35291,7 +35362,7 @@ const getFace = Fn( ( [ direction ] ) => { } ); // RH coordinate system; PMREM face-indexing convention -const getUV = Fn( ( [ direction, face ] ) => { +const getUV = /*@__PURE__*/ Fn( ( [ direction, face ] ) => { const uv = vec2().toVar(); @@ -35332,7 +35403,7 @@ const getUV = Fn( ( [ direction, face ] ) => { ] } ); -const roughnessToMip = Fn( ( [ roughness ] ) => { +const roughnessToMip = /*@__PURE__*/ Fn( ( [ roughness ] ) => { const mip = float( 0.0 ).toVar(); @@ -35369,7 +35440,7 @@ const roughnessToMip = Fn( ( [ roughness ] ) => { } ); // RH coordinate system; PMREM face-indexing convention -const getDirection = Fn( ( [ uv_immutable, face ] ) => { +const getDirection = /*@__PURE__*/ Fn( ( [ uv_immutable, face ] ) => { const uv = uv_immutable.toVar(); uv.assign( mul( 2.0, uv ).sub( 1.0 ) ); @@ -35417,7 +35488,7 @@ const getDirection = Fn( ( [ uv_immutable, face ] ) => { // -const textureCubeUV = Fn( ( [ envMap, sampleDir_immutable, roughness_immutable, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP ] ) => { +const textureCubeUV = /*@__PURE__*/ Fn( ( [ envMap, sampleDir_immutable, roughness_immutable, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP ] ) => { const roughness = float( roughness_immutable ); const sampleDir = vec3( sampleDir_immutable ); @@ -35439,7 +35510,7 @@ const textureCubeUV = Fn( ( [ envMap, sampleDir_immutable, roughness_immutable, } ); -const bilinearCubeUV = Fn( ( [ envMap, direction_immutable, mipInt_immutable, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP ] ) => { +const bilinearCubeUV = /*@__PURE__*/ Fn( ( [ envMap, direction_immutable, mipInt_immutable, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP ] ) => { const mipInt = float( mipInt_immutable ).toVar(); const direction = vec3( direction_immutable ); @@ -35466,7 +35537,7 @@ const bilinearCubeUV = Fn( ( [ envMap, direction_immutable, mipInt_immutable, CU } ); -const getSample = Fn( ( { envMap, mipInt, outputDirection, theta, axis, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP } ) => { +const getSample = /*@__PURE__*/ Fn( ( { envMap, mipInt, outputDirection, theta, axis, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP } ) => { const cosTheta = cos( theta ); @@ -35479,7 +35550,7 @@ const getSample = Fn( ( { envMap, mipInt, outputDirection, theta, axis, CUBEUV_T } ); -const blur = Fn( ( { n, latitudinal, poleAxis, outputDirection, weights, samples, dTheta, mipInt, envMap, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP } ) => { +const blur = /*@__PURE__*/ Fn( ( { n, latitudinal, poleAxis, outputDirection, weights, samples, dTheta, mipInt, envMap, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP } ) => { const axis = vec3( select( latitudinal, poleAxis, cross( poleAxis, outputDirection ) ) ).toVar(); @@ -35707,7 +35778,7 @@ class PMREMNode extends TempNode { } -registerNodeClass( 'PMREM', PMREMNode ); +PMREMNode.type = /*@__PURE__*/ registerNode( 'PMREM', PMREMNode ); function isCubeMapReady( image ) { @@ -35735,7 +35806,7 @@ function isEquirectangularMapReady( image ) { } -const pmremTexture = nodeProxy( PMREMNode ); +const pmremTexture = /*@__PURE__*/ nodeProxy( PMREMNode ); const _envNodeCache = new WeakMap(); @@ -35810,7 +35881,7 @@ class EnvironmentNode extends LightingNode { } -registerNodeClass( 'Environment', EnvironmentNode ); +EnvironmentNode.type = /*@__PURE__*/ registerNode( 'Environment', EnvironmentNode ); const createRadianceContext = ( roughnessNode, normalViewNode ) => { @@ -35949,6 +36020,8 @@ class MeshStandardNodeMaterial extends NodeMaterial { } +MeshStandardNodeMaterial.type = /*@__PURE__*/ registerNodeMaterial( 'MeshStandard', MeshStandardNodeMaterial ); + const _defaultValues$5 = /*@__PURE__*/ new MeshPhysicalMaterial(); class MeshPhysicalNodeMaterial extends MeshStandardNodeMaterial { @@ -36179,6 +36252,8 @@ class MeshPhysicalNodeMaterial extends MeshStandardNodeMaterial { } +MeshPhysicalNodeMaterial.type = /*@__PURE__*/ registerNodeMaterial( 'MeshPhysical', MeshPhysicalNodeMaterial ); + class SSSLightingModel extends PhysicalLightingModel { constructor( useClearcoat, useSheen, useIridescence, useSSS ) { @@ -36253,7 +36328,9 @@ class MeshSSSNodeMaterial extends MeshPhysicalNodeMaterial { } -const getGradientIrradiance = Fn( ( { normal, lightDirection, builder } ) => { +MeshSSSNodeMaterial.type = /*@__PURE__*/ registerNodeMaterial( 'MeshSSS', MeshSSSNodeMaterial ); + +const getGradientIrradiance = /*@__PURE__*/ Fn( ( { normal, lightDirection, builder } ) => { // dotNL will be from -1.0 to 1.0 const dotNL = normal.dot( lightDirection ); @@ -36321,6 +36398,8 @@ class MeshToonNodeMaterial extends NodeMaterial { } +MeshToonNodeMaterial.type = /*@__PURE__*/ registerNodeMaterial( 'MeshToon', MeshToonNodeMaterial ); + class MatcapUVNode extends TempNode { constructor() { @@ -36340,9 +36419,9 @@ class MatcapUVNode extends TempNode { } -registerNodeClass( 'MatcapUV', MatcapUVNode ); +MatcapUVNode.type = /*@__PURE__*/ registerNode( 'MatcapUV', MatcapUVNode ); -const matcapUV = nodeImmutable( MatcapUVNode ); +const matcapUV = /*@__PURE__*/ nodeImmutable( MatcapUVNode ); const _defaultValues$3 = /*@__PURE__*/ new MeshMatcapMaterial(); @@ -36384,6 +36463,8 @@ class MeshMatcapNodeMaterial extends NodeMaterial { } +MeshMatcapNodeMaterial.type = /*@__PURE__*/ registerNodeMaterial( 'MeshMatcap', MeshMatcapNodeMaterial ); + const _defaultValues$2 = /*@__PURE__*/ new PointsMaterial(); class PointsNodeMaterial extends NodeMaterial { @@ -36415,6 +36496,8 @@ class PointsNodeMaterial extends NodeMaterial { } +PointsNodeMaterial.type = /*@__PURE__*/ registerNodeMaterial( 'Points', PointsNodeMaterial ); + class RotateNode extends TempNode { constructor( positionNode, rotationNode ) { @@ -36465,9 +36548,9 @@ class RotateNode extends TempNode { } -registerNodeClass( 'Rotate', RotateNode ); +RotateNode.type = /*@__PURE__*/ registerNode( 'Rotate', RotateNode ); -const rotate = nodeProxy( RotateNode ); +const rotate = /*@__PURE__*/ nodeProxy( RotateNode ); const _defaultValues$1 = /*@__PURE__*/ new SpriteMaterial(); @@ -36545,6 +36628,8 @@ class SpriteNodeMaterial extends NodeMaterial { } +SpriteNodeMaterial.type = /*@__PURE__*/ registerNodeMaterial( 'Sprite', SpriteNodeMaterial ); + class ShadowMaskModel extends LightingModel { constructor() { @@ -36597,6 +36682,8 @@ class ShadowNodeMaterial extends NodeMaterial { } +ShadowNodeMaterial.type = /*@__PURE__*/ registerNodeMaterial( 'Shadow', ShadowNodeMaterial ); + const normal = Fn( ( { texture, uv } ) => { const epsilon = 0.0001; @@ -36688,9 +36775,9 @@ class Texture3DNode extends TextureNode { } -registerNodeClass( 'Texture3D', Texture3DNode ); +Texture3DNode.type = /*@__PURE__*/ registerNode( 'Texture3D', Texture3DNode ); -const texture3D = nodeProxy( Texture3DNode ); +const texture3D = /*@__PURE__*/ nodeProxy( Texture3DNode ); class VolumeNodeMaterial extends NodeMaterial { @@ -36782,6 +36869,8 @@ class VolumeNodeMaterial extends NodeMaterial { } +VolumeNodeMaterial.type = /*@__PURE__*/ registerNodeMaterial( 'Volume', VolumeNodeMaterial ); + // converts an array to a specific type function convertArray( array, type, forceClone ) { @@ -50630,7 +50719,7 @@ class ParameterNode extends PropertyNode { } -registerNodeClass( 'Parameter', ParameterNode ); +ParameterNode.type = /*@__PURE__*/ registerNode( 'Parameter', ParameterNode ); const parameter = ( type, name ) => nodeObject( new ParameterNode( type, name ) ); @@ -50706,9 +50795,9 @@ class CodeNode extends Node { } -registerNodeClass( 'Code', CodeNode ); +CodeNode.type = /*@__PURE__*/ registerNode( 'Code', CodeNode ); -const code = nodeProxy( CodeNode ); +const code = /*@__PURE__*/ nodeProxy( CodeNode ); const js = ( src, includes ) => code( src, includes, 'js' ); const wgsl = ( src, includes ) => code( src, includes, 'wgsl' ); @@ -50791,7 +50880,7 @@ class FunctionNode extends CodeNode { } -registerNodeClass( 'Function', FunctionNode ); +FunctionNode.type = /*@__PURE__*/ registerNode( 'Function', FunctionNode ); const nativeFn = ( code, includes = [], language = '' ) => { @@ -51176,9 +51265,9 @@ class StackNode extends Node { } -registerNodeClass( 'Stack', StackNode ); +StackNode.type = /*@__PURE__*/ registerNode( 'Stack', StackNode ); -const stack = nodeProxy( StackNode ); +const stack = /*@__PURE__*/ nodeProxy( StackNode ); const LOD_MIN = 4; @@ -51847,10 +51936,8 @@ function _createRenderTarget( width, height, params ) { function _setViewport( target, x, y, width, height ) { - const viewY = target.height - height - y; - - target.viewport.set( x, viewY, width, height ); - target.scissor.set( x, viewY, width, height ); + target.viewport.set( x, y, width, height ); + target.scissor.set( x, y, width, height ); } @@ -52508,7 +52595,7 @@ class NodeBuilder { } - needsColorSpaceToLinear( /*texture*/ ) { + needsColorSpaceToLinearSRGB( /*texture*/ ) { return false; @@ -53530,7 +53617,7 @@ class StructTypeNode extends Node { } -registerNodeClass( 'StructType', StructTypeNode ); +StructTypeNode.type = /*@__PURE__*/ registerNode( 'StructType', StructTypeNode ); class OutputStructNode extends Node { @@ -53582,9 +53669,9 @@ class OutputStructNode extends Node { } -registerNodeClass( 'OutputStruct', OutputStructNode ); +OutputStructNode.type = /*@__PURE__*/ registerNode( 'OutputStruct', OutputStructNode ); -const outputStruct = nodeProxy( OutputStructNode ); +const outputStruct = /*@__PURE__*/ nodeProxy( OutputStructNode ); function getTextureIndex( textures, name ) { @@ -53659,9 +53746,9 @@ class MRTNode extends OutputStructNode { } -registerNodeClass( 'MRT', MRTNode ); +MRTNode.type = /*@__PURE__*/ registerNode( 'MRT', MRTNode ); -const mrt = nodeProxy( MRTNode ); +const mrt = /*@__PURE__*/ nodeProxy( MRTNode ); class FunctionOverloadingNode extends Node { @@ -53750,9 +53837,9 @@ class FunctionOverloadingNode extends Node { } -registerNodeClass( 'FunctionOverloading', FunctionOverloadingNode ); +FunctionOverloadingNode.type = /*@__PURE__*/ registerNode( 'FunctionOverloading', FunctionOverloadingNode ); -const overloadingBaseFn = nodeProxy( FunctionOverloadingNode ); +const overloadingBaseFn = /*@__PURE__*/ nodeProxy( FunctionOverloadingNode ); const overloadingFn = ( functionNodes ) => ( ...params ) => overloadingBaseFn( functionNodes, ...params ); @@ -53836,13 +53923,13 @@ TimerNode.GLOBAL = 'global'; TimerNode.DELTA = 'delta'; TimerNode.FRAME = 'frame'; -registerNodeClass( 'Timer', TimerNode ); +TimerNode.type = /*@__PURE__*/ registerNode( 'Timer', TimerNode ); // @TODO: add support to use node in timeScale const timerLocal = ( timeScale, value = 0 ) => nodeObject( new TimerNode( TimerNode.LOCAL, timeScale, value ) ); const timerGlobal = ( timeScale, value = 0 ) => nodeObject( new TimerNode( TimerNode.GLOBAL, timeScale, value ) ); const timerDelta = ( timeScale, value = 0 ) => nodeObject( new TimerNode( TimerNode.DELTA, timeScale, value ) ); -const frameId = nodeImmutable( TimerNode, TimerNode.FRAME ).toUint(); +const frameId = /*@__PURE__*/ nodeImmutable( TimerNode, TimerNode.FRAME ).toUint(); class OscNode extends Node { @@ -53913,12 +54000,12 @@ OscNode.SQUARE = 'square'; OscNode.TRIANGLE = 'triangle'; OscNode.SAWTOOTH = 'sawtooth'; -registerNodeClass( 'Osc', OscNode ); +OscNode.type = /*@__PURE__*/ registerNode( 'Osc', OscNode ); -const oscSine = nodeProxy( OscNode, OscNode.SINE ); -const oscSquare = nodeProxy( OscNode, OscNode.SQUARE ); -const oscTriangle = nodeProxy( OscNode, OscNode.TRIANGLE ); -const oscSawtooth = nodeProxy( OscNode, OscNode.SAWTOOTH ); +const oscSine = /*@__PURE__*/ nodeProxy( OscNode, OscNode.SINE ); +const oscSquare = /*@__PURE__*/ nodeProxy( OscNode, OscNode.SQUARE ); +const oscTriangle = /*@__PURE__*/ nodeProxy( OscNode, OscNode.TRIANGLE ); +const oscSawtooth = /*@__PURE__*/ nodeProxy( OscNode, OscNode.SAWTOOTH ); class SpriteSheetUVNode extends Node { @@ -53952,9 +54039,9 @@ class SpriteSheetUVNode extends Node { } -registerNodeClass( 'SpriteSheetUV', SpriteSheetUVNode ); +SpriteSheetUVNode.type = /*@__PURE__*/ registerNode( 'SpriteSheetUV', SpriteSheetUVNode ); -const spritesheetUV = nodeProxy( SpriteSheetUVNode ); +const spritesheetUV = /*@__PURE__*/ nodeProxy( SpriteSheetUVNode ); class StorageArrayElementNode extends ArrayElementNode { @@ -54036,9 +54123,9 @@ class StorageArrayElementNode extends ArrayElementNode { } -registerNodeClass( 'StorageArrayElement', StorageArrayElementNode ); +StorageArrayElementNode.type = /*@__PURE__*/ registerNode( 'StorageArrayElement', StorageArrayElementNode ); -const storageElement = nodeProxy( StorageArrayElementNode ); +const storageElement = /*@__PURE__*/ nodeProxy( StorageArrayElementNode ); class TriplanarTexturesNode extends Node { @@ -54087,9 +54174,9 @@ class TriplanarTexturesNode extends Node { } -registerNodeClass( 'TriplanarTextures', TriplanarTexturesNode ); +TriplanarTexturesNode.type = /*@__PURE__*/ registerNode( 'TriplanarTextures', TriplanarTexturesNode ); -const triplanarTextures = nodeProxy( TriplanarTexturesNode ); +const triplanarTextures = /*@__PURE__*/ nodeProxy( TriplanarTexturesNode ); const triplanarTexture = ( ...params ) => triplanarTextures( ...params ); const _reflectorPlane = new Plane(); @@ -54314,7 +54401,7 @@ class ReflectorNode extends TextureNode { const reflector = ( parameters ) => nodeObject( new ReflectorNode( parameters ) ); -registerNodeClass( 'Reflector', ReflectorNode ); +ReflectorNode.type = /*@__PURE__*/ registerNode( 'Reflector', ReflectorNode ); // Helper for passes that need to fill the viewport with a single quad. @@ -54477,7 +54564,7 @@ class RTTNode extends TextureNode { } -registerNodeClass( 'RTT', RTTNode ); +RTTNode.type = /*@__PURE__*/ registerNode( 'RTT', RTTNode ); const rtt = ( node, ...params ) => nodeObject( new RTTNode( nodeObject( node ), ...params ) ); const convertToTexture = ( node, ...params ) => node.isTextureNode ? node : rtt( node, ...params ); @@ -54542,7 +54629,7 @@ class VertexColorNode extends AttributeNode { } -registerNodeClass( 'VertexColor', VertexColorNode ); +VertexColorNode.type = /*@__PURE__*/ registerNode( 'VertexColor', VertexColorNode ); const vertexColor = ( ...params ) => nodeObject( new VertexColorNode( ...params ) ); @@ -54564,9 +54651,9 @@ class PointUVNode extends Node { } -registerNodeClass( 'PointUV', PointUVNode ); +PointUVNode.type = /*@__PURE__*/ registerNode( 'PointUV', PointUVNode ); -const pointUV = nodeImmutable( PointUVNode ); +const pointUV = /*@__PURE__*/ nodeImmutable( PointUVNode ); class SceneNode extends Node { @@ -54609,10 +54696,10 @@ class SceneNode extends Node { SceneNode.BACKGROUND_BLURRINESS = 'backgroundBlurriness'; SceneNode.BACKGROUND_INTENSITY = 'backgroundIntensity'; -registerNodeClass( 'Scene', SceneNode ); +SceneNode.type = /*@__PURE__*/ registerNode( 'Scene', SceneNode ); -const backgroundBlurriness = nodeImmutable( SceneNode, SceneNode.BACKGROUND_BLURRINESS ); -const backgroundIntensity = nodeImmutable( SceneNode, SceneNode.BACKGROUND_INTENSITY ); +const backgroundBlurriness = /*@__PURE__*/ nodeImmutable( SceneNode, SceneNode.BACKGROUND_BLURRINESS ); +const backgroundIntensity = /*@__PURE__*/ nodeImmutable( SceneNode, SceneNode.BACKGROUND_INTENSITY ); const GPUPrimitiveTopology = { PointList: 'point-list', @@ -55024,7 +55111,7 @@ class StorageBufferNode extends BufferNode { } -registerNodeClass( 'StorageBuffer', StorageBufferNode ); +StorageBufferNode.type = /*@__PURE__*/ registerNode( 'StorageBuffer', StorageBufferNode ); // Read-Write Storage const storage = ( value, type, count ) => nodeObject( new StorageBufferNode( value, type, count ) ); @@ -55114,9 +55201,9 @@ class StorageTextureNode extends TextureNode { } -registerNodeClass( 'StorageTexture', StorageTextureNode ); +StorageTextureNode.type = /*@__PURE__*/ registerNode( 'StorageTexture', StorageTextureNode ); -const storageTexture = nodeProxy( StorageTextureNode ); +const storageTexture = /*@__PURE__*/ nodeProxy( StorageTextureNode ); const textureStore = ( value, uvNode, storeNode ) => { @@ -55148,7 +55235,7 @@ class UserDataNode extends ReferenceNode { } -registerNodeClass( 'UserData', UserDataNode ); +UserDataNode.type = /*@__PURE__*/ registerNode( 'UserData', UserDataNode ); const userData = ( name, inputType, userData ) => nodeObject( new UserDataNode( name, inputType, userData ) ); @@ -55173,9 +55260,9 @@ class PosterizeNode extends TempNode { } -registerNodeClass( 'Posterize', PosterizeNode ); +PosterizeNode.type = /*@__PURE__*/ registerNode( 'Posterize', PosterizeNode ); -const posterize = nodeProxy( PosterizeNode ); +const posterize = /*@__PURE__*/ nodeProxy( PosterizeNode ); let _sharedFramebuffer = null; @@ -55201,9 +55288,9 @@ class ViewportSharedTextureNode extends ViewportTextureNode { } -registerNodeClass( 'ViewportSharedTexture', ViewportSharedTextureNode ); +ViewportSharedTextureNode.type = /*@__PURE__*/ registerNode( 'ViewportSharedTexture', ViewportSharedTextureNode ); -const viewportSharedTexture = nodeProxy( ViewportSharedTextureNode ); +const viewportSharedTexture = /*@__PURE__*/ nodeProxy( ViewportSharedTextureNode ); const _size$7 = /*@__PURE__*/ new Vector2(); @@ -55235,7 +55322,7 @@ class PassTextureNode extends TextureNode { } -registerNodeClass( 'PassTexture', PassTextureNode ); +PassTextureNode.type = /*@__PURE__*/ registerNode( 'PassTexture', PassTextureNode ); class PassMultipleTextureNode extends PassTextureNode { @@ -55270,7 +55357,7 @@ class PassMultipleTextureNode extends PassTextureNode { } -registerNodeClass( 'PassMultipleTexture', PassMultipleTextureNode ); +PassMultipleTextureNode.type = /*@__PURE__*/ registerNode( 'PassMultipleTexture', PassMultipleTextureNode ); class PassNode extends TempNode { @@ -55552,7 +55639,7 @@ class PassNode extends TempNode { PassNode.COLOR = 'color'; PassNode.DEPTH = 'depth'; -registerNodeClass( 'Pass', PassNode ); +PassNode.type = /*@__PURE__*/ registerNode( 'Pass', PassNode ); const pass = ( scene, camera, options ) => nodeObject( new PassNode( PassNode.COLOR, scene, camera, options ) ); const passTexture = ( pass, texture ) => nodeObject( new PassTextureNode( pass, texture ) ); @@ -55748,7 +55835,7 @@ class GaussianBlurNode extends TempNode { } -registerNodeClass( 'GaussianBlur', GaussianBlurNode ); +GaussianBlurNode.type = /*@__PURE__*/ registerNode( 'GaussianBlur', GaussianBlurNode ); const gaussianBlur = ( node, directionNode, sigma ) => nodeObject( new GaussianBlurNode( convertToTexture( node ), directionNode, sigma ) ); @@ -55888,19 +55975,19 @@ class AfterImageNode extends TempNode { const afterImage = ( node, damp ) => nodeObject( new AfterImageNode( convertToTexture( node ), damp ) ); -const grayscale = /*#__PURE__*/ Fn( ( [ color ] ) => { +const grayscale = /*@__PURE__*/ Fn( ( [ color ] ) => { return luminance( color.rgb ); } ); -const saturation = /*#__PURE__*/ Fn( ( [ color, adjustment = float( 1 ) ] ) => { +const saturation = /*@__PURE__*/ Fn( ( [ color, adjustment = float( 1 ) ] ) => { return adjustment.mix( luminance( color.rgb ), color.rgb ); } ); -const vibrance = /*#__PURE__*/ Fn( ( [ color, adjustment = float( 1 ) ] ) => { +const vibrance = /*@__PURE__*/ Fn( ( [ color, adjustment = float( 1 ) ] ) => { const average = add( color.r, color.g, color.b ).div( 3.0 ); @@ -55911,7 +55998,7 @@ const vibrance = /*#__PURE__*/ Fn( ( [ color, adjustment = float( 1 ) ] ) => { } ); -const hue = /*#__PURE__*/ Fn( ( [ color, adjustment = float( 1 ) ] ) => { +const hue = /*@__PURE__*/ Fn( ( [ color, adjustment = float( 1 ) ] ) => { const k = vec3( 0.57735, 0.57735, 0.57735 ); @@ -55921,7 +56008,7 @@ const hue = /*#__PURE__*/ Fn( ( [ color, adjustment = float( 1 ) ] ) => { } ); -const _luminanceCoefficients = /*#__PURE__*/ new Vector3(); +const _luminanceCoefficients = /*@__PURE__*/ new Vector3(); const luminance = ( color, luminanceCoefficients = vec3( ... ColorManagement.getLuminanceCoefficients( _luminanceCoefficients ) ) @@ -56164,7 +56251,7 @@ class SobelOperatorNode extends TempNode { } -registerNodeClass( 'SobelOperator', SobelOperatorNode ); +SobelOperatorNode.type = /*@__PURE__*/ registerNode( 'SobelOperator', SobelOperatorNode ); const sobel = ( node ) => nodeObject( new SobelOperatorNode( convertToTexture( node ) ) ); @@ -56275,7 +56362,7 @@ class DepthOfFieldNode extends TempNode { } -registerNodeClass( 'DepthOfField', DepthOfFieldNode ); +DepthOfFieldNode.type = /*@__PURE__*/ registerNode( 'DepthOfField', DepthOfFieldNode ); const dof = ( node, viewZNode, focus = 1, aperture = 0.025, maxblur = 1 ) => nodeObject( new DepthOfFieldNode( convertToTexture( node ), nodeObject( viewZNode ), nodeObject( focus ), nodeObject( aperture ), nodeObject( maxblur ) ) ); @@ -56326,7 +56413,7 @@ class DotScreenNode extends TempNode { } -registerNodeClass( 'DotScreen', DotScreenNode ); +DotScreenNode.type = /*@__PURE__*/ registerNode( 'DotScreen', DotScreenNode ); const dotScreen = ( node, center, angle, scale ) => nodeObject( new DotScreenNode( nodeObject( node ), center, angle, scale ) ); @@ -56367,7 +56454,7 @@ class RGBShiftNode extends TempNode { } -registerNodeClass( 'RGBShift', RGBShiftNode ); +RGBShiftNode.type = /*@__PURE__*/ registerNode( 'RGBShift', RGBShiftNode ); const rgbShift = ( node, amount, angle ) => nodeObject( new RGBShiftNode( convertToTexture( node ), amount, angle ) ); @@ -56412,9 +56499,9 @@ class FilmNode extends TempNode { } -registerNodeClass( 'Film', FilmNode ); +FilmNode.type = /*@__PURE__*/ registerNode( 'Film', FilmNode ); -const film = nodeProxy( FilmNode ); +const film = /*@__PURE__*/ nodeProxy( FilmNode ); class Lut3DNode extends TempNode { @@ -56459,7 +56546,7 @@ class Lut3DNode extends TempNode { } -registerNodeClass( 'Lut3D', Lut3DNode ); +Lut3DNode.type = /*@__PURE__*/ registerNode( 'Lut3D', Lut3DNode ); const lut3D = ( node, lut, size, intensity ) => nodeObject( new Lut3DNode( nodeObject( node ), nodeObject( lut ), size, nodeObject( intensity ) ) ); @@ -56680,7 +56767,7 @@ class GTAONode extends TempNode { } -registerNodeClass( 'GTAO', GTAONode ); +GTAONode.type = /*@__PURE__*/ registerNode( 'GTAO', GTAONode ); function generateMagicSquareNoise( size = 5 ) { @@ -56915,7 +57002,7 @@ class DenoiseNode extends TempNode { } -registerNodeClass( 'Denoise', DenoiseNode ); +DenoiseNode.type = /*@__PURE__*/ registerNode( 'Denoise', DenoiseNode ); function generatePdSamplePointInitializer( samples, rings, radiusExponent ) { @@ -57263,7 +57350,7 @@ class FXAANode extends TempNode { } -registerNodeClass( 'FXAA', FXAANode ); +FXAANode.type = /*@__PURE__*/ registerNode( 'FXAA', FXAANode ); const fxaa = ( node ) => nodeObject( new FXAANode( convertToTexture( node ) ) ); @@ -57645,7 +57732,7 @@ class TransitionNode extends TempNode { } -registerNodeClass( 'Transition', TransitionNode ); +TransitionNode.type = /*@__PURE__*/ registerNode( 'Transition', TransitionNode ); const transition = ( nodeA, nodeB, mixTexture, mixRatio = 0.0, threshold = 0.1, useTexture = 0 ) => nodeObject( new TransitionNode( convertToTexture( nodeA ), convertToTexture( nodeB ), convertToTexture( mixTexture ), nodeObject( mixRatio ), nodeObject( threshold ), nodeObject( useTexture ) ) ); @@ -57788,7 +57875,7 @@ class PixelationNode extends TempNode { } -registerNodeClass( 'Pixelation', PixelationNode ); +PixelationNode.type = /*@__PURE__*/ registerNode( 'Pixelation', PixelationNode ); const pixelation = ( node, depthNode, normalNode, pixelSize = 6, normalEdgeStrength = 0.3, depthEdgeStrength = 0.4 ) => nodeObject( new PixelationNode( convertToTexture( node ), convertToTexture( depthNode ), convertToTexture( normalNode ), nodeObject( pixelSize ), nodeObject( normalEdgeStrength ), nodeObject( depthEdgeStrength ) ) ); @@ -57836,7 +57923,7 @@ class PixelationPassNode extends PassNode { const pixelationPass = ( scene, camera, pixelSize, normalEdgeStrength, depthEdgeStrength ) => nodeObject( new PixelationPassNode( scene, camera, pixelSize, normalEdgeStrength, depthEdgeStrength ) ); -registerNodeClass( 'PixelationPass', PixelationPassNode ); +PixelationPassNode.type = /*@__PURE__*/ registerNode( 'PixelationPass', PixelationPassNode ); const _size$3 = /*@__PURE__*/ new Vector2(); @@ -58068,7 +58155,7 @@ class SSAAPassNode extends PassNode { } -registerNodeClass( 'SSAAPass', SSAAPassNode ); +SSAAPassNode.type = /*@__PURE__*/ registerNode( 'SSAAPass', SSAAPassNode ); // These jitter vectors are specified in integers because it is easier. // I am assuming a [-8,8) integer grid, but it needs to be mapped onto [-0.5,0.5) @@ -58178,7 +58265,7 @@ class StereoPassNode extends PassNode { } -registerNodeClass( 'StereoPass', StereoPassNode ); +StereoPassNode.type = /*@__PURE__*/ registerNode( 'StereoPass', StereoPassNode ); const stereoPass = ( scene, camera ) => nodeObject( new StereoPassNode( scene, camera ) ); @@ -58276,7 +58363,7 @@ class StereoCompositePassNode extends PassNode { } -registerNodeClass( 'StereoCompositePass', StereoCompositePassNode ); +StereoCompositePassNode.type = /*@__PURE__*/ registerNode( 'StereoCompositePass', StereoCompositePassNode ); class AnaglyphPassNode extends StereoCompositePassNode { @@ -58372,7 +58459,7 @@ class ParallaxBarrierPassNode extends StereoCompositePassNode { } -registerNodeClass( 'ParallaxBarrierPass', ParallaxBarrierPassNode ); +ParallaxBarrierPassNode.type = /*@__PURE__*/ registerNode( 'ParallaxBarrierPass', ParallaxBarrierPassNode ); const parallaxBarrierPass = ( scene, camera ) => nodeObject( new ParallaxBarrierPassNode( scene, camera ) ); @@ -58531,9 +58618,9 @@ class ScriptableValueNode extends Node { } -registerNodeClass( 'ScriptableValue', ScriptableValueNode ); +ScriptableValueNode.type = /*@__PURE__*/ registerNode( 'ScriptableValue', ScriptableValueNode ); -const scriptableValue = nodeProxy( ScriptableValueNode ); +const scriptableValue = /*@__PURE__*/ nodeProxy( ScriptableValueNode ); class Resources extends Map { @@ -59026,9 +59113,9 @@ class ScriptableNode extends Node { } -registerNodeClass( 'Scriptable', ScriptableNode ); +ScriptableNode.type = /*@__PURE__*/ registerNode( 'Scriptable', ScriptableNode ); -const scriptable = nodeProxy( ScriptableNode ); +const scriptable = /*@__PURE__*/ nodeProxy( ScriptableNode ); class FogNode extends Node { @@ -59067,9 +59154,9 @@ class FogNode extends Node { } -registerNodeClass( 'Fog', FogNode ); +FogNode.type = /*@__PURE__*/ registerNode( 'Fog', FogNode ); -const fog = nodeProxy( FogNode ); +const fog = /*@__PURE__*/ nodeProxy( FogNode ); class FogRangeNode extends FogNode { @@ -59094,9 +59181,9 @@ class FogRangeNode extends FogNode { } -registerNodeClass( 'FogRange', FogRangeNode ); +FogRangeNode.type = /*@__PURE__*/ registerNode( 'FogRange', FogRangeNode ); -const rangeFog = nodeProxy( FogRangeNode ); +const rangeFog = /*@__PURE__*/ nodeProxy( FogRangeNode ); class FogExp2Node extends FogNode { @@ -59121,9 +59208,9 @@ class FogExp2Node extends FogNode { } -registerNodeClass( 'FogExp2', FogExp2Node ); +FogExp2Node.type = /*@__PURE__*/ registerNode( 'FogExp2', FogExp2Node ); -const densityFog = nodeProxy( FogExp2Node ); +const densityFog = /*@__PURE__*/ nodeProxy( FogExp2Node ); let min = null; let max = null; @@ -59226,9 +59313,9 @@ class RangeNode extends Node { } -registerNodeClass( 'Range', RangeNode ); +RangeNode.type = /*@__PURE__*/ registerNode( 'Range', RangeNode ); -const range = nodeProxy( RangeNode ); +const range = /*@__PURE__*/ nodeProxy( RangeNode ); class LightNode extends Node { @@ -59277,9 +59364,9 @@ class LightNode extends Node { LightNode.TARGET_DIRECTION = 'targetDirection'; -registerNodeClass( 'Light', LightNode ); +LightNode.type = /*@__PURE__*/ registerNode( 'Light', LightNode ); -const lightTargetDirection = nodeProxy( LightNode, LightNode.TARGET_DIRECTION ); +const lightTargetDirection = /*@__PURE__*/ nodeProxy( LightNode, LightNode.TARGET_DIRECTION ); const BasicShadowMap = Fn( ( { depthTexture, shadowCoord } ) => { @@ -59615,9 +59702,9 @@ class AnalyticLightNode extends LightingNode { } -registerNodeClass( 'AnalyticLight', AnalyticLightNode ); +AnalyticLightNode.type = /*@__PURE__*/ registerNode( 'AnalyticLight', AnalyticLightNode ); -const getDistanceAttenuation = Fn( ( inputs ) => { +const getDistanceAttenuation = /*@__PURE__*/ Fn( ( inputs ) => { const { lightDistance, cutoffDistance, decayExponent } = inputs; @@ -59686,7 +59773,7 @@ class PointLightNode extends AnalyticLightNode { } -registerNodeClass( 'PointLight', PointLightNode ); +PointLightNode.type = /*@__PURE__*/ registerNode( 'PointLight', PointLightNode ); class DirectionalLightNode extends AnalyticLightNode { @@ -59716,7 +59803,7 @@ class DirectionalLightNode extends AnalyticLightNode { } -registerNodeClass( 'DirectionalLight', DirectionalLightNode ); +DirectionalLightNode.type = /*@__PURE__*/ registerNode( 'DirectionalLight', DirectionalLightNode ); const _matrix41 = /*@__PURE__*/ new Matrix4(); const _matrix42 = /*@__PURE__*/ new Matrix4(); @@ -59799,7 +59886,7 @@ class RectAreaLightNode extends AnalyticLightNode { } -registerNodeClass( 'RectAreaLight', RectAreaLightNode ); +RectAreaLightNode.type = /*@__PURE__*/ registerNode( 'RectAreaLight', RectAreaLightNode ); class SpotLightNode extends AnalyticLightNode { @@ -59873,7 +59960,7 @@ class SpotLightNode extends AnalyticLightNode { } -registerNodeClass( 'SpotLight', SpotLightNode ); +SpotLightNode.type = /*@__PURE__*/ registerNode( 'SpotLight', SpotLightNode ); class IESSpotLightNode extends SpotLightNode { @@ -59901,7 +59988,7 @@ class IESSpotLightNode extends SpotLightNode { } -registerNodeClass( 'IESSpotLight', IESSpotLightNode ); +IESSpotLightNode.type = /*@__PURE__*/ registerNode( 'IESSpotLight', IESSpotLightNode ); class AmbientLightNode extends AnalyticLightNode { @@ -59919,7 +60006,7 @@ class AmbientLightNode extends AnalyticLightNode { } -registerNodeClass( 'AmbientLight', AmbientLightNode ); +AmbientLightNode.type = /*@__PURE__*/ registerNode( 'AmbientLight', AmbientLightNode ); class HemisphereLightNode extends AnalyticLightNode { @@ -59961,7 +60048,7 @@ class HemisphereLightNode extends AnalyticLightNode { } -registerNodeClass( 'HemisphereLight', HemisphereLightNode ); +HemisphereLightNode.type = /*@__PURE__*/ registerNode( 'HemisphereLight', HemisphereLightNode ); class LightProbeNode extends AnalyticLightNode { @@ -60003,9 +60090,9 @@ class LightProbeNode extends AnalyticLightNode { } -registerNodeClass( 'LightProbe', LightProbeNode ); +LightProbeNode.type = /*@__PURE__*/ registerNode( 'LightProbe', LightProbeNode ); -const shGetIrradianceAt = Fn( ( [ normal, shCoefficients ] ) => { +const shGetIrradianceAt = /*@__PURE__*/ Fn( ( [ normal, shCoefficients ] ) => { // normal is assumed to have unit length @@ -60939,7 +61026,7 @@ class Color4 extends Color { } -const hash = Fn( ( [ seed ] ) => { +const hash = /*@__PURE__*/ Fn( ( [ seed ] ) => { // Taken from https://www.shadertoy.com/view/XlGcRh, originally from pcg-random.org @@ -60960,7 +61047,7 @@ const sinc = ( x, k ) => sin( PI.mul( k.mul( x ).sub( 1.0 ) ) ).div( PI.mul( k.m // https://github.com/cabbibo/glsl-tri-noise-3d -const tri = Fn( ( [ x ] ) => { +const tri = /*@__PURE__*/ Fn( ( [ x ] ) => { return x.fract().sub( .5 ).abs(); @@ -60972,7 +61059,7 @@ const tri = Fn( ( [ x ] ) => { ] } ); -const tri3 = Fn( ( [ p ] ) => { +const tri3 = /*@__PURE__*/ Fn( ( [ p ] ) => { return vec3( tri( p.z.add( tri( p.y.mul( 1. ) ) ) ), tri( p.z.add( tri( p.x.mul( 1. ) ) ) ), tri( p.y.add( tri( p.x.mul( 1. ) ) ) ) ); @@ -60984,7 +61071,7 @@ const tri3 = Fn( ( [ p ] ) => { ] } ); -const triNoise3D = Fn( ( [ p_immutable, spd, time ] ) => { +const triNoise3D = /*@__PURE__*/ Fn( ( [ p_immutable, spd, time ] ) => { const p = vec3( p_immutable ).toVar(); const z = float( 1.4 ).toVar(); @@ -61017,13 +61104,13 @@ const triNoise3D = Fn( ( [ p_immutable, spd, time ] ) => { ] } ); -const rotateUV = Fn( ( [ uv, rotation, center = vec2( 0.5 ) ] ) => { +const rotateUV = /*@__PURE__*/ Fn( ( [ uv, rotation, center = vec2( 0.5 ) ] ) => { return rotate( uv.sub( center ), rotation ).add( center ); } ); -const spherizeUV = Fn( ( [ uv, strength, center = vec2( 0.5 ) ] ) => { +const spherizeUV = /*@__PURE__*/ Fn( ( [ uv, strength, center = vec2( 0.5 ) ] ) => { const delta = uv.sub( center ); const delta2 = delta.dot( delta ); @@ -61034,7 +61121,7 @@ const spherizeUV = Fn( ( [ uv, strength, center = vec2( 0.5 ) ] ) => { } ); -const billboarding = Fn( ( { position = null, horizontal = true, vertical = false } ) => { +const billboarding = /*@__PURE__*/ Fn( ( { position = null, horizontal = true, vertical = false } ) => { let worldMatrix; @@ -61077,7 +61164,7 @@ const billboarding = Fn( ( { position = null, horizontal = true, vertical = fals } ); -const viewportSafeUV = Fn( ( [ uv = null ] ) => { +const viewportSafeUV = /*@__PURE__*/ Fn( ( [ uv = null ] ) => { const depth = linearDepth(); const depthDiff = linearDepth( viewportDepthTexture( uv ) ).sub( depth ); @@ -61154,11 +61241,11 @@ function getPreviousMatrix( object ) { } -registerNodeClass( 'Velocity', VelocityNode ); +VelocityNode.type = /*@__PURE__*/ registerNode( 'Velocity', VelocityNode ); -const velocity = nodeImmutable( VelocityNode ); +const velocity = /*@__PURE__*/ nodeImmutable( VelocityNode ); -const burn = /*#__PURE__*/ Fn( ( [ base, blend ] ) => { +const burn = /*@__PURE__*/ Fn( ( [ base, blend ] ) => { return min$1( 1.0, base.oneMinus().div( blend ) ).oneMinus(); @@ -61171,7 +61258,7 @@ const burn = /*#__PURE__*/ Fn( ( [ base, blend ] ) => { ] } ); -const dodge = /*#__PURE__*/ Fn( ( [ base, blend ] ) => { +const dodge = /*@__PURE__*/ Fn( ( [ base, blend ] ) => { return min$1( base.div( blend.oneMinus() ), 1.0 ); @@ -61184,7 +61271,7 @@ const dodge = /*#__PURE__*/ Fn( ( [ base, blend ] ) => { ] } ); -const screen = /*#__PURE__*/ Fn( ( [ base, blend ] ) => { +const screen = /*@__PURE__*/ Fn( ( [ base, blend ] ) => { return base.oneMinus().mul( blend.oneMinus() ).oneMinus(); @@ -61197,7 +61284,7 @@ const screen = /*#__PURE__*/ Fn( ( [ base, blend ] ) => { ] } ); -const overlay = /*#__PURE__*/ Fn( ( [ base, blend ] ) => { +const overlay = /*@__PURE__*/ Fn( ( [ base, blend ] ) => { return mix( base.mul( 2.0 ).mul( blend ), base.oneMinus().mul( 2.0 ).mul( blend.oneMinus() ).oneMinus(), step( 0.5, base ) ); @@ -61210,7 +61297,7 @@ const overlay = /*#__PURE__*/ Fn( ( [ base, blend ] ) => { ] } ); -const motionBlur = /*#__PURE__*/ Fn( ( [ inputNode, velocity, numSamples = int( 16 ) ] ) => { +const motionBlur = /*@__PURE__*/ Fn( ( [ inputNode, velocity, numSamples = int( 16 ) ] ) => { const sampleColor = ( uv ) => inputNode.uv( uv ); @@ -61270,7 +61357,7 @@ const sepia = /*@__PURE__*/ Fn( ( [ color ] ) => { } ); -const sRGBToLinearShader = Fn( ( [ color ] ) => { +const sRGBToLinear = /*@__PURE__*/ Fn( ( [ color ] ) => { const a = color.mul( 0.9478672986 ).add( 0.0521327014 ).pow( 2.4 ); const b = color.mul( 0.0773993808 ); @@ -61281,14 +61368,14 @@ const sRGBToLinearShader = Fn( ( [ color ] ) => { return rgbResult; } ).setLayout( { - name: 'sRGBToLinearShader', + name: 'sRGBToLinear', type: 'vec3', inputs: [ { name: 'color', type: 'vec3' } ] } ); -const LinearTosRGBShader = Fn( ( [ color ] ) => { +const LinearTosRGB = /*@__PURE__*/ Fn( ( [ color ] ) => { const a = color.pow( 0.41666 ).mul( 1.055 ).sub( 0.055 ); const b = color.mul( 12.92 ); @@ -61299,7 +61386,7 @@ const LinearTosRGBShader = Fn( ( [ color ] ) => { return rgbResult; } ).setLayout( { - name: 'LinearTosRGBShader', + name: 'LinearTosRGB', type: 'vec3', inputs: [ { name: 'color', type: 'vec3' } @@ -61308,8 +61395,8 @@ const LinearTosRGBShader = Fn( ( [ color ] ) => { var ColorSpaceFunctions = /*#__PURE__*/Object.freeze({ __proto__: null, - LinearTosRGBShader: LinearTosRGBShader, - sRGBToLinearShader: sRGBToLinearShader + LinearTosRGB: LinearTosRGB, + sRGBToLinear: sRGBToLinear }); // exposure only @@ -61508,7 +61595,7 @@ var ToneMappingFunctions = /*#__PURE__*/Object.freeze({ ReinhardToneMapping: ReinhardToneMapping }); -const checker = Fn( ( [ coord = uv() ] ) => { +const checker = /*@__PURE__*/ Fn( ( [ coord = uv() ] ) => { const uv = coord.mul( 2.0 ); @@ -61525,7 +61612,7 @@ const checker = Fn( ( [ coord = uv() ] ) => { -const mx_select = /*#__PURE__*/ Fn( ( [ b_immutable, t_immutable, f_immutable ] ) => { +const mx_select = /*@__PURE__*/ Fn( ( [ b_immutable, t_immutable, f_immutable ] ) => { const f = float( f_immutable ).toVar(); const t = float( t_immutable ).toVar(); @@ -61543,7 +61630,7 @@ const mx_select = /*#__PURE__*/ Fn( ( [ b_immutable, t_immutable, f_immutable ] ] } ); -const mx_negate_if = /*#__PURE__*/ Fn( ( [ val_immutable, b_immutable ] ) => { +const mx_negate_if = /*@__PURE__*/ Fn( ( [ val_immutable, b_immutable ] ) => { const b = bool( b_immutable ).toVar(); const val = float( val_immutable ).toVar(); @@ -61559,7 +61646,7 @@ const mx_negate_if = /*#__PURE__*/ Fn( ( [ val_immutable, b_immutable ] ) => { ] } ); -const mx_floor = /*#__PURE__*/ Fn( ( [ x_immutable ] ) => { +const mx_floor = /*@__PURE__*/ Fn( ( [ x_immutable ] ) => { const x = float( x_immutable ).toVar(); @@ -61573,7 +61660,7 @@ const mx_floor = /*#__PURE__*/ Fn( ( [ x_immutable ] ) => { ] } ); -const mx_floorfrac = /*#__PURE__*/ Fn( ( [ x_immutable, i ] ) => { +const mx_floorfrac = /*@__PURE__*/ Fn( ( [ x_immutable, i ] ) => { const x = float( x_immutable ).toVar(); i.assign( mx_floor( x ) ); @@ -61582,7 +61669,7 @@ const mx_floorfrac = /*#__PURE__*/ Fn( ( [ x_immutable, i ] ) => { } ); -const mx_bilerp_0 = /*#__PURE__*/ Fn( ( [ v0_immutable, v1_immutable, v2_immutable, v3_immutable, s_immutable, t_immutable ] ) => { +const mx_bilerp_0 = /*@__PURE__*/ Fn( ( [ v0_immutable, v1_immutable, v2_immutable, v3_immutable, s_immutable, t_immutable ] ) => { const t = float( t_immutable ).toVar(); const s = float( s_immutable ).toVar(); @@ -61607,7 +61694,7 @@ const mx_bilerp_0 = /*#__PURE__*/ Fn( ( [ v0_immutable, v1_immutable, v2_immutab ] } ); -const mx_bilerp_1 = /*#__PURE__*/ Fn( ( [ v0_immutable, v1_immutable, v2_immutable, v3_immutable, s_immutable, t_immutable ] ) => { +const mx_bilerp_1 = /*@__PURE__*/ Fn( ( [ v0_immutable, v1_immutable, v2_immutable, v3_immutable, s_immutable, t_immutable ] ) => { const t = float( t_immutable ).toVar(); const s = float( s_immutable ).toVar(); @@ -61632,9 +61719,9 @@ const mx_bilerp_1 = /*#__PURE__*/ Fn( ( [ v0_immutable, v1_immutable, v2_immutab ] } ); -const mx_bilerp = /*#__PURE__*/ overloadingFn( [ mx_bilerp_0, mx_bilerp_1 ] ); +const mx_bilerp = /*@__PURE__*/ overloadingFn( [ mx_bilerp_0, mx_bilerp_1 ] ); -const mx_trilerp_0 = /*#__PURE__*/ Fn( ( [ v0_immutable, v1_immutable, v2_immutable, v3_immutable, v4_immutable, v5_immutable, v6_immutable, v7_immutable, s_immutable, t_immutable, r_immutable ] ) => { +const mx_trilerp_0 = /*@__PURE__*/ Fn( ( [ v0_immutable, v1_immutable, v2_immutable, v3_immutable, v4_immutable, v5_immutable, v6_immutable, v7_immutable, s_immutable, t_immutable, r_immutable ] ) => { const r = float( r_immutable ).toVar(); const t = float( t_immutable ).toVar(); @@ -61671,7 +61758,7 @@ const mx_trilerp_0 = /*#__PURE__*/ Fn( ( [ v0_immutable, v1_immutable, v2_immuta ] } ); -const mx_trilerp_1 = /*#__PURE__*/ Fn( ( [ v0_immutable, v1_immutable, v2_immutable, v3_immutable, v4_immutable, v5_immutable, v6_immutable, v7_immutable, s_immutable, t_immutable, r_immutable ] ) => { +const mx_trilerp_1 = /*@__PURE__*/ Fn( ( [ v0_immutable, v1_immutable, v2_immutable, v3_immutable, v4_immutable, v5_immutable, v6_immutable, v7_immutable, s_immutable, t_immutable, r_immutable ] ) => { const r = float( r_immutable ).toVar(); const t = float( t_immutable ).toVar(); @@ -61708,9 +61795,9 @@ const mx_trilerp_1 = /*#__PURE__*/ Fn( ( [ v0_immutable, v1_immutable, v2_immuta ] } ); -const mx_trilerp = /*#__PURE__*/ overloadingFn( [ mx_trilerp_0, mx_trilerp_1 ] ); +const mx_trilerp = /*@__PURE__*/ overloadingFn( [ mx_trilerp_0, mx_trilerp_1 ] ); -const mx_gradient_float_0 = /*#__PURE__*/ Fn( ( [ hash_immutable, x_immutable, y_immutable ] ) => { +const mx_gradient_float_0 = /*@__PURE__*/ Fn( ( [ hash_immutable, x_immutable, y_immutable ] ) => { const y = float( y_immutable ).toVar(); const x = float( x_immutable ).toVar(); @@ -61731,7 +61818,7 @@ const mx_gradient_float_0 = /*#__PURE__*/ Fn( ( [ hash_immutable, x_immutable, y ] } ); -const mx_gradient_float_1 = /*#__PURE__*/ Fn( ( [ hash_immutable, x_immutable, y_immutable, z_immutable ] ) => { +const mx_gradient_float_1 = /*@__PURE__*/ Fn( ( [ hash_immutable, x_immutable, y_immutable, z_immutable ] ) => { const z = float( z_immutable ).toVar(); const y = float( y_immutable ).toVar(); @@ -61754,9 +61841,9 @@ const mx_gradient_float_1 = /*#__PURE__*/ Fn( ( [ hash_immutable, x_immutable, y ] } ); -const mx_gradient_float = /*#__PURE__*/ overloadingFn( [ mx_gradient_float_0, mx_gradient_float_1 ] ); +const mx_gradient_float = /*@__PURE__*/ overloadingFn( [ mx_gradient_float_0, mx_gradient_float_1 ] ); -const mx_gradient_vec3_0 = /*#__PURE__*/ Fn( ( [ hash_immutable, x_immutable, y_immutable ] ) => { +const mx_gradient_vec3_0 = /*@__PURE__*/ Fn( ( [ hash_immutable, x_immutable, y_immutable ] ) => { const y = float( y_immutable ).toVar(); const x = float( x_immutable ).toVar(); @@ -61774,7 +61861,7 @@ const mx_gradient_vec3_0 = /*#__PURE__*/ Fn( ( [ hash_immutable, x_immutable, y_ ] } ); -const mx_gradient_vec3_1 = /*#__PURE__*/ Fn( ( [ hash_immutable, x_immutable, y_immutable, z_immutable ] ) => { +const mx_gradient_vec3_1 = /*@__PURE__*/ Fn( ( [ hash_immutable, x_immutable, y_immutable, z_immutable ] ) => { const z = float( z_immutable ).toVar(); const y = float( y_immutable ).toVar(); @@ -61794,9 +61881,9 @@ const mx_gradient_vec3_1 = /*#__PURE__*/ Fn( ( [ hash_immutable, x_immutable, y_ ] } ); -const mx_gradient_vec3 = /*#__PURE__*/ overloadingFn( [ mx_gradient_vec3_0, mx_gradient_vec3_1 ] ); +const mx_gradient_vec3 = /*@__PURE__*/ overloadingFn( [ mx_gradient_vec3_0, mx_gradient_vec3_1 ] ); -const mx_gradient_scale2d_0 = /*#__PURE__*/ Fn( ( [ v_immutable ] ) => { +const mx_gradient_scale2d_0 = /*@__PURE__*/ Fn( ( [ v_immutable ] ) => { const v = float( v_immutable ).toVar(); @@ -61810,7 +61897,7 @@ const mx_gradient_scale2d_0 = /*#__PURE__*/ Fn( ( [ v_immutable ] ) => { ] } ); -const mx_gradient_scale3d_0 = /*#__PURE__*/ Fn( ( [ v_immutable ] ) => { +const mx_gradient_scale3d_0 = /*@__PURE__*/ Fn( ( [ v_immutable ] ) => { const v = float( v_immutable ).toVar(); @@ -61824,7 +61911,7 @@ const mx_gradient_scale3d_0 = /*#__PURE__*/ Fn( ( [ v_immutable ] ) => { ] } ); -const mx_gradient_scale2d_1 = /*#__PURE__*/ Fn( ( [ v_immutable ] ) => { +const mx_gradient_scale2d_1 = /*@__PURE__*/ Fn( ( [ v_immutable ] ) => { const v = vec3( v_immutable ).toVar(); @@ -61838,9 +61925,9 @@ const mx_gradient_scale2d_1 = /*#__PURE__*/ Fn( ( [ v_immutable ] ) => { ] } ); -const mx_gradient_scale2d = /*#__PURE__*/ overloadingFn( [ mx_gradient_scale2d_0, mx_gradient_scale2d_1 ] ); +const mx_gradient_scale2d = /*@__PURE__*/ overloadingFn( [ mx_gradient_scale2d_0, mx_gradient_scale2d_1 ] ); -const mx_gradient_scale3d_1 = /*#__PURE__*/ Fn( ( [ v_immutable ] ) => { +const mx_gradient_scale3d_1 = /*@__PURE__*/ Fn( ( [ v_immutable ] ) => { const v = vec3( v_immutable ).toVar(); @@ -61854,9 +61941,9 @@ const mx_gradient_scale3d_1 = /*#__PURE__*/ Fn( ( [ v_immutable ] ) => { ] } ); -const mx_gradient_scale3d = /*#__PURE__*/ overloadingFn( [ mx_gradient_scale3d_0, mx_gradient_scale3d_1 ] ); +const mx_gradient_scale3d = /*@__PURE__*/ overloadingFn( [ mx_gradient_scale3d_0, mx_gradient_scale3d_1 ] ); -const mx_rotl32 = /*#__PURE__*/ Fn( ( [ x_immutable, k_immutable ] ) => { +const mx_rotl32 = /*@__PURE__*/ Fn( ( [ x_immutable, k_immutable ] ) => { const k = int( k_immutable ).toVar(); const x = uint( x_immutable ).toVar(); @@ -61872,7 +61959,7 @@ const mx_rotl32 = /*#__PURE__*/ Fn( ( [ x_immutable, k_immutable ] ) => { ] } ); -const mx_bjmix = /*#__PURE__*/ Fn( ( [ a, b, c ] ) => { +const mx_bjmix = /*@__PURE__*/ Fn( ( [ a, b, c ] ) => { a.subAssign( c ); a.bitXorAssign( mx_rotl32( c, int( 4 ) ) ); @@ -61895,7 +61982,7 @@ const mx_bjmix = /*#__PURE__*/ Fn( ( [ a, b, c ] ) => { } ); -const mx_bjfinal = /*#__PURE__*/ Fn( ( [ a_immutable, b_immutable, c_immutable ] ) => { +const mx_bjfinal = /*@__PURE__*/ Fn( ( [ a_immutable, b_immutable, c_immutable ] ) => { const c = uint( c_immutable ).toVar(); const b = uint( b_immutable ).toVar(); @@ -61927,7 +62014,7 @@ const mx_bjfinal = /*#__PURE__*/ Fn( ( [ a_immutable, b_immutable, c_immutable ] ] } ); -const mx_bits_to_01 = /*#__PURE__*/ Fn( ( [ bits_immutable ] ) => { +const mx_bits_to_01 = /*@__PURE__*/ Fn( ( [ bits_immutable ] ) => { const bits = uint( bits_immutable ).toVar(); @@ -61941,7 +62028,7 @@ const mx_bits_to_01 = /*#__PURE__*/ Fn( ( [ bits_immutable ] ) => { ] } ); -const mx_fade = /*#__PURE__*/ Fn( ( [ t_immutable ] ) => { +const mx_fade = /*@__PURE__*/ Fn( ( [ t_immutable ] ) => { const t = float( t_immutable ).toVar(); @@ -61955,7 +62042,7 @@ const mx_fade = /*#__PURE__*/ Fn( ( [ t_immutable ] ) => { ] } ); -const mx_hash_int_0 = /*#__PURE__*/ Fn( ( [ x_immutable ] ) => { +const mx_hash_int_0 = /*@__PURE__*/ Fn( ( [ x_immutable ] ) => { const x = int( x_immutable ).toVar(); const len = uint( uint( 1 ) ).toVar(); @@ -61971,7 +62058,7 @@ const mx_hash_int_0 = /*#__PURE__*/ Fn( ( [ x_immutable ] ) => { ] } ); -const mx_hash_int_1 = /*#__PURE__*/ Fn( ( [ x_immutable, y_immutable ] ) => { +const mx_hash_int_1 = /*@__PURE__*/ Fn( ( [ x_immutable, y_immutable ] ) => { const y = int( y_immutable ).toVar(); const x = int( x_immutable ).toVar(); @@ -61992,7 +62079,7 @@ const mx_hash_int_1 = /*#__PURE__*/ Fn( ( [ x_immutable, y_immutable ] ) => { ] } ); -const mx_hash_int_2 = /*#__PURE__*/ Fn( ( [ x_immutable, y_immutable, z_immutable ] ) => { +const mx_hash_int_2 = /*@__PURE__*/ Fn( ( [ x_immutable, y_immutable, z_immutable ] ) => { const z = int( z_immutable ).toVar(); const y = int( y_immutable ).toVar(); @@ -62016,7 +62103,7 @@ const mx_hash_int_2 = /*#__PURE__*/ Fn( ( [ x_immutable, y_immutable, z_immutabl ] } ); -const mx_hash_int_3 = /*#__PURE__*/ Fn( ( [ x_immutable, y_immutable, z_immutable, xx_immutable ] ) => { +const mx_hash_int_3 = /*@__PURE__*/ Fn( ( [ x_immutable, y_immutable, z_immutable, xx_immutable ] ) => { const xx = int( xx_immutable ).toVar(); const z = int( z_immutable ).toVar(); @@ -62044,7 +62131,7 @@ const mx_hash_int_3 = /*#__PURE__*/ Fn( ( [ x_immutable, y_immutable, z_immutabl ] } ); -const mx_hash_int_4 = /*#__PURE__*/ Fn( ( [ x_immutable, y_immutable, z_immutable, xx_immutable, yy_immutable ] ) => { +const mx_hash_int_4 = /*@__PURE__*/ Fn( ( [ x_immutable, y_immutable, z_immutable, xx_immutable, yy_immutable ] ) => { const yy = int( yy_immutable ).toVar(); const xx = int( xx_immutable ).toVar(); @@ -62075,9 +62162,9 @@ const mx_hash_int_4 = /*#__PURE__*/ Fn( ( [ x_immutable, y_immutable, z_immutabl ] } ); -const mx_hash_int = /*#__PURE__*/ overloadingFn( [ mx_hash_int_0, mx_hash_int_1, mx_hash_int_2, mx_hash_int_3, mx_hash_int_4 ] ); +const mx_hash_int = /*@__PURE__*/ overloadingFn( [ mx_hash_int_0, mx_hash_int_1, mx_hash_int_2, mx_hash_int_3, mx_hash_int_4 ] ); -const mx_hash_vec3_0 = /*#__PURE__*/ Fn( ( [ x_immutable, y_immutable ] ) => { +const mx_hash_vec3_0 = /*@__PURE__*/ Fn( ( [ x_immutable, y_immutable ] ) => { const y = int( y_immutable ).toVar(); const x = int( x_immutable ).toVar(); @@ -62098,7 +62185,7 @@ const mx_hash_vec3_0 = /*#__PURE__*/ Fn( ( [ x_immutable, y_immutable ] ) => { ] } ); -const mx_hash_vec3_1 = /*#__PURE__*/ Fn( ( [ x_immutable, y_immutable, z_immutable ] ) => { +const mx_hash_vec3_1 = /*@__PURE__*/ Fn( ( [ x_immutable, y_immutable, z_immutable ] ) => { const z = int( z_immutable ).toVar(); const y = int( y_immutable ).toVar(); @@ -62121,9 +62208,9 @@ const mx_hash_vec3_1 = /*#__PURE__*/ Fn( ( [ x_immutable, y_immutable, z_immutab ] } ); -const mx_hash_vec3 = /*#__PURE__*/ overloadingFn( [ mx_hash_vec3_0, mx_hash_vec3_1 ] ); +const mx_hash_vec3 = /*@__PURE__*/ overloadingFn( [ mx_hash_vec3_0, mx_hash_vec3_1 ] ); -const mx_perlin_noise_float_0 = /*#__PURE__*/ Fn( ( [ p_immutable ] ) => { +const mx_perlin_noise_float_0 = /*@__PURE__*/ Fn( ( [ p_immutable ] ) => { const p = vec2( p_immutable ).toVar(); const X = int().toVar(), Y = int().toVar(); @@ -62143,7 +62230,7 @@ const mx_perlin_noise_float_0 = /*#__PURE__*/ Fn( ( [ p_immutable ] ) => { ] } ); -const mx_perlin_noise_float_1 = /*#__PURE__*/ Fn( ( [ p_immutable ] ) => { +const mx_perlin_noise_float_1 = /*@__PURE__*/ Fn( ( [ p_immutable ] ) => { const p = vec3( p_immutable ).toVar(); const X = int().toVar(), Y = int().toVar(), Z = int().toVar(); @@ -62165,9 +62252,9 @@ const mx_perlin_noise_float_1 = /*#__PURE__*/ Fn( ( [ p_immutable ] ) => { ] } ); -const mx_perlin_noise_float = /*#__PURE__*/ overloadingFn( [ mx_perlin_noise_float_0, mx_perlin_noise_float_1 ] ); +const mx_perlin_noise_float = /*@__PURE__*/ overloadingFn( [ mx_perlin_noise_float_0, mx_perlin_noise_float_1 ] ); -const mx_perlin_noise_vec3_0 = /*#__PURE__*/ Fn( ( [ p_immutable ] ) => { +const mx_perlin_noise_vec3_0 = /*@__PURE__*/ Fn( ( [ p_immutable ] ) => { const p = vec2( p_immutable ).toVar(); const X = int().toVar(), Y = int().toVar(); @@ -62187,7 +62274,7 @@ const mx_perlin_noise_vec3_0 = /*#__PURE__*/ Fn( ( [ p_immutable ] ) => { ] } ); -const mx_perlin_noise_vec3_1 = /*#__PURE__*/ Fn( ( [ p_immutable ] ) => { +const mx_perlin_noise_vec3_1 = /*@__PURE__*/ Fn( ( [ p_immutable ] ) => { const p = vec3( p_immutable ).toVar(); const X = int().toVar(), Y = int().toVar(), Z = int().toVar(); @@ -62209,9 +62296,9 @@ const mx_perlin_noise_vec3_1 = /*#__PURE__*/ Fn( ( [ p_immutable ] ) => { ] } ); -const mx_perlin_noise_vec3 = /*#__PURE__*/ overloadingFn( [ mx_perlin_noise_vec3_0, mx_perlin_noise_vec3_1 ] ); +const mx_perlin_noise_vec3 = /*@__PURE__*/ overloadingFn( [ mx_perlin_noise_vec3_0, mx_perlin_noise_vec3_1 ] ); -const mx_cell_noise_float_0 = /*#__PURE__*/ Fn( ( [ p_immutable ] ) => { +const mx_cell_noise_float_0 = /*@__PURE__*/ Fn( ( [ p_immutable ] ) => { const p = float( p_immutable ).toVar(); const ix = int( mx_floor( p ) ).toVar(); @@ -62226,7 +62313,7 @@ const mx_cell_noise_float_0 = /*#__PURE__*/ Fn( ( [ p_immutable ] ) => { ] } ); -const mx_cell_noise_float_1 = /*#__PURE__*/ Fn( ( [ p_immutable ] ) => { +const mx_cell_noise_float_1 = /*@__PURE__*/ Fn( ( [ p_immutable ] ) => { const p = vec2( p_immutable ).toVar(); const ix = int( mx_floor( p.x ) ).toVar(); @@ -62242,7 +62329,7 @@ const mx_cell_noise_float_1 = /*#__PURE__*/ Fn( ( [ p_immutable ] ) => { ] } ); -const mx_cell_noise_float_2 = /*#__PURE__*/ Fn( ( [ p_immutable ] ) => { +const mx_cell_noise_float_2 = /*@__PURE__*/ Fn( ( [ p_immutable ] ) => { const p = vec3( p_immutable ).toVar(); const ix = int( mx_floor( p.x ) ).toVar(); @@ -62259,7 +62346,7 @@ const mx_cell_noise_float_2 = /*#__PURE__*/ Fn( ( [ p_immutable ] ) => { ] } ); -const mx_cell_noise_float_3 = /*#__PURE__*/ Fn( ( [ p_immutable ] ) => { +const mx_cell_noise_float_3 = /*@__PURE__*/ Fn( ( [ p_immutable ] ) => { const p = vec4( p_immutable ).toVar(); const ix = int( mx_floor( p.x ) ).toVar(); @@ -62277,9 +62364,9 @@ const mx_cell_noise_float_3 = /*#__PURE__*/ Fn( ( [ p_immutable ] ) => { ] } ); -const mx_cell_noise_float$1 = /*#__PURE__*/ overloadingFn( [ mx_cell_noise_float_0, mx_cell_noise_float_1, mx_cell_noise_float_2, mx_cell_noise_float_3 ] ); +const mx_cell_noise_float$1 = /*@__PURE__*/ overloadingFn( [ mx_cell_noise_float_0, mx_cell_noise_float_1, mx_cell_noise_float_2, mx_cell_noise_float_3 ] ); -const mx_cell_noise_vec3_0 = /*#__PURE__*/ Fn( ( [ p_immutable ] ) => { +const mx_cell_noise_vec3_0 = /*@__PURE__*/ Fn( ( [ p_immutable ] ) => { const p = float( p_immutable ).toVar(); const ix = int( mx_floor( p ) ).toVar(); @@ -62294,7 +62381,7 @@ const mx_cell_noise_vec3_0 = /*#__PURE__*/ Fn( ( [ p_immutable ] ) => { ] } ); -const mx_cell_noise_vec3_1 = /*#__PURE__*/ Fn( ( [ p_immutable ] ) => { +const mx_cell_noise_vec3_1 = /*@__PURE__*/ Fn( ( [ p_immutable ] ) => { const p = vec2( p_immutable ).toVar(); const ix = int( mx_floor( p.x ) ).toVar(); @@ -62310,7 +62397,7 @@ const mx_cell_noise_vec3_1 = /*#__PURE__*/ Fn( ( [ p_immutable ] ) => { ] } ); -const mx_cell_noise_vec3_2 = /*#__PURE__*/ Fn( ( [ p_immutable ] ) => { +const mx_cell_noise_vec3_2 = /*@__PURE__*/ Fn( ( [ p_immutable ] ) => { const p = vec3( p_immutable ).toVar(); const ix = int( mx_floor( p.x ) ).toVar(); @@ -62327,7 +62414,7 @@ const mx_cell_noise_vec3_2 = /*#__PURE__*/ Fn( ( [ p_immutable ] ) => { ] } ); -const mx_cell_noise_vec3_3 = /*#__PURE__*/ Fn( ( [ p_immutable ] ) => { +const mx_cell_noise_vec3_3 = /*@__PURE__*/ Fn( ( [ p_immutable ] ) => { const p = vec4( p_immutable ).toVar(); const ix = int( mx_floor( p.x ) ).toVar(); @@ -62345,9 +62432,9 @@ const mx_cell_noise_vec3_3 = /*#__PURE__*/ Fn( ( [ p_immutable ] ) => { ] } ); -const mx_cell_noise_vec3 = /*#__PURE__*/ overloadingFn( [ mx_cell_noise_vec3_0, mx_cell_noise_vec3_1, mx_cell_noise_vec3_2, mx_cell_noise_vec3_3 ] ); +const mx_cell_noise_vec3 = /*@__PURE__*/ overloadingFn( [ mx_cell_noise_vec3_0, mx_cell_noise_vec3_1, mx_cell_noise_vec3_2, mx_cell_noise_vec3_3 ] ); -const mx_fractal_noise_float$1 = /*#__PURE__*/ Fn( ( [ p_immutable, octaves_immutable, lacunarity_immutable, diminish_immutable ] ) => { +const mx_fractal_noise_float$1 = /*@__PURE__*/ Fn( ( [ p_immutable, octaves_immutable, lacunarity_immutable, diminish_immutable ] ) => { const diminish = float( diminish_immutable ).toVar(); const lacunarity = float( lacunarity_immutable ).toVar(); @@ -62377,7 +62464,7 @@ const mx_fractal_noise_float$1 = /*#__PURE__*/ Fn( ( [ p_immutable, octaves_immu ] } ); -const mx_fractal_noise_vec3$1 = /*#__PURE__*/ Fn( ( [ p_immutable, octaves_immutable, lacunarity_immutable, diminish_immutable ] ) => { +const mx_fractal_noise_vec3$1 = /*@__PURE__*/ Fn( ( [ p_immutable, octaves_immutable, lacunarity_immutable, diminish_immutable ] ) => { const diminish = float( diminish_immutable ).toVar(); const lacunarity = float( lacunarity_immutable ).toVar(); @@ -62407,7 +62494,7 @@ const mx_fractal_noise_vec3$1 = /*#__PURE__*/ Fn( ( [ p_immutable, octaves_immut ] } ); -const mx_fractal_noise_vec2$1 = /*#__PURE__*/ Fn( ( [ p_immutable, octaves_immutable, lacunarity_immutable, diminish_immutable ] ) => { +const mx_fractal_noise_vec2$1 = /*@__PURE__*/ Fn( ( [ p_immutable, octaves_immutable, lacunarity_immutable, diminish_immutable ] ) => { const diminish = float( diminish_immutable ).toVar(); const lacunarity = float( lacunarity_immutable ).toVar(); @@ -62427,7 +62514,7 @@ const mx_fractal_noise_vec2$1 = /*#__PURE__*/ Fn( ( [ p_immutable, octaves_immut ] } ); -const mx_fractal_noise_vec4$1 = /*#__PURE__*/ Fn( ( [ p_immutable, octaves_immutable, lacunarity_immutable, diminish_immutable ] ) => { +const mx_fractal_noise_vec4$1 = /*@__PURE__*/ Fn( ( [ p_immutable, octaves_immutable, lacunarity_immutable, diminish_immutable ] ) => { const diminish = float( diminish_immutable ).toVar(); const lacunarity = float( lacunarity_immutable ).toVar(); @@ -62449,7 +62536,7 @@ const mx_fractal_noise_vec4$1 = /*#__PURE__*/ Fn( ( [ p_immutable, octaves_immut ] } ); -const mx_worley_distance_0 = /*#__PURE__*/ Fn( ( [ p_immutable, x_immutable, y_immutable, xoff_immutable, yoff_immutable, jitter_immutable, metric_immutable ] ) => { +const mx_worley_distance_0 = /*@__PURE__*/ Fn( ( [ p_immutable, x_immutable, y_immutable, xoff_immutable, yoff_immutable, jitter_immutable, metric_immutable ] ) => { const metric = int( metric_immutable ).toVar(); const jitter = float( jitter_immutable ).toVar(); @@ -62494,7 +62581,7 @@ const mx_worley_distance_0 = /*#__PURE__*/ Fn( ( [ p_immutable, x_immutable, y_i ] } ); -const mx_worley_distance_1 = /*#__PURE__*/ Fn( ( [ p_immutable, x_immutable, y_immutable, z_immutable, xoff_immutable, yoff_immutable, zoff_immutable, jitter_immutable, metric_immutable ] ) => { +const mx_worley_distance_1 = /*@__PURE__*/ Fn( ( [ p_immutable, x_immutable, y_immutable, z_immutable, xoff_immutable, yoff_immutable, zoff_immutable, jitter_immutable, metric_immutable ] ) => { const metric = int( metric_immutable ).toVar(); const jitter = float( jitter_immutable ).toVar(); @@ -62542,9 +62629,9 @@ const mx_worley_distance_1 = /*#__PURE__*/ Fn( ( [ p_immutable, x_immutable, y_i ] } ); -const mx_worley_distance = /*#__PURE__*/ overloadingFn( [ mx_worley_distance_0, mx_worley_distance_1 ] ); +const mx_worley_distance = /*@__PURE__*/ overloadingFn( [ mx_worley_distance_0, mx_worley_distance_1 ] ); -const mx_worley_noise_float_0 = /*#__PURE__*/ Fn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => { +const mx_worley_noise_float_0 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => { const metric = int( metric_immutable ).toVar(); const jitter = float( jitter_immutable ).toVar(); @@ -62582,7 +62669,7 @@ const mx_worley_noise_float_0 = /*#__PURE__*/ Fn( ( [ p_immutable, jitter_immuta ] } ); -const mx_worley_noise_vec2_0 = /*#__PURE__*/ Fn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => { +const mx_worley_noise_vec2_0 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => { const metric = int( metric_immutable ).toVar(); const jitter = float( jitter_immutable ).toVar(); @@ -62630,7 +62717,7 @@ const mx_worley_noise_vec2_0 = /*#__PURE__*/ Fn( ( [ p_immutable, jitter_immutab ] } ); -const mx_worley_noise_vec3_0 = /*#__PURE__*/ Fn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => { +const mx_worley_noise_vec3_0 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => { const metric = int( metric_immutable ).toVar(); const jitter = float( jitter_immutable ).toVar(); @@ -62684,7 +62771,7 @@ const mx_worley_noise_vec3_0 = /*#__PURE__*/ Fn( ( [ p_immutable, jitter_immutab ] } ); -const mx_worley_noise_float_1 = /*#__PURE__*/ Fn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => { +const mx_worley_noise_float_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => { const metric = int( metric_immutable ).toVar(); const jitter = float( jitter_immutable ).toVar(); @@ -62726,9 +62813,9 @@ const mx_worley_noise_float_1 = /*#__PURE__*/ Fn( ( [ p_immutable, jitter_immuta ] } ); -const mx_worley_noise_float$1 = /*#__PURE__*/ overloadingFn( [ mx_worley_noise_float_0, mx_worley_noise_float_1 ] ); +const mx_worley_noise_float$1 = /*@__PURE__*/ overloadingFn( [ mx_worley_noise_float_0, mx_worley_noise_float_1 ] ); -const mx_worley_noise_vec2_1 = /*#__PURE__*/ Fn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => { +const mx_worley_noise_vec2_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => { const metric = int( metric_immutable ).toVar(); const jitter = float( jitter_immutable ).toVar(); @@ -62780,9 +62867,9 @@ const mx_worley_noise_vec2_1 = /*#__PURE__*/ Fn( ( [ p_immutable, jitter_immutab ] } ); -const mx_worley_noise_vec2$1 = /*#__PURE__*/ overloadingFn( [ mx_worley_noise_vec2_0, mx_worley_noise_vec2_1 ] ); +const mx_worley_noise_vec2$1 = /*@__PURE__*/ overloadingFn( [ mx_worley_noise_vec2_0, mx_worley_noise_vec2_1 ] ); -const mx_worley_noise_vec3_1 = /*#__PURE__*/ Fn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => { +const mx_worley_noise_vec3_1 = /*@__PURE__*/ Fn( ( [ p_immutable, jitter_immutable, metric_immutable ] ) => { const metric = int( metric_immutable ).toVar(); const jitter = float( jitter_immutable ).toVar(); @@ -62840,13 +62927,13 @@ const mx_worley_noise_vec3_1 = /*#__PURE__*/ Fn( ( [ p_immutable, jitter_immutab ] } ); -const mx_worley_noise_vec3$1 = /*#__PURE__*/ overloadingFn( [ mx_worley_noise_vec3_0, mx_worley_noise_vec3_1 ] ); +const mx_worley_noise_vec3$1 = /*@__PURE__*/ overloadingFn( [ mx_worley_noise_vec3_0, mx_worley_noise_vec3_1 ] ); // Three.js Transpiler // https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/libraries/stdlib/genglsl/lib/mx_hsv.glsl -const mx_hsvtorgb = /*#__PURE__*/ Fn( ( [ hsv ] ) => { +const mx_hsvtorgb = /*@__PURE__*/ Fn( ( [ hsv ] ) => { const s = hsv.y; const v = hsv.z; @@ -62905,7 +62992,7 @@ const mx_hsvtorgb = /*#__PURE__*/ Fn( ( [ hsv ] ) => { ] } ); -const mx_rgbtohsv = /*#__PURE__*/ Fn( ( [ c_immutable ] ) => { +const mx_rgbtohsv = /*@__PURE__*/ Fn( ( [ c_immutable ] ) => { const c = vec3( c_immutable ).toVar(); const r = float( c.x ).toVar(); @@ -62971,7 +63058,7 @@ const mx_rgbtohsv = /*#__PURE__*/ Fn( ( [ c_immutable ] ) => { // https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/libraries/stdlib/genglsl/lib/mx_transform_color.glsl -const mx_srgb_texture_to_lin_rec709 = /*#__PURE__*/ Fn( ( [ color_immutable ] ) => { +const mx_srgb_texture_to_lin_rec709 = /*@__PURE__*/ Fn( ( [ color_immutable ] ) => { const color = vec3( color_immutable ).toVar(); const isAbove = bvec3( greaterThan( color, vec3( 0.04045 ) ) ).toVar(); @@ -64287,13 +64374,12 @@ class Renderer { const { object, camera, renderList } = bundle; const renderContext = this._currentRenderContext; - const renderContextData = this.backend.get( renderContext ); // const renderBundle = this._bundles.get( object, camera ); - const renderBundleData = this.backend.get( renderBundle ); + if ( renderBundleData.renderContexts === undefined ) renderBundleData.renderContexts = new Set(); // @@ -64304,17 +64390,11 @@ class Renderer { if ( renderBundleNeedsUpdate ) { - if ( renderContextData.renderObjects === undefined || object.needsUpdate === true ) { - - const nodeFrame = this._nodes.nodeFrame; + this.backend.beginBundle( renderContext ); - renderContextData.renderObjects = []; - renderContextData.renderBundles = []; - renderContextData.scene = sceneRef; - renderContextData.camera = camera; - renderContextData.renderId = nodeFrame.renderId; + if ( renderBundleData.renderObjects === undefined || object.needsUpdate === true ) { - renderContextData.registerBundlesPhase = true; + renderBundleData.renderObjects = []; } @@ -64328,16 +64408,17 @@ class Renderer { // + this.backend.finishBundle( renderContext, renderBundle ); + object.needsUpdate = false; } else { - const renderContext = this._currentRenderContext; - const renderContextData = this.backend.get( renderContext ); + const renderObjects = renderBundleData.renderObjects; - for ( let i = 0, l = renderContextData.renderObjects.length; i < l; i ++ ) { + for ( let i = 0, l = renderObjects.length; i < l; i ++ ) { - const renderObject = renderContextData.renderObjects[ i ]; + const renderObject = renderObjects[ i ]; this._nodes.updateBefore( renderObject ); @@ -64349,14 +64430,14 @@ class Renderer { this._nodes.updateForRender( renderObject ); this._bindings.updateForRender( renderObject ); - this.backend.draw( renderObject, this.info ); - this._nodes.updateAfter( renderObject ); } } + this.backend.addBundle( renderContext, renderBundle ); + } render( scene, camera ) { @@ -64375,10 +64456,10 @@ class Renderer { _getFrameBufferTarget() { - const { currentColorSpace } = this; + const { currentToneMapping, currentColorSpace } = this; - const useToneMapping = this._renderTarget === null && ( this.toneMapping !== NoToneMapping ); - const useColorSpace = this._renderTarget === null && ( currentColorSpace !== LinearSRGBColorSpace && currentColorSpace !== NoColorSpace ); + const useToneMapping = currentToneMapping !== NoToneMapping; + const useColorSpace = currentColorSpace !== LinearSRGBColorSpace; if ( useToneMapping === false && useColorSpace === false ) return null; @@ -64970,19 +65051,15 @@ class Renderer { } - get currentColorSpace() { - - const renderTarget = this._renderTarget; - - if ( renderTarget !== null ) { + get currentToneMapping() { - const texture = renderTarget.texture; + return this._renderTarget !== null ? NoToneMapping : this.toneMapping; - return ( Array.isArray( texture ) ? texture[ 0 ] : texture ).colorSpace; + } - } + get currentColorSpace() { - return this.outputColorSpace; + return this._renderTarget !== null ? LinearSRGBColorSpace : this.outputColorSpace; } @@ -65247,7 +65324,7 @@ class Renderer { } - if ( object.static === true ) { + if ( object.static === true && this.backend.beginBundle !== undefined ) { const baseRenderList = renderList; @@ -65477,25 +65554,16 @@ class Renderer { // - if ( this._currentRenderBundle !== null && this._currentRenderBundle.needsUpdate === true ) { + if ( this._currentRenderBundle !== null ) { - const renderObjectData = this.backend.get( renderObject ); + const renderBundleData = this.backend.get( this._currentRenderBundle ); - renderObjectData.bundleEncoder = undefined; - renderObjectData.lastPipelineGPU = undefined; + renderBundleData.renderObjects.push( renderObject ); } this.backend.draw( renderObject, this.info ); - if ( this._currentRenderBundle !== null ) { - - const renderContextData = this.backend.get( this._currentRenderContext ); - - renderContextData.renderObjects.push( renderObject ); - - } - this._nodes.updateAfter( renderObject ); } @@ -65592,8 +65660,8 @@ class StandardNodeLibrary extends NodeLibrary { this.addToneMapping( AgXToneMapping, AgXToneMapping$1 ); this.addToneMapping( NeutralToneMapping, NeutralToneMapping$1 ); - this.addColorSpace( LinearTosRGBShader, getColorSpaceMethod( LinearSRGBColorSpace, SRGBColorSpace ) ); - this.addColorSpace( sRGBToLinearShader, getColorSpaceMethod( SRGBColorSpace, LinearSRGBColorSpace ) ); + this.addColorSpace( LinearTosRGB, getColorSpaceMethod( LinearSRGBColorSpace, SRGBColorSpace ) ); + this.addColorSpace( sRGBToLinear, getColorSpaceMethod( SRGBColorSpace, LinearSRGBColorSpace ) ); } @@ -66961,6 +67029,8 @@ ${vars} return `#version 300 es +${ this.getSignature() } + // extensions ${shaderData.extensions} @@ -69935,7 +70005,7 @@ class WebGLBackend extends Backend { const { x, y, width, height } = renderContext.scissorValue; - gl.scissor( x, y, width, height ); + gl.scissor( x, renderContext.height - height - y, width, height ); } @@ -70024,8 +70094,10 @@ class WebGLBackend extends Backend { const { x, y, width, height } = renderContext.scissorValue; - gl.blitFramebuffer( x, y, x + width, y + height, x, y, x + width, y + height, mask, gl.NEAREST ); - gl.invalidateSubFramebuffer( gl.READ_FRAMEBUFFER, renderTargetContextData.invalidationArray, x, y, width, height ); + const viewY = renderContext.height - height - y; + + gl.blitFramebuffer( x, viewY, x + width, viewY + height, x, viewY, x + width, viewY + height, mask, gl.NEAREST ); + gl.invalidateSubFramebuffer( gl.READ_FRAMEBUFFER, renderTargetContextData.invalidationArray, x, viewY, width, height ); } else { @@ -70132,7 +70204,7 @@ class WebGLBackend extends Backend { const gl = this.gl; const { x, y, width, height } = renderContext.viewportValue; - gl.viewport( x, y, width, height ); + gl.viewport( x, renderContext.height - height - y, width, height ); } @@ -73242,7 +73314,7 @@ class WGSLNodeBuilder extends NodeBuilder { } - needsColorSpaceToLinear( texture ) { + needsColorSpaceToLinearSRGB( texture ) { return texture.isVideoTexture === true && texture.colorSpace !== NoColorSpace; @@ -75283,17 +75355,14 @@ class WebGPUPipelineUtils { } - createBundleEncoder( renderContext, renderObject ) { + createBundleEncoder( renderContext ) { const backend = this.backend; const { utils, device } = backend; - const renderContextData = backend.get( renderContext ); - const renderObjectData = backend.get( renderObject ); - const depthStencilFormat = utils.getCurrentDepthStencilFormat( renderContext ); const colorFormat = utils.getCurrentColorFormat( renderContext ); - const sampleCount = this._getSampleCount( renderObject.context ); + const sampleCount = this._getSampleCount( renderContext ); const descriptor = { label: 'renderBundleEncoder', @@ -75302,13 +75371,7 @@ class WebGPUPipelineUtils { sampleCount }; - const bundleEncoder = device.createRenderBundleEncoder( descriptor ); - - renderObjectData.bundleEncoder = bundleEncoder; - renderContextData.currentSets = { attributes: {} }; - renderContextData._renderBundleViewport = renderContext.width + '_' + renderContext.height; - - return bundleEncoder; + return device.createRenderBundleEncoder( descriptor ); } @@ -75851,6 +75914,8 @@ class WebGPUBackend extends Backend { const alphaMode = parameters.alpha ? 'premultiplied' : 'opaque'; + this.trackTimestamp = this.trackTimestamp && this.hasFeature( GPUFeatureName.TimestampQuery ); + this.context.configure( { device: this.device, format: this.utils.getPreferredCanvasFormat(), @@ -76166,7 +76231,8 @@ class WebGPUBackend extends Backend { renderContextData.descriptor = descriptor; renderContextData.encoder = encoder; renderContextData.currentPass = currentPass; - renderContextData.currentSets = { attributes: {} }; + renderContextData.currentSets = { attributes: {}, pipeline: null, index: null }; + renderContextData.renderBundles = []; // @@ -76180,7 +76246,7 @@ class WebGPUBackend extends Backend { const { x, y, width, height } = renderContext.scissorValue; - currentPass.setScissorRect( x, renderContext.height - height - y, width, height ); + currentPass.setScissorRect( x, y, width, height ); } @@ -76191,9 +76257,8 @@ class WebGPUBackend extends Backend { const renderContextData = this.get( renderContext ); const occlusionQueryCount = renderContext.occlusionQueryCount; - if ( renderContextData.renderBundles !== undefined && renderContextData.renderBundles.length > 0 ) { + if ( renderContextData.renderBundles.length > 0 ) { - renderContextData.registerBundlesPhase = false; renderContextData.currentPass.executeBundles( renderContextData.renderBundles ); } @@ -76326,7 +76391,7 @@ class WebGPUBackend extends Backend { const { currentPass } = this.get( renderContext ); const { x, y, width, height, minDepth, maxDepth } = renderContext.viewportValue; - currentPass.setViewport( x, renderContext.height - height - y, width, height, minDepth, maxDepth ); + currentPass.setViewport( x, y, width, height, minDepth, maxDepth ); } @@ -76575,19 +76640,7 @@ class WebGPUBackend extends Backend { const renderContextData = this.get( context ); const pipelineGPU = this.get( pipeline ).pipeline; const currentSets = renderContextData.currentSets; - - const renderObjectData = this.get( renderObject ); - - const { bundleEncoder, renderBundle, lastPipelineGPU } = renderObjectData; - - if ( renderContextData.registerBundlesPhase === true && bundleEncoder !== undefined && lastPipelineGPU === pipelineGPU ) { - - renderContextData.renderBundles.push( renderBundle ); - return; - - } - - const passEncoderGPU = this.renderer._currentRenderBundle ? this.createBundleEncoder( context, renderObject ) : renderContextData.currentPass; + const passEncoderGPU = renderContextData.currentPass; // pipeline @@ -76725,15 +76778,6 @@ class WebGPUBackend extends Backend { } - if ( this.renderer._currentRenderBundle ) { - - const renderBundle = passEncoderGPU.finish(); - renderObjectData.lastPipelineGPU = pipelineGPU; - renderObjectData.renderBundle = renderBundle; - renderObjectData.bundleEncoder = passEncoderGPU; - - } - } // cache key @@ -76819,6 +76863,7 @@ class WebGPUBackend extends Backend { } + // textures createSampler( texture ) { @@ -76872,7 +76917,7 @@ class WebGPUBackend extends Backend { initTimestampQuery( renderContext, descriptor ) { - if ( ! this.hasFeature( GPUFeatureName.TimestampQuery ) || ! this.trackTimestamp ) return; + if ( ! this.trackTimestamp ) return; const renderContextData = this.get( renderContext ); @@ -76902,10 +76947,11 @@ class WebGPUBackend extends Backend { prepareTimestampBuffer( renderContext, encoder ) { - if ( ! this.hasFeature( GPUFeatureName.TimestampQuery ) || ! this.trackTimestamp ) return; + if ( ! this.trackTimestamp ) return; const renderContextData = this.get( renderContext ); + const size = 2 * BigInt64Array.BYTES_PER_ELEMENT; if ( renderContextData.currentTimestampQueryBuffers === undefined ) { @@ -76937,7 +76983,7 @@ class WebGPUBackend extends Backend { async resolveTimestampAsync( renderContext, type = 'render' ) { - if ( ! this.hasFeature( GPUFeatureName.TimestampQuery ) || ! this.trackTimestamp ) return; + if ( ! this.trackTimestamp ) return; const renderContextData = this.get( renderContext ); @@ -77006,9 +77052,39 @@ class WebGPUBackend extends Backend { } - createBundleEncoder( renderContext, renderObject ) { + beginBundle( renderContext ) { + + const renderContextData = this.get( renderContext ); + + renderContextData._currentPass = renderContextData.currentPass; + renderContextData._currentSets = renderContextData.currentSets; + + renderContextData.currentSets = { attributes: {}, pipeline: null, index: null }; + renderContextData.currentPass = this.pipelineUtils.createBundleEncoder( renderContext ); + + } + + finishBundle( renderContext, bundle ) { + + const renderContextData = this.get( renderContext ); + + const bundleEncoder = renderContextData.currentPass; + const bundleGPU = bundleEncoder.finish(); + + this.get( bundle ).bundleGPU = bundleGPU; + + // restore render pass state + + renderContextData.currentSets = renderContextData._currentSets; + renderContextData.currentPass = renderContextData._currentPass; + + } + + addBundle( renderContext, bundle ) { + + const renderContextData = this.get( renderContext ); - return this.pipelineUtils.createBundleEncoder( renderContext, renderObject ); + renderContextData.renderBundles.push( this.get( bundle ).bundleGPU ); } @@ -77212,7 +77288,7 @@ class WebGPUBackend extends Backend { if ( renderContext.stencil ) descriptor.depthStencilAttachment.stencilLoadOp = GPULoadOp.Load; renderContextData.currentPass = encoder.beginRenderPass( descriptor ); - renderContextData.currentSets = { attributes: {} }; + renderContextData.currentSets = { attributes: {}, pipeline: null, index: null }; } @@ -77499,6 +77575,22 @@ class NodeLoader extends Loader { } +const superFromTypeFunction = MaterialLoader.createMaterialFromType; + +MaterialLoader.createMaterialFromType = function ( type ) { + + const material = createNodeMaterialFromType( type ); + + if ( material !== undefined ) { + + return material; + + } + + return superFromTypeFunction.call( this, type ); + +}; + class NodeMaterialLoader extends MaterialLoader { constructor( manager ) { @@ -77625,4 +77717,4 @@ if ( typeof window !== 'undefined' ) { } -export { ACESFilmicToneMapping$1 as ACESFilmicToneMapping, AONode, AddEquation, AddOperation, AdditiveAnimationBlendMode, AdditiveBlending, AfterImageNode, AgXToneMapping$1 as AgXToneMapping, AlphaFormat, AlwaysCompare, AlwaysDepth, AlwaysStencilFunc, AmbientLight, AmbientLightNode, AnaglyphPassNode, AnalyticLightNode, AnamorphicNode, AnimationAction, AnimationClip, AnimationLoader, AnimationMixer, AnimationObjectGroup, AnimationUtils, ArcCurve, ArrayCamera, ArrayElementNode, ArrowHelper, AssignNode, AttachedBindMode, AttributeNode, Audio, AudioAnalyser, AudioContext, AudioListener, AudioLoader, AxesHelper, BRDF_GGX, BRDF_Lambert, BackSide, BasicDepthPacking, BasicEnvironmentNode, BasicShadowMap$1 as BasicShadowMap, BatchNode, BatchedMesh, BloomNode, Bone, BooleanKeyframeTrack, Box2, Box3, Box3Helper, BoxGeometry, BoxHelper, Break, BufferAttribute, BufferAttributeNode, BufferGeometry, BufferGeometryLoader, BufferNode, BumpMapNode, BypassNode, ByteType, Cache, CacheNode, Camera, CameraHelper, CanvasTexture, CapsuleGeometry, CatmullRomCurve3, CineonToneMapping$1 as CineonToneMapping, CircleGeometry, ClampToEdgeWrapping, Clock, CodeNode, Color, ColorKeyframeTrack, ColorManagement, ColorSpaceFunctions, ColorSpaceNode, CompressedArrayTexture, CompressedCubeTexture, CompressedTexture, CompressedTextureLoader, ComputeNode, ConeGeometry, ConstNode, ConstantAlphaFactor, ConstantColorFactor, ContextNode, Continue, Controls, ConvertNode, CubeCamera, CubeReflectionMapping, CubeRefractionMapping, CubeTexture, CubeTextureLoader, CubeTextureNode, CubeUVReflectionMapping, CubicBezierCurve, CubicBezierCurve3, CubicInterpolant, CullFaceBack, CullFaceFront, CullFaceFrontBack, CullFaceNone, Curve, CurvePath, CustomBlending, CustomToneMapping, CylinderGeometry, Cylindrical, DFGApprox, D_GGX, Data3DTexture, DataArrayTexture, DataTexture, DataTextureLoader, DataUtils, DecrementStencilOp, DecrementWrapStencilOp, DefaultLoadingManager, DenoiseNode, DepthFormat, DepthOfFieldNode, DepthStencilFormat, DepthTexture, DetachedBindMode, DirectionalLight, DirectionalLightHelper, DirectionalLightNode, Discard, DiscreteInterpolant, DisplayP3ColorSpace, DodecahedronGeometry, DotScreenNode, DoubleSide, DstAlphaFactor, DstColorFactor, DynamicCopyUsage, DynamicDrawUsage, DynamicReadUsage, EPSILON, EdgesGeometry, EllipseCurve, EnvironmentNode, EqualCompare, EqualDepth, EqualStencilFunc, EquirectUVNode, EquirectangularReflectionMapping, EquirectangularRefractionMapping, Euler, EventDispatcher, ExpressionNode, ExtrudeGeometry, FXAANode, F_Schlick, FileLoader, FilmNode, Float16BufferAttribute, Float32BufferAttribute, FloatType, Fn, Fog, FogExp2, FogExp2Node, FogNode, FogRangeNode, FramebufferTexture, FrontFacingNode, FrontSide, Frustum, FunctionCallNode, FunctionNode, FunctionOverloadingNode, GLBufferAttribute, GLSL1, GLSL3, GLSLNodeParser, GTAONode, GaussianBlurNode, GreaterCompare, GreaterDepth, GreaterEqualCompare, GreaterEqualDepth, GreaterEqualStencilFunc, GreaterStencilFunc, GridHelper, Group, HalfFloatType, HemisphereLight, HemisphereLightHelper, HemisphereLightNode, IESSpotLight, IESSpotLightNode, INFINITY, IcosahedronGeometry, If, ImageBitmapLoader, ImageLoader, ImageUtils, IncrementStencilOp, IncrementWrapStencilOp, IndexNode, InstanceNode, InstancedBufferAttribute, InstancedBufferGeometry, InstancedInterleavedBuffer, InstancedMesh, InstancedPointsNodeMaterial, Int16BufferAttribute, Int32BufferAttribute, Int8BufferAttribute, IntType, InterleavedBuffer, InterleavedBufferAttribute, Interpolant, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, InvertStencilOp, IrradianceNode, JoinNode, KeepStencilOp, KeyframeTrack, LOD, LatheGeometry, Layers, LessCompare, LessDepth, LessEqualCompare, LessEqualDepth, LessEqualStencilFunc, LessStencilFunc, Light, LightNode, LightProbe, LightProbeNode, LightingContextNode, LightingModel, LightingNode, LightsNode, Line, Line2NodeMaterial, Line3, LineBasicMaterial, LineBasicNodeMaterial, LineCurve, LineCurve3, LineDashedMaterial, LineDashedNodeMaterial, LineLoop, LineSegments, LinearDisplayP3ColorSpace, LinearFilter, LinearInterpolant, LinearMipMapLinearFilter, LinearMipMapNearestFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, LinearSRGBColorSpace, LinearToneMapping$1 as LinearToneMapping, LinearTransfer, Loader, LoaderUtils, LoadingManager, Loop, LoopNode, LoopOnce, LoopPingPong, LoopRepeat, LuminanceAlphaFormat, LuminanceFormat, Lut3DNode, MOUSE, MRTNode, MatcapUVNode, Material, MaterialLoader, MaterialNode, MaterialReferenceNode, MathUtils, Matrix2, Matrix3, Matrix4, MaxEquation, MaxMipLevelNode, Mesh, MeshBasicMaterial, MeshBasicNodeMaterial, MeshDepthMaterial, MeshDistanceMaterial, MeshLambertMaterial, MeshLambertNodeMaterial, MeshMatcapMaterial, MeshMatcapNodeMaterial, MeshNormalMaterial, MeshNormalNodeMaterial, MeshPhongMaterial, MeshPhongNodeMaterial, MeshPhysicalMaterial, MeshPhysicalNodeMaterial, MeshSSSNodeMaterial, MeshStandardMaterial, MeshStandardNodeMaterial, MeshToonMaterial, MeshToonNodeMaterial, MinEquation, MirroredRepeatWrapping, MixOperation, ModelNode, ModelViewProjectionNode, MorphNode, MultiplyBlending, MultiplyOperation, NearestFilter, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, NeutralToneMapping$1 as NeutralToneMapping, NeverCompare, NeverDepth, NeverStencilFunc, NoBlending, NoColorSpace, NoToneMapping, Node, NodeAttribute, NodeBuilder, NodeCache, NodeCode, NodeFrame, NodeFunctionInput, NodeLoader, NodeMaterial, NodeMaterialLoader, NodeObjectLoader, NodeShaderStage, NodeType, NodeUniform, NodeUpdateType, NodeUtils, NodeVar, NodeVarying, NormalAnimationBlendMode, NormalBlending, NormalMapNode, NotEqualCompare, NotEqualDepth, NotEqualStencilFunc, NumberKeyframeTrack, Object3D, Object3DNode, ObjectLoader, ObjectSpaceNormalMap, OctahedronGeometry, OneFactor, OneMinusConstantAlphaFactor, OneMinusConstantColorFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcAlphaFactor, OneMinusSrcColorFactor, OrthographicCamera, OscNode, OutputStructNode, P3Primaries, PCFShadowMap$1 as PCFShadowMap, PCFSoftShadowMap$1 as PCFSoftShadowMap, PI, PI2, PMREMGenerator, PMREMNode, ParallaxBarrierPassNode, ParameterNode, PassNode, Path, PerspectiveCamera, PhongLightingModel, PhysicalLightingModel, PixelationPassNode, Plane, PlaneGeometry, PlaneHelper, PointLight, PointLightHelper, PointLightNode, PointUVNode, Points, PointsMaterial, PointsNodeMaterial, PolarGridHelper, PolyhedronGeometry, PositionalAudio, PostProcessing, PosterizeNode, PropertyBinding, PropertyMixer, PropertyNode, QuadMesh, QuadraticBezierCurve, QuadraticBezierCurve3, Quaternion, QuaternionKeyframeTrack, QuaternionLinearInterpolant, RED_GREEN_RGTC2_Format, RED_RGTC1_Format, REVISION, RGBADepthPacking, RGBAFormat, RGBAIntegerFormat, RGBA_ASTC_10x10_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGBDepthPacking, RGBFormat, RGBIntegerFormat, RGBShiftNode, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, RGDepthPacking, RGFormat, RGIntegerFormat, RTTNode, RangeNode, RawShaderMaterial, Ray, Raycaster, Rec709Primaries, RectAreaLight, RectAreaLightNode, RedFormat, RedIntegerFormat, ReferenceNode, ReflectorNode, ReinhardToneMapping$1 as ReinhardToneMapping, RemapNode, RenderOutputNode, RenderTarget, RendererReferenceNode, RepeatWrapping, ReplaceStencilOp, Return, ReverseSubtractEquation, RingGeometry, RotateNode, SIGNED_RED_GREEN_RGTC2_Format, SIGNED_RED_RGTC1_Format, SRGBColorSpace, SRGBTransfer, SSAAPassNode, Scene, SceneNode, Schlick_to_F0, ScriptableNode, ScriptableValueNode, SetNode, ShaderMaterial, ShaderNode, ShadowMaterial, ShadowNodeMaterial, Shape, ShapeGeometry, ShapePath, ShapeUtils, ShortType, Skeleton, SkeletonHelper, SkinnedMesh, SkinningNode, SobelOperatorNode, Source, Sphere, SphereGeometry, Spherical, SphericalHarmonics3, SplineCurve, SplitNode, SpotLight, SpotLightHelper, SpotLightNode, Sprite, SpriteMaterial, SpriteNodeMaterial, SpriteSheetUVNode, SrcAlphaFactor, SrcAlphaSaturateFactor, SrcColorFactor, StackNode, StaticCopyUsage, StaticDrawUsage, StaticReadUsage, StereoCamera, StereoPassNode, StorageArrayElementNode, StorageBufferAttribute, StorageBufferNode, StorageInstancedBufferAttribute, StorageTexture, StorageTextureNode, StreamCopyUsage, StreamDrawUsage, StreamReadUsage, StringKeyframeTrack, SubtractEquation, SubtractiveBlending, TBNViewMatrix, TOUCH, TangentSpaceNormalMap, TempNode, TetrahedronGeometry, Texture, Texture3DNode, TextureLoader, TextureNode, TextureSizeNode, TimerNode, ToneMappingFunctions, ToneMappingNode, TorusGeometry, TorusKnotGeometry, TransitionNode, Triangle, TriangleFanDrawMode, TriangleStripDrawMode, TrianglesDrawMode, TriplanarTexturesNode, TubeGeometry, UVMapping, Uint16BufferAttribute, Uint32BufferAttribute, Uint8BufferAttribute, Uint8ClampedBufferAttribute, Uniform$1 as Uniform, UniformArrayNode, UniformGroupNode, UniformNode, UniformsGroup$1 as UniformsGroup, UnsignedByteType, UnsignedInt248Type, UnsignedInt5999Type, UnsignedIntType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShortType, UserDataNode, VSMShadowMap, V_GGX_SmithCorrelated, VarNode, VaryingNode, Vector2, Vector3, Vector4, VectorKeyframeTrack, VertexColorNode, VideoTexture, ViewportDepthNode, ViewportDepthTextureNode, ViewportNode, ViewportSharedTextureNode, ViewportTextureNode, VolumeNodeMaterial, WebGL3DRenderTarget, WebGLArrayRenderTarget, WebGLCoordinateSystem, WebGLCubeRenderTarget, WebGLMultipleRenderTargets, WebGLRenderTarget, WebGPUCoordinateSystem, WebGPURenderer, WireframeGeometry, WrapAroundEnding, ZeroCurvatureEnding, ZeroFactor, ZeroSlopeEnding, ZeroStencilOp, abs, acos, add, addMethodChaining, addNodeElement, afterImage, all, alphaT, anaglyphPass, anamorphic, and, anisotropy, anisotropyB, anisotropyT, any, ao, append, arrayBuffer, asin, assign, atan, atan2, attenuationColor, attenuationDistance, attribute, backgroundBlurriness, backgroundIntensity, batch, billboarding, bitAnd, bitNot, bitOr, bitXor, bitangentGeometry, bitangentLocal, bitangentView, bitangentWorld, bitcast, bleach, bloom, blur, bool, buffer, bufferAttribute, bumpMap, burn, bvec2, bvec3, bvec4, bypass, cache, call, cameraFar, cameraLogDepth, cameraNear, cameraNormalMatrix, cameraPosition, cameraProjectionMatrix, cameraProjectionMatrixInverse, cameraViewMatrix, cameraWorldMatrix, cbrt, ceil, checker, clamp, clearcoat, clearcoatRoughness, code, color, colorSpaceToLinear, colorToDirection, compute, cond, context, convert, convertToTexture, cos, createCanvasElement, cross, cubeTexture, dFdx, dFdy, dashSize, defaultBuildStages, defaultShaderStages, defined, degrees, denoise, densityFog, depth, depthPass, difference, diffuseColor, directionToColor, dispersion, distance, div, dodge, dof, dot, dotScreen, drawIndex, dynamicBufferAttribute, element, emissive, equal, equals, equirectUV, exp, exp2, expression, faceDirection, faceForward, film, float, floor, fog, fract, frameGroup, frameId, frontFacing, fwidth, fxaa, gain, gapSize, gaussianBlur, getColorSpaceMethod, getConstNodeType, getCurrentStack, getDirection, getDistanceAttenuation, getGeometryRoughness, getRoughness, getTextureIndex, global, glsl, glslFn, grayscale, greaterThan, greaterThanEqual, hash, hue, instance, instanceIndex, instancedBufferAttribute, instancedDynamicBufferAttribute, int, inverseSqrt, invocationLocalIndex, ior, iridescence, iridescenceIOR, iridescenceThickness, ivec2, ivec3, ivec4, js, label, length, lengthSq, lessThan, lessThanEqual, lightTargetDirection, lightingContext, lights, linearDepth, linearToColorSpace, log, log2, luminance, lut3D, mat2, mat3, mat4, matcapUV, materialAOMap, materialAlphaTest, materialAnisotropy, materialAnisotropyVector, materialClearcoat, materialClearcoatNormal, materialClearcoatRoughness, materialColor, materialDispersion, materialEmissive, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialLightMap, materialLineDashOffset, materialLineDashSize, materialLineGapSize, materialLineScale, materialLineWidth, materialMetalness, materialNormal, materialOpacity, materialPointWidth, materialReference, materialReflectivity, materialRefractionRatio, materialRotation, materialRoughness, materialSheen, materialSheenRoughness, materialShininess, materialSpecular, materialSpecularStrength, max$1 as max, maxMipLevel, metalness, min$1 as min, mix, mixElement, mod, modInt, modelDirection, modelNormalMatrix, modelPosition, modelScale, modelViewMatrix, modelViewPosition, modelViewProjection, modelWorldMatrix, modelWorldMatrixInverse, morphReference, motionBlur, mrt, mul, mx_aastep, mx_cell_noise_float, mx_contrast, mx_fractal_noise_float, mx_fractal_noise_vec2, mx_fractal_noise_vec3, mx_fractal_noise_vec4, mx_hsvtorgb, mx_noise_float, mx_noise_vec3, mx_noise_vec4, mx_ramplr, mx_ramptb, mx_rgbtohsv, mx_safepower, mx_splitlr, mx_splittb, mx_srgb_texture_to_lin_rec709, mx_transform_uv, mx_worley_noise_float, mx_worley_noise_vec2, mx_worley_noise_vec3, negate, nodeArray, nodeImmutable, nodeObject, nodeObjects, nodeProxy, normalFlat, normalGeometry, normalLocal, normalMap, normalView, normalWorld, normalize, not, notEqual, objectDirection, objectGroup, objectNormalMatrix, objectPosition, objectScale, objectViewMatrix, objectViewPosition, objectWorldMatrix, oneMinus, or, orthographicDepthToViewZ, oscSawtooth, oscSine, oscSquare, oscTriangle, output, outputStruct, overlay, overloadingFn, parabola, parallaxBarrierPass, parallaxDirection, parallaxUV, parameter, pass, passTexture, pcurve, perspectiveDepthToViewZ, pixelationPass, pmremTexture, pointUV, pointWidth, positionGeometry, positionLocal, positionPrevious, positionView, positionViewDirection, positionWorld, positionWorldDirection, posterize, pow, pow2, pow3, pow4, property, radians, rand, range, rangeFog, reciprocal, reference, referenceBuffer, reflect, reflectVector, reflectView, reflector, refract, refractVector, refractView, remainder, remap, remapClamp, renderGroup, renderOutput, rendererReference, rgbShift, rotate, rotateUV, roughness, round, rtt, sampler, saturate, saturation, screen, scriptable, scriptableValue, select, sepia, setCurrentStack, shaderStages, sharedUniformGroup, sheen, sheenRoughness, shiftLeft, shiftRight, shininess, sign, sin, sinc, skinning, skinningReference, smoothstep, smoothstepElement, sobel, specularColor, specularF90, spherizeUV, split, spritesheetUV, sqrt, ssaaPass, stack, step, stereoPass, storage, storageObject, storageTexture, string, sub, tan, tangentGeometry, tangentLocal, tangentView, tangentWorld, temp, texture, texture3D, textureBicubic, textureCubeUV, textureLoad, textureSize, textureStore, thickness, threshold, timerDelta, timerGlobal, timerLocal, toneMapping, toneMappingExposure, transformDirection, transformedBentNormalView, transformedBitangentView, transformedBitangentWorld, transformedClearcoatNormalView, transformedNormalView, transformedNormalWorld, transformedTangentView, transformedTangentWorld, transition, transmission, transpose, tri, tri3, triNoise3D, triplanarTexture, triplanarTextures, trunc, tslFn, uint, uniform, uniformArray, uniformGroup, userData, uv, uvec2, uvec3, uvec4, varying, varyingProperty, vec2, vec3, vec4, vectorComponents, velocity, vertexColor, vertexIndex, vibrance, viewZToOrthographicDepth, viewZToPerspectiveDepth, viewport, viewportBottomLeft, viewportCoordinate, viewportDepthTexture, viewportLinearDepth, viewportMipTexture, viewportResolution, viewportSafeUV, viewportSharedTexture, viewportTexture, viewportTopLeft, viewportUV, wgsl, wgslFn, xor }; +export { ACESFilmicToneMapping$1 as ACESFilmicToneMapping, AONode, AddEquation, AddOperation, AdditiveAnimationBlendMode, AdditiveBlending, AfterImageNode, AgXToneMapping$1 as AgXToneMapping, AlphaFormat, AlwaysCompare, AlwaysDepth, AlwaysStencilFunc, AmbientLight, AmbientLightNode, AnaglyphPassNode, AnalyticLightNode, AnamorphicNode, AnimationAction, AnimationClip, AnimationLoader, AnimationMixer, AnimationObjectGroup, AnimationUtils, ArcCurve, ArrayCamera, ArrayElementNode, ArrowHelper, AssignNode, AttachedBindMode, AttributeNode, Audio, AudioAnalyser, AudioContext, AudioListener, AudioLoader, AxesHelper, BRDF_GGX, BRDF_Lambert, BackSide, BasicDepthPacking, BasicEnvironmentNode, BasicShadowMap$1 as BasicShadowMap, BatchNode, BatchedMesh, BloomNode, Bone, BooleanKeyframeTrack, Box2, Box3, Box3Helper, BoxGeometry, BoxHelper, Break, BufferAttribute, BufferAttributeNode, BufferGeometry, BufferGeometryLoader, BufferNode, BumpMapNode, BypassNode, ByteType, Cache, CacheNode, Camera, CameraHelper, CanvasTexture, CapsuleGeometry, CatmullRomCurve3, CineonToneMapping$1 as CineonToneMapping, CircleGeometry, ClampToEdgeWrapping, Clock, CodeNode, Color, ColorKeyframeTrack, ColorManagement, ColorSpaceFunctions, ColorSpaceNode, CompressedArrayTexture, CompressedCubeTexture, CompressedTexture, CompressedTextureLoader, ComputeNode, ConeGeometry, ConstNode, ConstantAlphaFactor, ConstantColorFactor, ContextNode, Continue, Controls, ConvertNode, CubeCamera, CubeReflectionMapping, CubeRefractionMapping, CubeTexture, CubeTextureLoader, CubeTextureNode, CubeUVReflectionMapping, CubicBezierCurve, CubicBezierCurve3, CubicInterpolant, CullFaceBack, CullFaceFront, CullFaceFrontBack, CullFaceNone, Curve, CurvePath, CustomBlending, CustomToneMapping, CylinderGeometry, Cylindrical, DFGApprox, D_GGX, Data3DTexture, DataArrayTexture, DataTexture, DataTextureLoader, DataUtils, DecrementStencilOp, DecrementWrapStencilOp, DefaultLoadingManager, DenoiseNode, DepthFormat, DepthOfFieldNode, DepthStencilFormat, DepthTexture, DetachedBindMode, DirectionalLight, DirectionalLightHelper, DirectionalLightNode, Discard, DiscreteInterpolant, DisplayP3ColorSpace, DodecahedronGeometry, DotScreenNode, DoubleSide, DstAlphaFactor, DstColorFactor, DynamicCopyUsage, DynamicDrawUsage, DynamicReadUsage, EPSILON, EdgesGeometry, EllipseCurve, EnvironmentNode, EqualCompare, EqualDepth, EqualStencilFunc, EquirectUVNode, EquirectangularReflectionMapping, EquirectangularRefractionMapping, Euler, EventDispatcher, ExpressionNode, ExtrudeGeometry, FXAANode, F_Schlick, FileLoader, FilmNode, Float16BufferAttribute, Float32BufferAttribute, FloatType, Fn, Fog, FogExp2, FogExp2Node, FogNode, FogRangeNode, FramebufferTexture, FrontFacingNode, FrontSide, Frustum, FunctionCallNode, FunctionNode, FunctionOverloadingNode, GLBufferAttribute, GLSL1, GLSL3, GLSLNodeParser, GTAONode, GaussianBlurNode, GreaterCompare, GreaterDepth, GreaterEqualCompare, GreaterEqualDepth, GreaterEqualStencilFunc, GreaterStencilFunc, GridHelper, Group, HalfFloatType, HemisphereLight, HemisphereLightHelper, HemisphereLightNode, IESSpotLight, IESSpotLightNode, INFINITY, IcosahedronGeometry, If, ImageBitmapLoader, ImageLoader, ImageUtils, IncrementStencilOp, IncrementWrapStencilOp, IndexNode, InstanceNode, InstancedBufferAttribute, InstancedBufferGeometry, InstancedInterleavedBuffer, InstancedMesh, InstancedPointsNodeMaterial, Int16BufferAttribute, Int32BufferAttribute, Int8BufferAttribute, IntType, InterleavedBuffer, InterleavedBufferAttribute, Interpolant, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, InvertStencilOp, IrradianceNode, JoinNode, KeepStencilOp, KeyframeTrack, LOD, LatheGeometry, Layers, LessCompare, LessDepth, LessEqualCompare, LessEqualDepth, LessEqualStencilFunc, LessStencilFunc, Light, LightNode, LightProbe, LightProbeNode, LightingContextNode, LightingModel, LightingNode, LightsNode, Line, Line2NodeMaterial, Line3, LineBasicMaterial, LineBasicNodeMaterial, LineCurve, LineCurve3, LineDashedMaterial, LineDashedNodeMaterial, LineLoop, LineSegments, LinearDisplayP3ColorSpace, LinearFilter, LinearInterpolant, LinearMipMapLinearFilter, LinearMipMapNearestFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, LinearSRGBColorSpace, LinearToneMapping$1 as LinearToneMapping, LinearTransfer, Loader, LoaderUtils, LoadingManager, Loop, LoopNode, LoopOnce, LoopPingPong, LoopRepeat, LuminanceAlphaFormat, LuminanceFormat, Lut3DNode, MOUSE, MRTNode, MatcapUVNode, Material, MaterialLoader, MaterialNode, MaterialReferenceNode, MathUtils, Matrix2, Matrix3, Matrix4, MaxEquation, MaxMipLevelNode, Mesh, MeshBasicMaterial, MeshBasicNodeMaterial, MeshDepthMaterial, MeshDistanceMaterial, MeshLambertMaterial, MeshLambertNodeMaterial, MeshMatcapMaterial, MeshMatcapNodeMaterial, MeshNormalMaterial, MeshNormalNodeMaterial, MeshPhongMaterial, MeshPhongNodeMaterial, MeshPhysicalMaterial, MeshPhysicalNodeMaterial, MeshSSSNodeMaterial, MeshStandardMaterial, MeshStandardNodeMaterial, MeshToonMaterial, MeshToonNodeMaterial, MinEquation, MirroredRepeatWrapping, MixOperation, ModelNode, ModelViewProjectionNode, MorphNode, MultiplyBlending, MultiplyOperation, NearestFilter, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, NeutralToneMapping$1 as NeutralToneMapping, NeverCompare, NeverDepth, NeverStencilFunc, NoBlending, NoColorSpace, NoToneMapping, Node, NodeAttribute, NodeBuilder, NodeCache, NodeCode, NodeFrame, NodeFunctionInput, NodeLoader, NodeMaterial, NodeMaterialLoader, NodeObjectLoader, NodeShaderStage, NodeType, NodeUniform, NodeUpdateType, NodeUtils, NodeVar, NodeVarying, NormalAnimationBlendMode, NormalBlending, NormalMapNode, NotEqualCompare, NotEqualDepth, NotEqualStencilFunc, NumberKeyframeTrack, Object3D, Object3DNode, ObjectLoader, ObjectSpaceNormalMap, OctahedronGeometry, OneFactor, OneMinusConstantAlphaFactor, OneMinusConstantColorFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcAlphaFactor, OneMinusSrcColorFactor, OrthographicCamera, OscNode, OutputStructNode, P3Primaries, PCFShadowMap$1 as PCFShadowMap, PCFSoftShadowMap$1 as PCFSoftShadowMap, PI, PI2, PMREMGenerator, PMREMNode, ParallaxBarrierPassNode, ParameterNode, PassNode, Path, PerspectiveCamera, PhongLightingModel, PhysicalLightingModel, PixelationPassNode, Plane, PlaneGeometry, PlaneHelper, PointLight, PointLightHelper, PointLightNode, PointUVNode, Points, PointsMaterial, PointsNodeMaterial, PolarGridHelper, PolyhedronGeometry, PositionalAudio, PostProcessing, PosterizeNode, PropertyBinding, PropertyMixer, PropertyNode, QuadMesh, QuadraticBezierCurve, QuadraticBezierCurve3, Quaternion, QuaternionKeyframeTrack, QuaternionLinearInterpolant, RED_GREEN_RGTC2_Format, RED_RGTC1_Format, REVISION, RGBADepthPacking, RGBAFormat, RGBAIntegerFormat, RGBA_ASTC_10x10_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_BPTC_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGBDepthPacking, RGBFormat, RGBIntegerFormat, RGBShiftNode, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGB_S3TC_DXT1_Format, RGDepthPacking, RGFormat, RGIntegerFormat, RTTNode, RangeNode, RawShaderMaterial, Ray, Raycaster, Rec709Primaries, RectAreaLight, RectAreaLightNode, RedFormat, RedIntegerFormat, ReferenceNode, ReflectorNode, ReinhardToneMapping$1 as ReinhardToneMapping, RemapNode, RenderOutputNode, RenderTarget, RendererReferenceNode, RepeatWrapping, ReplaceStencilOp, Return, ReverseSubtractEquation, RingGeometry, RotateNode, SIGNED_RED_GREEN_RGTC2_Format, SIGNED_RED_RGTC1_Format, SRGBColorSpace, SRGBTransfer, SSAAPassNode, Scene, SceneNode, Schlick_to_F0, ScriptableNode, ScriptableValueNode, SetNode, ShaderMaterial, ShaderNode, ShadowMaterial, ShadowNodeMaterial, Shape, ShapeGeometry, ShapePath, ShapeUtils, ShortType, Skeleton, SkeletonHelper, SkinnedMesh, SkinningNode, SobelOperatorNode, Source, Sphere, SphereGeometry, Spherical, SphericalHarmonics3, SplineCurve, SplitNode, SpotLight, SpotLightHelper, SpotLightNode, Sprite, SpriteMaterial, SpriteNodeMaterial, SpriteSheetUVNode, SrcAlphaFactor, SrcAlphaSaturateFactor, SrcColorFactor, StackNode, StaticCopyUsage, StaticDrawUsage, StaticReadUsage, StereoCamera, StereoPassNode, StorageArrayElementNode, StorageBufferAttribute, StorageBufferNode, StorageInstancedBufferAttribute, StorageTexture, StorageTextureNode, StreamCopyUsage, StreamDrawUsage, StreamReadUsage, StringKeyframeTrack, SubtractEquation, SubtractiveBlending, TBNViewMatrix, TOUCH, TangentSpaceNormalMap, TempNode, TetrahedronGeometry, Texture, Texture3DNode, TextureLoader, TextureNode, TextureSizeNode, TimerNode, ToneMappingFunctions, ToneMappingNode, TorusGeometry, TorusKnotGeometry, TransitionNode, Triangle, TriangleFanDrawMode, TriangleStripDrawMode, TrianglesDrawMode, TriplanarTexturesNode, TubeGeometry, UVMapping, Uint16BufferAttribute, Uint32BufferAttribute, Uint8BufferAttribute, Uint8ClampedBufferAttribute, Uniform$1 as Uniform, UniformArrayNode, UniformGroupNode, UniformNode, UniformsGroup$1 as UniformsGroup, UnsignedByteType, UnsignedInt248Type, UnsignedInt5999Type, UnsignedIntType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedShortType, UserDataNode, VSMShadowMap, V_GGX_SmithCorrelated, VarNode, VaryingNode, Vector2, Vector3, Vector4, VectorKeyframeTrack, VertexColorNode, VideoTexture, ViewportDepthNode, ViewportDepthTextureNode, ViewportNode, ViewportSharedTextureNode, ViewportTextureNode, VolumeNodeMaterial, WebGL3DRenderTarget, WebGLArrayRenderTarget, WebGLCoordinateSystem, WebGLCubeRenderTarget, WebGLMultipleRenderTargets, WebGLRenderTarget, WebGPUCoordinateSystem, WebGPURenderer, WireframeGeometry, WrapAroundEnding, ZeroCurvatureEnding, ZeroFactor, ZeroSlopeEnding, ZeroStencilOp, abs, acos, add, addMethodChaining, addNodeElement, afterImage, all, alphaT, anaglyphPass, anamorphic, and, anisotropy, anisotropyB, anisotropyT, any, ao, append, arrayBuffer, asin, assign, atan, atan2, attenuationColor, attenuationDistance, attribute, backgroundBlurriness, backgroundIntensity, batch, billboarding, bitAnd, bitNot, bitOr, bitXor, bitangentGeometry, bitangentLocal, bitangentView, bitangentWorld, bitcast, bleach, bloom, blur, bool, buffer, bufferAttribute, bumpMap, burn, bvec2, bvec3, bvec4, bypass, cache, call, cameraFar, cameraLogDepth, cameraNear, cameraNormalMatrix, cameraPosition, cameraProjectionMatrix, cameraProjectionMatrixInverse, cameraViewMatrix, cameraWorldMatrix, cbrt, ceil, checker, clamp, clearcoat, clearcoatRoughness, code, color, colorSpaceToLinearSRGB, colorToDirection, compute, cond, context, convert, convertToTexture, cos, createCanvasElement, cross, cubeTexture, dFdx, dFdy, dashSize, defaultBuildStages, defaultShaderStages, defined, degrees, denoise, densityFog, depth, depthPass, difference, diffuseColor, directionToColor, dispersion, distance, div, dodge, dof, dot, dotScreen, drawIndex, dynamicBufferAttribute, element, emissive, equal, equals, equirectUV, exp, exp2, expression, faceDirection, faceForward, film, float, floor, fog, fract, frameGroup, frameId, frontFacing, fwidth, fxaa, gain, gapSize, gaussianBlur, getColorSpaceMethod, getConstNodeType, getCurrentStack, getDirection, getDistanceAttenuation, getGeometryRoughness, getRoughness, getTextureIndex, global, glsl, glslFn, grayscale, greaterThan, greaterThanEqual, hash, hue, instance, instanceIndex, instancedBufferAttribute, instancedDynamicBufferAttribute, int, inverseSqrt, invocationLocalIndex, ior, iridescence, iridescenceIOR, iridescenceThickness, ivec2, ivec3, ivec4, js, label, length, lengthSq, lessThan, lessThanEqual, lightTargetDirection, lightingContext, lights, linearDepth, linearSRGBToColorSpace, log, log2, luminance, lut3D, mat2, mat3, mat4, matcapUV, materialAOMap, materialAlphaTest, materialAnisotropy, materialAnisotropyVector, materialClearcoat, materialClearcoatNormal, materialClearcoatRoughness, materialColor, materialDispersion, materialEmissive, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialLightMap, materialLineDashOffset, materialLineDashSize, materialLineGapSize, materialLineScale, materialLineWidth, materialMetalness, materialNormal, materialOpacity, materialPointWidth, materialReference, materialReflectivity, materialRefractionRatio, materialRotation, materialRoughness, materialSheen, materialSheenRoughness, materialShininess, materialSpecular, materialSpecularStrength, max$1 as max, maxMipLevel, metalness, min$1 as min, mix, mixElement, mod, modInt, modelDirection, modelNormalMatrix, modelPosition, modelScale, modelViewMatrix, modelViewPosition, modelViewProjection, modelWorldMatrix, modelWorldMatrixInverse, morphReference, motionBlur, mrt, mul, mx_aastep, mx_cell_noise_float, mx_contrast, mx_fractal_noise_float, mx_fractal_noise_vec2, mx_fractal_noise_vec3, mx_fractal_noise_vec4, mx_hsvtorgb, mx_noise_float, mx_noise_vec3, mx_noise_vec4, mx_ramplr, mx_ramptb, mx_rgbtohsv, mx_safepower, mx_splitlr, mx_splittb, mx_srgb_texture_to_lin_rec709, mx_transform_uv, mx_worley_noise_float, mx_worley_noise_vec2, mx_worley_noise_vec3, negate, nodeArray, nodeImmutable, nodeObject, nodeObjects, nodeProxy, normalFlat, normalGeometry, normalLocal, normalMap, normalView, normalWorld, normalize, not, notEqual, objectDirection, objectGroup, objectNormalMatrix, objectPosition, objectScale, objectViewMatrix, objectViewPosition, objectWorldMatrix, oneMinus, or, orthographicDepthToViewZ, oscSawtooth, oscSine, oscSquare, oscTriangle, output, outputStruct, overlay, overloadingFn, parabola, parallaxBarrierPass, parallaxDirection, parallaxUV, parameter, pass, passTexture, pcurve, perspectiveDepthToViewZ, pixelationPass, pmremTexture, pointUV, pointWidth, positionGeometry, positionLocal, positionPrevious, positionView, positionViewDirection, positionWorld, positionWorldDirection, posterize, pow, pow2, pow3, pow4, property, radians, rand, range, rangeFog, reciprocal, reference, referenceBuffer, reflect, reflectVector, reflectView, reflector, refract, refractVector, refractView, registerNode, remainder, remap, remapClamp, renderGroup, renderOutput, rendererReference, rgbShift, rotate, rotateUV, roughness, round, rtt, sampler, saturate, saturation, screen, scriptable, scriptableValue, select, sepia, setCurrentStack, shaderStages, sharedUniformGroup, sheen, sheenRoughness, shiftLeft, shiftRight, shininess, sign, sin, sinc, skinning, skinningReference, smoothstep, smoothstepElement, sobel, specularColor, specularF90, spherizeUV, split, spritesheetUV, sqrt, ssaaPass, stack, step, stereoPass, storage, storageObject, storageTexture, string, sub, tan, tangentGeometry, tangentLocal, tangentView, tangentWorld, temp, texture, texture3D, textureBicubic, textureCubeUV, textureLoad, textureSize, textureStore, thickness, threshold, timerDelta, timerGlobal, timerLocal, toneMapping, toneMappingExposure, transformDirection, transformedBentNormalView, transformedBitangentView, transformedBitangentWorld, transformedClearcoatNormalView, transformedNormalView, transformedNormalWorld, transformedTangentView, transformedTangentWorld, transition, transmission, transpose, tri, tri3, triNoise3D, triplanarTexture, triplanarTextures, trunc, tslFn, uint, uniform, uniformArray, uniformGroup, userData, uv, uvec2, uvec3, uvec4, varying, varyingProperty, vec2, vec3, vec4, vectorComponents, velocity, vertexColor, vertexIndex, vibrance, viewZToOrthographicDepth, viewZToPerspectiveDepth, viewport, viewportBottomLeft, viewportCoordinate, viewportDepthTexture, viewportLinearDepth, viewportMipTexture, viewportResolution, viewportSafeUV, viewportSharedTexture, viewportTexture, viewportTopLeft, viewportUV, wgsl, wgslFn, xor }; diff --git a/build/three.webgpu.min.js b/build/three.webgpu.min.js index 8590cb6d98123f..ff553dd773d135 100644 --- a/build/three.webgpu.min.js +++ b/build/three.webgpu.min.js @@ -3,4 +3,4 @@ * Copyright 2010-2024 Three.js Authors * SPDX-License-Identifier: MIT */ -const e="168dev",t={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},s={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},i=0,r=1,n=2,o=3,a=0,h=1,l=2,u=3,c=0,d=1,p=2,m=0,g=1,f=2,y=3,x=4,b=5,v=100,T=101,_=102,w=103,S=104,M=200,A=201,N=202,R=203,C=204,E=205,B=206,I=207,P=208,F=209,z=210,U=211,L=212,O=213,V=214,D=0,k=1,G=2,W=3,H=4,j=5,q=6,$=7,X=0,Y=1,J=2,Z=0,K=1,Q=2,ee=3,te=4,se=5,ie=6,re=7,ne="attached",oe="detached",ae=300,he=301,le=302,ue=303,ce=304,de=306,pe=1e3,me=1001,ge=1002,fe=1003,ye=1004,xe=1004,be=1005,ve=1005,Te=1006,_e=1007,we=1007,Se=1008,Me=1008,Ae=1009,Ne=1010,Re=1011,Ce=1012,Ee=1013,Be=1014,Ie=1015,Pe=1016,Fe=1017,ze=1018,Ue=1020,Le=35902,Oe=1021,Ve=1022,De=1023,ke=1024,Ge=1025,We=1026,He=1027,je=1028,qe=1029,$e=1030,Xe=1031,Ye=1032,Je=1033,Ze=33776,Ke=33777,Qe=33778,et=33779,tt=35840,st=35841,it=35842,rt=35843,nt=36196,ot=37492,at=37496,ht=37808,lt=37809,ut=37810,ct=37811,dt=37812,pt=37813,mt=37814,gt=37815,ft=37816,yt=37817,xt=37818,bt=37819,vt=37820,Tt=37821,_t=36492,wt=36494,St=36495,Mt=36283,At=36284,Nt=36285,Rt=36286,Ct=2200,Et=2201,Bt=2202,It=2300,Pt=2301,Ft=2302,zt=2400,Ut=2401,Lt=2402,Ot=2500,Vt=2501,Dt=0,kt=1,Gt=2,Wt=3200,Ht=3201,jt=3202,qt=3203,$t=0,Xt=1,Yt="",Jt="srgb",Zt="srgb-linear",Kt="display-p3",Qt="display-p3-linear",es="linear",ts="srgb",ss="rec709",is="p3",rs=0,ns=7680,os=7681,as=7682,hs=7683,ls=34055,us=34056,cs=5386,ds=512,ps=513,ms=514,gs=515,fs=516,ys=517,xs=518,bs=519,vs=512,Ts=513,_s=514,ws=515,Ss=516,Ms=517,As=518,Ns=519,Rs=35044,Cs=35048,Es=35040,Bs=35045,Is=35049,Ps=35041,Fs=35046,zs=35050,Us=35042,Ls="100",Os="300 es",Vs=2e3,Ds=2001;class ks{addEventListener(e,t){void 0===this._listeners&&(this._listeners={});const s=this._listeners;void 0===s[e]&&(s[e]=[]),-1===s[e].indexOf(t)&&s[e].push(t)}hasEventListener(e,t){if(void 0===this._listeners)return!1;const s=this._listeners;return void 0!==s[e]&&-1!==s[e].indexOf(t)}removeEventListener(e,t){if(void 0===this._listeners)return;const s=this._listeners[e];if(void 0!==s){const e=s.indexOf(t);-1!==e&&s.splice(e,1)}}dispatchEvent(e){if(void 0===this._listeners)return;const t=this._listeners[e.type];if(void 0!==t){e.target=this;const s=t.slice(0);for(let t=0,i=s.length;t>8&255]+Gs[e>>16&255]+Gs[e>>24&255]+"-"+Gs[255&t]+Gs[t>>8&255]+"-"+Gs[t>>16&15|64]+Gs[t>>24&255]+"-"+Gs[63&s|128]+Gs[s>>8&255]+"-"+Gs[s>>16&255]+Gs[s>>24&255]+Gs[255&i]+Gs[i>>8&255]+Gs[i>>16&255]+Gs[i>>24&255]).toLowerCase()}function $s(e,t,s){return Math.max(t,Math.min(s,e))}function Xs(e,t){return(e%t+t)%t}function Ys(e,t,s){return(1-s)*e+s*t}function Js(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function Zs(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(4294967295*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(2147483647*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("Invalid component type.")}}const Ks={DEG2RAD:Hs,RAD2DEG:js,generateUUID:qs,clamp:$s,euclideanModulo:Xs,mapLinear:function(e,t,s,i,r){return i+(e-t)*(r-i)/(s-t)},inverseLerp:function(e,t,s){return e!==t?(s-e)/(t-e):0},lerp:Ys,damp:function(e,t,s,i){return Ys(e,t,1-Math.exp(-s*i))},pingpong:function(e,t=1){return t-Math.abs(Xs(e,2*t)-t)},smoothstep:function(e,t,s){return e<=t?0:e>=s?1:(e=(e-t)/(s-t))*e*(3-2*e)},smootherstep:function(e,t,s){return e<=t?0:e>=s?1:(e=(e-t)/(s-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){void 0!==e&&(Ws=e);let t=Ws+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296},degToRad:function(e){return e*Hs},radToDeg:function(e){return e*js},isPowerOfTwo:function(e){return 0==(e&e-1)&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},setQuaternionFromProperEuler:function(e,t,s,i,r){const n=Math.cos,o=Math.sin,a=n(s/2),h=o(s/2),l=n((t+i)/2),u=o((t+i)/2),c=n((t-i)/2),d=o((t-i)/2),p=n((i-t)/2),m=o((i-t)/2);switch(r){case"XYX":e.set(a*u,h*c,h*d,a*l);break;case"YZY":e.set(h*d,a*u,h*c,a*l);break;case"ZXZ":e.set(h*c,h*d,a*u,a*l);break;case"XZX":e.set(a*u,h*m,h*p,a*l);break;case"YXY":e.set(h*p,a*u,h*m,a*l);break;case"ZYZ":e.set(h*m,h*p,a*u,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:Zs,denormalize:Js};class Qs{constructor(e=0,t=0){Qs.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,s=this.y,i=e.elements;return this.x=i[0]*t+i[3]*s+i[6],this.y=i[1]*t+i[4]*s+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(e,Math.min(t,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const s=this.dot(e)/t;return Math.acos($s(s,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y;return t*t+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const s=Math.cos(t),i=Math.sin(t),r=this.x-e.x,n=this.y-e.y;return this.x=r*s-n*i+e.x,this.y=r*i+n*s+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ei{constructor(e,t,s,i,r,n,o,a,h){ei.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,s,i,r,n,o,a,h)}set(e,t,s,i,r,n,o,a,h){const l=this.elements;return l[0]=e,l[1]=i,l[2]=o,l[3]=t,l[4]=r,l[5]=a,l[6]=s,l[7]=n,l[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],this}extractBasis(e,t,s){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,i=t.elements,r=this.elements,n=s[0],o=s[3],a=s[6],h=s[1],l=s[4],u=s[7],c=s[2],d=s[5],p=s[8],m=i[0],g=i[3],f=i[6],y=i[1],x=i[4],b=i[7],v=i[2],T=i[5],_=i[8];return r[0]=n*m+o*y+a*v,r[3]=n*g+o*x+a*T,r[6]=n*f+o*b+a*_,r[1]=h*m+l*y+u*v,r[4]=h*g+l*x+u*T,r[7]=h*f+l*b+u*_,r[2]=c*m+d*y+p*v,r[5]=c*g+d*x+p*T,r[8]=c*f+d*b+p*_,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],s=e[1],i=e[2],r=e[3],n=e[4],o=e[5],a=e[6],h=e[7],l=e[8];return t*n*l-t*o*h-s*r*l+s*o*a+i*r*h-i*n*a}invert(){const e=this.elements,t=e[0],s=e[1],i=e[2],r=e[3],n=e[4],o=e[5],a=e[6],h=e[7],l=e[8],u=l*n-o*h,c=o*a-l*r,d=h*r-n*a,p=t*u+s*c+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return e[0]=u*m,e[1]=(i*h-l*s)*m,e[2]=(o*s-i*n)*m,e[3]=c*m,e[4]=(l*t-i*a)*m,e[5]=(i*r-o*t)*m,e[6]=d*m,e[7]=(s*a-h*t)*m,e[8]=(n*t-s*r)*m,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,s,i,r,n,o){const a=Math.cos(r),h=Math.sin(r);return this.set(s*a,s*h,-s*(a*n+h*o)+n+e,-i*h,i*a,-i*(-h*n+a*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(ti.makeScale(e,t)),this}rotate(e){return this.premultiply(ti.makeRotation(-e)),this}translate(e,t){return this.premultiply(ti.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,s,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,s=e.elements;for(let e=0;e<9;e++)if(t[e]!==s[e])return!1;return!0}fromArray(e,t=0){for(let s=0;s<9;s++)this.elements[s]=e[s+t];return this}toArray(e=[],t=0){const s=this.elements;return e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2],e[t+3]=s[3],e[t+4]=s[4],e[t+5]=s[5],e[t+6]=s[6],e[t+7]=s[7],e[t+8]=s[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}const ti=new ei;const si={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function ii(e,t){return new si[e](t)}function ri(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function ni(){const e=ri("canvas");return e.style.display="block",e}const oi={};function ai(e){e in oi||(oi[e]=!0,console.warn(e))}const hi=(new ei).set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),li=(new ei).set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),ui={[Zt]:{transfer:es,primaries:ss,luminanceCoefficients:[.2126,.7152,.0722],toReference:e=>e,fromReference:e=>e},[Jt]:{transfer:ts,primaries:ss,luminanceCoefficients:[.2126,.7152,.0722],toReference:e=>e.convertSRGBToLinear(),fromReference:e=>e.convertLinearToSRGB()},[Qt]:{transfer:es,primaries:is,luminanceCoefficients:[.2289,.6917,.0793],toReference:e=>e.applyMatrix3(li),fromReference:e=>e.applyMatrix3(hi)},[Kt]:{transfer:ts,primaries:is,luminanceCoefficients:[.2289,.6917,.0793],toReference:e=>e.convertSRGBToLinear().applyMatrix3(li),fromReference:e=>e.applyMatrix3(hi).convertLinearToSRGB()}},ci=new Set([Zt,Qt]),di={enabled:!0,_workingColorSpace:Zt,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(e){if(!ci.has(e))throw new Error(`Unsupported working color space, "${e}".`);this._workingColorSpace=e},convert:function(e,t,s){if(!1===this.enabled||t===s||!t||!s)return e;const i=ui[t].toReference;return(0,ui[s].fromReference)(i(e))},fromWorkingColorSpace:function(e,t){return this.convert(e,this._workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this._workingColorSpace)},getPrimaries:function(e){return ui[e].primaries},getTransfer:function(e){return e===Yt?es:ui[e].transfer},getLuminanceCoefficients:function(e,t=this._workingColorSpace){return e.fromArray(ui[t].luminanceCoefficients)}};function pi(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function mi(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}let gi;class fi{static getDataURL(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===gi&&(gi=ri("canvas")),gi.width=e.width,gi.height=e.height;const s=gi.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),t=gi}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const t=ri("canvas");t.width=e.width,t.height=e.height;const s=t.getContext("2d");s.drawImage(e,0,0,e.width,e.height);const i=s.getImageData(0,0,e.width,e.height),r=i.data;for(let e=0;e0&&(s.userData=this.userData),t||(e.textures[this.uuid]=s),s}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==ae)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case pe:e.x=e.x-Math.floor(e.x);break;case me:e.x=e.x<0?0:1;break;case ge:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case pe:e.y=e.y-Math.floor(e.y);break;case me:e.y=e.y<0?0:1;break;case ge:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){!0===e&&this.pmremVersion++}}Ti.DEFAULT_IMAGE=null,Ti.DEFAULT_MAPPING=ae,Ti.DEFAULT_ANISOTROPY=1;class _i{constructor(e=0,t=0,s=0,i=1){_i.prototype.isVector4=!0,this.x=e,this.y=t,this.z=s,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,s,i){return this.x=e,this.y=t,this.z=s,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,s=this.y,i=this.z,r=this.w,n=e.elements;return this.x=n[0]*t+n[4]*s+n[8]*i+n[12]*r,this.y=n[1]*t+n[5]*s+n[9]*i+n[13]*r,this.z=n[2]*t+n[6]*s+n[10]*i+n[14]*r,this.w=n[3]*t+n[7]*s+n[11]*i+n[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,s,i,r;const n=.01,o=.1,a=e.elements,h=a[0],l=a[4],u=a[8],c=a[1],d=a[5],p=a[9],m=a[2],g=a[6],f=a[10];if(Math.abs(l-c)a&&e>y?ey?a=0?1:-1,i=1-t*t;if(i>Number.EPSILON){const r=Math.sqrt(i),n=Math.atan2(r,t*s);e=Math.sin(e*n)/r,o=Math.sin(o*n)/r}const r=o*s;if(a=a*e+c*r,h=h*e+d*r,l=l*e+p*r,u=u*e+m*r,e===1-o){const e=1/Math.sqrt(a*a+h*h+l*l+u*u);a*=e,h*=e,l*=e,u*=e}}e[t]=a,e[t+1]=h,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,s,i,r,n){const o=s[i],a=s[i+1],h=s[i+2],l=s[i+3],u=r[n],c=r[n+1],d=r[n+2],p=r[n+3];return e[t]=o*p+l*u+a*d-h*c,e[t+1]=a*p+l*c+h*u-o*d,e[t+2]=h*p+l*d+o*c-a*u,e[t+3]=l*p-o*u-a*c-h*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,s,i){return this._x=e,this._y=t,this._z=s,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const s=e._x,i=e._y,r=e._z,n=e._order,o=Math.cos,a=Math.sin,h=o(s/2),l=o(i/2),u=o(r/2),c=a(s/2),d=a(i/2),p=a(r/2);switch(n){case"XYZ":this._x=c*l*u+h*d*p,this._y=h*d*u-c*l*p,this._z=h*l*p+c*d*u,this._w=h*l*u-c*d*p;break;case"YXZ":this._x=c*l*u+h*d*p,this._y=h*d*u-c*l*p,this._z=h*l*p-c*d*u,this._w=h*l*u+c*d*p;break;case"ZXY":this._x=c*l*u-h*d*p,this._y=h*d*u+c*l*p,this._z=h*l*p+c*d*u,this._w=h*l*u-c*d*p;break;case"ZYX":this._x=c*l*u-h*d*p,this._y=h*d*u+c*l*p,this._z=h*l*p-c*d*u,this._w=h*l*u+c*d*p;break;case"YZX":this._x=c*l*u+h*d*p,this._y=h*d*u+c*l*p,this._z=h*l*p-c*d*u,this._w=h*l*u-c*d*p;break;case"XZY":this._x=c*l*u-h*d*p,this._y=h*d*u-c*l*p,this._z=h*l*p+c*d*u,this._w=h*l*u+c*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+n)}return!0===t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const s=t/2,i=Math.sin(s);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,s=t[0],i=t[4],r=t[8],n=t[1],o=t[5],a=t[9],h=t[2],l=t[6],u=t[10],c=s+o+u;if(c>0){const e=.5/Math.sqrt(c+1);this._w=.25/e,this._x=(l-a)*e,this._y=(r-h)*e,this._z=(n-i)*e}else if(s>o&&s>u){const e=2*Math.sqrt(1+s-o-u);this._w=(l-a)/e,this._x=.25*e,this._y=(i+n)/e,this._z=(r+h)/e}else if(o>u){const e=2*Math.sqrt(1+o-s-u);this._w=(r-h)/e,this._x=(i+n)/e,this._y=.25*e,this._z=(a+l)/e}else{const e=2*Math.sqrt(1+u-s-o);this._w=(n-i)/e,this._x=(r+h)/e,this._y=(a+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let s=e.dot(t)+1;return sMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=s):(this._x=0,this._y=-e.z,this._z=e.y,this._w=s)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=s),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs($s(this.dot(e),-1,1)))}rotateTowards(e,t){const s=this.angleTo(e);if(0===s)return this;const i=Math.min(1,t/s);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const s=e._x,i=e._y,r=e._z,n=e._w,o=t._x,a=t._y,h=t._z,l=t._w;return this._x=s*l+n*o+i*h-r*a,this._y=i*l+n*a+r*o-s*h,this._z=r*l+n*h+s*a-i*o,this._w=n*l-s*o-i*a-r*h,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const s=this._x,i=this._y,r=this._z,n=this._w;let o=n*e._w+s*e._x+i*e._y+r*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=n,this._x=s,this._y=i,this._z=r,this;const a=1-o*o;if(a<=Number.EPSILON){const e=1-t;return this._w=e*n+t*this._w,this._x=e*s+t*this._x,this._y=e*i+t*this._y,this._z=e*r+t*this._z,this.normalize(),this}const h=Math.sqrt(a),l=Math.atan2(h,o),u=Math.sin((1-t)*l)/h,c=Math.sin(t*l)/h;return this._w=n*u+this._w*c,this._x=s*u+this._x*c,this._y=i*u+this._y*c,this._z=r*u+this._z*c,this._onChangeCallback(),this}slerpQuaternions(e,t,s){return this.copy(e).slerp(t,s)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),s=Math.random(),i=Math.sqrt(1-s),r=Math.sqrt(s);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Ei{constructor(e=0,t=0,s=0){Ei.prototype.isVector3=!0,this.x=e,this.y=t,this.z=s}set(e,t,s){return void 0===s&&(s=this.z),this.x=e,this.y=t,this.z=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Ii.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ii.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,s=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*s+r[6]*i,this.y=r[1]*t+r[4]*s+r[7]*i,this.z=r[2]*t+r[5]*s+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,s=this.y,i=this.z,r=e.elements,n=1/(r[3]*t+r[7]*s+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*s+r[8]*i+r[12])*n,this.y=(r[1]*t+r[5]*s+r[9]*i+r[13])*n,this.z=(r[2]*t+r[6]*s+r[10]*i+r[14])*n,this}applyQuaternion(e){const t=this.x,s=this.y,i=this.z,r=e.x,n=e.y,o=e.z,a=e.w,h=2*(n*i-o*s),l=2*(o*t-r*i),u=2*(r*s-n*t);return this.x=t+a*h+n*u-o*l,this.y=s+a*l+o*h-r*u,this.z=i+a*u+r*l-n*h,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,s=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*s+r[8]*i,this.y=r[1]*t+r[5]*s+r[9]*i,this.z=r[2]*t+r[6]*s+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(e,Math.min(t,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this.z=e.z+(t.z-e.z)*s,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const s=e.x,i=e.y,r=e.z,n=t.x,o=t.y,a=t.z;return this.x=i*a-r*o,this.y=r*n-s*a,this.z=s*o-i*n,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const s=e.dot(this)/t;return this.copy(e).multiplyScalar(s)}projectOnPlane(e){return Bi.copy(this).projectOnVector(e),this.sub(Bi)}reflect(e){return this.sub(Bi.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const s=this.dot(e)/t;return Math.acos($s(s,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y,i=this.z-e.z;return t*t+s*s+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,s){const i=Math.sin(t)*e;return this.x=i*Math.sin(s),this.y=Math.cos(t)*e,this.z=i*Math.cos(s),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,s){return this.x=e*Math.sin(t),this.y=s,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),s=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=s,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=2*Math.random()-1,s=Math.sqrt(1-t*t);return this.x=s*Math.cos(e),this.y=t,this.z=s*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Bi=new Ei,Ii=new Ci;class Pi{constructor(e=new Ei(1/0,1/0,1/0),t=new Ei(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,s=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,zi),zi.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,s;return e.normal.x>0?(t=e.normal.x*this.min.x,s=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,s=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,s+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,s+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,s+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,s+=e.normal.z*this.min.z),t<=-e.constant&&s>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Wi),Hi.subVectors(this.max,Wi),Li.subVectors(e.a,Wi),Oi.subVectors(e.b,Wi),Vi.subVectors(e.c,Wi),Di.subVectors(Oi,Li),ki.subVectors(Vi,Oi),Gi.subVectors(Li,Vi);let t=[0,-Di.z,Di.y,0,-ki.z,ki.y,0,-Gi.z,Gi.y,Di.z,0,-Di.x,ki.z,0,-ki.x,Gi.z,0,-Gi.x,-Di.y,Di.x,0,-ki.y,ki.x,0,-Gi.y,Gi.x,0];return!!$i(t,Li,Oi,Vi,Hi)&&(t=[1,0,0,0,1,0,0,0,1],!!$i(t,Li,Oi,Vi,Hi)&&(ji.crossVectors(Di,ki),t=[ji.x,ji.y,ji.z],$i(t,Li,Oi,Vi,Hi)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,zi).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(zi).length()),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(Fi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Fi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Fi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Fi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Fi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Fi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Fi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Fi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Fi)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Fi=[new Ei,new Ei,new Ei,new Ei,new Ei,new Ei,new Ei,new Ei],zi=new Ei,Ui=new Pi,Li=new Ei,Oi=new Ei,Vi=new Ei,Di=new Ei,ki=new Ei,Gi=new Ei,Wi=new Ei,Hi=new Ei,ji=new Ei,qi=new Ei;function $i(e,t,s,i,r){for(let n=0,o=e.length-3;n<=o;n+=3){qi.fromArray(e,n);const o=r.x*Math.abs(qi.x)+r.y*Math.abs(qi.y)+r.z*Math.abs(qi.z),a=t.dot(qi),h=s.dot(qi),l=i.dot(qi);if(Math.max(-Math.max(a,h,l),Math.min(a,h,l))>o)return!1}return!0}const Xi=new Pi,Yi=new Ei,Ji=new Ei;class Zi{constructor(e=new Ei,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const s=this.center;void 0!==t?s.copy(t):Xi.setFromPoints(e).getCenter(s);let i=0;for(let t=0,r=e.length;tthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Yi.subVectors(e,this.center);const t=Yi.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),s=.5*(e-this.radius);this.center.addScaledVector(Yi,s/e),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(Ji.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Yi.copy(e.center).add(Ji)),this.expandByPoint(Yi.copy(e.center).sub(Ji))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const Ki=new Ei,Qi=new Ei,er=new Ei,tr=new Ei,sr=new Ei,ir=new Ei,rr=new Ei;class nr{constructor(e=new Ei,t=new Ei(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Ki)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const s=t.dot(this.direction);return s<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,s)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Ki.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Ki.copy(this.origin).addScaledVector(this.direction,t),Ki.distanceToSquared(e))}distanceSqToSegment(e,t,s,i){Qi.copy(e).add(t).multiplyScalar(.5),er.copy(t).sub(e).normalize(),tr.copy(this.origin).sub(Qi);const r=.5*e.distanceTo(t),n=-this.direction.dot(er),o=tr.dot(this.direction),a=-tr.dot(er),h=tr.lengthSq(),l=Math.abs(1-n*n);let u,c,d,p;if(l>0)if(u=n*a-o,c=n*o-a,p=r*l,u>=0)if(c>=-p)if(c<=p){const e=1/l;u*=e,c*=e,d=u*(u+n*c+2*o)+c*(n*u+c+2*a)+h}else c=r,u=Math.max(0,-(n*c+o)),d=-u*u+c*(c+2*a)+h;else c=-r,u=Math.max(0,-(n*c+o)),d=-u*u+c*(c+2*a)+h;else c<=-p?(u=Math.max(0,-(-n*r+o)),c=u>0?-r:Math.min(Math.max(-r,-a),r),d=-u*u+c*(c+2*a)+h):c<=p?(u=0,c=Math.min(Math.max(-r,-a),r),d=c*(c+2*a)+h):(u=Math.max(0,-(n*r+o)),c=u>0?r:Math.min(Math.max(-r,-a),r),d=-u*u+c*(c+2*a)+h);else c=n>0?-r:r,u=Math.max(0,-(n*c+o)),d=-u*u+c*(c+2*a)+h;return s&&s.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(Qi).addScaledVector(er,c),d}intersectSphere(e,t){Ki.subVectors(e.center,this.origin);const s=Ki.dot(this.direction),i=Ki.dot(Ki)-s*s,r=e.radius*e.radius;if(i>r)return null;const n=Math.sqrt(r-i),o=s-n,a=s+n;return a<0?null:o<0?this.at(a,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const s=-(this.origin.dot(e.normal)+e.constant)/t;return s>=0?s:null}intersectPlane(e,t){const s=this.distanceToPlane(e);return null===s?null:this.at(s,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);if(0===t)return!0;return e.normal.dot(this.direction)*t<0}intersectBox(e,t){let s,i,r,n,o,a;const h=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,c=this.origin;return h>=0?(s=(e.min.x-c.x)*h,i=(e.max.x-c.x)*h):(s=(e.max.x-c.x)*h,i=(e.min.x-c.x)*h),l>=0?(r=(e.min.y-c.y)*l,n=(e.max.y-c.y)*l):(r=(e.max.y-c.y)*l,n=(e.min.y-c.y)*l),s>n||r>i?null:((r>s||isNaN(s))&&(s=r),(n=0?(o=(e.min.z-c.z)*u,a=(e.max.z-c.z)*u):(o=(e.max.z-c.z)*u,a=(e.min.z-c.z)*u),s>a||o>i?null:((o>s||s!=s)&&(s=o),(a=0?s:i,t)))}intersectsBox(e){return null!==this.intersectBox(e,Ki)}intersectTriangle(e,t,s,i,r){sr.subVectors(t,e),ir.subVectors(s,e),rr.crossVectors(sr,ir);let n,o=this.direction.dot(rr);if(o>0){if(i)return null;n=1}else{if(!(o<0))return null;n=-1,o=-o}tr.subVectors(this.origin,e);const a=n*this.direction.dot(ir.crossVectors(tr,ir));if(a<0)return null;const h=n*this.direction.dot(sr.cross(tr));if(h<0)return null;if(a+h>o)return null;const l=-n*tr.dot(rr);return l<0?null:this.at(l/o,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class or{constructor(e,t,s,i,r,n,o,a,h,l,u,c,d,p,m,g){or.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,t,s,i,r,n,o,a,h,l,u,c,d,p,m,g)}set(e,t,s,i,r,n,o,a,h,l,u,c,d,p,m,g){const f=this.elements;return f[0]=e,f[4]=t,f[8]=s,f[12]=i,f[1]=r,f[5]=n,f[9]=o,f[13]=a,f[2]=h,f[6]=l,f[10]=u,f[14]=c,f[3]=d,f[7]=p,f[11]=m,f[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new or).fromArray(this.elements)}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],t[9]=s[9],t[10]=s[10],t[11]=s[11],t[12]=s[12],t[13]=s[13],t[14]=s[14],t[15]=s[15],this}copyPosition(e){const t=this.elements,s=e.elements;return t[12]=s[12],t[13]=s[13],t[14]=s[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,s){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(e,t,s){return this.set(e.x,t.x,s.x,0,e.y,t.y,s.y,0,e.z,t.z,s.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,s=e.elements,i=1/ar.setFromMatrixColumn(e,0).length(),r=1/ar.setFromMatrixColumn(e,1).length(),n=1/ar.setFromMatrixColumn(e,2).length();return t[0]=s[0]*i,t[1]=s[1]*i,t[2]=s[2]*i,t[3]=0,t[4]=s[4]*r,t[5]=s[5]*r,t[6]=s[6]*r,t[7]=0,t[8]=s[8]*n,t[9]=s[9]*n,t[10]=s[10]*n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,s=e.x,i=e.y,r=e.z,n=Math.cos(s),o=Math.sin(s),a=Math.cos(i),h=Math.sin(i),l=Math.cos(r),u=Math.sin(r);if("XYZ"===e.order){const e=n*l,s=n*u,i=o*l,r=o*u;t[0]=a*l,t[4]=-a*u,t[8]=h,t[1]=s+i*h,t[5]=e-r*h,t[9]=-o*a,t[2]=r-e*h,t[6]=i+s*h,t[10]=n*a}else if("YXZ"===e.order){const e=a*l,s=a*u,i=h*l,r=h*u;t[0]=e+r*o,t[4]=i*o-s,t[8]=n*h,t[1]=n*u,t[5]=n*l,t[9]=-o,t[2]=s*o-i,t[6]=r+e*o,t[10]=n*a}else if("ZXY"===e.order){const e=a*l,s=a*u,i=h*l,r=h*u;t[0]=e-r*o,t[4]=-n*u,t[8]=i+s*o,t[1]=s+i*o,t[5]=n*l,t[9]=r-e*o,t[2]=-n*h,t[6]=o,t[10]=n*a}else if("ZYX"===e.order){const e=n*l,s=n*u,i=o*l,r=o*u;t[0]=a*l,t[4]=i*h-s,t[8]=e*h+r,t[1]=a*u,t[5]=r*h+e,t[9]=s*h-i,t[2]=-h,t[6]=o*a,t[10]=n*a}else if("YZX"===e.order){const e=n*a,s=n*h,i=o*a,r=o*h;t[0]=a*l,t[4]=r-e*u,t[8]=i*u+s,t[1]=u,t[5]=n*l,t[9]=-o*l,t[2]=-h*l,t[6]=s*u+i,t[10]=e-r*u}else if("XZY"===e.order){const e=n*a,s=n*h,i=o*a,r=o*h;t[0]=a*l,t[4]=-u,t[8]=h*l,t[1]=e*u+r,t[5]=n*l,t[9]=s*u-i,t[2]=i*u-s,t[6]=o*l,t[10]=r*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(lr,e,ur)}lookAt(e,t,s){const i=this.elements;return pr.subVectors(e,t),0===pr.lengthSq()&&(pr.z=1),pr.normalize(),cr.crossVectors(s,pr),0===cr.lengthSq()&&(1===Math.abs(s.z)?pr.x+=1e-4:pr.z+=1e-4,pr.normalize(),cr.crossVectors(s,pr)),cr.normalize(),dr.crossVectors(pr,cr),i[0]=cr.x,i[4]=dr.x,i[8]=pr.x,i[1]=cr.y,i[5]=dr.y,i[9]=pr.y,i[2]=cr.z,i[6]=dr.z,i[10]=pr.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,i=t.elements,r=this.elements,n=s[0],o=s[4],a=s[8],h=s[12],l=s[1],u=s[5],c=s[9],d=s[13],p=s[2],m=s[6],g=s[10],f=s[14],y=s[3],x=s[7],b=s[11],v=s[15],T=i[0],_=i[4],w=i[8],S=i[12],M=i[1],A=i[5],N=i[9],R=i[13],C=i[2],E=i[6],B=i[10],I=i[14],P=i[3],F=i[7],z=i[11],U=i[15];return r[0]=n*T+o*M+a*C+h*P,r[4]=n*_+o*A+a*E+h*F,r[8]=n*w+o*N+a*B+h*z,r[12]=n*S+o*R+a*I+h*U,r[1]=l*T+u*M+c*C+d*P,r[5]=l*_+u*A+c*E+d*F,r[9]=l*w+u*N+c*B+d*z,r[13]=l*S+u*R+c*I+d*U,r[2]=p*T+m*M+g*C+f*P,r[6]=p*_+m*A+g*E+f*F,r[10]=p*w+m*N+g*B+f*z,r[14]=p*S+m*R+g*I+f*U,r[3]=y*T+x*M+b*C+v*P,r[7]=y*_+x*A+b*E+v*F,r[11]=y*w+x*N+b*B+v*z,r[15]=y*S+x*R+b*I+v*U,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],s=e[4],i=e[8],r=e[12],n=e[1],o=e[5],a=e[9],h=e[13],l=e[2],u=e[6],c=e[10],d=e[14];return e[3]*(+r*a*u-i*h*u-r*o*c+s*h*c+i*o*d-s*a*d)+e[7]*(+t*a*d-t*h*c+r*n*c-i*n*d+i*h*l-r*a*l)+e[11]*(+t*h*u-t*o*d-r*n*u+s*n*d+r*o*l-s*h*l)+e[15]*(-i*o*l-t*a*u+t*o*c+i*n*u-s*n*c+s*a*l)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,s){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=s),this}invert(){const e=this.elements,t=e[0],s=e[1],i=e[2],r=e[3],n=e[4],o=e[5],a=e[6],h=e[7],l=e[8],u=e[9],c=e[10],d=e[11],p=e[12],m=e[13],g=e[14],f=e[15],y=u*g*h-m*c*h+m*a*d-o*g*d-u*a*f+o*c*f,x=p*c*h-l*g*h-p*a*d+n*g*d+l*a*f-n*c*f,b=l*m*h-p*u*h+p*o*d-n*m*d-l*o*f+n*u*f,v=p*u*a-l*m*a-p*o*c+n*m*c+l*o*g-n*u*g,T=t*y+s*x+i*b+r*v;if(0===T)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const _=1/T;return e[0]=y*_,e[1]=(m*c*r-u*g*r-m*i*d+s*g*d+u*i*f-s*c*f)*_,e[2]=(o*g*r-m*a*r+m*i*h-s*g*h-o*i*f+s*a*f)*_,e[3]=(u*a*r-o*c*r-u*i*h+s*c*h+o*i*d-s*a*d)*_,e[4]=x*_,e[5]=(l*g*r-p*c*r+p*i*d-t*g*d-l*i*f+t*c*f)*_,e[6]=(p*a*r-n*g*r-p*i*h+t*g*h+n*i*f-t*a*f)*_,e[7]=(n*c*r-l*a*r+l*i*h-t*c*h-n*i*d+t*a*d)*_,e[8]=b*_,e[9]=(p*u*r-l*m*r-p*s*d+t*m*d+l*s*f-t*u*f)*_,e[10]=(n*m*r-p*o*r+p*s*h-t*m*h-n*s*f+t*o*f)*_,e[11]=(l*o*r-n*u*r-l*s*h+t*u*h+n*s*d-t*o*d)*_,e[12]=v*_,e[13]=(l*m*i-p*u*i+p*s*c-t*m*c-l*s*g+t*u*g)*_,e[14]=(p*o*i-n*m*i-p*s*a+t*m*a+n*s*g-t*o*g)*_,e[15]=(n*u*i-l*o*i+l*s*a-t*u*a-n*s*c+t*o*c)*_,this}scale(e){const t=this.elements,s=e.x,i=e.y,r=e.z;return t[0]*=s,t[4]*=i,t[8]*=r,t[1]*=s,t[5]*=i,t[9]*=r,t[2]*=s,t[6]*=i,t[10]*=r,t[3]*=s,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],s=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,s,i))}makeTranslation(e,t,s){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,s,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),s=Math.sin(e);return this.set(1,0,0,0,0,t,-s,0,0,s,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,0,s,0,0,1,0,0,-s,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,0,s,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const s=Math.cos(t),i=Math.sin(t),r=1-s,n=e.x,o=e.y,a=e.z,h=r*n,l=r*o;return this.set(h*n+s,h*o-i*a,h*a+i*o,0,h*o+i*a,l*o+s,l*a-i*n,0,h*a-i*o,l*a+i*n,r*a*a+s,0,0,0,0,1),this}makeScale(e,t,s){return this.set(e,0,0,0,0,t,0,0,0,0,s,0,0,0,0,1),this}makeShear(e,t,s,i,r,n){return this.set(1,s,r,0,e,1,n,0,t,i,1,0,0,0,0,1),this}compose(e,t,s){const i=this.elements,r=t._x,n=t._y,o=t._z,a=t._w,h=r+r,l=n+n,u=o+o,c=r*h,d=r*l,p=r*u,m=n*l,g=n*u,f=o*u,y=a*h,x=a*l,b=a*u,v=s.x,T=s.y,_=s.z;return i[0]=(1-(m+f))*v,i[1]=(d+b)*v,i[2]=(p-x)*v,i[3]=0,i[4]=(d-b)*T,i[5]=(1-(c+f))*T,i[6]=(g+y)*T,i[7]=0,i[8]=(p+x)*_,i[9]=(g-y)*_,i[10]=(1-(c+m))*_,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,s){const i=this.elements;let r=ar.set(i[0],i[1],i[2]).length();const n=ar.set(i[4],i[5],i[6]).length(),o=ar.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],hr.copy(this);const a=1/r,h=1/n,l=1/o;return hr.elements[0]*=a,hr.elements[1]*=a,hr.elements[2]*=a,hr.elements[4]*=h,hr.elements[5]*=h,hr.elements[6]*=h,hr.elements[8]*=l,hr.elements[9]*=l,hr.elements[10]*=l,t.setFromRotationMatrix(hr),s.x=r,s.y=n,s.z=o,this}makePerspective(e,t,s,i,r,n,o=2e3){const a=this.elements,h=2*r/(t-e),l=2*r/(s-i),u=(t+e)/(t-e),c=(s+i)/(s-i);let d,p;if(o===Vs)d=-(n+r)/(n-r),p=-2*n*r/(n-r);else{if(o!==Ds)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);d=-n/(n-r),p=-n*r/(n-r)}return a[0]=h,a[4]=0,a[8]=u,a[12]=0,a[1]=0,a[5]=l,a[9]=c,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=p,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(e,t,s,i,r,n,o=2e3){const a=this.elements,h=1/(t-e),l=1/(s-i),u=1/(n-r),c=(t+e)*h,d=(s+i)*l;let p,m;if(o===Vs)p=(n+r)*u,m=-2*u;else{if(o!==Ds)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);p=r*u,m=-1*u}return a[0]=2*h,a[4]=0,a[8]=0,a[12]=-c,a[1]=0,a[5]=2*l,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=m,a[14]=-p,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(e){const t=this.elements,s=e.elements;for(let e=0;e<16;e++)if(t[e]!==s[e])return!1;return!0}fromArray(e,t=0){for(let s=0;s<16;s++)this.elements[s]=e[s+t];return this}toArray(e=[],t=0){const s=this.elements;return e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2],e[t+3]=s[3],e[t+4]=s[4],e[t+5]=s[5],e[t+6]=s[6],e[t+7]=s[7],e[t+8]=s[8],e[t+9]=s[9],e[t+10]=s[10],e[t+11]=s[11],e[t+12]=s[12],e[t+13]=s[13],e[t+14]=s[14],e[t+15]=s[15],e}}const ar=new Ei,hr=new or,lr=new Ei(0,0,0),ur=new Ei(1,1,1),cr=new Ei,dr=new Ei,pr=new Ei,mr=new or,gr=new Ci;class fr{constructor(e=0,t=0,s=0,i=fr.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=s,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,s,i=this._order){return this._x=e,this._y=t,this._z=s,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,s=!0){const i=e.elements,r=i[0],n=i[4],o=i[8],a=i[1],h=i[5],l=i[9],u=i[2],c=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin($s(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,d),this._z=Math.atan2(-n,r)):(this._x=Math.atan2(c,h),this._z=0);break;case"YXZ":this._x=Math.asin(-$s(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(a,h)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin($s(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(-u,d),this._z=Math.atan2(-n,h)):(this._y=0,this._z=Math.atan2(a,r));break;case"ZYX":this._y=Math.asin(-$s(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(c,d),this._z=Math.atan2(a,r)):(this._x=0,this._z=Math.atan2(-n,h));break;case"YZX":this._z=Math.asin($s(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-l,h),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-$s(n,-1,1)),Math.abs(n)<.9999999?(this._x=Math.atan2(c,h),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-l,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===s&&this._onChangeCallback(),this}setFromQuaternion(e,t,s){return mr.makeRotationFromQuaternion(e),this.setFromRotationMatrix(mr,t,s)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return gr.setFromEuler(this),this.setFromQuaternion(gr,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}fr.DEFAULT_ORDER="XYZ";class yr{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map((e=>({boxInitialized:e.boxInitialized,boxMin:e.box.min.toArray(),boxMax:e.box.max.toArray(),sphereInitialized:e.sphereInitialized,sphereRadius:e.sphere.radius,sphereCenter:e.sphere.center.toArray()}))),i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(e)),null!==this.boundingSphere&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),null!==this.boundingBox&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()})),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const s=t.shapes;if(Array.isArray(s))for(let t=0,i=s.length;t0){i.children=[];for(let t=0;t0){i.animations=[];for(let t=0;t0&&(s.geometries=t),i.length>0&&(s.materials=i),r.length>0&&(s.textures=r),o.length>0&&(s.images=o),a.length>0&&(s.shapes=a),h.length>0&&(s.skeletons=h),l.length>0&&(s.animations=l),u.length>0&&(s.nodes=u)}return s.object=i,s;function n(e){const t=[];for(const s in e){const i=e[s];delete i.metadata,t.push(i)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,s,i,r){Fr.subVectors(i,t),zr.subVectors(s,t),Ur.subVectors(e,t);const n=Fr.dot(Fr),o=Fr.dot(zr),a=Fr.dot(Ur),h=zr.dot(zr),l=zr.dot(Ur),u=n*h-o*o;if(0===u)return r.set(0,0,0),null;const c=1/u,d=(h*a-o*l)*c,p=(n*l-o*a)*c;return r.set(1-d-p,p,d)}static containsPoint(e,t,s,i){return null!==this.getBarycoord(e,t,s,i,Lr)&&(Lr.x>=0&&Lr.y>=0&&Lr.x+Lr.y<=1)}static getInterpolation(e,t,s,i,r,n,o,a){return null===this.getBarycoord(e,t,s,i,Lr)?(a.x=0,a.y=0,"z"in a&&(a.z=0),"w"in a&&(a.w=0),null):(a.setScalar(0),a.addScaledVector(r,Lr.x),a.addScaledVector(n,Lr.y),a.addScaledVector(o,Lr.z),a)}static isFrontFacing(e,t,s,i){return Fr.subVectors(s,t),zr.subVectors(e,t),Fr.cross(zr).dot(i)<0}set(e,t,s){return this.a.copy(e),this.b.copy(t),this.c.copy(s),this}setFromPointsAndIndices(e,t,s,i){return this.a.copy(e[t]),this.b.copy(e[s]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,s,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,s),this.c.fromBufferAttribute(e,i),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Fr.subVectors(this.c,this.b),zr.subVectors(this.a,this.b),.5*Fr.cross(zr).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Hr.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Hr.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,s,i,r){return Hr.getInterpolation(e,this.a,this.b,this.c,t,s,i,r)}containsPoint(e){return Hr.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Hr.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const s=this.a,i=this.b,r=this.c;let n,o;Or.subVectors(i,s),Vr.subVectors(r,s),kr.subVectors(e,s);const a=Or.dot(kr),h=Vr.dot(kr);if(a<=0&&h<=0)return t.copy(s);Gr.subVectors(e,i);const l=Or.dot(Gr),u=Vr.dot(Gr);if(l>=0&&u<=l)return t.copy(i);const c=a*u-l*h;if(c<=0&&a>=0&&l<=0)return n=a/(a-l),t.copy(s).addScaledVector(Or,n);Wr.subVectors(e,r);const d=Or.dot(Wr),p=Vr.dot(Wr);if(p>=0&&d<=p)return t.copy(r);const m=d*h-a*p;if(m<=0&&h>=0&&p<=0)return o=h/(h-p),t.copy(s).addScaledVector(Vr,o);const g=l*p-d*u;if(g<=0&&u-l>=0&&d-p>=0)return Dr.subVectors(r,i),o=(u-l)/(u-l+(d-p)),t.copy(i).addScaledVector(Dr,o);const f=1/(g+m+c);return n=m*f,o=c*f,t.copy(s).addScaledVector(Or,n).addScaledVector(Vr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const jr={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},qr={h:0,s:0,l:0},$r={h:0,s:0,l:0};function Xr(e,t,s){return s<0&&(s+=1),s>1&&(s-=1),s<1/6?e+6*(t-e)*s:s<.5?t:s<2/3?e+6*(t-e)*(2/3-s):e}class Yr{constructor(e,t,s){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,s)}set(e,t,s){if(void 0===t&&void 0===s){const t=e;t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t)}else this.setRGB(e,t,s);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Jt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,di.toWorkingColorSpace(this,t),this}setRGB(e,t,s,i=di.workingColorSpace){return this.r=e,this.g=t,this.b=s,di.toWorkingColorSpace(this,i),this}setHSL(e,t,s,i=di.workingColorSpace){if(e=Xs(e,1),t=$s(t,0,1),s=$s(s,0,1),0===t)this.r=this.g=this.b=s;else{const i=s<=.5?s*(1+t):s+t-s*t,r=2*s-i;this.r=Xr(r,i,e+1/3),this.g=Xr(r,i,e),this.b=Xr(r,i,e-1/3)}return di.toWorkingColorSpace(this,i),this}setStyle(e,t=Jt){function s(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const n=i[1],o=i[2];switch(n){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return s(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return s(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return s(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],r=s.length;if(3===r)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(6===r)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Jt){const s=jr[e.toLowerCase()];return void 0!==s?this.setHex(s,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=pi(e.r),this.g=pi(e.g),this.b=pi(e.b),this}copyLinearToSRGB(e){return this.r=mi(e.r),this.g=mi(e.g),this.b=mi(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Jt){return di.fromWorkingColorSpace(Jr.copy(this),e),65536*Math.round($s(255*Jr.r,0,255))+256*Math.round($s(255*Jr.g,0,255))+Math.round($s(255*Jr.b,0,255))}getHexString(e=Jt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=di.workingColorSpace){di.fromWorkingColorSpace(Jr.copy(this),t);const s=Jr.r,i=Jr.g,r=Jr.b,n=Math.max(s,i,r),o=Math.min(s,i,r);let a,h;const l=(o+n)/2;if(o===n)a=0,h=0;else{const e=n-o;switch(h=l<=.5?e/(n+o):e/(2-n-o),n){case s:a=(i-r)/e+(i0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const t in e){const s=e[t];if(void 0===s){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];void 0!==i?i&&i.isColor?i.set(s):i&&i.isVector3&&s&&s.isVector3?i.copy(s):this[t]=s:console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`)}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const s={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function i(e){const t=[];for(const s in e){const i=e[s];delete i.metadata,t.push(i)}return t}if(s.uuid=this.uuid,s.type=this.type,""!==this.name&&(s.name=this.name),this.color&&this.color.isColor&&(s.color=this.color.getHex()),void 0!==this.roughness&&(s.roughness=this.roughness),void 0!==this.metalness&&(s.metalness=this.metalness),void 0!==this.sheen&&(s.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(s.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(s.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(s.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(s.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(s.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(s.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(s.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(s.shininess=this.shininess),void 0!==this.clearcoat&&(s.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(s.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(s.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(s.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(s.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,s.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.dispersion&&(s.dispersion=this.dispersion),void 0!==this.iridescence&&(s.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(s.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(s.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(s.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(s.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(s.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(s.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(s.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(s.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(s.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(s.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(s.lightMap=this.lightMap.toJSON(e).uuid,s.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(s.aoMap=this.aoMap.toJSON(e).uuid,s.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(s.bumpMap=this.bumpMap.toJSON(e).uuid,s.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(s.normalMap=this.normalMap.toJSON(e).uuid,s.normalMapType=this.normalMapType,s.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(s.displacementMap=this.displacementMap.toJSON(e).uuid,s.displacementScale=this.displacementScale,s.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(s.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(s.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(s.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(s.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(s.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(s.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(s.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(s.combine=this.combine)),void 0!==this.envMapRotation&&(s.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(s.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(s.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(s.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(s.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(s.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(s.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(s.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(s.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(s.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(s.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(s.size=this.size),null!==this.shadowSide&&(s.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(s.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(s.blending=this.blending),this.side!==c&&(s.side=this.side),!0===this.vertexColors&&(s.vertexColors=!0),this.opacity<1&&(s.opacity=this.opacity),!0===this.transparent&&(s.transparent=!0),this.blendSrc!==C&&(s.blendSrc=this.blendSrc),this.blendDst!==E&&(s.blendDst=this.blendDst),this.blendEquation!==v&&(s.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(s.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(s.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(s.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(s.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(s.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(s.depthFunc=this.depthFunc),!1===this.depthTest&&(s.depthTest=this.depthTest),!1===this.depthWrite&&(s.depthWrite=this.depthWrite),!1===this.colorWrite&&(s.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(s.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==bs&&(s.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(s.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(s.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ns&&(s.stencilFail=this.stencilFail),this.stencilZFail!==ns&&(s.stencilZFail=this.stencilZFail),this.stencilZPass!==ns&&(s.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(s.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(s.rotation=this.rotation),!0===this.polygonOffset&&(s.polygonOffset=!0),0!==this.polygonOffsetFactor&&(s.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(s.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(s.linewidth=this.linewidth),void 0!==this.dashSize&&(s.dashSize=this.dashSize),void 0!==this.gapSize&&(s.gapSize=this.gapSize),void 0!==this.scale&&(s.scale=this.scale),!0===this.dithering&&(s.dithering=!0),this.alphaTest>0&&(s.alphaTest=this.alphaTest),!0===this.alphaHash&&(s.alphaHash=!0),!0===this.alphaToCoverage&&(s.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(s.premultipliedAlpha=!0),!0===this.forceSinglePass&&(s.forceSinglePass=!0),!0===this.wireframe&&(s.wireframe=!0),this.wireframeLinewidth>1&&(s.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(s.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(s.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(s.flatShading=!0),!1===this.visible&&(s.visible=!1),!1===this.toneMapped&&(s.toneMapped=!1),!1===this.fog&&(s.fog=!1),Object.keys(this.userData).length>0&&(s.userData=this.userData),t){const t=i(e.textures),r=i(e.images);t.length>0&&(s.textures=t),r.length>0&&(s.images=r)}return s}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let s=null;if(null!==t){const e=t.length;s=new Array(e);for(let i=0;i!==e;++i)s[i]=t[i].clone()}return this.clippingPlanes=s,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class Qr extends Kr{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Yr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new fr,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const en=tn();function tn(){const e=new ArrayBuffer(4),t=new Float32Array(e),s=new Uint32Array(e),i=new Uint32Array(512),r=new Uint32Array(512);for(let e=0;e<256;++e){const t=e-127;t<-27?(i[e]=0,i[256|e]=32768,r[e]=24,r[256|e]=24):t<-14?(i[e]=1024>>-t-14,i[256|e]=1024>>-t-14|32768,r[e]=-t-1,r[256|e]=-t-1):t<=15?(i[e]=t+15<<10,i[256|e]=t+15<<10|32768,r[e]=13,r[256|e]=13):t<128?(i[e]=31744,i[256|e]=64512,r[e]=24,r[256|e]=24):(i[e]=31744,i[256|e]=64512,r[e]=13,r[256|e]=13)}const n=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,s=0;for(;0==(8388608&t);)t<<=1,s-=8388608;t&=-8388609,s+=947912704,n[e]=t|s}for(let e=1024;e<2048;++e)n[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)o[e]=e<<23;o[31]=1199570944,o[32]=2147483648;for(let e=33;e<63;++e)o[e]=2147483648+(e-32<<23);o[63]=3347054592;for(let e=1;e<64;++e)32!==e&&(a[e]=1024);return{floatView:t,uint32View:s,baseTable:i,shiftTable:r,mantissaTable:n,exponentTable:o,offsetTable:a}}function sn(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=$s(e,-65504,65504),en.floatView[0]=e;const t=en.uint32View[0],s=t>>23&511;return en.baseTable[s]+((8388607&t)>>en.shiftTable[s])}function rn(e){const t=e>>10;return en.uint32View[0]=en.mantissaTable[en.offsetTable[t]+(1023&e)]+en.exponentTable[t],en.floatView[0]}const nn={toHalfFloat:sn,fromHalfFloat:rn},on=new Ei,an=new Qs;class hn{constructor(e,t,s=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=s,this.usage=Rs,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Ie,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}get updateRange(){return ai("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,s){e*=this.itemSize,s*=t.itemSize;for(let i=0,r=this.itemSize;i=0;--t)if(e[t]>=65535)return!0;return!1}(e)?gn:pn)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return void 0!==this.attributes[e]}addGroup(e,t,s=0){this.groups.push({start:e,count:t,materialIndex:s})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);const s=this.attributes.normal;if(void 0!==s){const t=(new ei).getNormalMatrix(e);s.applyNormalMatrix(t),s.needsUpdate=!0}const i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(e),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(e){return bn.makeRotationFromQuaternion(e),this.applyMatrix4(bn),this}rotateX(e){return bn.makeRotationX(e),this.applyMatrix4(bn),this}rotateY(e){return bn.makeRotationY(e),this.applyMatrix4(bn),this}rotateZ(e){return bn.makeRotationZ(e),this.applyMatrix4(bn),this}translate(e,t,s){return bn.makeTranslation(e,t,s),this.applyMatrix4(bn),this}scale(e,t,s){return bn.makeScale(e,t,s),this.applyMatrix4(bn),this}lookAt(e){return vn.lookAt(e),vn.updateMatrix(),this.applyMatrix4(vn.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Tn).negate(),this.translate(Tn.x,Tn.y,Tn.z),this}setFromPoints(e){const t=[];for(let s=0,i=e.length;s0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const s in t)void 0!==t[s]&&(e[s]=t[s]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const s=this.attributes;for(const t in s){const i=s[t];e.data.attributes[t]=i.toJSON(e.data)}const i={};let r=!1;for(const t in this.morphAttributes){const s=this.morphAttributes[t],n=[];for(let t=0,i=s.length;t0&&(i[t]=n,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const n=this.groups;n.length>0&&(e.data.groups=JSON.parse(JSON.stringify(n)));const o=this.boundingSphere;return null!==o&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const s=e.index;null!==s&&this.setIndex(s.clone(t));const i=e.attributes;for(const e in i){const s=i[e];this.setAttribute(e,s.clone(t))}const r=e.morphAttributes;for(const e in r){const s=[],i=r[e];for(let e=0,r=i.length;e0){const s=e[t[0]];if(void 0!==s){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=s.length;e(e.far-e.near)**2)return}An.copy(r).invert(),Nn.copy(e.ray).applyMatrix4(An),null!==s.boundingBox&&!1===Nn.intersectsBox(s.boundingBox)||this._computeIntersections(e,t,Nn)}}_computeIntersections(e,t,s){let i;const r=this.geometry,n=this.material,o=r.index,a=r.attributes.position,h=r.attributes.uv,l=r.attributes.uv1,u=r.attributes.normal,c=r.groups,d=r.drawRange;if(null!==o)if(Array.isArray(n))for(let r=0,a=c.length;rs.far?null:{distance:l,point:Gn.clone(),object:e}}(e,t,s,i,En,Bn,In,kn);if(u){r&&(zn.fromBufferAttribute(r,a),Un.fromBufferAttribute(r,h),Ln.fromBufferAttribute(r,l),u.uv=Hr.getInterpolation(kn,En,Bn,In,zn,Un,Ln,new Qs)),n&&(zn.fromBufferAttribute(n,a),Un.fromBufferAttribute(n,h),Ln.fromBufferAttribute(n,l),u.uv1=Hr.getInterpolation(kn,En,Bn,In,zn,Un,Ln,new Qs)),o&&(On.fromBufferAttribute(o,a),Vn.fromBufferAttribute(o,h),Dn.fromBufferAttribute(o,l),u.normal=Hr.getInterpolation(kn,En,Bn,In,On,Vn,Dn,new Ei),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const e={a:a,b:h,c:l,normal:new Ei,materialIndex:0};Hr.getNormal(En,Bn,In,e.normal),u.face=e}return u}class jn extends Mn{constructor(e=1,t=1,s=1,i=1,r=1,n=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:s,widthSegments:i,heightSegments:r,depthSegments:n};const o=this;i=Math.floor(i),r=Math.floor(r),n=Math.floor(n);const a=[],h=[],l=[],u=[];let c=0,d=0;function p(e,t,s,i,r,n,p,m,g,f,y){const x=n/g,b=p/f,v=n/2,T=p/2,_=m/2,w=g+1,S=f+1;let M=0,A=0;const N=new Ei;for(let n=0;n0?1:-1,l.push(N.x,N.y,N.z),u.push(a/g),u.push(1-n/f),M+=1}}for(let e=0;e0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const s={};for(const e in this.extensions)!0===this.extensions[e]&&(s[e]=!0);return Object.keys(s).length>0&&(t.extensions=s),t}}class Xn extends Pr{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new or,this.projectionMatrix=new or,this.projectionMatrixInverse=new or,this.coordinateSystem=Vs}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}const Yn=new Ei,Jn=new Qs,Zn=new Qs;class Kn extends Xn{constructor(e=50,t=1,s=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=s,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=2*js*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*Hs*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*js*Math.atan(Math.tan(.5*Hs*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,s){Yn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Yn.x,Yn.y).multiplyScalar(-e/Yn.z),Yn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),s.set(Yn.x,Yn.y).multiplyScalar(-e/Yn.z)}getViewSize(e,t){return this.getViewBounds(e,Jn,Zn),t.subVectors(Zn,Jn)}setViewOffset(e,t,s,i,r,n){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=s,this.view.offsetY=i,this.view.width=r,this.view.height=n,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*Hs*this.fov)/this.zoom,s=2*t,i=this.aspect*s,r=-.5*i;const n=this.view;if(null!==this.view&&this.view.enabled){const e=n.fullWidth,o=n.fullHeight;r+=n.offsetX*i/e,t-=n.offsetY*s/o,i*=n.width/e,s*=n.height/o}const o=this.filmOffset;0!==o&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-s,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const Qn=-90;class eo extends Pr{constructor(e,t,s){super(),this.type="CubeCamera",this.renderTarget=s,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Kn(Qn,1,e,t);i.layers=this.layers,this.add(i);const r=new Kn(Qn,1,e,t);r.layers=this.layers,this.add(r);const n=new Kn(Qn,1,e,t);n.layers=this.layers,this.add(n);const o=new Kn(Qn,1,e,t);o.layers=this.layers,this.add(o);const a=new Kn(Qn,1,e,t);a.layers=this.layers,this.add(a);const h=new Kn(Qn,1,e,t);h.layers=this.layers,this.add(h)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[s,i,r,n,o,a]=t;for(const e of t)this.remove(e);if(e===Vs)s.up.set(0,1,0),s.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),n.up.set(0,0,1),n.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),a.up.set(0,1,0),a.lookAt(0,0,-1);else{if(e!==Ds)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);s.up.set(0,-1,0),s.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),n.up.set(0,0,-1),n.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),a.up.set(0,-1,0),a.lookAt(0,0,-1)}for(const e of t)this.add(e),e.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();const{renderTarget:s,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,n,o,a,h,l]=this.children,u=e.getRenderTarget(),c=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const m=s.texture.generateMipmaps;s.texture.generateMipmaps=!1,e.setRenderTarget(s,0,i),e.render(t,r),e.setRenderTarget(s,1,i),e.render(t,n),e.setRenderTarget(s,2,i),e.render(t,o),e.setRenderTarget(s,3,i),e.render(t,a),e.setRenderTarget(s,4,i),e.render(t,h),s.texture.generateMipmaps=m,e.setRenderTarget(s,5,i),e.render(t,l),e.setRenderTarget(u,c,d),e.xr.enabled=p,s.texture.needsPMREMUpdate=!0}}class to extends Ti{constructor(e,t,s,i,r,n,o,a,h,l){super(e=void 0!==e?e:[],t=void 0!==t?t:he,s,i,r,n,o,a,h,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class so extends Si{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const s={width:e,height:e,depth:1},i=[s,s,s,s,s,s];this.texture=new to(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:Te}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const s={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},i=new jn(5,5,5),r=new $n({name:"CubemapFromEquirect",uniforms:qn(s.uniforms),vertexShader:s.vertexShader,fragmentShader:s.fragmentShader,side:d,blending:m});r.uniforms.tEquirect.value=t;const n=new Wn(i,r),o=t.minFilter;t.minFilter===Se&&(t.minFilter=Te);return new eo(1,10,this).update(e,n),t.minFilter=o,n.geometry.dispose(),n.material.dispose(),this}clear(e,t,s,i){const r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,s,i);e.setRenderTarget(r)}}class io{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Yr(e),this.density=t}clone(){return new io(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class ro{constructor(e,t=1,s=1e3){this.isFog=!0,this.name="",this.color=new Yr(e),this.near=t,this.far=s}clone(){return new ro(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class no extends Pr{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new fr,this.environmentIntensity=1,this.environmentRotation=new fr,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class oo{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=Rs,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=qs()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}get updateRange(){return ai("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,s){e*=this.stride,s*=t.stride;for(let i=0,r=this.stride;ie.far||t.push({distance:a,point:co.clone(),uv:Hr.getInterpolation(co,xo,bo,vo,To,_o,wo,new Qs),face:null,object:this})}copy(e,t){return super.copy(e,t),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function Mo(e,t,s,i,r,n){go.subVectors(e,s).addScalar(.5).multiply(i),void 0!==r?(fo.x=n*go.x-r*go.y,fo.y=r*go.x+n*go.y):fo.copy(go),e.copy(t),e.x+=fo.x,e.y+=fo.y,e.applyMatrix4(yo)}const Ao=new Ei,No=new Ei;class Ro extends Pr{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let e=0,s=t.length;e0){let s,i;for(s=1,i=t.length;s0){Ao.setFromMatrixPosition(this.matrixWorld);const s=e.ray.origin.distanceTo(Ao);this.getObjectForDistance(s).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Ao.setFromMatrixPosition(e.matrixWorld),No.setFromMatrixPosition(this.matrixWorld);const s=Ao.distanceTo(No)/e.zoom;let i,r;for(t[0].object.visible=!0,i=1,r=t.length;i=e))break;t[i-1].object.visible=!1,t[i].object.visible=!0}for(this._currentLevel=i-1;i1?null:t.copy(e.start).addScaledVector(s,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),s=this.distanceToPoint(e.end);return t<0&&s>0||s<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const s=t||ta.getNormalMatrix(e),i=this.coplanarPoint(Qo).applyMatrix4(e),r=this.normal.applyMatrix3(s).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const ia=new Zi,ra=new Ei;class na{constructor(e=new sa,t=new sa,s=new sa,i=new sa,r=new sa,n=new sa){this.planes=[e,t,s,i,r,n]}set(e,t,s,i,r,n){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(s),o[3].copy(i),o[4].copy(r),o[5].copy(n),this}copy(e){const t=this.planes;for(let s=0;s<6;s++)t[s].copy(e.planes[s]);return this}setFromProjectionMatrix(e,t=2e3){const s=this.planes,i=e.elements,r=i[0],n=i[1],o=i[2],a=i[3],h=i[4],l=i[5],u=i[6],c=i[7],d=i[8],p=i[9],m=i[10],g=i[11],f=i[12],y=i[13],x=i[14],b=i[15];if(s[0].setComponents(a-r,c-h,g-d,b-f).normalize(),s[1].setComponents(a+r,c+h,g+d,b+f).normalize(),s[2].setComponents(a+n,c+l,g+p,b+y).normalize(),s[3].setComponents(a-n,c-l,g-p,b-y).normalize(),s[4].setComponents(a-o,c-u,g-m,b-x).normalize(),t===Vs)s[5].setComponents(a+o,c+u,g+m,b+x).normalize();else{if(t!==Ds)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);s[5].setComponents(o,u,m,x).normalize()}return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),ia.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),ia.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(ia)}intersectsSprite(e){return ia.center.set(0,0,0),ia.radius=.7071067811865476,ia.applyMatrix4(e.matrixWorld),this.intersectsSphere(ia)}intersectsSphere(e){const t=this.planes,s=e.center,i=-e.radius;for(let e=0;e<6;e++){if(t[e].distanceToPoint(s)0?e.max.x:e.min.x,ra.y=i.normal.y>0?e.max.y:e.min.y,ra.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(ra)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let s=0;s<6;s++)if(t[s].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function oa(e,t){return e.z-t.z}function aa(e,t){return t.z-e.z}class ha{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,s){const i=this.pool,r=this.list;this.index>=i.length&&i.push({start:-1,count:-1,z:-1,index:-1});const n=i[this.index];r.push(n),this.index++,n.start=e.start,n.count=e.count,n.z=t,n.index=s}reset(){this.list.length=0,this.index=0}}const la=new or,ua=new or,ca=new or,da=new Yr(1,1,1),pa=new or,ma=new na,ga=new Pi,fa=new Zi,ya=new Ei,xa=new Ei,ba=new Ei,va=new ha,Ta=new Wn,_a=[];function wa(e,t,s=0){const i=t.itemSize;if(e.isInterleavedBufferAttribute||e.array.constructor!==t.array.constructor){const r=e.count;for(let n=0;n65535?new Uint32Array(i):new Uint16Array(i);t.setIndex(new hn(e,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(Boolean(e.getIndex())!==Boolean(t.getIndex()))throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const s in t.attributes){if(!e.hasAttribute(s))throw new Error(`BatchedMesh: Added geometry missing "${s}". All geometries must have consistent attributes.`);const i=e.getAttribute(s),r=t.getAttribute(s);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Pi);const e=this.boundingBox,t=this._drawInfo;e.makeEmpty();for(let s=0,i=t.length;s=this._maxInstanceCount)throw new Error("BatchedMesh: Maximum item count reached.");this._drawInfo.push({visible:!0,active:!0,geometryIndex:e});const t=this._drawInfo.length-1,s=this._matricesTexture,i=s.image.data;ca.toArray(i,16*t),s.needsUpdate=!0;const r=this._colorsTexture;return r&&(da.toArray(r.image.data,4*t),r.needsUpdate=!0),t}addGeometry(e,t=-1,s=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._drawInfo.length>=this._maxInstanceCount)throw new Error("BatchedMesh: Maximum item count reached.");const i={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let r=null;const n=this._reservedRanges,o=this._drawRanges,a=this._bounds;0!==this._geometryCount&&(r=n[n.length-1]),i.vertexCount=-1===t?e.getAttribute("position").count:t,i.vertexStart=null===r?0:r.vertexStart+r.vertexCount;const h=e.getIndex(),l=null!==h;if(l&&(i.indexCount=-1===s?h.count:s,i.indexStart=null===r?0:r.indexStart+r.indexCount),-1!==i.indexStart&&i.indexStart+i.indexCount>this._maxIndexCount||i.vertexStart+i.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const u=this._geometryCount;return this._geometryCount++,n.push(i),o.push({start:l?i.indexStart:i.vertexStart,count:-1}),a.push({boxInitialized:!1,box:new Pi,sphereInitialized:!1,sphere:new Zi}),this.setGeometryAt(u,e),u}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const s=this.geometry,i=null!==s.getIndex(),r=s.getIndex(),n=t.getIndex(),o=this._reservedRanges[e];if(i&&n.count>o.indexCount||t.attributes.position.count>o.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const a=o.vertexStart,h=o.vertexCount;for(const e in s.attributes){const i=t.getAttribute(e),r=s.getAttribute(e);wa(i,r,a);const n=i.itemSize;for(let e=i.count,t=h;e=this._geometryCount)return null;const s=this._bounds[e],i=s.box,r=this.geometry;if(!1===s.boxInitialized){i.makeEmpty();const t=r.index,n=r.attributes.position,o=this._drawRanges[e];for(let e=o.start,s=o.start+o.count;e=this._geometryCount)return null;const s=this._bounds[e],i=s.sphere,r=this.geometry;if(!1===s.sphereInitialized){i.makeEmpty(),this.getBoundingBoxAt(e,ga),ga.getCenter(i.center);const t=r.index,n=r.attributes.position,o=this._drawRanges[e];let a=0;for(let e=o.start,s=o.start+o.count;e=s.length||!1===s[e].active||(t.toArray(r,16*e),i.needsUpdate=!0),this}getMatrixAt(e,t){const s=this._drawInfo,i=this._matricesTexture.image.data;return e>=s.length||!1===s[e].active?null:t.fromArray(i,16*e)}setColorAt(e,t){null===this._colorsTexture&&this._initColorsTexture();const s=this._colorsTexture,i=this._colorsTexture.image.data,r=this._drawInfo;return e>=r.length||!1===r[e].active||(t.toArray(i,4*e),s.needsUpdate=!0),this}getColorAt(e,t){const s=this._colorsTexture.image.data,i=this._drawInfo;return e>=i.length||!1===i[e].active?null:t.fromArray(s,4*e)}setVisibleAt(e,t){const s=this._drawInfo;return e>=s.length||!1===s[e].active||s[e].visible===t||(s[e].visible=t,this._visibilityChanged=!0),this}getVisibleAt(e){const t=this._drawInfo;return!(e>=t.length||!1===t[e].active)&&t[e].visible}raycast(e,t){const s=this._drawInfo,i=this._drawRanges,r=this.matrixWorld,n=this.geometry;Ta.material=this.material,Ta.geometry.index=n.index,Ta.geometry.attributes=n.attributes,null===Ta.geometry.boundingBox&&(Ta.geometry.boundingBox=new Pi),null===Ta.geometry.boundingSphere&&(Ta.geometry.boundingSphere=new Zi);for(let n=0,o=s.length;n({...e}))),this._reservedRanges=e._reservedRanges.map((e=>({...e}))),this._drawInfo=e._drawInfo.map((e=>({...e}))),this._bounds=e._bounds.map((e=>({boxInitialized:e.boxInitialized,box:e.box.clone(),sphereInitialized:e.sphereInitialized,sphere:e.sphere.clone()}))),this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),null!==this._colorsTexture&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,null!==this._colorsTexture&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(e,t,s,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const n=i.getIndex(),o=null===n?1:n.array.BYTES_PER_ELEMENT,a=this._drawInfo,h=this._multiDrawStarts,l=this._multiDrawCounts,u=this._drawRanges,c=this.perObjectFrustumCulled,d=this._indirectTexture,p=d.image.data;c&&(pa.multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse).multiply(this.matrixWorld),ma.setFromProjectionMatrix(pa,e.coordinateSystem));let m=0;if(this.sortObjects){ua.copy(this.matrixWorld).invert(),ya.setFromMatrixPosition(s.matrixWorld).applyMatrix4(ua),xa.set(0,0,-1).transformDirection(s.matrixWorld).transformDirection(ua);for(let e=0,t=a.length;e0){const s=e[t[0]];if(void 0!==s){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=s.length;ei)return;Ba.applyMatrix4(e.matrixWorld);const a=t.ray.origin.distanceTo(Ba);return at.far?void 0:{distance:a,point:Ia.clone().applyMatrix4(e.matrixWorld),index:r,face:null,faceIndex:null,object:e}}const za=new Ei,Ua=new Ei;class La extends Pa{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,s=[];for(let e=0,i=t.count;e0){const s=e[t[0]];if(void 0!==s){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=s.length;er.far)return;n.push({distance:h,distanceToRay:Math.sqrt(a),point:s,index:t,face:null,object:o})}}class qa extends Pr{constructor(){super(),this.isGroup=!0,this.type="Group"}}class $a extends Ti{constructor(e,t,s,i,r,n,o,a,h){super(e,t,s,i,r,n,o,a,h),this.isVideoTexture=!0,this.minFilter=void 0!==n?n:Te,this.magFilter=void 0!==r?r:Te,this.generateMipmaps=!1;const l=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function t(){l.needsUpdate=!0,e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;!1==="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class Xa extends Ti{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=fe,this.minFilter=fe,this.generateMipmaps=!1,this.needsUpdate=!0}}class Ya extends Ti{constructor(e,t,s,i,r,n,o,a,h,l,u,c){super(null,n,o,a,h,l,i,r,u,c),this.isCompressedTexture=!0,this.image={width:t,height:s},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class Ja extends Ya{constructor(e,t,s,i,r,n){super(e,t,s,r,n),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=me,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Za extends Ya{constructor(e,t,s){super(void 0,e[0].width,e[0].height,t,s,he),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class Ka extends Ti{constructor(e,t,s,i,r,n,o,a,h){super(e,t,s,i,r,n,o,a,h),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Qa extends Ti{constructor(e,t,s,i,r,n,o,a,h,l=1026){if(l!==We&&l!==He)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===s&&l===We&&(s=Be),void 0===s&&l===He&&(s=Ue),super(null,i,r,n,o,a,l,s,h),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=void 0!==o?o:fe,this.minFilter=void 0!==a?a:fe,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return null!==this.compareFunction&&(t.compareFunction=this.compareFunction),t}}class eh{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const s=this.getUtoTmapping(e);return this.getPoint(s,t)}getPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPoint(s/e));return t}getSpacedPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPointAt(s/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let s,i=this.getPoint(0),r=0;t.push(0);for(let n=1;n<=e;n++)s=this.getPoint(n/e),r+=s.distanceTo(i),t.push(r),i=s;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const s=this.getLengths();let i=0;const r=s.length;let n;n=t||e*s[r-1];let o,a=0,h=r-1;for(;a<=h;)if(i=Math.floor(a+(h-a)/2),o=s[i]-n,o<0)a=i+1;else{if(!(o>0)){h=i;break}h=i-1}if(i=h,s[i]===n)return i/(r-1);const l=s[i];return(i+(n-l)/(s[i+1]-l))/(r-1)}getTangent(e,t){const s=1e-4;let i=e-s,r=e+s;i<0&&(i=0),r>1&&(r=1);const n=this.getPoint(i),o=this.getPoint(r),a=t||(n.isVector2?new Qs:new Ei);return a.copy(o).sub(n).normalize(),a}getTangentAt(e,t){const s=this.getUtoTmapping(e);return this.getTangent(s,t)}computeFrenetFrames(e,t){const s=new Ei,i=[],r=[],n=[],o=new Ei,a=new or;for(let t=0;t<=e;t++){const s=t/e;i[t]=this.getTangentAt(s,new Ei)}r[0]=new Ei,n[0]=new Ei;let h=Number.MAX_VALUE;const l=Math.abs(i[0].x),u=Math.abs(i[0].y),c=Math.abs(i[0].z);l<=h&&(h=l,s.set(1,0,0)),u<=h&&(h=u,s.set(0,1,0)),c<=h&&s.set(0,0,1),o.crossVectors(i[0],s).normalize(),r[0].crossVectors(i[0],o),n[0].crossVectors(i[0],r[0]);for(let t=1;t<=e;t++){if(r[t]=r[t-1].clone(),n[t]=n[t-1].clone(),o.crossVectors(i[t-1],i[t]),o.length()>Number.EPSILON){o.normalize();const e=Math.acos($s(i[t-1].dot(i[t]),-1,1));r[t].applyMatrix4(a.makeRotationAxis(o,e))}n[t].crossVectors(i[t],r[t])}if(!0===t){let t=Math.acos($s(r[0].dot(r[e]),-1,1));t/=e,i[0].dot(o.crossVectors(r[0],r[e]))>0&&(t=-t);for(let s=1;s<=e;s++)r[s].applyMatrix4(a.makeRotationAxis(i[s],t*s)),n[s].crossVectors(i[s],r[s])}return{tangents:i,normals:r,binormals:n}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class th extends eh{constructor(e=0,t=0,s=1,i=1,r=0,n=2*Math.PI,o=!1,a=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=s,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=n,this.aClockwise=o,this.aRotation=a}getPoint(e,t=new Qs){const s=t,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const n=Math.abs(r)i;)r-=i;r0?0:(Math.floor(Math.abs(h)/r)+1)*r:0===l&&h===r-1&&(h=r-2,l=1),this.closed||h>0?o=i[(h-1)%r]:(rh.subVectors(i[0],i[1]).add(i[0]),o=rh);const u=i[h%r],c=i[(h+1)%r];if(this.closed||h+2i.length-2?i.length-1:n+1],u=i[n>i.length-3?i.length-1:n+2];return s.set(lh(o,a.x,h.x,l.x,u.x),lh(o,a.y,h.y,l.y,u.y)),s}copy(e){super.copy(e),this.points=[];for(let t=0,s=e.points.length;t=s){const e=i[r]-s,n=this.curves[r],o=n.getLength(),a=0===o?0:1-e/o;return n.getPointAt(a,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let s=0,i=this.curves.length;s1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,s=e.curves.length;t0){const e=h.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(h);const l=h.getPoint(1);return this.currentPoint.copy(l),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class _h extends Mn{constructor(e=[new Qs(0,-.5),new Qs(.5,0),new Qs(0,.5)],t=12,s=0,i=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:s,phiLength:i},t=Math.floor(t),i=$s(i,0,2*Math.PI);const r=[],n=[],o=[],a=[],h=[],l=1/t,u=new Ei,c=new Qs,d=new Ei,p=new Ei,m=new Ei;let g=0,f=0;for(let t=0;t<=e.length-1;t++)switch(t){case 0:g=e[t+1].x-e[t].x,f=e[t+1].y-e[t].y,d.x=1*f,d.y=-g,d.z=0*f,m.copy(d),d.normalize(),a.push(d.x,d.y,d.z);break;case e.length-1:a.push(m.x,m.y,m.z);break;default:g=e[t+1].x-e[t].x,f=e[t+1].y-e[t].y,d.x=1*f,d.y=-g,d.z=0*f,p.copy(d),d.x+=m.x,d.y+=m.y,d.z+=m.z,d.normalize(),a.push(d.x,d.y,d.z),m.copy(p)}for(let r=0;r<=t;r++){const d=s+r*l*i,p=Math.sin(d),m=Math.cos(d);for(let s=0;s<=e.length-1;s++){u.x=e[s].x*p,u.y=e[s].y,u.z=e[s].x*m,n.push(u.x,u.y,u.z),c.x=r/t,c.y=s/(e.length-1),o.push(c.x,c.y);const i=a[3*s+0]*p,l=a[3*s+1],d=a[3*s+0]*m;h.push(i,l,d)}}for(let s=0;s0&&y(!0),t>0&&y(!1)),this.setIndex(l),this.setAttribute("position",new yn(u,3)),this.setAttribute("normal",new yn(c,3)),this.setAttribute("uv",new yn(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Mh(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Ah extends Mh{constructor(e=1,t=1,s=32,i=1,r=!1,n=0,o=2*Math.PI){super(0,e,t,s,i,r,n,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:s,heightSegments:i,openEnded:r,thetaStart:n,thetaLength:o}}static fromJSON(e){return new Ah(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Nh extends Mn{constructor(e=[],t=[],s=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:s,detail:i};const r=[],n=[];function o(e,t,s,i){const r=i+1,n=[];for(let i=0;i<=r;i++){n[i]=[];const o=e.clone().lerp(s,i/r),a=t.clone().lerp(s,i/r),h=r-i;for(let e=0;e<=h;e++)n[i][e]=0===e&&i===r?o:o.clone().lerp(a,e/h)}for(let e=0;e.9&&o<.1&&(t<.2&&(n[e+0]+=1),s<.2&&(n[e+2]+=1),i<.2&&(n[e+4]+=1))}}()}(),this.setAttribute("position",new yn(r,3)),this.setAttribute("normal",new yn(r.slice(),3)),this.setAttribute("uv",new yn(n,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Nh(e.vertices,e.indices,e.radius,e.details)}}class Rh extends Nh{constructor(e=1,t=0){const s=(1+Math.sqrt(5))/2,i=1/s;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-s,0,-i,s,0,i,-s,0,i,s,-i,-s,0,-i,s,0,i,-s,0,i,s,0,-s,0,-i,s,0,-i,-s,0,i,s,0,i],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Rh(e.radius,e.detail)}}const Ch=new Ei,Eh=new Ei,Bh=new Ei,Ih=new Hr;class Ph extends Mn{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},null!==e){const s=4,i=Math.pow(10,s),r=Math.cos(Hs*t),n=e.getIndex(),o=e.getAttribute("position"),a=n?n.count:o.count,h=[0,0,0],l=["a","b","c"],u=new Array(3),c={},d=[];for(let e=0;e80*s){a=l=e[0],h=u=e[1];for(let t=s;tl&&(l=c),d>u&&(u=d);p=Math.max(l-a,u-h),p=0!==p?32767/p:0}return Oh(n,o,s,a,h,p,0),o};function Uh(e,t,s,i,r){let n,o;if(r===function(e,t,s,i){let r=0;for(let n=t,o=s-i;n0)for(n=t;n=t;n-=i)o=il(n,e[n],e[n+1],o);return o&&Zh(o,o.next)&&(rl(o),o=o.next),o}function Lh(e,t){if(!e)return e;t||(t=e);let s,i=e;do{if(s=!1,i.steiner||!Zh(i,i.next)&&0!==Jh(i.prev,i,i.next))i=i.next;else{if(rl(i),i=t=i.prev,i===i.next)break;s=!0}}while(s||i!==t);return t}function Oh(e,t,s,i,r,n,o){if(!e)return;!o&&n&&function(e,t,s,i){let r=e;do{0===r.z&&(r.z=qh(r.x,r.y,t,s,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,s,i,r,n,o,a,h,l=1;do{for(s=e,e=null,n=null,o=0;s;){for(o++,i=s,a=0,t=0;t0||h>0&&i;)0!==a&&(0===h||!i||s.z<=i.z)?(r=s,s=s.nextZ,a--):(r=i,i=i.nextZ,h--),n?n.nextZ=r:e=r,r.prevZ=n,n=r;s=i}n.nextZ=null,l*=2}while(o>1)}(r)}(e,i,r,n);let a,h,l=e;for(;e.prev!==e.next;)if(a=e.prev,h=e.next,n?Dh(e,i,r,n):Vh(e))t.push(a.i/s|0),t.push(e.i/s|0),t.push(h.i/s|0),rl(e),e=h.next,l=h.next;else if((e=h)===l){o?1===o?Oh(e=kh(Lh(e),t,s),t,s,i,r,n,2):2===o&&Gh(e,t,s,i,r,n):Oh(Lh(e),t,s,i,r,n,1);break}}function Vh(e){const t=e.prev,s=e,i=e.next;if(Jh(t,s,i)>=0)return!1;const r=t.x,n=s.x,o=i.x,a=t.y,h=s.y,l=i.y,u=rn?r>o?r:o:n>o?n:o,p=a>h?a>l?a:l:h>l?h:l;let m=i.next;for(;m!==t;){if(m.x>=u&&m.x<=d&&m.y>=c&&m.y<=p&&Xh(r,a,n,h,o,l,m.x,m.y)&&Jh(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Dh(e,t,s,i){const r=e.prev,n=e,o=e.next;if(Jh(r,n,o)>=0)return!1;const a=r.x,h=n.x,l=o.x,u=r.y,c=n.y,d=o.y,p=ah?a>l?a:l:h>l?h:l,f=u>c?u>d?u:d:c>d?c:d,y=qh(p,m,t,s,i),x=qh(g,f,t,s,i);let b=e.prevZ,v=e.nextZ;for(;b&&b.z>=y&&v&&v.z<=x;){if(b.x>=p&&b.x<=g&&b.y>=m&&b.y<=f&&b!==r&&b!==o&&Xh(a,u,h,c,l,d,b.x,b.y)&&Jh(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,v.x>=p&&v.x<=g&&v.y>=m&&v.y<=f&&v!==r&&v!==o&&Xh(a,u,h,c,l,d,v.x,v.y)&&Jh(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;b&&b.z>=y;){if(b.x>=p&&b.x<=g&&b.y>=m&&b.y<=f&&b!==r&&b!==o&&Xh(a,u,h,c,l,d,b.x,b.y)&&Jh(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;v&&v.z<=x;){if(v.x>=p&&v.x<=g&&v.y>=m&&v.y<=f&&v!==r&&v!==o&&Xh(a,u,h,c,l,d,v.x,v.y)&&Jh(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function kh(e,t,s){let i=e;do{const r=i.prev,n=i.next.next;!Zh(r,n)&&Kh(r,i,i.next,n)&&tl(r,n)&&tl(n,r)&&(t.push(r.i/s|0),t.push(i.i/s|0),t.push(n.i/s|0),rl(i),rl(i.next),i=e=n),i=i.next}while(i!==e);return Lh(i)}function Gh(e,t,s,i,r,n){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&Yh(o,e)){let a=sl(o,e);return o=Lh(o,o.next),a=Lh(a,a.next),Oh(o,t,s,i,r,n,0),void Oh(a,t,s,i,r,n,0)}e=e.next}o=o.next}while(o!==e)}function Wh(e,t){return e.x-t.x}function Hh(e,t){const s=function(e,t){let s,i=t,r=-1/0;const n=e.x,o=e.y;do{if(o<=i.y&&o>=i.next.y&&i.next.y!==i.y){const e=i.x+(o-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=n&&e>r&&(r=e,s=i.x=i.x&&i.x>=h&&n!==i.x&&Xh(os.x||i.x===s.x&&jh(s,i)))&&(s=i,c=u)),i=i.next}while(i!==a);return s}(e,t);if(!s)return t;const i=sl(s,e);return Lh(i,i.next),Lh(s,s.next)}function jh(e,t){return Jh(e.prev,e,t.prev)<0&&Jh(t.next,e,e.next)<0}function qh(e,t,s,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-s)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function $h(e){let t=e,s=e;do{(t.x=(e-o)*(n-a)&&(e-o)*(i-a)>=(s-o)*(t-a)&&(s-o)*(n-a)>=(r-o)*(i-a)}function Yh(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let s=e;do{if(s.i!==e.i&&s.next.i!==e.i&&s.i!==t.i&&s.next.i!==t.i&&Kh(s,s.next,e,t))return!0;s=s.next}while(s!==e);return!1}(e,t)&&(tl(e,t)&&tl(t,e)&&function(e,t){let s=e,i=!1;const r=(e.x+t.x)/2,n=(e.y+t.y)/2;do{s.y>n!=s.next.y>n&&s.next.y!==s.y&&r<(s.next.x-s.x)*(n-s.y)/(s.next.y-s.y)+s.x&&(i=!i),s=s.next}while(s!==e);return i}(e,t)&&(Jh(e.prev,e,t.prev)||Jh(e,t.prev,t))||Zh(e,t)&&Jh(e.prev,e,e.next)>0&&Jh(t.prev,t,t.next)>0)}function Jh(e,t,s){return(t.y-e.y)*(s.x-t.x)-(t.x-e.x)*(s.y-t.y)}function Zh(e,t){return e.x===t.x&&e.y===t.y}function Kh(e,t,s,i){const r=el(Jh(e,t,s)),n=el(Jh(e,t,i)),o=el(Jh(s,i,e)),a=el(Jh(s,i,t));return r!==n&&o!==a||(!(0!==r||!Qh(e,s,t))||(!(0!==n||!Qh(e,i,t))||(!(0!==o||!Qh(s,e,i))||!(0!==a||!Qh(s,t,i)))))}function Qh(e,t,s){return t.x<=Math.max(e.x,s.x)&&t.x>=Math.min(e.x,s.x)&&t.y<=Math.max(e.y,s.y)&&t.y>=Math.min(e.y,s.y)}function el(e){return e>0?1:e<0?-1:0}function tl(e,t){return Jh(e.prev,e,e.next)<0?Jh(e,t,e.next)>=0&&Jh(e,e.prev,t)>=0:Jh(e,t,e.prev)<0||Jh(e,e.next,t)<0}function sl(e,t){const s=new nl(e.i,e.x,e.y),i=new nl(t.i,t.x,t.y),r=e.next,n=t.prev;return e.next=t,t.prev=e,s.next=r,r.prev=s,i.next=s,s.prev=i,n.next=i,i.prev=n,i}function il(e,t,s,i){const r=new nl(e,t,s);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function rl(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function nl(e,t,s){this.i=e,this.x=t,this.y=s,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}class ol{static area(e){const t=e.length;let s=0;for(let i=t-1,r=0;r2&&e[t-1].equals(e[0])&&e.pop()}function hl(e,t){for(let s=0;sNumber.EPSILON){const c=Math.sqrt(u),d=Math.sqrt(h*h+l*l),p=t.x-a/c,m=t.y+o/c,g=((s.x-l/d-p)*l-(s.y+h/d-m)*h)/(o*l-a*h);i=p+o*g-e.x,r=m+a*g-e.y;const f=i*i+r*r;if(f<=2)return new Qs(i,r);n=Math.sqrt(f/2)}else{let e=!1;o>Number.EPSILON?h>Number.EPSILON&&(e=!0):o<-Number.EPSILON?h<-Number.EPSILON&&(e=!0):Math.sign(a)===Math.sign(l)&&(e=!0),e?(i=-a,r=o,n=Math.sqrt(u)):(i=o,r=a,n=Math.sqrt(u/2))}return new Qs(i/n,r/n)}const B=[];for(let e=0,t=A.length,s=t-1,i=e+1;e=0;e--){const t=e/p,s=u*Math.cos(t*Math.PI/2),i=c*Math.sin(t*Math.PI/2)+d;for(let e=0,t=A.length;e=0;){const i=s;let r=s-1;r<0&&(r=e.length-1);for(let e=0,s=a+2*p;e0)&&d.push(t,r,h),(e!==s-1||a0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Rl extends Kr{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Yr(16777215),this.specular=new Yr(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Yr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Qs(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new fr,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Cl extends Kr{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Yr(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Yr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Qs(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class El extends Kr{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Qs(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class Bl extends Kr{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Yr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Yr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Qs(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new fr,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Il extends Kr{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Pl extends Kr{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Fl extends Kr{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Yr(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Qs(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class zl extends Ma{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function Ul(e,t=!1){let s="{";!0===e.isNode&&(s+=e.id);for(const{property:i,childNode:r}of Ll(e))s+=","+i.slice(0,-4)+":"+r.getCacheKey(t);return s+="}",s}function*Ll(e,t=!1){for(const s in e){if(!0===s.startsWith("_"))continue;const i=e[s];if(!0===Array.isArray(i))for(let e=0;ee.charCodeAt(0))).buffer}var Gl=Object.freeze({__proto__:null,arrayBufferToBase64:Dl,base64ToArrayBuffer:kl,getCacheKey:Ul,getNodeChildren:Ll,getValueFromType:Vl,getValueType:Ol});const Wl={VERTEX:"vertex",FRAGMENT:"fragment"},Hl={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},jl={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},ql=["fragment","vertex"],$l=["setup","analyze","generate"],Xl=[...ql,"compute"],Yl=["x","y","z","w"],Jl=new Map;let Zl=0;class Kl extends ks{constructor(e=null){super(),this.nodeType=e,this.updateType=Hl.NONE,this.updateBeforeType=Hl.NONE,this.updateAfterType=Hl.NONE,this.uuid=Ks.generateUUID(),this.version=0,this._cacheKey=null,this._cacheKeyVersion=0,this.global=!1,this.isNode=!0,Object.defineProperty(this,"id",{value:Zl++})}set needsUpdate(e){!0===e&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,Hl.FRAME)}onRenderUpdate(e){return this.onUpdate(e,Hl.RENDER)}onObjectUpdate(e){return this.onUpdate(e,Hl.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of Ll(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return!0!==(e=e||this.version!==this._cacheKeyVersion)&&null!==this._cacheKey||(this._cacheKey=Ul(this,e),this._cacheKeyVersion=this.version),this._cacheKey}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let s=0;for(const e of this.getChildren())t["node"+s++]=e;return null}analyze(e){if(1===e.increaseUsage(this)){const t=e.getNodeProperties(this);for(const s of Object.values(t))s&&!0===s.isNode&&s.build(e)}}generate(e,t){const{outputNode:s}=e.getNodeProperties(this);if(s&&!0===s.isNode)return s.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const s=this.getShared(e);if(this!==s)return s.build(e,t);e.addNode(this),e.addChain(this);let i=null;const r=e.getBuildStage();if("setup"===r){this.updateReference(e);const t=e.getNodeProperties(this);if(!0!==t.initialized){e.stack.nodes.length;t.initialized=!0,t.outputNode=this.setup(e),null!==t.outputNode&&e.stack.nodes.length;for(const s of Object.values(t))s&&!0===s.isNode&&s.build(e)}}else if("analyze"===r)this.analyze(e);else if("generate"===r){if(1===this.generate.length){const s=this.getNodeType(e),r=e.getDataFromNode(this);i=r.snippet,void 0===i&&(i=this.generate(e)||"",r.snippet=i),i=e.format(i,s,t)}else i=this.generate(e,t)||""}return e.removeChain(this),i}getSerializeChildren(){return Ll(this)}serialize(e){const t=this.getSerializeChildren(),s={};for(const{property:i,index:r,childNode:n}of t)void 0!==r?(void 0===s[i]&&(s[i]=Number.isInteger(r)?[]:{}),s[i][r]=n.toJSON(e.meta).uuid):s[i]=n.toJSON(e.meta).uuid;Object.keys(s).length>0&&(e.inputNodes=s)}deserialize(e){if(void 0!==e.inputNodes){const t=e.meta.nodes;for(const s in e.inputNodes)if(Array.isArray(e.inputNodes[s])){const i=[];for(const r of e.inputNodes[s])i.push(t[r]);this[s]=i}else if("object"==typeof e.inputNodes[s]){const i={};for(const r in e.inputNodes[s]){const n=e.inputNodes[s][r];i[r]=t[n]}this[s]=i}else{const i=e.inputNodes[s];this[s]=t[i]}}}toJSON(e){const{uuid:t,type:s}=this,i=void 0===e||"string"==typeof e;i&&(e={textures:{},images:{},nodes:{}});let r=e.nodes[t];function n(e){const t=[];for(const s in e){const i=e[s];delete i.metadata,t.push(i)}return t}if(void 0===r&&(r={uuid:t,type:s,meta:e,metadata:{version:4.6,type:"Node",generator:"Node.toJSON"}},!0!==i&&(e.nodes[r.uuid]=r),this.serialize(r),delete r.meta),i){const t=n(e.textures),s=n(e.images),i=n(e.nodes);t.length>0&&(r.textures=t),s.length>0&&(r.images=s),i.length>0&&(r.nodes=i)}return r}}function Ql(e,t){const s=e+"Node";if("function"!=typeof t||!e)throw new Error(`TSL.Node: Node class ${e} is not a class`);Jl.has(s)?console.warn(`TSL.Node: Redefinition of node class ${s}`):"Node"!==e.slice(-4)?(Jl.set(s,t),t.type=s):console.warn(`TSL.Node: Node class ${s} should not have 'Node' suffix.`)}function eu(e){const t=Jl.get(e);if(void 0!==t)return new t}class tu extends Kl{constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){return`${this.node.build(e)}[ ${this.indexNode.build(e,"uint")} ]`}}Ql("ArrayElement",tu);class su extends Kl{constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let s=null;for(const i of this.convertTo.split("|"))null!==s&&e.getTypeLength(t)!==e.getTypeLength(i)||(s=i);return s}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const s=this.node,i=this.getNodeType(e),r=s.build(e,i);return e.format(r,i,t)}}Ql("Convert",su);class iu extends Kl{constructor(e){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if("generate"===e.getBuildStage()){const s=e.getVectorType(this.getNodeType(e,t)),i=e.getDataFromNode(this);if(void 0!==i.propertyName)return e.format(i.propertyName,s,t);if("void"!==s&&"void"!==t&&this.hasDependencies(e)){const r=super.build(e,s),n=e.getVarFromNode(this,null,s),o=e.getPropertyName(n);return e.addLineFlowCode(`${o} = ${r}`),i.snippet=r,i.propertyName=o,e.format(i.propertyName,s,t)}}return super.build(e,t)}}Ql("Temp",iu);class ru extends iu{constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return null!==this.nodeType?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce(((t,s)=>t+e.getTypeLength(s.getNodeType(e))),0))}generate(e,t){const s=this.getNodeType(e),i=this.nodes,r=e.getComponentType(s),n=[];for(const t of i){let s=t.build(e);const i=e.getComponentType(t.getNodeType(e));i!==r&&(s=e.format(s,i,r)),n.push(s)}const o=`${e.getType(s)}( ${n.join(", ")} )`;return e.format(o,s,t)}}Ql("Join",ru);const nu=Yl.join("");class ou extends Kl{constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(Yl.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const s=this.node,i=e.getTypeLength(s.getNodeType(e));let r=null;if(i>1){let n=null;this.getVectorLength()>=i&&(n=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const o=s.build(e,n);r=this.components.length===i&&this.components===nu.slice(0,this.components.length)?e.format(o,n,t):e.format(`${o}.${this.components}`,this.getNodeType(e),t)}else r=s.build(e,t);return r}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}Ql("Split",ou);class au extends iu{constructor(e,t,s){super(),this.sourceNode=e,this.components=t,this.targetNode=s}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:s,targetNode:i}=this,r=this.getNodeType(e),n=e.getTypeFromLength(s.length),o=i.build(e,n),a=t.build(e,r),h=e.getTypeLength(r),l=[];for(let e=0;ee.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),gu=e=>mu(e).split("").sort().join(""),fu={setup(e,t){const s=t.shift();return e(ku(s),...t)},get(e,t,s){if("string"==typeof t&&void 0===e[t]){if(!0!==e.isStackNode&&"assign"===t)return(...e)=>(cu.assign(s,...e),s);if(du.has(t)){const i=du.get(t);return e.isStackNode?(...e)=>s.add(i(...e)):(...e)=>i(s,...e)}if("self"===t)return e;if(t.endsWith("Assign")&&du.has(t.slice(0,t.length-6))){const i=du.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>s.assign(e[0],i(...e)):(...e)=>s.assign(i(s,...e))}if(!0===/^[xyzwrgbastpq]{1,4}$/.test(t))return t=mu(t),Du(new ou(s,t));if(!0===/^set[XYZWRGBASTPQ]{1,4}$/.test(t))return t=gu(t.slice(3).toLowerCase()),s=>Du(new au(e,t,s));if(!0===/^flip[XYZWRGBASTPQ]{1,4}$/.test(t))return t=gu(t.slice(4).toLowerCase()),()=>Du(new hu(Du(e),t));if("width"===t||"height"===t||"depth"===t)return"width"===t?t="x":"height"===t?t="y":"depth"===t&&(t="z"),Du(new ou(e,t));if(!0===/^\d+$/.test(t))return Du(new tu(s,new uu(Number(t),"uint")))}return Reflect.get(e,t,s)},set:(e,t,s,i)=>"string"!=typeof t||void 0!==e[t]||!0!==/^[xyzwrgbastpq]{1,4}$/.test(t)&&"width"!==t&&"height"!==t&&"depth"!==t&&!0!==/^\d+$/.test(t)?Reflect.set(e,t,s,i):(i[t].assign(s),!0)},yu=new WeakMap,xu=new WeakMap,bu=function(e,t=null){for(const s in e)e[s]=Du(e[s],t);return e},vu=function(e,t=null){const s=e.length;for(let i=0;iDu(null!==i?Object.assign(e,i):e);return null===t?(...t)=>r(new e(...Gu(t))):null!==s?(s=Du(s),(...i)=>r(new e(t,...Gu(i),s))):(...s)=>r(new e(t,...Gu(s)))},_u=function(e,...t){return Du(new e(...Gu(t)))};class wu extends Kl{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}call(e){const{shaderNode:t,inputNodes:s}=this,i=e.getNodeProperties(t);if(i.onceOutput)return i.onceOutput;let r=null;if(t.layout){let i=xu.get(e.constructor);void 0===i&&(i=new WeakMap,xu.set(e.constructor,i));let n=i.get(t);void 0===n&&(n=Du(e.buildFunctionNode(t)),i.set(t,n)),null!==e.currentFunctionNode&&e.currentFunctionNode.includes.push(n),r=Du(n.call(s))}else{const i=t.jsFunc,n=null!==s?i(s,e):i(e);r=Du(n)}return t.once&&(i.onceOutput=r),r}getOutputNode(e){const t=e.getNodeProperties(this);return null===t.outputNode&&(t.outputNode=this.setupOutput(e)),t.outputNode}setup(e){return this.getOutputNode(e)}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}generate(e,t){return this.getOutputNode(e).build(e,t)}}class Su extends Kl{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}call(e=null){return ku(e),Du(new wu(this,e))}setup(){return this.call()}}const Mu=[!1,!0],Au=[0,1,2,3],Nu=[-1,-2],Ru=[.5,1.5,1/3,1e-6,1e6,Math.PI,2*Math.PI,1/Math.PI,2/Math.PI,1/(2*Math.PI),Math.PI/2],Cu=new Map;for(const e of Mu)Cu.set(e,new uu(e));const Eu=new Map;for(const e of Au)Eu.set(e,new uu(e,"uint"));const Bu=new Map([...Eu].map((e=>new uu(e.value,"int"))));for(const e of Nu)Bu.set(e,new uu(e,"int"));const Iu=new Map([...Bu].map((e=>new uu(e.value))));for(const e of Ru)Iu.set(e,new uu(e));for(const e of Ru)Iu.set(-e,new uu(-e));const Pu={bool:Cu,uint:Eu,ints:Bu,float:Iu},Fu=new Map([...Cu,...Iu]),zu=(e,t)=>Fu.has(e)?Fu.get(e):!0===e.isNode?e:new uu(e,t),Uu=function(e,t=null){return(...s)=>{if((0===s.length||!["bool","float","int","uint"].includes(e)&&s.every((e=>"object"!=typeof e)))&&(s=[Vl(e,...s)]),1===s.length&&null!==t&&t.has(s[0]))return Du(t.get(s[0]));if(1===s.length){const t=zu(s[0],e);return(e=>{try{return e.getNodeType()}catch(e){return}})(t)===e?Du(t):Du(new su(t,e))}const i=s.map((e=>zu(e)));return Du(new ru(i,e))}},Lu=e=>"object"==typeof e&&null!==e?e.value:e,Ou=e=>null!=e?e.nodeType||e.convertTo||("string"==typeof e?e:null):null;function Vu(e,t){return new Proxy(new Su(e,t),fu)}const Du=(e,t=null)=>function(e,t=null){const s=Ol(e);if("node"===s){let t=yu.get(e);return void 0===t&&(t=new Proxy(e,fu),yu.set(e,t),yu.set(t,t)),t}return null===t&&("float"===s||"boolean"===s)||s&&"shader"!==s&&"string"!==s?Du(zu(e,t)):"shader"===s?ju(e):e}(e,t),ku=(e,t=null)=>new bu(e,t),Gu=(e,t=null)=>new vu(e,t),Wu=(...e)=>new Tu(...e),Hu=(...e)=>new _u(...e),ju=(e,t)=>{const s=new Vu(e,t),i=(...e)=>{let t;return ku(e),t=e[0]&&e[0].isNode?[...e]:e[0],s.call(t)};return i.shaderNode=s,i.setLayout=e=>(s.setLayout(e),i),i.once=()=>(s.once=!0,i),i},qu=(...e)=>(console.warn("TSL.ShaderNode: tslFn() has been renamed to Fn()."),ju(...e));pu("toGlobal",(e=>(e.global=!0,e)));const $u=e=>{cu=e},Xu=()=>cu,Yu=(...e)=>cu.If(...e);function Ju(e){return cu&&cu.add(e),e}pu("append",Ju);const Zu=new Uu("color"),Ku=new Uu("float",Pu.float),Qu=new Uu("int",Pu.ints),ec=new Uu("uint",Pu.uint),tc=new Uu("bool",Pu.bool),sc=new Uu("vec2"),ic=new Uu("ivec2"),rc=new Uu("uvec2"),nc=new Uu("bvec2"),oc=new Uu("vec3"),ac=new Uu("ivec3"),hc=new Uu("uvec3"),lc=new Uu("bvec3"),uc=new Uu("vec4"),cc=new Uu("ivec4"),dc=new Uu("uvec4"),pc=new Uu("bvec4"),mc=new Uu("mat2"),gc=new Uu("mat3"),fc=new Uu("mat4"),yc=(e="")=>Du(new uu(e,"string")),xc=e=>Du(new uu(e,"ArrayBuffer"));pu("toColor",Zu),pu("toFloat",Ku),pu("toInt",Qu),pu("toUint",ec),pu("toBool",tc),pu("toVec2",sc),pu("toIVec2",ic),pu("toUVec2",rc),pu("toBVec2",nc),pu("toVec3",oc),pu("toIVec3",ac),pu("toUVec3",hc),pu("toBVec3",lc),pu("toVec4",uc),pu("toIVec4",cc),pu("toUVec4",dc),pu("toBVec4",pc),pu("toMat2",mc),pu("toMat3",gc),pu("toMat4",fc);const bc=Wu(tu),vc=(e,t)=>Du(new su(Du(e),t)),Tc=(e,t)=>Du(new ou(Du(e),t));pu("element",bc),pu("convert",vc);class _c extends Kl{constructor(e,t=!1){super("string"),this.name=e,this.version=0,this.shared=t,this.isUniformGroup=!0}set needsUpdate(e){!0===e&&this.version++}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}Ql("UniformGroup",_c);const wc=e=>new _c(e),Sc=e=>new _c(e,!0),Mc=Sc("frame"),Ac=Sc("render"),Nc=wc("object");class Rc extends lu{constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=Nc}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const s=this.getSelf();return e=e.bind(s),super.onUpdate((t=>{const i=e(t,s);void 0!==i&&(this.value=i)}),t)}generate(e,t){const s=this.getNodeType(e),i=this.getUniformHash(e);let r=e.getNodeFromHash(i);void 0===r&&(e.setHashNode(this,i),r=this);const n=r.getInputType(e),o=e.getUniformFromNode(r,n,e.shaderStage,this.name||e.context.label),a=e.getPropertyName(o);return void 0!==e.context.label&&delete e.context.label,e.format(a,s,t)}}Ql("Uniform",Rc);const Cc=(e,t)=>{const s=Ou(t||e),i=e&&!0===e.isNode?e.node&&e.node.value||e.value:e;return Du(new Rc(i,s))};class Ec extends Kl{constructor(e,t=null,s=!1){super(e),this.name=t,this.varying=s,this.isPropertyNode=!0}getHash(e){return this.name||super.getHash(e)}isGlobal(){return!0}generate(e){let t;return!0===this.varying?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}Ql("Property",Ec);const Bc=(e,t)=>Du(new Ec(e,t)),Ic=(e,t)=>Du(new Ec(e,t,!0)),Pc=Hu(Ec,"vec4","DiffuseColor"),Fc=Hu(Ec,"vec3","EmissiveColor"),zc=Hu(Ec,"float","Roughness"),Uc=Hu(Ec,"float","Metalness"),Lc=Hu(Ec,"float","Clearcoat"),Oc=Hu(Ec,"float","ClearcoatRoughness"),Vc=Hu(Ec,"vec3","Sheen"),Dc=Hu(Ec,"float","SheenRoughness"),kc=Hu(Ec,"float","Iridescence"),Gc=Hu(Ec,"float","IridescenceIOR"),Wc=Hu(Ec,"float","IridescenceThickness"),Hc=Hu(Ec,"float","AlphaT"),jc=Hu(Ec,"float","Anisotropy"),qc=Hu(Ec,"vec3","AnisotropyT"),$c=Hu(Ec,"vec3","AnisotropyB"),Xc=Hu(Ec,"color","SpecularColor"),Yc=Hu(Ec,"float","SpecularF90"),Jc=Hu(Ec,"float","Shininess"),Zc=Hu(Ec,"vec4","Output"),Kc=Hu(Ec,"float","dashSize"),Qc=Hu(Ec,"float","gapSize"),ed=Hu(Ec,"float","pointWidth"),td=Hu(Ec,"float","IOR"),sd=Hu(Ec,"float","Transmission"),id=Hu(Ec,"float","Thickness"),rd=Hu(Ec,"float","AttenuationDistance"),nd=Hu(Ec,"color","AttenuationColor"),od=Hu(Ec,"float","Dispersion");class ad extends iu{constructor(e,t){super(),this.targetNode=e,this.sourceNode=t}hasDependencies(){return!1}getNodeType(e,t){return"void"!==t?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(!1===e.isAvailable("swizzleAssign")&&t.isSplitNode&&t.components.length>1){const s=e.getTypeLength(t.node.getNodeType(e));return Yl.join("").slice(0,s)!==t.components}return!1}generate(e,t){const{targetNode:s,sourceNode:i}=this,r=this.needsSplitAssign(e),n=s.getNodeType(e),o=s.context({assign:!0}).build(e),a=i.build(e,n),h=i.getNodeType(e),l=e.getDataFromNode(this);let u;if(!0===l.initialized)"void"!==t&&(u=o);else if(r){const i=e.getVarFromNode(this,null,n),r=e.getPropertyName(i);e.addLineFlowCode(`${r} = ${a}`);const h=s.node.context({assign:!0}).build(e);for(let t=0;t(t=t.length>1||t[0]&&!0===t[0].isNode?Gu(t):ku(t[0]),Du(new ld(Du(e),t)));pu("call",ud);class cd extends iu{constructor(e,t,s,...i){if(super(),i.length>0){let r=new cd(e,t,s);for(let t=0;t>"===s||"<<"===s)return e.getIntegerType(n);if("!"===s||"=="===s||"&&"===s||"||"===s||"^^"===s)return"bool";if("<"===s||">"===s||"<="===s||">="===s){const s=t?e.getTypeLength(t):Math.max(e.getTypeLength(n),e.getTypeLength(o));return s>1?`bvec${s}`:"bool"}return"float"===n&&e.isMatrix(o)?o:e.isMatrix(n)&&e.isVector(o)?e.getVectorFromMatrix(n):e.isVector(n)&&e.isMatrix(o)?e.getVectorFromMatrix(o):e.getTypeLength(o)>e.getTypeLength(n)?o:n}generate(e,t){const s=this.op,i=this.aNode,r=this.bNode,n=this.getNodeType(e,t);let o=null,a=null;"void"!==n?(o=i.getNodeType(e),a=void 0!==r?r.getNodeType(e):null,"<"===s||">"===s||"<="===s||">="===s||"=="===s?e.isVector(o)?a=o:o!==a&&(o=a="float"):">>"===s||"<<"===s?(o=n,a=e.changeComponentType(a,"uint")):e.isMatrix(o)&&e.isVector(a)?a=e.getVectorFromMatrix(o):o=e.isVector(o)&&e.isMatrix(a)?e.getVectorFromMatrix(a):a=n):o=a=n;const h=i.build(e,o),l=void 0!==r?r.build(e,a):null,u=e.getTypeLength(t),c=e.getFunctionOperator(s);return"void"!==t?"<"===s&&u>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThan",t)}( ${h}, ${l} )`,n,t):e.format(`( ${h} < ${l} )`,n,t):"<="===s&&u>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThanEqual",t)}( ${h}, ${l} )`,n,t):e.format(`( ${h} <= ${l} )`,n,t):">"===s&&u>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThan",t)}( ${h}, ${l} )`,n,t):e.format(`( ${h} > ${l} )`,n,t):">="===s&&u>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThanEqual",t)}( ${h}, ${l} )`,n,t):e.format(`( ${h} >= ${l} )`,n,t):"!"===s||"~"===s?e.format(`(${s}${h})`,o,t):c?e.format(`${c}( ${h}, ${l} )`,n,t):e.format(`( ${h} ${s} ${l} )`,n,t):"void"!==o?c?e.format(`${c}( ${h}, ${l} )`,n,t):e.format(`${h} ${s} ${l}`,n,t):void 0}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}Ql("Operator",cd);const dd=Wu(cd,"+"),pd=Wu(cd,"-"),md=Wu(cd,"*"),gd=Wu(cd,"/"),fd=Wu(cd,"%"),yd=Wu(cd,"=="),xd=Wu(cd,"!="),bd=Wu(cd,"<"),vd=Wu(cd,">"),Td=Wu(cd,"<="),_d=Wu(cd,">="),wd=Wu(cd,"&&"),Sd=Wu(cd,"||"),Md=Wu(cd,"!"),Ad=Wu(cd,"^^"),Nd=Wu(cd,"&"),Rd=Wu(cd,"~"),Cd=Wu(cd,"|"),Ed=Wu(cd,"^"),Bd=Wu(cd,"<<"),Id=Wu(cd,">>");pu("add",dd),pu("sub",pd),pu("mul",md),pu("div",gd),pu("modInt",fd),pu("equal",yd),pu("notEqual",xd),pu("lessThan",bd),pu("greaterThan",vd),pu("lessThanEqual",Td),pu("greaterThanEqual",_d),pu("and",wd),pu("or",Sd),pu("not",Md),pu("xor",Ad),pu("bitAnd",Nd),pu("bitNot",Rd),pu("bitOr",Cd),pu("bitXor",Ed),pu("shiftLeft",Bd),pu("shiftRight",Id);const Pd=(...e)=>(console.warn("TSL.OperatorNode: .remainder() has been renamed to .modInt()."),fd(...e));pu("remainder",Pd);class Fd extends iu{constructor(e,t,s=null,i=null){super(),this.method=e,this.aNode=t,this.bNode=s,this.cNode=i}getInputType(e){const t=this.aNode.getNodeType(e),s=this.bNode?this.bNode.getNodeType(e):null,i=this.cNode?this.cNode.getNodeType(e):null,r=e.isMatrix(t)?0:e.getTypeLength(t),n=e.isMatrix(s)?0:e.getTypeLength(s),o=e.isMatrix(i)?0:e.getTypeLength(i);return r>n&&r>o?t:n>o?s:o>r?i:t}getNodeType(e){const t=this.method;return t===Fd.LENGTH||t===Fd.DISTANCE||t===Fd.DOT?"float":t===Fd.CROSS?"vec3":t===Fd.ALL?"bool":t===Fd.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):t===Fd.MOD?this.aNode.getNodeType(e):this.getInputType(e)}generate(e,t){const s=this.method,i=this.getNodeType(e),r=this.getInputType(e),n=this.aNode,o=this.bNode,a=this.cNode,h=!0===e.renderer.isWebGLRenderer;if(s===Fd.TRANSFORM_DIRECTION){let s=n,i=o;e.isMatrix(s.getNodeType(e))?i=uc(oc(i),0):s=uc(oc(s),0);const r=md(s,i).xyz;return Kd(r).build(e,t)}if(s===Fd.NEGATE)return e.format("( - "+n.build(e,r)+" )",i,t);if(s===Fd.ONE_MINUS)return pd(1,n).build(e,t);if(s===Fd.RECIPROCAL)return gd(1,n).build(e,t);if(s===Fd.DIFFERENCE)return op(pd(n,o)).build(e,t);{const l=[];return s===Fd.CROSS||s===Fd.MOD?l.push(n.build(e,i),o.build(e,i)):h&&s===Fd.STEP?l.push(n.build(e,1===e.getTypeLength(n.getNodeType(e))?"float":r),o.build(e,r)):h&&(s===Fd.MIN||s===Fd.MAX)||s===Fd.MOD?l.push(n.build(e,r),o.build(e,1===e.getTypeLength(o.getNodeType(e))?"float":r)):s===Fd.REFRACT?l.push(n.build(e,r),o.build(e,r),a.build(e,"float")):s===Fd.MIX?l.push(n.build(e,r),o.build(e,r),a.build(e,1===e.getTypeLength(a.getNodeType(e))?"float":r)):(l.push(n.build(e,r)),null!==o&&l.push(o.build(e,r)),null!==a&&l.push(a.build(e,r))),e.format(`${e.getMethod(s,i)}( ${l.join(", ")} )`,i,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}Fd.ALL="all",Fd.ANY="any",Fd.EQUALS="equals",Fd.RADIANS="radians",Fd.DEGREES="degrees",Fd.EXP="exp",Fd.EXP2="exp2",Fd.LOG="log",Fd.LOG2="log2",Fd.SQRT="sqrt",Fd.INVERSE_SQRT="inversesqrt",Fd.FLOOR="floor",Fd.CEIL="ceil",Fd.NORMALIZE="normalize",Fd.FRACT="fract",Fd.SIN="sin",Fd.COS="cos",Fd.TAN="tan",Fd.ASIN="asin",Fd.ACOS="acos",Fd.ATAN="atan",Fd.ABS="abs",Fd.SIGN="sign",Fd.LENGTH="length",Fd.NEGATE="negate",Fd.ONE_MINUS="oneMinus",Fd.DFDX="dFdx",Fd.DFDY="dFdy",Fd.ROUND="round",Fd.RECIPROCAL="reciprocal",Fd.TRUNC="trunc",Fd.FWIDTH="fwidth",Fd.BITCAST="bitcast",Fd.TRANSPOSE="transpose",Fd.ATAN2="atan2",Fd.MIN="min",Fd.MAX="max",Fd.MOD="mod",Fd.STEP="step",Fd.REFLECT="reflect",Fd.DISTANCE="distance",Fd.DIFFERENCE="difference",Fd.DOT="dot",Fd.CROSS="cross",Fd.POW="pow",Fd.TRANSFORM_DIRECTION="transformDirection",Fd.MIX="mix",Fd.CLAMP="clamp",Fd.REFRACT="refract",Fd.SMOOTHSTEP="smoothstep",Fd.FACEFORWARD="faceforward",Ql("Math",Fd);const zd=Ku(1e-6),Ud=Ku(1e6),Ld=Ku(Math.PI),Od=Ku(2*Math.PI),Vd=Wu(Fd,Fd.ALL),Dd=Wu(Fd,Fd.ANY),kd=Wu(Fd,Fd.EQUALS),Gd=Wu(Fd,Fd.RADIANS),Wd=Wu(Fd,Fd.DEGREES),Hd=Wu(Fd,Fd.EXP),jd=Wu(Fd,Fd.EXP2),qd=Wu(Fd,Fd.LOG),$d=Wu(Fd,Fd.LOG2),Xd=Wu(Fd,Fd.SQRT),Yd=Wu(Fd,Fd.INVERSE_SQRT),Jd=Wu(Fd,Fd.FLOOR),Zd=Wu(Fd,Fd.CEIL),Kd=Wu(Fd,Fd.NORMALIZE),Qd=Wu(Fd,Fd.FRACT),ep=Wu(Fd,Fd.SIN),tp=Wu(Fd,Fd.COS),sp=Wu(Fd,Fd.TAN),ip=Wu(Fd,Fd.ASIN),rp=Wu(Fd,Fd.ACOS),np=Wu(Fd,Fd.ATAN),op=Wu(Fd,Fd.ABS),ap=Wu(Fd,Fd.SIGN),hp=Wu(Fd,Fd.LENGTH),lp=Wu(Fd,Fd.NEGATE),up=Wu(Fd,Fd.ONE_MINUS),cp=Wu(Fd,Fd.DFDX),dp=Wu(Fd,Fd.DFDY),pp=Wu(Fd,Fd.ROUND),mp=Wu(Fd,Fd.RECIPROCAL),gp=Wu(Fd,Fd.TRUNC),fp=Wu(Fd,Fd.FWIDTH),yp=Wu(Fd,Fd.BITCAST),xp=Wu(Fd,Fd.TRANSPOSE),bp=Wu(Fd,Fd.ATAN2),vp=Wu(Fd,Fd.MIN),Tp=Wu(Fd,Fd.MAX),_p=Wu(Fd,Fd.MOD),wp=Wu(Fd,Fd.STEP),Sp=Wu(Fd,Fd.REFLECT),Mp=Wu(Fd,Fd.DISTANCE),Ap=Wu(Fd,Fd.DIFFERENCE),Np=Wu(Fd,Fd.DOT),Rp=Wu(Fd,Fd.CROSS),Cp=Wu(Fd,Fd.POW),Ep=Wu(Fd,Fd.POW,2),Bp=Wu(Fd,Fd.POW,3),Ip=Wu(Fd,Fd.POW,4),Pp=Wu(Fd,Fd.TRANSFORM_DIRECTION),Fp=e=>md(ap(e),Cp(op(e),1/3)),zp=e=>Np(e,e),Up=Wu(Fd,Fd.MIX),Lp=(e,t=0,s=1)=>Du(new Fd(Fd.CLAMP,Du(e),Du(t),Du(s))),Op=e=>Lp(e),Vp=Wu(Fd,Fd.REFRACT),Dp=Wu(Fd,Fd.SMOOTHSTEP),kp=Wu(Fd,Fd.FACEFORWARD),Gp=ju((([e])=>{const t=Np(e.xy,sc(12.9898,78.233)),s=_p(t,Ld);return Qd(ep(s).mul(43758.5453))})),Wp=(e,t,s)=>Up(t,s,e),Hp=(e,t,s)=>Dp(t,s,e);pu("all",Vd),pu("any",Dd),pu("equals",kd),pu("radians",Gd),pu("degrees",Wd),pu("exp",Hd),pu("exp2",jd),pu("log",qd),pu("log2",$d),pu("sqrt",Xd),pu("inverseSqrt",Yd),pu("floor",Jd),pu("ceil",Zd),pu("normalize",Kd),pu("fract",Qd),pu("sin",ep),pu("cos",tp),pu("tan",sp),pu("asin",ip),pu("acos",rp),pu("atan",np),pu("abs",op),pu("sign",ap),pu("length",hp),pu("lengthSq",zp),pu("negate",lp),pu("oneMinus",up),pu("dFdx",cp),pu("dFdy",dp),pu("round",pp),pu("reciprocal",mp),pu("trunc",gp),pu("fwidth",fp),pu("atan2",bp),pu("min",vp),pu("max",Tp),pu("mod",_p),pu("step",wp),pu("reflect",Sp),pu("distance",Mp),pu("dot",Np),pu("cross",Rp),pu("pow",Cp),pu("pow2",Ep),pu("pow3",Bp),pu("pow4",Ip),pu("transformDirection",Pp),pu("mix",Wp),pu("clamp",Lp),pu("refract",Vp),pu("smoothstep",Hp),pu("faceForward",kp),pu("difference",Ap),pu("saturate",Op),pu("cbrt",Fp),pu("transpose",xp),pu("rand",Gp);class jp extends Kl{constructor(e,t,s=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=s}getNodeType(e){const t=this.ifNode.getNodeType(e);if(null!==this.elseNode){const s=this.elseNode.getNodeType(e);if(e.getTypeLength(s)>e.getTypeLength(t))return s}return t}setup(e){const t=e.getNodeProperties(this);t.condNode=this.condNode.cache(),t.ifNode=this.ifNode.cache(),t.elseNode=this.elseNode?this.elseNode.cache():null}generate(e,t){const s=this.getNodeType(e),i=e.getDataFromNode(this);if(void 0!==i.nodeProperty)return i.nodeProperty;const{condNode:r,ifNode:n,elseNode:o}=e.getNodeProperties(this),a="void"!==t,h=a?Bc(s).build(e):"";i.nodeProperty=h;const l=r.build(e,"bool");e.addFlowCode(`\n${e.tab}if ( ${l} ) {\n\n`).addFlowTab();let u=n.build(e,s);if(u&&(u=a?h+" = "+u+";":"return "+u+";"),e.removeFlowTab().addFlowCode(e.tab+"\t"+u+"\n\n"+e.tab+"}"),null!==o){e.addFlowCode(" else {\n\n").addFlowTab();let t=o.build(e,s);t&&(t=a?h+" = "+t+";":"return "+t+";"),e.removeFlowTab().addFlowCode(e.tab+"\t"+t+"\n\n"+e.tab+"}\n\n")}else e.addFlowCode("\n\n");return e.format(h,s,t)}}Ql("Conditional",jp);const qp=Wu(jp);pu("select",qp);const $p=(...e)=>(console.warn("TSL.ConditionalNode: cond() has been renamed to select()."),qp(...e));pu("cond",$p);class Xp extends Kl{constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){this.node.build(e)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value});const s=this.node.build(e);return e.setContext(t),s}generate(e,t){const s=e.getContext();e.setContext({...e.context,...this.value});const i=this.node.build(e,t);return e.setContext(s),i}}Ql("Context",Xp);const Yp=Wu(Xp),Jp=(e,t)=>Yp(e,{label:t});pu("context",Yp),pu("label",Jp);class Zp extends Kl{constructor(e,t=null){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:s}=this,i=e.getVarFromNode(this,s,e.getVectorType(this.getNodeType(e))),r=e.getPropertyName(i),n=t.build(e,i.type);return e.addLineFlowCode(`${r} = ${n}`),r}}Ql("Var",Zp);const Kp=Wu(Zp);pu("temp",Kp),pu("toVar",((...e)=>Kp(...e).append()));class Qp extends Kl{constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0}isGlobal(){return!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let s=t.varying;if(void 0===s){const i=this.name,r=this.getNodeType(e);t.varying=s=e.getVaryingFromNode(this,i,r),t.node=this.node}return s.needsInterpolation||(s.needsInterpolation="fragment"===e.shaderStage),s}setup(e){this.setupVarying(e)}analyze(e){return this.setupVarying(e),this.node.analyze(e)}generate(e){const t=e.getNodeProperties(this),s=this.setupVarying(e);if(void 0===t.propertyName){const i=this.getNodeType(e),r=e.getPropertyName(s,Wl.VERTEX);e.flowNodeFromShaderStage(Wl.VERTEX,this.node,i,r),t.propertyName=r}return e.getPropertyName(s)}}Ql("Varying",Qp);const em=Wu(Qp);pu("varying",em);const tm=e=>{let t=null;return e===Zt?t="Linear":e===Jt&&(t="sRGB"),t},sm=(e,t)=>tm(e)+"To"+tm(t);class im extends iu{constructor(e,t){super("vec4"),this.colorSpace=e,this.colorNode=t}setup(e){const{colorSpace:t,colorNode:s}=this;if(t===im.LINEAR_TO_LINEAR)return s;let i=null;const r=e.renderer.nodes.library.getColorSpaceFunction(t);return null!==r?i=uc(r(s.rgb),s.a):(console.error("ColorSpaceNode: Unsupported Color Space configuration.",t),i=s),i}}im.LINEAR_TO_LINEAR="LinearToLinear",Ql("ColorSpace",im);const rm=(e,t)=>Du(new im(sm(Zt,t),Du(e))),nm=(e,t)=>Du(new im(sm(t,Zt),Du(e)));pu("linearToColorSpace",rm),pu("colorSpaceToLinear",nm);let om=class extends tu{constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),s=this.referenceNode.getNodeType(),i=this.getNodeType();return e.format(t,s,i)}};class am extends Kl{constructor(e,t,s=null,i=null){super(),this.property=e,this.uniformType=t,this.object=s,this.count=i,this.properties=e.split("."),this.reference=s,this.node=null,this.updateType=Hl.OBJECT}element(e){return Du(new om(this,Du(e)))}setNodeType(e){this.node=Cc(null,e).getSelf()}getNodeType(e){return null===this.node&&this.updateValue(),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let s=e[t[0]];for(let e=1;eDu(new hm(e,t,s));class um extends iu{constructor(e,t=dm,s=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=s}getCacheKey(){let e=super.getCacheKey();return e="{toneMapping:"+this.toneMapping+",nodes:"+e+"}",e}setup(e){const t=this.colorNode||e.context.color,s=this.toneMapping;if(0===s)return t;let i=null;const r=e.renderer.nodes.library.getToneMappingFunction(s);return null!==r?i=uc(r(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",s),i=t),i}}Ql("ToneMapping",um);const cm=(e,t,s)=>Du(new um(e,Du(t),Du(s))),dm=lm("toneMappingExposure","float");pu("toneMapping",((e,t,s)=>cm(t,s,e)));class pm extends lu{constructor(e,t=null,s=0,i=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=s,this.bufferOffset=i,this.usage=Rs,this.instanced=!1,this.attribute=null,this.global=!0,e&&!0===e.isBufferAttribute&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(0===this.bufferStride&&0===this.bufferOffset){let t=e.globalCache.getData(this.value);return void 0===t&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return null===this.bufferType&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(null!==this.attribute)return;const t=this.getNodeType(e),s=this.value,i=e.getTypeLength(t),r=this.bufferStride||i,n=this.bufferOffset,o=!0===s.isInterleavedBuffer?s:new oo(s,r),a=new ho(o,i,n);o.setUsage(this.usage),this.attribute=a,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),s=e.getBufferAttributeFromNode(this,t),i=e.getPropertyName(s);let r=null;if("vertex"===e.shaderStage||"compute"===e.shaderStage)this.name=i,r=i;else{r=em(this).build(e,t)}return r}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&!0===this.attribute.isBufferAttribute&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}Ql("BufferAttribute",pm);const mm=(e,t,s,i)=>Du(new pm(e,t,s,i)),gm=(e,t,s,i)=>mm(e,t,s,i).setUsage(Cs),fm=(e,t,s,i)=>mm(e,t,s,i).setInstanced(!0),ym=(e,t,s,i)=>gm(e,t,s,i).setInstanced(!0);pu("toAttribute",(e=>mm(e.value)));class xm extends Kl{constructor(e,t,s=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=s,this.dispatchCount=0,this.version=1,this.updateBeforeType=Hl.OBJECT,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}updateDispatchCount(){const{count:e,workgroupSize:t}=this;let s=t[0];for(let e=1;eDu(new xm(Du(e),t,s));pu("compute",bm);class vm extends Kl{constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){return this.node.getNodeType(e)}build(e,...t){const s=e.getCache(),i=e.getCacheFromNode(this,parent);e.setCache(i);const r=this.node.build(e,...t);return e.setCache(s),r}}Ql("Cache",vm);const Tm=(e,...t)=>Du(new vm(Du(e),...t));pu("cache",Tm);class _m extends Kl{constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return""!==t&&e.addLineFlowCode(t),this.outputNode.build(e)}}Ql("Bypass",_m);const wm=Wu(_m);pu("bypass",wm);class Sm extends Kl{constructor(e,t,s,i=Ku(0),r=Ku(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=s,this.outLowNode=i,this.outHighNode=r,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:s,outLowNode:i,outHighNode:r,doClamp:n}=this;let o=e.sub(t).div(s.sub(t));return!0===n&&(o=o.clamp()),o.mul(r.sub(i)).add(i)}}Ql("Remap",Sm);const Mm=Wu(Sm,null,null,{doClamp:!1}),Am=Wu(Sm);pu("remap",Mm),pu("remapClamp",Am);class Nm extends Kl{constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const s=this.getNodeType(e),i=this.snippet;if("void"!==s)return e.format(`( ${i} )`,s,t);e.addLineFlowCode(i)}}Ql("Expression",Nm);const Rm=Wu(Nm),Cm=e=>(e?qp(e,Rm("discard")):Rm("discard")).append(),Em=()=>Rm("return").append();pu("discard",Cm);class Bm extends iu{constructor(e,t,s){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=s,this.isRenderOutput=!0}setup({context:e}){let t=this.colorNode||e.color;const s=(null!==this.toneMapping?this.toneMapping:e.toneMapping)||0,i=(null!==this.outputColorSpace?this.outputColorSpace:e.outputColorSpace)||Zt;return 0!==s&&(t=t.toneMapping(s)),i===Jt&&(t=t.linearToColorSpace(i)),t}}Ql("RenderOutput",Bm);const Im=(e,t=null,s=null)=>Du(new Bm(Du(e),t,s));function Pm(e){console.warn("THREE.TSLBase: AddNodeElement has been removed in favor of tree-shaking. Trying add",e)}pu("renderOutput",Im);class Fm extends Kl{constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(null===t){const s=this.getAttributeName(e);if(e.hasGeometryAttribute(s)){const i=e.geometry.getAttribute(s);t=e.getTypeFromAttribute(i)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),s=this.getNodeType(e);if(!0===e.hasGeometryAttribute(t)){const i=e.geometry.getAttribute(t),r=e.getTypeFromAttribute(i),n=e.getAttribute(t,r);if("vertex"===e.shaderStage)return e.format(n.name,r,s);return em(this).build(e,s)}return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(s)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}Ql("Attribute",Fm);const zm=(e,t)=>Du(new Fm(e,t)),Um=e=>zm("uv"+(e>0?e:""),"vec2");class Lm extends Kl{constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const s=this.textureNode.build(e,"property"),i=this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${s}, ${i} )`,this.getNodeType(e),t)}}Ql("TextureSize",Lm);const Om=Wu(Lm);class Vm extends Rc{constructor(e){super(0),this._textureNode=e,this.updateType=Hl.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,s=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(s&&void 0!==s.width){const{width:e,height:t}=s;this.value=Math.log2(Math.max(e,t))}}}Ql("MaxMipLevel",Vm);const Dm=Wu(Vm);class km extends Rc{constructor(e,t=null,s=null,i=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=s,this.biasNode=i,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=Hl.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(null===t)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return!0===this.value.isDepthTexture?"float":this.value.type===Be?"uvec4":this.value.type===Ee?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return Um(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return null===this._matrixUniform&&(this._matrixUniform=Cc(this.value.matrix)),this._matrixUniform.mul(oc(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?Hl.FRAME:Hl.NONE,this}setupUV(e,t){const s=this.value;return!e.isFlipY()||!0!==s.isRenderTargetTexture&&!0!==s.isFramebufferTexture&&!0!==s.isDepthTexture||(t=t.setY(t.y.oneMinus())),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let s=this.uvNode;null!==s&&!0!==e.context.forceUVContext||!e.context.getUV||(s=e.context.getUV(this)),s||(s=this.getDefaultUV()),!0===this.updateMatrix&&(s=this.getTransformedUV(s)),s=this.setupUV(e,s);let i=this.levelNode;null===i&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this)),t.uvNode=s,t.levelNode=i,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode}generateUV(e,t){return t.build(e,!0===this.sampler?"vec2":"ivec2")}generateSnippet(e,t,s,i,r,n,o,a){const h=this.value;let l;return l=i?e.generateTextureLevel(h,t,s,i,n):r?e.generateTextureBias(h,t,s,r,n):a?e.generateTextureGrad(h,t,s,a,n):o?e.generateTextureCompare(h,t,s,o,n):!1===this.sampler?e.generateTextureLoad(h,t,s,n):e.generateTexture(h,t,s,n),l}generate(e,t){const s=e.getNodeProperties(this),i=this.value;if(!i||!0!==i.isTexture)throw new Error("TextureNode: Need a three.js texture.");const r=super.generate(e,"property");if("sampler"===t)return r+"_sampler";if(e.isReference(t))return r;{const n=e.getDataFromNode(this);let o=n.propertyName;if(void 0===o){const{uvNode:t,levelNode:i,biasNode:a,compareNode:h,depthNode:l,gradNode:u}=s,c=this.generateUV(e,t),d=i?i.build(e,"float"):null,p=a?a.build(e,"float"):null,m=l?l.build(e,"int"):null,g=h?h.build(e,"float"):null,f=u?[u[0].build(e,"vec2"),u[1].build(e,"vec2")]:null,y=e.getVarFromNode(this);o=e.getPropertyName(y);const x=this.generateSnippet(e,r,c,d,p,m,g,f);e.addLineFlowCode(`${o} = ${x}`),n.snippet=x,n.propertyName=o}let a=o;const h=this.getNodeType(e);return e.needsColorSpaceToLinear(i)&&(a=nm(Rm(a,h),i.colorSpace).setup(e).build(e,h)),e.format(a,h,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){const t=this.clone();return t.uvNode=Du(e),t.referenceNode=this.getSelf(),Du(t)}blur(e){const t=this.clone();return t.biasNode=Du(e).mul(Dm(t)),t.referenceNode=this.getSelf(),Du(t)}level(e){const t=this.clone();return t.levelNode=Du(e),t.referenceNode=this.getSelf(),Du(t)}size(e){return Om(this,e)}bias(e){const t=this.clone();return t.biasNode=Du(e),t.referenceNode=this.getSelf(),Du(t)}compare(e){const t=this.clone();return t.compareNode=Du(e),t.referenceNode=this.getSelf(),Du(t)}grad(e,t){const s=this.clone();return s.gradNode=[Du(e),Du(t)],s.referenceNode=this.getSelf(),Du(s)}depth(e){const t=this.clone();return t.depthNode=Du(e),t.referenceNode=this.getSelf(),Du(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;null!==t&&(t.value=e.matrix),!0===e.matrixAutoUpdate&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e}}Ql("Texture",km);const Gm=Wu(km),Wm=(...e)=>Gm(...e).setSampler(!1),Hm=e=>(!0===e.isNode?e:Gm(e)).convert("sampler"),jm=Sc("camera").onRenderUpdate((()=>{jm.needsUpdate=!0})),qm=Cc("float").label("cameraNear").setGroup(jm).onRenderUpdate((({camera:e})=>e.near)),$m=Cc("float").label("cameraFar").setGroup(jm).onRenderUpdate((({camera:e})=>e.far)),Xm=Cc("float").label("cameraLogDepth").setGroup(jm).onRenderUpdate((({camera:e})=>2/(Math.log(e.far+1)/Math.LN2))),Ym=Cc("mat4").label("cameraProjectionMatrix").setGroup(jm).onRenderUpdate((({camera:e})=>e.projectionMatrix)),Jm=Cc("mat4").label("cameraProjectionMatrixInverse").setGroup(jm).onRenderUpdate((({camera:e})=>e.projectionMatrixInverse)),Zm=Cc("mat4").label("cameraViewMatrix").setGroup(jm).onRenderUpdate((({camera:e})=>e.matrixWorldInverse)),Km=Cc("mat4").label("cameraWorldMatrix").setGroup(jm).onRenderUpdate((({camera:e})=>e.matrixWorld)),Qm=Cc("mat3").label("cameraNormalMatrix").setGroup(jm).onRenderUpdate((({camera:e})=>e.normalMatrix)),eg=Cc(new Ei).label("cameraPosition").setGroup(jm).onRenderUpdate((({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld)));class tg extends Kl{constructor(e=tg.VIEW_MATRIX,t=null){super(),this.scope=e,this.object3d=t,this.updateType=Hl.OBJECT,this._uniformNode=new Rc(null)}getNodeType(){const e=this.scope;return e===tg.WORLD_MATRIX||e===tg.VIEW_MATRIX?"mat4":e===tg.NORMAL_MATRIX?"mat3":e===tg.POSITION||e===tg.VIEW_POSITION||e===tg.DIRECTION||e===tg.SCALE?"vec3":void 0}update(e){const t=this.object3d,s=this._uniformNode,i=this.scope;if(i===tg.VIEW_MATRIX)s.value=t.modelViewMatrix;else if(i===tg.NORMAL_MATRIX)s.value=t.normalMatrix;else if(i===tg.WORLD_MATRIX)s.value=t.matrixWorld;else if(i===tg.POSITION)s.value=s.value||new Ei,s.value.setFromMatrixPosition(t.matrixWorld);else if(i===tg.SCALE)s.value=s.value||new Ei,s.value.setFromMatrixScale(t.matrixWorld);else if(i===tg.DIRECTION)s.value=s.value||new Ei,t.getWorldDirection(s.value);else if(i===tg.VIEW_POSITION){const i=e.camera;s.value=s.value||new Ei,s.value.setFromMatrixPosition(t.matrixWorld),s.value.applyMatrix4(i.matrixWorldInverse)}}generate(e){const t=this.scope;return t===tg.WORLD_MATRIX||t===tg.VIEW_MATRIX?this._uniformNode.nodeType="mat4":t===tg.NORMAL_MATRIX?this._uniformNode.nodeType="mat3":t!==tg.POSITION&&t!==tg.VIEW_POSITION&&t!==tg.DIRECTION&&t!==tg.SCALE||(this._uniformNode.nodeType="vec3"),this._uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}tg.VIEW_MATRIX="viewMatrix",tg.NORMAL_MATRIX="normalMatrix",tg.WORLD_MATRIX="worldMatrix",tg.POSITION="position",tg.SCALE="scale",tg.VIEW_POSITION="viewPosition",tg.DIRECTION="direction",Ql("Object3D",tg);const sg=Wu(tg,tg.DIRECTION),ig=Wu(tg,tg.VIEW_MATRIX),rg=Wu(tg,tg.NORMAL_MATRIX),ng=Wu(tg,tg.WORLD_MATRIX),og=Wu(tg,tg.POSITION),ag=Wu(tg,tg.SCALE),hg=Wu(tg,tg.VIEW_POSITION);class lg extends tg{constructor(e=lg.VIEW_MATRIX){super(e)}update(e){this.object3d=e.object,super.update(e)}}Ql("Model",lg);const ug=Hu(lg,lg.DIRECTION),cg=Hu(lg,lg.VIEW_MATRIX).label("modelViewMatrix").toVar("ModelViewMatrix"),dg=Hu(lg,lg.NORMAL_MATRIX),pg=Hu(lg,lg.WORLD_MATRIX),mg=Hu(lg,lg.POSITION),gg=Hu(lg,lg.SCALE),fg=Hu(lg,lg.VIEW_POSITION),yg=Cc(new or).onObjectUpdate((({object:e},t)=>t.value.copy(e.matrixWorld).invert())),xg=zm("position","vec3"),bg=xg.varying("positionLocal"),vg=xg.varying("positionPrevious"),Tg=pg.mul(bg).xyz.varying("v_positionWorld"),_g=bg.transformDirection(pg).varying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),wg=cg.mul(bg).xyz.varying("v_positionView"),Sg=wg.negate().varying("v_positionViewDirection").normalize().toVar("positionViewDirection");class Mg extends Kl{constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){const{renderer:t,material:s}=e;return t.coordinateSystem===Vs&&s.side===d?"false":e.getFrontFacing()}}Ql("FrontFacing",Mg);const Ag=Hu(Mg),Ng=Ku(Ag).mul(2).sub(1),Rg=zm("normal","vec3"),Cg=ju((e=>!1===e.geometry.hasAttribute("normal")?(console.warn('TSL.NormalNode: Vertex attribute "normal" not found on geometry.'),oc(0,1,0)):Rg),"vec3").once()().toVar("normalLocal"),Eg=wg.dFdx().cross(wg.dFdy()).normalize().toVar("normalFlat");let Bg=null;const Ig=ju((e=>{let t;return t=!0===e.material.flatShading?Eg:Bg||(Bg=em(dg.mul(Cg),"v_normalView").normalize()),t}),"vec3").once()().toVar("normalView"),Pg=em(Ig.transformDirection(Zm),"v_normalWorld").normalize().toVar("normalWorld"),Fg=ju((e=>e.context.setupNormal()),"vec3").once()().mul(Ng).toVar("transformedNormalView"),zg=Fg.transformDirection(Zm).normalize().toVar("transformedNormalWorld"),Ug=ju((e=>e.context.setupClearcoatNormal()),"vec3").once()().mul(Ng).toVar("transformedClearcoatNormalView"),Lg=Cc(0).onReference((({material:e})=>e)).onRenderUpdate((({material:e})=>e.refractionRatio)),Og=Sg.negate().reflect(Fg),Vg=Sg.negate().refract(Fg,Lg),Dg=Og.transformDirection(Zm).toVar("reflectVector"),kg=Vg.transformDirection(Zm).toVar("reflectVector");class Gg extends km{constructor(e,t=null,s=null,i=null){super(e,t,s,i),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===he?Dg:e.mapping===le?kg:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),oc(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const s=this.value;return e.renderer.coordinateSystem!==Ds&&s.isRenderTargetTexture?t:oc(t.x.negate(),t.yz)}generateUV(e,t){return t.build(e,"vec3")}}Ql("CubeTexture",Gg);const Wg=Wu(Gg);class Hg extends Rc{constructor(e,t,s=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=s}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}Ql("Buffer",Hg);const jg=(e,t,s)=>Du(new Hg(e,t,s));class qg extends tu{constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=super.generate(e),s=this.getNodeType();return e.format(t,"vec4",s)}}class $g extends Hg{constructor(e,t=null){super(null,"vec4"),this.array=e,this.elementType=t,this._elementType=null,this._elementLength=0,this.updateType=Hl.RENDER,this.isArrayBufferNode=!0}getElementType(){return this.elementType||this._elementType}getElementLength(){return this._elementLength}update(){const{array:e,value:t}=this,s=this.getElementLength(),i=this.getElementType();if(1===s)for(let s=0;sDu(new $g(e,t));class Yg extends tu{constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),s=this.referenceNode.getNodeType(),i=this.getNodeType();return e.format(t,s,i)}}class Jg extends Kl{constructor(e,t,s=null,i=null){super(),this.property=e,this.uniformType=t,this.object=s,this.count=i,this.properties=e.split("."),this.reference=s,this.node=null,this.updateType=Hl.OBJECT}element(e){return Du(new Yg(this,Du(e)))}setNodeType(e){let t=null;t=null!==this.count?jg(null,e,this.count):Array.isArray(this.getValueFromReference())?Xg(null,e):"texture"===e?Gm(null):"cubeTexture"===e?Wg(null):Cc(null,e),this.node=t.getSelf()}getNodeType(e){return null===this.node&&this.updateValue(),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let s=e[t[0]];for(let e=1;eDu(new Jg(e,t,s)),Kg=(e,t,s,i)=>Du(new Jg(e,t,i,s));class Qg extends Jg{constructor(e,t,s=null){super(e,t,s),this.material=s,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=null!==this.material?this.material:e.material,this.reference}}Ql("MaterialReference",Qg);const ef=(e,t,s)=>Du(new Qg(e,t,s)),tf=ju((e=>(!1===e.geometry.hasAttribute("tangent")&&e.geometry.computeTangents(),zm("tangent","vec4"))))(),sf=tf.xyz.toVar("tangentLocal"),rf=cg.mul(uc(sf,0)).xyz.varying("v_tangentView").normalize().toVar("tangentView"),nf=rf.transformDirection(Zm).varying("v_tangentWorld").normalize().toVar("tangentWorld"),of=rf.toVar("transformedTangentView"),af=of.transformDirection(Zm).normalize().toVar("transformedTangentWorld"),hf=e=>e.mul(tf.w).xyz,lf=em(hf(Rg.cross(tf)),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),uf=em(hf(Cg.cross(sf)),"v_bitangentLocal").normalize().toVar("bitangentLocal"),cf=em(hf(Ig.cross(rf)),"v_bitangentView").normalize().toVar("bitangentView"),df=em(hf(Pg.cross(nf)),"v_bitangentWorld").normalize().toVar("bitangentWorld"),pf=hf(Fg.cross(of)).normalize().toVar("transformedBitangentView"),mf=pf.transformDirection(Zm).normalize().toVar("transformedBitangentWorld"),gf=gc(rf,cf,Ig),ff=Sg.mul(gf),yf=(e,t)=>e.sub(ff.mul(t)),xf=(()=>{let e=$c.cross(Sg);return e=e.cross($c).normalize(),e=Up(e,Fg,jc.mul(zc.oneMinus()).oneMinus().pow2().pow2()).normalize(),e})(),bf=ju((e=>{const{eye_pos:t,surf_norm:s,mapN:i,uv:r}=e,n=t.dFdx(),o=t.dFdy(),a=r.dFdx(),h=r.dFdy(),l=s,u=o.cross(l),c=l.cross(n),d=u.mul(a.x).add(c.mul(h.x)),p=u.mul(a.y).add(c.mul(h.y)),m=d.dot(d).max(p.dot(p)),g=Ng.mul(m.inverseSqrt());return dd(d.mul(i.x,g),p.mul(i.y,g),l.mul(i.z)).normalize()}));class vf extends iu{constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=0}setup(e){const{normalMapType:t,scaleNode:s}=this;let i=this.node.mul(2).sub(1);null!==s&&(i=oc(i.xy.mul(s),i.z));let r=null;if(1===t)r=dg.mul(i).normalize();else if(0===t){r=!0===e.hasGeometryAttribute("tangent")?gf.mul(i).normalize():bf({eye_pos:wg,surf_norm:Ig,mapN:i,uv:Um()})}return r}}Ql("NormalMap",vf);const Tf=Wu(vf),_f=ju((({textureNode:e,bumpScale:t})=>{const s=t=>e.cache().context({getUV:e=>t(e.uvNode||Um()),forceUVContext:!0}),i=Ku(s((e=>e)));return sc(Ku(s((e=>e.add(e.dFdx())))).sub(i),Ku(s((e=>e.add(e.dFdy())))).sub(i)).mul(t)})),wf=ju((e=>{const{surf_pos:t,surf_norm:s,dHdxy:i}=e,r=t.dFdx().normalize(),n=s,o=t.dFdy().normalize().cross(n),a=n.cross(r),h=r.dot(o).mul(Ng),l=h.sign().mul(i.x.mul(o).add(i.y.mul(a)));return h.abs().mul(s).sub(l).normalize()}));class Sf extends iu{constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=null!==this.scaleNode?this.scaleNode:1,t=_f({textureNode:this.textureNode,bumpScale:e});return wf({surf_pos:wg,surf_norm:Ig,dHdxy:t})}}const Mf=Wu(Sf),Af=new Map;class Nf extends Kl{constructor(e){super(),this.scope=e}getCache(e,t){let s=Af.get(e);return void 0===s&&(s=ef(e,t),Af.set(e,s)),s}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache("map"===e?"map":e+"Map","texture")}setup(e){const t=e.context.material,s=this.scope;let i=null;if(s===Nf.COLOR){const e=void 0!==t.color?this.getColor(s):oc();i=t.map&&!0===t.map.isTexture?e.mul(this.getTexture("map")):e}else if(s===Nf.OPACITY){const e=this.getFloat(s);i=t.alphaMap&&!0===t.alphaMap.isTexture?e.mul(this.getTexture("alpha")):e}else if(s===Nf.SPECULAR_STRENGTH)i=t.specularMap&&!0===t.specularMap.isTexture?this.getTexture("specular").r:Ku(1);else if(s===Nf.SPECULAR_INTENSITY){const e=this.getFloat(s);i=t.specularMap?e.mul(this.getTexture(s).a):e}else if(s===Nf.SPECULAR_COLOR){const e=this.getColor(s);i=t.specularColorMap&&!0===t.specularColorMap.isTexture?e.mul(this.getTexture(s).rgb):e}else if(s===Nf.ROUGHNESS){const e=this.getFloat(s);i=t.roughnessMap&&!0===t.roughnessMap.isTexture?e.mul(this.getTexture(s).g):e}else if(s===Nf.METALNESS){const e=this.getFloat(s);i=t.metalnessMap&&!0===t.metalnessMap.isTexture?e.mul(this.getTexture(s).b):e}else if(s===Nf.EMISSIVE){const e=this.getFloat("emissiveIntensity"),r=this.getColor(s).mul(e);i=t.emissiveMap&&!0===t.emissiveMap.isTexture?r.mul(this.getTexture(s)):r}else if(s===Nf.NORMAL)i=t.normalMap?Tf(this.getTexture("normal"),this.getCache("normalScale","vec2")):t.bumpMap?Mf(this.getTexture("bump").r,this.getFloat("bumpScale")):Ig;else if(s===Nf.CLEARCOAT){const e=this.getFloat(s);i=t.clearcoatMap&&!0===t.clearcoatMap.isTexture?e.mul(this.getTexture(s).r):e}else if(s===Nf.CLEARCOAT_ROUGHNESS){const e=this.getFloat(s);i=t.clearcoatRoughnessMap&&!0===t.clearcoatRoughnessMap.isTexture?e.mul(this.getTexture(s).r):e}else if(s===Nf.CLEARCOAT_NORMAL)i=t.clearcoatNormalMap?Tf(this.getTexture(s),this.getCache(s+"Scale","vec2")):Ig;else if(s===Nf.SHEEN){const e=this.getColor("sheenColor").mul(this.getFloat("sheen"));i=t.sheenColorMap&&!0===t.sheenColorMap.isTexture?e.mul(this.getTexture("sheenColor").rgb):e}else if(s===Nf.SHEEN_ROUGHNESS){const e=this.getFloat(s);i=t.sheenRoughnessMap&&!0===t.sheenRoughnessMap.isTexture?e.mul(this.getTexture(s).a):e,i=i.clamp(.07,1)}else if(s===Nf.ANISOTROPY)if(t.anisotropyMap&&!0===t.anisotropyMap.isTexture){const e=this.getTexture(s);i=mc(cy.x,cy.y,cy.y.negate(),cy.x).mul(e.rg.mul(2).sub(sc(1)).normalize().mul(e.b))}else i=cy;else if(s===Nf.IRIDESCENCE_THICKNESS){const e=Zg("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const r=Zg("0","float",t.iridescenceThicknessRange);i=e.sub(r).mul(this.getTexture(s).g).add(r)}else i=e}else if(s===Nf.TRANSMISSION){const e=this.getFloat(s);i=t.transmissionMap?e.mul(this.getTexture(s).r):e}else if(s===Nf.THICKNESS){const e=this.getFloat(s);i=t.thicknessMap?e.mul(this.getTexture(s).g):e}else if(s===Nf.IOR)i=this.getFloat(s);else if(s===Nf.LIGHT_MAP)i=this.getTexture(s).rgb.mul(this.getFloat("lightMapIntensity"));else if(s===Nf.AO_MAP)i=this.getTexture(s).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else{const t=this.getNodeType(e);i=this.getCache(s,t)}return i}}Nf.ALPHA_TEST="alphaTest",Nf.COLOR="color",Nf.OPACITY="opacity",Nf.SHININESS="shininess",Nf.SPECULAR="specular",Nf.SPECULAR_STRENGTH="specularStrength",Nf.SPECULAR_INTENSITY="specularIntensity",Nf.SPECULAR_COLOR="specularColor",Nf.REFLECTIVITY="reflectivity",Nf.ROUGHNESS="roughness",Nf.METALNESS="metalness",Nf.NORMAL="normal",Nf.CLEARCOAT="clearcoat",Nf.CLEARCOAT_ROUGHNESS="clearcoatRoughness",Nf.CLEARCOAT_NORMAL="clearcoatNormal",Nf.EMISSIVE="emissive",Nf.ROTATION="rotation",Nf.SHEEN="sheen",Nf.SHEEN_ROUGHNESS="sheenRoughness",Nf.ANISOTROPY="anisotropy",Nf.IRIDESCENCE="iridescence",Nf.IRIDESCENCE_IOR="iridescenceIOR",Nf.IRIDESCENCE_THICKNESS="iridescenceThickness",Nf.IOR="ior",Nf.TRANSMISSION="transmission",Nf.THICKNESS="thickness",Nf.ATTENUATION_DISTANCE="attenuationDistance",Nf.ATTENUATION_COLOR="attenuationColor",Nf.LINE_SCALE="scale",Nf.LINE_DASH_SIZE="dashSize",Nf.LINE_GAP_SIZE="gapSize",Nf.LINE_WIDTH="linewidth",Nf.LINE_DASH_OFFSET="dashOffset",Nf.POINT_WIDTH="pointWidth",Nf.DISPERSION="dispersion",Nf.LIGHT_MAP="light",Nf.AO_MAP="ao",Ql("Material",Nf);const Rf=Hu(Nf,Nf.ALPHA_TEST),Cf=Hu(Nf,Nf.COLOR),Ef=Hu(Nf,Nf.SHININESS),Bf=Hu(Nf,Nf.EMISSIVE),If=Hu(Nf,Nf.OPACITY),Pf=Hu(Nf,Nf.SPECULAR),Ff=Hu(Nf,Nf.SPECULAR_INTENSITY),zf=Hu(Nf,Nf.SPECULAR_COLOR),Uf=Hu(Nf,Nf.SPECULAR_STRENGTH),Lf=Hu(Nf,Nf.REFLECTIVITY),Of=Hu(Nf,Nf.ROUGHNESS),Vf=Hu(Nf,Nf.METALNESS),Df=Hu(Nf,Nf.NORMAL).context({getUV:null}),kf=Hu(Nf,Nf.CLEARCOAT),Gf=Hu(Nf,Nf.CLEARCOAT_ROUGHNESS),Wf=Hu(Nf,Nf.CLEARCOAT_NORMAL).context({getUV:null}),Hf=Hu(Nf,Nf.ROTATION),jf=Hu(Nf,Nf.SHEEN),qf=Hu(Nf,Nf.SHEEN_ROUGHNESS),$f=Hu(Nf,Nf.ANISOTROPY),Xf=Hu(Nf,Nf.IRIDESCENCE),Yf=Hu(Nf,Nf.IRIDESCENCE_IOR),Jf=Hu(Nf,Nf.IRIDESCENCE_THICKNESS),Zf=Hu(Nf,Nf.TRANSMISSION),Kf=Hu(Nf,Nf.THICKNESS),Qf=Hu(Nf,Nf.IOR),ey=Hu(Nf,Nf.ATTENUATION_DISTANCE),ty=Hu(Nf,Nf.ATTENUATION_COLOR),sy=Hu(Nf,Nf.LINE_SCALE),iy=Hu(Nf,Nf.LINE_DASH_SIZE),ry=Hu(Nf,Nf.LINE_GAP_SIZE),ny=Hu(Nf,Nf.LINE_WIDTH),oy=Hu(Nf,Nf.LINE_DASH_OFFSET),ay=Hu(Nf,Nf.POINT_WIDTH),hy=Hu(Nf,Nf.DISPERSION),ly=Hu(Nf,Nf.LIGHT_MAP),uy=Hu(Nf,Nf.AO_MAP);Hu(Nf,Nf.REFRACTION_RATIO);const cy=Cc(new Qs).onReference((function(e){return e.material})).onRenderUpdate((function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))}));class dy extends iu{constructor(e=null){super("vec4"),this.positionNode=e}setup(e){if("fragment"===e.shaderStage)return em(e.context.mvp);const t=this.positionNode||bg;return Ym.mul(cg).mul(t)}}Ql("ModelViewProjection",dy);const py=Wu(dy);class my extends Kl{constructor(e){super("uint"),this.scope=e,this.isInstanceIndexNode=!0}generate(e){const t=this.getNodeType(e),s=this.scope;let i,r;if(s===my.VERTEX)i=e.getVertexIndex();else if(s===my.INSTANCE)i=e.getInstanceIndex();else if(s===my.DRAW)i=e.getDrawIndex();else{if(s!==my.INVOCATION_LOCAL)throw new Error("THREE.IndexNode: Unknown scope: "+s);i=e.getInvocationLocalIndex()}if("vertex"===e.shaderStage||"compute"===e.shaderStage)r=i;else{r=em(this).build(e,t)}return r}}my.VERTEX="vertex",my.INSTANCE="instance",my.INVOCATION_LOCAL="invocationLocal",my.DRAW="draw",Ql("Index",my);const gy=Hu(my,my.VERTEX),fy=Hu(my,my.INSTANCE),yy=Hu(my,my.INVOCATION_LOCAL),xy=Hu(my,my.DRAW);class by extends oo{constructor(e,t,s=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=s}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class vy extends Kl{constructor(e){super("void"),this.instanceMesh=e,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=Hl.FRAME,this.buffer=null,this.bufferColor=null}setup(e){let t=this.instanceMatrixNode,s=this.instanceColorNode;const i=this.instanceMesh;if(null===t){const e=i.instanceMatrix;if(i.count<=1e3)t=jg(e.array,"mat4",i.count).element(fy);else{const s=new by(e.array,16,1);this.buffer=s;const i=e.usage===Cs?ym:fm,r=[i(s,"vec4",16,0),i(s,"vec4",16,4),i(s,"vec4",16,8),i(s,"vec4",16,12)];t=fc(...r)}this.instanceMatrixNode=t}const r=i.instanceColor;if(r&&null===s){const e=new Ho(r.array,3),t=r.usage===Cs?ym:fm;this.bufferColor=e,s=oc(t(e,"vec3",3,0)),this.instanceColorNode=s}const n=t.mul(bg).xyz;if(bg.assign(n),e.hasGeometryAttribute("normal")){const e=gc(t),s=Cg.div(oc(e[0].dot(e[0]),e[1].dot(e[1]),e[2].dot(e[2]))),i=e.mul(s).xyz;Cg.assign(i)}null!==this.instanceColorNode&&Ic("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMesh.instanceMatrix.usage!==Cs&&null!=this.buffer&&this.instanceMesh.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMesh.instanceMatrix.version),this.instanceMesh.instanceColor&&this.instanceMesh.instanceColor.usage!==Cs&&null!=this.bufferColor&&this.instanceMesh.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceMesh.instanceColor.version)}}Ql("Instance",vy);const Ty=Wu(vy);class _y extends Kl{constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){null===this.batchingIdNode&&(null===e.getDrawIndex()?this.batchingIdNode=fy:this.batchingIdNode=xy);const t=ju((([e])=>{const t=Om(Wm(this.batchMesh._indirectTexture),0),s=Qu(e).modInt(Qu(t)),i=Qu(e).div(Qu(t));return Wm(this.batchMesh._indirectTexture,ic(s,i)).x})).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]}),s=t(Qu(this.batchingIdNode)),i=this.batchMesh._matricesTexture,r=Om(Wm(i),0),n=Ku(s).mul(4).toInt().toVar(),o=n.modInt(r),a=n.div(Qu(r)),h=fc(Wm(i,ic(o,a)),Wm(i,ic(o.add(1),a)),Wm(i,ic(o.add(2),a)),Wm(i,ic(o.add(3),a))),l=this.batchMesh._colorsTexture;if(null!==l){const e=ju((([e])=>{const t=Om(Wm(l),0).x,s=e,i=s.modInt(t),r=s.div(t);return Wm(l,ic(i,r)).rgb})).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]}),t=e(s);Ic("vec3","vBatchColor").assign(t)}const u=gc(h);bg.assign(h.mul(bg));const c=Cg.div(oc(u[0].dot(u[0]),u[1].dot(u[1]),u[2].dot(u[2]))),d=u.mul(c).xyz;Cg.assign(d),e.hasGeometryAttribute("tangent")&&sf.mulAssign(u)}}Ql("Batch",_y);const wy=Wu(_y),Sy=new WeakMap;class My extends Kl{constructor(e,t=!1){let s,i,r;super("void"),this.skinnedMesh=e,this.useReference=t,this.updateType=Hl.OBJECT,this.skinIndexNode=zm("skinIndex","uvec4"),this.skinWeightNode=zm("skinWeight","vec4"),t?(s=Zg("bindMatrix","mat4"),i=Zg("bindMatrixInverse","mat4"),r=Kg("skeleton.boneMatrices","mat4",e.skeleton.bones.length)):(s=Cc(e.bindMatrix,"mat4"),i=Cc(e.bindMatrixInverse,"mat4"),r=jg(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length)),this.bindMatrixNode=s,this.bindMatrixInverseNode=i,this.boneMatricesNode=r,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=bg){const{skinIndexNode:s,skinWeightNode:i,bindMatrixNode:r,bindMatrixInverseNode:n}=this,o=e.element(s.x),a=e.element(s.y),h=e.element(s.z),l=e.element(s.w),u=r.mul(t),c=dd(o.mul(i.x).mul(u),a.mul(i.y).mul(u),h.mul(i.z).mul(u),l.mul(i.w).mul(u));return n.mul(c).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=Cg){const{skinIndexNode:s,skinWeightNode:i,bindMatrixNode:r,bindMatrixInverseNode:n}=this,o=e.element(s.x),a=e.element(s.y),h=e.element(s.z),l=e.element(s.w);let u=dd(i.x.mul(o),i.y.mul(a),i.z.mul(h),i.w.mul(l));return u=n.mul(u).mul(r),u.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return null===this.previousBoneMatricesNode&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=Kg("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,vg)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")}setup(e){this.needsPreviousBoneMatrices(e)&&vg.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(bg.assign(t),e.hasGeometryAttribute("normal")){const t=this.getSkinnedNormal();Cg.assign(t),e.hasGeometryAttribute("tangent")&&sf.assign(t)}}generate(e,t){if("void"!==t)return bg.build(e,t)}update(e){const t=(this.useReference?e.object:this.skinnedMesh).skeleton;Sy.get(t)!==e.frameId&&(Sy.set(t,e.frameId),null!==this.previousBoneMatricesNode&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}}Ql("Skinning",My);const Ay=e=>Du(new My(e)),Ny=e=>Du(new My(e,!0));class Ry extends Kl{constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode("i".charCodeAt()+e)}getProperties(e){const t=e.getNodeProperties(this);if(void 0!==t.stackNode)return t;const s={};for(let e=0,t=this.params.length-1;eNumber(n)?">=":"<"));const u={start:r,end:n,condition:h},c=u.start,d=u.end;let p="",m="",g="";l||(l="int"===a||"uint"===a?h.includes("<")?"++":"--":h.includes("<")?"+= 1.":"-= 1."),p+=e.getVar(a,o)+" = "+c,m+=o+" "+h+" "+d,g+=o+" "+l;const f=`for ( ${p}; ${m}; ${g} )`;e.addFlowCode((0===t?"\n":"")+e.tab+f+" {\n\n").addFlowTab()}const r=i.build(e,"void"),n=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode("\n"+e.tab+r);for(let t=0,s=this.params.length-1;tDu(new Ry(Gu(e,"int"))).append(),Ey=()=>Rm("continue").append(),By=()=>Rm("break").append(),Iy=new WeakMap,Py=new _i,Fy=ju((({bufferMap:e,influence:t,stride:s,width:i,depth:r,offset:n})=>{const o=Qu(gy).mul(s).add(n),a=o.div(i),h=o.sub(a.mul(i));return Wm(e,ic(h,a)).depth(r).mul(t)}));class zy extends Kl{constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=Cc(1),this.updateType=Hl.OBJECT}setup(e){const{geometry:t}=e,s=void 0!==t.morphAttributes.position,i=t.hasAttribute("normal")&&void 0!==t.morphAttributes.normal,r=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,n=void 0!==r?r.length:0,{texture:o,stride:a,size:h}=function(e){const t=void 0!==e.morphAttributes.position,s=void 0!==e.morphAttributes.normal,i=void 0!==e.morphAttributes.color,r=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,n=void 0!==r?r.length:0;let o=Iy.get(e);if(void 0===o||o.count!==n){void 0!==o&&o.texture.dispose();const a=e.morphAttributes.position||[],h=e.morphAttributes.normal||[],l=e.morphAttributes.color||[];let u=0;!0===t&&(u=1),!0===s&&(u=2),!0===i&&(u=3);let c=e.attributes.position.count*u,d=1;const p=4096;c>p&&(d=Math.ceil(c/p),c=p);const m=new Float32Array(c*d*4*n),g=new Mi(m,c,d,n);g.type=Ie,g.needsUpdate=!0;const f=4*u;for(let x=0;x{const t=Ku(0).toVar();this.mesh.count>1&&null!==this.mesh.morphTexture&&void 0!==this.mesh.morphTexture?t.assign(Wm(this.mesh.morphTexture,ic(Qu(e).add(1),Qu(fy))).r):t.assign(Zg("morphTargetInfluences","float").element(e).toVar()),!0===s&&bg.addAssign(Fy({bufferMap:o,influence:t,stride:a,width:l,depth:e,offset:Qu(0)})),!0===i&&Cg.addAssign(Fy({bufferMap:o,influence:t,stride:a,width:l,depth:e,offset:Qu(1)}))}))}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce(((e,t)=>e+t),0)}}Ql("Morph",zy);const Uy=Wu(zy),Ly=(e,t)=>{for(const s of t)if(s.isAnalyticLightNode&&s.light.id===e)return s;return null};class Oy extends Kl{constructor(e=[]){super("vec3"),this.totalDiffuseNode=oc().toVar("totalDiffuse"),this.totalSpecularNode=oc().toVar("totalSpecular"),this.outgoingLightNode=oc().toVar("outgoingLight"),this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this.global=!0}getHash(e){if(null===this._lightNodesHash){null===this._lightNodes&&this.setupLightsNode(e);const t=[];for(const e of this._lightNodes)t.push(e.getHash());this._lightNodesHash="lights-"+t.join(",")}return this._lightNodesHash}analyze(e){const t=e.getDataFromNode(this);for(const s of t.nodes)s.build(e)}setupLightsNode(e){const t=[],s=this._lightNodes,i=(e=>e.sort(((e,t)=>e.id-t.id)))(this._lights),r=e.renderer.nodes.library;for(const e of i)if(e.isNode)t.push(Du(e));else{let i=null;if(null!==s&&(i=Ly(e.id,s)),null===i){const s=r.getLightNodeClass(e.constructor);if(void 0===s){console.warn(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}t.push(Du(new s(e)))}}this._lightNodes=t}setup(e){null===this._lightNodes&&this.setupLightsNode(e);const t=e.context,s=t.lightingModel;let i=this.outgoingLightNode;if(s){const{_lightNodes:r,totalDiffuseNode:n,totalSpecularNode:o}=this;t.outgoingLight=i;const a=e.addStack();e.getDataFromNode(this).nodes=a.nodes,s.start(t,a,e);for(const t of r)t.build(e);s.indirect(t,a,e);const{backdrop:h,backdropAlpha:l}=t,{directDiffuse:u,directSpecular:c,indirectDiffuse:d,indirectSpecular:p}=t.reflectedLight;let m=u.add(d);null!==h&&(m=oc(null!==l?l.mix(m,h):h),t.material.transparent=!0),n.assign(m),o.assign(c.add(p)),i.assign(n.add(o)),s.finish(t,a,e),i=i.bypass(e.removeStack())}return i}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}}Ql("Lights",Oy);const Vy=Wu(Oy);class Dy extends Kl{constructor(){super("vec3"),this.isLightingNode=!0}generate(){console.warn("Abstract function.")}}Ql("Lighting",Dy);class ky extends Dy{constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}Ql("AO",ky);class Gy extends Xp{constructor(e,t=null,s=null,i=null){super(e),this.lightingModel=t,this.backdropNode=s,this.backdropAlphaNode=i,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,s={directDiffuse:oc().toVar("directDiffuse"),directSpecular:oc().toVar("directSpecular"),indirectDiffuse:oc().toVar("indirectDiffuse"),indirectSpecular:oc().toVar("indirectSpecular")};return{radiance:oc().toVar("radiance"),irradiance:oc().toVar("irradiance"),iblIrradiance:oc().toVar("iblIrradiance"),ambientOcclusion:Ku(1).toVar("ambientOcclusion"),reflectedLight:s,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}Ql("LightingContext",Gy);const Wy=Wu(Gy);class Hy extends Dy{constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let jy,qy;Ql("Irradiance",Hy);class $y extends Kl{constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===$y.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=Hl.NONE;return this.scope!==$y.RESOLUTION&&this.scope!==$y.VIEWPORT||(e=Hl.RENDER),this.updateType=e,e}update({renderer:e}){this.scope===$y.VIEWPORT?e.getViewport(qy):e.getDrawingBufferSize(jy)}setup(){const e=this.scope;let t=null;return t=e===$y.RESOLUTION?Cc(jy||(jy=new Qs)):e===$y.VIEWPORT?Cc(qy||(qy=new _i)):sc(Xy.div(Yy)),t}generate(e){if(this.scope===$y.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const s=e.getNodeProperties(Yy).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${s}.y - ${t}.y )`}return t}return super.generate(e)}}$y.COORDINATE="coordinate",$y.RESOLUTION="resolution",$y.VIEWPORT="viewport",$y.UV="uv",Ql("Viewport",$y);const Xy=Hu($y,$y.COORDINATE),Yy=Hu($y,$y.RESOLUTION),Jy=Hu($y,$y.VIEWPORT),Zy=Hu($y,$y.UV),Ky=ju((()=>(console.warn('TSL.ViewportNode: "viewportTopLeft" is deprecated. Use "viewportUV" instead.'),Zy)),"vec2").once()(),Qy=ju((()=>(console.warn('TSL.ViewportNode: "viewportBottomLeft" is deprecated. Use "viewportUV.flipY()" instead.'),Zy.flipY())),"vec2").once()(),ex=new Qs;class tx extends km{constructor(e=Zy,t=null,s=null){null===s&&((s=new Xa).minFilter=Se),super(s,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=Hl.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(ex);const s=this.value;s.image.width===ex.width&&s.image.height===ex.height||(s.image.width=ex.width,s.image.height=ex.height,s.needsUpdate=!0);const i=s.generateMipmaps;s.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(s),s.generateMipmaps=i}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}Ql("ViewportTexture",tx);const sx=Wu(tx),ix=Wu(tx,null,null,{generateMipmaps:!0});let rx=null;class nx extends tx{constructor(e=Zy,t=null){null===rx&&(rx=new Qa),super(e,t,rx)}}Ql("ViewportDepthTexture",nx);const ox=Wu(nx);class ax extends Kl{constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===ax.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,s=this.valueNode;let i=null;if(t===ax.DEPTH_BASE)null!==s&&(i=dx().assign(s));else if(t===ax.DEPTH)i=e.isPerspectiveCamera?ux(wg.z,qm,$m):hx(wg.z,qm,$m);else if(t===ax.LINEAR_DEPTH)if(null!==s)if(e.isPerspectiveCamera){const e=cx(s,qm,$m);i=hx(e,qm,$m)}else i=s;else i=hx(wg.z,qm,$m);return i}}ax.DEPTH_BASE="depthBase",ax.DEPTH="depth",ax.LINEAR_DEPTH="linearDepth",Ql("ViewportDepth",ax);const hx=(e,t,s)=>e.add(t).div(t.sub(s)),lx=(e,t,s)=>t.sub(s).mul(e).sub(t),ux=(e,t,s)=>t.add(e).mul(s).div(s.sub(t).mul(e)),cx=(e,t,s)=>t.mul(s).div(s.sub(t).mul(e).sub(s)),dx=Wu(ax,ax.DEPTH_BASE),px=Hu(ax,ax.DEPTH),mx=Wu(ax,ax.LINEAR_DEPTH),gx=mx(ox());px.assign=e=>dx(e);class fx extends Kl{constructor(e=fx.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{localClipIntersection:s,localClippingCount:i,globalClippingCount:r}=t,n=r+i,o=s?n-i:n;return this.scope===fx.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(t.planes,n,o):this.setupDefault(t.planes,n,o)}setupAlphaToCoverage(e,t,s){return ju((()=>{const i=Xg(e),r=Bc("float","distanceToPlane"),n=Bc("float","distanceToGradient"),o=Bc("float","clipOpacity");let a;if(o.assign(1),Cy(s,(({i:e})=>{a=i.element(e),r.assign(wg.dot(a.xyz).negate().add(a.w)),n.assign(r.fwidth().div(2)),o.mulAssign(Dp(n.negate(),n,r)),o.equal(0).discard()})),s{a=i.element(t),r.assign(wg.dot(a.xyz).negate().add(a.w)),n.assign(r.fwidth().div(2)),e.mulAssign(Dp(n.negate(),n,r).oneMinus())})),o.mulAssign(e.oneMinus())}Pc.a.mulAssign(o),Pc.a.equal(0).discard()}))()}setupDefault(e,t,s){return ju((()=>{const i=Xg(e);let r;if(Cy(s,(({i:e})=>{r=i.element(e),wg.dot(r.xyz).greaterThan(r.w).discard()})),s{r=i.element(t),e.assign(wg.dot(r.xyz).greaterThan(r.w).and(e))})),e.discard()}}))()}}fx.ALPHA_TO_COVERAGE="alphaToCoverage",fx.DEFAULT="default",Ql("Clipping",fx);class yx extends Kr{constructor(){super(),this.isNodeMaterial=!0,this.type=this.constructor.type,this.forceSinglePass=!1,this.fog=!0,this.lights=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.positionNode=null,this.depthNode=null,this.shadowNode=null,this.shadowPositionNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null}customProgramCacheKey(){return this.type+Ul(this)}build(e){this.setup(e)}setup(e){let t;e.context.setupNormal=()=>this.setupNormal(e),e.addStack(),e.stack.outputNode=this.vertexNode||this.setupPosition(e),e.addFlow("vertex",e.removeStack()),e.addStack();const s=this.setupClipping(e);if(!0===this.depthWrite&&this.setupDepth(e),null===this.fragmentNode){this.setupDiffuseColor(e),this.setupVariants(e);const i=this.setupLighting(e);null!==s&&e.stack.add(s);const r=uc(i,Pc.a).max(0);t=this.setupOutput(e,r),Zc.assign(t),null!==this.outputNode&&(t=this.outputNode);if(null!==e.renderer.getRenderTarget()){const s=e.renderer.getMRT(),i=this.mrtNode;null!==s?(t=s,null!==i&&(t=s.merge(i))):null!==i&&(t=i)}}else{let s=this.fragmentNode;!0!==s.isOutputStructNode&&(s=uc(s)),t=this.setupOutput(e,s)}e.stack.outputNode=t,e.addFlow("fragment",e.removeStack())}setupClipping(e){if(null===e.clippingContext)return null;const{globalClippingCount:t,localClippingCount:s}=e.clippingContext;let i=null;return(t||s)&&(this.alphaToCoverage?i=Du(new fx(fx.ALPHA_TO_COVERAGE)):e.stack.add(Du(new fx))),i}setupDepth(e){const{renderer:t}=e;let s=this.depthNode;if(null===s){const e=t.getMRT();if(e&&e.has("depth"))s=e.get("depth");else if(!0===t.logarithmicDepthBuffer){s=py().w.add(1).log2().mul(Xm).mul(.5)}}null!==s&&px.assign(s).append()}setupPosition(e){const{object:t}=e,s=t.geometry;if(e.addStack(),(s.morphAttributes.position||s.morphAttributes.normal||s.morphAttributes.color)&&Uy(t).append(),!0===t.isSkinnedMesh&&Ny(t).append(),this.displacementMap){const e=ef("displacementMap","texture"),t=ef("displacementScale","float"),s=ef("displacementBias","float");bg.addAssign(Cg.normalize().mul(e.x.mul(t).add(s)))}t.isBatchedMesh&&wy(t).append(),t.instanceMatrix&&!0===t.instanceMatrix.isInstancedBufferAttribute&&Ty(t).append(),null!==this.positionNode&&bg.assign(this.positionNode);const i=py();return e.context.vertex=e.removeStack(),e.context.mvp=i,i}setupDiffuseColor({object:e,geometry:t}){let s=this.colorNode?uc(this.colorNode):Cf;if(!0===this.vertexColors&&t.hasAttribute("color")&&(s=uc(s.xyz.mul(zm("color","vec3")),s.a)),e.instanceColor){s=Ic("vec3","vInstanceColor").mul(s)}if(e.isBatchedMesh&&e._colorsTexture){s=Ic("vec3","vBatchColor").mul(s)}Pc.assign(s);const i=this.opacityNode?Ku(this.opacityNode):If;if(Pc.a.assign(Pc.a.mul(i)),null!==this.alphaTestNode||this.alphaTest>0){const e=null!==this.alphaTestNode?Ku(this.alphaTestNode):Rf;Pc.a.lessThanEqual(e).discard()}!1===this.transparent&&1===this.blending&&!1===this.alphaToCoverage&&Pc.a.assign(1)}setupVariants(){}setupOutgoingLight(){return!0===this.lights?oc(0):Pc.rgb}setupNormal(){return this.normalNode?oc(this.normalNode):Df}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?ef("envMap","cubeTexture"):ef("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new Hy(ly)),t}setupLights(e){const t=[],s=this.setupEnvironment(e);s&&s.isLightingNode&&t.push(s);const i=this.setupLightMap(e);if(i&&i.isLightingNode&&t.push(i),null!==this.aoNode||e.material.aoMap){const e=null!==this.aoNode?this.aoNode:uy;t.push(new ky(e))}let r=this.lightsNode||e.lightsNode;return t.length>0&&(r=Vy([...r.getLights(),...t])),r}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:s,backdropAlphaNode:i,emissiveNode:r}=this,n=!0===this.lights||null!==this.lightsNode?this.setupLights(e):null;let o=this.setupOutgoingLight(e);if(n&&n.getScope().getLights().length>0){const t=this.setupLightingModel(e);o=Wy(n,t,s,i)}else null!==s&&(o=oc(null!==i?Up(o,s,i):s));return(r&&!0===r.isNode||t.emissive&&!0===t.emissive.isColor)&&(Fc.assign(oc(r||Bf)),o=o.add(Fc)),o}setupOutput(e,t){if(!0===this.fog){const s=e.fogNode;s&&(t=uc(s.mix(t.rgb,s.colorNode),t.a))}return t}setDefaultValues(e){for(const t in e){const s=e[t];void 0===this[t]&&(this[t]=s,s&&s.clone&&(this[t]=s.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const e in t)void 0===Object.getOwnPropertyDescriptor(this.constructor.prototype,e)&&void 0!==t[e].get&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{},nodes:{}});const s=Kr.prototype.toJSON.call(this,e),i=Ll(this);s.inputNodes={};for(const{property:t,childNode:r}of i)s.inputNodes[t]=r.toJSON(e).uuid;function r(e){const t=[];for(const s in e){const i=e[s];delete i.metadata,t.push(i)}return t}if(t){const t=r(e.textures),i=r(e.images),n=r(e.nodes);t.length>0&&(s.textures=t),i.length>0&&(s.images=i),n.length>0&&(s.nodes=n)}return s}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.positionNode=e.positionNode,this.depthNode=e.depthNode,this.shadowNode=e.shadowNode,this.shadowPositionNode=e.shadowPositionNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const xx=new Va;class bx extends yx{constructor(e={}){super(),this.lights=!1,this.useAlphaToCoverage=!0,this.useColor=e.vertexColors,this.pointWidth=1,this.pointColorNode=null,this.setDefaultValues(xx),this.setupShaders(),this.setValues(e)}setup(e){this.setupShaders(),super.setup(e)}setupShaders(){const e=this.alphaToCoverage,t=this.useColor;this.vertexNode=ju((()=>{em(sc(),"vUv").assign(Um());const e=zm("instancePosition"),t=Bc("vec4","mvPos");t.assign(cg.mul(uc(e,1)));const s=Jy.z.div(Jy.w),i=Ym.mul(t),r=Bc("vec2","offset");return r.assign(xg.xy),r.assign(r.mul(ay)),r.assign(r.div(Jy.z)),r.y.assign(r.y.mul(s)),r.assign(r.mul(i.w)),i.assign(i.add(uc(r,0,0))),i}))(),this.fragmentNode=ju((()=>{const s=em(sc(),"vUv"),i=Bc("float","alpha");i.assign(1);const r=s.x,n=s.y,o=r.mul(r).add(n.mul(n));if(e){const e=Bc("float","dlen");e.assign(o.fwidth()),i.assign(Dp(e.oneMinus(),e.add(1),o).oneMinus())}else o.greaterThan(1).discard();let a;if(this.pointColorNode)a=this.pointColorNode;else if(t){a=zm("instanceColor").mul(Cf)}else a=Cf;return uc(a,i)}))()}get alphaToCoverage(){return this.useAlphaToCoverage}set alphaToCoverage(e){this.useAlphaToCoverage!==e&&(this.useAlphaToCoverage=e,this.needsUpdate=!0)}}const vx=new Ma;class Tx extends yx{constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.lights=!1,this.setDefaultValues(vx),this.setValues(e)}}const _x=new zl;class wx extends yx{constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.lights=!1,this.setDefaultValues(_x),this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode,t=this.dashScaleNode?Ku(this.dashScaleNode):sy,s=this.dashSizeNode?Ku(this.dashSizeNode):iy,i=this.dashSizeNode?Ku(this.dashGapNode):ry;Kc.assign(s),Qc.assign(i);const r=em(zm("lineDistance").mul(t));(e?r.add(e):r).mod(Kc.add(Qc)).greaterThan(Kc).discard()}}const Sx=new zl;class Mx extends yx{constructor(e={}){super(),this.lights=!1,this.setDefaultValues(Sx),this.useAlphaToCoverage=!0,this.useColor=e.vertexColors,this.useDash=e.dashed,this.useWorldUnits=!1,this.dashOffset=0,this.lineWidth=1,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setup(e){this.setupShaders(),super.setup(e)}setupShaders(){const e=this.alphaToCoverage,t=this.useColor,s=this.dashed,i=this.worldUnits,r=ju((({start:e,end:t})=>{const s=Ym.element(2).element(2),i=Ym.element(3).element(2).mul(-.5).div(s).sub(e.z).div(t.z.sub(e.z));return uc(Up(e.xyz,t.xyz,i),t.w)}));this.vertexNode=ju((()=>{Ic("vec2","vUv").assign(Um());const e=zm("instanceStart"),t=zm("instanceEnd"),n=Bc("vec4","start"),o=Bc("vec4","end");n.assign(cg.mul(uc(e,1))),o.assign(cg.mul(uc(t,1))),i&&(Ic("vec3","worldStart").assign(n.xyz),Ic("vec3","worldEnd").assign(o.xyz));const a=Jy.z.div(Jy.w),h=Ym.element(2).element(3).equal(-1);Yu(h,(()=>{Yu(n.z.lessThan(0).and(o.z.greaterThan(0)),(()=>{o.assign(r({start:n,end:o}))})).ElseIf(o.z.lessThan(0).and(n.z.greaterThanEqual(0)),(()=>{n.assign(r({start:o,end:n}))}))}));const l=Ym.mul(n),u=Ym.mul(o),c=l.xyz.div(l.w),d=u.xyz.div(u.w),p=d.xy.sub(c.xy).toVar();p.x.assign(p.x.mul(a)),p.assign(p.normalize());const m=uc().toVar();if(i){const e=o.xyz.sub(n.xyz).normalize(),t=Up(n.xyz,o.xyz,.5).normalize(),i=e.cross(t).normalize(),r=e.cross(i),a=Ic("vec4","worldPos");a.assign(xg.y.lessThan(.5).select(n,o));const h=ny.mul(.5);a.addAssign(uc(xg.x.lessThan(0).select(i.mul(h),i.mul(h).negate()),0)),s||(a.addAssign(uc(xg.y.lessThan(.5).select(e.mul(h).negate(),e.mul(h)),0)),a.addAssign(uc(r.mul(h),0)),Yu(xg.y.greaterThan(1).or(xg.y.lessThan(0)),(()=>{a.subAssign(uc(r.mul(2).mul(h),0))}))),m.assign(Ym.mul(a));const l=oc().toVar();l.assign(xg.y.lessThan(.5).select(c,d)),m.z.assign(l.z.mul(m.w))}else{const e=Bc("vec2","offset");e.assign(sc(p.y,p.x.negate())),p.x.assign(p.x.div(a)),e.x.assign(e.x.div(a)),e.assign(xg.x.lessThan(0).select(e.negate(),e)),Yu(xg.y.lessThan(0),(()=>{e.assign(e.sub(p))})).ElseIf(xg.y.greaterThan(1),(()=>{e.assign(e.add(p))})),e.assign(e.mul(ny)),e.assign(e.div(Jy.w)),m.assign(xg.y.lessThan(.5).select(l,u)),e.assign(e.mul(m.w)),m.assign(m.add(uc(e,0,0)))}return m}))();const n=ju((({p1:e,p2:t,p3:s,p4:i})=>{const r=e.sub(s),n=i.sub(s),o=t.sub(e),a=r.dot(n),h=n.dot(o),l=r.dot(o),u=n.dot(n),c=o.dot(o).mul(u).sub(h.mul(h)),d=a.mul(h).sub(l.mul(u)).div(c).clamp(),p=a.add(h.mul(d)).div(u).clamp();return sc(d,p)}));this.fragmentNode=ju((()=>{const r=Ic("vec2","vUv");if(s){const e=this.offsetNode?Ku(this.offsetNodeNode):oy,t=this.dashScaleNode?Ku(this.dashScaleNode):sy,s=this.dashSizeNode?Ku(this.dashSizeNode):iy,i=this.dashSizeNode?Ku(this.dashGapNode):ry;Kc.assign(s),Qc.assign(i);const n=zm("instanceDistanceStart"),o=zm("instanceDistanceEnd"),a=xg.y.lessThan(.5).select(t.mul(n),sy.mul(o)),h=em(a.add(oy)),l=e?h.add(e):h;r.y.lessThan(-1).or(r.y.greaterThan(1)).discard(),l.mod(Kc.add(Qc)).greaterThan(Kc).discard()}const o=Bc("float","alpha");if(o.assign(1),i){const t=Ic("vec3","worldStart"),i=Ic("vec3","worldEnd"),r=Ic("vec4","worldPos").xyz.normalize().mul(1e5),a=i.sub(t),h=n({p1:t,p2:i,p3:oc(0,0,0),p4:r}),l=t.add(a.mul(h.x)),u=r.mul(h.y),c=l.sub(u).length().div(ny);if(!s)if(e){const e=c.fwidth();o.assign(Dp(e.negate().add(.5),e.add(.5),c).oneMinus())}else c.greaterThan(.5).discard()}else if(e){const e=r.x,t=r.y.greaterThan(0).select(r.y.sub(1),r.y.add(1)),s=e.mul(e).add(t.mul(t)),i=Bc("float","dlen");i.assign(s.fwidth()),Yu(r.y.abs().greaterThan(1),(()=>{o.assign(Dp(i.oneMinus(),i.add(1),s).oneMinus())}))}else Yu(r.y.abs().greaterThan(1),(()=>{const e=r.x,t=r.y.greaterThan(0).select(r.y.sub(1),r.y.add(1));e.mul(e).add(t.mul(t)).greaterThan(1).discard()}));let a;if(this.lineColorNode)a=this.lineColorNode;else if(t){const e=zm("instanceColorStart"),t=zm("instanceColorEnd");a=xg.y.lessThan(.5).select(e,t).mul(Cf)}else a=Cf;return uc(a,o)}))()}get worldUnits(){return this.useWorldUnits}set worldUnits(e){this.useWorldUnits!==e&&(this.useWorldUnits=e,this.needsUpdate=!0)}get dashed(){return this.useDash}set dashed(e){this.useDash!==e&&(this.useDash=e,this.needsUpdate=!0)}get alphaToCoverage(){return this.useAlphaToCoverage}set alphaToCoverage(e){this.useAlphaToCoverage!==e&&(this.useAlphaToCoverage=e,this.needsUpdate=!0)}}const Ax=e=>Du(e).mul(.5).add(.5),Nx=e=>Du(e).mul(2).sub(1),Rx=new El;class Cx extends yx{constructor(e){super(),this.lights=!1,this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(Rx),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?Ku(this.opacityNode):If;Pc.assign(uc(Ax(Fg),e))}}class Ex extends iu{constructor(e=_g){super("vec2"),this.dirNode=e}setup(){const e=this.dirNode,t=e.z.atan2(e.x).mul(1/(2*Math.PI)).add(.5),s=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return sc(t,s)}}Ql("EquirectUV",Ex);const Bx=Wu(Ex);class Ix extends so{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const s=t.minFilter,i=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const r=new jn(5,5,5),n=Bx(_g),o=new yx;o.colorNode=Gm(t,n,0),o.side=d,o.blending=m;const a=new Wn(r,o),h=new no;h.add(a),t.minFilter===Se&&(t.minFilter=Te);const l=new eo(1,10,this),u=e.getMRT();return e.setMRT(null),l.update(e,h),e.setMRT(u),t.minFilter=s,t.currentGenerateMipmaps=i,a.geometry.dispose(),a.material.dispose(),this}}const Px=new WeakMap;class Fx extends iu{constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=Wg();const t=new to;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=Hl.RENDER}updateBefore(e){const{renderer:t,material:s}=e,i=this.envNode;if(i.isTextureNode||i.isMaterialReferenceNode){const e=i.isTextureNode?i.value:s[i.property];if(e&&e.isTexture){const s=e.mapping;if(s===ue||s===ce){if(Px.has(e)){const t=Px.get(e);Ux(t,e.mapping),this._cubeTexture=t}else{const s=e.image;if(function(e){return null!=e&&e.height>0}(s)){const i=new Ix(s.height);i.fromEquirectangularTexture(t,e),Ux(i.texture,e.mapping),this._cubeTexture=i.texture,Px.set(e,i.texture),e.addEventListener("dispose",zx)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function zx(e){const t=e.target;t.removeEventListener("dispose",zx);const s=Px.get(t);void 0!==s&&(Px.delete(t),s.dispose())}function Ux(e,t){t===ue?e.mapping=he:t===ce&&(e.mapping=le)}Ql("CubeMap",Fx);const Lx=Wu(Fx);class Ox extends Dy{constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=Lx(this.envNode)}}Ql("BasicEnvironment",Ox);class Vx extends Dy{constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=Ku(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}Ql("BasicLightMap",Vx);class Dx{start(){}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class kx extends Dx{constructor(){super()}indirect(e,t,s){const i=e.ambientOcclusion,r=e.reflectedLight,n=s.context.irradianceLightMap;r.indirectDiffuse.assign(uc(0)),n?r.indirectDiffuse.addAssign(n):r.indirectDiffuse.addAssign(uc(1,1,1,0)),r.indirectDiffuse.mulAssign(i),r.indirectDiffuse.mulAssign(Pc.rgb)}finish(e,t,s){const i=s.material,r=e.outgoingLight,n=s.context.environment;if(n)switch(i.combine){case 0:r.rgb.assign(Up(r.rgb,r.rgb.mul(n.rgb),Uf.mul(Lf)));break;case 1:r.rgb.assign(Up(r.rgb,n.rgb,Uf.mul(Lf)));break;case 2:r.rgb.addAssign(n.rgb.mul(Uf.mul(Lf)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",i.combine)}}}const Gx=new Qr;class Wx extends yx{constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Gx),this.setValues(e)}setupNormal(){return Ig}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Ox(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new Vx(ly)),t}setupOutgoingLight(){return Pc.rgb}setupLightingModel(){return new kx}}const Hx=ju((({f0:e,f90:t,dotVH:s})=>{const i=s.mul(-5.55473).sub(6.98316).mul(s).exp2();return e.mul(i.oneMinus()).add(t.mul(i))})),jx=ju((e=>e.diffuseColor.mul(1/Math.PI))),qx=ju((({dotNH:e})=>Jc.mul(Ku(.5)).add(1).mul(Ku(1/Math.PI)).mul(e.pow(Jc)))),$x=ju((({lightDirection:e})=>{const t=e.add(Sg).normalize(),s=Fg.dot(t).clamp(),i=Sg.dot(t).clamp(),r=Hx({f0:Xc,f90:1,dotVH:i}),n=Ku(.25),o=qx({dotNH:s});return r.mul(n).mul(o)}));class Xx extends kx{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:s}){const i=Fg.dot(e).clamp().mul(t);s.directDiffuse.addAssign(i.mul(jx({diffuseColor:Pc.rgb}))),!0===this.specular&&s.directSpecular.addAssign(i.mul($x({lightDirection:e})).mul(Uf))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:s}){s.indirectDiffuse.addAssign(t.mul(jx({diffuseColor:Pc}))),s.indirectDiffuse.mulAssign(e)}}const Yx=new Bl;class Jx extends yx{constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Yx),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Ox(t):null}setupLightingModel(){return new Xx(!1)}}const Zx=new Rl;class Kx extends yx{constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(Zx),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Ox(t):null}setupLightingModel(){return new Xx}setupVariants(){const e=(this.shininessNode?Ku(this.shininessNode):Ef).max(1e-4);Jc.assign(e);const t=this.specularNode||Pf;Xc.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const Qx=ju((()=>{const e=Ig.dFdx().abs().max(Ig.dFdy().abs());return e.x.max(e.y).max(e.z)})),eb=ju((e=>{const{roughness:t}=e,s=Qx();let i=t.max(.0525);return i=i.add(s),i=i.min(1),i})),tb=ju((({alpha:e,dotNL:t,dotNV:s})=>{const i=e.pow2(),r=t.mul(i.add(i.oneMinus().mul(s.pow2())).sqrt()),n=s.mul(i.add(i.oneMinus().mul(t.pow2())).sqrt());return gd(.5,r.add(n).max(zd))})).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),sb=ju((({alphaT:e,alphaB:t,dotTV:s,dotBV:i,dotTL:r,dotBL:n,dotNV:o,dotNL:a})=>{const h=a.mul(oc(e.mul(s),t.mul(i),o).length()),l=o.mul(oc(e.mul(r),t.mul(n),a).length());return gd(.5,h.add(l)).saturate()})).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),ib=ju((({alpha:e,dotNH:t})=>{const s=e.pow2(),i=t.pow2().mul(s.oneMinus()).oneMinus();return s.div(i.pow2()).mul(1/Math.PI)})).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),rb=Ku(1/Math.PI),nb=ju((({alphaT:e,alphaB:t,dotNH:s,dotTH:i,dotBH:r})=>{const n=e.mul(t),o=oc(t.mul(i),e.mul(r),n.mul(s)),a=o.dot(o),h=n.div(a);return rb.mul(n.mul(h.pow2()))})).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),ob=ju((e=>{const{lightDirection:t,f0:s,f90:i,roughness:r,f:n,USE_IRIDESCENCE:o,USE_ANISOTROPY:a}=e,h=e.normalView||Fg,l=r.pow2(),u=t.add(Sg).normalize(),c=h.dot(t).clamp(),d=h.dot(Sg).clamp(),p=h.dot(u).clamp(),m=Sg.dot(u).clamp();let g,f,y=Hx({f0:s,f90:i,dotVH:m});if(Lu(o)&&(y=kc.mix(y,n)),Lu(a)){const e=qc.dot(t),s=qc.dot(Sg),i=qc.dot(u),r=$c.dot(t),n=$c.dot(Sg),o=$c.dot(u);g=sb({alphaT:Hc,alphaB:l,dotTV:s,dotBV:n,dotTL:e,dotBL:r,dotNV:d,dotNL:c}),f=nb({alphaT:Hc,alphaB:l,dotNH:p,dotTH:i,dotBH:o})}else g=tb({alpha:l,dotNL:c,dotNV:d}),f=ib({alpha:l,dotNH:p});return y.mul(g).mul(f)})),ab=ju((({roughness:e,dotNV:t})=>{const s=uc(-1,-.0275,-.572,.022),i=uc(1,.0425,1.04,-.04),r=e.mul(s).add(i),n=r.x.mul(r.x).min(t.mul(-9.28).exp2()).mul(r.x).add(r.y);return sc(-1.04,1.04).mul(n).add(r.zw)})).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),hb=ju((e=>{const{dotNV:t,specularColor:s,specularF90:i,roughness:r}=e,n=ab({dotNV:t,roughness:r});return s.mul(n.x).add(i.mul(n.y))})),lb=ju((({f:e,f90:t,dotVH:s})=>{const i=s.oneMinus().saturate(),r=i.mul(i),n=i.mul(r,r).clamp(0,.9999);return e.sub(oc(t).mul(n)).div(n.oneMinus())})).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),ub=ju((({roughness:e,dotNH:t})=>{const s=e.pow2(),i=Ku(1).div(s),r=t.pow2().oneMinus().max(.0078125);return Ku(2).add(i).mul(r.pow(i.mul(.5))).div(2*Math.PI)})).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),cb=ju((({dotNV:e,dotNL:t})=>Ku(1).div(Ku(4).mul(t.add(e).sub(t.mul(e)))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),db=ju((({lightDirection:e})=>{const t=e.add(Sg).normalize(),s=Fg.dot(e).clamp(),i=Fg.dot(Sg).clamp(),r=Fg.dot(t).clamp(),n=ub({roughness:Dc,dotNH:r}),o=cb({dotNV:i,dotNL:s});return Vc.mul(n).mul(o)})),pb=ju((({N:e,V:t,roughness:s})=>{const i=e.dot(t).saturate(),r=sc(s,i.oneMinus().sqrt());return r.assign(r.mul(.984375).add(.0078125)),r})).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),mb=ju((({f:e})=>{const t=e.length();return Tp(t.mul(t).add(e.z).div(t.add(1)),0)})).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),gb=ju((({v1:e,v2:t})=>{const s=e.dot(t),i=s.abs().toVar(),r=i.mul(.0145206).add(.4965155).mul(i).add(.8543985).toVar(),n=i.add(4.1616724).mul(i).add(3.417594).toVar(),o=r.div(n),a=s.greaterThan(0).select(o,Tp(s.mul(s).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(o));return e.cross(t).mul(a)})).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),fb=ju((({N:e,V:t,P:s,mInv:i,p0:r,p1:n,p2:o,p3:a})=>{const h=n.sub(r).toVar(),l=a.sub(r).toVar(),u=h.cross(l),c=oc().toVar();return Yu(u.dot(s.sub(r)).greaterThanEqual(0),(()=>{const h=t.sub(e.mul(t.dot(e))).normalize(),l=e.cross(h).negate(),u=i.mul(gc(h,l,e).transpose()).toVar(),d=u.mul(r.sub(s)).normalize().toVar(),p=u.mul(n.sub(s)).normalize().toVar(),m=u.mul(o.sub(s)).normalize().toVar(),g=u.mul(a.sub(s)).normalize().toVar(),f=oc(0).toVar();f.addAssign(gb({v1:d,v2:p})),f.addAssign(gb({v1:p,v2:m})),f.addAssign(gb({v1:m,v2:g})),f.addAssign(gb({v1:g,v2:d})),c.assign(oc(mb({f:f})))})),c})).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),yb=1/6,xb=e=>md(yb,md(e,md(e,e.negate().add(3)).sub(3)).add(1)),bb=e=>md(yb,md(e,md(e,md(3,e).sub(6))).add(4)),vb=e=>md(yb,md(e,md(e,md(-3,e).add(3)).add(3)).add(1)),Tb=e=>md(yb,Cp(e,3)),_b=e=>xb(e).add(bb(e)),wb=e=>vb(e).add(Tb(e)),Sb=e=>dd(-1,bb(e).div(xb(e).add(bb(e)))),Mb=e=>dd(1,Tb(e).div(vb(e).add(Tb(e)))),Ab=(e,t,s)=>{const i=e.uvNode,r=md(i,t.zw).add(.5),n=Jd(r),o=Qd(r),a=_b(o.x),h=wb(o.x),l=Sb(o.x),u=Mb(o.x),c=Sb(o.y),d=Mb(o.y),p=sc(n.x.add(l),n.y.add(c)).sub(.5).mul(t.xy),m=sc(n.x.add(u),n.y.add(c)).sub(.5).mul(t.xy),g=sc(n.x.add(l),n.y.add(d)).sub(.5).mul(t.xy),f=sc(n.x.add(u),n.y.add(d)).sub(.5).mul(t.xy),y=_b(o.y).mul(dd(a.mul(e.uv(p).level(s)),h.mul(e.uv(m).level(s)))),x=wb(o.y).mul(dd(a.mul(e.uv(g).level(s)),h.mul(e.uv(f).level(s))));return y.add(x)},Nb=ju((([e,t=Ku(3)])=>{const s=sc(e.size(Qu(t))),i=sc(e.size(Qu(t.add(1)))),r=gd(1,s),n=gd(1,i),o=Ab(e,uc(r,s),Jd(t)),a=Ab(e,uc(n,i),Zd(t));return Qd(t).mix(o,a)})),Rb=ju((([e,t,s,i,r])=>{const n=oc(Vp(t.negate(),Kd(e),gd(1,i))),o=oc(hp(r[0].xyz),hp(r[1].xyz),hp(r[2].xyz));return Kd(n).mul(s.mul(o))})).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),Cb=ju((([e,t])=>e.mul(Lp(t.mul(2).sub(2),0,1)))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),Eb=ix(),Bb=ju((([e,t,s])=>{const i=Eb.uv(e),r=$d(Ku(Yy.x)).mul(Cb(t,s));return Nb(i,r)})),Ib=ju((([e,t,s])=>(Yu(s.notEqual(0),(()=>{const i=qd(t).negate().div(s);return Hd(i.negate().mul(e))})),oc(1)))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),Pb=ju((([e,t,s,i,r,n,o,a,h,l,u,c,d,p,m])=>{let g,f;if(m){g=uc().toVar(),f=oc().toVar();const r=u.sub(1).mul(m.mul(.025)),n=oc(u.sub(r),u,u.add(r));Cy({start:0,end:3},(({i:r})=>{const u=n.element(r),m=Rb(e,t,c,u,a),y=o.add(m),x=l.mul(h.mul(uc(y,1))),b=sc(x.xy.div(x.w)).toVar();b.addAssign(1),b.divAssign(2),b.assign(sc(b.x,b.y.oneMinus()));const v=Bb(b,s,u);g.element(r).assign(v.element(r)),g.a.addAssign(v.a),f.element(r).assign(i.element(r).mul(Ib(hp(m),d,p).element(r)))})),g.a.divAssign(3)}else{const r=Rb(e,t,c,u,a),n=o.add(r),m=l.mul(h.mul(uc(n,1))),y=sc(m.xy.div(m.w)).toVar();y.addAssign(1),y.divAssign(2),y.assign(sc(y.x,y.y.oneMinus())),g=Bb(y,s,u),f=i.mul(Ib(hp(r),d,p))}const y=f.rgb.mul(g.rgb),x=e.dot(t).clamp(),b=oc(hb({dotNV:x,specularColor:r,specularF90:n,roughness:s})),v=f.r.add(f.g,f.b).div(3);return uc(b.oneMinus().mul(y),g.a.oneMinus().mul(v).oneMinus())})),Fb=gc(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),zb=(e,t)=>e.sub(t).div(e.add(t)).pow2(),Ub=(e,t)=>{const s=e.mul(2*Math.PI*1e-9),i=oc(54856e-17,44201e-17,52481e-17),r=oc(1681e3,1795300,2208400),n=oc(43278e5,93046e5,66121e5),o=Ku(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(s.mul(2239900).add(t.x).cos()).mul(s.pow2().mul(-45282e5).exp());let a=i.mul(n.mul(2*Math.PI).sqrt()).mul(r.mul(s).add(t).cos()).mul(s.pow2().negate().mul(n).exp());a=oc(a.x.add(o),a.y,a.z).div(1.0685e-7);return Fb.mul(a)},Lb=ju((({outsideIOR:e,eta2:t,cosTheta1:s,thinFilmThickness:i,baseF0:r})=>{const n=Up(e,t,Dp(0,.03,i)),o=e.div(n).pow2().mul(Ku(1).sub(s.pow2())),a=Ku(1).sub(o).sqrt(),h=zb(n,e),l=Hx({f0:h,f90:1,dotVH:s}),u=l.oneMinus(),c=n.lessThan(e).select(Math.PI,0),d=Ku(Math.PI).sub(c),p=(e=>{const t=e.sqrt();return oc(1).add(t).div(oc(1).sub(t))})(r.clamp(0,.9999)),m=zb(p,n.toVec3()),g=Hx({f0:m,f90:1,dotVH:a}),f=oc(p.x.lessThan(n).select(Math.PI,0),p.y.lessThan(n).select(Math.PI,0),p.z.lessThan(n).select(Math.PI,0)),y=n.mul(i,a,2),x=oc(d).add(f),b=l.mul(g).clamp(1e-5,.9999),v=b.sqrt(),T=u.pow2().mul(g).div(oc(1).sub(b));let _=l.add(T),w=T.sub(u);for(let e=1;e<=2;++e){w=w.mul(v);const t=Ub(Ku(e).mul(y),Ku(e).mul(x)).mul(2);_=_.add(w.mul(t))}return _.max(oc(0))})).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),Ob=ju((({normal:e,viewDir:t,roughness:s})=>{const i=e.dot(t).saturate(),r=s.pow2(),n=qp(s.lessThan(.25),Ku(-339.2).mul(r).add(Ku(161.4).mul(s)).sub(25.9),Ku(-8.48).mul(r).add(Ku(14.3).mul(s)).sub(9.95)),o=qp(s.lessThan(.25),Ku(44).mul(r).sub(Ku(23.7).mul(s)).add(3.26),Ku(1.97).mul(r).sub(Ku(3.27).mul(s)).add(.72));return qp(s.lessThan(.25),0,Ku(.1).mul(s).sub(.025)).add(n.mul(i).add(o).exp()).mul(1/Math.PI).saturate()})),Vb=oc(.04),Db=Ku(1);class kb extends Dx{constructor(e=!1,t=!1,s=!1,i=!1,r=!1,n=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=s,this.anisotropy=i,this.transmission=r,this.dispersion=n,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(!0===this.clearcoat&&(this.clearcoatRadiance=oc().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=oc().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=oc().toVar("clearcoatSpecularIndirect")),!0===this.sheen&&(this.sheenSpecularDirect=oc().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=oc().toVar("sheenSpecularIndirect")),!0===this.iridescence){const e=Fg.dot(Sg).clamp();this.iridescenceFresnel=Lb({outsideIOR:Ku(1),eta2:Gc,cosTheta1:e,thinFilmThickness:Wc,baseF0:Xc}),this.iridescenceF0=lb({f:this.iridescenceFresnel,f90:1,dotVH:e})}if(!0===this.transmission){const t=Tg,s=eg.sub(Tg).normalize(),i=zg;e.backdrop=Pb(i,s,zc,Pc,Xc,Yc,t,pg,Zm,Ym,td,id,nd,rd,this.dispersion?od:null),e.backdropAlpha=sd,Pc.a.mulAssign(Up(1,e.backdrop.a,sd))}}computeMultiscattering(e,t,s){const i=Fg.dot(Sg).clamp(),r=ab({roughness:zc,dotNV:i}),n=(this.iridescenceF0?kc.mix(Xc,this.iridescenceF0):Xc).mul(r.x).add(s.mul(r.y)),o=r.x.add(r.y).oneMinus(),a=Xc.add(Xc.oneMinus().mul(.047619)),h=n.mul(a).div(o.mul(a).oneMinus());e.addAssign(n),t.addAssign(h.mul(o))}direct({lightDirection:e,lightColor:t,reflectedLight:s}){const i=Fg.dot(e).clamp().mul(t);if(!0===this.sheen&&this.sheenSpecularDirect.addAssign(i.mul(db({lightDirection:e}))),!0===this.clearcoat){const s=Ug.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(s.mul(ob({lightDirection:e,f0:Vb,f90:Db,roughness:Oc,normalView:Ug})))}s.directDiffuse.addAssign(i.mul(jx({diffuseColor:Pc.rgb}))),s.directSpecular.addAssign(i.mul(ob({lightDirection:e,f0:Xc,f90:1,roughness:zc,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:s,halfHeight:i,reflectedLight:r,ltc_1:n,ltc_2:o}){const a=t.add(s).sub(i),h=t.sub(s).sub(i),l=t.sub(s).add(i),u=t.add(s).add(i),c=Fg,d=Sg,p=wg.toVar(),m=pb({N:c,V:d,roughness:zc}),g=n.uv(m).toVar(),f=o.uv(m).toVar(),y=gc(oc(g.x,0,g.y),oc(0,1,0),oc(g.z,0,g.w)).toVar(),x=Xc.mul(f.x).add(Xc.oneMinus().mul(f.y)).toVar();r.directSpecular.addAssign(e.mul(x).mul(fb({N:c,V:d,P:p,mInv:y,p0:a,p1:h,p2:l,p3:u}))),r.directDiffuse.addAssign(e.mul(Pc).mul(fb({N:c,V:d,P:p,mInv:gc(1,0,0,0,1,0,0,0,1),p0:a,p1:h,p2:l,p3:u})))}indirect(e,t,s){this.indirectDiffuse(e,t,s),this.indirectSpecular(e,t,s),this.ambientOcclusion(e,t,s)}indirectDiffuse({irradiance:e,reflectedLight:t}){t.indirectDiffuse.addAssign(e.mul(jx({diffuseColor:Pc})))}indirectSpecular({radiance:e,iblIrradiance:t,reflectedLight:s}){if(!0===this.sheen&&this.sheenSpecularIndirect.addAssign(t.mul(Vc,Ob({normal:Fg,viewDir:Sg,roughness:Dc}))),!0===this.clearcoat){const e=Ug.dot(Sg).clamp(),t=hb({dotNV:e,specularColor:Vb,specularF90:Db,roughness:Oc});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(t))}const i=oc().toVar("singleScattering"),r=oc().toVar("multiScattering"),n=t.mul(1/Math.PI);this.computeMultiscattering(i,r,Yc);const o=i.add(r),a=Pc.mul(o.r.max(o.g).max(o.b).oneMinus());s.indirectSpecular.addAssign(e.mul(i)),s.indirectSpecular.addAssign(r.mul(n)),s.indirectDiffuse.addAssign(a.mul(n))}ambientOcclusion({ambientOcclusion:e,reflectedLight:t}){const s=Fg.dot(Sg).clamp().add(e),i=zc.mul(-16).oneMinus().negate().exp2(),r=e.sub(s.pow(i).oneMinus()).clamp();!0===this.clearcoat&&this.clearcoatSpecularIndirect.mulAssign(e),!0===this.sheen&&this.sheenSpecularIndirect.mulAssign(e),t.indirectDiffuse.mulAssign(e),t.indirectSpecular.mulAssign(r)}finish(e){const{outgoingLight:t}=e;if(!0===this.clearcoat){const e=Ug.dot(Sg).clamp(),s=Hx({dotVH:e,f0:Vb,f90:Db}),i=t.mul(Lc.mul(s).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(Lc));t.assign(i)}if(!0===this.sheen){const e=Vc.r.max(Vc.g).max(Vc.b).mul(.157).oneMinus(),s=t.mul(e).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(s)}}}const Gb=Ku(1),Wb=Ku(-2),Hb=Ku(.8),jb=Ku(-1),qb=Ku(.4),$b=Ku(2),Xb=Ku(.305),Yb=Ku(3),Jb=Ku(.21),Zb=Ku(4),Kb=Ku(4),Qb=Ku(16),ev=ju((([e])=>{const t=oc(op(e)).toVar(),s=Ku(-1).toVar();return Yu(t.x.greaterThan(t.z),(()=>{Yu(t.x.greaterThan(t.y),(()=>{s.assign(qp(e.x.greaterThan(0),0,3))})).Else((()=>{s.assign(qp(e.y.greaterThan(0),1,4))}))})).Else((()=>{Yu(t.z.greaterThan(t.y),(()=>{s.assign(qp(e.z.greaterThan(0),2,5))})).Else((()=>{s.assign(qp(e.y.greaterThan(0),1,4))}))})),s})).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),tv=ju((([e,t])=>{const s=sc().toVar();return Yu(t.equal(0),(()=>{s.assign(sc(e.z,e.y).div(op(e.x)))})).ElseIf(t.equal(1),(()=>{s.assign(sc(e.x.negate(),e.z.negate()).div(op(e.y)))})).ElseIf(t.equal(2),(()=>{s.assign(sc(e.x.negate(),e.y).div(op(e.z)))})).ElseIf(t.equal(3),(()=>{s.assign(sc(e.z.negate(),e.y).div(op(e.x)))})).ElseIf(t.equal(4),(()=>{s.assign(sc(e.x.negate(),e.z).div(op(e.y)))})).Else((()=>{s.assign(sc(e.x,e.y).div(op(e.z)))})),md(.5,s.add(1))})).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),sv=ju((([e])=>{const t=Ku(0).toVar();return Yu(e.greaterThanEqual(Hb),(()=>{t.assign(Gb.sub(e).mul(jb.sub(Wb)).div(Gb.sub(Hb)).add(Wb))})).ElseIf(e.greaterThanEqual(qb),(()=>{t.assign(Hb.sub(e).mul($b.sub(jb)).div(Hb.sub(qb)).add(jb))})).ElseIf(e.greaterThanEqual(Xb),(()=>{t.assign(qb.sub(e).mul(Yb.sub($b)).div(qb.sub(Xb)).add($b))})).ElseIf(e.greaterThanEqual(Jb),(()=>{t.assign(Xb.sub(e).mul(Zb.sub(Yb)).div(Xb.sub(Jb)).add(Yb))})).Else((()=>{t.assign(Ku(-2).mul($d(md(1.16,e))))})),t})).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),iv=ju((([e,t])=>{const s=e.toVar();s.assign(md(2,s).sub(1));const i=oc(s,1).toVar();return Yu(t.equal(0),(()=>{i.assign(i.zyx)})).ElseIf(t.equal(1),(()=>{i.assign(i.xzy),i.xz.mulAssign(-1)})).ElseIf(t.equal(2),(()=>{i.x.mulAssign(-1)})).ElseIf(t.equal(3),(()=>{i.assign(i.zyx),i.xz.mulAssign(-1)})).ElseIf(t.equal(4),(()=>{i.assign(i.xzy),i.xy.mulAssign(-1)})).ElseIf(t.equal(5),(()=>{i.z.mulAssign(-1)})),i})).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),rv=ju((([e,t,s,i,r,n])=>{const o=Ku(s),a=oc(t),h=Lp(sv(o),Wb,n),l=Qd(h),u=Jd(h),c=oc(nv(e,a,u,i,r,n)).toVar();return Yu(l.notEqual(0),(()=>{const t=oc(nv(e,a,u.add(1),i,r,n)).toVar();c.assign(Up(c,t,l))})),c})),nv=ju((([e,t,s,i,r,n])=>{const o=Ku(s).toVar(),a=oc(t),h=Ku(ev(a)).toVar(),l=Ku(Tp(Kb.sub(o),0)).toVar();o.assign(Tp(o,Kb));const u=Ku(jd(o)).toVar(),c=sc(tv(a,h).mul(u.sub(2)).add(1)).toVar();return Yu(h.greaterThan(2),(()=>{c.y.addAssign(u),h.subAssign(3)})),c.x.addAssign(h.mul(u)),c.x.addAssign(l.mul(md(3,Qb))),c.y.addAssign(md(4,jd(n).sub(u))),c.x.mulAssign(i),c.y.mulAssign(r),e.uv(c).grad(sc(),sc())})),ov=ju((({envMap:e,mipInt:t,outputDirection:s,theta:i,axis:r,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:a})=>{const h=tp(i),l=s.mul(h).add(r.cross(s).mul(ep(i))).add(r.mul(r.dot(s).mul(h.oneMinus())));return nv(e,l,t,n,o,a)})),av=ju((({n:e,latitudinal:t,poleAxis:s,outputDirection:i,weights:r,samples:n,dTheta:o,mipInt:a,envMap:h,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:c})=>{const d=oc(qp(t,s,Rp(s,i))).toVar();Yu(Vd(d.equals(oc(0))),(()=>{d.assign(oc(i.z,0,i.x.negate()))})),d.assign(Kd(d));const p=oc().toVar();return p.addAssign(r.element(Qu(0)).mul(ov({theta:0,axis:d,outputDirection:i,mipInt:a,envMap:h,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:c}))),Cy({start:Qu(1),end:e},(({i:e})=>{Yu(e.greaterThanEqual(n),(()=>{By()}));const t=Ku(o.mul(Ku(e))).toVar();p.addAssign(r.element(e).mul(ov({theta:t.mul(-1),axis:d,outputDirection:i,mipInt:a,envMap:h,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:c}))),p.addAssign(r.element(e).mul(ov({theta:t,axis:d,outputDirection:i,mipInt:a,envMap:h,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:c})))})),uc(p,1)}));let hv=null;const lv=new WeakMap;function uv(e){let t=lv.get(e);if((void 0!==t?t.pmremVersion:-1)!==e.pmremVersion){const s=e.image;if(e.isCubeTexture){if(!function(e){if(null==e)return!1;let t=0;const s=6;for(let i=0;i0}(s))return null;t=hv.fromEquirectangular(e,t)}t.pmremVersion=e.pmremVersion,lv.set(e,t)}return t.texture}class cv extends iu{constructor(e,t=null,s=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=s,this._generator=null;const i=new Ti;i.isRenderTargetTexture=!0,this._texture=Gm(i),this._width=Cc(0),this._height=Cc(0),this._maxMip=Cc(0),this.updateBeforeType=Hl.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=function(e){const t=Math.log2(e)-2,s=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:s,maxMip:t}}(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(){let e=this._pmrem;const t=e?e.pmremVersion:-1,s=this._value;t!==s.pmremVersion&&(e=!0===s.isPMREMTexture?s:uv(s),null!==e&&(this._pmrem=e,this.updateFromTexture(e)))}setup(e){null===hv&&(hv=e.createPMREMGenerator()),this.updateBefore(e);let t=this.uvNode;null===t&&e.context.getUV&&(t=e.context.getUV(this));const s=this.value;e.renderer.coordinateSystem===Vs&&!0!==s.isPMREMTexture&&!0===s.isRenderTargetTexture&&(t=oc(t.x.negate(),t.yz));let i=this.levelNode;return null===i&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this)),rv(this._texture,t,i,this._width,this._height,this._maxMip)}}Ql("PMREM",cv);const dv=Wu(cv),pv=new WeakMap;class mv extends Dy{constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let s=this.envNode;if(s.isTextureNode||s.isMaterialReferenceNode){const e=s.isTextureNode?s.value:t[s.property];let i=pv.get(e);void 0===i&&(i=dv(e),pv.set(e,i)),s=i}const i=t.envMap?Zg("envMapIntensity","float",e.material):Zg("environmentIntensity","float",e.scene),r=!0===t.useAnisotropy||t.anisotropy>0?xf:Fg,n=s.context(gv(zc,r)).mul(i),o=s.context(fv(zg)).mul(Math.PI).mul(i),a=Tm(n),h=Tm(o);e.context.radiance.addAssign(a),e.context.iblIrradiance.addAssign(h);const l=e.context.lightingModel.clearcoatRadiance;if(l){const e=s.context(gv(Oc,Ug)).mul(i),t=Tm(e);l.addAssign(t)}}}Ql("Environment",mv);const gv=(e,t)=>{let s=null;return{getUV:()=>(null===s&&(s=Sg.negate().reflect(t),s=e.mul(e).mix(s,t).normalize(),s=s.transformDirection(Zm)),s),getTextureLevel:()=>e}},fv=e=>({getUV:()=>e,getTextureLevel:()=>Ku(1)}),yv=new Al;class xv extends yx{constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(yv),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return null===t&&e.environmentNode&&(t=e.environmentNode),t?new mv(t):null}setupLightingModel(){return new kb}setupSpecular(){const e=Up(oc(.04),Pc.rgb,Uc);Xc.assign(e),Yc.assign(1)}setupVariants(){const e=this.metalnessNode?Ku(this.metalnessNode):Vf;Uc.assign(e);let t=this.roughnessNode?Ku(this.roughnessNode):Of;t=eb({roughness:t}),zc.assign(t),this.setupSpecular(),Pc.assign(uc(Pc.rgb.mul(e.oneMinus()),Pc.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const bv=new Nl;class vv extends xv{constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(bv),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||null!==this.clearcoatNode}get useIridescence(){return this.iridescence>0||null!==this.iridescenceNode}get useSheen(){return this.sheen>0||null!==this.sheenNode}get useAnisotropy(){return this.anisotropy>0||null!==this.anisotropyNode}get useTransmission(){return this.transmission>0||null!==this.transmissionNode}get useDispersion(){return this.dispersion>0||null!==this.dispersionNode}setupSpecular(){const e=this.iorNode?Ku(this.iorNode):Qf;td.assign(e),Xc.assign(Up(vp(Ep(td.sub(1).div(td.add(1))).mul(zf),oc(1)).mul(Ff),Pc.rgb,Uc)),Yc.assign(Up(Ff,1,Uc))}setupLightingModel(){return new kb(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const e=this.clearcoatNode?Ku(this.clearcoatNode):kf,t=this.clearcoatRoughnessNode?Ku(this.clearcoatRoughnessNode):Gf;Lc.assign(e),Oc.assign(eb({roughness:t}))}if(this.useSheen){const e=this.sheenNode?oc(this.sheenNode):jf,t=this.sheenRoughnessNode?Ku(this.sheenRoughnessNode):qf;Vc.assign(e),Dc.assign(t)}if(this.useIridescence){const e=this.iridescenceNode?Ku(this.iridescenceNode):Xf,t=this.iridescenceIORNode?Ku(this.iridescenceIORNode):Yf,s=this.iridescenceThicknessNode?Ku(this.iridescenceThicknessNode):Jf;kc.assign(e),Gc.assign(t),Wc.assign(s)}if(this.useAnisotropy){const e=(this.anisotropyNode?sc(this.anisotropyNode):$f).toVar();jc.assign(e.length()),Yu(jc.equal(0),(()=>{e.assign(sc(1,0))})).Else((()=>{e.divAssign(sc(jc)),jc.assign(jc.saturate())})),Hc.assign(jc.pow2().mix(zc.pow2(),1)),qc.assign(gf[0].mul(e.x).add(gf[1].mul(e.y))),$c.assign(gf[1].mul(e.x).sub(gf[0].mul(e.y)))}if(this.useTransmission){const e=this.transmissionNode?Ku(this.transmissionNode):Zf,t=this.thicknessNode?Ku(this.thicknessNode):Kf,s=this.attenuationDistanceNode?Ku(this.attenuationDistanceNode):ey,i=this.attenuationColorNode?oc(this.attenuationColorNode):ty;if(sd.assign(e),id.assign(t),rd.assign(s),nd.assign(i),this.useDispersion){const e=this.dispersionNode?Ku(this.dispersionNode):hy;od.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?oc(this.clearcoatNormalNode):Wf}setup(e){e.context.setupClearcoatNormal=()=>this.setupClearcoatNormal(e),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}class Tv extends kb{constructor(e,t,s,i){super(e,t,s),this.useSSS=i}direct({lightDirection:e,lightColor:t,reflectedLight:s},i,r){if(!0===this.useSSS){const i=r.material,{thicknessColorNode:n,thicknessDistortionNode:o,thicknessAmbientNode:a,thicknessAttenuationNode:h,thicknessPowerNode:l,thicknessScaleNode:u}=i,c=e.add(Fg.mul(o)).normalize(),d=Ku(Sg.dot(c.negate()).saturate().pow(l).mul(u)),p=oc(d.add(a).mul(n));s.directDiffuse.addAssign(p.mul(h.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:s},i,r)}}class _v extends vv{constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=Ku(.1),this.thicknessAmbientNode=Ku(0),this.thicknessAttenuationNode=Ku(.1),this.thicknessPowerNode=Ku(2),this.thicknessScaleNode=Ku(10)}get useSSS(){return null!==this.thicknessColorNode}setupLightingModel(){return new Tv(this.useClearcoat,this.useSheen,this.useIridescence,this.useSSS)}copy(e){return this.thicknessColorNode=e.thicknessColorNode,this.thicknessDistortionNode=e.thicknessDistortionNode,this.thicknessAmbientNode=e.thicknessAmbientNode,this.thicknessAttenuationNode=e.thicknessAttenuationNode,this.thicknessPowerNode=e.thicknessPowerNode,this.thicknessScaleNode=e.thicknessScaleNode,super.copy(e)}}const wv=ju((({normal:e,lightDirection:t,builder:s})=>{const i=e.dot(t),r=sc(i.mul(.5).add(.5),0);if(s.material.gradientMap){const e=ef("gradientMap","texture").context({getUV:()=>r});return oc(e.r)}{const e=r.fwidth().mul(.5);return Up(oc(.7),oc(1),Dp(Ku(.7).sub(e.x),Ku(.7).add(e.x),r.x))}}));class Sv extends Dx{direct({lightDirection:e,lightColor:t,reflectedLight:s},i,r){const n=wv({normal:Rg,lightDirection:e,builder:r}).mul(t);s.directDiffuse.addAssign(n.mul(jx({diffuseColor:Pc.rgb})))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:s}){s.indirectDiffuse.addAssign(t.mul(jx({diffuseColor:Pc}))),s.indirectDiffuse.mulAssign(e)}}const Mv=new Cl;class Av extends yx{constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Mv),this.setValues(e)}setupLightingModel(){return new Sv}}class Nv extends iu{constructor(){super("vec2")}setup(){const e=oc(Sg.z,0,Sg.x.negate()).normalize(),t=Sg.cross(e);return sc(e.dot(Fg),t.dot(Fg)).mul(.495).add(.5)}}Ql("MatcapUV",Nv);const Rv=Hu(Nv),Cv=new Fl;class Ev extends yx{constructor(e){super(),this.lights=!1,this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(Cv),this.setValues(e)}setupVariants(e){const t=Rv;let s;s=e.material.matcap?ef("matcap","texture").context({getUV:()=>t}):oc(Up(.2,.8,t.y)),Pc.rgb.mulAssign(s.rgb)}}const Bv=new Va;class Iv extends yx{constructor(e){super(),this.isPointsNodeMaterial=!0,this.lights=!1,this.transparent=!0,this.sizeNode=null,this.setDefaultValues(Bv),this.setValues(e)}copy(e){return this.sizeNode=e.sizeNode,super.copy(e)}}class Pv extends iu{constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:s}=this;if("vec2"===this.getNodeType(e)){const e=t.cos(),i=t.sin();return mc(e,i,i.negate(),e).mul(s)}{const e=t,i=fc(uc(1,0,0,0),uc(0,tp(e.x),ep(e.x).negate(),0),uc(0,ep(e.x),tp(e.x),0),uc(0,0,0,1)),r=fc(uc(tp(e.y),0,ep(e.y),0),uc(0,1,0,0),uc(ep(e.y).negate(),0,tp(e.y),0),uc(0,0,0,1)),n=fc(uc(tp(e.z),ep(e.z).negate(),0,0),uc(ep(e.z),tp(e.z),0,0),uc(0,0,1,0),uc(0,0,0,1));return i.mul(r).mul(n).mul(uc(s,1)).xyz}}}Ql("Rotate",Pv);const Fv=Wu(Pv),zv=new lo;class Uv extends yx{constructor(e){super(),this.isSpriteNodeMaterial=!0,this.lights=!1,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.setDefaultValues(zv),this.setValues(e)}setupPosition({object:e,context:t}){const{positionNode:s,rotationNode:i,scaleNode:r}=this,n=bg;let o=cg.mul(oc(s||0)),a=sc(pg[0].xyz.length(),pg[1].xyz.length());null!==r&&(a=a.mul(r));let h=n.xy;e.center&&!0===e.center.isVector2&&(h=h.sub(Cc(e.center).sub(.5))),h=h.mul(a);const l=Ku(i||Hf),u=Fv(h,l);o=uc(o.xy.add(u),o.zw);const c=Ym.mul(o);return t.vertex=n,c}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}}class Lv extends Dx{constructor(){super(),this.shadowNode=Ku(1).toVar("shadowMask")}direct({shadowMask:e}){this.shadowNode.mulAssign(e)}finish(e){Pc.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(Pc.rgb)}}const Ov=new Sl;class Vv extends yx{constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Ov),this.setValues(e)}setupLightingModel(){return new Lv}}const Dv=ju((({texture:e,uv:t})=>{const s=1e-4,i=oc().temp();return Yu(t.x.lessThan(s),(()=>{i.assign(oc(1,0,0))})).ElseIf(t.y.lessThan(s),(()=>{i.assign(oc(0,1,0))})).ElseIf(t.z.lessThan(s),(()=>{i.assign(oc(0,0,1))})).ElseIf(t.x.greaterThan(.9999),(()=>{i.assign(oc(-1,0,0))})).ElseIf(t.y.greaterThan(.9999),(()=>{i.assign(oc(0,-1,0))})).ElseIf(t.z.greaterThan(.9999),(()=>{i.assign(oc(0,0,-1))})).Else((()=>{const s=.01,r=e.uv(t.add(oc(-.01,0,0))).r.sub(e.uv(t.add(oc(s,0,0))).r),n=e.uv(t.add(oc(0,-.01,0))).r.sub(e.uv(t.add(oc(0,s,0))).r),o=e.uv(t.add(oc(0,0,-.01))).r.sub(e.uv(t.add(oc(0,0,s))).r);i.assign(oc(r,n,o))})),i.normalize()}));class kv extends km{constructor(e,t=null,s=null){super(e,t,s),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return oc(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){return t}generateUV(e,t){return t.build(e,"vec3")}normal(e){return Dv({texture:this,uv:e})}}Ql("Texture3D",kv);const Gv=Wu(kv);class Wv extends yx{constructor(e={}){super(),this.lights=!1,this.isVolumeNodeMaterial=!0,this.testNode=null,this.setValues(e)}setup(e){const t=Gv(this.map,null,0),s=ju((({orig:e,dir:t})=>{const s=oc(-.5),i=oc(.5),r=t.reciprocal(),n=s.sub(e).mul(r),o=i.sub(e).mul(r),a=vp(n,o),h=Tp(n,o),l=Tp(a.x,Tp(a.y,a.z)),u=vp(h.x,vp(h.y,h.z));return sc(l,u)}));this.fragmentNode=ju((()=>{const e=em(oc(yg.mul(uc(eg,1)))),i=em(xg.sub(e)).normalize(),r=Bc("vec2","bounds").assign(s({orig:e,dir:i}));r.x.greaterThan(r.y).discard(),r.assign(sc(Tp(r.x,0),r.y));const n=Bc("vec3","p").assign(e.add(r.x.mul(i))),o=Bc("vec3","inc").assign(oc(i.abs().reciprocal())),a=Bc("float","delta").assign(vp(o.x,vp(o.y,o.z)));a.divAssign(ef("steps","float"));const h=Bc("vec4","ac").assign(uc(ef("base","color"),0));return Cy({type:"float",start:r.x,end:r.y,update:"+= delta"},(()=>{const e=Bc("float","d").assign(t.uv(n.add(.5)).r);null!==this.testNode?this.testNode({map:t,mapValue:e,probe:n,finalColor:h}).append():(h.a.assign(1),By()),n.addAssign(i.mul(a))})),h.a.equal(0).discard(),uc(h)}))(),super.setup(e)}}function Hv(e,t,s){return!e||!s&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)}function jv(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function qv(e){const t=e.length,s=new Array(t);for(let e=0;e!==t;++e)s[e]=e;return s.sort((function(t,s){return e[t]-e[s]})),s}function $v(e,t,s){const i=e.length,r=new e.constructor(i);for(let n=0,o=0;o!==i;++n){const i=s[n]*t;for(let s=0;s!==t;++s)r[o++]=e[i+s]}return r}function Xv(e,t,s,i){let r=1,n=e[0];for(;void 0!==n&&void 0===n[i];)n=e[r++];if(void 0===n)return;let o=n[i];if(void 0!==o)if(Array.isArray(o))do{o=n[i],void 0!==o&&(t.push(n.time),s.push.apply(s,o)),n=e[r++]}while(void 0!==n);else if(void 0!==o.toArray)do{o=n[i],void 0!==o&&(t.push(n.time),o.toArray(s,s.length)),n=e[r++]}while(void 0!==n);else do{o=n[i],void 0!==o&&(t.push(n.time),s.push(o)),n=e[r++]}while(void 0!==n)}const Yv={convertArray:Hv,isTypedArray:jv,getKeyframeOrder:qv,sortedArray:$v,flattenJSON:Xv,subclip:function(e,t,s,i,r=30){const n=e.clone();n.name=t;const o=[];for(let e=0;e=i)){h.push(t.times[e]);for(let s=0;sn.tracks[e].times[0]&&(a=n.tracks[e].times[0]);for(let e=0;e=i.times[c]){const e=c*h+a,t=e+h-a;d=i.values.slice(e,t)}else{const e=i.createInterpolant(),t=a,s=h-a;e.evaluate(n),d=e.resultBuffer.slice(t,s)}if("quaternion"===r){(new Ci).fromArray(d).normalize().conjugate().toArray(d)}const p=o.times.length;for(let e=0;e=r)break e;{const o=t[1];e=r)break t}n=s,s=0}}for(;s>>1;et;)--n;if(++n,0!==r||n!==i){r>=n&&(n=Math.max(n,1),r=n-1);const e=this.getValueSize();this.times=s.slice(r,n),this.values=this.values.slice(r*e,n*e)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const s=this.times,i=this.values,r=s.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let n=null;for(let t=0;t!==r;t++){const i=s[t];if("number"==typeof i&&isNaN(i)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,t,i),e=!1;break}if(null!==n&&n>i){console.error("THREE.KeyframeTrack: Out of order keys.",this,t,i,n),e=!1;break}n=i}if(void 0!==i&&jv(i))for(let t=0,s=i.length;t!==s;++t){const s=i[t];if(isNaN(s)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,t,s),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),s=this.getValueSize(),i=this.getInterpolation()===Ft,r=e.length-1;let n=1;for(let o=1;o0){e[n]=e[r];for(let e=r*s,i=n*s,o=0;o!==s;++o)t[i+o]=t[e+o];++n}return n!==e.length?(this.times=e.slice(0,n),this.values=t.slice(0,n*s)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),s=new(0,this.constructor)(this.name,e,t);return s.createInterpolant=this.createInterpolant,s}}eT.prototype.TimeBufferType=Float32Array,eT.prototype.ValueBufferType=Float32Array,eT.prototype.DefaultInterpolation=Pt;class tT extends eT{constructor(e,t,s){super(e,t,s)}}tT.prototype.ValueTypeName="bool",tT.prototype.ValueBufferType=Array,tT.prototype.DefaultInterpolation=It,tT.prototype.InterpolantFactoryMethodLinear=void 0,tT.prototype.InterpolantFactoryMethodSmooth=void 0;class sT extends eT{}sT.prototype.ValueTypeName="color";class iT extends eT{}iT.prototype.ValueTypeName="number";class rT extends Jv{constructor(e,t,s,i){super(e,t,s,i)}interpolate_(e,t,s,i){const r=this.resultBuffer,n=this.sampleValues,o=this.valueSize,a=(s-t)/(i-t);let h=e*o;for(let e=h+o;h!==e;h+=4)Ci.slerpFlat(r,0,n,h-o,n,h,a);return r}}class nT extends eT{InterpolantFactoryMethodLinear(e){return new rT(this.times,this.values,this.getValueSize(),e)}}nT.prototype.ValueTypeName="quaternion",nT.prototype.InterpolantFactoryMethodSmooth=void 0;class oT extends eT{constructor(e,t,s){super(e,t,s)}}oT.prototype.ValueTypeName="string",oT.prototype.ValueBufferType=Array,oT.prototype.DefaultInterpolation=It,oT.prototype.InterpolantFactoryMethodLinear=void 0,oT.prototype.InterpolantFactoryMethodSmooth=void 0;class aT extends eT{}aT.prototype.ValueTypeName="vector";class hT{constructor(e="",t=-1,s=[],i=2500){this.name=e,this.tracks=s,this.duration=t,this.blendMode=i,this.uuid=qs(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],s=e.tracks,i=1/(e.fps||1);for(let e=0,r=s.length;e!==r;++e)t.push(lT(s[e]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],s=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,i=s.length;e!==i;++e)t.push(eT.toJSON(s[e]));return i}static CreateFromMorphTargetSequence(e,t,s,i){const r=t.length,n=[];for(let e=0;e1){const e=n[1];let t=i[e];t||(i[e]=t=[]),t.push(s)}}const n=[];for(const e in i)n.push(this.CreateFromMorphTargetSequence(e,i[e],t,s));return n}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const s=function(e,t,s,i,r){if(0!==s.length){const n=[],o=[];Xv(s,n,o,i),0!==n.length&&r.push(new e(t,n,o))}},i=[],r=e.name||"default",n=e.fps||30,o=e.blendMode;let a=e.length||-1;const h=e.hierarchy||[];for(let e=0;e{t&&t(r),this.manager.itemEnd(e)}),0),r;if(void 0!==mT[e])return void mT[e].push({onLoad:t,onProgress:s,onError:i});mT[e]=[],mT[e].push({onLoad:t,onProgress:s,onError:i});const n=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,a=this.responseType;fetch(n).then((t=>{if(200===t.status||0===t.status){if(0===t.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body||void 0===t.body.getReader)return t;const s=mT[e],i=t.body.getReader(),r=t.headers.get("X-File-Size")||t.headers.get("Content-Length"),n=r?parseInt(r):0,o=0!==n;let a=0;const h=new ReadableStream({start(e){!function t(){i.read().then((({done:i,value:r})=>{if(i)e.close();else{a+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:o,loaded:a,total:n});for(let e=0,t=s.length;e{e.error(t)}))}()}});return new Response(h)}throw new gT(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)})).then((e=>{switch(a){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,o)));case"json":return e.json();default:if(void 0===o)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(o),s=t&&t[1]?t[1].toLowerCase():void 0,i=new TextDecoder(s);return e.arrayBuffer().then((e=>i.decode(e)))}}})).then((t=>{uT.add(e,t);const s=mT[e];delete mT[e];for(let e=0,i=s.length;e{const s=mT[e];if(void 0===s)throw this.manager.itemError(e),t;delete mT[e];for(let e=0,i=s.length;e{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class yT extends pT{constructor(e){super(e)}load(e,t,s,i){const r=this,n=new fT(this.manager);n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(e,(function(s){try{t(r.parse(JSON.parse(s)))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),s,i)}parse(e){const t=[];for(let s=0;s0:i.vertexColors=e.vertexColors),void 0!==e.uniforms)for(const t in e.uniforms){const r=e.uniforms[t];switch(i.uniforms[t]={},r.type){case"t":i.uniforms[t].value=s(r.value);break;case"c":i.uniforms[t].value=(new Yr).setHex(r.value);break;case"v2":i.uniforms[t].value=(new Qs).fromArray(r.value);break;case"v3":i.uniforms[t].value=(new Ei).fromArray(r.value);break;case"v4":i.uniforms[t].value=(new _i).fromArray(r.value);break;case"m3":i.uniforms[t].value=(new ei).fromArray(r.value);break;case"m4":i.uniforms[t].value=(new or).fromArray(r.value);break;default:i.uniforms[t].value=r.value}}if(void 0!==e.defines&&(i.defines=e.defines),void 0!==e.vertexShader&&(i.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(i.fragmentShader=e.fragmentShader),void 0!==e.glslVersion&&(i.glslVersion=e.glslVersion),void 0!==e.extensions)for(const t in e.extensions)i.extensions[t]=e.extensions[t];if(void 0!==e.lights&&(i.lights=e.lights),void 0!==e.clipping&&(i.clipping=e.clipping),void 0!==e.size&&(i.size=e.size),void 0!==e.sizeAttenuation&&(i.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(i.map=s(e.map)),void 0!==e.matcap&&(i.matcap=s(e.matcap)),void 0!==e.alphaMap&&(i.alphaMap=s(e.alphaMap)),void 0!==e.bumpMap&&(i.bumpMap=s(e.bumpMap)),void 0!==e.bumpScale&&(i.bumpScale=e.bumpScale),void 0!==e.normalMap&&(i.normalMap=s(e.normalMap)),void 0!==e.normalMapType&&(i.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),i.normalScale=(new Qs).fromArray(t)}return void 0!==e.displacementMap&&(i.displacementMap=s(e.displacementMap)),void 0!==e.displacementScale&&(i.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(i.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(i.roughnessMap=s(e.roughnessMap)),void 0!==e.metalnessMap&&(i.metalnessMap=s(e.metalnessMap)),void 0!==e.emissiveMap&&(i.emissiveMap=s(e.emissiveMap)),void 0!==e.emissiveIntensity&&(i.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(i.specularMap=s(e.specularMap)),void 0!==e.specularIntensityMap&&(i.specularIntensityMap=s(e.specularIntensityMap)),void 0!==e.specularColorMap&&(i.specularColorMap=s(e.specularColorMap)),void 0!==e.envMap&&(i.envMap=s(e.envMap)),void 0!==e.envMapRotation&&i.envMapRotation.fromArray(e.envMapRotation),void 0!==e.envMapIntensity&&(i.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(i.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(i.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(i.lightMap=s(e.lightMap)),void 0!==e.lightMapIntensity&&(i.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(i.aoMap=s(e.aoMap)),void 0!==e.aoMapIntensity&&(i.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(i.gradientMap=s(e.gradientMap)),void 0!==e.clearcoatMap&&(i.clearcoatMap=s(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=s(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(i.clearcoatNormalMap=s(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(i.clearcoatNormalScale=(new Qs).fromArray(e.clearcoatNormalScale)),void 0!==e.iridescenceMap&&(i.iridescenceMap=s(e.iridescenceMap)),void 0!==e.iridescenceThicknessMap&&(i.iridescenceThicknessMap=s(e.iridescenceThicknessMap)),void 0!==e.transmissionMap&&(i.transmissionMap=s(e.transmissionMap)),void 0!==e.thicknessMap&&(i.thicknessMap=s(e.thicknessMap)),void 0!==e.anisotropyMap&&(i.anisotropyMap=s(e.anisotropyMap)),void 0!==e.sheenColorMap&&(i.sheenColorMap=s(e.sheenColorMap)),void 0!==e.sheenRoughnessMap&&(i.sheenRoughnessMap=s(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){return new{ShadowMaterial:Sl,SpriteMaterial:lo,RawShaderMaterial:Ml,ShaderMaterial:$n,PointsMaterial:Va,MeshPhysicalMaterial:Nl,MeshStandardMaterial:Al,MeshPhongMaterial:Rl,MeshToonMaterial:Cl,MeshNormalMaterial:El,MeshLambertMaterial:Bl,MeshDepthMaterial:Il,MeshDistanceMaterial:Pl,MeshBasicMaterial:Qr,MeshMatcapMaterial:Fl,LineDashedMaterial:zl,LineBasicMaterial:Ma,Material:Kr}[e]}}class HT{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let s=0,i=e.length;s0){const s=new cT(t);r=new bT(s),r.setCrossOrigin(this.crossOrigin);for(let t=0,s=e.length;t0){i=new bT(this.manager),i.setCrossOrigin(this.crossOrigin);for(let t=0,i=e.length;t{const t=new Pi;t.min.fromArray(e.boxMin),t.max.fromArray(e.boxMax);const s=new Zi;return s.radius=e.sphereRadius,s.center.fromArray(e.sphereCenter),{boxInitialized:e.boxInitialized,box:t,sphereInitialized:e.sphereInitialized,sphere:s}})),n._maxInstanceCount=e.maxInstanceCount,n._maxVertexCount=e.maxVertexCount,n._maxIndexCount=e.maxIndexCount,n._geometryInitialized=e.geometryInitialized,n._geometryCount=e.geometryCount,n._matricesTexture=u(e.matricesTexture.uuid),void 0!==e.colorsTexture&&(n._colorsTexture=u(e.colorsTexture.uuid));break;case"LOD":n=new Ro;break;case"Line":n=new Pa(h(e.geometry),l(e.material));break;case"LineLoop":n=new Oa(h(e.geometry),l(e.material));break;case"LineSegments":n=new La(h(e.geometry),l(e.material));break;case"PointCloud":case"Points":n=new Ha(h(e.geometry),l(e.material));break;case"Sprite":n=new So(l(e.material));break;case"Group":n=new qa;break;case"Bone":n=new Vo;break;default:n=new Pr}if(n.uuid=e.uuid,void 0!==e.name&&(n.name=e.name),void 0!==e.matrix?(n.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(n.matrixAutoUpdate=e.matrixAutoUpdate),n.matrixAutoUpdate&&n.matrix.decompose(n.position,n.quaternion,n.scale)):(void 0!==e.position&&n.position.fromArray(e.position),void 0!==e.rotation&&n.rotation.fromArray(e.rotation),void 0!==e.quaternion&&n.quaternion.fromArray(e.quaternion),void 0!==e.scale&&n.scale.fromArray(e.scale)),void 0!==e.up&&n.up.fromArray(e.up),void 0!==e.castShadow&&(n.castShadow=e.castShadow),void 0!==e.receiveShadow&&(n.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.intensity&&(n.shadow.intensity=e.shadow.intensity),void 0!==e.shadow.bias&&(n.shadow.bias=e.shadow.bias),void 0!==e.shadow.normalBias&&(n.shadow.normalBias=e.shadow.normalBias),void 0!==e.shadow.radius&&(n.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&n.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(n.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(n.visible=e.visible),void 0!==e.frustumCulled&&(n.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(n.renderOrder=e.renderOrder),void 0!==e.userData&&(n.userData=e.userData),void 0!==e.layers&&(n.layers.mask=e.layers),void 0!==e.children){const o=e.children;for(let e=0;e{t&&t(s),r.manager.itemEnd(e)})).catch((e=>{i&&i(e)})):(setTimeout((function(){t&&t(n),r.manager.itemEnd(e)}),0),n);const o={};o.credentials="anonymous"===this.crossOrigin?"same-origin":"include",o.headers=this.requestHeader;const a=fetch(e,o).then((function(e){return e.blob()})).then((function(e){return createImageBitmap(e,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(s){return uT.add(e,s),t&&t(s),r.manager.itemEnd(e),s})).catch((function(t){i&&i(t),uT.remove(e),r.manager.itemError(e),r.manager.itemEnd(e)}));uT.add(e,a),r.manager.itemStart(e)}}let KT;class QT{static getContext(){return void 0===KT&&(KT=new(window.AudioContext||window.webkitAudioContext)),KT}static setContext(e){KT=e}}class e_ extends pT{constructor(e){super(e)}load(e,t,s,i){const r=this,n=new fT(this.manager);function o(t){i?i(t):console.error(t),r.manager.itemError(e)}n.setResponseType("arraybuffer"),n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(e,(function(e){try{const s=e.slice(0);QT.getContext().decodeAudioData(s,(function(e){t(e)})).catch(o)}catch(e){o(e)}}),s,i)}}const t_=new or,s_=new or,i_=new or;class r_{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Kn,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Kn,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,i_.copy(e.projectionMatrix);const s=t.eyeSep/2,i=s*t.near/t.focus,r=t.near*Math.tan(Hs*t.fov*.5)/t.zoom;let n,o;s_.elements[12]=-s,t_.elements[12]=s,n=-r*t.aspect+i,o=r*t.aspect+i,i_.elements[0]=2*t.near/(o-n),i_.elements[8]=(o+n)/(o-n),this.cameraL.projectionMatrix.copy(i_),n=-r*t.aspect-i,o=r*t.aspect-i,i_.elements[0]=2*t.near/(o-n),i_.elements[8]=(o+n)/(o-n),this.cameraR.projectionMatrix.copy(i_)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(s_),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(t_)}}class n_ extends Kn{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class o_{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=a_(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=a_();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function a_(){return("undefined"==typeof performance?Date:performance).now()}const h_=new Ei,l_=new Ci,u_=new Ei,c_=new Ei;class d_ extends Pr{constructor(){super(),this.type="AudioListener",this.context=QT.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new o_}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,s=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(h_,l_,u_),c_.set(0,0,-1).applyQuaternion(l_),t.positionX){const e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(h_.x,e),t.positionY.linearRampToValueAtTime(h_.y,e),t.positionZ.linearRampToValueAtTime(h_.z,e),t.forwardX.linearRampToValueAtTime(c_.x,e),t.forwardY.linearRampToValueAtTime(c_.y,e),t.forwardZ.linearRampToValueAtTime(c_.z,e),t.upX.linearRampToValueAtTime(s.x,e),t.upY.linearRampToValueAtTime(s.y,e),t.upZ.linearRampToValueAtTime(s.z,e)}else t.setPosition(h_.x,h_.y,h_.z),t.setOrientation(c_.x,c_.y,c_.z,s.x,s.y,s.z)}}class p_ extends Pr{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(!0===this.isPlaying)return void console.warn("THREE.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("THREE.Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(){if(!1!==this.hasPlaybackControl)return this._progress=0,null!==this.source&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(s,i,this._addIndex*t,1,t);for(let e=t,r=t+t;e!==r;++e)if(s[e]!==s[e+t]){o.setValue(s,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,s=this.valueSize,i=s*this._origIndex;e.getValue(t,i);for(let e=s,r=i;e!==r;++e)t[e]=t[i+e%s];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let s=e;s=.5)for(let i=0;i!==r;++i)e[t+i]=e[s+i]}_slerp(e,t,s,i){Ci.slerpFlat(e,t,e,t,e,s,i)}_slerpAdditive(e,t,s,i,r){const n=this._workIndex*r;Ci.multiplyQuaternionsFlat(e,n,e,t,e,s),Ci.slerpFlat(e,t,e,t,e,n,i)}_lerp(e,t,s,i,r){const n=1-i;for(let o=0;o!==r;++o){const r=t+o;e[r]=e[r]*n+e[s+o]*i}}_lerpAdditive(e,t,s,i,r){for(let n=0;n!==r;++n){const r=t+n;e[r]=e[r]+e[s+n]*i}}}const T_="\\[\\]\\.:\\/",__=new RegExp("["+T_+"]","g"),w_="[^"+T_+"]",S_="[^"+T_.replace("\\.","")+"]",M_=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",w_)+/(WCOD+)?/.source.replace("WCOD",S_)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",w_)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",w_)+"$"),A_=["material","materials","bones","map"];class N_{constructor(e,t,s){this.path=t,this.parsedPath=s||N_.parseTrackName(t),this.node=N_.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,s){return e&&e.isAnimationObjectGroup?new N_.Composite(e,t,s):new N_(e,t,s)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(__,"")}static parseTrackName(e){const t=M_.exec(e);if(null===t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const s={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=s.nodeName&&s.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const e=s.nodeName.substring(i+1);-1!==A_.indexOf(e)&&(s.nodeName=s.nodeName.substring(0,i),s.objectName=e)}if(null===s.propertyName||0===s.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return s}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const s=e.skeleton.getBoneByName(t);if(void 0!==s)return s}if(e.children){const s=function(e){for(let i=0;i=r){const n=r++,l=e[n];t[l.uuid]=h,e[h]=l,t[a]=n,e[n]=o;for(let e=0,t=i;e!==t;++e){const t=s[e],i=t[n],r=t[h];t[h]=i,t[n]=r}}}this.nCachedObjects_=r}uncache(){const e=this._objects,t=this._indicesByUUID,s=this._bindings,i=s.length;let r=this.nCachedObjects_,n=e.length;for(let o=0,a=arguments.length;o!==a;++o){const a=arguments[o].uuid,h=t[a];if(void 0!==h)if(delete t[a],h0&&(t[o.uuid]=h),e[h]=o,e.pop();for(let e=0,t=i;e!==t;++e){const t=s[e];t[h]=t[r],t.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){const s=this._bindingsIndicesByPath;let i=s[e];const r=this._bindings;if(void 0!==i)return r[i];const n=this._paths,o=this._parsedPaths,a=this._objects,h=a.length,l=this.nCachedObjects_,u=new Array(h);i=r.length,s[e]=i,n.push(e),o.push(t),r.push(u);for(let s=l,i=a.length;s!==i;++s){const i=a[s];u[s]=new N_(i,e,t)}return u}unsubscribe_(e){const t=this._bindingsIndicesByPath,s=t[e];if(void 0!==s){const i=this._paths,r=this._parsedPaths,n=this._bindings,o=n.length-1,a=n[o];t[e[o]]=s,n[s]=a,n.pop(),r[s]=r[o],r.pop(),i[s]=i[o],i.pop()}}}class C_{constructor(e,t,s=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=s,this.blendMode=i;const r=t.tracks,n=r.length,o=new Array(n),a={endingStart:zt,endingEnd:zt};for(let e=0;e!==n;++e){const t=r[e].createInterpolant(null);o[e]=t,t.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=new Array(n),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,s){if(e.fadeOut(t),this.fadeIn(t),s){const s=this._clip.duration,i=e._clip.duration,r=i/s,n=s/i;e.warp(1,r,t),this.warp(n,1,t)}return this}crossFadeTo(e,t,s){return e.crossFadeFrom(this,t,s)}stopFading(){const e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,s){const i=this._mixer,r=i.time,n=this.timeScale;let o=this._timeScaleInterpolant;null===o&&(o=i._lendControlInterpolant(),this._timeScaleInterpolant=o);const a=o.parameterPositions,h=o.sampleValues;return a[0]=r,a[1]=r+s,h[0]=e/n,h[1]=t/n,this}stopWarping(){const e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,s,i){if(!this.enabled)return void this._updateWeight(e);const r=this._startTime;if(null!==r){const i=(e-r)*s;i<0||0===s?t=0:(this._startTime=null,t=s*i)}t*=this._updateTimeScale(e);const n=this._updateTime(t),o=this._updateWeight(e);if(o>0){const e=this._interpolants,t=this._propertyBindings;if(this.blendMode===Vt)for(let s=0,i=e.length;s!==i;++s)e[s].evaluate(n),t[s].accumulateAdditive(o);else for(let s=0,r=e.length;s!==r;++s)e[s].evaluate(n),t[s].accumulate(i,o)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const s=this._weightInterpolant;if(null!==s){const i=s.evaluate(e)[0];t*=i,e>s.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const s=this._timeScaleInterpolant;if(null!==s){t*=s.evaluate(e)[0],e>s.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,s=this.loop;let i=this.time+e,r=this._loopCount;const n=2202===s;if(0===e)return-1===r?i:n&&1==(1&r)?t-i:i;if(2200===s){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else{if(!(i<0)){this.time=i;break e}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,n)):this._setEndings(0===this.repetitions,!0,n)),i>=t||i<0){const s=Math.floor(i/t);i-=t*s,r+=Math.abs(s);const o=this.repetitions-r;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===o){const t=e<0;this._setEndings(t,!t,n)}else this._setEndings(!1,!1,n);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:s})}}else this.time=i;if(n&&1==(1&r))return t-i}return i}_setEndings(e,t,s){const i=this._interpolantSettings;s?(i.endingStart=Ut,i.endingEnd=Ut):(i.endingStart=e?this.zeroSlopeAtStart?Ut:zt:Lt,i.endingEnd=t?this.zeroSlopeAtEnd?Ut:zt:Lt)}_scheduleFading(e,t,s){const i=this._mixer,r=i.time;let n=this._weightInterpolant;null===n&&(n=i._lendControlInterpolant(),this._weightInterpolant=n);const o=n.parameterPositions,a=n.sampleValues;return o[0]=r,a[0]=t,o[1]=r+e,a[1]=s,this}}const E_=new Float32Array(1);class B_ extends ks{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const s=e._localRoot||this._root,i=e._clip.tracks,r=i.length,n=e._propertyBindings,o=e._interpolants,a=s.uuid,h=this._bindingsByRootAndName;let l=h[a];void 0===l&&(l={},h[a]=l);for(let e=0;e!==r;++e){const r=i[e],h=r.name;let u=l[h];if(void 0!==u)++u.referenceCount,n[e]=u;else{if(u=n[e],void 0!==u){null===u._cacheIndex&&(++u.referenceCount,this._addInactiveBinding(u,a,h));continue}const i=t&&t._propertyBindings[e].binding.parsedPath;u=new v_(N_.create(s,h,i),r.ValueTypeName,r.getValueSize()),++u.referenceCount,this._addInactiveBinding(u,a,h),n[e]=u}o[e].resultBuffer=u.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){const t=(e._localRoot||this._root).uuid,s=e._clip.uuid,i=this._actionsByClip[s];this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,s,t)}const t=e._propertyBindings;for(let e=0,s=t.length;e!==s;++e){const s=t[e];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let e=0,s=t.length;e!==s;++e){const s=t[e];0==--s.useCount&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return null!==t&&t=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;const t=this._actions,s=this._nActiveActions,i=this.time+=e,r=Math.sign(e),n=this._accuIndex^=1;for(let o=0;o!==s;++o){t[o]._update(i,e,r,n)}const o=this._bindings,a=this._nActiveBindings;for(let e=0;e!==a;++e)o[e].apply(n);return this}setTime(e){this.time=0;for(let e=0;e=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,W_).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const j_=new Ei,q_=new Ei;class $_{constructor(e=new Ei,t=new Ei){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){j_.subVectors(e,this.start),q_.subVectors(this.end,this.start);const s=q_.dot(q_);let i=q_.dot(j_)/s;return t&&(i=$s(i,0,1)),i}closestPointToPoint(e,t,s){const i=this.closestPointToPointParameter(e,t);return this.delta(s).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}const X_=new Ei;class Y_ extends Pr{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const s=new Mn,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let e=0,t=1,s=32;e1)for(let s=0;s.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{vw.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(vw,t)}}setLength(e,t=.2*e,s=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(s,t,s),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class Sw extends La{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],s=new Mn;s.setAttribute("position",new yn(t,3)),s.setAttribute("color",new yn([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));super(s,new Ma({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,s){const i=new Yr,r=this.geometry.attributes.color.array;return i.set(e),i.toArray(r,0),i.toArray(r,3),i.set(t),i.toArray(r,6),i.toArray(r,9),i.set(s),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Mw{constructor(){this.type="ShapePath",this.color=new Yr,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Th,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,s,i){return this.currentPath.quadraticCurveTo(e,t,s,i),this}bezierCurveTo(e,t,s,i,r,n){return this.currentPath.bezierCurveTo(e,t,s,i,r,n),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(e,t){const s=t.length;let i=!1;for(let r=s-1,n=0;nNumber.EPSILON){if(h<0&&(s=t[n],a=-a,o=t[r],h=-h),e.yo.y)continue;if(e.y===s.y){if(e.x===s.x)return!0}else{const t=h*(e.x-s.x)-a*(e.y-s.y);if(0===t)return!0;if(t<0)continue;i=!i}}else{if(e.y!==s.y)continue;if(o.x<=e.x&&e.x<=s.x||s.x<=e.x&&e.x<=o.x)return!0}}return i}const s=ol.isClockWise,i=this.subPaths;if(0===i.length)return[];let r,n,o;const a=[];if(1===i.length)return n=i[0],o=new Fh,o.curves=n.curves,a.push(o),a;let h=!s(i[0].getPoints());h=e?!h:h;const l=[],u=[];let c,d,p=[],m=0;u[m]=void 0,p[m]=[];for(let t=0,o=i.length;t1){let e=!1,s=0;for(let e=0,t=u.length;e0&&!1===e&&(p=l)}for(let e=0,t=u.length;e{this.requestId=self.requestAnimationFrame(e),!0===this.info.autoReset&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,null!==this.animationLoop&&this.animationLoop(t,s)};e()}dispose(){self.cancelAnimationFrame(this.requestId),this.requestId=null}setAnimationLoop(e){this.animationLoop=e}}class Cw{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let s=0;s{this.dispose()},this.material.addEventListener("dispose",this.onMaterialDispose)}updateClipping(e){const t=this.material;let s=this.clippingContext;Array.isArray(t.clippingPlanes)?(s!==e&&s||(s=new Bw,this.clippingContext=s),s.update(e,t)):this.clippingContext!==e&&(this.clippingContext=e)}get clippingNeedsUpdate(){return this.clippingContext.version!==this.clippingContextVersion&&(this.clippingContextVersion=this.clippingContext.version,!0)}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getIndex(){return this._geometries.getIndex(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}getAttributes(){if(null!==this.attributes)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,s=[],i=new Set;for(const r of e){const e=r.node&&r.node.attribute?r.node.attribute:t.getAttribute(r.name);if(void 0===e)continue;s.push(e);const n=e.isInterleavedBufferAttribute?e.data:e;i.add(n)}return this.attributes=s,this.vertexBuffers=Array.from(i.values()),s}getVertexBuffers(){return null===this.vertexBuffers&&this.getAttributes(),this.vertexBuffers}getMaterialCacheKey(){const{object:e,material:t}=this;let s=t.customProgramCacheKey();for(const e of function(e){const t=Object.keys(e);let s=Object.getPrototypeOf(e);for(;s;){const e=Object.getOwnPropertyDescriptors(s);for(const s in e)if(void 0!==e[s]){const i=e[s];i&&"function"==typeof i.get&&t.push(s)}s=Object.getPrototypeOf(s)}return t}(t)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(e))continue;const i=t[e];let r;if(null!==i){const e=typeof i;"number"===e?r=0!==i?"1":"0":"object"===e?(r="{",i.isTexture&&(r+=i.mapping),r+="}"):r=String(i)}else r=String(i);s+=r+","}return s+=this.clippingContext.cacheKey+",",e.skeleton&&(s+=e.skeleton.bones.length+","),e.morphTargetInfluences&&(s+=e.morphTargetInfluences.length+","),e.isBatchedMesh&&(s+=e._matricesTexture.uuid+",",null!==e._colorsTexture&&(s+=e._colorsTexture.uuid+",")),e.count>1&&(s+=e.count+","+e.uuid+","),s}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){return this.object.receiveShadow+","+this._nodes.getCacheKey(this.scene,this.lightsNode)}getCacheKey(){return this.getMaterialCacheKey()+","+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.onDispose()}}class Fw{constructor(e,t,s,i,r,n){this.renderer=e,this.nodes=t,this.geometries=s,this.pipelines=i,this.bindings=r,this.info=n,this.chainMaps={}}get(e,t,s,i,r,n,o){const a=this.getChainMap(o),h=[e,t,n,r];let l=a.get(h);return void 0===l?(l=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,s,i,r,n,o),a.set(h,l)):(l.updateClipping(n.clippingContext),(l.version!==t.version||l.needsUpdate)&&(l.initialCacheKey!==l.getCacheKey()?(l.dispose(),l=this.get(e,t,s,i,r,n,o)):l.version=t.version)),l}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new Cw)}dispose(){this.chainMaps={}}createRenderObject(e,t,s,i,r,n,o,a,h,l){const u=this.getChainMap(l),c=new Pw(e,t,s,i,r,n,o,a,h);return c.onDispose=()=>{this.pipelines.delete(c),this.bindings.delete(c),this.nodes.delete(c),u.delete(c.getChainArray())},c}}class zw{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}delete(e){let t;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const Uw=1,Lw=2,Ow=4,Vw=16;class Dw extends zw{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return void 0!==t&&this.backend.destroyAttribute(e),t}update(e,t){const s=this.get(e);if(void 0===s.version)t===Uw?this.backend.createAttribute(e):t===Lw?this.backend.createIndexAttribute(e):t===Ow&&this.backend.createStorageAttribute(e),s.version=this._getBufferAttribute(e).version;else{const t=this._getBufferAttribute(e);(s.version=0;--t)if(e[t]>=65535)return!0;return!1}(t)?gn:pn)(t,1);return r.version=kw(e),r}class Ww extends zw{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap}has(e){const t=e.geometry;return super.has(t)&&!0===this.get(t).initialized}updateForRender(e){!1===this.has(e)&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){const t=e.geometry;this.get(t).initialized=!0,this.info.memory.geometries++;const s=()=>{this.info.memory.geometries--;const i=t.index,r=e.getAttributes();null!==i&&this.attributes.delete(i);for(const e of r)this.attributes.delete(e);const n=this.wireframes.get(t);void 0!==n&&this.attributes.delete(n),t.removeEventListener("dispose",s)};t.addEventListener("dispose",s)}updateAttributes(e){const t=e.getAttributes();for(const e of t)e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute?this.updateAttribute(e,Ow):this.updateAttribute(e,Uw);const s=this.getIndex(e);null!==s&&this.updateAttribute(s,Lw)}updateAttribute(e,t){const s=this.info.render.calls;e.isInterleavedBufferAttribute?void 0===this.attributeCall.get(e)?(this.attributes.update(e,t),this.attributeCall.set(e,s)):this.attributeCall.get(e.data)!==s&&(this.attributes.update(e,t),this.attributeCall.set(e.data,s),this.attributeCall.set(e,s)):this.attributeCall.get(e)!==s&&(this.attributes.update(e,t),this.attributeCall.set(e,s))}getIndex(e){const{geometry:t,material:s}=e;let i=t.index;if(!0===s.wireframe){const e=this.wireframes;let s=e.get(t);void 0===s?(s=Gw(t),e.set(t,s)):s.version!==kw(t)&&(this.attributes.delete(s),s=Gw(t),e.set(t,s)),i=s}return i}}class Hw{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0,previousFrameCalls:0,timestampCalls:0},this.compute={calls:0,frameCalls:0,timestamp:0,previousFrameCalls:0,timestampCalls:0},this.memory={geometries:0,textures:0}}update(e,t,s){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=s*(t/3):e.isPoints?this.render.points+=s*t:e.isLineSegments?this.render.lines+=s*(t/2):e.isLine?this.render.lines+=s*(t-1):console.error("THREE.WebGPUInfo: Unknown object type.")}updateTimestamp(e,t){0===this[e].timestampCalls&&(this[e].timestamp=0),this[e].timestamp+=t,this[e].timestampCalls++,this[e].timestampCalls>=this[e].previousFrameCalls&&(this[e].timestampCalls=0)}reset(){const e=this.render.frameCalls;this.render.previousFrameCalls=e;const t=this.compute.frameCalls;this.compute.previousFrameCalls=t,this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}}class jw{constructor(e){this.cacheKey=e,this.usedTimes=0}}class qw extends jw{constructor(e,t,s){super(e),this.vertexProgram=t,this.fragmentProgram=s}}class $w extends jw{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let Xw=0;class Yw{constructor(e,t,s=null,i=null){this.id=Xw++,this.code=e,this.stage=t,this.transforms=s,this.attributes=i,this.usedTimes=0}}class Jw extends zw{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:s}=this,i=this.get(e);if(this._needsComputeUpdate(e)){const r=i.pipeline;r&&(r.usedTimes--,r.computeProgram.usedTimes--);const n=this.nodes.getForCompute(e);let o=this.programs.compute.get(n.computeShader);void 0===o&&(r&&0===r.computeProgram.usedTimes&&this._releaseProgram(r.computeProgram),o=new Yw(n.computeShader,"compute",n.transforms,n.nodeAttributes),this.programs.compute.set(n.computeShader,o),s.createProgram(o));const a=this._getComputeCacheKey(e,o);let h=this.caches.get(a);void 0===h&&(r&&0===r.usedTimes&&this._releasePipeline(r),h=this._getComputePipeline(e,o,a,t)),h.usedTimes++,o.usedTimes++,i.version=e.version,i.pipeline=h}return i.pipeline}getForRender(e,t=null){const{backend:s}=this,i=this.get(e);if(this._needsRenderUpdate(e)){const r=i.pipeline;r&&(r.usedTimes--,r.vertexProgram.usedTimes--,r.fragmentProgram.usedTimes--);const n=e.getNodeBuilderState();let o=this.programs.vertex.get(n.vertexShader);void 0===o&&(r&&0===r.vertexProgram.usedTimes&&this._releaseProgram(r.vertexProgram),o=new Yw(n.vertexShader,"vertex"),this.programs.vertex.set(n.vertexShader,o),s.createProgram(o));let a=this.programs.fragment.get(n.fragmentShader);void 0===a&&(r&&0===r.fragmentProgram.usedTimes&&this._releaseProgram(r.fragmentProgram),a=new Yw(n.fragmentShader,"fragment"),this.programs.fragment.set(n.fragmentShader,a),s.createProgram(a));const h=this._getRenderCacheKey(e,o,a);let l=this.caches.get(h);void 0===l?(r&&0===r.usedTimes&&this._releasePipeline(r),l=this._getRenderPipeline(e,o,a,h,t)):e.pipeline=l,l.usedTimes++,o.usedTimes++,a.usedTimes++,i.pipeline=l}return i.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,0===t.usedTimes&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,0===t.computeProgram.usedTimes&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,0===t.vertexProgram.usedTimes&&this._releaseProgram(t.vertexProgram),0===t.fragmentProgram.usedTimes&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,s,i){s=s||this._getComputeCacheKey(e,t);let r=this.caches.get(s);return void 0===r&&(r=new $w(s,t),this.caches.set(s,r),this.backend.createComputePipeline(r,i)),r}_getRenderPipeline(e,t,s,i,r){i=i||this._getRenderCacheKey(e,t,s);let n=this.caches.get(i);return void 0===n&&(n=new qw(i,t,s),this.caches.set(i,n),e.pipeline=n,this.backend.createRenderPipeline(e,r)),n}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,s){return t.id+","+s.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,s=e.stage;this.programs[s].delete(t)}_needsComputeUpdate(e){const t=this.get(e);return void 0===t.pipeline||t.version!==e.version}_needsRenderUpdate(e){return void 0===this.get(e).pipeline||this.backend.needsRenderUpdate(e)}}class Zw extends zw{constructor(e,t,s,i,r,n){super(),this.backend=e,this.textures=s,this.pipelines=r,this.attributes=i,this.nodes=t,this.info=n,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const e of t){const s=this.get(e);void 0===s.bindGroup&&(this._init(e),this.backend.createBindings(e,t),s.bindGroup=e)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const e of t){const s=this.get(e);void 0===s.bindGroup&&(this._init(e),this.backend.createBindings(e,t),s.bindGroup=e)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){const e=t.attribute;this.attributes.update(e,Ow)}}_update(e,t){const{backend:s}=this;let i=!1;for(const t of e.bindings){if(t.isNodeUniformsGroup){if(!this.nodes.updateGroup(t))continue}if(t.isUniformBuffer){t.update()&&s.updateBinding(t)}else if(t.isSampler)t.update();else if(t.isSampledTexture){t.needsBindingsUpdate(this.textures.get(t.texture).generation)&&(i=!0);const e=t.update(),r=t.texture;e&&this.textures.updateTexture(r);const n=s.get(r);if(!0===s.isWebGPUBackend&&void 0===n.texture&&void 0===n.externalTexture&&(console.error("Bindings._update: binding should be available:",t,e,r,t.textureNode.value,i),this.textures.updateTexture(r),i=!0),!0===r.isStorageTexture){const e=this.get(r);!0===t.store?e.needsMipmap=!0:!0===r.generateMipmaps&&this.textures.needsMipmaps(r)&&!0===e.needsMipmap&&(this.backend.generateMipmaps(r),e.needsMipmap=!1)}}}!0===i&&this.backend.updateBindings(e,t)}}class Kw{constructor(e,t,s=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=s}}class Qw{constructor(e,t,s){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=s.getSelf()}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class eS{constructor(e,t){this.isNodeVar=!0,this.name=e,this.type=t}}class tS extends eS{constructor(e,t){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0}}class sS{constructor(e,t,s=""){this.name=e,this.type=t,this.code=s,Object.defineProperty(this,"isNodeCode",{value:!0})}}let iS=0;class rS{constructor(e=null){this.id=iS++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return void 0===t&&null!==this.parent&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class nS extends Ec{constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}Ql("Parameter",nS);const oS=(e,t)=>Du(new nS(e,t));class aS extends Kl{constructor(e="",t=[],s=""){super("code"),this.isCodeNode=!0,this.code=e,this.language=s,this.includes=t}isGlobal(){return!0}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const s of t)s.build(e);const s=e.getCodeFromNode(this,this.getNodeType(e));return s.code=this.code,s.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}Ql("Code",aS);const hS=Wu(aS),lS=(e,t)=>hS(e,t,"js"),uS=(e,t)=>hS(e,t,"wgsl"),cS=(e,t)=>hS(e,t,"glsl");class dS extends aS{constructor(e="",t=[],s=""){super(e,t,s)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let s=t.nodeFunction;return void 0===s&&(s=e.parser.parseFunction(this.code),t.nodeFunction=s),s}generate(e,t){super.generate(e);const s=this.getNodeFunction(e),i=s.name,r=s.type,n=e.getCodeFromNode(this,r);""!==i&&(n.name=i);const o=e.getPropertyName(n),a=this.getNodeFunction(e).getCode(o);return n.code=a+"\n","property"===t?o:e.format(`${o}()`,r,t)}}Ql("Function",dS);const pS=(e,t=[],s="")=>{for(let e=0;ei.call(...e);return r.functionNode=i,r},mS=(e,t)=>pS(e,t,"glsl"),gS=(e,t)=>pS(e,t,"wgsl");class fS{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class yS extends fS{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class xS extends fS{constructor(e,t=new Qs){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class bS extends fS{constructor(e,t=new Ei){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class vS extends fS{constructor(e,t=new _i){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class TS extends fS{constructor(e,t=new Yr){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class _S extends fS{constructor(e,t=new ei){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class wS extends fS{constructor(e,t=new or){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class SS extends yS{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class MS extends xS{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class AS extends bS{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class NS extends vS{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class RS extends TS{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class CS extends _S{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class ES extends wS{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class BS extends Kl{constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}add(e){return this.nodes.push(e),this}If(e,t){const s=new Vu(t);return this._currentCond=qp(e,s),this.add(this._currentCond)}ElseIf(e,t){const s=new Vu(t),i=qp(e,s);return this._currentCond.elseNode=i,this._currentCond=i,this}Else(e){return this._currentCond.elseNode=new Vu(e),this}build(e,...t){const s=Xu();$u(this);for(const t of this.nodes)t.build(e,"void");return $u(s),this.outputNode?this.outputNode.build(e,...t):super.build(e,...t)}else(...e){return console.warn("TSL.StackNode: .else() has been renamed to .Else()."),this.Else(...e)}elseif(...e){return console.warn("TSL.StackNode: .elseif() has been renamed to .ElseIf()."),this.ElseIf(...e)}}Ql("Stack",BS);const IS=Wu(BS),PS=[.125,.215,.35,.446,.526,.582],FS=20,zS=new UT(-1,1,1,-1,0,1),US=new Kn(90,1),LS=new Yr;let OS=null,VS=0,DS=0;const kS=(1+Math.sqrt(5))/2,GS=1/kS,WS=[new Ei(-kS,GS,0),new Ei(kS,GS,0),new Ei(-GS,0,kS),new Ei(GS,0,kS),new Ei(0,kS,-GS),new Ei(0,kS,GS),new Ei(-1,1,-1),new Ei(1,1,-1),new Ei(-1,1,1),new Ei(1,1,1)],HS=[3,1,5,0,4,2],jS=iv(Um(),zm("faceIndex")).normalize(),qS=oc(jS.x,jS.y.negate(),jS.z);class $S{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}fromScene(e,t=0,s=.1,i=100){OS=this._renderer.getRenderTarget(),VS=this._renderer.getActiveCubeFace(),DS=this._renderer.getActiveMipmapLevel(),this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,s,i,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=ZS(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=KS(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?h=PS[a-e+4-1]:0===a&&(h=0),i.push(h);const l=1/(o-2),u=-l,c=1+l,d=[u,u,c,u,c,c,u,u,c,c,u,c],p=6,m=6,g=3,f=2,y=1,x=new Float32Array(g*m*p),b=new Float32Array(f*m*p),v=new Float32Array(y*m*p);for(let e=0;e2?0:-1,i=[t,s,0,t+2/3,s,0,t+2/3,s+1,0,t,s,0,t+2/3,s+1,0,t,s+1,0],r=HS[e];x.set(i,g*m*r),b.set(d,f*m*r);const n=[r,r,r,r,r,r];v.set(n,y*m*r)}const T=new Mn;T.setAttribute("position",new hn(x,g)),T.setAttribute("uv",new hn(b,f)),T.setAttribute("faceIndex",new hn(v,y)),t.push(T),r.push(new Wn(T,null)),n>4&&n--}return{lodPlanes:t,sizeLods:s,sigmas:i,lodMeshes:r}}(i)),this._blurMaterial=function(e,t,s){const i=Xg(new Array(FS).fill(0)),r=Cc(new Ei(0,1,0)),n=Cc(0),o=Ku(FS),a=Cc(0),h=Cc(1),l=Gm(null),u=Cc(0),c=Ku(1/t),d=Ku(1/s),p=Ku(e),m={n:o,latitudinal:a,weights:i,poleAxis:r,outputDirection:qS,dTheta:n,samples:h,envMap:l,mipInt:u,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:p},g=JS("blur");return g.uniforms=m,g.fragmentNode=av({...m,latitudinal:a.equal(1)}),g}(i,e,t)}return i}_compileMaterial(e){const t=this._lodMeshes[0];t.material=e,this._renderer.compile(t,zS)}_sceneToCubeUV(e,t,s,i){const r=US;r.near=t,r.far=s;const n=[-1,1,-1,-1,-1,-1],o=[1,1,1,-1,-1,-1],a=this._renderer,h=a.autoClear;a.getClearColor(LS),a.autoClear=!1;let l=this._backgroundBox;if(null===l){const e=new Qr({name:"PMREM.Background",side:d,depthWrite:!1,depthTest:!1});l=new Wn(new jn,e)}let u=!1;const c=e.background;c?c.isColor&&(l.material.color.copy(c),e.background=null,u=!0):(l.material.color.copy(LS),u=!0),a.setRenderTarget(i),a.clear(),u&&a.render(l,r);for(let t=0;t<6;t++){const s=t%3;0===s?(r.up.set(0,n[t],0),r.lookAt(o[t],0,0)):1===s?(r.up.set(0,0,n[t]),r.lookAt(0,o[t],0)):(r.up.set(0,n[t],0),r.lookAt(0,0,o[t]));const h=this._cubeSize;YS(i,s*h,t>2?h:0,h,h),a.render(e,r)}a.autoClear=h,e.background=c}_textureToCubeUV(e,t){const s=this._renderer,i=e.mapping===he||e.mapping===le;i?null===this._cubemapMaterial&&(this._cubemapMaterial=ZS(e)):null===this._equirectMaterial&&(this._equirectMaterial=KS(e));const r=i?this._cubemapMaterial:this._equirectMaterial;r.fragmentNode.value=e;const n=this._lodMeshes[0];n.material=r;const o=this._cubeSize;YS(t,0,0,3*o,2*o),s.setRenderTarget(t),s.render(n,zS)}_applyPMREM(e){const t=this._renderer,s=t.autoClear;t.autoClear=!1;const i=this._lodPlanes.length;for(let t=1;tFS&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);const g=[];let f=0;for(let e=0;ey-4?i-y+4:0),4*(this._cubeSize-x),3*x,2*x),a.setRenderTarget(t),a.render(l,zS)}}function XS(e,t,s){const i=new wi(e,t,s);return i.texture.mapping=306,i.texture.name="PMREM.cubeUv",i.texture.isPMREMTexture=!0,i.scissorTest=!0,i}function YS(e,t,s,i,r){const n=e.height-r-s;e.viewport.set(t,n,i,r),e.scissor.set(t,n,i,r)}function JS(e){const t=new yx;return t.depthTest=!1,t.depthWrite=!1,t.blending=m,t.name=`PMREM_${e}`,t}function ZS(e){const t=JS("cubemap");return t.fragmentNode=Wg(e,qS),t}function KS(e){const t=JS("equirect");return t.fragmentNode=Gm(e,Bx(qS),0),t}let QS=0;class eM{constructor(e="",t=[],s=0,i=[]){this.name=e,this.bindings=t,this.index=s,this.bindingsReference=i,this.id=QS++}}const tM=new WeakMap,sM=new Map([[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),iM=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),rM=e=>(e=Number(e))+(e%1?"":".0");class nM{constructor(e,t,s){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=s,this.scene=null,this.camera=null,this.nodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.flow={code:""},this.chaining=[],this.stack=IS(),this.stacks=[],this.tab="\t",this.instanceBindGroups=!0,this.currentFunctionNode=null,this.context={material:this.material},this.cache=new rS,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.useComparisonMethod=!1}getBindGroupsCache(){let e=tM.get(this.renderer);return void 0===e&&(e=new Cw,tM.set(this.renderer,e)),e}createRenderTarget(e,t,s){return new wi(e,t,s)}createCubeRenderTarget(e,t){return new Ix(e,t)}createPMREMGenerator(){return new $S(this.renderer)}includes(e){return this.nodes.includes(e)}_getBindGroup(e,t){const s=this.getBindGroupsCache(),i=[];let r,n=!0;for(const e of t)i.push(e),n=n&&!0!==e.groupNode.shared;return n?(r=s.get(i),void 0===r&&(r=new eM(e,i,this.bindingsIndexes[e].group,i),s.set(i,r))):r=new eM(e,i,this.bindingsIndexes[e].group,i),r}getBindGroupArray(e,t){const s=this.bindings[t];let i=s[e];return void 0===i&&(void 0===this.bindingsIndexes[e]&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),s[e]=i=[]),i}getBindings(){let e=this.bindGroups;if(null===e){const t={},s=this.bindings;for(const e of Xl)for(const i in s[e]){const r=s[e][i];(t[i]||(t[i]=[])).push(...r)}e=[];for(const s in t){const i=t[s],r=this._getBindGroup(s,i);e.push(r)}this.bindGroups=e}return e}setHashNode(e,t){this.hashNodes[t]=e}addNode(e){!1===this.nodes.includes(e)&&(this.nodes.push(e),this.setHashNode(e,e.getHash(this)))}buildUpdateNodes(){for(const e of this.nodes){const t=e.getUpdateType(),s=e.getUpdateBeforeType(),i=e.getUpdateAfterType();t!==Hl.NONE&&this.updateNodes.push(e.getSelf()),s!==Hl.NONE&&this.updateBeforeNodes.push(e),i!==Hl.NONE&&this.updateAfterNodes.push(e)}}get currentNode(){return this.chaining[this.chaining.length-1]}isFilteredTexture(e){return e.magFilter===Te||e.magFilter===_e||e.magFilter===be||e.magFilter===Se||e.minFilter===Te||e.minFilter===_e||e.minFilter===be||e.minFilter===Se}addChain(e){this.chaining.push(e)}removeChain(e){if(this.chaining.pop()!==e)throw new Error("NodeBuilder: Invalid node chaining!")}getMethod(e){return e}getNodeFromHash(e){return this.hashNodes[e]}addFlow(e,t){return this.flowNodes[e].push(t),t}setContext(e){this.context=e}getContext(){return this.context}getSharedContext(){return this.context,this.context}setCache(e){this.cache=e}getCache(){return this.cache}getCacheFromNode(e,t=!0){const s=this.getDataFromNode(e);return void 0===s.cache&&(s.cache=new rS(t?this.getCache():null)),s.cache}isAvailable(){return!1}getVertexIndex(){console.warn("Abstract function.")}getInstanceIndex(){console.warn("Abstract function.")}getDrawIndex(){console.warn("Abstract function.")}getFrontFacing(){console.warn("Abstract function.")}getFragCoord(){console.warn("Abstract function.")}isFlipY(){return!1}increaseUsage(e){const t=this.getDataFromNode(e);return t.usageCount=void 0===t.usageCount?1:t.usageCount+1,t.usageCount}generateTexture(){console.warn("Abstract function.")}generateTextureLod(){console.warn("Abstract function.")}generateConst(e,t=null){if(null===t&&("float"===e||"int"===e||"uint"===e?t=0:"bool"===e?t=!1:"color"===e?t=new Yr:"vec2"===e?t=new Qs:"vec3"===e?t=new Ei:"vec4"===e&&(t=new _i)),"float"===e)return rM(t);if("int"===e)return`${Math.round(t)}`;if("uint"===e)return t>=0?`${Math.round(t)}u`:"0u";if("bool"===e)return t?"true":"false";if("color"===e)return`${this.getType("vec3")}( ${rM(t.r)}, ${rM(t.g)}, ${rM(t.b)} )`;const s=this.getTypeLength(e),i=this.getComponentType(e),r=e=>this.generateConst(i,e);if(2===s)return`${this.getType(e)}( ${r(t.x)}, ${r(t.y)} )`;if(3===s)return`${this.getType(e)}( ${r(t.x)}, ${r(t.y)}, ${r(t.z)} )`;if(4===s)return`${this.getType(e)}( ${r(t.x)}, ${r(t.y)}, ${r(t.z)}, ${r(t.w)} )`;if(s>4&&t&&(t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(r).join(", ")} )`;if(s>4)return`${this.getType(e)}()`;throw new Error(`NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return"color"===e?"vec3":e}hasGeometryAttribute(e){return this.geometry&&void 0!==this.geometry.getAttribute(e)}getAttribute(e,t){const s=this.attributes;for(const t of s)if(t.name===e)return t;const i=new Kw(e,t);return s.push(i),i}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return"void"===e||"property"===e||"sampler"===e||"texture"===e||"cubeTexture"===e||"storageTexture"===e||"depthTexture"===e||"texture3D"===e}needsColorSpaceToLinear(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===Ee)return"int";if(t===Be)return"uint"}return"float"}getElementType(e){return"mat2"===e?"vec2":"mat3"===e?"vec3":"mat4"===e?"vec4":this.getComponentType(e)}getComponentType(e){if("float"===(e=this.getVectorType(e))||"bool"===e||"int"===e||"uint"===e)return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return null===t?null:"b"===t[1]?"bool":"i"===t[1]?"int":"u"===t[1]?"uint":"float"}getVectorType(e){return"color"===e?"vec3":"texture"===e||"cubeTexture"===e||"storageTexture"===e||"texture3D"===e?"vec4":e}getTypeFromLength(e,t="float"){if(1===e)return t;const s=sM.get(e);return("float"===t?"":t[0])+s}getTypeFromArray(e){return iM.get(e.constructor)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const s=t.array,i=e.itemSize,r=e.normalized;let n;return e instanceof fn||!0===r||(n=this.getTypeFromArray(s)),this.getTypeFromLength(i,n)}getTypeLength(e){const t=this.getVectorType(e),s=/vec([2-4])/.exec(t);return null!==s?Number(s[1]):"float"===t||"bool"===t||"int"===t||"uint"===t?1:!0===/mat2/.test(e)?4:!0===/mat3/.test(e)?9:!0===/mat4/.test(e)?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return"int"===t||"uint"===t?e:this.changeComponentType(e,"int")}addStack(){return this.stack=IS(this.stack),this.stacks.push(Xu()||this.stack),$u(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,$u(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,s=null){let i=(s=null===s?e.isGlobal(this)?this.globalCache:this.cache:s).getData(e);return void 0===i&&(i={},s.setData(e,i)),void 0===i[t]&&(i[t]={}),i[t]}getNodeProperties(e,t="any"){const s=this.getDataFromNode(e,t);return s.properties||(s.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const s=this.getDataFromNode(e);let i=s.bufferAttribute;if(void 0===i){const r=this.uniforms.index++;i=new Kw("nodeAttribute"+r,t,e),this.bufferAttributes.push(i),s.bufferAttribute=i}return i}getStructTypeFromNode(e,t=this.shaderStage){const s=this.getDataFromNode(e,t);if(void 0===s.structType){const i=this.structs.index++;e.name=`StructType${i}`,this.structs[t].push(e),s.structType=e}return e}getUniformFromNode(e,t,s=this.shaderStage,i=null){const r=this.getDataFromNode(e,s,this.globalCache);let n=r.uniform;if(void 0===n){const o=this.uniforms.index++;n=new Qw(i||"nodeUniform"+o,t,e),this.uniforms[s].push(n),r.uniform=n}return n}getVarFromNode(e,t=null,s=e.getNodeType(this),i=this.shaderStage){const r=this.getDataFromNode(e,i);let n=r.variable;if(void 0===n){const e=this.vars[i]||(this.vars[i]=[]);null===t&&(t="nodeVar"+e.length),n=new eS(t,s),e.push(n),r.variable=n}return n}getVaryingFromNode(e,t=null,s=e.getNodeType(this)){const i=this.getDataFromNode(e,"any");let r=i.varying;if(void 0===r){const e=this.varyings,n=e.length;null===t&&(t="nodeVarying"+n),r=new tS(t,s),e.push(r),i.varying=r}return r}getCodeFromNode(e,t,s=this.shaderStage){const i=this.getDataFromNode(e);let r=i.code;if(void 0===r){const e=this.codes[s]||(this.codes[s]=[]),n=e.length;r=new sS("nodeCode"+n,t),e.push(r),i.code=r}return r}addLineFlowCode(e){return""===e||(e=this.tab+e,/;\s*$/.test(e)||(e+=";\n"),this.flow.code+=e),this}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+="\t",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),s=this.flowChildNode(e,t);return this.flowsData.set(e,s),s}buildFunctionNode(e){const t=new dS,s=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=s,t}flowShaderNode(e){const t=e.layout,s={[Symbol.iterator](){let e=0;const t=Object.values(this);return{next:()=>({value:t[e],done:e++>=t.length})}}};for(const e of t.inputs)s[e.name]=new nS(e.type,e.name);e.layout=null;const i=e.call(s),r=this.flowStagesNode(i,t.type);return e.layout=t,r}flowStagesNode(e,t=null){const s=this.flow,i=this.vars,r=this.cache,n=this.buildStage,o=this.stack,a={code:""};this.flow=a,this.vars={},this.cache=new rS,this.stack=IS();for(const s of $l)this.setBuildStage(s),a.result=e.build(this,t);return a.vars=this.getVars(this.shaderStage),this.flow=s,this.vars=i,this.cache=r,this.stack=o,this.setBuildStage(n),a}getFunctionOperator(){return null}flowChildNode(e,t=null){const s=this.flow,i={code:""};return this.flow=i,i.result=e.build(this,t),this.flow=s,i}flowNodeFromShaderStage(e,t,s=null,i=null){const r=this.shaderStage;this.setShaderStage(e);const n=this.flowChildNode(t,s);return null!==i&&(n.code+=`${this.tab+i} = ${n.result};\n`),this.flowCode[e]=this.flowCode[e]+n.code,this.setShaderStage(r),n}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t){return`${this.getType(e)} ${t}`}getVars(e){let t="";const s=this.vars[e];if(void 0!==s)for(const e of s)t+=`${this.getVar(e.type,e.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){const t=this.codes[e];let s="";if(void 0!==t)for(const e of t)s+=e.code+"\n";return s}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}build(){const{object:e,material:t,renderer:s}=this;if(null!==t){let e=s.nodes.library.fromMaterial(t);null===e&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),e=new yx),e.build(this)}else this.addFlow("compute",e);for(const e of $l){this.setBuildStage(e),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const t of Xl){this.setShaderStage(t);const s=this.flowNodes[t];for(const t of s)"generate"===e?this.flowNode(t):t.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if("float"===t||"int"===t||"uint"===t)return new SS(e);if("vec2"===t||"ivec2"===t||"uvec2"===t)return new MS(e);if("vec3"===t||"ivec3"===t||"uvec3"===t)return new AS(e);if("vec4"===t||"ivec4"===t||"uvec4"===t)return new NS(e);if("color"===t)return new RS(e);if("mat3"===t)return new CS(e);if("mat4"===t)return new ES(e);throw new Error(`Uniform "${t}" not declared.`)}createNodeMaterial(e="NodeMaterial"){throw new Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${e}() instead.`)}format(e,t,s){if((t=this.getVectorType(t))===(s=this.getVectorType(s))||null===s||this.isReference(s))return e;const i=this.getTypeLength(t),r=this.getTypeLength(s);return 16===i&&9===r?`${this.getType(s)}(${e}[0].xyz, ${e}[1].xyz, ${e}[2].xyz)`:9===i&&4===r?`${this.getType(s)}(${e}[0].xy, ${e}[1].xy)`:i>4||r>4||0===r?e:i===r?`${this.getType(s)}( ${e} )`:i>r?this.format(`${e}.${"xyz".slice(0,r)}`,this.getTypeFromLength(r,this.getComponentType(t)),s):4===r&&i>1?`${this.getType(s)}( ${this.format(e,t,"vec3")}, 1.0 )`:2===i?`${this.getType(s)}( ${this.format(e,t,"vec2")}, 0.0 )`:(1===i&&r>1&&t!==this.getComponentType(s)&&(e=`${this.getType(this.getComponentType(s))}( ${e} )`),`${this.getType(s)}( ${e} )`)}getSignature(){return`// Three.js r${e} - Node System\n`}}class oM{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.startTime=null,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let s=e.get(t);return void 0===s&&(s={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,s)),s}updateBeforeNode(e){const t=e.getUpdateBeforeType(),s=e.updateReference(this);if(t===Hl.FRAME){const{frameMap:t}=this._getMaps(this.updateBeforeMap,s);t.get(s)!==this.frameId&&!1!==e.updateBefore(this)&&t.set(s,this.frameId)}else if(t===Hl.RENDER){const{renderMap:t}=this._getMaps(this.updateBeforeMap,s);t.get(s)!==this.renderId&&!1!==e.updateBefore(this)&&t.set(s,this.renderId)}else t===Hl.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),s=e.updateReference(this);if(t===Hl.FRAME){const{frameMap:t}=this._getMaps(this.updateAfterMap,s);t.get(s)!==this.frameId&&!1!==e.updateAfter(this)&&t.set(s,this.frameId)}else if(t===Hl.RENDER){const{renderMap:t}=this._getMaps(this.updateAfterMap,s);t.get(s)!==this.renderId&&!1!==e.updateAfter(this)&&t.set(s,this.renderId)}else t===Hl.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),s=e.updateReference(this);if(t===Hl.FRAME){const{frameMap:t}=this._getMaps(this.updateMap,s);t.get(s)!==this.frameId&&!1!==e.update(this)&&t.set(s,this.frameId)}else if(t===Hl.RENDER){const{renderMap:t}=this._getMaps(this.updateMap,s);t.get(s)!==this.renderId&&!1!==e.update(this)&&t.set(s,this.renderId)}else t===Hl.OBJECT&&e.update(this)}update(){this.frameId++,void 0===this.lastTime&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class aM{constructor(e,t,s=null,i="",r=!1){this.type=e,this.name=t,this.count=s,this.qualifier=i,this.isConst=r}}aM.isNodeFunctionInput=!0;class hM extends Kl{constructor(e){super(),this.types=e,this.isStructTypeNode=!0}getMemberTypes(){return this.types}}Ql("StructType",hM);class lM extends Kl{constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}setup(e){super.setup(e);const t=this.members,s=[];for(let i=0;ir&&(i=s,r=n)}}this._candidateFnCall=s=i(...t)}return s}}Ql("FunctionOverloading",mM);const gM=Wu(mM),fM=e=>(...t)=>gM(e,...t);class yM extends Rc{constructor(e=yM.LOCAL,t=1,s=0){super(s),this.scope=e,this.scale=t,this.updateType=Hl.FRAME}update(e){const t=this.scope,s=this.scale;t===yM.LOCAL?this.value+=e.deltaTime*s:t===yM.DELTA?this.value=e.deltaTime*s:t===yM.FRAME?this.value=e.frameId:this.value=e.time*s}serialize(e){super.serialize(e),e.scope=this.scope,e.scale=this.scale}deserialize(e){super.deserialize(e),this.scope=e.scope,this.scale=e.scale}}yM.LOCAL="local",yM.GLOBAL="global",yM.DELTA="delta",yM.FRAME="frame",Ql("Timer",yM);const xM=(e,t=0)=>Du(new yM(yM.LOCAL,e,t)),bM=(e,t=0)=>Du(new yM(yM.GLOBAL,e,t)),vM=(e,t=0)=>Du(new yM(yM.DELTA,e,t)),TM=Hu(yM,yM.FRAME).toUint();class _M extends Kl{constructor(e=_M.SINE,t=xM()){super(),this.method=e,this.timeNode=t}getNodeType(e){return this.timeNode.getNodeType(e)}setup(){const e=this.method,t=Du(this.timeNode);let s=null;return e===_M.SINE?s=t.add(.75).mul(2*Math.PI).sin().mul(.5).add(.5):e===_M.SQUARE?s=t.fract().round():e===_M.TRIANGLE?s=t.add(.5).fract().mul(2).sub(1).abs():e===_M.SAWTOOTH&&(s=t.fract()),s}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}_M.SINE="sine",_M.SQUARE="square",_M.TRIANGLE="triangle",_M.SAWTOOTH="sawtooth",Ql("Osc",_M);const wM=Wu(_M,_M.SINE),SM=Wu(_M,_M.SQUARE),MM=Wu(_M,_M.TRIANGLE),AM=Wu(_M,_M.SAWTOOTH);class NM extends Kl{constructor(e,t=Um(),s=Ku(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=s}setup(){const{frameNode:e,uvNode:t,countNode:s}=this,{width:i,height:r}=s,n=e.mod(i.mul(r)).floor(),o=n.mod(i),a=r.sub(n.add(1).div(i).ceil()),h=s.reciprocal(),l=sc(o,a);return t.add(l).mul(h)}}Ql("SpriteSheetUV",NM);const RM=Wu(NM);class CM extends tu{constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}setup(e){return!1===e.isAvailable("storageBuffer")&&(this.node.instanceIndex||!0!==this.node.bufferObject||e.setupPBO(this.node)),super.setup(e)}generate(e,t){let s;const i=e.context.assign;if(!1===e.isAvailable("storageBuffer")){const{node:t}=this;s=t.instanceIndex||!0!==this.node.bufferObject||!0===i?t.build(e):e.generatePBO(this)}else s=super.generate(e);if(!0!==i){const i=this.getNodeType(e);s=e.format(s,i,t)}return s}}Ql("StorageArrayElement",CM);const EM=Wu(CM);class BM extends Kl{constructor(e,t=null,s=null,i=Ku(1),r=bg,n=Cg){super("vec4"),this.textureXNode=e,this.textureYNode=t,this.textureZNode=s,this.scaleNode=i,this.positionNode=r,this.normalNode=n}setup(){const{textureXNode:e,textureYNode:t,textureZNode:s,scaleNode:i,positionNode:r,normalNode:n}=this;let o=n.abs().normalize();o=o.div(o.dot(oc(1)));const a=r.yz.mul(i),h=r.zx.mul(i),l=r.xy.mul(i),u=e.value,c=null!==t?t.value:u,d=null!==s?s.value:u,p=Gm(u,a).mul(o.x),m=Gm(c,h).mul(o.y),g=Gm(d,l).mul(o.z);return dd(p,m,g)}}Ql("TriplanarTextures",BM);const IM=Wu(BM),PM=(...e)=>IM(...e),FM=new sa,zM=new Ei,UM=new Ei,LM=new Ei,OM=new or,VM=new Ei(0,0,-1),DM=new _i,kM=new Ei,GM=new Ei,WM=new _i,HM=new Qs,jM=new wi,qM=Zy.flipX();let $M=!1;class XM extends km{constructor(e={}){super(jM.texture,qM);const{target:t=new Pr,resolution:s=1,generateMipmaps:i=!1,bounces:r=!0}=e;this.target=t,this.resolution=s,this.generateMipmaps=i,this.bounces=r,this.updateBeforeType=r?Hl.RENDER:Hl.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new WeakMap}_updateResolution(e,t){const s=this.resolution;t.getDrawingBufferSize(HM),e.setSize(Math.round(HM.width*s),Math.round(HM.height*s))}setup(e){return this._updateResolution(jM,e.renderer),super.setup(e)}getTextureNode(){return this.textureNode}getVirtualCamera(e){let t=this.virtualCameras.get(e);return void 0===t&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return void 0===t&&(t=new wi(0,0,{type:Pe}),!0===this.generateMipmaps&&(t.texture.minFilter=1008,t.texture.generateMipmaps=!0),this.renderTargets.set(e,t)),t}updateBefore(e){if(!1===this.bounces&&$M)return!1;$M=!0;const{scene:t,camera:s,renderer:i,material:r}=e,{target:n}=this,o=this.getVirtualCamera(s),a=this.getRenderTarget(o);if(i.getDrawingBufferSize(HM),this._updateResolution(a,i),UM.setFromMatrixPosition(n.matrixWorld),LM.setFromMatrixPosition(s.matrixWorld),OM.extractRotation(n.matrixWorld),zM.set(0,0,1),zM.applyMatrix4(OM),kM.subVectors(UM,LM),kM.dot(zM)>0)return;kM.reflect(zM).negate(),kM.add(UM),OM.extractRotation(s.matrixWorld),VM.set(0,0,-1),VM.applyMatrix4(OM),VM.add(LM),GM.subVectors(UM,VM),GM.reflect(zM).negate(),GM.add(UM),o.coordinateSystem=s.coordinateSystem,o.position.copy(kM),o.up.set(0,1,0),o.up.applyMatrix4(OM),o.up.reflect(zM),o.lookAt(GM),o.near=s.near,o.far=s.far,o.updateMatrixWorld(),o.projectionMatrix.copy(s.projectionMatrix),FM.setFromNormalAndCoplanarPoint(zM,UM),FM.applyMatrix4(o.matrixWorldInverse),DM.set(FM.normal.x,FM.normal.y,FM.normal.z,FM.constant);const h=o.projectionMatrix;WM.x=(Math.sign(DM.x)+h.elements[8])/h.elements[0],WM.y=(Math.sign(DM.y)+h.elements[9])/h.elements[5],WM.z=-1,WM.w=(1+h.elements[10])/h.elements[14],DM.multiplyScalar(1/DM.dot(WM));h.elements[2]=DM.x,h.elements[6]=DM.y,h.elements[10]=DM.z-0,h.elements[14]=DM.w,this.value=a.texture,r.visible=!1;const l=i.getRenderTarget(),u=i.getMRT();i.setMRT(null),i.setRenderTarget(a),i.render(t,o),i.setMRT(u),i.setRenderTarget(l),r.visible=!0,$M=!1}}const YM=e=>Du(new XM(e));Ql("Reflector",XM);const JM=new UT(-1,1,1,-1,0,1);class ZM extends Mn{constructor(e=!1){super();const t=!1===e?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new yn([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new yn(t,2))}}const KM=new ZM;class QM extends Wn{constructor(e=null){super(KM,e),this.camera=JM,this.isQuadMesh=!0}renderAsync(e){return e.renderAsync(this,JM)}render(e){e.render(this,JM)}}const eA=new Qs;class tA extends km{constructor(e,t=null,s=null,i={type:Pe}){const r=new wi(t,s,i);super(r.texture,Um()),this.node=e,this.width=t,this.height=s,this.renderTarget=r,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this.updateMap=new WeakMap,this._rttNode=null,this._quadMesh=new QM(new yx),this.updateBeforeType=Hl.RENDER}get autoSize(){return null===this.width}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;const s=e*this.pixelRatio,i=t*this.pixelRatio;this.renderTarget.setSize(s,i),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(!1===this.textureNeedsUpdate&&!1===this.autoUpdate)return;if(this.textureNeedsUpdate=!1,!0===this.autoSize){this.pixelRatio=e.getPixelRatio();const t=e.getSize(eA);this.setSize(t.width,t.height)}this._quadMesh.material.fragmentNode=this._rttNode;const t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new km(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}Ql("RTT",tA);const sA=(e,...t)=>Du(new tA(Du(e),...t)),iA=(e,...t)=>e.isTextureNode?e:sA(e,...t);class rA extends Fm{constructor(e=0){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e);let s;return s=!0===e.hasGeometryAttribute(t)?super.generate(e):e.generateConst(this.nodeType,new _i(1,1,1,1)),s}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}Ql("VertexColor",rA);const nA=(...e)=>Du(new rA(...e));class oA extends Kl{constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}Ql("PointUV",oA);const aA=Hu(oA);class hA extends Kl{constructor(e=hA.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,s=null!==this.scene?this.scene:e.scene;let i;return t===hA.BACKGROUND_BLURRINESS?i=Zg("backgroundBlurriness","float",s):t===hA.BACKGROUND_INTENSITY?i=Zg("backgroundIntensity","float",s):console.error("THREE.SceneNode: Unknown scope:",t),i}}hA.BACKGROUND_BLURRINESS="backgroundBlurriness",hA.BACKGROUND_INTENSITY="backgroundIntensity",Ql("Scene",hA);const lA=Hu(hA,hA.BACKGROUND_BLURRINESS),uA=Hu(hA,hA.BACKGROUND_INTENSITY),cA="point-list",dA="line-list",pA="line-strip",mA="triangle-list",gA="triangle-strip",fA="never",yA="less",xA="equal",bA="less-equal",vA="greater",TA="not-equal",_A="greater-equal",wA="always",SA="store",MA="load",AA="clear",NA="ccw",RA="none",CA="front",EA="back",BA="uint16",IA="uint32",PA={R8Unorm:"r8unorm",R8Snorm:"r8snorm",R8Uint:"r8uint",R8Sint:"r8sint",R16Uint:"r16uint",R16Sint:"r16sint",R16Float:"r16float",RG8Unorm:"rg8unorm",RG8Snorm:"rg8snorm",RG8Uint:"rg8uint",RG8Sint:"rg8sint",R32Uint:"r32uint",R32Sint:"r32sint",R32Float:"r32float",RG16Uint:"rg16uint",RG16Sint:"rg16sint",RG16Float:"rg16float",RGBA8Unorm:"rgba8unorm",RGBA8UnormSRGB:"rgba8unorm-srgb",RGBA8Snorm:"rgba8snorm",RGBA8Uint:"rgba8uint",RGBA8Sint:"rgba8sint",BGRA8Unorm:"bgra8unorm",BGRA8UnormSRGB:"bgra8unorm-srgb",RGB9E5UFloat:"rgb9e5ufloat",RGB10A2Unorm:"rgb10a2unorm",RG11B10uFloat:"rgb10a2unorm",RG32Uint:"rg32uint",RG32Sint:"rg32sint",RG32Float:"rg32float",RGBA16Uint:"rgba16uint",RGBA16Sint:"rgba16sint",RGBA16Float:"rgba16float",RGBA32Uint:"rgba32uint",RGBA32Sint:"rgba32sint",RGBA32Float:"rgba32float",Stencil8:"stencil8",Depth16Unorm:"depth16unorm",Depth24Plus:"depth24plus",Depth24PlusStencil8:"depth24plus-stencil8",Depth32Float:"depth32float",Depth32FloatStencil8:"depth32float-stencil8",BC1RGBAUnorm:"bc1-rgba-unorm",BC1RGBAUnormSRGB:"bc1-rgba-unorm-srgb",BC2RGBAUnorm:"bc2-rgba-unorm",BC2RGBAUnormSRGB:"bc2-rgba-unorm-srgb",BC3RGBAUnorm:"bc3-rgba-unorm",BC3RGBAUnormSRGB:"bc3-rgba-unorm-srgb",BC4RUnorm:"bc4-r-unorm",BC4RSnorm:"bc4-r-snorm",BC5RGUnorm:"bc5-rg-unorm",BC5RGSnorm:"bc5-rg-snorm",BC6HRGBUFloat:"bc6h-rgb-ufloat",BC6HRGBFloat:"bc6h-rgb-float",BC7RGBAUnorm:"bc7-rgba-unorm",BC7RGBAUnormSRGB:"bc7-rgba-srgb",ETC2RGB8Unorm:"etc2-rgb8unorm",ETC2RGB8UnormSRGB:"etc2-rgb8unorm-srgb",ETC2RGB8A1Unorm:"etc2-rgb8a1unorm",ETC2RGB8A1UnormSRGB:"etc2-rgb8a1unorm-srgb",ETC2RGBA8Unorm:"etc2-rgba8unorm",ETC2RGBA8UnormSRGB:"etc2-rgba8unorm-srgb",EACR11Unorm:"eac-r11unorm",EACR11Snorm:"eac-r11snorm",EACRG11Unorm:"eac-rg11unorm",EACRG11Snorm:"eac-rg11snorm",ASTC4x4Unorm:"astc-4x4-unorm",ASTC4x4UnormSRGB:"astc-4x4-unorm-srgb",ASTC5x4Unorm:"astc-5x4-unorm",ASTC5x4UnormSRGB:"astc-5x4-unorm-srgb",ASTC5x5Unorm:"astc-5x5-unorm",ASTC5x5UnormSRGB:"astc-5x5-unorm-srgb",ASTC6x5Unorm:"astc-6x5-unorm",ASTC6x5UnormSRGB:"astc-6x5-unorm-srgb",ASTC6x6Unorm:"astc-6x6-unorm",ASTC6x6UnormSRGB:"astc-6x6-unorm-srgb",ASTC8x5Unorm:"astc-8x5-unorm",ASTC8x5UnormSRGB:"astc-8x5-unorm-srgb",ASTC8x6Unorm:"astc-8x6-unorm",ASTC8x6UnormSRGB:"astc-8x6-unorm-srgb",ASTC8x8Unorm:"astc-8x8-unorm",ASTC8x8UnormSRGB:"astc-8x8-unorm-srgb",ASTC10x5Unorm:"astc-10x5-unorm",ASTC10x5UnormSRGB:"astc-10x5-unorm-srgb",ASTC10x6Unorm:"astc-10x6-unorm",ASTC10x6UnormSRGB:"astc-10x6-unorm-srgb",ASTC10x8Unorm:"astc-10x8-unorm",ASTC10x8UnormSRGB:"astc-10x8-unorm-srgb",ASTC10x10Unorm:"astc-10x10-unorm",ASTC10x10UnormSRGB:"astc-10x10-unorm-srgb",ASTC12x10Unorm:"astc-12x10-unorm",ASTC12x10UnormSRGB:"astc-12x10-unorm-srgb",ASTC12x12Unorm:"astc-12x12-unorm",ASTC12x12UnormSRGB:"astc-12x12-unorm-srgb"},FA="clamp-to-edge",zA="repeat",UA="mirror-repeat",LA="linear",OA="nearest",VA="zero",DA="one",kA="src",GA="one-minus-src",WA="src-alpha",HA="one-minus-src-alpha",jA="dst",qA="one-minus-dst",$A="dst-alpha",XA="one-minus-dst-alpha",YA="src-alpha-saturated",JA="constant",ZA="one-minus-constant",KA="add",QA="subtract",eN="reverse-subtract",tN="min",sN="max",iN=0,rN=15,nN="keep",oN="zero",aN="replace",hN="invert",lN="increment-clamp",uN="decrement-clamp",cN="increment-wrap",dN="decrement-wrap",pN="storage",mN="read-only-storage",gN="write-only",fN="read-only",yN="float",xN="unfilterable-float",bN="depth",vN="sint",TN="uint",_N="2d",wN="3d",SN="2d",MN="2d-array",AN="cube",NN="3d",RN="all",CN="vertex",EN="instance",BN={DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups"};class IN extends Hg{constructor(e,t,s=0){super(e,t,s),this.isStorageBufferNode=!0,this.access=pN,this.bufferObject=!1,this.bufferCount=s,this._attribute=null,this._varying=null,this.global=!0,!0!==e.isStorageBufferAttribute&&!0!==e.isStorageInstancedBufferAttribute&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(0===this.bufferCount){let t=e.globalCache.getData(this.value);return void 0===t&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return"storageBuffer"}element(e){return EM(this,e)}setBufferObject(e){return this.bufferObject=e,this}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(mN)}generate(e){if(e.isAvailable("storageBuffer"))return super.generate(e);const t=this.getNodeType(e);null===this._attribute&&(this._attribute=mm(this.value),this._varying=em(this._attribute));const s=this._varying.build(e,t);return e.registerTransform(s,this._attribute),s}}Ql("StorageBuffer",IN);const PN=(e,t,s)=>Du(new IN(e,t,s)),FN=(e,t,s)=>Du(new IN(e,t,s).setBufferObject(!0));class zN extends km{constructor(e,t,s=null){super(e,t),this.storeNode=s,this.isStorageTextureNode=!0,this.access=gN}getInputType(){return"storageTexture"}setup(e){super.setup(e);e.getNodeProperties(this).storeNode=this.storeNode}setAccess(e){return this.access=e,this}generate(e,t){let s;return s=null!==this.storeNode?this.generateStore(e):super.generate(e,t),s}toReadOnly(){return this.setAccess(fN)}toWriteOnly(){return this.setAccess(gN)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:s,storeNode:i}=t,r=super.generate(e,"property"),n=s.build(e,"uvec2"),o=i.build(e,"vec4"),a=e.generateTextureStore(e,r,n,o);e.addLineFlowCode(a)}}Ql("StorageTexture",zN);const UN=Wu(zN),LN=(e,t,s)=>{const i=UN(e,t,s);return null!==s&&i.append(),i};class ON extends Jg{constructor(e,t,s=null){super(e,t,s),this.userData=s}update(e){this.reference=null!==this.userData?this.userData:e.object.userData,super.update(e)}}Ql("UserData",ON);const VN=(e,t,s)=>Du(new ON(e,t,s));class DN extends iu{constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}Ql("Posterize",DN);const kN=Wu(DN);let GN=null;class WN extends tx{constructor(e=Zy,t=null){null===GN&&(GN=new Xa),super(e,t,GN)}updateReference(){return this}}Ql("ViewportSharedTexture",WN);const HN=Wu(WN),jN=new Qs;class qN extends km{constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}Ql("PassTexture",qN);class $N extends qN{constructor(e,t,s=!1){super(e,null),this.textureName=t,this.previousTexture=s}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}Ql("PassMultipleTexture",$N);class XN extends iu{constructor(e,t,s,i={}){super("vec4"),this.scope=e,this.scene=t,this.camera=s,this.options=i,this._pixelRatio=1,this._width=1,this._height=1;const r=new Qa;r.isRenderTargetTexture=!0,r.name="depth";const n=new wi(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Pe,...i});n.texture.name="output",n.depthTexture=r,this.renderTarget=n,this.updateBeforeType=Hl.FRAME,this._textures={output:n.texture,depth:r},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=Cc(0),this._cameraFar=Cc(0),this._mrt=null,this.isPassNode=!0}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}isGlobal(){return!0}getTexture(e){let t=this._textures[e];if(void 0===t){t=this.renderTarget.texture.clone(),t.isRenderTargetTexture=!0,t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return void 0===t&&(t=this.getTexture(e).clone(),t.isRenderTargetTexture=!0,this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(void 0!==t){const s=this._textures[e],i=this.renderTarget.textures.indexOf(s);this.renderTarget.textures[i]=t,this._textures[e]=t,this._previousTextures[e]=s,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return void 0===t&&(this._textureNodes[e]=t=Du(new $N(this,e)),this._textureNodes[e].updateTexture()),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return void 0===t&&(void 0===this._textureNodes[e]&&this.getTextureNode(e),this._previousTextureNodes[e]=t=Du(new $N(this,e,!0)),this._previousTextureNodes[e].updateTexture()),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(void 0===t){const s=this._cameraNear,i=this._cameraFar;this._viewZNodes[e]=t=cx(this.getTextureNode(e),s,i)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(void 0===t){const s=this._cameraNear,i=this._cameraFar,r=this.getViewZNode(e);this._linearDepthNodes[e]=t=hx(r,s,i)}return t}setup({renderer:e}){return this.renderTarget.samples=void 0===this.options.samples?e.samples:this.options.samples,!0===e.backend.isWebGLBackend&&(this.renderTarget.samples=0),this.renderTarget.depthTexture.isMultisampleRenderTargetTexture=this.renderTarget.samples>1,this.scope===XN.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:s,camera:i}=this;this._pixelRatio=t.getPixelRatio();const r=t.getSize(jN);this.setSize(r.width,r.height);const n=t.getRenderTarget(),o=t.getMRT();this._cameraNear.value=i.near,this._cameraFar.value=i.far;for(const e in this._previousTextures)this.toggleTexture(e);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(s,i),t.setRenderTarget(n),t.setMRT(o)}setSize(e,t){this._width=e,this._height=t;const s=this._width*this._pixelRatio,i=this._height*this._pixelRatio;this.renderTarget.setSize(s,i)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}XN.COLOR="color",XN.DEPTH="depth",Ql("Pass",XN);const YN=(e,t,s)=>Du(new XN(XN.COLOR,e,t,s)),JN=(e,t)=>Du(new qN(e,t)),ZN=(e,t)=>Du(new XN(XN.DEPTH,e,t)),KN=new QM,QN=new QM;class eR extends iu{constructor(e,t=null,s=2){super("vec4"),this.textureNode=e,this.directionNode=t,this.sigma=s,this._invSize=Cc(new Qs),this._passDirection=Cc(new Qs),this._horizontalRT=new wi,this._horizontalRT.texture.name="GaussianBlurNode.horizontal",this._verticalRT=new wi,this._verticalRT.texture.name="GaussianBlurNode.vertical",this._textureNode=JN(this,this._verticalRT.texture),this.updateBeforeType=Hl.RENDER,this.resolution=new Qs(1,1)}setSize(e,t){e=Math.max(Math.round(e*this.resolution.x),1),t=Math.max(Math.round(t*this.resolution.y),1),this._invSize.value.set(1/e,1/t),this._horizontalRT.setSize(e,t),this._verticalRT.setSize(e,t)}updateBefore(e){const{renderer:t}=e,s=this.textureNode,i=s.value,r=t.getRenderTarget(),n=t.getMRT(),o=s.value;KN.material=this._material,QN.material=this._material,this.setSize(i.image.width,i.image.height);const a=i.type;this._horizontalRT.texture.type=a,this._verticalRT.texture.type=a,t.setMRT(null),t.setRenderTarget(this._horizontalRT),this._passDirection.value.set(1,0),KN.render(t),s.value=this._horizontalRT.texture,t.setRenderTarget(this._verticalRT),this._passDirection.value.set(0,1),QN.render(t),t.setRenderTarget(r),t.setMRT(n),s.value=o}getTextureNode(){return this._textureNode}setup(e){const t=this.textureNode;if(!0!==t.isTextureNode)return console.error("GaussianBlurNode requires a TextureNode."),uc();const s=t.uvNode||Um(),i=sc(this.directionNode||1),r=e=>t.uv(e),n=ju((()=>{const e=3+2*this.sigma,t=this._getCoefficients(e),n=this._invSize,o=i.mul(this._passDirection),a=Ku(t[0]).toVar(),h=uc(r(s).mul(a)).toVar();for(let i=1;iDu(new eR(iA(e),t,s)),sR=new Qs,iR=new QM;class rR extends iu{constructor(e,t=.96){super(e),this.textureNode=e,this.textureNodeOld=Gm(),this.damp=Cc(t),this._compRT=new wi,this._compRT.texture.name="AfterImageNode.comp",this._oldRT=new wi,this._oldRT.texture.name="AfterImageNode.old",this._textureNode=JN(this,this._compRT.texture),this.updateBeforeType=Hl.RENDER}getTextureNode(){return this._textureNode}setSize(e,t){this._compRT.setSize(e,t),this._oldRT.setSize(e,t)}updateBefore(e){const{renderer:t}=e,s=this.textureNode,i=s.value.type;this._compRT.texture.type=i,this._oldRT.texture.type=i,t.getDrawingBufferSize(sR),this.setSize(sR.x,sR.y);const r=t.getRenderTarget(),n=s.value;this.textureNodeOld.value=this._oldRT.texture,t.setRenderTarget(this._compRT),iR.render(t);const o=this._oldRT;this._oldRT=this._compRT,this._compRT=o,t.setRenderTarget(r),s.value=n}setup(e){const t=this.textureNode,s=this.textureNodeOld,i=t.uvNode||Um();s.uvNode=i;const r=ju((([e,t])=>{const s=Ku(t).toVar(),i=uc(e).toVar();return Tp(ap(i.sub(s)),0)})),n=ju((()=>{const e=uc(s),n=uc((e=>t.uv(e))(i));return e.mulAssign(this.damp.mul(r(e,.1))),Tp(n,e)})),o=this._materialComposed||(this._materialComposed=new yx);o.name="AfterImage",o.fragmentNode=n(),iR.material=o;return e.getNodeProperties(this).textureNode=t,this._textureNode}dispose(){this._compRT.dispose(),this._oldRT.dispose()}}const nR=(e,t)=>Du(new rR(iA(e),t)),oR=ju((([e])=>cR(e.rgb))),aR=ju((([e,t=Ku(1)])=>t.mix(cR(e.rgb),e.rgb))),hR=ju((([e,t=Ku(1)])=>{const s=dd(e.r,e.g,e.b).div(3),i=e.r.max(e.g.max(e.b)),r=i.sub(s).mul(t).mul(-3);return Up(e.rgb,i,r)})),lR=ju((([e,t=Ku(1)])=>{const s=oc(.57735,.57735,.57735),i=t.cos();return oc(e.rgb.mul(i).add(s.cross(e.rgb).mul(t.sin()).add(s.mul(Np(s,e.rgb).mul(i.oneMinus())))))})),uR=new Ei,cR=(e,t=oc(...di.getLuminanceCoefficients(uR)))=>Np(e,t),dR=(e,t)=>Up(oc(0),e,cR(e).sub(t).max(0)),pR=new QM;class mR extends iu{constructor(e,t,s,i){super("vec4"),this.textureNode=e,this.tresholdNode=t,this.scaleNode=s,this.colorNode=oc(.1,0,1),this.samples=i,this.resolution=new Qs(1,1),this._renderTarget=new wi,this._renderTarget.texture.name="anamorphic",this._invSize=Cc(new Qs),this._textureNode=JN(this,this._renderTarget.texture),this.updateBeforeType=Hl.RENDER}getTextureNode(){return this._textureNode}setSize(e,t){this._invSize.value.set(1/e,1/t),e=Math.max(Math.round(e*this.resolution.x),1),t=Math.max(Math.round(t*this.resolution.y),1),this._renderTarget.setSize(e,t)}updateBefore(e){const{renderer:t}=e,s=this.textureNode,i=s.value;this._renderTarget.texture.type=i.type;const r=t.getRenderTarget(),n=s.value;pR.material=this._material,this.setSize(i.image.width,i.image.height),t.setRenderTarget(this._renderTarget),pR.render(t),t.setRenderTarget(r),s.value=n}setup(e){const t=this.textureNode,s=t.uvNode||Um(),i=ju((()=>{const e=this.samples,i=Math.floor(e/2),r=oc(0).toVar();return Cy({start:-i,end:i},(({i:e})=>{const n=Ku(e).abs().div(i).oneMinus(),o=(e=>t.uv(e))(sc(s.x.add(this._invSize.x.mul(e).mul(this.scaleNode)),s.y)),a=dR(o,this.tresholdNode).mul(n);r.addAssign(a)})),r.mul(this.colorNode)})),r=this._material||(this._material=new yx);r.name="Anamorphic",r.fragmentNode=i();return e.getNodeProperties(this).textureNode=t,this._textureNode}dispose(){this._renderTarget.dispose()}}const gR=(e,t=.9,s=3,i=32)=>Du(new mR(iA(e),Du(t),Du(s),i));class fR extends iu{constructor(e){super(),this.textureNode=e,this.updateBeforeType=Hl.RENDER,this._invSize=Cc(new Qs)}updateBefore(){const e=this.textureNode.value;this._invSize.value.set(1/e.image.width,1/e.image.height)}setup(){const{textureNode:e}=this,t=e.uvNode||Um(),s=t=>e.uv(t);return ju((()=>{const e=this._invSize,i=gc(-1,-2,-1,0,0,0,1,2,1),r=gc(-1,0,1,-2,0,2,-1,0,1),n=cR(s(t.add(e.mul(sc(-1,-1)))).xyz),o=cR(s(t.add(e.mul(sc(-1,0)))).xyz),a=cR(s(t.add(e.mul(sc(-1,1)))).xyz),h=cR(s(t.add(e.mul(sc(0,-1)))).xyz),l=cR(s(t.add(e.mul(sc(0,0)))).xyz),u=cR(s(t.add(e.mul(sc(0,1)))).xyz),c=cR(s(t.add(e.mul(sc(1,-1)))).xyz),d=cR(s(t.add(e.mul(sc(1,0)))).xyz),p=cR(s(t.add(e.mul(sc(1,1)))).xyz),m=dd(i[0][0].mul(n),i[1][0].mul(h),i[2][0].mul(c),i[0][1].mul(o),i[1][1].mul(l),i[2][1].mul(d),i[0][2].mul(a),i[1][2].mul(u),i[2][2].mul(p)),g=dd(r[0][0].mul(n),r[1][0].mul(h),r[2][0].mul(c),r[0][1].mul(o),r[1][1].mul(l),r[2][1].mul(d),r[0][2].mul(a),r[1][2].mul(u),r[2][2].mul(p)),f=m.mul(m).add(g.mul(g)).sqrt();return uc(oc(f),1)}))()}}Ql("SobelOperator",fR);const yR=e=>Du(new fR(iA(e)));class xR extends iu{constructor(e,t,s,i,r){super(),this.textureNode=e,this.viewZNode=t,this.focusNode=s,this.apertureNode=i,this.maxblurNode=r,this._aspect=Cc(0),this.updateBeforeType=Hl.RENDER}updateBefore(){const e=this.textureNode.value;this._aspect.value=e.image.width/e.image.height}setup(){const e=this.textureNode,t=e.uvNode||Um(),s=t=>e.uv(t);return ju((()=>{const e=sc(1,this._aspect),i=this.focusNode.add(this.viewZNode),r=sc(Lp(i.mul(this.apertureNode),this.maxblurNode.negate(),this.maxblurNode)),n=r.mul(.9),o=r.mul(.7),a=r.mul(.4);let h=uc(0);return h=h.add(s(t)),h=h.add(s(t.add(sc(0,.4).mul(e).mul(r)))),h=h.add(s(t.add(sc(.15,.37).mul(e).mul(r)))),h=h.add(s(t.add(sc(.29,.29).mul(e).mul(r)))),h=h.add(s(t.add(sc(-.37,.15).mul(e).mul(r)))),h=h.add(s(t.add(sc(.4,0).mul(e).mul(r)))),h=h.add(s(t.add(sc(.37,-.15).mul(e).mul(r)))),h=h.add(s(t.add(sc(.29,-.29).mul(e).mul(r)))),h=h.add(s(t.add(sc(-.15,-.37).mul(e).mul(r)))),h=h.add(s(t.add(sc(0,-.4).mul(e).mul(r)))),h=h.add(s(t.add(sc(-.15,.37).mul(e).mul(r)))),h=h.add(s(t.add(sc(-.29,.29).mul(e).mul(r)))),h=h.add(s(t.add(sc(.37,.15).mul(e).mul(r)))),h=h.add(s(t.add(sc(-.4,0).mul(e).mul(r)))),h=h.add(s(t.add(sc(-.37,-.15).mul(e).mul(r)))),h=h.add(s(t.add(sc(-.29,-.29).mul(e).mul(r)))),h=h.add(s(t.add(sc(.15,-.37).mul(e).mul(r)))),h=h.add(s(t.add(sc(.15,.37).mul(e).mul(n)))),h=h.add(s(t.add(sc(-.37,.15).mul(e).mul(n)))),h=h.add(s(t.add(sc(.37,-.15).mul(e).mul(n)))),h=h.add(s(t.add(sc(-.15,-.37).mul(e).mul(n)))),h=h.add(s(t.add(sc(-.15,.37).mul(e).mul(n)))),h=h.add(s(t.add(sc(.37,.15).mul(e).mul(n)))),h=h.add(s(t.add(sc(-.37,-.15).mul(e).mul(n)))),h=h.add(s(t.add(sc(.15,-.37).mul(e).mul(n)))),h=h.add(s(t.add(sc(.29,.29).mul(e).mul(o)))),h=h.add(s(t.add(sc(.4,0).mul(e).mul(o)))),h=h.add(s(t.add(sc(.29,-.29).mul(e).mul(o)))),h=h.add(s(t.add(sc(0,-.4).mul(e).mul(o)))),h=h.add(s(t.add(sc(-.29,.29).mul(e).mul(o)))),h=h.add(s(t.add(sc(-.4,0).mul(e).mul(o)))),h=h.add(s(t.add(sc(-.29,-.29).mul(e).mul(o)))),h=h.add(s(t.add(sc(0,.4).mul(e).mul(o)))),h=h.add(s(t.add(sc(.29,.29).mul(e).mul(a)))),h=h.add(s(t.add(sc(.4,0).mul(e).mul(a)))),h=h.add(s(t.add(sc(.29,-.29).mul(e).mul(a)))),h=h.add(s(t.add(sc(0,-.4).mul(e).mul(a)))),h=h.add(s(t.add(sc(-.29,.29).mul(e).mul(a)))),h=h.add(s(t.add(sc(-.4,0).mul(e).mul(a)))),h=h.add(s(t.add(sc(-.29,-.29).mul(e).mul(a)))),h=h.add(s(t.add(sc(0,.4).mul(e).mul(a)))),h=h.div(41),h.a=1,uc(h)}))()}}Ql("DepthOfField",xR);const bR=(e,t,s=1,i=.025,r=1)=>Du(new xR(iA(e),Du(t),Du(s),Du(i),Du(r)));class vR extends iu{constructor(e,t=new Qs(.5,.5),s=1.57,i=1){super("vec4"),this.inputNode=e,this.center=Cc(t),this.angle=Cc(s),this.scale=Cc(i)}setup(){const e=this.inputNode,t=ju((()=>{const e=ep(this.angle),t=tp(this.angle),s=Um().mul(Yy).sub(this.center),i=sc(t.mul(s.x).sub(e.mul(s.y)),e.mul(s.x).add(t.mul(s.y))).mul(this.scale);return ep(i.x).mul(ep(i.y)).mul(4)})),s=ju((()=>{const s=e,i=dd(s.r,s.g,s.b).div(3);return uc(oc(i.mul(10).sub(5).add(t())),s.a)}));return s()}}Ql("DotScreen",vR);const TR=(e,t,s,i)=>Du(new vR(Du(e),t,s,i));class _R extends iu{constructor(e,t=.005,s=0){super("vec4"),this.textureNode=e,this.amount=Cc(t),this.angle=Cc(s)}setup(){const{textureNode:e}=this,t=e.uvNode||Um(),s=t=>e.uv(t);return ju((()=>{const e=sc(tp(this.angle),ep(this.angle)).mul(this.amount),i=s(t.add(e)),r=s(t),n=s(t.sub(e));return uc(i.r,r.g,n.b,r.a)}))()}}Ql("RGBShift",_R);const wR=(e,t,s)=>Du(new _R(iA(e),t,s));class SR extends iu{constructor(e,t=null,s=null){super(),this.inputNode=e,this.intensityNode=t,this.uvNode=s}setup(){const e=this.uvNode||Um(),t=ju((()=>{const t=this.inputNode.rgb,s=Gp(Qd(e.add(xM())));let i=t.add(t.mul(Lp(s.add(.1),0,1)));return null!==this.intensityNode&&(i=Up(t,i,this.intensityNode)),uc(i,this.inputNode.a)}));return t()}}Ql("Film",SR);const MR=Wu(SR);class AR extends iu{constructor(e,t,s,i){super(),this.inputNode=e,this.lutNode=t,this.size=Cc(s),this.intensityNode=i}setup(){const{inputNode:e,lutNode:t}=this,s=ju((()=>{const s=e,i=Ku(1).div(this.size),r=Ku(.5).div(this.size),n=oc(r).add(s.rgb.mul(Ku(1).sub(i))),o=uc((e=>t.uv(e))(n).rgb,s.a);return uc(Up(s,o,this.intensityNode))}));return s()}}Ql("Lut3D",AR);const NR=(e,t,s,i)=>Du(new AR(Du(e),Du(t),s,Du(i))),RR=new QM,CR=new Yr,ER=new Qs;class BR extends iu{constructor(e,t,s){super(),this.depthNode=e,this.normalNode=t,this.radius=Cc(.25),this.resolution=Cc(new Qs),this.thickness=Cc(1),this.distanceExponent=Cc(1),this.distanceFallOff=Cc(1),this.scale=Cc(1),this.noiseNode=Gm(function(e=5){const t=Math.floor(e)%2==0?Math.floor(e)+1:Math.floor(e),s=function(e){const t=Math.floor(e)%2==0?Math.floor(e)+1:Math.floor(e),s=t*t,i=Array(s).fill(0);let r=Math.floor(t/2),n=t-1;for(let e=1;e<=s;)-1===r&&n===t?(n=t-2,r=0):(n===t&&(n=0),r<0&&(r=t-1)),0===i[r*t+n]?(i[r*t+n]=e++,n++,r--):(n-=2,r++);return i}(t),i=s.length,r=new Uint8Array(4*i);for(let e=0;ethis.depthNode.uv(e).x,i=e=>this.noiseNode.uv(e),r=ju((([e])=>{const t=this.cameraProjectionMatrix.mul(uc(e,1));let i=t.xy.div(t.w).mul(.5).add(.5).toVar();i=sc(i.x,i.y.oneMinus());const r=s(i);return oc(i,r)})),n=ju((([e,t])=>{e=sc(e.x,e.y.oneMinus()).mul(2).sub(1);const s=uc(oc(e,t),1),i=uc(this.cameraProjectionMatrixInverse.mul(s));return i.xyz.div(i.w)})),o=ju((()=>{const e=s(t);e.greaterThanEqual(1).discard();const o=n(t,e),a=this.normalNode.rgb.normalize(),h=this.radius,l=Om(this.noiseNode,0);let u=sc(t.x,t.y.oneMinus());u=u.mul(this.resolution.div(l));const c=i(u),d=c.xyz.mul(2).sub(1),p=oc(d.xy,0).normalize(),m=oc(p.y.mul(-1),p.x,0),g=gc(p,m,oc(0,0,1)),f=this.SAMPLES.lessThan(30).select(3,5),y=dd(this.SAMPLES,f.sub(1)).div(f),x=Ku(0).toVar();return Cy({start:Qu(0),end:f,type:"int",condition:"<"},(({i:e})=>{const t=Ku(e).div(Ku(f)).mul(Ld),s=uc(tp(t),ep(t),0,dd(.5,md(.5,c.w)));s.xyz=Kd(g.mul(s.xyz));const i=Kd(o.xyz.negate()),l=Kd(Rp(s.xyz,i)),u=Rp(l,i),d=Kd(a.sub(l.mul(Np(a,l)))),p=Rp(d,l),m=sc(Np(i,p),Np(i,p.negate())).toVar();Cy({end:y,type:"int",name:"j",condition:"<"},(({j:e})=>{const t=s.xyz.mul(h).mul(s.w).mul(Cp(gd(Ku(e).add(1),Ku(y)),this.distanceExponent)),a=r(o.add(t)),l=n(a.xy,a.z).sub(o);Yu(op(l.z).lessThan(this.thickness),(()=>{const t=Np(i,Kd(l));m.x.addAssign(Tp(0,md(t.sub(m.x),Up(1,Ku(2).div(Ku(e).add(2)),this.distanceFallOff))))}));const u=r(o.sub(t)),c=n(u.xy,u.z).sub(o);Yu(op(c.z).lessThan(this.thickness),(()=>{const t=Np(i,Kd(c));m.y.addAssign(Tp(0,md(t.sub(m.y),Up(1,Ku(2).div(Ku(e).add(2)),this.distanceFallOff))))}))}));const b=Xd(pd(1,m.mul(m))),v=Np(d,u),T=Np(d,i),_=md(.5,rp(m.y).sub(rp(m.x)).add(b.x.mul(m.x).sub(b.y.mul(m.y)))),w=md(.5,pd(2,m.x.mul(m.x)).sub(m.y.mul(m.y))),S=v.mul(_).add(T.mul(w));x.addAssign(S)})),x.assign(Lp(x.div(f),0,1)),x.assign(Cp(x,this.scale)),uc(oc(x),1)})),a=this._material||(this._material=new yx);return a.fragmentNode=o().context(e.getSharedContext()),a.name="GTAO",a.needsUpdate=!0,this._textureNode}dispose(){this._aoRenderTarget.dispose()}}Ql("GTAO",BR);const IR=(e,t,s)=>Du(new BR(Du(e),Du(t),s));class PR extends iu{constructor(e,t,s,i,r){super(),this.textureNode=e,this.depthNode=t,this.normalNode=s,this.noiseNode=i,this.cameraProjectionMatrixInverse=Cc(r.projectionMatrixInverse),this.lumaPhi=Cc(5),this.depthPhi=Cc(5),this.normalPhi=Cc(5),this.radius=Cc(5),this.index=Cc(0),this._resolution=Cc(new Qs),this._sampleVectors=Xg(function(e,t,s){const i=function(e,t,s){const i=[];for(let r=0;rthis.textureNode.uv(e),s=e=>this.depthNode.uv(e).x,i=e=>this.normalNode.uv(e),r=e=>this.noiseNode.uv(e),n=ju((([e,t])=>{e=sc(e.x,e.y.oneMinus()).mul(2).sub(1);const s=uc(oc(e,t),1),i=uc(this.cameraProjectionMatrixInverse.mul(s));return i.xyz.div(i.w)})),o=ju((([e,r,o,a])=>{const h=t(a),l=s(a),u=i(a).rgb.normalize(),c=h.rgb,d=n(a,l),p=Np(r,u).toVar(),m=Cp(Tp(p,0),this.normalPhi).toVar(),g=op(cR(c).sub(cR(e))).toVar(),f=Tp(Ku(1).sub(g.div(this.lumaPhi)),0).toVar(),y=op(Np(o.sub(d),r)).toVar(),x=Tp(Ku(1).sub(y.div(this.depthPhi)),0),b=f.mul(x).mul(m);return uc(c.mul(b),b)})),a=ju((([e])=>{const a=s(e),h=i(e).rgb.normalize(),l=t(e);Yu(a.greaterThanEqual(1).or(Np(h,h).equal(0)),(()=>l));const u=oc(l.rgb),c=n(e,a),d=Om(this.noiseNode,0);let p=sc(e.x,e.y.oneMinus());p=p.mul(this._resolution.div(d));const m=r(p),g=ep(m.element(this.index.mod(4).mul(2).mul(Ld))),f=tp(m.element(this.index.mod(4).mul(2).mul(Ld))),y=sc(g,f),x=mc(y.x,y.y.negate(),y.x,y.y),b=Ku(1).toVar(),v=oc(l.rgb).toVar();return Cy({start:Qu(0),end:Qu(16),type:"int",condition:"<"},(({i:t})=>{const s=this._sampleVectors.element(t).toVar(),i=x.mul(s.xy.mul(Ku(1).add(s.z.mul(this.radius.sub(1))))).div(this._resolution).toVar(),r=e.add(i).toVar(),n=o(u,h,c,r);v.addAssign(n.xyz),b.addAssign(n.w)})),Yu(b.greaterThan(Ku(0)),(()=>{v.divAssign(b)})),uc(v,l.a)})).setLayout({name:"denoise",type:"vec4",inputs:[{name:"uv",type:"vec2"}]});return ju((()=>a(e)))()}}Ql("Denoise",PR);const FR=(e,t,s,i,r)=>Du(new PR(iA(e),Du(t),Du(s),Du(i),r));class zR extends iu{constructor(e){super(),this.textureNode=e,this.updateBeforeType=Hl.RENDER,this._invSize=Cc(new Qs)}updateBefore(){const e=this.textureNode.value;this._invSize.value.set(1/e.image.width,1/e.image.height)}setup(){const e=this.textureNode.bias(-100),t=e.uvNode||Um(),s=t=>e.uv(t),i=(t,s,i)=>e.uv(t.add(s.mul(i))),r=Qu(5),n=ju((([e,t])=>{const s=uc(t).toVar(),i=uc(e).toVar(),r=uc(op(i.sub(s))).toVar();return Tp(Tp(Tp(r.r,r.g),r.b),r.a)})),o=ju((([e,t,o,a])=>{const h=s(e).toVar(),l=i(e,sc(0,-1),t.xy).toVar(),u=i(e,sc(1,0),t.xy).toVar(),c=i(e,sc(0,1),t.xy).toVar(),d=i(e,sc(-1,0),t.xy).toVar(),p=n(h,c).toVar(),m=n(h,l).toVar(),g=n(h,u).toVar(),f=n(h,d).toVar(),y=Tp(p,Tp(m,Tp(g,f))).toVar();Yu(y.lessThan(o),(()=>h));const x=pd(p.add(m),g.add(f)).toVar();x.mulAssign(a),Yu(op(x).lessThan(.3),(()=>{const s=g.greaterThan(f).select(1,-1).toVar(),r=m.greaterThan(p).select(1,-1).toVar(),o=sc(s,r).toVar(),y=i(e,sc(o.x,o.y),t.xy),b=n(h,y).toVar(),v=i(e,sc(o.x.negate(),o.y.negate()),t.xy),T=n(h,v).toVar();x.assign(T.sub(b)),x.mulAssign(a),Yu(op(x).lessThan(.3),(()=>{const e=c.add(l).add(u).add(d);return Up(h,e.mul(.25),.4)}))}));const b=sc().toVar();Yu(x.lessThanEqual(0),(()=>{c.assign(d),l.assign(u),b.x.assign(0),b.y.assign(t.y)})).Else((()=>{b.x.assign(t.x),b.y.assign(0)}));const v=n(h,c).toVar(),T=n(h,l).toVar();Yu(v.lessThanEqual(T),(()=>{c.assign(l)}));const _=Qu(0).toVar(),w=Qu(0).toVar(),S=Ku(0).toVar(),M=Ku(0).toVar(),A=sc(e).toVar(),N=sc(e).toVar(),R=Qu(0).toVar(),C=Qu(0).toVar();Cy(r,(({i:t})=>{const i=t.add(1).toVar();Yu(_.equal(0),(()=>{S.addAssign(i),A.assign(e.add(b.mul(S)));const r=s(A.xy),o=n(r,h).toVar(),a=n(r,c).toVar();Yu(o.greaterThan(a),(()=>{_.assign(1)})),R.assign(t)})),Yu(w.equal(0),(()=>{M.addAssign(i),N.assign(e.sub(b.mul(M)));const r=s(N.xy),o=n(r,h).toVar(),a=n(r,c).toVar();Yu(o.greaterThan(a),(()=>{w.assign(1)})),C.assign(t)})),Yu(_.equal(1).or(w.equal(1)),(()=>{By()}))})),Yu(_.equal(0).and(w.equal(0)),(()=>h));const E=Ku(1).toVar(),B=Ku(1).toVar();Yu(_.equal(1),(()=>{E.assign(Ku(R).div(Ku(r.sub(1))))})),Yu(w.equal(1),(()=>{B.assign(Ku(C).div(Ku(r.sub(1))))}));const I=vp(E,B);return I.assign(Cp(I,.5)),I.assign(Ku(1).sub(I)),Up(h,c,I.mul(.5))})).setLayout({name:"FxaaPixelShader",type:"vec4",inputs:[{name:"uv",type:"vec2"},{name:"fxaaQualityRcpFrame",type:"vec2"},{name:"fxaaQualityEdgeThreshold",type:"float"},{name:"fxaaQualityinvEdgeThreshold",type:"float"}]});return ju((()=>{const e=Ku(.2),s=Ku(1).div(e);return o(t,this._invSize,e,s)}))()}}Ql("FXAA",zR);const UR=e=>Du(new zR(iA(e))),LR=new QM,OR=new Yr(0,0,0),VR=new Yr,DR=new Qs,kR=new Qs(1,0),GR=new Qs(0,1);class WR extends iu{constructor(e,t=1,s=0,i=0){super(),this.inputNode=e,this.strength=Cc(t),this.radius=Cc(s),this.threshold=Cc(i),this.smoothWidth=Cc(.01),this._renderTargetsHorizontal=[],this._renderTargetsVertical=[],this._nMips=5,this._renderTargetBright=new wi(1,1,{type:Pe}),this._renderTargetBright.texture.name="UnrealBloomPass.bright",this._renderTargetBright.texture.generateMipmaps=!1;for(let e=0;e{const e=this.inputNode,t=cR(e.rgb),s=Dp(this.threshold,this.threshold.add(this.smoothWidth),t);return Up(uc(0),e,s)}));this._highPassFilterMaterial=this._highPassFilterMaterial||new yx,this._highPassFilterMaterial.fragmentNode=t().context(e.getSharedContext()),this._highPassFilterMaterial.name="Bloom_highPass",this._highPassFilterMaterial.needsUpdate=!0;const s=[3,5,7,9,11];for(let t=0;t{const s=Ku(1.2).sub(e);return Up(e,s,t)})).setLayout({name:"lerpBloomFactor",type:"float",inputs:[{name:"factor",type:"float"},{name:"radius",type:"float"}]}),o=ju((()=>{const e=n(i.element(0),this.radius).mul(uc(r.element(0),1)).mul(this._textureNodeBlur0),t=n(i.element(1),this.radius).mul(uc(r.element(1),1)).mul(this._textureNodeBlur1),s=n(i.element(2),this.radius).mul(uc(r.element(2),1)).mul(this._textureNodeBlur2),o=n(i.element(3),this.radius).mul(uc(r.element(3),1)).mul(this._textureNodeBlur3),a=n(i.element(4),this.radius).mul(uc(r.element(4),1)).mul(this._textureNodeBlur4);return e.add(t).add(s).add(o).add(a).mul(this.strength)}));return this._compositeMaterial=this._compositeMaterial||new yx,this._compositeMaterial.fragmentNode=o().context(e.getSharedContext()),this._compositeMaterial.name="Bloom_comp",this._compositeMaterial.needsUpdate=!0,this._textureOutput}dispose(){for(let e=0;ei.uv(e),l=ju((()=>{const e=r.element(0).toVar(),s=h(a).rgb.mul(e).toVar();return Cy({start:Qu(1),end:Qu(t),type:"int",condition:"<"},(({i:t})=>{const i=Ku(t),l=r.element(t),u=o.mul(n).mul(i),c=h(a.add(u)).rgb,d=h(a.sub(u)).rgb;s.addAssign(dd(c,d).mul(l)),e.addAssign(Ku(2).mul(l))})),uc(s.div(e),1)})),u=new yx;return u.fragmentNode=l().context(e.getSharedContext()),u.name="Bloom_seperable",u.needsUpdate=!0,u.colorTexture=i,u.direction=o,u.invSize=n,u}}const HR=(e,t,s,i)=>Du(new WR(Du(e),t,s,i));class jR extends iu{constructor(e,t,s,i,r,n){super(),this.textureNodeA=e,this.textureNodeB=t,this.mixTextureNode=s,this.mixRatioNode=i,this.thresholdNode=r,this.useTextureNode=n}setup(){const{textureNodeA:e,textureNodeB:t,mixTextureNode:s,mixRatioNode:i,thresholdNode:r,useTextureNode:n}=this,o=e=>{const t=e.uvNode||Um();return e.uv(t)},a=ju((()=>{const a=o(e),h=o(t),l=uc().toVar();return Yu(n.equal(Qu(1)),(()=>{const e=o(s),t=i.mul(r.mul(2).add(1)).sub(r),n=Lp(pd(e.r,t).mul(Ku(1).div(r)),0,1);l.assign(Up(a,h,n))})).Else((()=>{l.assign(Up(h,a,i))})),l}));return a()}}Ql("Transition",jR);const qR=(e,t,s,i=0,r=.1,n=0)=>Du(new jR(iA(e),iA(t),iA(s),Du(i),Du(r),Du(n)));class $R extends iu{constructor(e,t,s,i,r,n){super(),this.textureNode=e,this.depthNode=t,this.normalNode=s,this.pixelSize=i,this.normalEdgeStrength=r,this.depthEdgeStrength=n,this._resolution=Cc(new _i),this.updateBeforeType=Hl.RENDER}updateBefore(){const e=this.textureNode.value,t=e.image.width,s=e.image.height;this._resolution.value.set(t,s,1/t,1/s)}setup(){const{textureNode:e,depthNode:t,normalNode:s}=this,i=e.uvNode||Um(),r=t.uvNode||Um(),n=s.uvNode||Um(),o=(e,s)=>t.uv(r.add(sc(e,s).mul(this._resolution.zw))).r,a=(e,t)=>s.uv(n.add(sc(e,t).mul(this._resolution.zw))).rgb.normalize(),h=(e,t,s,i)=>{const r=o(e,t).sub(s),n=a(e,t),h=oc(1,1,1),l=Np(i.sub(n),h),u=Lp(Dp(-.01,.01,l),0,1),c=Lp(ap(r.mul(.25).add(.0025)),0,1);return Ku(1).sub(Np(i,n)).mul(c).mul(u)},l=ju((()=>{const t=e.uv(i),s=Bc("float","depth"),r=Bc("vec3","normal");Yu(this.depthEdgeStrength.greaterThan(0).or(this.normalEdgeStrength.greaterThan(0)),(()=>{s.assign(o(0,0)),r.assign(a(0,0))}));const n=Bc("float","dei");Yu(this.depthEdgeStrength.greaterThan(0),(()=>{n.assign((e=>{const t=Bc("float","diff");return t.addAssign(Lp(o(1,0).sub(e))),t.addAssign(Lp(o(-1,0).sub(e))),t.addAssign(Lp(o(0,1).sub(e))),t.addAssign(Lp(o(0,-1).sub(e))),Jd(Dp(.01,.02,t).mul(2)).div(2)})(s))}));const l=Bc("float","nei");Yu(this.normalEdgeStrength.greaterThan(0),(()=>{l.assign(((e,t)=>{const s=Bc("float","indicator");return s.addAssign(h(0,-1,e,t)),s.addAssign(h(0,1,e,t)),s.addAssign(h(-1,0,e,t)),s.addAssign(h(1,0,e,t)),wp(.1,s)})(s,r))}));const u=n.greaterThan(0).select(Ku(1).sub(n.mul(this.depthEdgeStrength)),l.mul(this.normalEdgeStrength).add(1));return t.mul(u)}));return l()}}Ql("Pixelation",$R);class XR extends XN{constructor(e,t,s=6,i=.3,r=.4){super("color",e,t,{minFilter:fe,magFilter:fe}),this.pixelSize=s,this.normalEdgeStrength=i,this.depthEdgeStrength=r,this.isPixelationPassNode=!0,this._mrt=pM({output:Zc,normal:Ig})}setSize(e,t){const s=this.pixelSize.value?this.pixelSize.value:this.pixelSize,i=Math.floor(e/s),r=Math.floor(t/s);super.setSize(i,r)}setup(){return((e,t,s,i=6,r=.3,n=.4)=>Du(new $R(iA(e),iA(t),iA(s),Du(i),Du(r),Du(n))))(super.getTextureNode("output"),super.getTextureNode("depth"),super.getTextureNode("normal"),this.pixelSize,this.normalEdgeStrength,this.depthEdgeStrength)}}const YR=(e,t,s,i,r)=>Du(new XR(e,t,s,i,r));Ql("PixelationPass",XR);const JR=new Qs;class ZR extends XN{constructor(e,t){super(XN.COLOR,e,t),this.isSSAAPassNode=!0,this.sampleLevel=4,this.unbiased=!0,this.clearColor=new Yr(0),this.clearAlpha=0,this._currentClearColor=new Yr,this.sampleWeight=Cc(1),this.sampleRenderTarget=null,this._quadMesh=new QM}updateBefore(e){const{renderer:t}=e,{scene:s,camera:i}=this;this._pixelRatio=t.getPixelRatio();const r=t.getSize(JR);this.setSize(r.width,r.height),this.sampleRenderTarget.setSize(this.renderTarget.width,this.renderTarget.height),t.getClearColor(this._currentClearColor);const n=t.getClearAlpha(),o=t.getRenderTarget(),a=t.getMRT(),h=t.autoClear;this._cameraNear.value=i.near,this._cameraFar.value=i.far,t.setMRT(this.getMRT()),t.autoClear=!1;const l=KR[Math.max(0,Math.min(this.sampleLevel,5))],u=1/l.length,c={fullWidth:this.renderTarget.width,fullHeight:this.renderTarget.height,offsetX:0,offsetY:0,width:this.renderTarget.width,height:this.renderTarget.height},d=Object.assign({},i.view);d.enabled&&Object.assign(c,d);for(let e=0;e=0&&(e[t]=Gm(this.sampleRenderTarget.textures[s]).mul(this.sampleWeight))}t=pM(e)}else t=Gm(this.sampleRenderTarget.texture).mul(this.sampleWeight);return this._quadMesh.material=new yx,this._quadMesh.material.fragmentNode=t,this._quadMesh.material.transparent=!0,this._quadMesh.material.depthTest=!1,this._quadMesh.material.depthWrite=!1,this._quadMesh.material.premultipliedAlpha=!0,this._quadMesh.material.blending=2,this._quadMesh.material.normals=!1,this._quadMesh.material.name="SSAA",super.setup(e)}dispose(){super.dispose(),null!==this.sampleRenderTarget&&this.sampleRenderTarget.dispose()}}Ql("SSAAPass",ZR);const KR=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]],QR=(e,t)=>Du(new ZR(e,t)),eC=new Qs;class tC extends XN{constructor(e,t){super(XN.COLOR,e,t),this.isStereoPassNode=!0,this.stereo=new r_,this.stereo.aspect=.5}updateBefore(e){const{renderer:t}=e,{scene:s,camera:i,stereo:r,renderTarget:n}=this;this._pixelRatio=t.getPixelRatio(),r.cameraL.coordinateSystem=t.coordinateSystem,r.cameraR.coordinateSystem=t.coordinateSystem,r.update(i);const o=t.getSize(eC);this.setSize(o.width,o.height);const a=t.autoClear;t.autoClear=!1;const h=t.getRenderTarget(),l=t.getMRT();this._cameraNear.value=i.near,this._cameraFar.value=i.far;for(const e in this._previousTextures)this.toggleTexture(e);t.setRenderTarget(n),t.setMRT(this._mrt),t.clear(),n.scissorTest=!0,n.scissor.set(0,0,n.width/2,n.height),n.viewport.set(0,0,n.width/2,n.height),t.render(s,r.cameraL),n.scissor.set(n.width/2,0,n.width/2,n.height),n.viewport.set(n.width/2,0,n.width/2,n.height),t.render(s,r.cameraR),n.scissorTest=!1,t.setRenderTarget(h),t.setMRT(l),t.autoClear=a}}Ql("StereoPass",tC);const sC=(e,t)=>Du(new tC(e,t)),iC=new Qs,rC=new QM;class nC extends XN{constructor(e,t){super(XN.COLOR,e,t),this.isStereoCompositePassNode=!0,this.stereo=new r_;const s={minFilter:Te,magFilter:fe,type:Pe};this._renderTargetL=new wi(1,1,s),this._renderTargetR=new wi(1,1,s),this._mapLeft=Gm(this._renderTargetL.texture),this._mapRight=Gm(this._renderTargetR.texture),this._material=null}updateStereoCamera(e){this.stereo.cameraL.coordinateSystem=e,this.stereo.cameraR.coordinateSystem=e,this.stereo.update(this.camera)}setSize(e,t){super.setSize(e,t),this._renderTargetL.setSize(this.renderTarget.width,this.renderTarget.height),this._renderTargetR.setSize(this.renderTarget.width,this.renderTarget.height)}updateBefore(e){const{renderer:t}=e,{scene:s,stereo:i,renderTarget:r}=this;this._pixelRatio=t.getPixelRatio(),this.updateStereoCamera(t.coordinateSystem);const n=t.getSize(iC);this.setSize(n.width,n.height);const o=t.getRenderTarget();t.setRenderTarget(this._renderTargetL),t.render(s,i.cameraL),t.setRenderTarget(this._renderTargetR),t.render(s,i.cameraR),t.setRenderTarget(r),rC.material=this._material,rC.render(t),t.setRenderTarget(o)}dispose(){super.dispose(),this._renderTargetL.dispose(),this._renderTargetR.dispose(),null!==this._material&&this._material.dispose()}}Ql("StereoCompositePass",nC);class oC extends nC{constructor(e,t){super(e,t),this.isAnaglyphPassNode=!0,this._colorMatrixLeft=Cc((new ei).fromArray([.4561,-.0400822,-.0152161,.500484,-.0378246,-.0205971,.176381,-.0157589,-.00546856])),this._colorMatrixRight=Cc((new ei).fromArray([-.0434706,.378476,-.0721527,-.0879388,.73364,-.112961,-.00155529,-.0184503,1.2264]))}setup(e){const t=Um(),s=ju((()=>{const e=this._mapLeft.uv(t),s=this._mapRight.uv(t),i=Lp(this._colorMatrixLeft.mul(e.rgb).add(this._colorMatrixRight.mul(s.rgb)));return uc(i.rgb,Tp(e.a,s.a))})),i=this._material||(this._material=new yx);return i.fragmentNode=s().context(e.getSharedContext()),i.name="Anaglyph",i.needsUpdate=!0,super.setup(e)}}const aC=(e,t)=>Du(new oC(e,t));class hC extends nC{constructor(e,t){super(e,t),this.isParallaxBarrierPassNode=!0}setup(e){const t=Um(),s=ju((()=>{const e=uc().toVar();return Yu(_p(Xy.y,2).greaterThan(1),(()=>{e.assign(this._mapLeft.uv(t))})).Else((()=>{e.assign(this._mapRight.uv(t))})),e})),i=this._material||(this._material=new yx);return i.fragmentNode=s().context(e.getSharedContext()),i.needsUpdate=!0,super.setup(e)}}Ql("ParallaxBarrierPass",hC);const lC=(e,t)=>Du(new hC(e,t));class uC extends Kl{constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outpuType=null,this.events=new ks,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return null!==this.outputType}set value(e){this._value!==e&&(this._cache&&"URL"===this.inputType&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&null===this._cache&&"URL"===this.inputType&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&null!==e.value&&void 0!==e.value&&(("URL"===this.inputType||"String"===this.inputType)&&"string"==typeof e.value||"Number"===this.inputType&&"number"==typeof e.value||"Vector2"===this.inputType&&e.value.isVector2||"Vector3"===this.inputType&&e.value.isVector3||"Vector4"===this.inputType&&e.value.isVector4||"Color"===this.inputType&&e.value.isColor||"Matrix3"===this.inputType&&e.value.isMatrix3||"Matrix4"===this.inputType&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:Ku()}serialize(e){super.serialize(e),null!==this.value?"ArrayBuffer"===this.inputType?e.value=Dl(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;null!==e.value&&(t="ArrayBuffer"===e.inputType?kl(e.value):"Texture"===e.inputType?e.meta.textures[e.value]:e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}Ql("ScriptableValue",uC);const cC=Wu(uC);class dC extends Map{get(e,t=null,...s){if(this.has(e))return super.get(e);if(null!==t){const i=t(...s);return this.set(e,i),i}}}class pC{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const mC=new dC;class gC extends Kl{constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new dC,this._output=cC(),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const s=this._outputs;return void 0===s[e]?s[e]=cC(t):s[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const s=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),s[e]=t,s[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),s[e]=t,s[e].events.addEventListener("refresh",this.onRefresh)):void 0===s[e]?(s[e]=cC(t),s[e].events.addEventListener("refresh",this.onRefresh)):s[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){const s=this.getObject()[e];if("function"==typeof s)return s(...t)}async callAsync(e,...t){const s=this.getObject()[e];if("function"==typeof s)return"AsyncFunction"===s.constructor.name?await s(...t):s(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){null!==e?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),null!==this._object)return this._object;const e=new pC(this),t=mC.get("THREE"),s=mC.get("TSL"),i=this.getMethod(this.codeNode),r=[e,this._local,mC,()=>this.refresh(),(e,t)=>this.setOutput(e,t),t,s];this._object=i(...r);const n=this._object.layout;if(n&&(!1===n.cache&&this._local.clear(),this._output.outputType=n.outputType||null,Array.isArray(n.elements)))for(const e of n.elements){const t=e.id||e.name;e.inputType&&(void 0===this.getParameter(t)&&this.setParameter(t,null),this.getParameter(t).inputType=e.inputType),e.outputType&&(void 0===this.getOutput(t)&&this.setOutput(t,null),this.getOutput(t).outputType=e.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const e in this.parameters){let t=this.parameters[e];t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:Ku()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),null!==this._method)return this._method;const e=["layout","init","main","dispose"].join(", "),t="\nreturn { ...output, "+e+" };",s="var "+e+"; var output = {};\n"+this.codeNode.code+t;return this._method=new Function(...["parameters","local","global","refresh","setOutput","THREE","TSL"],s),this._method}dispose(){null!==this._method&&(this._object&&"function"==typeof this._object.dispose&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[this.source,this.getDefaultOutputNode().getCacheKey(e)];for(const s in this.parameters)t.push(this.parameters[s].getCacheKey(e));return t.join(",")}set needsUpdate(e){!0===e&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return null===this.codeNode||(!0===this._needsOutputUpdate&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value),this}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}Ql("Scriptable",gC);const fC=Wu(gC);class yC extends Kl{constructor(e,t){super("float"),this.isFogNode=!0,this.colorNode=e,this.factorNode=t}getViewZNode(e){let t;const s=e.context.getViewZ;return void 0!==s&&(t=s(this)),(t||wg.z).negate()}setup(){return this.factorNode}}Ql("Fog",yC);const xC=Wu(yC);class bC extends yC{constructor(e,t,s){super(e),this.isFogRangeNode=!0,this.nearNode=t,this.farNode=s}setup(e){const t=this.getViewZNode(e);return Dp(this.nearNode,this.farNode,t)}}Ql("FogRange",bC);const vC=Wu(bC);class TC extends yC{constructor(e,t){super(e),this.isFogExp2Node=!0,this.densityNode=t}setup(e){const t=this.getViewZNode(e),s=this.densityNode;return s.mul(s,t,t).negate().exp().oneMinus()}}Ql("FogExp2",TC);const _C=Wu(TC);let wC=null,SC=null;class MC extends Kl{constructor(e=Ku(),t=Ku()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(Ol(this.minNode.value)),s=e.getTypeLength(Ol(this.maxNode.value));return t>s?t:s}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let s=null;if(t.count>1){const i=this.minNode.value,r=this.maxNode.value,n=e.getTypeLength(Ol(i)),o=e.getTypeLength(Ol(r));wC=wC||new _i,SC=SC||new _i,wC.setScalar(0),SC.setScalar(0),1===n?wC.setScalar(i):i.isColor?wC.set(i.r,i.g,i.b):wC.set(i.x,i.y,i.z||0,i.w||0),1===o?SC.setScalar(r):r.isColor?SC.set(r.r,r.g,r.b):SC.set(r.x,r.y,r.z||0,r.w||0);const a=4,h=a*t.count,l=new Float32Array(h);for(let e=0;eGm(e,t.xy).compare(t.z))),EC=ju((({depthTexture:e,shadowCoord:t,shadow:s})=>{const i=(t,s)=>Gm(e,t).compare(s),r=Zg("mapSize","vec2",s),n=Zg("radius","float",s),o=sc(1).div(r),a=o.x.negate().mul(n),h=o.y.negate().mul(n),l=o.x.mul(n),u=o.y.mul(n),c=a.div(2),d=h.div(2),p=l.div(2),m=u.div(2);return dd(i(t.xy.add(sc(a,h)),t.z),i(t.xy.add(sc(0,h)),t.z),i(t.xy.add(sc(l,h)),t.z),i(t.xy.add(sc(c,d)),t.z),i(t.xy.add(sc(0,d)),t.z),i(t.xy.add(sc(p,d)),t.z),i(t.xy.add(sc(a,0)),t.z),i(t.xy.add(sc(c,0)),t.z),i(t.xy,t.z),i(t.xy.add(sc(p,0)),t.z),i(t.xy.add(sc(l,0)),t.z),i(t.xy.add(sc(c,m)),t.z),i(t.xy.add(sc(0,m)),t.z),i(t.xy.add(sc(p,m)),t.z),i(t.xy.add(sc(a,u)),t.z),i(t.xy.add(sc(0,u)),t.z),i(t.xy.add(sc(l,u)),t.z)).mul(1/17)})),BC=ju((({depthTexture:e,shadowCoord:t,shadow:s})=>{const i=(t,s)=>Gm(e,t).compare(s),r=Zg("mapSize","vec2",s),n=sc(1).div(r),o=n.x,a=n.y,h=t.xy,l=Qd(h.mul(r).add(.5));return h.subAssign(l.mul(n)),dd(i(h,t.z),i(h.add(sc(o,0)),t.z),i(h.add(sc(0,a)),t.z),i(h.add(n),t.z),Up(i(h.add(sc(o.negate(),0)),t.z),i(h.add(sc(o.mul(2),0)),t.z),l.x),Up(i(h.add(sc(o.negate(),a)),t.z),i(h.add(sc(o.mul(2),a)),t.z),l.x),Up(i(h.add(sc(0,a.negate())),t.z),i(h.add(sc(0,a.mul(2))),t.z),l.y),Up(i(h.add(sc(o,a.negate())),t.z),i(h.add(sc(o,a.mul(2))),t.z),l.y),Up(Up(i(h.add(sc(o.negate(),a.negate())),t.z),i(h.add(sc(o.mul(2),a.negate())),t.z),l.x),Up(i(h.add(sc(o.negate(),a.mul(2))),t.z),i(h.add(sc(o.mul(2),a.mul(2))),t.z),l.x),l.y)).mul(1/9)})),IC=[CC,EC,BC];let PC=null;class FC extends Dy{constructor(e=null){super(),this.updateType=Hl.FRAME,this.light=e,this.color=new Yr,this.colorNode=Cc(this.color),this.baseColorNode=null,this.shadowMap=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0}getCacheKey(){return super.getCacheKey()+"-"+this.light.id+"-"+(this.light.castShadow?"1":"0")}getHash(){return this.light.uuid}setupShadow(e){const{object:t,renderer:s}=e;let i=this.shadowColorNode;if(null===i){null===PC&&(PC=new yx,PC.fragmentNode=uc(0,0,0,1),PC.isShadowNodeMaterial=!0,PC.name="ShadowMaterial");const r=new Qa;r.compareFunction=Ts;const n=this.light.shadow,o=e.createRenderTarget(n.mapSize.width,n.mapSize.height);o.depthTexture=r,n.camera.updateProjectionMatrix();const a=Zg("intensity","float",n),h=Zg("bias","float",n),l=Zg("normalBias","float",n),u=t.material.shadowPositionNode||Tg;let c=Cc(n.matrix).mul(u.add(Pg.mul(l)));c=c.xyz.div(c.w);let d=c.z.add(h);s.coordinateSystem===Ds&&(d=d.mul(2).sub(1)),c=oc(c.x,c.y.oneMinus(),d);const p=c.x.greaterThanEqual(0).and(c.x.lessThanEqual(1)).and(c.y.greaterThanEqual(0)).and(c.y.lessThanEqual(1)).and(c.z.lessThanEqual(1)),m=n.filterNode||IC[s.shadowMap.type]||null;if(null===m)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const g=Gm(o.texture,c),f=p.select(m({depthTexture:r,shadowCoord:c,shadow:n}),Ku(1));this.shadowMap=o,this.shadowNode=f,this.shadowColorNode=i=this.colorNode.mul(Up(1,f.rgb.mix(g,1),a.mul(g.a))),this.baseColorNode=this.colorNode}this.colorNode=i,this.updateBeforeType=Hl.RENDER}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):null!==this.shadowNode&&this.disposeShadow()}updateShadow(e){const{shadowMap:t,light:s}=this,{renderer:i,scene:r,camera:n}=e,o=t.depthTexture.version;this._depthVersionCached=o;const a=r.overrideMaterial;r.overrideMaterial=PC,t.setSize(s.shadow.mapSize.width,s.shadow.mapSize.height),s.shadow.updateMatrices(s),s.shadow.camera.layers.mask=n.layers.mask;const h=i.getRenderTarget(),l=i.getRenderObjectFunction();i.setRenderObjectFunction(((e,...t)=>{!0===e.castShadow&&i.renderObject(e,...t)})),i.setRenderTarget(t),i.render(r,s.shadow.camera),i.setRenderTarget(h),i.setRenderObjectFunction(l),r.overrideMaterial=a}disposeShadow(){this.shadowMap.dispose(),this.shadowMap=null,this.shadowNode=null,this.shadowColorNode=null,this.baseColorNode=null,this.updateBeforeType=Hl.NONE}updateBefore(e){const t=this.light.shadow;(t.needsUpdate||t.autoUpdate)&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}Ql("AnalyticLight",FC);const zC=ju((e=>{const{lightDistance:t,cutoffDistance:s,decayExponent:i}=e,r=t.pow(i).max(.01).reciprocal();return s.greaterThan(0).select(r.mul(t.div(s).pow4().oneMinus().clamp().pow2()),r)}));class UC extends FC{constructor(e=null){super(e),this.cutoffDistanceNode=Cc(0),this.decayExponentNode=Cc(0)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setup(e){const{colorNode:t,cutoffDistanceNode:s,decayExponentNode:i,light:r}=this,n=e.context.lightingModel,o=hg(r).sub(wg),a=o.normalize(),h=o.length(),l=zC({lightDistance:h,cutoffDistance:s,decayExponent:i}),u=t.mul(l),c=e.context.reflectedLight;n.direct({lightDirection:a,lightColor:u,reflectedLight:c},e.stack,e)}}Ql("PointLight",UC);class LC extends FC{constructor(e=null){super(e)}setup(e){super.setup(e);const t=e.context.lightingModel,s=this.colorNode,i=RC(this.light),r=e.context.reflectedLight;t.direct({lightDirection:i,lightColor:s,reflectedLight:r},e.stack,e)}}Ql("DirectionalLight",LC);const OC=new or,VC=new or;let DC=null;class kC extends FC{constructor(e=null){super(e),this.halfHeight=Cc(new Ei),this.halfWidth=Cc(new Ei)}update(e){super.update(e);const{light:t}=this,s=e.camera.matrixWorldInverse;VC.identity(),OC.copy(t.matrixWorld),OC.premultiply(s),VC.extractRotation(OC),this.halfWidth.value.set(.5*t.width,0,0),this.halfHeight.value.set(0,.5*t.height,0),this.halfWidth.value.applyMatrix4(VC),this.halfHeight.value.applyMatrix4(VC)}setup(e){let t,s;super.setup(e),e.isAvailable("float32Filterable")?(t=Gm(DC.LTC_FLOAT_1),s=Gm(DC.LTC_FLOAT_2)):(t=Gm(DC.LTC_HALF_1),s=Gm(DC.LTC_HALF_2));const{colorNode:i,light:r}=this,n=e.context.lightingModel,o=hg(r),a=e.context.reflectedLight;n.directRectArea({lightColor:i,lightPosition:o,halfWidth:this.halfWidth,halfHeight:this.halfHeight,reflectedLight:a,ltc_1:t,ltc_2:s},e.stack,e)}static setLTC(e){DC=e}}Ql("RectAreaLight",kC);class GC extends FC{constructor(e=null){super(e),this.coneCosNode=Cc(0),this.penumbraCosNode=Cc(0),this.cutoffDistanceNode=Cc(0),this.decayExponentNode=Cc(0)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e){const{coneCosNode:t,penumbraCosNode:s}=this;return Dp(t,s,e)}setup(e){super.setup(e);const t=e.context.lightingModel,{colorNode:s,cutoffDistanceNode:i,decayExponentNode:r,light:n}=this,o=hg(n).sub(wg),a=o.normalize(),h=a.dot(RC(n)),l=this.getSpotAttenuation(h),u=o.length(),c=zC({lightDistance:u,cutoffDistance:i,decayExponent:r}),d=s.mul(l).mul(c),p=e.context.reflectedLight;t.direct({lightDirection:a,lightColor:d,reflectedLight:p},e.stack,e)}}Ql("SpotLight",GC);class WC extends GC{getSpotAttenuation(e){const t=this.light.iesMap;let s=null;if(t&&!0===t.isTexture){const i=e.acos().mul(1/Math.PI);s=Gm(t,sc(i,0),0).r}else s=super.getSpotAttenuation(e);return s}}Ql("IESSpotLight",WC);class HC extends FC{constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}Ql("AmbientLight",HC);class jC extends FC{constructor(e=null){super(e),this.lightPositionNode=og(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=Cc(new Yr)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:s,lightDirectionNode:i}=this,r=Ig.dot(i).mul(.5).add(.5),n=Up(s,t,r);e.context.irradiance.addAssign(n)}}Ql("HemisphereLight",jC);class qC extends FC{constructor(e=null){super(e);const t=[];for(let e=0;e<9;e++)t.push(new Ei);this.lightProbe=Xg(t)}update(e){const{light:t}=this;super.update(e);for(let e=0;e<9;e++)this.lightProbe.array[e].copy(t.sh.coefficients[e]).multiplyScalar(t.intensity)}setup(e){const t=$C(Pg,this.lightProbe);e.context.irradiance.addAssign(t)}}Ql("LightProbe",qC);const $C=ju((([e,t])=>{const s=e.x,i=e.y,r=e.z,n=t.element(0).mul(.886227);return n.addAssign(t.element(1).mul(1.023328).mul(i)),n.addAssign(t.element(2).mul(1.023328).mul(r)),n.addAssign(t.element(3).mul(1.023328).mul(s)),n.addAssign(t.element(4).mul(.858086).mul(s).mul(i)),n.addAssign(t.element(5).mul(.858086).mul(i).mul(r)),n.addAssign(t.element(6).mul(r.mul(r).mul(.743125).sub(.247708))),n.addAssign(t.element(7).mul(.858086).mul(s).mul(r)),n.addAssign(t.element(8).mul(.429043).mul(md(s,s).sub(md(i,i)))),n}));class XC{parseFunction(){console.warn("Abstract function.")}}class YC{constructor(e,t,s="",i=""){this.type=e,this.inputs=t,this.name=s,this.precision=i}getCode(){console.warn("Abstract function.")}}YC.isNodeFunction=!0;const JC=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,ZC=/[a-z_0-9]+/gi,KC="#pragma main";class QC extends YC{constructor(e){const{type:t,inputs:s,name:i,precision:r,inputsCode:n,blockCode:o,headerCode:a}=(e=>{const t=(e=e.trim()).indexOf(KC),s=-1!==t?e.slice(t+12):e,i=s.match(JC);if(null!==i&&5===i.length){const r=i[4],n=[];let o=null;for(;null!==(o=ZC.exec(r));)n.push(o);const a=[];let h=0;for(;h0?this.transparent:this.opaque).push(o)}unshift(e,t,s,i,r,n){const o=this.getNextRenderItem(e,t,s,i,r,n);(!0===s.transparent?this.transparent:this.opaque).unshift(o)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}getLightsNode(){return this.lightsNode.fromLights(this.lightsArray)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||tE),this.transparent.length>1&&this.transparent.sort(t||sE)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,h=o.height>>t;let l=e.depthTexture||r[t],u=!1;void 0===l&&(l=new Qa,l.format=e.stencilBuffer?He:We,l.type=e.stencilBuffer?Ue:Be,l.image.width=a,l.image.height=h,r[t]=l),s.width===o.width&&o.height===s.height||(u=!0,l.needsUpdate=!0,l.image.width=a,l.image.height=h),s.width=o.width,s.height=o.height,s.textures=n,s.depthTexture=l,s.depth=e.depthBuffer,s.stencil=e.stencilBuffer,s.renderTarget=e,s.sampleCount!==i&&(u=!0,l.needsUpdate=!0,s.sampleCount=i);const c={sampleCount:i};for(let e=0;e{e.removeEventListener("dispose",t);for(let e=0;e0){const i=e.image;if(void 0===i)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(!1===i.complete)console.warn("THREE.Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const s=[];for(const t of e.images)s.push(t);t.images=s}else t.image=i;void 0!==s.isDefaultTexture&&!0!==s.isDefaultTexture||(r.createTexture(e,t),s.isDefaultTexture=!1,s.generation=e.version),!0===e.source.dataReady&&r.updateTexture(e,t),t.needsMipmaps&&0===e.mipmaps.length&&r.generateMipmaps(e)}}else r.createDefaultTexture(e),s.isDefaultTexture=!0,s.generation=e.version}if(!0!==s.initialized){s.initialized=!0,s.generation=e.version,this.info.memory.textures++;const t=()=>{e.removeEventListener("dispose",t),this._destroyTexture(e),this.info.memory.textures--};e.addEventListener("dispose",t)}s.version=e.version}getSize(e,t=lE){let s=e.images?e.images[0]:e.image;return s?(void 0!==s.image&&(s=s.image),t.width=s.width,t.height=s.height,t.depth=e.isCubeTexture?6:s.depth||1):t.width=t.height=t.depth=1,t}getMipLevels(e,t,s){let i;return i=e.isCompressedTexture?e.mipmaps.length:Math.floor(Math.log2(Math.max(t,s)))+1,i}needsMipmaps(e){return!!this.isEnvironmentTexture(e)||(!0===e.isCompressedTexture||e.minFilter!==fe&&e.minFilter!==Te)}isEnvironmentTexture(e){const t=e.mapping;return t===ue||t===ce||t===he||t===le}_destroyTexture(e){this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e)}}class cE extends Yr{constructor(e,t,s,i=1){super(e,t,s),this.a=i}set(e,t,s,i=1){return this.a=i,super.set(e,t,s)}copy(e){return void 0!==e.a&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}const dE=ju((([e])=>{const t=e.toUint().mul(747796405).add(2891336453),s=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737);return s.shiftRight(22).bitXor(s).toFloat().mul(1/2**32)})),pE=(e,t)=>Cp(md(4,e.mul(pd(1,e))),t),mE=(e,t)=>e.lessThan(.5)?pE(e.mul(2),t).div(2):pd(1,pE(md(pd(1,e),2),t).div(2)),gE=(e,t,s)=>Cp(gd(Cp(e,t),dd(Cp(e,t),Cp(pd(1,e),s))),1/t),fE=(e,t)=>ep(Ld.mul(t.mul(e).sub(1))).div(Ld.mul(t.mul(e).sub(1))),yE=ju((([e])=>e.fract().sub(.5).abs())).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),xE=ju((([e])=>oc(yE(e.z.add(yE(e.y.mul(1)))),yE(e.z.add(yE(e.x.mul(1)))),yE(e.y.add(yE(e.x.mul(1))))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),bE=ju((([e,t,s])=>{const i=oc(e).toVar(),r=Ku(1.4).toVar(),n=Ku(0).toVar(),o=oc(i).toVar();return Cy({start:Ku(0),end:Ku(3),type:"float",condition:"<="},(()=>{const e=oc(xE(o.mul(2))).toVar();i.addAssign(e.add(s.mul(Ku(.1).mul(t)))),o.mulAssign(1.8),r.mulAssign(1.5),i.mulAssign(1.2);const a=Ku(yE(i.z.add(yE(i.x.add(yE(i.y)))))).toVar();n.addAssign(a.div(r)),o.addAssign(.14)})),n})).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"p",type:"vec3"},{name:"spd",type:"float"},{name:"time",type:"float"}]}),vE=ju((([e,t,s=sc(.5)])=>Fv(e.sub(s),t).add(s))),TE=ju((([e,t,s=sc(.5)])=>{const i=e.sub(s),r=i.dot(i),n=r.mul(r).mul(t);return e.add(i.mul(n))})),_E=ju((({position:e=null,horizontal:t=!0,vertical:s=!1})=>{let i;null!==e?(i=pg.toVar(),i[3][0]=e.x,i[3][1]=e.y,i[3][2]=e.z):i=pg;const r=Zm.mul(i);return Lu(t)&&(r[0][0]=pg[0].length(),r[0][1]=0,r[0][2]=0),Lu(s)&&(r[1][0]=0,r[1][1]=pg[1].length(),r[1][2]=0),r[2][0]=0,r[2][1]=0,r[2][2]=1,Ym.mul(r).mul(bg)})),wE=ju((([e=null])=>{const t=mx();return mx(ox(e)).sub(t).lessThan(0).select(Zy,e)})),SE=new WeakMap;class ME extends iu{constructor(){super("vec2"),this.updateType=Hl.OBJECT,this.updateAfterType=Hl.OBJECT,this.previousProjectionMatrix=Cc(new or),this.previousModelViewMatrix=Cc(new or)}update({camera:e,object:t}){const s=AE(t),i=AE(e);this.previousModelViewMatrix.value.copy(s),this.previousProjectionMatrix.value.copy(i)}updateAfter({camera:e,object:t}){const s=AE(t),i=AE(e);s.copy(t.modelViewMatrix),i.copy(e.projectionMatrix)}setup(){const e=Ym.mul(cg).mul(bg),t=this.previousProjectionMatrix.mul(this.previousModelViewMatrix).mul(vg),s=e.xy.div(e.w),i=t.xy.div(t.w);return pd(s,i)}}function AE(e){let t=SE.get(e);return void 0===t&&(t=new or,SE.set(e,t)),t}Ql("Velocity",ME);const NE=Hu(ME),RE=ju((([e,t])=>vp(1,e.oneMinus().div(t)).oneMinus())).setLayout({name:"burnBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),CE=ju((([e,t])=>vp(e.div(t.oneMinus()),1))).setLayout({name:"dodgeBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),EE=ju((([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus())).setLayout({name:"screenBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),BE=ju((([e,t])=>Up(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),wp(.5,e)))).setLayout({name:"overlayBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),IE=ju((([e,t,s=Qu(16)])=>{const i=t=>e.uv(t),r=Um(),n=i(r).toVar(),o=Ku(s);return Cy({start:Qu(1),end:s,type:"int",condition:"<="},(({i:e})=>{const s=t.mul(Ku(e).div(o.sub(1)).sub(.5));n.addAssign(i(r.add(s)))})),n.divAssign(o),n})),PE=ju((([e,t=1])=>{const s=e,i=cR(s.rgb),r=oc(i),n=vp(1,Tp(0,Ku(10).mul(i.sub(.45)))),o=r.mul(s.rgb).mul(2),a=Ku(2).mul(r.oneMinus()).mul(s.rgb.oneMinus()).oneMinus(),h=Up(o,a,n),l=s.a.mul(t),u=l.mul(h.rgb);return u.addAssign(s.rgb.mul(l.oneMinus())),uc(u,s.a)})),FE=ju((([e])=>{const t=oc(e);return uc(Np(t,oc(.393,.769,.189)),Np(t,oc(.349,.686,.168)),Np(t,oc(.272,.534,.131)),e.a)})),zE=ju((([e])=>{const t=e.mul(.9478672986).add(.0521327014).pow(2.4),s=e.mul(.0773993808),i=e.lessThanEqual(.04045);return Up(t,s,i)})).setLayout({name:"sRGBToLinearShader",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),UE=ju((([e])=>{const t=e.pow(.41666).mul(1.055).sub(.055),s=e.mul(12.92),i=e.lessThanEqual(.0031308);return Up(t,s,i)})).setLayout({name:"LinearTosRGBShader",type:"vec3",inputs:[{name:"color",type:"vec3"}]});var LE=Object.freeze({__proto__:null,LinearTosRGBShader:UE,sRGBToLinearShader:zE});const OE=ju((([e,t])=>e.mul(t).clamp())).setLayout({name:"LinearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),VE=ju((([e,t])=>(e=e.mul(t)).div(e.add(1)).clamp())).setLayout({name:"ReinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),DE=ju((([e,t])=>{const s=(e=(e=e.mul(t)).sub(.004).max(0)).mul(e.mul(6.2).add(.5)),i=e.mul(e.mul(6.2).add(1.7)).add(.06);return s.div(i).pow(2.2)})).setLayout({name:"CineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),kE=ju((([e])=>{const t=e.mul(e.add(.0245786)).sub(90537e-9),s=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(s)})),GE=ju((([e,t])=>{const s=gc(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),i=gc(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=s.mul(e),e=kE(e),(e=i.mul(e)).clamp()})).setLayout({name:"ACESFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),WE=gc(oc(1.6605,-.1246,-.0182),oc(-.5876,1.1329,-.1006),oc(-.0728,-.0083,1.1187)),HE=gc(oc(.6274,.0691,.0164),oc(.3293,.9195,.088),oc(.0433,.0113,.8956)),jE=ju((([e])=>{const t=oc(e).toVar(),s=oc(t.mul(t)).toVar(),i=oc(s.mul(s)).toVar();return Ku(15.5).mul(i.mul(s)).sub(md(40.14,i.mul(t))).add(md(31.96,i).sub(md(6.868,s.mul(t))).add(md(.4298,s).add(md(.1191,t).sub(.00232))))})),qE=ju((([e,t])=>{const s=oc(e).toVar(),i=gc(oc(.856627153315983,.137318972929847,.11189821299995),oc(.0951212405381588,.761241990602591,.0767994186031903),oc(.0482516061458583,.101439036467562,.811302368396859)),r=gc(oc(1.1271005818144368,-.1413297634984383,-.14132976349843826),oc(-.11060664309660323,1.157823702216272,-.11060664309660294),oc(-.016493938717834573,-.016493938717834257,1.2519364065950405)),n=Ku(-12.47393),o=Ku(4.026069);return s.mulAssign(t),s.assign(HE.mul(s)),s.assign(i.mul(s)),s.assign(Tp(s,1e-10)),s.assign($d(s)),s.assign(s.sub(n).div(o.sub(n))),s.assign(Lp(s,0,1)),s.assign(jE(s)),s.assign(r.mul(s)),s.assign(Cp(Tp(oc(0),s),oc(2.2))),s.assign(WE.mul(s)),s.assign(Lp(s,0,1)),s})).setLayout({name:"AgXToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),$E=ju((([e,t])=>{const s=Ku(.76),i=Ku(.15);e=e.mul(t);const r=vp(e.r,vp(e.g,e.b)),n=qp(r.lessThan(.08),r.sub(md(6.25,r.mul(r))),.04);e.subAssign(n);const o=Tp(e.r,Tp(e.g,e.b));Yu(o.lessThan(s),(()=>e));const a=pd(1,s),h=pd(1,a.mul(a).div(o.add(a.sub(s))));e.mulAssign(h.div(o));const l=pd(1,gd(1,i.mul(o.sub(h)).add(1)));return Up(e,oc(h),l)})).setLayout({name:"NeutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});var XE=Object.freeze({__proto__:null,ACESFilmicToneMapping:GE,AgXToneMapping:qE,CineonToneMapping:DE,LinearToneMapping:OE,NeutralToneMapping:$E,ReinhardToneMapping:VE});const YE=ju((([e=t()])=>{const t=e.mul(2),s=t.x.floor(),i=t.y.floor();return s.add(i).mod(2).sign()})),JE=ju((([e,t,s])=>{const i=Ku(s).toVar(),r=Ku(t).toVar(),n=tc(e).toVar();return qp(n,r,i)})).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),ZE=ju((([e,t])=>{const s=tc(t).toVar(),i=Ku(e).toVar();return qp(s,i.negate(),i)})).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),KE=ju((([e])=>{const t=Ku(e).toVar();return Qu(Jd(t))})).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),QE=ju((([e,t])=>{const s=Ku(e).toVar();return t.assign(KE(s)),s.sub(Ku(t))})),eB=fM([ju((([e,t,s,i,r,n])=>{const o=Ku(n).toVar(),a=Ku(r).toVar(),h=Ku(i).toVar(),l=Ku(s).toVar(),u=Ku(t).toVar(),c=Ku(e).toVar(),d=Ku(pd(1,a)).toVar();return pd(1,o).mul(c.mul(d).add(u.mul(a))).add(o.mul(l.mul(d).add(h.mul(a))))})).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),ju((([e,t,s,i,r,n])=>{const o=Ku(n).toVar(),a=Ku(r).toVar(),h=oc(i).toVar(),l=oc(s).toVar(),u=oc(t).toVar(),c=oc(e).toVar(),d=Ku(pd(1,a)).toVar();return pd(1,o).mul(c.mul(d).add(u.mul(a))).add(o.mul(l.mul(d).add(h.mul(a))))})).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]})]),tB=fM([ju((([e,t,s,i,r,n,o,a,h,l,u])=>{const c=Ku(u).toVar(),d=Ku(l).toVar(),p=Ku(h).toVar(),m=Ku(a).toVar(),g=Ku(o).toVar(),f=Ku(n).toVar(),y=Ku(r).toVar(),x=Ku(i).toVar(),b=Ku(s).toVar(),v=Ku(t).toVar(),T=Ku(e).toVar(),_=Ku(pd(1,p)).toVar(),w=Ku(pd(1,d)).toVar();return Ku(pd(1,c)).toVar().mul(w.mul(T.mul(_).add(v.mul(p))).add(d.mul(b.mul(_).add(x.mul(p))))).add(c.mul(w.mul(y.mul(_).add(f.mul(p))).add(d.mul(g.mul(_).add(m.mul(p))))))})).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),ju((([e,t,s,i,r,n,o,a,h,l,u])=>{const c=Ku(u).toVar(),d=Ku(l).toVar(),p=Ku(h).toVar(),m=oc(a).toVar(),g=oc(o).toVar(),f=oc(n).toVar(),y=oc(r).toVar(),x=oc(i).toVar(),b=oc(s).toVar(),v=oc(t).toVar(),T=oc(e).toVar(),_=Ku(pd(1,p)).toVar(),w=Ku(pd(1,d)).toVar();return Ku(pd(1,c)).toVar().mul(w.mul(T.mul(_).add(v.mul(p))).add(d.mul(b.mul(_).add(x.mul(p))))).add(c.mul(w.mul(y.mul(_).add(f.mul(p))).add(d.mul(g.mul(_).add(m.mul(p))))))})).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]})]),sB=ju((([e,t,s])=>{const i=Ku(s).toVar(),r=Ku(t).toVar(),n=ec(e).toVar(),o=ec(n.bitAnd(ec(7))).toVar(),a=Ku(JE(o.lessThan(ec(4)),r,i)).toVar(),h=Ku(md(2,JE(o.lessThan(ec(4)),i,r))).toVar();return ZE(a,tc(o.bitAnd(ec(1)))).add(ZE(h,tc(o.bitAnd(ec(2)))))})).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),iB=ju((([e,t,s,i])=>{const r=Ku(i).toVar(),n=Ku(s).toVar(),o=Ku(t).toVar(),a=ec(e).toVar(),h=ec(a.bitAnd(ec(15))).toVar(),l=Ku(JE(h.lessThan(ec(8)),o,n)).toVar(),u=Ku(JE(h.lessThan(ec(4)),n,JE(h.equal(ec(12)).or(h.equal(ec(14))),o,r))).toVar();return ZE(l,tc(h.bitAnd(ec(1)))).add(ZE(u,tc(h.bitAnd(ec(2)))))})).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),rB=fM([sB,iB]),nB=ju((([e,t,s])=>{const i=Ku(s).toVar(),r=Ku(t).toVar(),n=hc(e).toVar();return oc(rB(n.x,r,i),rB(n.y,r,i),rB(n.z,r,i))})).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),oB=ju((([e,t,s,i])=>{const r=Ku(i).toVar(),n=Ku(s).toVar(),o=Ku(t).toVar(),a=hc(e).toVar();return oc(rB(a.x,o,n,r),rB(a.y,o,n,r),rB(a.z,o,n,r))})).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),aB=fM([nB,oB]),hB=ju((([e])=>{const t=Ku(e).toVar();return md(.6616,t)})).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),lB=ju((([e])=>{const t=Ku(e).toVar();return md(.982,t)})).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),uB=fM([hB,ju((([e])=>{const t=oc(e).toVar();return md(.6616,t)})).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),cB=fM([lB,ju((([e])=>{const t=oc(e).toVar();return md(.982,t)})).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),dB=ju((([e,t])=>{const s=Qu(t).toVar(),i=ec(e).toVar();return i.shiftLeft(s).bitOr(i.shiftRight(Qu(32).sub(s)))})).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),pB=ju((([e,t,s])=>{e.subAssign(s),e.bitXorAssign(dB(s,Qu(4))),s.addAssign(t),t.subAssign(e),t.bitXorAssign(dB(e,Qu(6))),e.addAssign(s),s.subAssign(t),s.bitXorAssign(dB(t,Qu(8))),t.addAssign(e),e.subAssign(s),e.bitXorAssign(dB(s,Qu(16))),s.addAssign(t),t.subAssign(e),t.bitXorAssign(dB(e,Qu(19))),e.addAssign(s),s.subAssign(t),s.bitXorAssign(dB(t,Qu(4))),t.addAssign(e)})),mB=ju((([e,t,s])=>{const i=ec(s).toVar(),r=ec(t).toVar(),n=ec(e).toVar();return i.bitXorAssign(r),i.subAssign(dB(r,Qu(14))),n.bitXorAssign(i),n.subAssign(dB(i,Qu(11))),r.bitXorAssign(n),r.subAssign(dB(n,Qu(25))),i.bitXorAssign(r),i.subAssign(dB(r,Qu(16))),n.bitXorAssign(i),n.subAssign(dB(i,Qu(4))),r.bitXorAssign(n),r.subAssign(dB(n,Qu(14))),i.bitXorAssign(r),i.subAssign(dB(r,Qu(24))),i})).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),gB=ju((([e])=>{const t=ec(e).toVar();return Ku(t).div(Ku(ec(Qu(4294967295))))})).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),fB=ju((([e])=>{const t=Ku(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))})).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),yB=fM([ju((([e])=>{const t=Qu(e).toVar(),s=ec(ec(1)).toVar(),i=ec(ec(Qu(3735928559)).add(s.shiftLeft(ec(2))).add(ec(13))).toVar();return mB(i.add(ec(t)),i,i)})).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),ju((([e,t])=>{const s=Qu(t).toVar(),i=Qu(e).toVar(),r=ec(ec(2)).toVar(),n=ec().toVar(),o=ec().toVar(),a=ec().toVar();return n.assign(o.assign(a.assign(ec(Qu(3735928559)).add(r.shiftLeft(ec(2))).add(ec(13))))),n.addAssign(ec(i)),o.addAssign(ec(s)),mB(n,o,a)})).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),ju((([e,t,s])=>{const i=Qu(s).toVar(),r=Qu(t).toVar(),n=Qu(e).toVar(),o=ec(ec(3)).toVar(),a=ec().toVar(),h=ec().toVar(),l=ec().toVar();return a.assign(h.assign(l.assign(ec(Qu(3735928559)).add(o.shiftLeft(ec(2))).add(ec(13))))),a.addAssign(ec(n)),h.addAssign(ec(r)),l.addAssign(ec(i)),mB(a,h,l)})).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),ju((([e,t,s,i])=>{const r=Qu(i).toVar(),n=Qu(s).toVar(),o=Qu(t).toVar(),a=Qu(e).toVar(),h=ec(ec(4)).toVar(),l=ec().toVar(),u=ec().toVar(),c=ec().toVar();return l.assign(u.assign(c.assign(ec(Qu(3735928559)).add(h.shiftLeft(ec(2))).add(ec(13))))),l.addAssign(ec(a)),u.addAssign(ec(o)),c.addAssign(ec(n)),pB(l,u,c),l.addAssign(ec(r)),mB(l,u,c)})).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),ju((([e,t,s,i,r])=>{const n=Qu(r).toVar(),o=Qu(i).toVar(),a=Qu(s).toVar(),h=Qu(t).toVar(),l=Qu(e).toVar(),u=ec(ec(5)).toVar(),c=ec().toVar(),d=ec().toVar(),p=ec().toVar();return c.assign(d.assign(p.assign(ec(Qu(3735928559)).add(u.shiftLeft(ec(2))).add(ec(13))))),c.addAssign(ec(l)),d.addAssign(ec(h)),p.addAssign(ec(a)),pB(c,d,p),c.addAssign(ec(o)),d.addAssign(ec(n)),mB(c,d,p)})).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]})]),xB=fM([ju((([e,t])=>{const s=Qu(t).toVar(),i=Qu(e).toVar(),r=ec(yB(i,s)).toVar(),n=hc().toVar();return n.x.assign(r.bitAnd(Qu(255))),n.y.assign(r.shiftRight(Qu(8)).bitAnd(Qu(255))),n.z.assign(r.shiftRight(Qu(16)).bitAnd(Qu(255))),n})).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),ju((([e,t,s])=>{const i=Qu(s).toVar(),r=Qu(t).toVar(),n=Qu(e).toVar(),o=ec(yB(n,r,i)).toVar(),a=hc().toVar();return a.x.assign(o.bitAnd(Qu(255))),a.y.assign(o.shiftRight(Qu(8)).bitAnd(Qu(255))),a.z.assign(o.shiftRight(Qu(16)).bitAnd(Qu(255))),a})).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]})]),bB=fM([ju((([e])=>{const t=sc(e).toVar(),s=Qu().toVar(),i=Qu().toVar(),r=Ku(QE(t.x,s)).toVar(),n=Ku(QE(t.y,i)).toVar(),o=Ku(fB(r)).toVar(),a=Ku(fB(n)).toVar(),h=Ku(eB(rB(yB(s,i),r,n),rB(yB(s.add(Qu(1)),i),r.sub(1),n),rB(yB(s,i.add(Qu(1))),r,n.sub(1)),rB(yB(s.add(Qu(1)),i.add(Qu(1))),r.sub(1),n.sub(1)),o,a)).toVar();return uB(h)})).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),ju((([e])=>{const t=oc(e).toVar(),s=Qu().toVar(),i=Qu().toVar(),r=Qu().toVar(),n=Ku(QE(t.x,s)).toVar(),o=Ku(QE(t.y,i)).toVar(),a=Ku(QE(t.z,r)).toVar(),h=Ku(fB(n)).toVar(),l=Ku(fB(o)).toVar(),u=Ku(fB(a)).toVar(),c=Ku(tB(rB(yB(s,i,r),n,o,a),rB(yB(s.add(Qu(1)),i,r),n.sub(1),o,a),rB(yB(s,i.add(Qu(1)),r),n,o.sub(1),a),rB(yB(s.add(Qu(1)),i.add(Qu(1)),r),n.sub(1),o.sub(1),a),rB(yB(s,i,r.add(Qu(1))),n,o,a.sub(1)),rB(yB(s.add(Qu(1)),i,r.add(Qu(1))),n.sub(1),o,a.sub(1)),rB(yB(s,i.add(Qu(1)),r.add(Qu(1))),n,o.sub(1),a.sub(1)),rB(yB(s.add(Qu(1)),i.add(Qu(1)),r.add(Qu(1))),n.sub(1),o.sub(1),a.sub(1)),h,l,u)).toVar();return cB(c)})).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]})]),vB=fM([ju((([e])=>{const t=sc(e).toVar(),s=Qu().toVar(),i=Qu().toVar(),r=Ku(QE(t.x,s)).toVar(),n=Ku(QE(t.y,i)).toVar(),o=Ku(fB(r)).toVar(),a=Ku(fB(n)).toVar(),h=oc(eB(aB(xB(s,i),r,n),aB(xB(s.add(Qu(1)),i),r.sub(1),n),aB(xB(s,i.add(Qu(1))),r,n.sub(1)),aB(xB(s.add(Qu(1)),i.add(Qu(1))),r.sub(1),n.sub(1)),o,a)).toVar();return uB(h)})).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),ju((([e])=>{const t=oc(e).toVar(),s=Qu().toVar(),i=Qu().toVar(),r=Qu().toVar(),n=Ku(QE(t.x,s)).toVar(),o=Ku(QE(t.y,i)).toVar(),a=Ku(QE(t.z,r)).toVar(),h=Ku(fB(n)).toVar(),l=Ku(fB(o)).toVar(),u=Ku(fB(a)).toVar(),c=oc(tB(aB(xB(s,i,r),n,o,a),aB(xB(s.add(Qu(1)),i,r),n.sub(1),o,a),aB(xB(s,i.add(Qu(1)),r),n,o.sub(1),a),aB(xB(s.add(Qu(1)),i.add(Qu(1)),r),n.sub(1),o.sub(1),a),aB(xB(s,i,r.add(Qu(1))),n,o,a.sub(1)),aB(xB(s.add(Qu(1)),i,r.add(Qu(1))),n.sub(1),o,a.sub(1)),aB(xB(s,i.add(Qu(1)),r.add(Qu(1))),n,o.sub(1),a.sub(1)),aB(xB(s.add(Qu(1)),i.add(Qu(1)),r.add(Qu(1))),n.sub(1),o.sub(1),a.sub(1)),h,l,u)).toVar();return cB(c)})).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]})]),TB=fM([ju((([e])=>{const t=Ku(e).toVar(),s=Qu(KE(t)).toVar();return gB(yB(s))})).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),ju((([e])=>{const t=sc(e).toVar(),s=Qu(KE(t.x)).toVar(),i=Qu(KE(t.y)).toVar();return gB(yB(s,i))})).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),ju((([e])=>{const t=oc(e).toVar(),s=Qu(KE(t.x)).toVar(),i=Qu(KE(t.y)).toVar(),r=Qu(KE(t.z)).toVar();return gB(yB(s,i,r))})).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),ju((([e])=>{const t=uc(e).toVar(),s=Qu(KE(t.x)).toVar(),i=Qu(KE(t.y)).toVar(),r=Qu(KE(t.z)).toVar(),n=Qu(KE(t.w)).toVar();return gB(yB(s,i,r,n))})).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),_B=fM([ju((([e])=>{const t=Ku(e).toVar(),s=Qu(KE(t)).toVar();return oc(gB(yB(s,Qu(0))),gB(yB(s,Qu(1))),gB(yB(s,Qu(2))))})).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),ju((([e])=>{const t=sc(e).toVar(),s=Qu(KE(t.x)).toVar(),i=Qu(KE(t.y)).toVar();return oc(gB(yB(s,i,Qu(0))),gB(yB(s,i,Qu(1))),gB(yB(s,i,Qu(2))))})).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),ju((([e])=>{const t=oc(e).toVar(),s=Qu(KE(t.x)).toVar(),i=Qu(KE(t.y)).toVar(),r=Qu(KE(t.z)).toVar();return oc(gB(yB(s,i,r,Qu(0))),gB(yB(s,i,r,Qu(1))),gB(yB(s,i,r,Qu(2))))})).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),ju((([e])=>{const t=uc(e).toVar(),s=Qu(KE(t.x)).toVar(),i=Qu(KE(t.y)).toVar(),r=Qu(KE(t.z)).toVar(),n=Qu(KE(t.w)).toVar();return oc(gB(yB(s,i,r,n,Qu(0))),gB(yB(s,i,r,n,Qu(1))),gB(yB(s,i,r,n,Qu(2))))})).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),wB=ju((([e,t,s,i])=>{const r=Ku(i).toVar(),n=Ku(s).toVar(),o=Qu(t).toVar(),a=oc(e).toVar(),h=Ku(0).toVar(),l=Ku(1).toVar();return Cy(o,(()=>{h.addAssign(l.mul(bB(a))),l.mulAssign(r),a.mulAssign(n)})),h})).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),SB=ju((([e,t,s,i])=>{const r=Ku(i).toVar(),n=Ku(s).toVar(),o=Qu(t).toVar(),a=oc(e).toVar(),h=oc(0).toVar(),l=Ku(1).toVar();return Cy(o,(()=>{h.addAssign(l.mul(vB(a))),l.mulAssign(r),a.mulAssign(n)})),h})).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),MB=ju((([e,t,s,i])=>{const r=Ku(i).toVar(),n=Ku(s).toVar(),o=Qu(t).toVar(),a=oc(e).toVar();return sc(wB(a,o,n,r),wB(a.add(oc(Qu(19),Qu(193),Qu(17))),o,n,r))})).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),AB=ju((([e,t,s,i])=>{const r=Ku(i).toVar(),n=Ku(s).toVar(),o=Qu(t).toVar(),a=oc(e).toVar(),h=oc(SB(a,o,n,r)).toVar(),l=Ku(wB(a.add(oc(Qu(19),Qu(193),Qu(17))),o,n,r)).toVar();return uc(h,l)})).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),NB=ju((([e,t,s,i,r,n,o])=>{const a=Qu(o).toVar(),h=Ku(n).toVar(),l=Qu(r).toVar(),u=Qu(i).toVar(),c=Qu(s).toVar(),d=Qu(t).toVar(),p=sc(e).toVar(),m=oc(_B(sc(d.add(u),c.add(l)))).toVar(),g=sc(m.x,m.y).toVar();g.subAssign(.5),g.mulAssign(h),g.addAssign(.5);const f=sc(sc(Ku(d),Ku(c)).add(g)).toVar(),y=sc(f.sub(p)).toVar();return Yu(a.equal(Qu(2)),(()=>op(y.x).add(op(y.y)))),Yu(a.equal(Qu(3)),(()=>Tp(op(y.x),op(y.y)))),Np(y,y)})).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),RB=fM([NB,ju((([e,t,s,i,r,n,o,a,h])=>{const l=Qu(h).toVar(),u=Ku(a).toVar(),c=Qu(o).toVar(),d=Qu(n).toVar(),p=Qu(r).toVar(),m=Qu(i).toVar(),g=Qu(s).toVar(),f=Qu(t).toVar(),y=oc(e).toVar(),x=oc(_B(oc(f.add(p),g.add(d),m.add(c)))).toVar();x.subAssign(.5),x.mulAssign(u),x.addAssign(.5);const b=oc(oc(Ku(f),Ku(g),Ku(m)).add(x)).toVar(),v=oc(b.sub(y)).toVar();return Yu(l.equal(Qu(2)),(()=>op(v.x).add(op(v.y)).add(op(v.z)))),Yu(l.equal(Qu(3)),(()=>Tp(Tp(op(v.x),op(v.y)),op(v.z)))),Np(v,v)})).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),CB=ju((([e,t,s])=>{const i=Qu(s).toVar(),r=Ku(t).toVar(),n=sc(e).toVar(),o=Qu().toVar(),a=Qu().toVar(),h=sc(QE(n.x,o),QE(n.y,a)).toVar(),l=Ku(1e6).toVar();return Cy({start:-1,end:Qu(1),name:"x",condition:"<="},(({x:e})=>{Cy({start:-1,end:Qu(1),name:"y",condition:"<="},(({y:t})=>{const s=Ku(RB(h,e,t,o,a,r,i)).toVar();l.assign(vp(l,s))}))})),Yu(i.equal(Qu(0)),(()=>{l.assign(Xd(l))})),l})).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),EB=ju((([e,t,s])=>{const i=Qu(s).toVar(),r=Ku(t).toVar(),n=sc(e).toVar(),o=Qu().toVar(),a=Qu().toVar(),h=sc(QE(n.x,o),QE(n.y,a)).toVar(),l=sc(1e6,1e6).toVar();return Cy({start:-1,end:Qu(1),name:"x",condition:"<="},(({x:e})=>{Cy({start:-1,end:Qu(1),name:"y",condition:"<="},(({y:t})=>{const s=Ku(RB(h,e,t,o,a,r,i)).toVar();Yu(s.lessThan(l.x),(()=>{l.y.assign(l.x),l.x.assign(s)})).ElseIf(s.lessThan(l.y),(()=>{l.y.assign(s)}))}))})),Yu(i.equal(Qu(0)),(()=>{l.assign(Xd(l))})),l})).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),BB=ju((([e,t,s])=>{const i=Qu(s).toVar(),r=Ku(t).toVar(),n=sc(e).toVar(),o=Qu().toVar(),a=Qu().toVar(),h=sc(QE(n.x,o),QE(n.y,a)).toVar(),l=oc(1e6,1e6,1e6).toVar();return Cy({start:-1,end:Qu(1),name:"x",condition:"<="},(({x:e})=>{Cy({start:-1,end:Qu(1),name:"y",condition:"<="},(({y:t})=>{const s=Ku(RB(h,e,t,o,a,r,i)).toVar();Yu(s.lessThan(l.x),(()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(s)})).ElseIf(s.lessThan(l.y),(()=>{l.z.assign(l.y),l.y.assign(s)})).ElseIf(s.lessThan(l.z),(()=>{l.z.assign(s)}))}))})),Yu(i.equal(Qu(0)),(()=>{l.assign(Xd(l))})),l})).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),IB=fM([CB,ju((([e,t,s])=>{const i=Qu(s).toVar(),r=Ku(t).toVar(),n=oc(e).toVar(),o=Qu().toVar(),a=Qu().toVar(),h=Qu().toVar(),l=oc(QE(n.x,o),QE(n.y,a),QE(n.z,h)).toVar(),u=Ku(1e6).toVar();return Cy({start:-1,end:Qu(1),name:"x",condition:"<="},(({x:e})=>{Cy({start:-1,end:Qu(1),name:"y",condition:"<="},(({y:t})=>{Cy({start:-1,end:Qu(1),name:"z",condition:"<="},(({z:s})=>{const n=Ku(RB(l,e,t,s,o,a,h,r,i)).toVar();u.assign(vp(u,n))}))}))})),Yu(i.equal(Qu(0)),(()=>{u.assign(Xd(u))})),u})).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),PB=fM([EB,ju((([e,t,s])=>{const i=Qu(s).toVar(),r=Ku(t).toVar(),n=oc(e).toVar(),o=Qu().toVar(),a=Qu().toVar(),h=Qu().toVar(),l=oc(QE(n.x,o),QE(n.y,a),QE(n.z,h)).toVar(),u=sc(1e6,1e6).toVar();return Cy({start:-1,end:Qu(1),name:"x",condition:"<="},(({x:e})=>{Cy({start:-1,end:Qu(1),name:"y",condition:"<="},(({y:t})=>{Cy({start:-1,end:Qu(1),name:"z",condition:"<="},(({z:s})=>{const n=Ku(RB(l,e,t,s,o,a,h,r,i)).toVar();Yu(n.lessThan(u.x),(()=>{u.y.assign(u.x),u.x.assign(n)})).ElseIf(n.lessThan(u.y),(()=>{u.y.assign(n)}))}))}))})),Yu(i.equal(Qu(0)),(()=>{u.assign(Xd(u))})),u})).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),FB=fM([BB,ju((([e,t,s])=>{const i=Qu(s).toVar(),r=Ku(t).toVar(),n=oc(e).toVar(),o=Qu().toVar(),a=Qu().toVar(),h=Qu().toVar(),l=oc(QE(n.x,o),QE(n.y,a),QE(n.z,h)).toVar(),u=oc(1e6,1e6,1e6).toVar();return Cy({start:-1,end:Qu(1),name:"x",condition:"<="},(({x:e})=>{Cy({start:-1,end:Qu(1),name:"y",condition:"<="},(({y:t})=>{Cy({start:-1,end:Qu(1),name:"z",condition:"<="},(({z:s})=>{const n=Ku(RB(l,e,t,s,o,a,h,r,i)).toVar();Yu(n.lessThan(u.x),(()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(n)})).ElseIf(n.lessThan(u.y),(()=>{u.z.assign(u.y),u.y.assign(n)})).ElseIf(n.lessThan(u.z),(()=>{u.z.assign(n)}))}))}))})),Yu(i.equal(Qu(0)),(()=>{u.assign(Xd(u))})),u})).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),zB=ju((([e])=>{const t=e.y,s=e.z,i=oc().toVar();return Yu(t.lessThan(1e-4),(()=>{i.assign(oc(s,s,s))})).Else((()=>{let r=e.x;r=r.sub(Jd(r)).mul(6).toVar();const n=Qu(gp(r)),o=r.sub(Ku(n)),a=s.mul(t.oneMinus()),h=s.mul(t.mul(o).oneMinus()),l=s.mul(t.mul(o.oneMinus()).oneMinus());Yu(n.equal(Qu(0)),(()=>{i.assign(oc(s,l,a))})).ElseIf(n.equal(Qu(1)),(()=>{i.assign(oc(h,s,a))})).ElseIf(n.equal(Qu(2)),(()=>{i.assign(oc(a,s,l))})).ElseIf(n.equal(Qu(3)),(()=>{i.assign(oc(a,h,s))})).ElseIf(n.equal(Qu(4)),(()=>{i.assign(oc(l,a,s))})).Else((()=>{i.assign(oc(s,a,h))}))})),i})).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),UB=ju((([e])=>{const t=oc(e).toVar(),s=Ku(t.x).toVar(),i=Ku(t.y).toVar(),r=Ku(t.z).toVar(),n=Ku(vp(s,vp(i,r))).toVar(),o=Ku(Tp(s,Tp(i,r))).toVar(),a=Ku(o.sub(n)).toVar(),h=Ku().toVar(),l=Ku().toVar(),u=Ku().toVar();return u.assign(o),Yu(o.greaterThan(0),(()=>{l.assign(a.div(o))})).Else((()=>{l.assign(0)})),Yu(l.lessThanEqual(0),(()=>{h.assign(0)})).Else((()=>{Yu(s.greaterThanEqual(o),(()=>{h.assign(i.sub(r).div(a))})).ElseIf(i.greaterThanEqual(o),(()=>{h.assign(dd(2,r.sub(s).div(a)))})).Else((()=>{h.assign(dd(4,s.sub(i).div(a)))})),h.mulAssign(1/6),Yu(h.lessThan(0),(()=>{h.addAssign(1)}))})),oc(h,l,u)})).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),LB=ju((([e])=>{const t=oc(e).toVar(),s=lc(vd(t,oc(.04045))).toVar(),i=oc(t.div(12.92)).toVar(),r=oc(Cp(Tp(t.add(oc(.055)),oc(0)).div(1.055),oc(2.4))).toVar();return Up(i,r,s)})).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),OB=(e,t)=>{e=Ku(e),t=Ku(t);const s=sc(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return Dp(e.sub(s),e.add(s),t)},VB=(e,t,s,i)=>Up(e,t,s[i].clamp()),DB=(e,t,s=Um())=>VB(e,t,s,"x"),kB=(e,t,s=Um())=>VB(e,t,s,"y"),GB=(e,t,s,i,r)=>Up(e,t,OB(s,i[r])),WB=(e,t,s,i=Um())=>GB(e,t,s,i,"x"),HB=(e,t,s,i=Um())=>GB(e,t,s,i,"y"),jB=(e=1,t=0,s=Um())=>s.mul(e).add(t),qB=(e,t=1)=>(e=Ku(e)).abs().pow(t).mul(e.sign()),$B=(e,t=1,s=.5)=>Ku(e).sub(s).mul(t).add(s),XB=(e=Um(),t=1,s=0)=>bB(e.convert("vec2|vec3")).mul(t).add(s),YB=(e=Um(),t=1,s=0)=>vB(e.convert("vec2|vec3")).mul(t).add(s),JB=(e=Um(),t=1,s=0)=>{e=e.convert("vec2|vec3");return uc(vB(e),bB(e.add(sc(19,73)))).mul(t).add(s)},ZB=(e=Um(),t=1)=>IB(e.convert("vec2|vec3"),t,Qu(1)),KB=(e=Um(),t=1)=>PB(e.convert("vec2|vec3"),t,Qu(1)),QB=(e=Um(),t=1)=>FB(e.convert("vec2|vec3"),t,Qu(1)),eI=(e=Um())=>TB(e.convert("vec2|vec3")),tI=(e=Um(),t=3,s=2,i=.5,r=1)=>wB(e,Qu(t),s,i).mul(r),sI=(e=Um(),t=3,s=2,i=.5,r=1)=>MB(e,Qu(t),s,i).mul(r),iI=(e=Um(),t=3,s=2,i=.5,r=1)=>SB(e,Qu(t),s,i).mul(r),rI=(e=Um(),t=3,s=2,i=.5,r=1)=>AB(e,Qu(t),s,i).mul(r),nI=new cE;class oI extends zw{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,s){const i=this.renderer,r=this.nodes.getBackgroundNode(e)||e.background;let n=!1;if(null===r)i._clearColor.getRGB(nI,Zt),nI.a=i._clearColor.a;else if(!0===r.isColor)r.getRGB(nI,Zt),nI.a=1,n=!0;else if(!0===r.isNode){const s=this.get(e),n=r;nI.copy(i._clearColor);let o=s.backgroundMesh;if(void 0===o){const e=Yp(uc(n).mul(uA),{getUV:()=>Pg,getTextureLevel:()=>lA});let t=py();t=t.setZ(t.w);const i=new yx;i.name="Background.material",i.side=d,i.depthTest=!1,i.depthWrite=!1,i.fog=!1,i.lights=!1,i.vertexNode=t,i.colorNode=e,s.backgroundMeshNode=e,s.backgroundMesh=o=new Wn(new fl(1,32,32),i),o.frustumCulled=!1,o.name="Background.mesh",o.onBeforeRender=function(e,t,s){this.matrixWorld.copyPosition(s.matrixWorld)}}const a=n.getCacheKey();s.backgroundCacheKey!==a&&(s.backgroundMeshNode.node=uc(n).mul(uA),s.backgroundMeshNode.needsUpdate=!0,o.material.needsUpdate=!0,s.backgroundCacheKey=a),t.unshift(o,o.geometry,o.material,0,0,null)}else console.error("THREE.Renderer: Unsupported background configuration.",r);if(!0===i.autoClear||!0===n){nI.multiplyScalar(nI.a);const e=s.clearColorValue;e.r=nI.r,e.g=nI.g,e.b=nI.b,e.a=nI.a,s.depthClearValue=i._clearDepth,s.stencilClearValue=i._clearStencil,s.clearColor=!0===i.autoClearColor,s.clearDepth=!0===i.autoClearDepth,s.clearStencil=!0===i.autoClearStencil}else s.clearColor=!1,s.clearDepth=!1,s.clearStencil=!1}}class aI{constructor(e,t,s,i,r,n,o,a,h=!0,l=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=s,this.transforms=l,this.nodeAttributes=i,this.bindings=r,this.updateNodes=n,this.updateBeforeNodes=o,this.updateAfterNodes=a,this.instanceBindGroups=h,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings){if(!0!==(this.instanceBindGroups&&t.bindings[0].groupNode.shared)){const s=new eM(t.name,[],t.index,t);e.push(s);for(const e of t.bindings)s.bindings.push(e.clone())}else e.push(t)}return e}}const hI=new WeakMap;class lI extends zw{constructor(e,t){super(),this.renderer=e,this.backend=t,this.nodeFrame=new oM,this.nodeBuilderCache=new Map,this.callHashCache=new Cw,this.groupsData=new Cw}updateGroup(e){const t=e.groupNode,s=t.name;if(s===Nc.name)return!0;if(s===Ac.name){const t=this.get(e),s=this.nodeFrame.renderId;return t.renderId!==s&&(t.renderId=s,!0)}if(s===Mc.name){const t=this.get(e),s=this.nodeFrame.frameId;return t.frameId!==s&&(t.frameId=s,!0)}const i=[t,e];let r=this.groupsData.get(i);return void 0===r&&this.groupsData.set(i,r={}),r.version!==t.version&&(r.version=t.version,!0)}getForRenderCacheKey(e){return e.initialCacheKey}getForRender(e){const t=this.get(e);let s=t.nodeBuilderState;if(void 0===s){const{nodeBuilderCache:i}=this,r=this.getForRenderCacheKey(e);if(s=i.get(r),void 0===s){const t=this.backend.createNodeBuilder(e.object,this.renderer);t.scene=e.scene,t.material=e.material,t.camera=e.camera,t.context.material=e.material,t.lightsNode=e.lightsNode,t.environmentNode=this.getEnvironmentNode(e.scene),t.fogNode=this.getFogNode(e.scene),t.clippingContext=e.clippingContext,t.build(),s=this._createNodeBuilderState(t),i.set(r,s)}s.usedTimes++,t.nodeBuilderState=s}return s}delete(e){if(e.isRenderObject){const t=this.get(e).nodeBuilderState;t.usedTimes--,0===t.usedTimes&&this.nodeBuilderCache.delete(this.getForRenderCacheKey(e))}return super.delete(e)}getForCompute(e){const t=this.get(e);let s=t.nodeBuilderState;if(void 0===s){const i=this.backend.createNodeBuilder(e,this.renderer);i.build(),s=this._createNodeBuilderState(i),t.nodeBuilderState=s}return s}_createNodeBuilderState(e){return new aI(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.instanceBindGroups,e.transforms)}getEnvironmentNode(e){return e.environmentNode||this.get(e).environmentNode||null}getBackgroundNode(e){return e.backgroundNode||this.get(e).backgroundNode||null}getFogNode(e){return e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){const s=[e,t],i=this.renderer.info.calls;let r=this.callHashCache.get(s);if(void 0===r||r.callId!==i){const n=this.getEnvironmentNode(e),o=this.getFogNode(e),a=[];t&&a.push(t.getCacheKey(!0)),n&&a.push(n.getCacheKey()),o&&a.push(o.getCacheKey()),r={callId:i,cacheKey:a.join(",")},this.callHashCache.set(s,r)}return r.cacheKey}updateScene(e){this.updateEnvironment(e),this.updateFog(e),this.updateBackground(e)}get isToneMappingState(){return!this.renderer.getRenderTarget()}updateBackground(e){const t=this.get(e),s=e.background;if(s){const i=0===e.backgroundBlurriness&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&0===t.backgroundBlurriness;if(t.background!==s||i){let i=null;if(!0===s.isCubeTexture||s.mapping===ue||s.mapping===ce)if(e.backgroundBlurriness>0)i=dv(s,Pg);else{let e;e=!0===s.isCubeTexture?Wg(s):Gm(s),i=Lx(e)}else!0===s.isTexture?i=Gm(s,Zy.flipY()).setUpdateMatrix(!0):!0!==s.isColor&&console.error("WebGPUNodes: Unsupported background configuration.",s);t.backgroundNode=i,t.background=s,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}updateFog(e){const t=this.get(e),s=e.fog;if(s){if(t.fog!==s){let e=null;s.isFogExp2?e=_C(Zg("color","color",s),Zg("density","float",s)):s.isFog?e=vC(Zg("color","color",s),Zg("near","float",s),Zg("far","float",s)):console.error("WebGPUNodes: Unsupported fog configuration.",s),t.fogNode=e,t.fog=s}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),s=e.environment;if(s){if(t.environment!==s){let e=null;!0===s.isCubeTexture?e=Wg(s):!0===s.isTexture?e=Gm(s):console.error("Nodes: Unsupported environment configuration.",s),t.environmentNode=e,t.environment=s}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,s=null,i=null,r=null){const n=this.nodeFrame;return n.renderer=e,n.scene=t,n.object=s,n.camera=i,n.material=r,n}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace}hasOutputChange(e){return hI.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,s=this.getOutputCacheKey(),i=Gm(e,Zy).renderOutput(t.toneMapping,t.currentColorSpace);return hI.set(e,s),i}updateBefore(e){const t=e.getNodeBuilderState();for(const s of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(s)}updateAfter(e){const t=e.getNodeBuilderState();for(const s of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(s)}updateForCompute(e){const t=this.getNodeFrame(),s=this.getForCompute(e);for(const e of s.updateNodes)t.updateNode(e)}updateForRender(e){const t=this.getNodeFrameForRender(e),s=e.getNodeBuilderState();for(const e of s.updateNodes)t.updateNode(e)}dispose(){super.dispose(),this.nodeFrame=new oM,this.nodeBuilderCache=new Map}}class uI{constructor(e,t){this.scene=e,this.camera=t}clone(){return Object.assign(new this.constructor,this)}}class cI{constructor(){this.lists=new Cw}get(e,t){const s=this.lists,i=[e,t];let r=s.get(i);return void 0===r&&(r=new uI(e,t),s.set(i,r)),r}dispose(){this.lists=new Cw}}class dI{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map,this.colorSpaceNodes=new Map}fromMaterial(e){if(e.isNodeMaterial)return e;let t=null;const s=this.getMaterialNodeClass(e.type);if(null!==s){t=new s;for(const s in e)t[s]=e[s]}return t}addColorSpace(e,t){this.addType(e,t,this.colorSpaceNodes)}getColorSpaceFunction(e){return this.colorSpaceNodes.get(e)||null}addToneMapping(e,t){this.addType(e,t,this.toneMappingNodes)}getToneMappingFunction(e){return this.toneMappingNodes.get(e)||null}getMaterialNodeClass(e){return this.materialNodes.get(e)||null}addMaterial(e,t){this.addType(e,t.name,this.materialNodes)}getLightNodeClass(e){return this.lightNodes.get(e)||null}addLight(e,t){this.addClass(e,t,this.lightNodes)}addType(e,t,s){if(s.has(t))console.warn(`Redefinition of node ${t}`);else{if("function"!=typeof e)throw new Error(`Node class ${e.name} is not a class.`);if("function"==typeof t||"object"==typeof t)throw new Error(`Base class ${t} is not a class.`);s.set(t,e)}}addClass(e,t,s){if(s.has(t))console.warn(`Redefinition of node ${t.name}`);else{if("function"!=typeof e)throw new Error(`Node class ${e.name} is not a class.`);if("function"!=typeof t)throw new Error(`Base class ${t.name} is not a class.`);s.set(t,e)}}}const pI=new no,mI=new Qs,gI=new _i,fI=new na,yI=new or,xI=new Ei;class bI{constructor(e,t={}){this.isRenderer=!0;const{logarithmicDepthBuffer:s=!1,alpha:i=!0,antialias:r=!1,samples:n=0,getFallback:o=null}=t;this.domElement=e.getDomElement(),this.backend=e,this.samples=n||!0===r?4:0,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.alpha=i,this.logarithmicDepthBuffer=s,this.outputColorSpace=Jt,this.toneMapping=0,this.toneMappingExposure=1,this.sortObjects=!0,this.depth=!0,this.stencil=!1,this.clippingPlanes=[],this.info=new Hw,this.nodes={library:new dI},this._getFallback=o,this._pixelRatio=1,this._width=this.domElement.width,this._height=this.domElement.height,this._viewport=new _i(0,0,this._width,this._height),this._scissor=new _i(0,0,this._width,this._height),this._scissorTest=!1,this._attributes=null,this._geometries=null,this._nodes=null,this._animation=null,this._bindings=null,this._objects=null,this._pipelines=null,this._bundles=null,this._renderLists=null,this._renderContexts=null,this._textures=null,this._background=null,this._quad=new QM(new yx),this._quad.material.type="Renderer_output",this._currentRenderContext=null,this._opaqueSort=null,this._transparentSort=null,this._frameBufferTarget=null;const a=!0===this.alpha?0:1;this._clearColor=new cE(0,0,0,a),this._clearDepth=1,this._clearStencil=0,this._renderTarget=null,this._activeCubeFace=0,this._activeMipmapLevel=0,this._mrt=null,this._renderObjectFunction=null,this._currentRenderObjectFunction=null,this._currentRenderBundle=null,this._handleObjectFunction=this._renderObjectDirect,this._initialized=!1,this._initPromise=null,this._compilationPromises=null,this.transparent=!0,this.opaque=!0,this.shadowMap={enabled:!1,type:1},this.xr={enabled:!1},this.debug={checkShaderErrors:!0,onShaderError:null,getShaderAsync:async(e,t,s)=>{await this.compileAsync(e,t);const i=this._renderLists.get(e,t),r=this._renderContexts.get(e,t,this._renderTarget),n=e.overrideMaterial||s.material,o=this._objects.get(s,n,e,t,i.lightsNode,r),{fragmentShader:a,vertexShader:h}=o.getNodeBuilderState();return{fragmentShader:a,vertexShader:h}}}}async init(){if(this._initialized)throw new Error("Renderer: Backend has already been initialized.");return null!==this._initPromise||(this._initPromise=new Promise((async(e,t)=>{let s=this.backend;try{await s.init(this)}catch(e){if(null===this._getFallback)return void t(e);try{this.backend=s=this._getFallback(e),await s.init(this)}catch(e){return void t(e)}}this._nodes=new lI(this,s),this._animation=new Rw(this._nodes,this.info),this._attributes=new Dw(s),this._background=new oI(this,this._nodes),this._geometries=new Ww(this._attributes,this.info),this._textures=new uE(this,s,this.info),this._pipelines=new Jw(s,this._nodes),this._bindings=new Zw(s,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new Fw(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new rE,this._bundles=new cI,this._renderContexts=new hE,this._initialized=!0,e()}))),this._initPromise}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,s=null){!1===this._initialized&&await this.init();const i=this._nodes.nodeFrame,r=i.renderId,n=this._currentRenderContext,o=this._currentRenderObjectFunction,a=this._compilationPromises,h=!0===e.isScene?e:pI;null===s&&(s=e);const l=this._renderTarget,u=this._renderContexts.get(s,t,l),c=this._activeMipmapLevel,d=[];this._currentRenderContext=u,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=d,i.renderId++,i.update(),u.depth=this.depth,u.stencil=this.stencil,u.clippingContext||(u.clippingContext=new Bw),u.clippingContext.updateGlobal(this,t),h.onBeforeRender(this,e,t,l);const p=this._renderLists.get(e,t);if(p.begin(),this._projectObject(e,t,0,p),s!==e&&s.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&p.pushLight(e)})),p.finish(),null!==l){this._textures.updateRenderTarget(l,c);const e=this._textures.get(l);u.textures=e.textures,u.depthTexture=e.depthTexture}else u.textures=null,u.depthTexture=null;this._nodes.updateScene(h),this._background.update(h,p,u);const m=p.opaque,g=p.transparent,f=p.lightsNode;!0===this.opaque&&m.length>0&&this._renderObjects(m,t,h,f),!0===this.transparent&&g.length>0&&this._renderObjects(g,t,h,f),i.renderId=r,this._currentRenderContext=n,this._currentRenderObjectFunction=o,this._compilationPromises=a,this._handleObjectFunction=this._renderObjectDirect,await Promise.all(d)}async renderAsync(e,t){!1===this._initialized&&await this.init();const s=this._renderScene(e,t);await this.backend.resolveTimestampAsync(s,"render")}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}_renderBundle(e,t,s){const{object:i,camera:r,renderList:n}=e,o=this._currentRenderContext,a=this.backend.get(o),h=this._bundles.get(i,r),l=this.backend.get(h);void 0===l.renderContexts&&(l.renderContexts=new Set);const u=!1===l.renderContexts.has(o)||!0===i.needsUpdate;if(l.renderContexts.add(o),u){if(void 0===a.renderObjects||!0===i.needsUpdate){const e=this._nodes.nodeFrame;a.renderObjects=[],a.renderBundles=[],a.scene=t,a.camera=r,a.renderId=e.renderId,a.registerBundlesPhase=!0}this._currentRenderBundle=h;const e=n.opaque;e.length>0&&this._renderObjects(e,r,t,s),this._currentRenderBundle=null,i.needsUpdate=!1}else{const e=this._currentRenderContext,t=this.backend.get(e);for(let e=0,s=t.renderObjects.length;e>=c,p.viewportValue.height>>=c,p.viewportValue.minDepth=x,p.viewportValue.maxDepth=b,p.viewport=!1===p.viewportValue.equals(gI),p.scissorValue.copy(f).multiplyScalar(y).floor(),p.scissor=this._scissorTest&&!1===p.scissorValue.equals(gI),p.scissorValue.width>>=c,p.scissorValue.height>>=c,p.clippingContext||(p.clippingContext=new Bw),p.clippingContext.updateGlobal(this,t),h.onBeforeRender(this,e,t,d),yI.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),fI.setFromProjectionMatrix(yI,m);const v=this._renderLists.get(e,t);if(v.begin(),this._projectObject(e,t,0,v),v.finish(),!0===this.sortObjects&&v.sort(this._opaqueSort,this._transparentSort),null!==d){this._textures.updateRenderTarget(d,c);const e=this._textures.get(d);p.textures=e.textures,p.depthTexture=e.depthTexture,p.width=e.width,p.height=e.height,p.renderTarget=d,p.depth=d.depthBuffer,p.stencil=d.stencilBuffer}else p.textures=null,p.depthTexture=null,p.width=this.domElement.width,p.height=this.domElement.height,p.depth=this.depth,p.stencil=this.stencil;p.width>>=c,p.height>>=c,p.activeCubeFace=u,p.activeMipmapLevel=c,p.occlusionQueryCount=v.occlusionQueryCount,this._nodes.updateScene(h),this._background.update(h,v,p),this.backend.beginRender(p);const T=v.opaque,_=v.transparent,w=v.bundles,S=v.lightsNode;if(w.length>0&&this._renderBundles(w,h,S),!0===this.opaque&&T.length>0&&this._renderObjects(T,t,h,S),!0===this.transparent&&_.length>0&&this._renderObjects(_,t,h,S),this.backend.finishRender(p),r.renderId=n,this._currentRenderContext=o,this._currentRenderObjectFunction=a,null!==i){this.setRenderTarget(l,u,c);const e=this._quad;this._nodes.hasOutputChange(d.texture)&&(e.material.fragmentNode=this._nodes.getOutputNode(d.texture),e.material.needsUpdate=!0),this._renderScene(e,e.camera,!1)}return h.onAfterRender(this,e,t,d),p}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){!1===this._initialized&&await this.init(),this._animation.setAnimationLoop(e)}async getArrayBufferAsync(e){return await this.backend.getArrayBufferAsync(e)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio=e,this.setSize(this._width,this._height,!1)}setDrawingBufferSize(e,t,s){this._width=e,this._height=t,this._pixelRatio=s,this.domElement.width=Math.floor(e*s),this.domElement.height=Math.floor(t*s),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize()}setSize(e,t,s=!0){this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),!0===s&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize()}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){const t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,s,i){const r=this._scissor;e.isVector4?r.copy(e):r.set(e,t,s,i)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e,this.backend.setScissorTest(e)}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,s,i,r=0,n=1){const o=this._viewport;e.isVector4?o.copy(e):o.set(e,t,s,i),o.minDepth=r,o.maxDepth=n}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,s=!0){if(!1===this._initialized)return console.warn("THREE.Renderer: .clear() called before the backend is initialized. Try using .clearAsync() instead."),this.clearAsync(e,t,s);const i=this._renderTarget||this._getFrameBufferTarget();let r=null;if(null!==i&&(this._textures.updateRenderTarget(i),r=this._textures.get(i)),this.backend.clear(e,t,s,r),null!==i&&null===this._renderTarget){const e=this._quad;this._nodes.hasOutputChange(i.texture)&&(e.material.fragmentNode=this._nodes.getOutputNode(i.texture),e.material.needsUpdate=!0),this._renderScene(e,e.camera,!1)}}clearColor(){return this.clear(!0,!1,!1)}clearDepth(){return this.clear(!1,!0,!1)}clearStencil(){return this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,s=!0){!1===this._initialized&&await this.init(),this.clear(e,t,s)}clearColorAsync(){return this.clearAsync(!0,!1,!1)}clearDepthAsync(){return this.clearAsync(!1,!0,!1)}clearStencilAsync(){return this.clearAsync(!1,!1,!0)}get currentColorSpace(){const e=this._renderTarget;if(null!==e){const t=e.texture;return(Array.isArray(t)?t[0]:t).colorSpace}return this.outputColorSpace}dispose(){this.info.dispose(),this._animation.dispose(),this._objects.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,s=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=s}getRenderTarget(){return this._renderTarget}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}async computeAsync(e){!1===this._initialized&&await this.init();const t=this._nodes.nodeFrame,s=t.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,t.renderId=this.info.calls;const i=this.backend,r=this._pipelines,n=this._bindings,o=this._nodes,a=Array.isArray(e)?e:[e];if(void 0===a[0]||!0!==a[0].isComputeNode)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");i.beginCompute(e);for(const t of a){if(!1===r.has(t)){const e=()=>{t.removeEventListener("dispose",e),r.delete(t),n.delete(t),o.delete(t)};t.addEventListener("dispose",e),t.onInit({renderer:this})}o.updateForCompute(t),n.updateForCompute(t);const s=n.getForCompute(t),a=r.getForCompute(t,s);i.compute(e,t,s,a)}i.finishCompute(e),await this.backend.resolveTimestampAsync(e,"compute"),t.renderId=s}async hasFeatureAsync(e){return!1===this._initialized&&await this.init(),this.backend.hasFeature(e)}hasFeature(e){return!1===this._initialized?(console.warn("THREE.Renderer: .hasFeature() called before the backend is initialized. Try using .hasFeatureAsync() instead."),!1):this.backend.hasFeature(e)}copyFramebufferToTexture(e){const t=this._currentRenderContext;this._textures.updateTexture(e),this.backend.copyFramebufferToTexture(e,t)}copyTextureToTexture(e,t,s=null,i=null,r=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,s,i,r)}readRenderTargetPixelsAsync(e,t,s,i,r,n=0){return this.backend.copyTextureToBuffer(e.textures[n],t,s,i,r)}_projectObject(e,t,s,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)s=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)i.pushLight(e);else if(e.isSprite){if(!e.frustumCulled||fI.intersectsSprite(e)){!0===this.sortObjects&&xI.setFromMatrixPosition(e.matrixWorld).applyMatrix4(yI);const t=e.geometry,r=e.material;r.visible&&i.push(e,t,r,s,xI.z,null)}}else if(e.isLineLoop)console.error("THREE.Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||fI.intersectsObject(e))){const t=e.geometry,r=e.material;if(!0===this.sortObjects&&(null===t.boundingSphere&&t.computeBoundingSphere(),xI.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(yI)),Array.isArray(r)){const n=t.groups;for(let o=0,a=n.length;o0?i:"";t=`${e.name} {\n\t${s} ${r.name}[${n}];\n};\n`}else{t=`${this.getVectorType(r.type)} ${this.getPropertyName(r,e)};`,n=!0}const o=r.node.precision;if(null!==o&&(t=LI[o]+" "+t),n){t="\t"+t;const e=r.groupNode.name;(i[e]||(i[e]=[])).push(t)}else t="uniform "+t,s.push(t)}let r="";for(const t in i){const s=i[t];r+=this._getGLSLUniformStruct(e+"_"+t,s.join("\n"))+"\n"}return r+=s.join("\n"),r}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==Ee){let s=e;e.isInterleavedBufferAttribute&&(s=e.data);const i=s.array;!1==(i instanceof Uint32Array||i instanceof Int32Array)&&(t=t.slice(1))}return t}getAttributes(e){let t="";if("vertex"===e||"compute"===e){const e=this.getAttributesArray();let s=0;for(const i of e)t+=`layout( location = ${s++} ) in ${i.type} ${i.name};\n`}return t}getStructMembers(e){const t=[],s=e.getMemberTypes();for(let e=0;ee*t),1)}u`}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":null}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,s=this.shaderStage){const i=this.extensions[s]||(this.extensions[s]=new Map);!1===i.has(e)&&i.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if("vertex"===e){const t=this.renderer.backend.extensions;this.object.isBatchedMesh&&t.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const s=this.extensions[e];if(void 0!==s)for(const{name:e,behavior:i}of s.values())t.push(`#extension ${e} : ${i}`);return t.join("\n")}isAvailable(e){let t=OI[e];if(void 0===t){if("float32Filterable"===e){const e=this.renderer.backend.extensions;e.has("OES_texture_float_linear")?(e.get("OES_texture_float_linear"),t=!0):t=!1}OI[e]=t}return t}isFlipY(){return!0}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let s=0;s0&&(s+="\n"),s+=`\t// flow -> ${n}\n\t`),s+=`${i.code}\n\t`,e===r&&"compute"!==t&&(s+="// result\n\t","vertex"===t?(s+="gl_Position = ",s+=`${i.result};`):"fragment"===t&&(e.outputNode.isOutputStructNode||(s+="fragColor = ",s+=`${i.result};`)))}const n=e[t];n.extensions=this.getExtensions(t),n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.vars=this.getVars(t),n.structs=this.getStructs(t),n.codes=this.getCodes(t),n.transforms=this.getTransforms(t),n.flow=s}null!==this.material?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,s,i=null){const r=super.getUniformFromNode(e,t,s,i),n=this.getDataFromNode(e,s,this.globalCache);let o=n.uniformGPU;if(void 0===o){const i=e.groupNode,a=i.name,h=this.getBindGroupArray(a,s);if("texture"===t)o=new PI(r.name,r.node,i),h.push(o);else if("cubeTexture"===t)o=new FI(r.name,r.node,i),h.push(o);else if("texture3D"===t)o=new zI(r.name,r.node,i),h.push(o);else if("buffer"===t){e.name=`NodeBuffer_${e.id}`,r.name=`buffer${e.id}`;const t=new NI(e,i);t.name=e.name,h.push(t),o=t}else{const e=this.uniformGroups[s]||(this.uniformGroups[s]={});let n=e[a];void 0===n&&(n=new EI(s+"_"+a,i),e[a]=n,h.push(n)),o=this.getNodeUniform(r,t),n.addUniform(o)}n.uniformGPU=o}return r}}let kI=null,GI=null,WI=null;class HI{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null}async init(e){this.renderer=e}begin(){}finish(){}draw(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}createRenderPipeline(){}createComputePipeline(){}destroyPipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}createDefaultTexture(){}createTexture(){}copyTextureToBuffer(){}createAttribute(){}createIndexAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}resolveTimestampAsync(){}hasFeatureAsync(){}hasFeature(){}getInstanceCount(e){const{object:t,geometry:s}=e;return s.isInstancedBufferGeometry?s.instanceCount:t.count>1?t.count:1}getDrawingBufferSize(){return kI=kI||new Qs,this.renderer.getDrawingBufferSize(kI)}getScissor(){return GI=GI||new _i,this.renderer.getScissor(GI)}setScissorTest(){}getClearColor(){const e=this.renderer;return WI=WI||new cE,e.getClearColor(WI),WI.getRGB(WI,this.renderer.currentColorSpace),WI}getDomElement(){let t=this.domElement;return null===t&&(t=void 0!==this.parameters.canvas?this.parameters.canvas:ni(),"setAttribute"in t&&t.setAttribute("data-engine",`three.js r${e} webgpu`),this.domElement=t),t}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}}let jI=0;class qI{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[1^this.activeBufferIndex]}switchBuffers(){this.activeBufferIndex^=1}}class $I{constructor(e){this.backend=e}createAttribute(e,t){const s=this.backend,{gl:i}=s,r=e.array,n=e.usage||i.STATIC_DRAW,o=e.isInterleavedBufferAttribute?e.data:e,a=s.get(o);let h,l=a.bufferGPU;if(void 0===l&&(l=this._createBuffer(i,t,r,n),a.bufferGPU=l,a.bufferType=t,a.version=o.version),r instanceof Float32Array)h=i.FLOAT;else if(r instanceof Uint16Array)h=e.isFloat16BufferAttribute?i.HALF_FLOAT:i.UNSIGNED_SHORT;else if(r instanceof Int16Array)h=i.SHORT;else if(r instanceof Uint32Array)h=i.UNSIGNED_INT;else if(r instanceof Int32Array)h=i.INT;else if(r instanceof Int8Array)h=i.BYTE;else if(r instanceof Uint8Array)h=i.UNSIGNED_BYTE;else{if(!(r instanceof Uint8ClampedArray))throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+r);h=i.UNSIGNED_BYTE}let u={bufferGPU:l,bufferType:t,type:h,byteLength:r.byteLength,bytesPerElement:r.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:h===i.INT||h===i.UNSIGNED_INT||e.gpuType===Ee,id:jI++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const e=this._createBuffer(i,t,r,n);u=new qI(u,e)}s.set(e,u)}updateAttribute(e){const t=this.backend,{gl:s}=t,i=e.array,r=e.isInterleavedBufferAttribute?e.data:e,n=t.get(r),o=n.bufferType,a=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(s.bindBuffer(o,n.bufferGPU),0===a.length)s.bufferSubData(o,0,i);else{for(let e=0,t=a.length;e{!function r(){const n=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(n===e.WAIT_FAILED)return e.deleteSync(t),void i();n!==e.TIMEOUT_EXPIRED?(e.deleteSync(t),s()):requestAnimationFrame(r)}()}))}}let QI,eP,tP,sP=!1;class iP{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},!1===sP&&(this._init(this.gl),sP=!0)}_init(e){QI={[pe]:e.REPEAT,[me]:e.CLAMP_TO_EDGE,[ge]:e.MIRRORED_REPEAT},eP={[fe]:e.NEAREST,[ye]:e.NEAREST_MIPMAP_NEAREST,[be]:e.NEAREST_MIPMAP_LINEAR,[Te]:e.LINEAR,[_e]:e.LINEAR_MIPMAP_NEAREST,[Se]:e.LINEAR_MIPMAP_LINEAR},tP={512:e.NEVER,519:e.ALWAYS,[Ts]:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL}}filterFallback(e){const{gl:t}=this;return e===fe||e===ye||e===be?t.NEAREST:t.LINEAR}getGLTextureType(e){const{gl:t}=this;let s;return s=!0===e.isCubeTexture?t.TEXTURE_CUBE_MAP:!0===e.isDataArrayTexture||!0===e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:!0===e.isData3DTexture?t.TEXTURE_3D:t.TEXTURE_2D,s}getInternalFormat(e,t,s,i,r=!1){const{gl:n,extensions:o}=this;if(null!==e){if(void 0!==n[e])return n[e];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}let a=t;return t===n.RED&&(s===n.FLOAT&&(a=n.R32F),s===n.HALF_FLOAT&&(a=n.R16F),s===n.UNSIGNED_BYTE&&(a=n.R8),s===n.UNSIGNED_SHORT&&(a=n.R16),s===n.UNSIGNED_INT&&(a=n.R32UI),s===n.BYTE&&(a=n.R8I),s===n.SHORT&&(a=n.R16I),s===n.INT&&(a=n.R32I)),t===n.RED_INTEGER&&(s===n.UNSIGNED_BYTE&&(a=n.R8UI),s===n.UNSIGNED_SHORT&&(a=n.R16UI),s===n.UNSIGNED_INT&&(a=n.R32UI),s===n.BYTE&&(a=n.R8I),s===n.SHORT&&(a=n.R16I),s===n.INT&&(a=n.R32I)),t===n.RG&&(s===n.FLOAT&&(a=n.RG32F),s===n.HALF_FLOAT&&(a=n.RG16F),s===n.UNSIGNED_BYTE&&(a=n.RG8),s===n.UNSIGNED_SHORT&&(a=n.RG16),s===n.UNSIGNED_INT&&(a=n.RG32UI),s===n.BYTE&&(a=n.RG8I),s===n.SHORT&&(a=n.RG16I),s===n.INT&&(a=n.RG32I)),t===n.RG_INTEGER&&(s===n.UNSIGNED_BYTE&&(a=n.RG8UI),s===n.UNSIGNED_SHORT&&(a=n.RG16UI),s===n.UNSIGNED_INT&&(a=n.RG32UI),s===n.BYTE&&(a=n.RG8I),s===n.SHORT&&(a=n.RG16I),s===n.INT&&(a=n.RG32I)),t===n.RGB&&(s===n.FLOAT&&(a=n.RGB32F),s===n.HALF_FLOAT&&(a=n.RGB16F),s===n.UNSIGNED_BYTE&&(a=n.RGB8),s===n.UNSIGNED_SHORT&&(a=n.RGB16),s===n.UNSIGNED_INT&&(a=n.RGB32UI),s===n.BYTE&&(a=n.RGB8I),s===n.SHORT&&(a=n.RGB16I),s===n.INT&&(a=n.RGB32I),s===n.UNSIGNED_BYTE&&(a=i===Jt&&!1===r?n.SRGB8:n.RGB8),s===n.UNSIGNED_SHORT_5_6_5&&(a=n.RGB565),s===n.UNSIGNED_SHORT_5_5_5_1&&(a=n.RGB5_A1),s===n.UNSIGNED_SHORT_4_4_4_4&&(a=n.RGB4),s===n.UNSIGNED_INT_5_9_9_9_REV&&(a=n.RGB9_E5)),t===n.RGB_INTEGER&&(s===n.UNSIGNED_BYTE&&(a=n.RGB8UI),s===n.UNSIGNED_SHORT&&(a=n.RGB16UI),s===n.UNSIGNED_INT&&(a=n.RGB32UI),s===n.BYTE&&(a=n.RGB8I),s===n.SHORT&&(a=n.RGB16I),s===n.INT&&(a=n.RGB32I)),t===n.RGBA&&(s===n.FLOAT&&(a=n.RGBA32F),s===n.HALF_FLOAT&&(a=n.RGBA16F),s===n.UNSIGNED_BYTE&&(a=n.RGBA8),s===n.UNSIGNED_SHORT&&(a=n.RGBA16),s===n.UNSIGNED_INT&&(a=n.RGBA32UI),s===n.BYTE&&(a=n.RGBA8I),s===n.SHORT&&(a=n.RGBA16I),s===n.INT&&(a=n.RGBA32I),s===n.UNSIGNED_BYTE&&(a=i===Jt&&!1===r?n.SRGB8_ALPHA8:n.RGBA8),s===n.UNSIGNED_SHORT_4_4_4_4&&(a=n.RGBA4),s===n.UNSIGNED_SHORT_5_5_5_1&&(a=n.RGB5_A1)),t===n.RGBA_INTEGER&&(s===n.UNSIGNED_BYTE&&(a=n.RGBA8UI),s===n.UNSIGNED_SHORT&&(a=n.RGBA16UI),s===n.UNSIGNED_INT&&(a=n.RGBA32UI),s===n.BYTE&&(a=n.RGBA8I),s===n.SHORT&&(a=n.RGBA16I),s===n.INT&&(a=n.RGBA32I)),t===n.DEPTH_COMPONENT&&(s===n.UNSIGNED_INT&&(a=n.DEPTH24_STENCIL8),s===n.FLOAT&&(a=n.DEPTH_COMPONENT32F)),t===n.DEPTH_STENCIL&&s===n.UNSIGNED_INT_24_8&&(a=n.DEPTH24_STENCIL8),a!==n.R16F&&a!==n.R32F&&a!==n.RG16F&&a!==n.RG32F&&a!==n.RGBA16F&&a!==n.RGBA32F||o.get("EXT_color_buffer_float"),a}setTextureParameters(e,t){const{gl:s,extensions:i,backend:r}=this;s.texParameteri(e,s.TEXTURE_WRAP_S,QI[t.wrapS]),s.texParameteri(e,s.TEXTURE_WRAP_T,QI[t.wrapT]),e!==s.TEXTURE_3D&&e!==s.TEXTURE_2D_ARRAY||s.texParameteri(e,s.TEXTURE_WRAP_R,QI[t.wrapR]),s.texParameteri(e,s.TEXTURE_MAG_FILTER,eP[t.magFilter]);const n=void 0!==t.mipmaps&&t.mipmaps.length>0,o=t.minFilter===Te&&n?Se:t.minFilter;if(s.texParameteri(e,s.TEXTURE_MIN_FILTER,eP[o]),t.compareFunction&&(s.texParameteri(e,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(e,s.TEXTURE_COMPARE_FUNC,tP[t.compareFunction])),!0===i.has("EXT_texture_filter_anisotropic")){if(t.magFilter===fe)return;if(t.minFilter!==be&&t.minFilter!==Se)return;if(t.type===Ie&&!1===i.has("OES_texture_float_linear"))return;if(t.anisotropy>1){const n=i.get("EXT_texture_filter_anisotropic");s.texParameterf(e,n.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,r.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:s,defaultTextures:i}=this,r=this.getGLTextureType(e);let n=i[r];void 0===n&&(n=t.createTexture(),s.state.bindTexture(r,n),t.texParameteri(r,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(r,t.TEXTURE_MAG_FILTER,t.NEAREST),i[r]=n),s.set(e,{textureGPU:n,glTextureType:r,isDefault:!0})}createTexture(e,t){const{gl:s,backend:i}=this,{levels:r,width:n,height:o,depth:a}=t,h=i.utils.convert(e.format,e.colorSpace),l=i.utils.convert(e.type),u=this.getInternalFormat(e.internalFormat,h,l,e.colorSpace,e.isVideoTexture),c=s.createTexture(),d=this.getGLTextureType(e);i.state.bindTexture(d,c),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,e.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,e.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,s.NONE),this.setTextureParameters(d,e),e.isDataArrayTexture||e.isCompressedArrayTexture?s.texStorage3D(s.TEXTURE_2D_ARRAY,r,u,n,o,a):e.isData3DTexture?s.texStorage3D(s.TEXTURE_3D,r,u,n,o,a):e.isVideoTexture||s.texStorage2D(d,r,u,n,o),i.set(e,{textureGPU:c,glTextureType:d,glFormat:h,glType:l,glInternalFormat:u})}copyBufferToTexture(e,t){const{gl:s,backend:i}=this,{textureGPU:r,glTextureType:n,glFormat:o,glType:a}=i.get(t),{width:h,height:l}=t.source.data;s.bindBuffer(s.PIXEL_UNPACK_BUFFER,e),i.state.bindTexture(n,r),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,!1),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),s.texSubImage2D(n,0,0,0,h,l,o,a,0),s.bindBuffer(s.PIXEL_UNPACK_BUFFER,null),i.state.unbindTexture()}updateTexture(e,t){const{gl:s}=this,{width:i,height:r}=t,{textureGPU:n,glTextureType:o,glFormat:a,glType:h,glInternalFormat:l}=this.backend.get(e);if(e.isRenderTargetTexture||void 0===n)return;const u=e=>e.isDataTexture?e.image.data:e instanceof ImageBitmap||e instanceof OffscreenCanvas||e instanceof HTMLImageElement||e instanceof HTMLCanvasElement?e:e.data;if(this.backend.state.bindTexture(o,n),e.isCompressedTexture){const i=e.mipmaps,r=t.image;for(let t=0;t0){let a,h;!0===e.isDepthTexture?(a=s.DEPTH_BUFFER_BIT,h=s.DEPTH_ATTACHMENT,t.stencil&&(a|=s.STENCIL_BUFFER_BIT)):(a=s.COLOR_BUFFER_BIT,h=s.COLOR_ATTACHMENT0);const l=s.createFramebuffer();i.bindFramebuffer(s.DRAW_FRAMEBUFFER,l),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,h,s.TEXTURE_2D,r,0),s.blitFramebuffer(0,0,n,o,0,0,n,o,a,s.NEAREST),s.deleteFramebuffer(l)}else i.bindTexture(s.TEXTURE_2D,r),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,0,0,n,o),i.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t){const{gl:s}=this,i=t.renderTarget,{samples:r,depthTexture:n,depthBuffer:o,stencilBuffer:a,width:h,height:l}=i;if(s.bindRenderbuffer(s.RENDERBUFFER,e),o&&!a){let t=s.DEPTH_COMPONENT24;r>0?(n&&n.isDepthTexture&&n.type===s.FLOAT&&(t=s.DEPTH_COMPONENT32F),s.renderbufferStorageMultisample(s.RENDERBUFFER,r,t,h,l)):s.renderbufferStorage(s.RENDERBUFFER,t,h,l),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,e)}else o&&a&&(r>0?s.renderbufferStorageMultisample(s.RENDERBUFFER,r,s.DEPTH24_STENCIL8,h,l):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,h,l),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,e))}async copyTextureToBuffer(e,t,s,i,r){const{backend:n,gl:o}=this,{textureGPU:a,glFormat:h,glType:l}=this.backend.get(e),u=o.createFramebuffer();o.bindFramebuffer(o.READ_FRAMEBUFFER,u),o.framebufferTexture2D(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,a,0);const c=this._getTypedArrayType(l),d=i*r*this._getBytesPerTexel(h),p=o.createBuffer();o.bindBuffer(o.PIXEL_PACK_BUFFER,p),o.bufferData(o.PIXEL_PACK_BUFFER,d,o.STREAM_READ),o.readPixels(t,s,i,r,h,l,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),await n.utils._clientWaitAsync();const m=new c(d/c.BYTES_PER_ELEMENT);return o.bindBuffer(o.PIXEL_PACK_BUFFER,p),o.getBufferSubData(o.PIXEL_PACK_BUFFER,0,m),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),o.deleteFramebuffer(u),m}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_5_5_1)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_6_5)return Uint16Array;if(e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.FLOAT)return Float32Array;throw new Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e){const{gl:t}=this;return e===t.RGBA?4:e===t.RGB?3:e===t.ALPHA?1:void 0}}class rP{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return void 0===t&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class nP{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(null!==this.maxAnisotropy)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(!0===t.has("EXT_texture_filter_anisotropic")){const s=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}const oP={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBKIT_WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-bc",EXT_texture_compression_bptc:"texture-compression-bptc",EXT_disjoint_timer_query_webgl2:"timestamp-query"};class aP{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:s,mode:i,object:r,type:n,info:o,index:a}=this;0!==a?s.drawElements(i,t,n,e):s.drawArrays(i,e,t),o.update(r,t,i,1)}renderInstances(e,t,s){const{gl:i,mode:r,type:n,index:o,object:a,info:h}=this;0!==s&&(0!==o?i.drawElementsInstanced(r,t,n,e,s):i.drawArraysInstanced(r,e,t,s),h.update(a,t,r,s))}renderMultiDraw(e,t,s){const{extensions:i,mode:r,object:n,info:o}=this;if(0===s)return;const a=i.get("WEBGL_multi_draw");if(null===a)for(let i=0;i0)){const e=t.queryQueue.shift();this.initTimestampQuery(e)}}async resolveTimestampAsync(e,t="render"){if(!this.disjoint||!this.trackTimestamp)return;const s=this.get(e);s.gpuQueries||(s.gpuQueries=[]);for(let e=0;e0&&(s.currentOcclusionQueries=s.occlusionQueries,s.currentOcclusionQueryObjects=s.occlusionQueryObjects,s.lastOcclusionObject=null,s.occlusionQueries=new Array(i),s.occlusionQueryObjects=new Array(i),s.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:s}=this,i=this.get(e),r=i.previousContext,n=e.occlusionQueryCount;n>0&&(n>i.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const o=e.textures;if(null!==o)for(let e=0;e0){const r=i.framebuffers[e.getCacheKey()],n=t.COLOR_BUFFER_BIT,o=i.msaaFrameBuffer,a=e.textures;s.bindFramebuffer(t.READ_FRAMEBUFFER,o),s.bindFramebuffer(t.DRAW_FRAMEBUFFER,r);for(let s=0;s{let o=0;for(let t=0;t0&&e.add(i[t]),s[t]=null,r.deleteQuery(n),o++))}o1?f.renderInstances(m,y,x):f.render(m,y),o.bindVertexArray(null)}needsRenderUpdate(){return!1}getRenderCacheKey(){return""}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}copyTextureToBuffer(e,t,s,i,r){return this.textureUtils.copyTextureToBuffer(e,t,s,i,r)}createSampler(){}destroySampler(){}createNodeBuilder(e,t){return new DI(e,t)}createProgram(e){const t=this.gl,{stage:s,code:i}=e,r="fragment"===s?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);t.shaderSource(r,i),t.compileShader(r),this.set(e,{shaderGPU:r})}destroyProgram(){console.warn("Abstract class.")}createRenderPipeline(e,t){const s=this.gl,i=e.pipeline,{fragmentProgram:r,vertexProgram:n}=i,o=s.createProgram(),a=this.get(r).shaderGPU,h=this.get(n).shaderGPU;if(s.attachShader(o,a),s.attachShader(o,h),s.linkProgram(o),this.set(i,{programGPU:o,fragmentShader:a,vertexShader:h}),null!==t&&this.parallel){const r=new Promise((t=>{const r=this.parallel,n=()=>{s.getProgramParameter(o,r.COMPLETION_STATUS_KHR)?(this._completeCompile(e,i),t()):requestAnimationFrame(n)};n()}));t.push(r)}else this._completeCompile(e,i)}_handleSource(e,t){const s=e.split("\n"),i=[],r=Math.max(t-6,0),n=Math.min(t+6,s.length);for(let e=r;e":" "} ${r}: ${s[e]}`)}return i.join("\n")}_getShaderErrors(e,t,s){const i=e.getShaderParameter(t,e.COMPILE_STATUS),r=e.getShaderInfoLog(t).trim();if(i&&""===r)return"";const n=/ERROR: 0:(\d+)/.exec(r);if(n){const i=parseInt(n[1]);return s.toUpperCase()+"\n\n"+r+"\n\n"+this._handleSource(e.getShaderSource(t),i)}return r}_logProgramError(e,t,s){if(this.renderer.debug.checkShaderErrors){const i=this.gl,r=i.getProgramInfoLog(e).trim();if(!1===i.getProgramParameter(e,i.LINK_STATUS))if("function"==typeof this.renderer.debug.onShaderError)this.renderer.debug.onShaderError(i,e,s,t);else{const n=this._getShaderErrors(i,s,"vertex"),o=this._getShaderErrors(i,t,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(e,i.VALIDATE_STATUS)+"\n\nProgram Info Log: "+r+"\n"+n+"\n"+o)}else""!==r&&console.warn("THREE.WebGLProgram: Program Info Log:",r)}}_completeCompile(e,t){const{state:s,gl:i}=this,r=this.get(t),{programGPU:n,fragmentShader:o,vertexShader:a}=r;!1===i.getProgramParameter(n,i.LINK_STATUS)&&this._logProgramError(n,o,a),s.useProgram(n);const h=e.getBindings();this._setupBindings(h,n),this.set(t,{programGPU:n})}createComputePipeline(e,t){const{state:s,gl:i}=this,r={stage:"fragment",code:"#version 300 es\nprecision highp float;\nvoid main() {}"};this.createProgram(r);const{computeProgram:n}=e,o=i.createProgram(),a=this.get(r).shaderGPU,h=this.get(n).shaderGPU,l=n.transforms,u=[],c=[];for(let e=0;eoP[t]===e)),s=this.extensions;for(let e=0;e0){if(void 0===u){const i=[];u=t.createFramebuffer(),s.bindFramebuffer(t.FRAMEBUFFER,u);const r=[],l=e.textures;for(let s=0;s,\n\t@location( 0 ) vTex : vec2\n};\n\n@vertex\nfn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct {\n\n\tvar Varys : VarysStruct;\n\n\tvar pos = array< vec2, 4 >(\n\t\tvec2( -1.0, 1.0 ),\n\t\tvec2( 1.0, 1.0 ),\n\t\tvec2( -1.0, -1.0 ),\n\t\tvec2( 1.0, -1.0 )\n\t);\n\n\tvar tex = array< vec2, 4 >(\n\t\tvec2( 0.0, 0.0 ),\n\t\tvec2( 1.0, 0.0 ),\n\t\tvec2( 0.0, 1.0 ),\n\t\tvec2( 1.0, 1.0 )\n\t);\n\n\tVarys.vTex = tex[ vertexIndex ];\n\tVarys.Position = vec4( pos[ vertexIndex ], 0.0, 1.0 );\n\n\treturn Varys;\n\n}\n"}),this.mipmapFragmentShaderModule=e.createShaderModule({label:"mipmapFragment",code:"\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img : texture_2d;\n\n@fragment\nfn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img, imgSampler, vTex );\n\n}\n"}),this.flipYFragmentShaderModule=e.createShaderModule({label:"flipYFragment",code:"\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img : texture_2d;\n\n@fragment\nfn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) );\n\n}\n"})}getTransferPipeline(e){let t=this.transferPipelines[e];return void 0===t&&(t=this.device.createRenderPipeline({label:`mipmap-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.mipmapFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:gA,stripIndexFormat:IA},layout:"auto"}),this.transferPipelines[e]=t),t}getFlipYPipeline(e){let t=this.flipYPipelines[e];return void 0===t&&(t=this.device.createRenderPipeline({label:`flipY-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.flipYFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:gA,stripIndexFormat:IA},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,s=0){const i=t.format,{width:r,height:n}=t.size,o=this.getTransferPipeline(i),a=this.getFlipYPipeline(i),h=this.device.createTexture({size:{width:r,height:n,depthOrArrayLayers:1},format:i,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),l=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:SN,baseArrayLayer:s}),u=h.createView({baseMipLevel:0,mipLevelCount:1,dimension:SN,baseArrayLayer:0}),c=this.device.createCommandEncoder({}),d=(e,t,s)=>{const i=e.getBindGroupLayout(0),r=this.device.createBindGroup({layout:i,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:t}]}),n=c.beginRenderPass({colorAttachments:[{view:s,loadOp:AA,storeOp:SA,clearValue:[0,0,0,0]}]});n.setPipeline(e),n.setBindGroup(0,r),n.draw(4,1,0,0),n.end()};d(o,l,u),d(a,u,l),this.device.queue.submit([c.finish()]),h.destroy()}generateMipmaps(e,t,s=0){const i=this.get(e);void 0===i.useCount&&(i.useCount=0,i.layers=[]);const r=i.layers[s]||this._mipmapCreateBundles(e,t,s),n=this.device.createCommandEncoder({});this._mipmapRunBundles(n,r),this.device.queue.submit([n.finish()]),0!==i.useCount&&(i.layers[s]=r),i.useCount++}_mipmapCreateBundles(e,t,s){const i=this.getTransferPipeline(t.format),r=i.getBindGroupLayout(0);let n=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:SN,baseArrayLayer:s});const o=[];for(let a=1;a1&&!e.isMultisampleRenderTargetTexture){const e=Object.assign({},p);e.label=e.label+"-msaa",e.sampleCount=u,i.msaaTexture=s.device.createTexture(e)}i.initialized=!0,i.textureDescriptorGPU=p}destroyTexture(e){const t=this.backend,s=t.get(e);s.texture.destroy(),void 0!==s.msaaTexture&&s.msaaTexture.destroy(),t.delete(e)}destroySampler(e){delete this.backend.get(e).sampler}generateMipmaps(e){const t=this.backend.get(e);if(e.isCubeTexture)for(let e=0;e<6;e++)this._generateMipmaps(t.texture,t.textureDescriptorGPU,e);else{const s=e.image.depth||1;for(let e=0;e1;for(let o=0;o]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,vP=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,TP={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2":"vec2","vec2":"ivec2","vec2":"uvec2","vec2":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3":"vec3","vec3":"ivec3","vec3":"uvec3","vec3":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4":"vec4","vec4":"ivec4","vec4":"uvec4","vec4":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2":"mat2",mat2x2f:"mat2","mat3x3":"mat3",mat3x3f:"mat3","mat4x4":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"};class _P extends YC{constructor(e){const{type:t,inputs:s,name:i,inputsCode:r,blockCode:n,outputType:o}=(e=>{const t=(e=e.trim()).match(bP);if(null!==t&&4===t.length){const s=t[2],i=[];let r=null;for(;null!==(r=vP.exec(s));)i.push({name:r[1],type:r[2]});const n=[];for(let e=0;e "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class wP extends XC{parseFunction(e){return new _P(e)}}const SP=self.GPUShaderStage,MP={vertex:SP?SP.VERTEX:1,fragment:SP?SP.FRAGMENT:2,compute:SP?SP.COMPUTE:4},AP={instance:!0,swizzleAssign:!1,storageBuffer:!0},NP={"^^":"tsl_xor"},RP={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3",vec2:"vec2",ivec2:"vec2",uvec2:"vec2",bvec2:"vec2",vec3:"vec3",ivec3:"vec3",uvec3:"vec3",bvec3:"vec3",vec4:"vec4",ivec4:"vec4",uvec4:"vec4",bvec4:"vec4",mat2:"mat2x2",imat2:"mat2x2",umat2:"mat2x2",bmat2:"mat2x2",mat3:"mat3x3",imat3:"mat3x3",umat3:"mat3x3",bmat3:"mat3x3",mat4:"mat4x4",imat4:"mat4x4",umat4:"mat4x4",bmat4:"mat4x4"},CP={tsl_xor:new aS("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new aS("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new aS("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new aS("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new aS("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new aS("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new aS("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new aS("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3 { return vec3( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new aS("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4 { return vec4( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping:new aS("\nfn tsl_repeatWrapping( uv : vec2, dimension : vec2 ) -> vec2 {\n\n\tlet uvScaled = vec2( uv * vec2( dimension ) );\n\n\treturn ( ( uvScaled % dimension ) + dimension ) % dimension;\n\n}\n"),biquadraticTexture:new aS("\nfn tsl_biquadraticTexture( map : texture_2d, coord : vec2f, level : i32 ) -> vec4f {\n\n\tlet res = vec2f( textureDimensions( map, level ) );\n\n\tlet uvScaled = coord * res;\n\tlet uvWrapping = ( ( uvScaled % res ) + res ) % res;\n\n\t// https://www.shadertoy.com/view/WtyXRy\n\n\tlet uv = uvWrapping - 0.5;\n\tlet iuv = floor( uv );\n\tlet f = fract( uv );\n\n\tlet rg1 = textureLoad( map, vec2i( iuv + vec2( 0.5, 0.5 ) ), level );\n\tlet rg2 = textureLoad( map, vec2i( iuv + vec2( 1.5, 0.5 ) ), level );\n\tlet rg3 = textureLoad( map, vec2i( iuv + vec2( 0.5, 1.5 ) ), level );\n\tlet rg4 = textureLoad( map, vec2i( iuv + vec2( 1.5, 1.5 ) ), level );\n\n\treturn mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );\n\n}\n")},EP={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast"};/Windows/g.test(navigator.userAgent)&&(CP.pow_float=new aS("fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }"),CP.pow_vec2=new aS("fn tsl_pow_vec2( a : vec2f, b : vec2f ) -> vec2f { return vec2f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ) ); }",[CP.pow_float]),CP.pow_vec3=new aS("fn tsl_pow_vec3( a : vec3f, b : vec3f ) -> vec3f { return vec3f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ) ); }",[CP.pow_float]),CP.pow_vec4=new aS("fn tsl_pow_vec4( a : vec4f, b : vec4f ) -> vec4f { return vec4f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ), tsl_pow_float( a.w, b.w ) ); }",[CP.pow_float]),EP.pow_float="tsl_pow_float",EP.pow_vec2="tsl_pow_vec2",EP.pow_vec3="tsl_pow_vec3",EP.pow_vec4="tsl_pow_vec4");class BP extends nM{constructor(e,t){super(e,t,new wP),this.uniformGroups={},this.builtins={},this.directives={}}needsColorSpaceToLinear(e){return!0===e.isVideoTexture&&e.colorSpace!==Yt}_generateTextureSample(e,t,s,i,r=this.shaderStage){return"fragment"===r?i?`textureSample( ${t}, ${t}_sampler, ${s}, ${i} )`:`textureSample( ${t}, ${t}_sampler, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,s):this.generateTextureLod(e,t,s,"0")}_generateVideoSample(e,t,s=this.shaderStage){if("fragment"===s)return`textureSampleBaseClampToEdge( ${e}, ${e}_sampler, vec2( ${t}.x, 1.0 - ${t}.y ) )`;console.error(`WebGPURenderer: THREE.VideoTexture does not support ${s} shader.`)}_generateTextureSampleLevel(e,t,s,i,r,n=this.shaderStage){return"fragment"===n&&!1===this.isUnfilterable(e)?`textureSampleLevel( ${t}, ${t}_sampler, ${s}, ${i} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,s,i):this.generateTextureLod(e,t,s,i)}generateFilteredTexture(e,t,s,i="0"){return this._include("biquadraticTexture"),`tsl_biquadraticTexture( ${t}, ${s}, i32( ${i} ) )`}generateTextureLod(e,t,s,i="0"){this._include("repeatWrapping");return`textureLoad( ${t}, tsl_repeatWrapping( ${s}, ${!0===e.isMultisampleRenderTargetTexture?`textureDimensions( ${t} )`:`textureDimensions( ${t}, 0 )`} ), i32( ${i} ) )`}generateTextureLoad(e,t,s,i,r="0u"){return i?`textureLoad( ${t}, ${s}, ${i}, ${r} )`:`textureLoad( ${t}, ${s}, ${r} )`}generateTextureStore(e,t,s,i){return`textureStore( ${t}, ${s}, ${i} )`}isUnfilterable(e){return"float"!==this.getComponentTypeFromTexture(e)||!this.isAvailable("float32Filterable")&&!0===e.isDataTexture&&e.type===Ie||!0===e.isMultisampleRenderTargetTexture}generateTexture(e,t,s,i,r=this.shaderStage){let n=null;return n=!0===e.isVideoTexture?this._generateVideoSample(t,s,r):this.isUnfilterable(e)?this.generateTextureLod(e,t,s,"0",i,r):this._generateTextureSample(e,t,s,i,r),n}generateTextureGrad(e,t,s,i,r,n=this.shaderStage){if("fragment"===n)return`textureSampleGrad( ${t}, ${t}_sampler, ${s}, ${i[0]}, ${i[1]} )`;console.error(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${n} shader.`)}generateTextureCompare(e,t,s,i,r,n=this.shaderStage){if("fragment"===n)return`textureSampleCompare( ${t}, ${t}_sampler, ${s}, ${i} )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${n} shader.`)}generateTextureLevel(e,t,s,i,r,n=this.shaderStage){let o=null;return o=!0===e.isVideoTexture?this._generateVideoSample(t,s,n):this._generateTextureSampleLevel(e,t,s,i,r,n),o}generateTextureBias(e,t,s,i,r,n=this.shaderStage){if("fragment"===n)return`textureSampleBias( ${t}, ${t}_sampler, ${s}, ${i} )`;console.error(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${n} shader.`)}getPropertyName(e,t=this.shaderStage){if(!0===e.isNodeVarying&&!0===e.needsInterpolation){if("vertex"===t)return`varyings.${e.name}`}else if(!0===e.isNodeUniform){const t=e.name,s=e.type;return"texture"===s||"cubeTexture"===s||"storageTexture"===s||"texture3D"===s?t:"buffer"===s||"storageBuffer"===s?`NodeBuffer_${e.id}.${t}`:e.groupNode.name+"."+t}return super.getPropertyName(e)}getOutputStructName(){return"output"}_getUniformGroupCount(e){return Object.keys(this.uniforms[e]).length}getFunctionOperator(e){const t=NP[e];return void 0!==t?(this._include(t),t):null}getStorageAccess(e){if(e.isStorageTextureNode)switch(e.access){case fN:return"read";case gN:return"write";default:return"read_write"}else switch(e.access){case pN:return"read_write";case mN:return"read";default:return"write"}}getUniformFromNode(e,t,s,i=null){const r=super.getUniformFromNode(e,t,s,i),n=this.getDataFromNode(e,s,this.globalCache);if(void 0===n.uniformGPU){let i;const o=e.groupNode,a=o.name,h=this.getBindGroupArray(a,s);if("texture"===t||"cubeTexture"===t||"storageTexture"===t||"texture3D"===t){let n=null;if("texture"===t||"storageTexture"===t?n=new PI(r.name,r.node,o,e.access?e.access:null):"cubeTexture"===t?n=new FI(r.name,r.node,o,e.access?e.access:null):"texture3D"===t&&(n=new zI(r.name,r.node,o,e.access?e.access:null)),n.store=!0===e.isStorageTextureNode,n.setVisibility(MP[s]),"fragment"===s&&!1===this.isUnfilterable(e.value)&&!1===n.store){const e=new uP(`${r.name}_sampler`,r.node,o);e.setVisibility(MP[s]),h.push(e,n),i=[e,n]}else h.push(n),i=[n]}else if("buffer"===t||"storageBuffer"===t){const r=new("storageBuffer"===t?pP:NI)(e,o);r.setVisibility(MP[s]),h.push(r),i=r}else{const e=this.uniformGroups[s]||(this.uniformGroups[s]={});let n=e[a];void 0===n&&(n=new EI(a,o),n.setVisibility(MP[s]),e[a]=n,h.push(n)),i=this.getNodeUniform(r,t),n.addUniform(i)}n.uniformGPU=i}return r}getBuiltin(e,t,s,i=this.shaderStage){const r=this.builtins[i]||(this.builtins[i]=new Map);return!1===r.has(e)&&r.set(e,{name:e,property:t,type:s}),t}getVertexIndex(){return"vertex"===this.shaderStage?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,s=this.flowShaderNode(e),i=[];for(const e of t.inputs)i.push(e.name+" : "+this.getType(e.type));let r=`fn ${t.name}( ${i.join(", ")} ) -> ${this.getType(t.type)} {\n${s.vars}\n${s.code}\n`;return s.result&&(r+=`\treturn ${s.result};\n`),r+="\n}\n",r}getInstanceIndex(){return"vertex"===this.shaderStage?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],s=this.directives[e];if(void 0!==s)for(const e of s)t.push(`enable ${e};`);return t.join("\n")}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}getBuiltins(e){const t=[],s=this.builtins[e];if(void 0!==s)for(const{name:e,property:i,type:r}of s.values())t.push(`@builtin( ${e} ) ${i} : ${r}`);return t.join(",\n\t")}getAttributes(e){const t=[];if("compute"===e&&(this.getBuiltin("global_invocation_id","id","vec3","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3","attribute"),this.getBuiltin("local_invocation_id","localId","vec3","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3","attribute")),"vertex"===e||"compute"===e){const e=this.getBuiltins("attribute");e&&t.push(e);const s=this.getAttributesArray();for(let e=0,i=s.length;e`)}const i=this.getBuiltins("output");return i&&t.push("\t"+i),t.join(",\n")}getStructs(e){const t=[],s=this.structs[e];for(let e=0,i=s.length;e output : ${r};\n\n`)}return t.join("\n\n")}getVar(e,t){return`var ${t} : ${this.getType(e)}`}getVars(e){const t=[],s=this.vars[e];if(void 0!==s)for(const e of s)t.push(`\t${this.getVar(e.type,e.name)};`);return`\n${t.join("\n")}\n`}getVaryings(e){const t=[];if("vertex"===e&&this.getBuiltin("position","Vertex","vec4","vertex"),"vertex"===e||"fragment"===e){const s=this.varyings,i=this.vars[e];for(let r=0;r";else if(!0===t.isDataArrayTexture||!0===t.isCompressedArrayTexture)i="texture_2d_array";else if(!0===t.isDepthTexture)i=`texture_depth${n}_2d`;else if(!0===t.isVideoTexture)i="texture_external";else if(!0===t.isData3DTexture)i="texture_3d";else if(!0===r.node.isStorageTextureNode){i=`texture_storage_2d<${xP(t)}, ${this.getStorageAccess(r.node)}>`}else{i=`texture${n}_2d<${this.getComponentTypeFromTexture(t).charAt(0)}32>`}s.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var ${r.name} : ${i};`)}else if("buffer"===r.type||"storageBuffer"===r.type){const e=r.node,t=this.getType(e.bufferType),s=e.bufferCount,n=s>0?", "+s:"",a=`\t${r.name} : array< ${t}${n} >\n`,h=e.isStorageBufferNode?`storage, ${this.getStorageAccess(e)}`:"uniform";i.push(this._getWGSLStructBinding("NodeBuffer_"+e.id,a,h,o.binding++,o.group))}else{const e=this.getType(this.getVectorType(r.type)),t=r.groupNode.name;(n[t]||(n[t]={index:o.binding++,id:o.group,snippets:[]})).snippets.push(`\t${r.name} : ${e}`)}}for(const e in n){const t=n[e];r.push(this._getWGSLStructBinding(e,t.snippets.join(",\n"),"uniform",t.index,t.id))}let o=s.join("\n");return o+=i.join("\n"),o+=r.join("\n"),o}buildCode(){const e=null!==this.material?{fragment:{},vertex:{}}:{compute:{}};for(const t in e){const s=e[t];s.uniforms=this.getUniforms(t),s.attributes=this.getAttributes(t),s.varyings=this.getVaryings(t),s.structs=this.getStructs(t),s.vars=this.getVars(t),s.codes=this.getCodes(t),s.directives=this.getDirectives(t);let i="// code\n\n";i+=this.flowCode[t];const r=this.flowNodes[t],n=r[r.length-1],o=n.outputNode,a=void 0!==o&&!0===o.isOutputStructNode;for(const e of r){const r=this.getFlowData(e),h=e.name;if(h&&(i.length>0&&(i+="\n"),i+=`\t// flow -> ${h}\n\t`),i+=`${r.code}\n\t`,e===n&&"compute"!==t)if(i+="// result\n\n\t","vertex"===t)i+=`varyings.Vertex = ${r.result};`;else if("fragment"===t)if(a)s.returnType=o.nodeType,i+=`return ${r.result};`;else{let e="\t@location(0) color: vec4";const t=this.getBuiltins("output");t&&(e+=",\n\t"+t),s.returnType="OutputStruct",s.structs+=this._getWGSLStruct("OutputStruct",e),s.structs+="\nvar output : OutputStruct;\n\n",i+=`output.color = ${r.result};\n\n\treturn output;`}}s.flow=i}null!==this.material?(this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment)):this.computeShader=this._getWGSLComputeCode(e.compute,(this.object.workgroupSize||[64]).join(", "))}getMethod(e,t=null){let s;return null!==t&&(s=this._getWGSLMethod(e+"_"+t)),void 0===s&&(s=this._getWGSLMethod(e)),s||e}getType(e){return RP[e]||e}isAvailable(e){let t=AP[e];return void 0===t&&("float32Filterable"===e&&(t=this.renderer.hasFeature("float32-filterable")),AP[e]=t),t}_getWGSLMethod(e){return void 0!==CP[e]&&this._include(e),EP[e]}_include(e){const t=CP[e];return t.build(this),null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(t),t}_getWGSLVertexCode(e){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// uniforms\n${e.uniforms}\n\n// varyings\n${e.varyings}\nvar varyings : VaryingsStruct;\n\n// codes\n${e.codes}\n\n@vertex\nfn main( ${e.attributes} ) -> VaryingsStruct {\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n\treturn varyings;\n\n}\n`}_getWGSLFragmentCode(e){return`${this.getSignature()}\n\ndiagnostic( off, derivative_uniformity );\n\n// uniforms\n${e.uniforms}\n\n// structs\n${e.structs}\n\n// codes\n${e.codes}\n\n@fragment\nfn main( ${e.varyings} ) -> ${e.returnType} {\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLComputeCode(e,t){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// system\nvar instanceIndex : u32;\n\n// uniforms\n${e.uniforms}\n\n// codes\n${e.codes}\n\n@compute @workgroup_size( ${t} )\nfn main( ${e.attributes} ) {\n\n\t// system\n\tinstanceIndex = id.x + id.y * numWorkgroups.x * u32(${t}) + id.z * numWorkgroups.x * numWorkgroups.y * u32(${t});\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLStruct(e,t){return`\nstruct ${e} {\n${t}\n};`}_getWGSLStructBinding(e,t,s,i=0,r=0){const n=e+"Struct";return`${this._getWGSLStruct(n,t)}\n@binding( ${i} ) @group( ${r} )\nvar<${s}> ${e} : ${n};`}}class IP{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return null!==e.depthTexture?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=PA.Depth24PlusStencil8:e.depth&&(t=PA.Depth24Plus),t}getTextureFormatGPU(e){return this.backend.get(e).texture.format}getCurrentColorFormat(e){let t;return t=null!==e.textures?this.getTextureFormatGPU(e.textures[0]):this.getPreferredCanvasFormat(),t}getCurrentColorSpace(e){return null!==e.textures?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){return e.isPoints?cA:e.isLineSegments||e.isMesh&&!0===t.wireframe?dA:e.isLine?pA:e.isMesh?mA:void 0}getSampleCount(e){let t=1;return e>1&&(t=Math.pow(2,Math.floor(Math.log2(e))),2===t&&(t=4)),t}getSampleCountRenderContext(e){return null!==e.textures?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.samples)}getPreferredCanvasFormat(){return navigator.userAgent.includes("Quest")?PA.BGRA8Unorm:navigator.gpu.getPreferredCanvasFormat()}}const PP=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]),FP=new Map([[fn,["float16"]]]),zP=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class UP{constructor(e){this.backend=e}createAttribute(e,t){const s=this._getBufferAttribute(e),i=this.backend,r=i.get(s);let n=r.buffer;if(void 0===n){const o=i.device;let a=s.array;if(!1===e.normalized&&(a.constructor===Int16Array||a.constructor===Uint16Array)){const e=new Uint32Array(a.length);for(let t=0;t{l.createRenderPipelineAsync(M).then((t=>{c.pipeline=t,e()}))}));t.push(e)}}createBundleEncoder(e,t){const s=this.backend,{utils:i,device:r}=s,n=s.get(e),o=s.get(t),a=i.getCurrentDepthStencilFormat(e),h={label:"renderBundleEncoder",colorFormats:[i.getCurrentColorFormat(e)],depthStencilFormat:a,sampleCount:this._getSampleCount(t.context)},l=r.createRenderBundleEncoder(h);return o.bundleEncoder=l,n.currentSets={attributes:{}},n._renderBundleViewport=e.width+"_"+e.height,l}createComputePipeline(e,t){const s=this.backend,i=s.device,r=s.get(e.computeProgram).module,n=s.get(e),o=[];for(const e of t){const t=s.get(e);o.push(t.layout)}n.pipeline=i.createComputePipeline({compute:r,layout:i.createPipelineLayout({bindGroupLayouts:o})})}_getBlending(e){let t,s;const i=e.blending,r=e.blendSrc,n=e.blendDst,o=e.blendEquation;if(5===i){const i=null!==e.blendSrcAlpha?e.blendSrcAlpha:r,a=null!==e.blendDstAlpha?e.blendDstAlpha:n,h=null!==e.blendEquationAlpha?e.blendEquationAlpha:o;t={srcFactor:this._getBlendFactor(r),dstFactor:this._getBlendFactor(n),operation:this._getBlendOperation(o)},s={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(a),operation:this._getBlendOperation(h)}}else{const r=(e,i,r,n)=>{t={srcFactor:e,dstFactor:i,operation:KA},s={srcFactor:r,dstFactor:n,operation:KA}};if(e.premultipliedAlpha)switch(i){case 1:r(DA,HA,DA,HA);break;case 2:r(DA,DA,DA,DA);break;case 3:r(VA,GA,VA,DA);break;case 4:r(VA,kA,VA,WA)}else switch(i){case 1:r(WA,HA,DA,HA);break;case 2:r(WA,DA,WA,DA);break;case 3:r(VA,GA,VA,DA);break;case 4:r(VA,kA,VA,kA)}}if(void 0!==t&&void 0!==s)return{color:t,alpha:s};console.error("THREE.WebGPURenderer: Invalid blending: ",i)}_getBlendFactor(e){let t;switch(e){case 200:t=VA;break;case 201:t=DA;break;case 202:t=kA;break;case 203:t=GA;break;case C:t=WA;break;case E:t=HA;break;case 208:t=jA;break;case 209:t=qA;break;case 206:t=$A;break;case 207:t=XA;break;case 210:t=YA;break;case 211:t=JA;break;case 212:t=ZA;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const s=e.stencilFunc;switch(s){case 512:t=fA;break;case bs:t=wA;break;case 513:t=yA;break;case 515:t=bA;break;case 514:t=xA;break;case 518:t=_A;break;case 516:t=vA;break;case 517:t=TA;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",s)}return t}_getStencilOperation(e){let t;switch(e){case ns:t=nN;break;case 0:t=oN;break;case 7681:t=aN;break;case 5386:t=hN;break;case 7682:t=lN;break;case 7683:t=uN;break;case 34055:t=cN;break;case 34056:t=dN;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case v:t=KA;break;case 101:t=QA;break;case 102:t=eN;break;case 103:t=tN;break;case 104:t=sN;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,s){const i={},r=this.backend.utils;switch(i.topology=r.getPrimitiveTopology(e,s),null!==t.index&&!0===e.isLine&&!0!==e.isLineSegments&&(i.stripIndexFormat=t.index.array instanceof Uint16Array?BA:IA),s.side){case c:i.frontFace=NA,i.cullMode=EA;break;case d:i.frontFace=NA,i.cullMode=CA;break;case 2:i.frontFace=NA,i.cullMode=RA;break;default:console.error("THREE.WebGPUPipelineUtils: Unknown material.side value.",s.side)}return i}_getColorWriteMask(e){return!0===e.colorWrite?rN:iN}_getDepthCompare(e){let t;if(!1===e.depthTest)t=wA;else{const s=e.depthFunc;switch(s){case 0:t=fA;break;case 1:t=wA;break;case 2:t=yA;break;case 3:t=bA;break;case 4:t=xA;break;case 5:t=_A;break;case 6:t=vA;break;case 7:t=TA;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",s)}}return t}}class VP extends HI{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=void 0===e.alpha||e.alpha,this.parameters.requiredLimits=void 0===e.requiredLimits?{}:e.requiredLimits,this.trackTimestamp=!0===e.trackTimestamp,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new IP(this),this.attributeUtils=new UP(this),this.bindingUtils=new LP(this),this.pipelineUtils=new OP(this),this.textureUtils=new yP(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);const t=this.parameters;let s;if(void 0===t.device){const e={powerPreference:t.powerPreference},i=await navigator.gpu.requestAdapter(e);if(null===i)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const r=Object.values(BN),n=[];for(const e of r)i.features.has(e)&&n.push(e);const o={requiredFeatures:n,requiredLimits:t.requiredLimits};s=await i.requestDevice(o)}else s=t.device;const i=void 0!==t.context?t.context:e.domElement.getContext("webgpu");this.device=s,this.context=i;const r=t.alpha?"premultiplied":"opaque";this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:r}),this.updateSize()}get coordinateSystem(){return Ds}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(null===e){const t=this.renderer;e={colorAttachments:[{view:null}],depthStencilAttachment:{view:this.textureUtils.getDepthBuffer(t.depth,t.stencil).createView()}};const s=e.colorAttachments[0];this.renderer.samples>0?s.view=this.colorBuffer.createView():s.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}const t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_getRenderPassDescriptor(e){const t=e.renderTarget,s=this.get(t);let i=s.descriptors;if(void 0===i||s.width!==t.width||s.height!==t.height||s.activeMipmapLevel!==t.activeMipmapLevel||s.samples!==t.samples){i={},s.descriptors=i;const e=()=>{t.removeEventListener("dispose",e),this.delete(t)};t.addEventListener("dispose",e)}const r=e.getCacheKey();let n=i[r];if(void 0===n){const o=e.textures,a=[];for(let t=0;t0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,r=s.createQuerySet({type:"occlusion",count:i}),t.occlusionQuerySet=r,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(i),t.lastOcclusionObject=null),n=null===e.textures?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e),this.initTimestampQuery(e,n),n.occlusionQuerySet=r;const o=n.depthStencilAttachment;if(null!==e.textures){const t=n.colorAttachments;for(let s=0;s0&&(t.registerBundlesPhase=!1,t.currentPass.executeBundles(t.renderBundles)),s>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery(),t.currentPass.end(),s>0){const i=8*s;let r=this.occludedResolveCache.get(i);void 0===r&&(r=this.device.createBuffer({size:i,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(i,r));const n=this.device.createBuffer({size:i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,s,r,0),t.encoder.copyBufferToBuffer(r,0,n,0,i),t.occlusionQueryBuffer=n,this.resolveOccludedAsync(e)}if(this.prepareTimestampBuffer(e,t.encoder),this.device.queue.submit([t.encoder.finish()]),null!==e.textures){const t=e.textures;for(let e=0;eo?(h.x=Math.min(t.dispatchCount,o),h.y=Math.ceil(t.dispatchCount/o)):h.x=t.dispatchCount,r.dispatchWorkgroups(h.x,h.y,h.z)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.prepareTimestampBuffer(e,t.cmdEncoderGPU),this.device.queue.submit([t.cmdEncoderGPU.finish()])}draw(e,t){const{object:s,geometry:i,context:r,pipeline:n}=e,o=e.getBindings(),a=this.get(r),h=this.get(n).pipeline,l=a.currentSets,u=this.get(e),{bundleEncoder:c,renderBundle:d,lastPipelineGPU:p}=u;if(!0===a.registerBundlesPhase&&void 0!==c&&p===h)return void a.renderBundles.push(d);const m=this.renderer._currentRenderBundle?this.createBundleEncoder(r,e):a.currentPass;l.pipeline!==h&&(m.setPipeline(h),l.pipeline=h);for(let e=0,t=o.length;e1?0:s;m.drawIndexed(t[s],i,e[s]/n,0,o)}}else if(!0===f){const e=x.count!==1/0?x.count:g.count;m.drawIndexed(e,v,b,0,0),t.update(s,e,v)}else{const e=i.attributes.position,r=x.count!==1/0?x.count:e.count;m.draw(r,v,b,0),t.update(s,r,v)}if(this.renderer._currentRenderBundle){const e=m.finish();u.lastPipelineGPU=h,u.renderBundle=e,u.bundleEncoder=m}}}needsRenderUpdate(e){const t=this.get(e),{object:s,material:i}=e,r=this.utils,n=r.getSampleCountRenderContext(e.context),o=r.getCurrentColorSpace(e.context),a=r.getCurrentColorFormat(e.context),h=r.getCurrentDepthStencilFormat(e.context),l=r.getPrimitiveTopology(s,i);let u=!1;return t.material===i&&t.materialVersion===i.version&&t.transparent===i.transparent&&t.blending===i.blending&&t.premultipliedAlpha===i.premultipliedAlpha&&t.blendSrc===i.blendSrc&&t.blendDst===i.blendDst&&t.blendEquation===i.blendEquation&&t.blendSrcAlpha===i.blendSrcAlpha&&t.blendDstAlpha===i.blendDstAlpha&&t.blendEquationAlpha===i.blendEquationAlpha&&t.colorWrite===i.colorWrite&&t.depthWrite===i.depthWrite&&t.depthTest===i.depthTest&&t.depthFunc===i.depthFunc&&t.stencilWrite===i.stencilWrite&&t.stencilFunc===i.stencilFunc&&t.stencilFail===i.stencilFail&&t.stencilZFail===i.stencilZFail&&t.stencilZPass===i.stencilZPass&&t.stencilFuncMask===i.stencilFuncMask&&t.stencilWriteMask===i.stencilWriteMask&&t.side===i.side&&t.alphaToCoverage===i.alphaToCoverage&&t.sampleCount===n&&t.colorSpace===o&&t.colorFormat===a&&t.depthStencilFormat===h&&t.primitiveTopology===l&&t.clippingContextCacheKey===e.clippingContext.cacheKey||(t.material=i,t.materialVersion=i.version,t.transparent=i.transparent,t.blending=i.blending,t.premultipliedAlpha=i.premultipliedAlpha,t.blendSrc=i.blendSrc,t.blendDst=i.blendDst,t.blendEquation=i.blendEquation,t.blendSrcAlpha=i.blendSrcAlpha,t.blendDstAlpha=i.blendDstAlpha,t.blendEquationAlpha=i.blendEquationAlpha,t.colorWrite=i.colorWrite,t.depthWrite=i.depthWrite,t.depthTest=i.depthTest,t.depthFunc=i.depthFunc,t.stencilWrite=i.stencilWrite,t.stencilFunc=i.stencilFunc,t.stencilFail=i.stencilFail,t.stencilZFail=i.stencilZFail,t.stencilZPass=i.stencilZPass,t.stencilFuncMask=i.stencilFuncMask,t.stencilWriteMask=i.stencilWriteMask,t.side=i.side,t.alphaToCoverage=i.alphaToCoverage,t.sampleCount=n,t.colorSpace=o,t.colorFormat=a,t.depthStencilFormat=h,t.primitiveTopology=l,t.clippingContextCacheKey=e.clippingContext.cacheKey,u=!0),u}getRenderCacheKey(e){const{object:t,material:s}=e,i=this.utils,r=e.context;return[s.transparent,s.blending,s.premultipliedAlpha,s.blendSrc,s.blendDst,s.blendEquation,s.blendSrcAlpha,s.blendDstAlpha,s.blendEquationAlpha,s.colorWrite,s.depthWrite,s.depthTest,s.depthFunc,s.stencilWrite,s.stencilFunc,s.stencilFail,s.stencilZFail,s.stencilZPass,s.stencilFuncMask,s.stencilWriteMask,s.side,i.getSampleCountRenderContext(r),i.getCurrentColorSpace(r),i.getCurrentColorFormat(r),i.getCurrentDepthStencilFormat(r),i.getPrimitiveTopology(t,s),e.clippingContext.cacheKey].join()}createSampler(e){this.textureUtils.createSampler(e)}destroySampler(e){this.textureUtils.destroySampler(e)}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}copyTextureToBuffer(e,t,s,i,r){return this.textureUtils.copyTextureToBuffer(e,t,s,i,r)}initTimestampQuery(e,t){if(!this.hasFeature(BN.TimestampQuery)||!this.trackTimestamp)return;const s=this.get(e);if(!s.timeStampQuerySet){const e=this.device.createQuerySet({type:"timestamp",count:2}),i={querySet:e,beginningOfPassWriteIndex:0,endOfPassWriteIndex:1};Object.assign(t,{timestampWrites:i}),s.timeStampQuerySet=e}}prepareTimestampBuffer(e,t){if(!this.hasFeature(BN.TimestampQuery)||!this.trackTimestamp)return;const s=this.get(e),i=2*BigInt64Array.BYTES_PER_ELEMENT;void 0===s.currentTimestampQueryBuffers&&(s.currentTimestampQueryBuffers={resolveBuffer:this.device.createBuffer({label:"timestamp resolve buffer",size:i,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),resultBuffer:this.device.createBuffer({label:"timestamp result buffer",size:i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),isMappingPending:!1});const{resolveBuffer:r,resultBuffer:n,isMappingPending:o}=s.currentTimestampQueryBuffers;!0!==o&&(t.resolveQuerySet(s.timeStampQuerySet,0,2,r,0),t.copyBufferToBuffer(r,0,n,0,i))}async resolveTimestampAsync(e,t="render"){if(!this.hasFeature(BN.TimestampQuery)||!this.trackTimestamp)return;const s=this.get(e);if(void 0===s.currentTimestampQueryBuffers)return;const{resultBuffer:i,isMappingPending:r}=s.currentTimestampQueryBuffers;!0!==r&&(s.currentTimestampQueryBuffers.isMappingPending=!0,i.mapAsync(GPUMapMode.READ).then((()=>{const e=new BigUint64Array(i.getMappedRange()),r=Number(e[1]-e[0])/1e6;this.renderer.info.updateTimestamp(t,r),i.unmap(),s.currentTimestampQueryBuffers.isMappingPending=!1})))}createNodeBuilder(e,t){return new BP(e,t)}createProgram(e){this.get(e).module={module:this.device.createShaderModule({code:e.code,label:e.stage}),entryPoint:"main"}}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}createBundleEncoder(e,t){return this.pipelineUtils.createBundleEncoder(e,t)}createBindings(e){this.bindingUtils.createBindings(e)}updateBindings(e){this.bindingUtils.createBindings(e)}updateBinding(e){this.bindingUtils.updateBinding(e)}createIndexAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.colorBuffer=this.textureUtils.getColorBuffer(),this.defaultRenderPassdescriptor=null}getMaxAnisotropy(){return 16}hasFeature(e){return this.device.features.has(e)}copyTextureToTexture(e,t,s=null,i=null,r=0){let n=0,o=0,a=0,h=0,l=e.image.width,u=e.image.height;null!==s&&(a=s.x,h=s.y,l=s.width,u=s.height),null!==i&&(n=i.x,o=i.y);const c=this.device.createCommandEncoder({label:"copyTextureToTexture_"+e.id+"_"+t.id}),d=this.get(e).texture,p=this.get(t).texture;c.copyTextureToTexture({texture:d,mipLevel:r,origin:{x:a,y:h,z:0}},{texture:p,mipLevel:r,origin:{x:n,y:o,z:0}},[l,u]),this.device.queue.submit([c.finish()])}copyFramebufferToTexture(e,t){const s=this.get(t),{encoder:i,descriptor:r}=s;let n=null;n=t.renderTarget?e.isDepthTexture?this.get(t.depthTexture).texture:this.get(t.textures[0]).texture:e.isDepthTexture?this.textureUtils.getDepthBuffer(t.depth,t.stencil):this.context.getCurrentTexture();const o=this.get(e).texture;if(n.format===o.format){s.currentPass.end(),i.copyTextureToTexture({texture:n,origin:{x:0,y:0,z:0}},{texture:o},[e.image.width,e.image.height]),e.generateMipmaps&&this.textureUtils.generateMipmaps(e);for(let e=0;e(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new hP(e)));super(new t(e),e),this.isWebGPURenderer=!0}}const kP=new yx,GP=new QM(kP);class WP{constructor(e,t=uc(0,0,1,1)){this.renderer=e,this.outputNode=t,this.outputColorTransform=!0,this.needsUpdate=!0,kP.name="PostProcessing"}render(){this.update();const e=this.renderer,t=e.toneMapping,s=e.outputColorSpace;e.toneMapping=0,e.outputColorSpace=Zt,GP.render(e),e.toneMapping=t,e.outputColorSpace=s}update(){if(!0===this.needsUpdate){const e=this.renderer,t=e.toneMapping,s=e.outputColorSpace;GP.material.fragmentNode=!0===this.outputColorTransform?Im(this.outputNode,t,s):this.outputNode.context({toneMapping:t,outputColorSpace:s}),GP.material.needsUpdate=!0,this.needsUpdate=!1}}async renderAsync(){this.update();const e=this.renderer,t=e.toneMapping,s=e.outputColorSpace;e.toneMapping=0,e.outputColorSpace=Zt,await GP.renderAsync(e),e.toneMapping=t,e.outputColorSpace=s}}class HP extends Ti{constructor(e=1,t=1){super(),this.image={width:e,height:t},this.magFilter=Te,this.minFilter=Te,this.isStorageTexture=!0}}class jP extends hn{constructor(e,t,s=Float32Array){!1===ArrayBuffer.isView(e)&&(e=new s(e*t)),super(e,t),this.isStorageBufferAttribute=!0}}class qP extends Ho{constructor(e,t,s=Float32Array){!1===ArrayBuffer.isView(e)&&(e=new s(e*t)),super(e,t),this.isStorageInstancedBufferAttribute=!0}}class $P extends pT{constructor(e){super(e),this.textures={}}load(e,t,s,i){const r=new fT(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,(s=>{try{t(this.parse(JSON.parse(s)))}catch(t){i?i(t):console.error(t),this.manager.itemError(e)}}),s,i)}parseNodes(e){const t={};if(void 0!==e){for(const s of e){const{uuid:e,type:i}=s;t[e]=Du(eu(i)),t[e].uuid=e}const s={nodes:t,textures:this.textures};for(const i of e){i.meta=s;t[i.uuid].deserialize(i),delete i.meta}}return t}parse(e){const t=Du(eu(e.type));t.uuid=e.uuid;const s={nodes:this.parseNodes(e.nodes),textures:this.textures};return e.meta=s,t.deserialize(e),delete e.meta,t}setTextures(e){return this.textures=e,this}}class XP extends WT{constructor(e){super(e),this.nodes={}}parse(e){const t=super.parse(e),s=this.nodes,i=e.inputNodes;for(const e in i){const r=i[e];t[e]=s[r]}return t}setNodes(e){return this.nodes=e,this}}class YP extends $T{constructor(e){super(e),this._nodesJSON=null}parse(e,t){this._nodesJSON=e.nodes;const s=super.parse(e,t);return this._nodesJSON=null,s}parseNodes(e,t){if(void 0!==e){const s=new $P;return s.setTextures(t),s.parseNodes(e)}return{}}parseMaterials(e,t){const s={};if(void 0!==e){const i=this.parseNodes(this._nodesJSON,t),r=new XP;r.setTextures(t),r.setNodes(i);for(let t=0,i=e.length;t>8&255]+Gs[e>>16&255]+Gs[e>>24&255]+"-"+Gs[255&t]+Gs[t>>8&255]+"-"+Gs[t>>16&15|64]+Gs[t>>24&255]+"-"+Gs[63&s|128]+Gs[s>>8&255]+"-"+Gs[s>>16&255]+Gs[s>>24&255]+Gs[255&i]+Gs[i>>8&255]+Gs[i>>16&255]+Gs[i>>24&255]).toLowerCase()}function $s(e,t,s){return Math.max(t,Math.min(s,e))}function Xs(e,t){return(e%t+t)%t}function Ys(e,t,s){return(1-s)*e+s*t}function Js(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return e/4294967295;case Uint16Array:return e/65535;case Uint8Array:return e/255;case Int32Array:return Math.max(e/2147483647,-1);case Int16Array:return Math.max(e/32767,-1);case Int8Array:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}function Zs(e,t){switch(t.constructor){case Float32Array:return e;case Uint32Array:return Math.round(4294967295*e);case Uint16Array:return Math.round(65535*e);case Uint8Array:return Math.round(255*e);case Int32Array:return Math.round(2147483647*e);case Int16Array:return Math.round(32767*e);case Int8Array:return Math.round(127*e);default:throw new Error("Invalid component type.")}}const Ks={DEG2RAD:Hs,RAD2DEG:js,generateUUID:qs,clamp:$s,euclideanModulo:Xs,mapLinear:function(e,t,s,i,r){return i+(e-t)*(r-i)/(s-t)},inverseLerp:function(e,t,s){return e!==t?(s-e)/(t-e):0},lerp:Ys,damp:function(e,t,s,i){return Ys(e,t,1-Math.exp(-s*i))},pingpong:function(e,t=1){return t-Math.abs(Xs(e,2*t)-t)},smoothstep:function(e,t,s){return e<=t?0:e>=s?1:(e=(e-t)/(s-t))*e*(3-2*e)},smootherstep:function(e,t,s){return e<=t?0:e>=s?1:(e=(e-t)/(s-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},seededRandom:function(e){void 0!==e&&(Ws=e);let t=Ws+=1831565813;return t=Math.imul(t^t>>>15,1|t),t^=t+Math.imul(t^t>>>7,61|t),((t^t>>>14)>>>0)/4294967296},degToRad:function(e){return e*Hs},radToDeg:function(e){return e*js},isPowerOfTwo:function(e){return 0==(e&e-1)&&0!==e},ceilPowerOfTwo:function(e){return Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},floorPowerOfTwo:function(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},setQuaternionFromProperEuler:function(e,t,s,i,r){const n=Math.cos,o=Math.sin,a=n(s/2),h=o(s/2),l=n((t+i)/2),u=o((t+i)/2),c=n((t-i)/2),d=o((t-i)/2),p=n((i-t)/2),m=o((i-t)/2);switch(r){case"XYX":e.set(a*u,h*c,h*d,a*l);break;case"YZY":e.set(h*d,a*u,h*c,a*l);break;case"ZXZ":e.set(h*c,h*d,a*u,a*l);break;case"XZX":e.set(a*u,h*m,h*p,a*l);break;case"YXY":e.set(h*p,a*u,h*m,a*l);break;case"ZYZ":e.set(h*m,h*p,a*u,a*l);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}},normalize:Zs,denormalize:Js};class Qs{constructor(e=0,t=0){Qs.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,s=this.y,i=e.elements;return this.x=i[0]*t+i[3]*s+i[6],this.y=i[1]*t+i[4]*s+i[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(e,Math.min(t,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const s=this.dot(e)/t;return Math.acos($s(s,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y;return t*t+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const s=Math.cos(t),i=Math.sin(t),r=this.x-e.x,n=this.y-e.y;return this.x=r*s-n*i+e.x,this.y=r*i+n*s+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ei{constructor(e,t,s,i,r,n,o,a,h){ei.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],void 0!==e&&this.set(e,t,s,i,r,n,o,a,h)}set(e,t,s,i,r,n,o,a,h){const l=this.elements;return l[0]=e,l[1]=i,l[2]=o,l[3]=t,l[4]=r,l[5]=a,l[6]=s,l[7]=n,l[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],this}extractBasis(e,t,s){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,i=t.elements,r=this.elements,n=s[0],o=s[3],a=s[6],h=s[1],l=s[4],u=s[7],c=s[2],d=s[5],p=s[8],m=i[0],g=i[3],f=i[6],y=i[1],x=i[4],b=i[7],v=i[2],T=i[5],_=i[8];return r[0]=n*m+o*y+a*v,r[3]=n*g+o*x+a*T,r[6]=n*f+o*b+a*_,r[1]=h*m+l*y+u*v,r[4]=h*g+l*x+u*T,r[7]=h*f+l*b+u*_,r[2]=c*m+d*y+p*v,r[5]=c*g+d*x+p*T,r[8]=c*f+d*b+p*_,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],s=e[1],i=e[2],r=e[3],n=e[4],o=e[5],a=e[6],h=e[7],l=e[8];return t*n*l-t*o*h-s*r*l+s*o*a+i*r*h-i*n*a}invert(){const e=this.elements,t=e[0],s=e[1],i=e[2],r=e[3],n=e[4],o=e[5],a=e[6],h=e[7],l=e[8],u=l*n-o*h,c=o*a-l*r,d=h*r-n*a,p=t*u+s*c+i*d;if(0===p)return this.set(0,0,0,0,0,0,0,0,0);const m=1/p;return e[0]=u*m,e[1]=(i*h-l*s)*m,e[2]=(o*s-i*n)*m,e[3]=c*m,e[4]=(l*t-i*a)*m,e[5]=(i*r-o*t)*m,e[6]=d*m,e[7]=(s*a-h*t)*m,e[8]=(n*t-s*r)*m,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,s,i,r,n,o){const a=Math.cos(r),h=Math.sin(r);return this.set(s*a,s*h,-s*(a*n+h*o)+n+e,-i*h,i*a,-i*(-h*n+a*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(ti.makeScale(e,t)),this}rotate(e){return this.premultiply(ti.makeRotation(-e)),this}translate(e,t){return this.premultiply(ti.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,s,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,s=e.elements;for(let e=0;e<9;e++)if(t[e]!==s[e])return!1;return!0}fromArray(e,t=0){for(let s=0;s<9;s++)this.elements[s]=e[s+t];return this}toArray(e=[],t=0){const s=this.elements;return e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2],e[t+3]=s[3],e[t+4]=s[4],e[t+5]=s[5],e[t+6]=s[6],e[t+7]=s[7],e[t+8]=s[8],e}clone(){return(new this.constructor).fromArray(this.elements)}}const ti=new ei;const si={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};function ii(e,t){return new si[e](t)}function ri(e){return document.createElementNS("http://www.w3.org/1999/xhtml",e)}function ni(){const e=ri("canvas");return e.style.display="block",e}const oi={};function ai(e){e in oi||(oi[e]=!0,console.warn(e))}const hi=(new ei).set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),li=(new ei).set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),ui={[Zt]:{transfer:es,primaries:ss,luminanceCoefficients:[.2126,.7152,.0722],toReference:e=>e,fromReference:e=>e},[Jt]:{transfer:ts,primaries:ss,luminanceCoefficients:[.2126,.7152,.0722],toReference:e=>e.convertSRGBToLinear(),fromReference:e=>e.convertLinearToSRGB()},[Qt]:{transfer:es,primaries:is,luminanceCoefficients:[.2289,.6917,.0793],toReference:e=>e.applyMatrix3(li),fromReference:e=>e.applyMatrix3(hi)},[Kt]:{transfer:ts,primaries:is,luminanceCoefficients:[.2289,.6917,.0793],toReference:e=>e.convertSRGBToLinear().applyMatrix3(li),fromReference:e=>e.applyMatrix3(hi).convertLinearToSRGB()}},ci=new Set([Zt,Qt]),di={enabled:!0,_workingColorSpace:Zt,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(e){if(!ci.has(e))throw new Error(`Unsupported working color space, "${e}".`);this._workingColorSpace=e},convert:function(e,t,s){if(!1===this.enabled||t===s||!t||!s)return e;const i=ui[t].toReference;return(0,ui[s].fromReference)(i(e))},fromWorkingColorSpace:function(e,t){return this.convert(e,this._workingColorSpace,t)},toWorkingColorSpace:function(e,t){return this.convert(e,t,this._workingColorSpace)},getPrimaries:function(e){return ui[e].primaries},getTransfer:function(e){return""===e?es:ui[e].transfer},getLuminanceCoefficients:function(e,t=this._workingColorSpace){return e.fromArray(ui[t].luminanceCoefficients)}};function pi(e){return e<.04045?.0773993808*e:Math.pow(.9478672986*e+.0521327014,2.4)}function mi(e){return e<.0031308?12.92*e:1.055*Math.pow(e,.41666)-.055}let gi;class fi{static getDataURL(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===gi&&(gi=ri("canvas")),gi.width=e.width,gi.height=e.height;const s=gi.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),t=gi}return t.width>2048||t.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",e),t.toDataURL("image/jpeg",.6)):t.toDataURL("image/png")}static sRGBToLinear(e){if("undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const t=ri("canvas");t.width=e.width,t.height=e.height;const s=t.getContext("2d");s.drawImage(e,0,0,e.width,e.height);const i=s.getImageData(0,0,e.width,e.height),r=i.data;for(let e=0;e0&&(s.userData=this.userData),t||(e.textures[this.uuid]=s),s}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==ae)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case pe:e.x=e.x-Math.floor(e.x);break;case me:e.x=e.x<0?0:1;break;case ge:1===Math.abs(Math.floor(e.x)%2)?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x)}if(e.y<0||e.y>1)switch(this.wrapT){case pe:e.y=e.y-Math.floor(e.y);break;case me:e.y=e.y<0?0:1;break;case ge:1===Math.abs(Math.floor(e.y)%2)?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y)}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){!0===e&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){!0===e&&this.pmremVersion++}}Ti.DEFAULT_IMAGE=null,Ti.DEFAULT_MAPPING=ae,Ti.DEFAULT_ANISOTROPY=1;class _i{constructor(e=0,t=0,s=0,i=1){_i.prototype.isVector4=!0,this.x=e,this.y=t,this.z=s,this.w=i}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,s,i){return this.x=e,this.y=t,this.z=s,this.w=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,s=this.y,i=this.z,r=this.w,n=e.elements;return this.x=n[0]*t+n[4]*s+n[8]*i+n[12]*r,this.y=n[1]*t+n[5]*s+n[9]*i+n[13]*r,this.z=n[2]*t+n[6]*s+n[10]*i+n[14]*r,this.w=n[3]*t+n[7]*s+n[11]*i+n[15]*r,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,s,i,r;const n=.01,o=.1,a=e.elements,h=a[0],l=a[4],u=a[8],c=a[1],d=a[5],p=a[9],m=a[2],g=a[6],f=a[10];if(Math.abs(l-c)a&&e>y?ey?a=0?1:-1,i=1-t*t;if(i>Number.EPSILON){const r=Math.sqrt(i),n=Math.atan2(r,t*s);e=Math.sin(e*n)/r,o=Math.sin(o*n)/r}const r=o*s;if(a=a*e+c*r,h=h*e+d*r,l=l*e+p*r,u=u*e+m*r,e===1-o){const e=1/Math.sqrt(a*a+h*h+l*l+u*u);a*=e,h*=e,l*=e,u*=e}}e[t]=a,e[t+1]=h,e[t+2]=l,e[t+3]=u}static multiplyQuaternionsFlat(e,t,s,i,r,n){const o=s[i],a=s[i+1],h=s[i+2],l=s[i+3],u=r[n],c=r[n+1],d=r[n+2],p=r[n+3];return e[t]=o*p+l*u+a*d-h*c,e[t+1]=a*p+l*c+h*u-o*d,e[t+2]=h*p+l*d+o*c-a*u,e[t+3]=l*p-o*u-a*c-h*d,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,s,i){return this._x=e,this._y=t,this._z=s,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const s=e._x,i=e._y,r=e._z,n=e._order,o=Math.cos,a=Math.sin,h=o(s/2),l=o(i/2),u=o(r/2),c=a(s/2),d=a(i/2),p=a(r/2);switch(n){case"XYZ":this._x=c*l*u+h*d*p,this._y=h*d*u-c*l*p,this._z=h*l*p+c*d*u,this._w=h*l*u-c*d*p;break;case"YXZ":this._x=c*l*u+h*d*p,this._y=h*d*u-c*l*p,this._z=h*l*p-c*d*u,this._w=h*l*u+c*d*p;break;case"ZXY":this._x=c*l*u-h*d*p,this._y=h*d*u+c*l*p,this._z=h*l*p+c*d*u,this._w=h*l*u-c*d*p;break;case"ZYX":this._x=c*l*u-h*d*p,this._y=h*d*u+c*l*p,this._z=h*l*p-c*d*u,this._w=h*l*u+c*d*p;break;case"YZX":this._x=c*l*u+h*d*p,this._y=h*d*u+c*l*p,this._z=h*l*p-c*d*u,this._w=h*l*u-c*d*p;break;case"XZY":this._x=c*l*u-h*d*p,this._y=h*d*u-c*l*p,this._z=h*l*p+c*d*u,this._w=h*l*u+c*d*p;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+n)}return!0===t&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const s=t/2,i=Math.sin(s);return this._x=e.x*i,this._y=e.y*i,this._z=e.z*i,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,s=t[0],i=t[4],r=t[8],n=t[1],o=t[5],a=t[9],h=t[2],l=t[6],u=t[10],c=s+o+u;if(c>0){const e=.5/Math.sqrt(c+1);this._w=.25/e,this._x=(l-a)*e,this._y=(r-h)*e,this._z=(n-i)*e}else if(s>o&&s>u){const e=2*Math.sqrt(1+s-o-u);this._w=(l-a)/e,this._x=.25*e,this._y=(i+n)/e,this._z=(r+h)/e}else if(o>u){const e=2*Math.sqrt(1+o-s-u);this._w=(r-h)/e,this._x=(i+n)/e,this._y=.25*e,this._z=(a+l)/e}else{const e=2*Math.sqrt(1+u-s-o);this._w=(n-i)/e,this._x=(r+h)/e,this._y=(a+l)/e,this._z=.25*e}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let s=e.dot(t)+1;return sMath.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=s):(this._x=0,this._y=-e.z,this._z=e.y,this._w=s)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=s),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs($s(this.dot(e),-1,1)))}rotateTowards(e,t){const s=this.angleTo(e);if(0===s)return this;const i=Math.min(1,t/s);return this.slerp(e,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const s=e._x,i=e._y,r=e._z,n=e._w,o=t._x,a=t._y,h=t._z,l=t._w;return this._x=s*l+n*o+i*h-r*a,this._y=i*l+n*a+r*o-s*h,this._z=r*l+n*h+s*a-i*o,this._w=n*l-s*o-i*a-r*h,this._onChangeCallback(),this}slerp(e,t){if(0===t)return this;if(1===t)return this.copy(e);const s=this._x,i=this._y,r=this._z,n=this._w;let o=n*e._w+s*e._x+i*e._y+r*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=n,this._x=s,this._y=i,this._z=r,this;const a=1-o*o;if(a<=Number.EPSILON){const e=1-t;return this._w=e*n+t*this._w,this._x=e*s+t*this._x,this._y=e*i+t*this._y,this._z=e*r+t*this._z,this.normalize(),this}const h=Math.sqrt(a),l=Math.atan2(h,o),u=Math.sin((1-t)*l)/h,c=Math.sin(t*l)/h;return this._w=n*u+this._w*c,this._x=s*u+this._x*c,this._y=i*u+this._y*c,this._z=r*u+this._z*c,this._onChangeCallback(),this}slerpQuaternions(e,t,s){return this.copy(e).slerp(t,s)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),s=Math.random(),i=Math.sqrt(1-s),r=Math.sqrt(s);return this.set(i*Math.sin(e),i*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class Ei{constructor(e=0,t=0,s=0){Ei.prototype.isVector3=!0,this.x=e,this.y=t,this.z=s}set(e,t,s){return void 0===s&&(s=this.z),this.x=e,this.y=t,this.z=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Ii.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ii.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,s=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[3]*s+r[6]*i,this.y=r[1]*t+r[4]*s+r[7]*i,this.z=r[2]*t+r[5]*s+r[8]*i,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,s=this.y,i=this.z,r=e.elements,n=1/(r[3]*t+r[7]*s+r[11]*i+r[15]);return this.x=(r[0]*t+r[4]*s+r[8]*i+r[12])*n,this.y=(r[1]*t+r[5]*s+r[9]*i+r[13])*n,this.z=(r[2]*t+r[6]*s+r[10]*i+r[14])*n,this}applyQuaternion(e){const t=this.x,s=this.y,i=this.z,r=e.x,n=e.y,o=e.z,a=e.w,h=2*(n*i-o*s),l=2*(o*t-r*i),u=2*(r*s-n*t);return this.x=t+a*h+n*u-o*l,this.y=s+a*l+o*h-r*u,this.z=i+a*u+r*l-n*h,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,s=this.y,i=this.z,r=e.elements;return this.x=r[0]*t+r[4]*s+r[8]*i,this.y=r[1]*t+r[5]*s+r[9]*i,this.z=r[2]*t+r[6]*s+r[10]*i,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(e,Math.min(t,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,s){return this.x=e.x+(t.x-e.x)*s,this.y=e.y+(t.y-e.y)*s,this.z=e.z+(t.z-e.z)*s,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const s=e.x,i=e.y,r=e.z,n=t.x,o=t.y,a=t.z;return this.x=i*a-r*o,this.y=r*n-s*a,this.z=s*o-i*n,this}projectOnVector(e){const t=e.lengthSq();if(0===t)return this.set(0,0,0);const s=e.dot(this)/t;return this.copy(e).multiplyScalar(s)}projectOnPlane(e){return Bi.copy(this).projectOnVector(e),this.sub(Bi)}reflect(e){return this.sub(Bi.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(0===t)return Math.PI/2;const s=this.dot(e)/t;return Math.acos($s(s,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,s=this.y-e.y,i=this.z-e.z;return t*t+s*s+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,s){const i=Math.sin(t)*e;return this.x=i*Math.sin(s),this.y=Math.cos(t)*e,this.z=i*Math.cos(s),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,s){return this.x=e*Math.sin(t),this.y=s,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),s=this.setFromMatrixColumn(e,1).length(),i=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=s,this.z=i,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,4*t)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,3*t)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=2*Math.random()-1,s=Math.sqrt(1-t*t);return this.x=s*Math.cos(e),this.y=t,this.z=s*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Bi=new Ei,Ii=new Ci;class Pi{constructor(e=new Ei(1/0,1/0,1/0),t=new Ei(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,s=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,zi),zi.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,s;return e.normal.x>0?(t=e.normal.x*this.min.x,s=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,s=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,s+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,s+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,s+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,s+=e.normal.z*this.min.z),t<=-e.constant&&s>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Wi),Hi.subVectors(this.max,Wi),Li.subVectors(e.a,Wi),Oi.subVectors(e.b,Wi),Vi.subVectors(e.c,Wi),Di.subVectors(Oi,Li),ki.subVectors(Vi,Oi),Gi.subVectors(Li,Vi);let t=[0,-Di.z,Di.y,0,-ki.z,ki.y,0,-Gi.z,Gi.y,Di.z,0,-Di.x,ki.z,0,-ki.x,Gi.z,0,-Gi.x,-Di.y,Di.x,0,-ki.y,ki.x,0,-Gi.y,Gi.x,0];return!!$i(t,Li,Oi,Vi,Hi)&&(t=[1,0,0,0,1,0,0,0,1],!!$i(t,Li,Oi,Vi,Hi)&&(ji.crossVectors(Di,ki),t=[ji.x,ji.y,ji.z],$i(t,Li,Oi,Vi,Hi)))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,zi).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=.5*this.getSize(zi).length()),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()||(Fi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Fi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Fi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Fi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Fi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Fi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Fi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Fi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Fi)),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Fi=[new Ei,new Ei,new Ei,new Ei,new Ei,new Ei,new Ei,new Ei],zi=new Ei,Ui=new Pi,Li=new Ei,Oi=new Ei,Vi=new Ei,Di=new Ei,ki=new Ei,Gi=new Ei,Wi=new Ei,Hi=new Ei,ji=new Ei,qi=new Ei;function $i(e,t,s,i,r){for(let n=0,o=e.length-3;n<=o;n+=3){qi.fromArray(e,n);const o=r.x*Math.abs(qi.x)+r.y*Math.abs(qi.y)+r.z*Math.abs(qi.z),a=t.dot(qi),h=s.dot(qi),l=i.dot(qi);if(Math.max(-Math.max(a,h,l),Math.min(a,h,l))>o)return!1}return!0}const Xi=new Pi,Yi=new Ei,Ji=new Ei;class Zi{constructor(e=new Ei,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const s=this.center;void 0!==t?s.copy(t):Xi.setFromPoints(e).getCenter(s);let i=0;for(let t=0,r=e.length;tthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Yi.subVectors(e,this.center);const t=Yi.lengthSq();if(t>this.radius*this.radius){const e=Math.sqrt(t),s=.5*(e-this.radius);this.center.addScaledVector(Yi,s/e),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(!0===this.center.equals(e.center)?this.radius=Math.max(this.radius,e.radius):(Ji.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Yi.copy(e.center).add(Ji)),this.expandByPoint(Yi.copy(e.center).sub(Ji))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return(new this.constructor).copy(this)}}const Ki=new Ei,Qi=new Ei,er=new Ei,tr=new Ei,sr=new Ei,ir=new Ei,rr=new Ei;class nr{constructor(e=new Ei,t=new Ei(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Ki)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const s=t.dot(this.direction);return s<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,s)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Ki.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Ki.copy(this.origin).addScaledVector(this.direction,t),Ki.distanceToSquared(e))}distanceSqToSegment(e,t,s,i){Qi.copy(e).add(t).multiplyScalar(.5),er.copy(t).sub(e).normalize(),tr.copy(this.origin).sub(Qi);const r=.5*e.distanceTo(t),n=-this.direction.dot(er),o=tr.dot(this.direction),a=-tr.dot(er),h=tr.lengthSq(),l=Math.abs(1-n*n);let u,c,d,p;if(l>0)if(u=n*a-o,c=n*o-a,p=r*l,u>=0)if(c>=-p)if(c<=p){const e=1/l;u*=e,c*=e,d=u*(u+n*c+2*o)+c*(n*u+c+2*a)+h}else c=r,u=Math.max(0,-(n*c+o)),d=-u*u+c*(c+2*a)+h;else c=-r,u=Math.max(0,-(n*c+o)),d=-u*u+c*(c+2*a)+h;else c<=-p?(u=Math.max(0,-(-n*r+o)),c=u>0?-r:Math.min(Math.max(-r,-a),r),d=-u*u+c*(c+2*a)+h):c<=p?(u=0,c=Math.min(Math.max(-r,-a),r),d=c*(c+2*a)+h):(u=Math.max(0,-(n*r+o)),c=u>0?r:Math.min(Math.max(-r,-a),r),d=-u*u+c*(c+2*a)+h);else c=n>0?-r:r,u=Math.max(0,-(n*c+o)),d=-u*u+c*(c+2*a)+h;return s&&s.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(Qi).addScaledVector(er,c),d}intersectSphere(e,t){Ki.subVectors(e.center,this.origin);const s=Ki.dot(this.direction),i=Ki.dot(Ki)-s*s,r=e.radius*e.radius;if(i>r)return null;const n=Math.sqrt(r-i),o=s-n,a=s+n;return a<0?null:o<0?this.at(a,t):this.at(o,t)}intersectsSphere(e){return this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;const s=-(this.origin.dot(e.normal)+e.constant)/t;return s>=0?s:null}intersectPlane(e,t){const s=this.distanceToPlane(e);return null===s?null:this.at(s,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);if(0===t)return!0;return e.normal.dot(this.direction)*t<0}intersectBox(e,t){let s,i,r,n,o,a;const h=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,c=this.origin;return h>=0?(s=(e.min.x-c.x)*h,i=(e.max.x-c.x)*h):(s=(e.max.x-c.x)*h,i=(e.min.x-c.x)*h),l>=0?(r=(e.min.y-c.y)*l,n=(e.max.y-c.y)*l):(r=(e.max.y-c.y)*l,n=(e.min.y-c.y)*l),s>n||r>i?null:((r>s||isNaN(s))&&(s=r),(n=0?(o=(e.min.z-c.z)*u,a=(e.max.z-c.z)*u):(o=(e.max.z-c.z)*u,a=(e.min.z-c.z)*u),s>a||o>i?null:((o>s||s!=s)&&(s=o),(a=0?s:i,t)))}intersectsBox(e){return null!==this.intersectBox(e,Ki)}intersectTriangle(e,t,s,i,r){sr.subVectors(t,e),ir.subVectors(s,e),rr.crossVectors(sr,ir);let n,o=this.direction.dot(rr);if(o>0){if(i)return null;n=1}else{if(!(o<0))return null;n=-1,o=-o}tr.subVectors(this.origin,e);const a=n*this.direction.dot(ir.crossVectors(tr,ir));if(a<0)return null;const h=n*this.direction.dot(sr.cross(tr));if(h<0)return null;if(a+h>o)return null;const l=-n*tr.dot(rr);return l<0?null:this.at(l/o,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return(new this.constructor).copy(this)}}class or{constructor(e,t,s,i,r,n,o,a,h,l,u,c,d,p,m,g){or.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==e&&this.set(e,t,s,i,r,n,o,a,h,l,u,c,d,p,m,g)}set(e,t,s,i,r,n,o,a,h,l,u,c,d,p,m,g){const f=this.elements;return f[0]=e,f[4]=t,f[8]=s,f[12]=i,f[1]=r,f[5]=n,f[9]=o,f[13]=a,f[2]=h,f[6]=l,f[10]=u,f[14]=c,f[3]=d,f[7]=p,f[11]=m,f[15]=g,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new or).fromArray(this.elements)}copy(e){const t=this.elements,s=e.elements;return t[0]=s[0],t[1]=s[1],t[2]=s[2],t[3]=s[3],t[4]=s[4],t[5]=s[5],t[6]=s[6],t[7]=s[7],t[8]=s[8],t[9]=s[9],t[10]=s[10],t[11]=s[11],t[12]=s[12],t[13]=s[13],t[14]=s[14],t[15]=s[15],this}copyPosition(e){const t=this.elements,s=e.elements;return t[12]=s[12],t[13]=s[13],t[14]=s[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,s){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(e,t,s){return this.set(e.x,t.x,s.x,0,e.y,t.y,s.y,0,e.z,t.z,s.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,s=e.elements,i=1/ar.setFromMatrixColumn(e,0).length(),r=1/ar.setFromMatrixColumn(e,1).length(),n=1/ar.setFromMatrixColumn(e,2).length();return t[0]=s[0]*i,t[1]=s[1]*i,t[2]=s[2]*i,t[3]=0,t[4]=s[4]*r,t[5]=s[5]*r,t[6]=s[6]*r,t[7]=0,t[8]=s[8]*n,t[9]=s[9]*n,t[10]=s[10]*n,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,s=e.x,i=e.y,r=e.z,n=Math.cos(s),o=Math.sin(s),a=Math.cos(i),h=Math.sin(i),l=Math.cos(r),u=Math.sin(r);if("XYZ"===e.order){const e=n*l,s=n*u,i=o*l,r=o*u;t[0]=a*l,t[4]=-a*u,t[8]=h,t[1]=s+i*h,t[5]=e-r*h,t[9]=-o*a,t[2]=r-e*h,t[6]=i+s*h,t[10]=n*a}else if("YXZ"===e.order){const e=a*l,s=a*u,i=h*l,r=h*u;t[0]=e+r*o,t[4]=i*o-s,t[8]=n*h,t[1]=n*u,t[5]=n*l,t[9]=-o,t[2]=s*o-i,t[6]=r+e*o,t[10]=n*a}else if("ZXY"===e.order){const e=a*l,s=a*u,i=h*l,r=h*u;t[0]=e-r*o,t[4]=-n*u,t[8]=i+s*o,t[1]=s+i*o,t[5]=n*l,t[9]=r-e*o,t[2]=-n*h,t[6]=o,t[10]=n*a}else if("ZYX"===e.order){const e=n*l,s=n*u,i=o*l,r=o*u;t[0]=a*l,t[4]=i*h-s,t[8]=e*h+r,t[1]=a*u,t[5]=r*h+e,t[9]=s*h-i,t[2]=-h,t[6]=o*a,t[10]=n*a}else if("YZX"===e.order){const e=n*a,s=n*h,i=o*a,r=o*h;t[0]=a*l,t[4]=r-e*u,t[8]=i*u+s,t[1]=u,t[5]=n*l,t[9]=-o*l,t[2]=-h*l,t[6]=s*u+i,t[10]=e-r*u}else if("XZY"===e.order){const e=n*a,s=n*h,i=o*a,r=o*h;t[0]=a*l,t[4]=-u,t[8]=h*l,t[1]=e*u+r,t[5]=n*l,t[9]=s*u-i,t[2]=i*u-s,t[6]=o*l,t[10]=r*u+e}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(lr,e,ur)}lookAt(e,t,s){const i=this.elements;return pr.subVectors(e,t),0===pr.lengthSq()&&(pr.z=1),pr.normalize(),cr.crossVectors(s,pr),0===cr.lengthSq()&&(1===Math.abs(s.z)?pr.x+=1e-4:pr.z+=1e-4,pr.normalize(),cr.crossVectors(s,pr)),cr.normalize(),dr.crossVectors(pr,cr),i[0]=cr.x,i[4]=dr.x,i[8]=pr.x,i[1]=cr.y,i[5]=dr.y,i[9]=pr.y,i[2]=cr.z,i[6]=dr.z,i[10]=pr.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const s=e.elements,i=t.elements,r=this.elements,n=s[0],o=s[4],a=s[8],h=s[12],l=s[1],u=s[5],c=s[9],d=s[13],p=s[2],m=s[6],g=s[10],f=s[14],y=s[3],x=s[7],b=s[11],v=s[15],T=i[0],_=i[4],w=i[8],S=i[12],M=i[1],A=i[5],N=i[9],R=i[13],C=i[2],E=i[6],B=i[10],I=i[14],P=i[3],F=i[7],z=i[11],U=i[15];return r[0]=n*T+o*M+a*C+h*P,r[4]=n*_+o*A+a*E+h*F,r[8]=n*w+o*N+a*B+h*z,r[12]=n*S+o*R+a*I+h*U,r[1]=l*T+u*M+c*C+d*P,r[5]=l*_+u*A+c*E+d*F,r[9]=l*w+u*N+c*B+d*z,r[13]=l*S+u*R+c*I+d*U,r[2]=p*T+m*M+g*C+f*P,r[6]=p*_+m*A+g*E+f*F,r[10]=p*w+m*N+g*B+f*z,r[14]=p*S+m*R+g*I+f*U,r[3]=y*T+x*M+b*C+v*P,r[7]=y*_+x*A+b*E+v*F,r[11]=y*w+x*N+b*B+v*z,r[15]=y*S+x*R+b*I+v*U,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],s=e[4],i=e[8],r=e[12],n=e[1],o=e[5],a=e[9],h=e[13],l=e[2],u=e[6],c=e[10],d=e[14];return e[3]*(+r*a*u-i*h*u-r*o*c+s*h*c+i*o*d-s*a*d)+e[7]*(+t*a*d-t*h*c+r*n*c-i*n*d+i*h*l-r*a*l)+e[11]*(+t*h*u-t*o*d-r*n*u+s*n*d+r*o*l-s*h*l)+e[15]*(-i*o*l-t*a*u+t*o*c+i*n*u-s*n*c+s*a*l)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,s){const i=this.elements;return e.isVector3?(i[12]=e.x,i[13]=e.y,i[14]=e.z):(i[12]=e,i[13]=t,i[14]=s),this}invert(){const e=this.elements,t=e[0],s=e[1],i=e[2],r=e[3],n=e[4],o=e[5],a=e[6],h=e[7],l=e[8],u=e[9],c=e[10],d=e[11],p=e[12],m=e[13],g=e[14],f=e[15],y=u*g*h-m*c*h+m*a*d-o*g*d-u*a*f+o*c*f,x=p*c*h-l*g*h-p*a*d+n*g*d+l*a*f-n*c*f,b=l*m*h-p*u*h+p*o*d-n*m*d-l*o*f+n*u*f,v=p*u*a-l*m*a-p*o*c+n*m*c+l*o*g-n*u*g,T=t*y+s*x+i*b+r*v;if(0===T)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const _=1/T;return e[0]=y*_,e[1]=(m*c*r-u*g*r-m*i*d+s*g*d+u*i*f-s*c*f)*_,e[2]=(o*g*r-m*a*r+m*i*h-s*g*h-o*i*f+s*a*f)*_,e[3]=(u*a*r-o*c*r-u*i*h+s*c*h+o*i*d-s*a*d)*_,e[4]=x*_,e[5]=(l*g*r-p*c*r+p*i*d-t*g*d-l*i*f+t*c*f)*_,e[6]=(p*a*r-n*g*r-p*i*h+t*g*h+n*i*f-t*a*f)*_,e[7]=(n*c*r-l*a*r+l*i*h-t*c*h-n*i*d+t*a*d)*_,e[8]=b*_,e[9]=(p*u*r-l*m*r-p*s*d+t*m*d+l*s*f-t*u*f)*_,e[10]=(n*m*r-p*o*r+p*s*h-t*m*h-n*s*f+t*o*f)*_,e[11]=(l*o*r-n*u*r-l*s*h+t*u*h+n*s*d-t*o*d)*_,e[12]=v*_,e[13]=(l*m*i-p*u*i+p*s*c-t*m*c-l*s*g+t*u*g)*_,e[14]=(p*o*i-n*m*i-p*s*a+t*m*a+n*s*g-t*o*g)*_,e[15]=(n*u*i-l*o*i+l*s*a-t*u*a-n*s*c+t*o*c)*_,this}scale(e){const t=this.elements,s=e.x,i=e.y,r=e.z;return t[0]*=s,t[4]*=i,t[8]*=r,t[1]*=s,t[5]*=i,t[9]*=r,t[2]*=s,t[6]*=i,t[10]*=r,t[3]*=s,t[7]*=i,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],s=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],i=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,s,i))}makeTranslation(e,t,s){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,s,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),s=Math.sin(e);return this.set(1,0,0,0,0,t,-s,0,0,s,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,0,s,0,0,1,0,0,-s,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),s=Math.sin(e);return this.set(t,-s,0,0,s,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const s=Math.cos(t),i=Math.sin(t),r=1-s,n=e.x,o=e.y,a=e.z,h=r*n,l=r*o;return this.set(h*n+s,h*o-i*a,h*a+i*o,0,h*o+i*a,l*o+s,l*a-i*n,0,h*a-i*o,l*a+i*n,r*a*a+s,0,0,0,0,1),this}makeScale(e,t,s){return this.set(e,0,0,0,0,t,0,0,0,0,s,0,0,0,0,1),this}makeShear(e,t,s,i,r,n){return this.set(1,s,r,0,e,1,n,0,t,i,1,0,0,0,0,1),this}compose(e,t,s){const i=this.elements,r=t._x,n=t._y,o=t._z,a=t._w,h=r+r,l=n+n,u=o+o,c=r*h,d=r*l,p=r*u,m=n*l,g=n*u,f=o*u,y=a*h,x=a*l,b=a*u,v=s.x,T=s.y,_=s.z;return i[0]=(1-(m+f))*v,i[1]=(d+b)*v,i[2]=(p-x)*v,i[3]=0,i[4]=(d-b)*T,i[5]=(1-(c+f))*T,i[6]=(g+y)*T,i[7]=0,i[8]=(p+x)*_,i[9]=(g-y)*_,i[10]=(1-(c+m))*_,i[11]=0,i[12]=e.x,i[13]=e.y,i[14]=e.z,i[15]=1,this}decompose(e,t,s){const i=this.elements;let r=ar.set(i[0],i[1],i[2]).length();const n=ar.set(i[4],i[5],i[6]).length(),o=ar.set(i[8],i[9],i[10]).length();this.determinant()<0&&(r=-r),e.x=i[12],e.y=i[13],e.z=i[14],hr.copy(this);const a=1/r,h=1/n,l=1/o;return hr.elements[0]*=a,hr.elements[1]*=a,hr.elements[2]*=a,hr.elements[4]*=h,hr.elements[5]*=h,hr.elements[6]*=h,hr.elements[8]*=l,hr.elements[9]*=l,hr.elements[10]*=l,t.setFromRotationMatrix(hr),s.x=r,s.y=n,s.z=o,this}makePerspective(e,t,s,i,r,n,o=2e3){const a=this.elements,h=2*r/(t-e),l=2*r/(s-i),u=(t+e)/(t-e),c=(s+i)/(s-i);let d,p;if(o===Vs)d=-(n+r)/(n-r),p=-2*n*r/(n-r);else{if(o!==Ds)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);d=-n/(n-r),p=-n*r/(n-r)}return a[0]=h,a[4]=0,a[8]=u,a[12]=0,a[1]=0,a[5]=l,a[9]=c,a[13]=0,a[2]=0,a[6]=0,a[10]=d,a[14]=p,a[3]=0,a[7]=0,a[11]=-1,a[15]=0,this}makeOrthographic(e,t,s,i,r,n,o=2e3){const a=this.elements,h=1/(t-e),l=1/(s-i),u=1/(n-r),c=(t+e)*h,d=(s+i)*l;let p,m;if(o===Vs)p=(n+r)*u,m=-2*u;else{if(o!==Ds)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);p=r*u,m=-1*u}return a[0]=2*h,a[4]=0,a[8]=0,a[12]=-c,a[1]=0,a[5]=2*l,a[9]=0,a[13]=-d,a[2]=0,a[6]=0,a[10]=m,a[14]=-p,a[3]=0,a[7]=0,a[11]=0,a[15]=1,this}equals(e){const t=this.elements,s=e.elements;for(let e=0;e<16;e++)if(t[e]!==s[e])return!1;return!0}fromArray(e,t=0){for(let s=0;s<16;s++)this.elements[s]=e[s+t];return this}toArray(e=[],t=0){const s=this.elements;return e[t]=s[0],e[t+1]=s[1],e[t+2]=s[2],e[t+3]=s[3],e[t+4]=s[4],e[t+5]=s[5],e[t+6]=s[6],e[t+7]=s[7],e[t+8]=s[8],e[t+9]=s[9],e[t+10]=s[10],e[t+11]=s[11],e[t+12]=s[12],e[t+13]=s[13],e[t+14]=s[14],e[t+15]=s[15],e}}const ar=new Ei,hr=new or,lr=new Ei(0,0,0),ur=new Ei(1,1,1),cr=new Ei,dr=new Ei,pr=new Ei,mr=new or,gr=new Ci;class fr{constructor(e=0,t=0,s=0,i=fr.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=s,this._order=i}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,s,i=this._order){return this._x=e,this._y=t,this._z=s,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,s=!0){const i=e.elements,r=i[0],n=i[4],o=i[8],a=i[1],h=i[5],l=i[9],u=i[2],c=i[6],d=i[10];switch(t){case"XYZ":this._y=Math.asin($s(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-l,d),this._z=Math.atan2(-n,r)):(this._x=Math.atan2(c,h),this._z=0);break;case"YXZ":this._x=Math.asin(-$s(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(o,d),this._z=Math.atan2(a,h)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin($s(c,-1,1)),Math.abs(c)<.9999999?(this._y=Math.atan2(-u,d),this._z=Math.atan2(-n,h)):(this._y=0,this._z=Math.atan2(a,r));break;case"ZYX":this._y=Math.asin(-$s(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(c,d),this._z=Math.atan2(a,r)):(this._x=0,this._z=Math.atan2(-n,h));break;case"YZX":this._z=Math.asin($s(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-l,h),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(o,d));break;case"XZY":this._z=Math.asin(-$s(n,-1,1)),Math.abs(n)<.9999999?(this._x=Math.atan2(c,h),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-l,d),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,!0===s&&this._onChangeCallback(),this}setFromQuaternion(e,t,s){return mr.makeRotationFromQuaternion(e),this.setFromRotationMatrix(mr,t,s)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return gr.setFromEuler(this),this.setFromQuaternion(gr,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}fr.DEFAULT_ORDER="XYZ";class yr{constructor(){this.mask=1}set(e){this.mask=(1<>>0}enable(e){this.mask|=1<1){for(let e=0;e1){for(let e=0;e0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),!1===this.matrixAutoUpdate&&(i.matrixAutoUpdate=!1),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),null!==this.instanceColor&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.visibility=this._visibility,i.active=this._active,i.bounds=this._bounds.map((e=>({boxInitialized:e.boxInitialized,boxMin:e.box.min.toArray(),boxMax:e.box.max.toArray(),sphereInitialized:e.sphereInitialized,sphereRadius:e.sphere.radius,sphereCenter:e.sphere.center.toArray()}))),i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.geometryCount=this._geometryCount,i.matricesTexture=this._matricesTexture.toJSON(e),null!==this._colorsTexture&&(i.colorsTexture=this._colorsTexture.toJSON(e)),null!==this.boundingSphere&&(i.boundingSphere={center:i.boundingSphere.center.toArray(),radius:i.boundingSphere.radius}),null!==this.boundingBox&&(i.boundingBox={min:i.boundingBox.min.toArray(),max:i.boundingBox.max.toArray()})),this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&!0!==this.environment.isRenderTargetTexture&&(i.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(e.geometries,this.geometry);const t=this.geometry.parameters;if(void 0!==t&&void 0!==t.shapes){const s=t.shapes;if(Array.isArray(s))for(let t=0,i=s.length;t0){i.children=[];for(let t=0;t0){i.animations=[];for(let t=0;t0&&(s.geometries=t),i.length>0&&(s.materials=i),r.length>0&&(s.textures=r),o.length>0&&(s.images=o),a.length>0&&(s.shapes=a),h.length>0&&(s.skeletons=h),l.length>0&&(s.animations=l),u.length>0&&(s.nodes=u)}return s.object=i,s;function n(e){const t=[];for(const s in e){const i=e[s];delete i.metadata,t.push(i)}return t}}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(e,t,s,i,r){Fr.subVectors(i,t),zr.subVectors(s,t),Ur.subVectors(e,t);const n=Fr.dot(Fr),o=Fr.dot(zr),a=Fr.dot(Ur),h=zr.dot(zr),l=zr.dot(Ur),u=n*h-o*o;if(0===u)return r.set(0,0,0),null;const c=1/u,d=(h*a-o*l)*c,p=(n*l-o*a)*c;return r.set(1-d-p,p,d)}static containsPoint(e,t,s,i){return null!==this.getBarycoord(e,t,s,i,Lr)&&(Lr.x>=0&&Lr.y>=0&&Lr.x+Lr.y<=1)}static getInterpolation(e,t,s,i,r,n,o,a){return null===this.getBarycoord(e,t,s,i,Lr)?(a.x=0,a.y=0,"z"in a&&(a.z=0),"w"in a&&(a.w=0),null):(a.setScalar(0),a.addScaledVector(r,Lr.x),a.addScaledVector(n,Lr.y),a.addScaledVector(o,Lr.z),a)}static isFrontFacing(e,t,s,i){return Fr.subVectors(s,t),zr.subVectors(e,t),Fr.cross(zr).dot(i)<0}set(e,t,s){return this.a.copy(e),this.b.copy(t),this.c.copy(s),this}setFromPointsAndIndices(e,t,s,i){return this.a.copy(e[t]),this.b.copy(e[s]),this.c.copy(e[i]),this}setFromAttributeAndIndices(e,t,s,i){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,s),this.c.fromBufferAttribute(e,i),this}clone(){return(new this.constructor).copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Fr.subVectors(this.c,this.b),zr.subVectors(this.a,this.b),.5*Fr.cross(zr).length()}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Hr.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Hr.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,s,i,r){return Hr.getInterpolation(e,this.a,this.b,this.c,t,s,i,r)}containsPoint(e){return Hr.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Hr.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const s=this.a,i=this.b,r=this.c;let n,o;Or.subVectors(i,s),Vr.subVectors(r,s),kr.subVectors(e,s);const a=Or.dot(kr),h=Vr.dot(kr);if(a<=0&&h<=0)return t.copy(s);Gr.subVectors(e,i);const l=Or.dot(Gr),u=Vr.dot(Gr);if(l>=0&&u<=l)return t.copy(i);const c=a*u-l*h;if(c<=0&&a>=0&&l<=0)return n=a/(a-l),t.copy(s).addScaledVector(Or,n);Wr.subVectors(e,r);const d=Or.dot(Wr),p=Vr.dot(Wr);if(p>=0&&d<=p)return t.copy(r);const m=d*h-a*p;if(m<=0&&h>=0&&p<=0)return o=h/(h-p),t.copy(s).addScaledVector(Vr,o);const g=l*p-d*u;if(g<=0&&u-l>=0&&d-p>=0)return Dr.subVectors(r,i),o=(u-l)/(u-l+(d-p)),t.copy(i).addScaledVector(Dr,o);const f=1/(g+m+c);return n=m*f,o=c*f,t.copy(s).addScaledVector(Or,n).addScaledVector(Vr,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const jr={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},qr={h:0,s:0,l:0},$r={h:0,s:0,l:0};function Xr(e,t,s){return s<0&&(s+=1),s>1&&(s-=1),s<1/6?e+6*(t-e)*s:s<.5?t:s<2/3?e+6*(t-e)*(2/3-s):e}class Yr{constructor(e,t,s){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,s)}set(e,t,s){if(void 0===t&&void 0===s){const t=e;t&&t.isColor?this.copy(t):"number"==typeof t?this.setHex(t):"string"==typeof t&&this.setStyle(t)}else this.setRGB(e,t,s);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Jt){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,di.toWorkingColorSpace(this,t),this}setRGB(e,t,s,i=di.workingColorSpace){return this.r=e,this.g=t,this.b=s,di.toWorkingColorSpace(this,i),this}setHSL(e,t,s,i=di.workingColorSpace){if(e=Xs(e,1),t=$s(t,0,1),s=$s(s,0,1),0===t)this.r=this.g=this.b=s;else{const i=s<=.5?s*(1+t):s+t-s*t,r=2*s-i;this.r=Xr(r,i,e+1/3),this.g=Xr(r,i,e),this.b=Xr(r,i,e-1/3)}return di.toWorkingColorSpace(this,i),this}setStyle(e,t=Jt){function s(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const n=i[1],o=i[2];switch(n){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return s(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return s(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return s(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:console.warn("THREE.Color: Unknown color model "+e)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(e)){const s=i[1],r=s.length;if(3===r)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,t);if(6===r)return this.setHex(parseInt(s,16),t);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Jt){const s=jr[e.toLowerCase()];return void 0!==s?this.setHex(s,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=pi(e.r),this.g=pi(e.g),this.b=pi(e.b),this}copyLinearToSRGB(e){return this.r=mi(e.r),this.g=mi(e.g),this.b=mi(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Jt){return di.fromWorkingColorSpace(Jr.copy(this),e),65536*Math.round($s(255*Jr.r,0,255))+256*Math.round($s(255*Jr.g,0,255))+Math.round($s(255*Jr.b,0,255))}getHexString(e=Jt){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=di.workingColorSpace){di.fromWorkingColorSpace(Jr.copy(this),t);const s=Jr.r,i=Jr.g,r=Jr.b,n=Math.max(s,i,r),o=Math.min(s,i,r);let a,h;const l=(o+n)/2;if(o===n)a=0,h=0;else{const e=n-o;switch(h=l<=.5?e/(n+o):e/(2-n-o),n){case s:a=(i-r)/e+(i0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(void 0!==e)for(const t in e){const s=e[t];if(void 0===s){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const i=this[t];void 0!==i?i&&i.isColor?i.set(s):i&&i.isVector3&&s&&s.isVector3?i.copy(s):this[t]=s:console.warn(`THREE.Material: '${t}' is not a property of THREE.${this.type}.`)}}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{}});const s={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};function i(e){const t=[];for(const s in e){const i=e[s];delete i.metadata,t.push(i)}return t}if(s.uuid=this.uuid,s.type=this.type,""!==this.name&&(s.name=this.name),this.color&&this.color.isColor&&(s.color=this.color.getHex()),void 0!==this.roughness&&(s.roughness=this.roughness),void 0!==this.metalness&&(s.metalness=this.metalness),void 0!==this.sheen&&(s.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(s.sheenColor=this.sheenColor.getHex()),void 0!==this.sheenRoughness&&(s.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(s.emissive=this.emissive.getHex()),void 0!==this.emissiveIntensity&&1!==this.emissiveIntensity&&(s.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(s.specular=this.specular.getHex()),void 0!==this.specularIntensity&&(s.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(s.specularColor=this.specularColor.getHex()),void 0!==this.shininess&&(s.shininess=this.shininess),void 0!==this.clearcoat&&(s.clearcoat=this.clearcoat),void 0!==this.clearcoatRoughness&&(s.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(s.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(s.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(s.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,s.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),void 0!==this.dispersion&&(s.dispersion=this.dispersion),void 0!==this.iridescence&&(s.iridescence=this.iridescence),void 0!==this.iridescenceIOR&&(s.iridescenceIOR=this.iridescenceIOR),void 0!==this.iridescenceThicknessRange&&(s.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(s.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(s.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),void 0!==this.anisotropy&&(s.anisotropy=this.anisotropy),void 0!==this.anisotropyRotation&&(s.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(s.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(s.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(s.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(s.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(s.lightMap=this.lightMap.toJSON(e).uuid,s.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(s.aoMap=this.aoMap.toJSON(e).uuid,s.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(s.bumpMap=this.bumpMap.toJSON(e).uuid,s.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(s.normalMap=this.normalMap.toJSON(e).uuid,s.normalMapType=this.normalMapType,s.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(s.displacementMap=this.displacementMap.toJSON(e).uuid,s.displacementScale=this.displacementScale,s.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(s.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(s.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(s.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(s.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(s.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(s.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(s.envMap=this.envMap.toJSON(e).uuid,void 0!==this.combine&&(s.combine=this.combine)),void 0!==this.envMapRotation&&(s.envMapRotation=this.envMapRotation.toArray()),void 0!==this.envMapIntensity&&(s.envMapIntensity=this.envMapIntensity),void 0!==this.reflectivity&&(s.reflectivity=this.reflectivity),void 0!==this.refractionRatio&&(s.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(s.gradientMap=this.gradientMap.toJSON(e).uuid),void 0!==this.transmission&&(s.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(s.transmissionMap=this.transmissionMap.toJSON(e).uuid),void 0!==this.thickness&&(s.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(s.thicknessMap=this.thicknessMap.toJSON(e).uuid),void 0!==this.attenuationDistance&&this.attenuationDistance!==1/0&&(s.attenuationDistance=this.attenuationDistance),void 0!==this.attenuationColor&&(s.attenuationColor=this.attenuationColor.getHex()),void 0!==this.size&&(s.size=this.size),null!==this.shadowSide&&(s.shadowSide=this.shadowSide),void 0!==this.sizeAttenuation&&(s.sizeAttenuation=this.sizeAttenuation),1!==this.blending&&(s.blending=this.blending),this.side!==c&&(s.side=this.side),!0===this.vertexColors&&(s.vertexColors=!0),this.opacity<1&&(s.opacity=this.opacity),!0===this.transparent&&(s.transparent=!0),this.blendSrc!==C&&(s.blendSrc=this.blendSrc),this.blendDst!==E&&(s.blendDst=this.blendDst),this.blendEquation!==v&&(s.blendEquation=this.blendEquation),null!==this.blendSrcAlpha&&(s.blendSrcAlpha=this.blendSrcAlpha),null!==this.blendDstAlpha&&(s.blendDstAlpha=this.blendDstAlpha),null!==this.blendEquationAlpha&&(s.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(s.blendColor=this.blendColor.getHex()),0!==this.blendAlpha&&(s.blendAlpha=this.blendAlpha),3!==this.depthFunc&&(s.depthFunc=this.depthFunc),!1===this.depthTest&&(s.depthTest=this.depthTest),!1===this.depthWrite&&(s.depthWrite=this.depthWrite),!1===this.colorWrite&&(s.colorWrite=this.colorWrite),255!==this.stencilWriteMask&&(s.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==bs&&(s.stencilFunc=this.stencilFunc),0!==this.stencilRef&&(s.stencilRef=this.stencilRef),255!==this.stencilFuncMask&&(s.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ns&&(s.stencilFail=this.stencilFail),this.stencilZFail!==ns&&(s.stencilZFail=this.stencilZFail),this.stencilZPass!==ns&&(s.stencilZPass=this.stencilZPass),!0===this.stencilWrite&&(s.stencilWrite=this.stencilWrite),void 0!==this.rotation&&0!==this.rotation&&(s.rotation=this.rotation),!0===this.polygonOffset&&(s.polygonOffset=!0),0!==this.polygonOffsetFactor&&(s.polygonOffsetFactor=this.polygonOffsetFactor),0!==this.polygonOffsetUnits&&(s.polygonOffsetUnits=this.polygonOffsetUnits),void 0!==this.linewidth&&1!==this.linewidth&&(s.linewidth=this.linewidth),void 0!==this.dashSize&&(s.dashSize=this.dashSize),void 0!==this.gapSize&&(s.gapSize=this.gapSize),void 0!==this.scale&&(s.scale=this.scale),!0===this.dithering&&(s.dithering=!0),this.alphaTest>0&&(s.alphaTest=this.alphaTest),!0===this.alphaHash&&(s.alphaHash=!0),!0===this.alphaToCoverage&&(s.alphaToCoverage=!0),!0===this.premultipliedAlpha&&(s.premultipliedAlpha=!0),!0===this.forceSinglePass&&(s.forceSinglePass=!0),!0===this.wireframe&&(s.wireframe=!0),this.wireframeLinewidth>1&&(s.wireframeLinewidth=this.wireframeLinewidth),"round"!==this.wireframeLinecap&&(s.wireframeLinecap=this.wireframeLinecap),"round"!==this.wireframeLinejoin&&(s.wireframeLinejoin=this.wireframeLinejoin),!0===this.flatShading&&(s.flatShading=!0),!1===this.visible&&(s.visible=!1),!1===this.toneMapped&&(s.toneMapped=!1),!1===this.fog&&(s.fog=!1),Object.keys(this.userData).length>0&&(s.userData=this.userData),t){const t=i(e.textures),r=i(e.images);t.length>0&&(s.textures=t),r.length>0&&(s.images=r)}return s}clone(){return(new this.constructor).copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let s=null;if(null!==t){const e=t.length;s=new Array(e);for(let i=0;i!==e;++i)s[i]=t[i].clone()}return this.clippingPlanes=s,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}onBuild(){console.warn("Material: onBuild() has been removed.")}}class Qr extends Kr{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Yr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new fr,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const en=tn();function tn(){const e=new ArrayBuffer(4),t=new Float32Array(e),s=new Uint32Array(e),i=new Uint32Array(512),r=new Uint32Array(512);for(let e=0;e<256;++e){const t=e-127;t<-27?(i[e]=0,i[256|e]=32768,r[e]=24,r[256|e]=24):t<-14?(i[e]=1024>>-t-14,i[256|e]=1024>>-t-14|32768,r[e]=-t-1,r[256|e]=-t-1):t<=15?(i[e]=t+15<<10,i[256|e]=t+15<<10|32768,r[e]=13,r[256|e]=13):t<128?(i[e]=31744,i[256|e]=64512,r[e]=24,r[256|e]=24):(i[e]=31744,i[256|e]=64512,r[e]=13,r[256|e]=13)}const n=new Uint32Array(2048),o=new Uint32Array(64),a=new Uint32Array(64);for(let e=1;e<1024;++e){let t=e<<13,s=0;for(;0==(8388608&t);)t<<=1,s-=8388608;t&=-8388609,s+=947912704,n[e]=t|s}for(let e=1024;e<2048;++e)n[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)o[e]=e<<23;o[31]=1199570944,o[32]=2147483648;for(let e=33;e<63;++e)o[e]=2147483648+(e-32<<23);o[63]=3347054592;for(let e=1;e<64;++e)32!==e&&(a[e]=1024);return{floatView:t,uint32View:s,baseTable:i,shiftTable:r,mantissaTable:n,exponentTable:o,offsetTable:a}}function sn(e){Math.abs(e)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),e=$s(e,-65504,65504),en.floatView[0]=e;const t=en.uint32View[0],s=t>>23&511;return en.baseTable[s]+((8388607&t)>>en.shiftTable[s])}function rn(e){const t=e>>10;return en.uint32View[0]=en.mantissaTable[en.offsetTable[t]+(1023&e)]+en.exponentTable[t],en.floatView[0]}const nn={toHalfFloat:sn,fromHalfFloat:rn},on=new Ei,an=new Qs;class hn{constructor(e,t,s=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=e,this.itemSize=t,this.count=void 0!==e?e.length/t:0,this.normalized=s,this.usage=Rs,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=Ie,this.version=0}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}get updateRange(){return ai("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,s){e*=this.itemSize,s*=t.itemSize;for(let i=0,r=this.itemSize;i=0;--t)if(e[t]>=65535)return!0;return!1}(e)?gn:pn)(e,1):this.index=e,this}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return void 0!==this.attributes[e]}addGroup(e,t,s=0){this.groups.push({start:e,count:t,materialIndex:s})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;void 0!==t&&(t.applyMatrix4(e),t.needsUpdate=!0);const s=this.attributes.normal;if(void 0!==s){const t=(new ei).getNormalMatrix(e);s.applyNormalMatrix(t),s.needsUpdate=!0}const i=this.attributes.tangent;return void 0!==i&&(i.transformDirection(e),i.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}applyQuaternion(e){return bn.makeRotationFromQuaternion(e),this.applyMatrix4(bn),this}rotateX(e){return bn.makeRotationX(e),this.applyMatrix4(bn),this}rotateY(e){return bn.makeRotationY(e),this.applyMatrix4(bn),this}rotateZ(e){return bn.makeRotationZ(e),this.applyMatrix4(bn),this}translate(e,t,s){return bn.makeTranslation(e,t,s),this.applyMatrix4(bn),this}scale(e,t,s){return bn.makeScale(e,t,s),this.applyMatrix4(bn),this}lookAt(e){return vn.lookAt(e),vn.updateMatrix(),this.applyMatrix4(vn.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Tn).negate(),this.translate(Tn.x,Tn.y,Tn.z),this}setFromPoints(e){const t=[];for(let s=0,i=e.length;s0&&(e.userData=this.userData),void 0!==this.parameters){const t=this.parameters;for(const s in t)void 0!==t[s]&&(e[s]=t[s]);return e}e.data={attributes:{}};const t=this.index;null!==t&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const s=this.attributes;for(const t in s){const i=s[t];e.data.attributes[t]=i.toJSON(e.data)}const i={};let r=!1;for(const t in this.morphAttributes){const s=this.morphAttributes[t],n=[];for(let t=0,i=s.length;t0&&(i[t]=n,r=!0)}r&&(e.data.morphAttributes=i,e.data.morphTargetsRelative=this.morphTargetsRelative);const n=this.groups;n.length>0&&(e.data.groups=JSON.parse(JSON.stringify(n)));const o=this.boundingSphere;return null!==o&&(e.data.boundingSphere={center:o.center.toArray(),radius:o.radius}),e}clone(){return(new this.constructor).copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const s=e.index;null!==s&&this.setIndex(s.clone(t));const i=e.attributes;for(const e in i){const s=i[e];this.setAttribute(e,s.clone(t))}const r=e.morphAttributes;for(const e in r){const s=[],i=r[e];for(let e=0,r=i.length;e0){const s=e[t[0]];if(void 0!==s){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=s.length;e(e.far-e.near)**2)return}An.copy(r).invert(),Nn.copy(e.ray).applyMatrix4(An),null!==s.boundingBox&&!1===Nn.intersectsBox(s.boundingBox)||this._computeIntersections(e,t,Nn)}}_computeIntersections(e,t,s){let i;const r=this.geometry,n=this.material,o=r.index,a=r.attributes.position,h=r.attributes.uv,l=r.attributes.uv1,u=r.attributes.normal,c=r.groups,d=r.drawRange;if(null!==o)if(Array.isArray(n))for(let r=0,a=c.length;rs.far?null:{distance:l,point:Gn.clone(),object:e}}(e,t,s,i,En,Bn,In,kn);if(u){r&&(zn.fromBufferAttribute(r,a),Un.fromBufferAttribute(r,h),Ln.fromBufferAttribute(r,l),u.uv=Hr.getInterpolation(kn,En,Bn,In,zn,Un,Ln,new Qs)),n&&(zn.fromBufferAttribute(n,a),Un.fromBufferAttribute(n,h),Ln.fromBufferAttribute(n,l),u.uv1=Hr.getInterpolation(kn,En,Bn,In,zn,Un,Ln,new Qs)),o&&(On.fromBufferAttribute(o,a),Vn.fromBufferAttribute(o,h),Dn.fromBufferAttribute(o,l),u.normal=Hr.getInterpolation(kn,En,Bn,In,On,Vn,Dn,new Ei),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const e={a:a,b:h,c:l,normal:new Ei,materialIndex:0};Hr.getNormal(En,Bn,In,e.normal),u.face=e}return u}class jn extends Mn{constructor(e=1,t=1,s=1,i=1,r=1,n=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:s,widthSegments:i,heightSegments:r,depthSegments:n};const o=this;i=Math.floor(i),r=Math.floor(r),n=Math.floor(n);const a=[],h=[],l=[],u=[];let c=0,d=0;function p(e,t,s,i,r,n,p,m,g,f,y){const x=n/g,b=p/f,v=n/2,T=p/2,_=m/2,w=g+1,S=f+1;let M=0,A=0;const N=new Ei;for(let n=0;n0?1:-1,l.push(N.x,N.y,N.z),u.push(a/g),u.push(1-n/f),M+=1}}for(let e=0;e0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const s={};for(const e in this.extensions)!0===this.extensions[e]&&(s[e]=!0);return Object.keys(s).length>0&&(t.extensions=s),t}}class Xn extends Pr{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new or,this.projectionMatrix=new or,this.projectionMatrixInverse=new or,this.coordinateSystem=Vs}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return(new this.constructor).copy(this)}}const Yn=new Ei,Jn=new Qs,Zn=new Qs;class Kn extends Xn{constructor(e=50,t=1,s=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=s,this.far=i,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=null===e.view?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=2*js*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(.5*Hs*this.fov);return.5*this.getFilmHeight()/e}getEffectiveFOV(){return 2*js*Math.atan(Math.tan(.5*Hs*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,s){Yn.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Yn.x,Yn.y).multiplyScalar(-e/Yn.z),Yn.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),s.set(Yn.x,Yn.y).multiplyScalar(-e/Yn.z)}getViewSize(e,t){return this.getViewBounds(e,Jn,Zn),t.subVectors(Zn,Jn)}setViewOffset(e,t,s,i,r,n){this.aspect=e/t,null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=s,this.view.offsetY=i,this.view.width=r,this.view.height=n,this.updateProjectionMatrix()}clearViewOffset(){null!==this.view&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(.5*Hs*this.fov)/this.zoom,s=2*t,i=this.aspect*s,r=-.5*i;const n=this.view;if(null!==this.view&&this.view.enabled){const e=n.fullWidth,o=n.fullHeight;r+=n.offsetX*i/e,t-=n.offsetY*s/o,i*=n.width/e,s*=n.height/o}const o=this.filmOffset;0!==o&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,t,t-s,e,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,null!==this.view&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const Qn=-90;class eo extends Pr{constructor(e,t,s){super(),this.type="CubeCamera",this.renderTarget=s,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new Kn(Qn,1,e,t);i.layers=this.layers,this.add(i);const r=new Kn(Qn,1,e,t);r.layers=this.layers,this.add(r);const n=new Kn(Qn,1,e,t);n.layers=this.layers,this.add(n);const o=new Kn(Qn,1,e,t);o.layers=this.layers,this.add(o);const a=new Kn(Qn,1,e,t);a.layers=this.layers,this.add(a);const h=new Kn(Qn,1,e,t);h.layers=this.layers,this.add(h)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[s,i,r,n,o,a]=t;for(const e of t)this.remove(e);if(e===Vs)s.up.set(0,1,0),s.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),n.up.set(0,0,1),n.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),a.up.set(0,1,0),a.lookAt(0,0,-1);else{if(e!==Ds)throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);s.up.set(0,-1,0),s.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),n.up.set(0,0,-1),n.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),a.up.set(0,-1,0),a.lookAt(0,0,-1)}for(const e of t)this.add(e),e.updateMatrixWorld()}update(e,t){null===this.parent&&this.updateMatrixWorld();const{renderTarget:s,activeMipmapLevel:i}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,n,o,a,h,l]=this.children,u=e.getRenderTarget(),c=e.getActiveCubeFace(),d=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const m=s.texture.generateMipmaps;s.texture.generateMipmaps=!1,e.setRenderTarget(s,0,i),e.render(t,r),e.setRenderTarget(s,1,i),e.render(t,n),e.setRenderTarget(s,2,i),e.render(t,o),e.setRenderTarget(s,3,i),e.render(t,a),e.setRenderTarget(s,4,i),e.render(t,h),s.texture.generateMipmaps=m,e.setRenderTarget(s,5,i),e.render(t,l),e.setRenderTarget(u,c,d),e.xr.enabled=p,s.texture.needsPMREMUpdate=!0}}class to extends Ti{constructor(e,t,s,i,r,n,o,a,h,l){super(e=void 0!==e?e:[],t=void 0!==t?t:he,s,i,r,n,o,a,h,l),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class so extends Si{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const s={width:e,height:e,depth:1},i=[s,s,s,s,s,s];this.texture=new to(i,t.mapping,t.wrapS,t.wrapT,t.magFilter,t.minFilter,t.format,t.type,t.anisotropy,t.colorSpace),this.texture.isRenderTargetTexture=!0,this.texture.generateMipmaps=void 0!==t.generateMipmaps&&t.generateMipmaps,this.texture.minFilter=void 0!==t.minFilter?t.minFilter:Te}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const s={uniforms:{tEquirect:{value:null}},vertexShader:"\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\tvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t\t\t\t\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n\t\t\t\t}\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t\t\t\t\t#include \n\t\t\t\t\t#include \n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\n\t\t\t\tuniform sampler2D tEquirect;\n\n\t\t\t\tvarying vec3 vWorldDirection;\n\n\t\t\t\t#include \n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tvec3 direction = normalize( vWorldDirection );\n\n\t\t\t\t\tvec2 sampleUV = equirectUv( direction );\n\n\t\t\t\t\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\n\t\t\t\t}\n\t\t\t"},i=new jn(5,5,5),r=new $n({name:"CubemapFromEquirect",uniforms:qn(s.uniforms),vertexShader:s.vertexShader,fragmentShader:s.fragmentShader,side:d,blending:m});r.uniforms.tEquirect.value=t;const n=new Wn(i,r),o=t.minFilter;t.minFilter===Se&&(t.minFilter=Te);return new eo(1,10,this).update(e,n),t.minFilter=o,n.geometry.dispose(),n.material.dispose(),this}clear(e,t,s,i){const r=e.getRenderTarget();for(let r=0;r<6;r++)e.setRenderTarget(this,r),e.clear(t,s,i);e.setRenderTarget(r)}}class io{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new Yr(e),this.density=t}clone(){return new io(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class ro{constructor(e,t=1,s=1e3){this.isFog=!0,this.name="",this.color=new Yr(e),this.near=t,this.far=s}clone(){return new ro(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class no extends Pr{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new fr,this.environmentIntensity=1,this.environmentRotation=new fr,this.overrideMaterial=null,"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),null!==e.background&&(this.background=e.background.clone()),null!==e.environment&&(this.environment=e.environment.clone()),null!==e.fog&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),null!==e.overrideMaterial&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return null!==this.fog&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),1!==this.backgroundIntensity&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),1!==this.environmentIntensity&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class oo{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=void 0!==e?e.length/t:0,this.usage=Rs,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.version=0,this.uuid=qs()}onUploadCallback(){}set needsUpdate(e){!0===e&&this.version++}get updateRange(){return ai("THREE.InterleavedBuffer: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,s){e*=this.stride,s*=t.stride;for(let i=0,r=this.stride;ie.far||t.push({distance:a,point:co.clone(),uv:Hr.getInterpolation(co,xo,bo,vo,To,_o,wo,new Qs),face:null,object:this})}copy(e,t){return super.copy(e,t),void 0!==e.center&&this.center.copy(e.center),this.material=e.material,this}}function Mo(e,t,s,i,r,n){go.subVectors(e,s).addScalar(.5).multiply(i),void 0!==r?(fo.x=n*go.x-r*go.y,fo.y=r*go.x+n*go.y):fo.copy(go),e.copy(t),e.x+=fo.x,e.y+=fo.y,e.applyMatrix4(yo)}const Ao=new Ei,No=new Ei;class Ro extends Pr{constructor(){super(),this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]},isLOD:{value:!0}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let e=0,s=t.length;e0){let s,i;for(s=1,i=t.length;s0){Ao.setFromMatrixPosition(this.matrixWorld);const s=e.ray.origin.distanceTo(Ao);this.getObjectForDistance(s).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Ao.setFromMatrixPosition(e.matrixWorld),No.setFromMatrixPosition(this.matrixWorld);const s=Ao.distanceTo(No)/e.zoom;let i,r;for(t[0].object.visible=!0,i=1,r=t.length;i=e))break;t[i-1].object.visible=!1,t[i].object.visible=!0}for(this._currentLevel=i-1;i1?null:t.copy(e.start).addScaledVector(s,r)}intersectsLine(e){const t=this.distanceToPoint(e.start),s=this.distanceToPoint(e.end);return t<0&&s>0||s<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const s=t||ta.getNormalMatrix(e),i=this.coplanarPoint(Qo).applyMatrix4(e),r=this.normal.applyMatrix3(s).normalize();return this.constant=-i.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return(new this.constructor).copy(this)}}const ia=new Zi,ra=new Ei;class na{constructor(e=new sa,t=new sa,s=new sa,i=new sa,r=new sa,n=new sa){this.planes=[e,t,s,i,r,n]}set(e,t,s,i,r,n){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(s),o[3].copy(i),o[4].copy(r),o[5].copy(n),this}copy(e){const t=this.planes;for(let s=0;s<6;s++)t[s].copy(e.planes[s]);return this}setFromProjectionMatrix(e,t=2e3){const s=this.planes,i=e.elements,r=i[0],n=i[1],o=i[2],a=i[3],h=i[4],l=i[5],u=i[6],c=i[7],d=i[8],p=i[9],m=i[10],g=i[11],f=i[12],y=i[13],x=i[14],b=i[15];if(s[0].setComponents(a-r,c-h,g-d,b-f).normalize(),s[1].setComponents(a+r,c+h,g+d,b+f).normalize(),s[2].setComponents(a+n,c+l,g+p,b+y).normalize(),s[3].setComponents(a-n,c-l,g-p,b-y).normalize(),s[4].setComponents(a-o,c-u,g-m,b-x).normalize(),t===Vs)s[5].setComponents(a+o,c+u,g+m,b+x).normalize();else{if(t!==Ds)throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);s[5].setComponents(o,u,m,x).normalize()}return this}intersectsObject(e){if(void 0!==e.boundingSphere)null===e.boundingSphere&&e.computeBoundingSphere(),ia.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;null===t.boundingSphere&&t.computeBoundingSphere(),ia.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(ia)}intersectsSprite(e){return ia.center.set(0,0,0),ia.radius=.7071067811865476,ia.applyMatrix4(e.matrixWorld),this.intersectsSphere(ia)}intersectsSphere(e){const t=this.planes,s=e.center,i=-e.radius;for(let e=0;e<6;e++){if(t[e].distanceToPoint(s)0?e.max.x:e.min.x,ra.y=i.normal.y>0?e.max.y:e.min.y,ra.z=i.normal.z>0?e.max.z:e.min.z,i.distanceToPoint(ra)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let s=0;s<6;s++)if(t[s].distanceToPoint(e)<0)return!1;return!0}clone(){return(new this.constructor).copy(this)}}function oa(e,t){return e.z-t.z}function aa(e,t){return t.z-e.z}class ha{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,s){const i=this.pool,r=this.list;this.index>=i.length&&i.push({start:-1,count:-1,z:-1,index:-1});const n=i[this.index];r.push(n),this.index++,n.start=e.start,n.count=e.count,n.z=t,n.index=s}reset(){this.list.length=0,this.index=0}}const la=new or,ua=new or,ca=new or,da=new Yr(1,1,1),pa=new or,ma=new na,ga=new Pi,fa=new Zi,ya=new Ei,xa=new Ei,ba=new Ei,va=new ha,Ta=new Wn,_a=[];function wa(e,t,s=0){const i=t.itemSize;if(e.isInterleavedBufferAttribute||e.array.constructor!==t.array.constructor){const r=e.count;for(let n=0;n65535?new Uint32Array(i):new Uint16Array(i);t.setIndex(new hn(e,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(Boolean(e.getIndex())!==Boolean(t.getIndex()))throw new Error('BatchedMesh: All geometries must consistently have "index".');for(const s in t.attributes){if(!e.hasAttribute(s))throw new Error(`BatchedMesh: Added geometry missing "${s}". All geometries must have consistent attributes.`);const i=e.getAttribute(s),r=t.getAttribute(s);if(i.itemSize!==r.itemSize||i.normalized!==r.normalized)throw new Error("BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new Pi);const e=this.boundingBox,t=this._drawInfo;e.makeEmpty();for(let s=0,i=t.length;s=this._maxInstanceCount)throw new Error("BatchedMesh: Maximum item count reached.");this._drawInfo.push({visible:!0,active:!0,geometryIndex:e});const t=this._drawInfo.length-1,s=this._matricesTexture,i=s.image.data;ca.toArray(i,16*t),s.needsUpdate=!0;const r=this._colorsTexture;return r&&(da.toArray(r.image.data,4*t),r.needsUpdate=!0),t}addGeometry(e,t=-1,s=-1){if(this._initializeGeometry(e),this._validateGeometry(e),this._drawInfo.length>=this._maxInstanceCount)throw new Error("BatchedMesh: Maximum item count reached.");const i={vertexStart:-1,vertexCount:-1,indexStart:-1,indexCount:-1};let r=null;const n=this._reservedRanges,o=this._drawRanges,a=this._bounds;0!==this._geometryCount&&(r=n[n.length-1]),i.vertexCount=-1===t?e.getAttribute("position").count:t,i.vertexStart=null===r?0:r.vertexStart+r.vertexCount;const h=e.getIndex(),l=null!==h;if(l&&(i.indexCount=-1===s?h.count:s,i.indexStart=null===r?0:r.indexStart+r.indexCount),-1!==i.indexStart&&i.indexStart+i.indexCount>this._maxIndexCount||i.vertexStart+i.vertexCount>this._maxVertexCount)throw new Error("BatchedMesh: Reserved space request exceeds the maximum buffer size.");const u=this._geometryCount;return this._geometryCount++,n.push(i),o.push({start:l?i.indexStart:i.vertexStart,count:-1}),a.push({boxInitialized:!1,box:new Pi,sphereInitialized:!1,sphere:new Zi}),this.setGeometryAt(u,e),u}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const s=this.geometry,i=null!==s.getIndex(),r=s.getIndex(),n=t.getIndex(),o=this._reservedRanges[e];if(i&&n.count>o.indexCount||t.attributes.position.count>o.vertexCount)throw new Error("BatchedMesh: Reserved space not large enough for provided geometry.");const a=o.vertexStart,h=o.vertexCount;for(const e in s.attributes){const i=t.getAttribute(e),r=s.getAttribute(e);wa(i,r,a);const n=i.itemSize;for(let e=i.count,t=h;e=this._geometryCount)return null;const s=this._bounds[e],i=s.box,r=this.geometry;if(!1===s.boxInitialized){i.makeEmpty();const t=r.index,n=r.attributes.position,o=this._drawRanges[e];for(let e=o.start,s=o.start+o.count;e=this._geometryCount)return null;const s=this._bounds[e],i=s.sphere,r=this.geometry;if(!1===s.sphereInitialized){i.makeEmpty(),this.getBoundingBoxAt(e,ga),ga.getCenter(i.center);const t=r.index,n=r.attributes.position,o=this._drawRanges[e];let a=0;for(let e=o.start,s=o.start+o.count;e=s.length||!1===s[e].active||(t.toArray(r,16*e),i.needsUpdate=!0),this}getMatrixAt(e,t){const s=this._drawInfo,i=this._matricesTexture.image.data;return e>=s.length||!1===s[e].active?null:t.fromArray(i,16*e)}setColorAt(e,t){null===this._colorsTexture&&this._initColorsTexture();const s=this._colorsTexture,i=this._colorsTexture.image.data,r=this._drawInfo;return e>=r.length||!1===r[e].active||(t.toArray(i,4*e),s.needsUpdate=!0),this}getColorAt(e,t){const s=this._colorsTexture.image.data,i=this._drawInfo;return e>=i.length||!1===i[e].active?null:t.fromArray(s,4*e)}setVisibleAt(e,t){const s=this._drawInfo;return e>=s.length||!1===s[e].active||s[e].visible===t||(s[e].visible=t,this._visibilityChanged=!0),this}getVisibleAt(e){const t=this._drawInfo;return!(e>=t.length||!1===t[e].active)&&t[e].visible}raycast(e,t){const s=this._drawInfo,i=this._drawRanges,r=this.matrixWorld,n=this.geometry;Ta.material=this.material,Ta.geometry.index=n.index,Ta.geometry.attributes=n.attributes,null===Ta.geometry.boundingBox&&(Ta.geometry.boundingBox=new Pi),null===Ta.geometry.boundingSphere&&(Ta.geometry.boundingSphere=new Zi);for(let n=0,o=s.length;n({...e}))),this._reservedRanges=e._reservedRanges.map((e=>({...e}))),this._drawInfo=e._drawInfo.map((e=>({...e}))),this._bounds=e._bounds.map((e=>({boxInitialized:e.boxInitialized,box:e.box.clone(),sphereInitialized:e.sphereInitialized,sphere:e.sphere.clone()}))),this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._geometryCount=e._geometryCount,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),null!==this._colorsTexture&&(this._colorsTexture=e._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){return this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,null!==this._colorsTexture&&(this._colorsTexture.dispose(),this._colorsTexture=null),this}onBeforeRender(e,t,s,i,r){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const n=i.getIndex(),o=null===n?1:n.array.BYTES_PER_ELEMENT,a=this._drawInfo,h=this._multiDrawStarts,l=this._multiDrawCounts,u=this._drawRanges,c=this.perObjectFrustumCulled,d=this._indirectTexture,p=d.image.data;c&&(pa.multiplyMatrices(s.projectionMatrix,s.matrixWorldInverse).multiply(this.matrixWorld),ma.setFromProjectionMatrix(pa,e.coordinateSystem));let m=0;if(this.sortObjects){ua.copy(this.matrixWorld).invert(),ya.setFromMatrixPosition(s.matrixWorld).applyMatrix4(ua),xa.set(0,0,-1).transformDirection(s.matrixWorld).transformDirection(ua);for(let e=0,t=a.length;e0){const s=e[t[0]];if(void 0!==s){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=s.length;ei)return;Ba.applyMatrix4(e.matrixWorld);const a=t.ray.origin.distanceTo(Ba);return at.far?void 0:{distance:a,point:Ia.clone().applyMatrix4(e.matrixWorld),index:r,face:null,faceIndex:null,object:e}}const za=new Ei,Ua=new Ei;class La extends Pa{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(null===e.index){const t=e.attributes.position,s=[];for(let e=0,i=t.count;e0){const s=e[t[0]];if(void 0!==s){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let e=0,t=s.length;er.far)return;n.push({distance:h,distanceToRay:Math.sqrt(a),point:s,index:t,face:null,object:o})}}class qa extends Pr{constructor(){super(),this.isGroup=!0,this.type="Group"}}class $a extends Ti{constructor(e,t,s,i,r,n,o,a,h){super(e,t,s,i,r,n,o,a,h),this.isVideoTexture=!0,this.minFilter=void 0!==n?n:Te,this.magFilter=void 0!==r?r:Te,this.generateMipmaps=!1;const l=this;"requestVideoFrameCallback"in e&&e.requestVideoFrameCallback((function t(){l.needsUpdate=!0,e.requestVideoFrameCallback(t)}))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;!1==="requestVideoFrameCallback"in e&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}}class Xa extends Ti{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=fe,this.minFilter=fe,this.generateMipmaps=!1,this.needsUpdate=!0}}class Ya extends Ti{constructor(e,t,s,i,r,n,o,a,h,l,u,c){super(null,n,o,a,h,l,i,r,u,c),this.isCompressedTexture=!0,this.image={width:t,height:s},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class Ja extends Ya{constructor(e,t,s,i,r,n){super(e,t,s,r,n),this.isCompressedArrayTexture=!0,this.image.depth=i,this.wrapR=me,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class Za extends Ya{constructor(e,t,s){super(void 0,e[0].width,e[0].height,t,s,he),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class Ka extends Ti{constructor(e,t,s,i,r,n,o,a,h){super(e,t,s,i,r,n,o,a,h),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Qa extends Ti{constructor(e,t,s,i,r,n,o,a,h,l=1026){if(l!==We&&l!==He)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===s&&l===We&&(s=Be),void 0===s&&l===He&&(s=Ue),super(null,i,r,n,o,a,l,s,h),this.isDepthTexture=!0,this.image={width:e,height:t},this.magFilter=void 0!==o?o:fe,this.minFilter=void 0!==a?a:fe,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return null!==this.compareFunction&&(t.compareFunction=this.compareFunction),t}}class eh{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(e,t){const s=this.getUtoTmapping(e);return this.getPoint(s,t)}getPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPoint(s/e));return t}getSpacedPoints(e=5){const t=[];for(let s=0;s<=e;s++)t.push(this.getPointAt(s/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let s,i=this.getPoint(0),r=0;t.push(0);for(let n=1;n<=e;n++)s=this.getPoint(n/e),r+=s.distanceTo(i),t.push(r),i=s;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t){const s=this.getLengths();let i=0;const r=s.length;let n;n=t||e*s[r-1];let o,a=0,h=r-1;for(;a<=h;)if(i=Math.floor(a+(h-a)/2),o=s[i]-n,o<0)a=i+1;else{if(!(o>0)){h=i;break}h=i-1}if(i=h,s[i]===n)return i/(r-1);const l=s[i];return(i+(n-l)/(s[i+1]-l))/(r-1)}getTangent(e,t){const s=1e-4;let i=e-s,r=e+s;i<0&&(i=0),r>1&&(r=1);const n=this.getPoint(i),o=this.getPoint(r),a=t||(n.isVector2?new Qs:new Ei);return a.copy(o).sub(n).normalize(),a}getTangentAt(e,t){const s=this.getUtoTmapping(e);return this.getTangent(s,t)}computeFrenetFrames(e,t){const s=new Ei,i=[],r=[],n=[],o=new Ei,a=new or;for(let t=0;t<=e;t++){const s=t/e;i[t]=this.getTangentAt(s,new Ei)}r[0]=new Ei,n[0]=new Ei;let h=Number.MAX_VALUE;const l=Math.abs(i[0].x),u=Math.abs(i[0].y),c=Math.abs(i[0].z);l<=h&&(h=l,s.set(1,0,0)),u<=h&&(h=u,s.set(0,1,0)),c<=h&&s.set(0,0,1),o.crossVectors(i[0],s).normalize(),r[0].crossVectors(i[0],o),n[0].crossVectors(i[0],r[0]);for(let t=1;t<=e;t++){if(r[t]=r[t-1].clone(),n[t]=n[t-1].clone(),o.crossVectors(i[t-1],i[t]),o.length()>Number.EPSILON){o.normalize();const e=Math.acos($s(i[t-1].dot(i[t]),-1,1));r[t].applyMatrix4(a.makeRotationAxis(o,e))}n[t].crossVectors(i[t],r[t])}if(!0===t){let t=Math.acos($s(r[0].dot(r[e]),-1,1));t/=e,i[0].dot(o.crossVectors(r[0],r[e]))>0&&(t=-t);for(let s=1;s<=e;s++)r[s].applyMatrix4(a.makeRotationAxis(i[s],t*s)),n[s].crossVectors(i[s],r[s])}return{tangents:i,normals:r,binormals:n}}clone(){return(new this.constructor).copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class th extends eh{constructor(e=0,t=0,s=1,i=1,r=0,n=2*Math.PI,o=!1,a=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=s,this.yRadius=i,this.aStartAngle=r,this.aEndAngle=n,this.aClockwise=o,this.aRotation=a}getPoint(e,t=new Qs){const s=t,i=2*Math.PI;let r=this.aEndAngle-this.aStartAngle;const n=Math.abs(r)i;)r-=i;r0?0:(Math.floor(Math.abs(h)/r)+1)*r:0===l&&h===r-1&&(h=r-2,l=1),this.closed||h>0?o=i[(h-1)%r]:(rh.subVectors(i[0],i[1]).add(i[0]),o=rh);const u=i[h%r],c=i[(h+1)%r];if(this.closed||h+2i.length-2?i.length-1:n+1],u=i[n>i.length-3?i.length-1:n+2];return s.set(lh(o,a.x,h.x,l.x,u.x),lh(o,a.y,h.y,l.y,u.y)),s}copy(e){super.copy(e),this.points=[];for(let t=0,s=e.points.length;t=s){const e=i[r]-s,n=this.curves[r],o=n.getLength(),a=0===o?0:1-e/o;return n.getPointAt(a,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let s=0,i=this.curves.length;s1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,s=e.curves.length;t0){const e=h.getPoint(0);e.equals(this.currentPoint)||this.lineTo(e.x,e.y)}this.curves.push(h);const l=h.getPoint(1);return this.currentPoint.copy(l),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class _h extends Mn{constructor(e=[new Qs(0,-.5),new Qs(.5,0),new Qs(0,.5)],t=12,s=0,i=2*Math.PI){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:s,phiLength:i},t=Math.floor(t),i=$s(i,0,2*Math.PI);const r=[],n=[],o=[],a=[],h=[],l=1/t,u=new Ei,c=new Qs,d=new Ei,p=new Ei,m=new Ei;let g=0,f=0;for(let t=0;t<=e.length-1;t++)switch(t){case 0:g=e[t+1].x-e[t].x,f=e[t+1].y-e[t].y,d.x=1*f,d.y=-g,d.z=0*f,m.copy(d),d.normalize(),a.push(d.x,d.y,d.z);break;case e.length-1:a.push(m.x,m.y,m.z);break;default:g=e[t+1].x-e[t].x,f=e[t+1].y-e[t].y,d.x=1*f,d.y=-g,d.z=0*f,p.copy(d),d.x+=m.x,d.y+=m.y,d.z+=m.z,d.normalize(),a.push(d.x,d.y,d.z),m.copy(p)}for(let r=0;r<=t;r++){const d=s+r*l*i,p=Math.sin(d),m=Math.cos(d);for(let s=0;s<=e.length-1;s++){u.x=e[s].x*p,u.y=e[s].y,u.z=e[s].x*m,n.push(u.x,u.y,u.z),c.x=r/t,c.y=s/(e.length-1),o.push(c.x,c.y);const i=a[3*s+0]*p,l=a[3*s+1],d=a[3*s+0]*m;h.push(i,l,d)}}for(let s=0;s0&&y(!0),t>0&&y(!1)),this.setIndex(l),this.setAttribute("position",new yn(u,3)),this.setAttribute("normal",new yn(c,3)),this.setAttribute("uv",new yn(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Mh(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Ah extends Mh{constructor(e=1,t=1,s=32,i=1,r=!1,n=0,o=2*Math.PI){super(0,e,t,s,i,r,n,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:s,heightSegments:i,openEnded:r,thetaStart:n,thetaLength:o}}static fromJSON(e){return new Ah(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Nh extends Mn{constructor(e=[],t=[],s=1,i=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:s,detail:i};const r=[],n=[];function o(e,t,s,i){const r=i+1,n=[];for(let i=0;i<=r;i++){n[i]=[];const o=e.clone().lerp(s,i/r),a=t.clone().lerp(s,i/r),h=r-i;for(let e=0;e<=h;e++)n[i][e]=0===e&&i===r?o:o.clone().lerp(a,e/h)}for(let e=0;e.9&&o<.1&&(t<.2&&(n[e+0]+=1),s<.2&&(n[e+2]+=1),i<.2&&(n[e+4]+=1))}}()}(),this.setAttribute("position",new yn(r,3)),this.setAttribute("normal",new yn(r.slice(),3)),this.setAttribute("uv",new yn(n,2)),0===i?this.computeVertexNormals():this.normalizeNormals()}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Nh(e.vertices,e.indices,e.radius,e.details)}}class Rh extends Nh{constructor(e=1,t=0){const s=(1+Math.sqrt(5))/2,i=1/s;super([-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-i,-s,0,-i,s,0,i,-s,0,i,s,-i,-s,0,-i,s,0,i,-s,0,i,s,0,-s,0,-i,s,0,-i,-s,0,i,s,0,i],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Rh(e.radius,e.detail)}}const Ch=new Ei,Eh=new Ei,Bh=new Ei,Ih=new Hr;class Ph extends Mn{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},null!==e){const s=4,i=Math.pow(10,s),r=Math.cos(Hs*t),n=e.getIndex(),o=e.getAttribute("position"),a=n?n.count:o.count,h=[0,0,0],l=["a","b","c"],u=new Array(3),c={},d=[];for(let e=0;e80*s){a=l=e[0],h=u=e[1];for(let t=s;tl&&(l=c),d>u&&(u=d);p=Math.max(l-a,u-h),p=0!==p?32767/p:0}return Oh(n,o,s,a,h,p,0),o};function Uh(e,t,s,i,r){let n,o;if(r===function(e,t,s,i){let r=0;for(let n=t,o=s-i;n0)for(n=t;n=t;n-=i)o=il(n,e[n],e[n+1],o);return o&&Zh(o,o.next)&&(rl(o),o=o.next),o}function Lh(e,t){if(!e)return e;t||(t=e);let s,i=e;do{if(s=!1,i.steiner||!Zh(i,i.next)&&0!==Jh(i.prev,i,i.next))i=i.next;else{if(rl(i),i=t=i.prev,i===i.next)break;s=!0}}while(s||i!==t);return t}function Oh(e,t,s,i,r,n,o){if(!e)return;!o&&n&&function(e,t,s,i){let r=e;do{0===r.z&&(r.z=qh(r.x,r.y,t,s,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==e);r.prevZ.nextZ=null,r.prevZ=null,function(e){let t,s,i,r,n,o,a,h,l=1;do{for(s=e,e=null,n=null,o=0;s;){for(o++,i=s,a=0,t=0;t0||h>0&&i;)0!==a&&(0===h||!i||s.z<=i.z)?(r=s,s=s.nextZ,a--):(r=i,i=i.nextZ,h--),n?n.nextZ=r:e=r,r.prevZ=n,n=r;s=i}n.nextZ=null,l*=2}while(o>1)}(r)}(e,i,r,n);let a,h,l=e;for(;e.prev!==e.next;)if(a=e.prev,h=e.next,n?Dh(e,i,r,n):Vh(e))t.push(a.i/s|0),t.push(e.i/s|0),t.push(h.i/s|0),rl(e),e=h.next,l=h.next;else if((e=h)===l){o?1===o?Oh(e=kh(Lh(e),t,s),t,s,i,r,n,2):2===o&&Gh(e,t,s,i,r,n):Oh(Lh(e),t,s,i,r,n,1);break}}function Vh(e){const t=e.prev,s=e,i=e.next;if(Jh(t,s,i)>=0)return!1;const r=t.x,n=s.x,o=i.x,a=t.y,h=s.y,l=i.y,u=rn?r>o?r:o:n>o?n:o,p=a>h?a>l?a:l:h>l?h:l;let m=i.next;for(;m!==t;){if(m.x>=u&&m.x<=d&&m.y>=c&&m.y<=p&&Xh(r,a,n,h,o,l,m.x,m.y)&&Jh(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Dh(e,t,s,i){const r=e.prev,n=e,o=e.next;if(Jh(r,n,o)>=0)return!1;const a=r.x,h=n.x,l=o.x,u=r.y,c=n.y,d=o.y,p=ah?a>l?a:l:h>l?h:l,f=u>c?u>d?u:d:c>d?c:d,y=qh(p,m,t,s,i),x=qh(g,f,t,s,i);let b=e.prevZ,v=e.nextZ;for(;b&&b.z>=y&&v&&v.z<=x;){if(b.x>=p&&b.x<=g&&b.y>=m&&b.y<=f&&b!==r&&b!==o&&Xh(a,u,h,c,l,d,b.x,b.y)&&Jh(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,v.x>=p&&v.x<=g&&v.y>=m&&v.y<=f&&v!==r&&v!==o&&Xh(a,u,h,c,l,d,v.x,v.y)&&Jh(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;b&&b.z>=y;){if(b.x>=p&&b.x<=g&&b.y>=m&&b.y<=f&&b!==r&&b!==o&&Xh(a,u,h,c,l,d,b.x,b.y)&&Jh(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;v&&v.z<=x;){if(v.x>=p&&v.x<=g&&v.y>=m&&v.y<=f&&v!==r&&v!==o&&Xh(a,u,h,c,l,d,v.x,v.y)&&Jh(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function kh(e,t,s){let i=e;do{const r=i.prev,n=i.next.next;!Zh(r,n)&&Kh(r,i,i.next,n)&&tl(r,n)&&tl(n,r)&&(t.push(r.i/s|0),t.push(i.i/s|0),t.push(n.i/s|0),rl(i),rl(i.next),i=e=n),i=i.next}while(i!==e);return Lh(i)}function Gh(e,t,s,i,r,n){let o=e;do{let e=o.next.next;for(;e!==o.prev;){if(o.i!==e.i&&Yh(o,e)){let a=sl(o,e);return o=Lh(o,o.next),a=Lh(a,a.next),Oh(o,t,s,i,r,n,0),void Oh(a,t,s,i,r,n,0)}e=e.next}o=o.next}while(o!==e)}function Wh(e,t){return e.x-t.x}function Hh(e,t){const s=function(e,t){let s,i=t,r=-1/0;const n=e.x,o=e.y;do{if(o<=i.y&&o>=i.next.y&&i.next.y!==i.y){const e=i.x+(o-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=n&&e>r&&(r=e,s=i.x=i.x&&i.x>=h&&n!==i.x&&Xh(os.x||i.x===s.x&&jh(s,i)))&&(s=i,c=u)),i=i.next}while(i!==a);return s}(e,t);if(!s)return t;const i=sl(s,e);return Lh(i,i.next),Lh(s,s.next)}function jh(e,t){return Jh(e.prev,e,t.prev)<0&&Jh(t.next,e,e.next)<0}function qh(e,t,s,i,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-s)*r|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function $h(e){let t=e,s=e;do{(t.x=(e-o)*(n-a)&&(e-o)*(i-a)>=(s-o)*(t-a)&&(s-o)*(n-a)>=(r-o)*(i-a)}function Yh(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){let s=e;do{if(s.i!==e.i&&s.next.i!==e.i&&s.i!==t.i&&s.next.i!==t.i&&Kh(s,s.next,e,t))return!0;s=s.next}while(s!==e);return!1}(e,t)&&(tl(e,t)&&tl(t,e)&&function(e,t){let s=e,i=!1;const r=(e.x+t.x)/2,n=(e.y+t.y)/2;do{s.y>n!=s.next.y>n&&s.next.y!==s.y&&r<(s.next.x-s.x)*(n-s.y)/(s.next.y-s.y)+s.x&&(i=!i),s=s.next}while(s!==e);return i}(e,t)&&(Jh(e.prev,e,t.prev)||Jh(e,t.prev,t))||Zh(e,t)&&Jh(e.prev,e,e.next)>0&&Jh(t.prev,t,t.next)>0)}function Jh(e,t,s){return(t.y-e.y)*(s.x-t.x)-(t.x-e.x)*(s.y-t.y)}function Zh(e,t){return e.x===t.x&&e.y===t.y}function Kh(e,t,s,i){const r=el(Jh(e,t,s)),n=el(Jh(e,t,i)),o=el(Jh(s,i,e)),a=el(Jh(s,i,t));return r!==n&&o!==a||(!(0!==r||!Qh(e,s,t))||(!(0!==n||!Qh(e,i,t))||(!(0!==o||!Qh(s,e,i))||!(0!==a||!Qh(s,t,i)))))}function Qh(e,t,s){return t.x<=Math.max(e.x,s.x)&&t.x>=Math.min(e.x,s.x)&&t.y<=Math.max(e.y,s.y)&&t.y>=Math.min(e.y,s.y)}function el(e){return e>0?1:e<0?-1:0}function tl(e,t){return Jh(e.prev,e,e.next)<0?Jh(e,t,e.next)>=0&&Jh(e,e.prev,t)>=0:Jh(e,t,e.prev)<0||Jh(e,e.next,t)<0}function sl(e,t){const s=new nl(e.i,e.x,e.y),i=new nl(t.i,t.x,t.y),r=e.next,n=t.prev;return e.next=t,t.prev=e,s.next=r,r.prev=s,i.next=s,s.prev=i,n.next=i,i.prev=n,i}function il(e,t,s,i){const r=new nl(e,t,s);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function rl(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function nl(e,t,s){this.i=e,this.x=t,this.y=s,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}class ol{static area(e){const t=e.length;let s=0;for(let i=t-1,r=0;r2&&e[t-1].equals(e[0])&&e.pop()}function hl(e,t){for(let s=0;sNumber.EPSILON){const c=Math.sqrt(u),d=Math.sqrt(h*h+l*l),p=t.x-a/c,m=t.y+o/c,g=((s.x-l/d-p)*l-(s.y+h/d-m)*h)/(o*l-a*h);i=p+o*g-e.x,r=m+a*g-e.y;const f=i*i+r*r;if(f<=2)return new Qs(i,r);n=Math.sqrt(f/2)}else{let e=!1;o>Number.EPSILON?h>Number.EPSILON&&(e=!0):o<-Number.EPSILON?h<-Number.EPSILON&&(e=!0):Math.sign(a)===Math.sign(l)&&(e=!0),e?(i=-a,r=o,n=Math.sqrt(u)):(i=o,r=a,n=Math.sqrt(u/2))}return new Qs(i/n,r/n)}const B=[];for(let e=0,t=A.length,s=t-1,i=e+1;e=0;e--){const t=e/p,s=u*Math.cos(t*Math.PI/2),i=c*Math.sin(t*Math.PI/2)+d;for(let e=0,t=A.length;e=0;){const i=s;let r=s-1;r<0&&(r=e.length-1);for(let e=0,s=a+2*p;e0)&&d.push(t,r,h),(e!==s-1||a0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class Rl extends Kr{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Yr(16777215),this.specular=new Yr(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Yr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Qs(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new fr,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Cl extends Kr{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Yr(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Yr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Qs(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class El extends Kr{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Qs(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class Bl extends Kr{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Yr(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Yr(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Qs(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new fr,this.combine=0,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Il extends Kr{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=3200,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Pl extends Kr{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Fl extends Kr{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Yr(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=0,this.normalScale=new Qs(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class zl extends Ma{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function Ul(e,t=!1){let s="{";!0===e.isNode&&(s+=e.id,e=e.getSelf());for(const{property:i,childNode:r}of Ll(e))s+=","+i.slice(0,-4)+":"+r.getCacheKey(t);return s+="}",s}function*Ll(e,t=!1){for(const s in e){if(!0===s.startsWith("_"))continue;const i=e[s];if(!0===Array.isArray(i))for(let e=0;ee.charCodeAt(0))).buffer}var Gl=Object.freeze({__proto__:null,arrayBufferToBase64:Dl,base64ToArrayBuffer:kl,getCacheKey:Ul,getNodeChildren:Ll,getValueFromType:Vl,getValueType:Ol});const Wl={VERTEX:"vertex",FRAGMENT:"fragment"},Hl={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},jl={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},ql=["fragment","vertex"],$l=["setup","analyze","generate"],Xl=[...ql,"compute"],Yl=["x","y","z","w"],Jl=new Map;let Zl=0;class Kl extends ks{constructor(e=null){super(),this.nodeType=e,this.updateType=Hl.NONE,this.updateBeforeType=Hl.NONE,this.updateAfterType=Hl.NONE,this.uuid=Ks.generateUUID(),this.version=0,this._cacheKey=null,this._cacheKeyVersion=0,this.global=!1,this.isNode=!0,Object.defineProperty(this,"id",{value:Zl++})}set needsUpdate(e){!0===e&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this.getSelf()),this}onFrameUpdate(e){return this.onUpdate(e,Hl.FRAME)}onRenderUpdate(e){return this.onUpdate(e,Hl.RENDER)}onObjectUpdate(e){return this.onUpdate(e,Hl.OBJECT)}onReference(e){return this.updateReference=e.bind(this.getSelf()),this}getSelf(){return this.self||this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of Ll(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return!0!==(e=e||this.version!==this._cacheKeyVersion)&&null!==this._cacheKey||(this._cacheKey=Ul(this,e),this._cacheKeyVersion=this.version),this._cacheKey}getScope(){return this}getHash(){return this.uuid}getUpdateType(){return this.updateType}getUpdateBeforeType(){return this.updateBeforeType}getUpdateAfterType(){return this.updateAfterType}getElementType(e){const t=this.getNodeType(e);return e.getElementType(t)}getNodeType(e){const t=e.getNodeProperties(this);return t.outputNode?t.outputNode.getNodeType(e):this.nodeType}getShared(e){const t=this.getHash(e);return e.getNodeFromHash(t)||this}setup(e){const t=e.getNodeProperties(this);let s=0;for(const e of this.getChildren())t["node"+s++]=e;return null}analyze(e){if(1===e.increaseUsage(this)){const t=e.getNodeProperties(this);for(const s of Object.values(t))s&&!0===s.isNode&&s.build(e)}}generate(e,t){const{outputNode:s}=e.getNodeProperties(this);if(s&&!0===s.isNode)return s.build(e,t)}updateBefore(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const s=this.getShared(e);if(this!==s)return s.build(e,t);e.addNode(this),e.addChain(this);let i=null;const r=e.getBuildStage();if("setup"===r){this.updateReference(e);const t=e.getNodeProperties(this);if(!0!==t.initialized){e.stack.nodes.length;t.initialized=!0,t.outputNode=this.setup(e),null!==t.outputNode&&e.stack.nodes.length;for(const s of Object.values(t))s&&!0===s.isNode&&s.build(e)}}else if("analyze"===r)this.analyze(e);else if("generate"===r){if(1===this.generate.length){const s=this.getNodeType(e),r=e.getDataFromNode(this);i=r.snippet,void 0===i&&(i=this.generate(e)||"",r.snippet=i),i=e.format(i,s,t)}else i=this.generate(e,t)||""}return e.removeChain(this),i}getSerializeChildren(){return Ll(this)}serialize(e){const t=this.getSerializeChildren(),s={};for(const{property:i,index:r,childNode:n}of t)void 0!==r?(void 0===s[i]&&(s[i]=Number.isInteger(r)?[]:{}),s[i][r]=n.toJSON(e.meta).uuid):s[i]=n.toJSON(e.meta).uuid;Object.keys(s).length>0&&(e.inputNodes=s)}deserialize(e){if(void 0!==e.inputNodes){const t=e.meta.nodes;for(const s in e.inputNodes)if(Array.isArray(e.inputNodes[s])){const i=[];for(const r of e.inputNodes[s])i.push(t[r]);this[s]=i}else if("object"==typeof e.inputNodes[s]){const i={};for(const r in e.inputNodes[s]){const n=e.inputNodes[s][r];i[r]=t[n]}this[s]=i}else{const i=e.inputNodes[s];this[s]=t[i]}}}toJSON(e){const{uuid:t,type:s}=this,i=void 0===e||"string"==typeof e;i&&(e={textures:{},images:{},nodes:{}});let r=e.nodes[t];function n(e){const t=[];for(const s in e){const i=e[s];delete i.metadata,t.push(i)}return t}if(void 0===r&&(r={uuid:t,type:s,meta:e,metadata:{version:4.6,type:"Node",generator:"Node.toJSON"}},!0!==i&&(e.nodes[r.uuid]=r),this.serialize(r),delete r.meta),i){const t=n(e.textures),s=n(e.images),i=n(e.nodes);t.length>0&&(r.textures=t),s.length>0&&(r.images=s),i.length>0&&(r.nodes=i)}return r}}function Ql(e,t){const s="Node",i=e+s;if("function"!=typeof t)throw new Error(`TSL.Node: Node class ${e} is not a class`);if(Jl.has(i))console.warn(`TSL.Node: Redefinition of node class ${i}`);else{if(e.slice(-4)!==s)return Jl.set(i,t),t.type=i,i;console.warn(`TSL.Node: Node class ${i} should not have '${s}' suffix.`)}}function eu(e){const t=Jl.get(e);if(void 0!==t)return new t}Kl.type=Ql("",Kl);class tu extends Kl{constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){return`${this.node.build(e)}[ ${this.indexNode.build(e,"uint")} ]`}}tu.type=Ql("ArrayElement",tu);class su extends Kl{constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let s=null;for(const i of this.convertTo.split("|"))null!==s&&e.getTypeLength(t)!==e.getTypeLength(i)||(s=i);return s}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const s=this.node,i=this.getNodeType(e),r=s.build(e,i);return e.format(r,i,t)}}su.type=Ql("Convert",su);class iu extends Kl{constructor(e){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if("generate"===e.getBuildStage()){const s=e.getVectorType(this.getNodeType(e,t)),i=e.getDataFromNode(this);if(void 0!==i.propertyName)return e.format(i.propertyName,s,t);if("void"!==s&&"void"!==t&&this.hasDependencies(e)){const r=super.build(e,s),n=e.getVarFromNode(this,null,s),o=e.getPropertyName(n);return e.addLineFlowCode(`${o} = ${r}`),i.snippet=r,i.propertyName=o,e.format(i.propertyName,s,t)}}return super.build(e,t)}}iu.type=Ql("Temp",iu);class ru extends iu{constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return null!==this.nodeType?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce(((t,s)=>t+e.getTypeLength(s.getNodeType(e))),0))}generate(e,t){const s=this.getNodeType(e),i=this.nodes,r=e.getComponentType(s),n=[];for(const t of i){let s=t.build(e);const i=e.getComponentType(t.getNodeType(e));i!==r&&(s=e.format(s,i,r)),n.push(s)}const o=`${e.getType(s)}( ${n.join(", ")} )`;return e.format(o,s,t)}}ru.type=Ql("Join",ru);const nu=Yl.join("");class ou extends Kl{constructor(e,t="x"){super(),this.node=e,this.components=t,this.isSplitNode=!0}getVectorLength(){let e=this.components.length;for(const t of this.components)e=Math.max(Yl.indexOf(t)+1,e);return e}getComponentType(e){return e.getComponentType(this.node.getNodeType(e))}getNodeType(e){return e.getTypeFromLength(this.components.length,this.getComponentType(e))}generate(e,t){const s=this.node,i=e.getTypeLength(s.getNodeType(e));let r=null;if(i>1){let n=null;this.getVectorLength()>=i&&(n=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const o=s.build(e,n);r=this.components.length===i&&this.components===nu.slice(0,this.components.length)?e.format(o,n,t):e.format(`${o}.${this.components}`,this.getNodeType(e),t)}else r=s.build(e,t);return r}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}ou.type=Ql("Split",ou);class au extends iu{constructor(e,t,s){super(),this.sourceNode=e,this.components=t,this.targetNode=s}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:s,targetNode:i}=this,r=this.getNodeType(e),n=e.getTypeFromLength(s.length),o=i.build(e,n),a=t.build(e,r),h=e.getTypeLength(r),l=[];for(let e=0;ee.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),gu=e=>mu(e).split("").sort().join(""),fu={setup(e,t){const s=t.shift();return e(ku(s),...t)},get(e,t,s){if("string"==typeof t&&void 0===e[t]){if(!0!==e.isStackNode&&"assign"===t)return(...e)=>(cu.assign(s,...e),s);if(du.has(t)){const i=du.get(t);return e.isStackNode?(...e)=>s.add(i(...e)):(...e)=>i(s,...e)}if("self"===t)return e;if(t.endsWith("Assign")&&du.has(t.slice(0,t.length-6))){const i=du.get(t.slice(0,t.length-6));return e.isStackNode?(...e)=>s.assign(e[0],i(...e)):(...e)=>s.assign(i(s,...e))}if(!0===/^[xyzwrgbastpq]{1,4}$/.test(t))return t=mu(t),Du(new ou(s,t));if(!0===/^set[XYZWRGBASTPQ]{1,4}$/.test(t))return t=gu(t.slice(3).toLowerCase()),s=>Du(new au(e,t,s));if(!0===/^flip[XYZWRGBASTPQ]{1,4}$/.test(t))return t=gu(t.slice(4).toLowerCase()),()=>Du(new hu(Du(e),t));if("width"===t||"height"===t||"depth"===t)return"width"===t?t="x":"height"===t?t="y":"depth"===t&&(t="z"),Du(new ou(e,t));if(!0===/^\d+$/.test(t))return Du(new tu(s,new uu(Number(t),"uint")))}return Reflect.get(e,t,s)},set:(e,t,s,i)=>"string"!=typeof t||void 0!==e[t]||!0!==/^[xyzwrgbastpq]{1,4}$/.test(t)&&"width"!==t&&"height"!==t&&"depth"!==t&&!0!==/^\d+$/.test(t)?Reflect.set(e,t,s,i):(i[t].assign(s),!0)},yu=new WeakMap,xu=new WeakMap,bu=function(e,t=null){for(const s in e)e[s]=Du(e[s],t);return e},vu=function(e,t=null){const s=e.length;for(let i=0;iDu(null!==i?Object.assign(e,i):e);return null===t?(...t)=>r(new e(...Gu(t))):null!==s?(s=Du(s),(...i)=>r(new e(t,...Gu(i),s))):(...s)=>r(new e(t,...Gu(s)))},_u=function(e,...t){return Du(new e(...Gu(t)))};class wu extends Kl{constructor(e,t){super(),this.shaderNode=e,this.inputNodes=t}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}call(e){const{shaderNode:t,inputNodes:s}=this,i=e.getNodeProperties(t);if(i.onceOutput)return i.onceOutput;let r=null;if(t.layout){let i=xu.get(e.constructor);void 0===i&&(i=new WeakMap,xu.set(e.constructor,i));let n=i.get(t);void 0===n&&(n=Du(e.buildFunctionNode(t)),i.set(t,n)),null!==e.currentFunctionNode&&e.currentFunctionNode.includes.push(n),r=Du(n.call(s))}else{const i=t.jsFunc,n=null!==s?i(s,e):i(e);r=Du(n)}return t.once&&(i.onceOutput=r),r}getOutputNode(e){const t=e.getNodeProperties(this);return null===t.outputNode&&(t.outputNode=this.setupOutput(e)),t.outputNode}setup(e){return this.getOutputNode(e)}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}generate(e,t){return this.getOutputNode(e).build(e,t)}}class Su extends Kl{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}call(e=null){return ku(e),Du(new wu(this,e))}setup(){return this.call()}}const Mu=[!1,!0],Au=[0,1,2,3],Nu=[-1,-2],Ru=[.5,1.5,1/3,1e-6,1e6,Math.PI,2*Math.PI,1/Math.PI,2/Math.PI,1/(2*Math.PI),Math.PI/2],Cu=new Map;for(const e of Mu)Cu.set(e,new uu(e));const Eu=new Map;for(const e of Au)Eu.set(e,new uu(e,"uint"));const Bu=new Map([...Eu].map((e=>new uu(e.value,"int"))));for(const e of Nu)Bu.set(e,new uu(e,"int"));const Iu=new Map([...Bu].map((e=>new uu(e.value))));for(const e of Ru)Iu.set(e,new uu(e));for(const e of Ru)Iu.set(-e,new uu(-e));const Pu={bool:Cu,uint:Eu,ints:Bu,float:Iu},Fu=new Map([...Cu,...Iu]),zu=(e,t)=>Fu.has(e)?Fu.get(e):!0===e.isNode?e:new uu(e,t),Uu=function(e,t=null){return(...s)=>{if((0===s.length||!["bool","float","int","uint"].includes(e)&&s.every((e=>"object"!=typeof e)))&&(s=[Vl(e,...s)]),1===s.length&&null!==t&&t.has(s[0]))return Du(t.get(s[0]));if(1===s.length){const t=zu(s[0],e);return(e=>{try{return e.getNodeType()}catch(e){return}})(t)===e?Du(t):Du(new su(t,e))}const i=s.map((e=>zu(e)));return Du(new ru(i,e))}},Lu=e=>"object"==typeof e&&null!==e?e.value:e,Ou=e=>null!=e?e.nodeType||e.convertTo||("string"==typeof e?e:null):null;function Vu(e,t){return new Proxy(new Su(e,t),fu)}const Du=(e,t=null)=>function(e,t=null){const s=Ol(e);if("node"===s){let t=yu.get(e);return void 0===t&&(t=new Proxy(e,fu),yu.set(e,t),yu.set(t,t)),t}return null===t&&("float"===s||"boolean"===s)||s&&"shader"!==s&&"string"!==s?Du(zu(e,t)):"shader"===s?ju(e):e}(e,t),ku=(e,t=null)=>new bu(e,t),Gu=(e,t=null)=>new vu(e,t),Wu=(...e)=>new Tu(...e),Hu=(...e)=>new _u(...e),ju=(e,t)=>{const s=new Vu(e,t),i=(...e)=>{let t;return ku(e),t=e[0]&&e[0].isNode?[...e]:e[0],s.call(t)};return i.shaderNode=s,i.setLayout=e=>(s.setLayout(e),i),i.once=()=>(s.once=!0,i),i},qu=(...e)=>(console.warn("TSL.ShaderNode: tslFn() has been renamed to Fn()."),ju(...e));pu("toGlobal",(e=>(e.global=!0,e)));const $u=e=>{cu=e},Xu=()=>cu,Yu=(...e)=>cu.If(...e);function Ju(e){return cu&&cu.add(e),e}pu("append",Ju);const Zu=new Uu("color"),Ku=new Uu("float",Pu.float),Qu=new Uu("int",Pu.ints),ec=new Uu("uint",Pu.uint),tc=new Uu("bool",Pu.bool),sc=new Uu("vec2"),ic=new Uu("ivec2"),rc=new Uu("uvec2"),nc=new Uu("bvec2"),oc=new Uu("vec3"),ac=new Uu("ivec3"),hc=new Uu("uvec3"),lc=new Uu("bvec3"),uc=new Uu("vec4"),cc=new Uu("ivec4"),dc=new Uu("uvec4"),pc=new Uu("bvec4"),mc=new Uu("mat2"),gc=new Uu("mat3"),fc=new Uu("mat4"),yc=(e="")=>Du(new uu(e,"string")),xc=e=>Du(new uu(e,"ArrayBuffer"));pu("toColor",Zu),pu("toFloat",Ku),pu("toInt",Qu),pu("toUint",ec),pu("toBool",tc),pu("toVec2",sc),pu("toIVec2",ic),pu("toUVec2",rc),pu("toBVec2",nc),pu("toVec3",oc),pu("toIVec3",ac),pu("toUVec3",hc),pu("toBVec3",lc),pu("toVec4",uc),pu("toIVec4",cc),pu("toUVec4",dc),pu("toBVec4",pc),pu("toMat2",mc),pu("toMat3",gc),pu("toMat4",fc);const bc=Wu(tu),vc=(e,t)=>Du(new su(Du(e),t)),Tc=(e,t)=>Du(new ou(Du(e),t));pu("element",bc),pu("convert",vc);class _c extends Kl{constructor(e,t=!1){super("string"),this.name=e,this.version=0,this.shared=t,this.isUniformGroup=!0}set needsUpdate(e){!0===e&&this.version++}serialize(e){super.serialize(e),e.name=this.name,e.version=this.version,e.shared=this.shared}deserialize(e){super.deserialize(e),this.name=e.name,this.version=e.version,this.shared=e.shared}}_c.type=Ql("UniformGroup",_c);const wc=e=>new _c(e),Sc=e=>new _c(e,!0),Mc=Sc("frame"),Ac=Sc("render"),Nc=wc("object");class Rc extends lu{constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=Nc}label(e){return this.name=e,this}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){const s=this.getSelf();return e=e.bind(s),super.onUpdate((t=>{const i=e(t,s);void 0!==i&&(this.value=i)}),t)}generate(e,t){const s=this.getNodeType(e),i=this.getUniformHash(e);let r=e.getNodeFromHash(i);void 0===r&&(e.setHashNode(this,i),r=this);const n=r.getInputType(e),o=e.getUniformFromNode(r,n,e.shaderStage,this.name||e.context.label),a=e.getPropertyName(o);return void 0!==e.context.label&&delete e.context.label,e.format(a,s,t)}}Rc.type=Ql("Uniform",Rc);const Cc=(e,t)=>{const s=Ou(t||e),i=e&&!0===e.isNode?e.node&&e.node.value||e.value:e;return Du(new Rc(i,s))};class Ec extends Kl{constructor(e,t=null,s=!1){super(e),this.name=t,this.varying=s,this.isPropertyNode=!0}getHash(e){return this.name||super.getHash(e)}isGlobal(){return!0}generate(e){let t;return!0===this.varying?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}Ec.type=Ql("Property",Ec);const Bc=(e,t)=>Du(new Ec(e,t)),Ic=(e,t)=>Du(new Ec(e,t,!0)),Pc=Hu(Ec,"vec4","DiffuseColor"),Fc=Hu(Ec,"vec3","EmissiveColor"),zc=Hu(Ec,"float","Roughness"),Uc=Hu(Ec,"float","Metalness"),Lc=Hu(Ec,"float","Clearcoat"),Oc=Hu(Ec,"float","ClearcoatRoughness"),Vc=Hu(Ec,"vec3","Sheen"),Dc=Hu(Ec,"float","SheenRoughness"),kc=Hu(Ec,"float","Iridescence"),Gc=Hu(Ec,"float","IridescenceIOR"),Wc=Hu(Ec,"float","IridescenceThickness"),Hc=Hu(Ec,"float","AlphaT"),jc=Hu(Ec,"float","Anisotropy"),qc=Hu(Ec,"vec3","AnisotropyT"),$c=Hu(Ec,"vec3","AnisotropyB"),Xc=Hu(Ec,"color","SpecularColor"),Yc=Hu(Ec,"float","SpecularF90"),Jc=Hu(Ec,"float","Shininess"),Zc=Hu(Ec,"vec4","Output"),Kc=Hu(Ec,"float","dashSize"),Qc=Hu(Ec,"float","gapSize"),ed=Hu(Ec,"float","pointWidth"),td=Hu(Ec,"float","IOR"),sd=Hu(Ec,"float","Transmission"),id=Hu(Ec,"float","Thickness"),rd=Hu(Ec,"float","AttenuationDistance"),nd=Hu(Ec,"color","AttenuationColor"),od=Hu(Ec,"float","Dispersion");class ad extends iu{constructor(e,t){super(),this.targetNode=e,this.sourceNode=t}hasDependencies(){return!1}getNodeType(e,t){return"void"!==t?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(!1===e.isAvailable("swizzleAssign")&&t.isSplitNode&&t.components.length>1){const s=e.getTypeLength(t.node.getNodeType(e));return Yl.join("").slice(0,s)!==t.components}return!1}generate(e,t){const{targetNode:s,sourceNode:i}=this,r=this.needsSplitAssign(e),n=s.getNodeType(e),o=s.context({assign:!0}).build(e),a=i.build(e,n),h=i.getNodeType(e),l=e.getDataFromNode(this);let u;if(!0===l.initialized)"void"!==t&&(u=o);else if(r){const i=e.getVarFromNode(this,null,n),r=e.getPropertyName(i);e.addLineFlowCode(`${r} = ${a}`);const h=s.node.context({assign:!0}).build(e);for(let t=0;t(t=t.length>1||t[0]&&!0===t[0].isNode?Gu(t):ku(t[0]),Du(new ld(Du(e),t)));pu("call",ud);class cd extends iu{constructor(e,t,s,...i){if(super(),i.length>0){let r=new cd(e,t,s);for(let t=0;t>"===s||"<<"===s)return e.getIntegerType(n);if("!"===s||"=="===s||"&&"===s||"||"===s||"^^"===s)return"bool";if("<"===s||">"===s||"<="===s||">="===s){const s=t?e.getTypeLength(t):Math.max(e.getTypeLength(n),e.getTypeLength(o));return s>1?`bvec${s}`:"bool"}return"float"===n&&e.isMatrix(o)?o:e.isMatrix(n)&&e.isVector(o)?e.getVectorFromMatrix(n):e.isVector(n)&&e.isMatrix(o)?e.getVectorFromMatrix(o):e.getTypeLength(o)>e.getTypeLength(n)?o:n}generate(e,t){const s=this.op,i=this.aNode,r=this.bNode,n=this.getNodeType(e,t);let o=null,a=null;"void"!==n?(o=i.getNodeType(e),a=void 0!==r?r.getNodeType(e):null,"<"===s||">"===s||"<="===s||">="===s||"=="===s?e.isVector(o)?a=o:o!==a&&(o=a="float"):">>"===s||"<<"===s?(o=n,a=e.changeComponentType(a,"uint")):e.isMatrix(o)&&e.isVector(a)?a=e.getVectorFromMatrix(o):o=e.isVector(o)&&e.isMatrix(a)?e.getVectorFromMatrix(a):a=n):o=a=n;const h=i.build(e,o),l=void 0!==r?r.build(e,a):null,u=e.getTypeLength(t),c=e.getFunctionOperator(s);return"void"!==t?"<"===s&&u>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThan",t)}( ${h}, ${l} )`,n,t):e.format(`( ${h} < ${l} )`,n,t):"<="===s&&u>1?e.useComparisonMethod?e.format(`${e.getMethod("lessThanEqual",t)}( ${h}, ${l} )`,n,t):e.format(`( ${h} <= ${l} )`,n,t):">"===s&&u>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThan",t)}( ${h}, ${l} )`,n,t):e.format(`( ${h} > ${l} )`,n,t):">="===s&&u>1?e.useComparisonMethod?e.format(`${e.getMethod("greaterThanEqual",t)}( ${h}, ${l} )`,n,t):e.format(`( ${h} >= ${l} )`,n,t):"!"===s||"~"===s?e.format(`(${s}${h})`,o,t):c?e.format(`${c}( ${h}, ${l} )`,n,t):e.format(`( ${h} ${s} ${l} )`,n,t):"void"!==o?c?e.format(`${c}( ${h}, ${l} )`,n,t):e.format(`${h} ${s} ${l}`,n,t):void 0}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}cd.type=Ql("Operator",cd);const dd=Wu(cd,"+"),pd=Wu(cd,"-"),md=Wu(cd,"*"),gd=Wu(cd,"/"),fd=Wu(cd,"%"),yd=Wu(cd,"=="),xd=Wu(cd,"!="),bd=Wu(cd,"<"),vd=Wu(cd,">"),Td=Wu(cd,"<="),_d=Wu(cd,">="),wd=Wu(cd,"&&"),Sd=Wu(cd,"||"),Md=Wu(cd,"!"),Ad=Wu(cd,"^^"),Nd=Wu(cd,"&"),Rd=Wu(cd,"~"),Cd=Wu(cd,"|"),Ed=Wu(cd,"^"),Bd=Wu(cd,"<<"),Id=Wu(cd,">>");pu("add",dd),pu("sub",pd),pu("mul",md),pu("div",gd),pu("modInt",fd),pu("equal",yd),pu("notEqual",xd),pu("lessThan",bd),pu("greaterThan",vd),pu("lessThanEqual",Td),pu("greaterThanEqual",_d),pu("and",wd),pu("or",Sd),pu("not",Md),pu("xor",Ad),pu("bitAnd",Nd),pu("bitNot",Rd),pu("bitOr",Cd),pu("bitXor",Ed),pu("shiftLeft",Bd),pu("shiftRight",Id);const Pd=(...e)=>(console.warn("TSL.OperatorNode: .remainder() has been renamed to .modInt()."),fd(...e));pu("remainder",Pd);class Fd extends iu{constructor(e,t,s=null,i=null){super(),this.method=e,this.aNode=t,this.bNode=s,this.cNode=i}getInputType(e){const t=this.aNode.getNodeType(e),s=this.bNode?this.bNode.getNodeType(e):null,i=this.cNode?this.cNode.getNodeType(e):null,r=e.isMatrix(t)?0:e.getTypeLength(t),n=e.isMatrix(s)?0:e.getTypeLength(s),o=e.isMatrix(i)?0:e.getTypeLength(i);return r>n&&r>o?t:n>o?s:o>r?i:t}getNodeType(e){const t=this.method;return t===Fd.LENGTH||t===Fd.DISTANCE||t===Fd.DOT?"float":t===Fd.CROSS?"vec3":t===Fd.ALL?"bool":t===Fd.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):t===Fd.MOD?this.aNode.getNodeType(e):this.getInputType(e)}generate(e,t){const s=this.method,i=this.getNodeType(e),r=this.getInputType(e),n=this.aNode,o=this.bNode,a=this.cNode,h=!0===e.renderer.isWebGLRenderer;if(s===Fd.TRANSFORM_DIRECTION){let s=n,i=o;e.isMatrix(s.getNodeType(e))?i=uc(oc(i),0):s=uc(oc(s),0);const r=md(s,i).xyz;return Kd(r).build(e,t)}if(s===Fd.NEGATE)return e.format("( - "+n.build(e,r)+" )",i,t);if(s===Fd.ONE_MINUS)return pd(1,n).build(e,t);if(s===Fd.RECIPROCAL)return gd(1,n).build(e,t);if(s===Fd.DIFFERENCE)return op(pd(n,o)).build(e,t);{const l=[];return s===Fd.CROSS||s===Fd.MOD?l.push(n.build(e,i),o.build(e,i)):h&&s===Fd.STEP?l.push(n.build(e,1===e.getTypeLength(n.getNodeType(e))?"float":r),o.build(e,r)):h&&(s===Fd.MIN||s===Fd.MAX)||s===Fd.MOD?l.push(n.build(e,r),o.build(e,1===e.getTypeLength(o.getNodeType(e))?"float":r)):s===Fd.REFRACT?l.push(n.build(e,r),o.build(e,r),a.build(e,"float")):s===Fd.MIX?l.push(n.build(e,r),o.build(e,r),a.build(e,1===e.getTypeLength(a.getNodeType(e))?"float":r)):(l.push(n.build(e,r)),null!==o&&l.push(o.build(e,r)),null!==a&&l.push(a.build(e,r))),e.format(`${e.getMethod(s,i)}( ${l.join(", ")} )`,i,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}Fd.ALL="all",Fd.ANY="any",Fd.EQUALS="equals",Fd.RADIANS="radians",Fd.DEGREES="degrees",Fd.EXP="exp",Fd.EXP2="exp2",Fd.LOG="log",Fd.LOG2="log2",Fd.SQRT="sqrt",Fd.INVERSE_SQRT="inversesqrt",Fd.FLOOR="floor",Fd.CEIL="ceil",Fd.NORMALIZE="normalize",Fd.FRACT="fract",Fd.SIN="sin",Fd.COS="cos",Fd.TAN="tan",Fd.ASIN="asin",Fd.ACOS="acos",Fd.ATAN="atan",Fd.ABS="abs",Fd.SIGN="sign",Fd.LENGTH="length",Fd.NEGATE="negate",Fd.ONE_MINUS="oneMinus",Fd.DFDX="dFdx",Fd.DFDY="dFdy",Fd.ROUND="round",Fd.RECIPROCAL="reciprocal",Fd.TRUNC="trunc",Fd.FWIDTH="fwidth",Fd.BITCAST="bitcast",Fd.TRANSPOSE="transpose",Fd.ATAN2="atan2",Fd.MIN="min",Fd.MAX="max",Fd.MOD="mod",Fd.STEP="step",Fd.REFLECT="reflect",Fd.DISTANCE="distance",Fd.DIFFERENCE="difference",Fd.DOT="dot",Fd.CROSS="cross",Fd.POW="pow",Fd.TRANSFORM_DIRECTION="transformDirection",Fd.MIX="mix",Fd.CLAMP="clamp",Fd.REFRACT="refract",Fd.SMOOTHSTEP="smoothstep",Fd.FACEFORWARD="faceforward",Fd.type=Ql("Math",Fd);const zd=Ku(1e-6),Ud=Ku(1e6),Ld=Ku(Math.PI),Od=Ku(2*Math.PI),Vd=Wu(Fd,Fd.ALL),Dd=Wu(Fd,Fd.ANY),kd=Wu(Fd,Fd.EQUALS),Gd=Wu(Fd,Fd.RADIANS),Wd=Wu(Fd,Fd.DEGREES),Hd=Wu(Fd,Fd.EXP),jd=Wu(Fd,Fd.EXP2),qd=Wu(Fd,Fd.LOG),$d=Wu(Fd,Fd.LOG2),Xd=Wu(Fd,Fd.SQRT),Yd=Wu(Fd,Fd.INVERSE_SQRT),Jd=Wu(Fd,Fd.FLOOR),Zd=Wu(Fd,Fd.CEIL),Kd=Wu(Fd,Fd.NORMALIZE),Qd=Wu(Fd,Fd.FRACT),ep=Wu(Fd,Fd.SIN),tp=Wu(Fd,Fd.COS),sp=Wu(Fd,Fd.TAN),ip=Wu(Fd,Fd.ASIN),rp=Wu(Fd,Fd.ACOS),np=Wu(Fd,Fd.ATAN),op=Wu(Fd,Fd.ABS),ap=Wu(Fd,Fd.SIGN),hp=Wu(Fd,Fd.LENGTH),lp=Wu(Fd,Fd.NEGATE),up=Wu(Fd,Fd.ONE_MINUS),cp=Wu(Fd,Fd.DFDX),dp=Wu(Fd,Fd.DFDY),pp=Wu(Fd,Fd.ROUND),mp=Wu(Fd,Fd.RECIPROCAL),gp=Wu(Fd,Fd.TRUNC),fp=Wu(Fd,Fd.FWIDTH),yp=Wu(Fd,Fd.BITCAST),xp=Wu(Fd,Fd.TRANSPOSE),bp=Wu(Fd,Fd.ATAN2),vp=Wu(Fd,Fd.MIN),Tp=Wu(Fd,Fd.MAX),_p=Wu(Fd,Fd.MOD),wp=Wu(Fd,Fd.STEP),Sp=Wu(Fd,Fd.REFLECT),Mp=Wu(Fd,Fd.DISTANCE),Ap=Wu(Fd,Fd.DIFFERENCE),Np=Wu(Fd,Fd.DOT),Rp=Wu(Fd,Fd.CROSS),Cp=Wu(Fd,Fd.POW),Ep=Wu(Fd,Fd.POW,2),Bp=Wu(Fd,Fd.POW,3),Ip=Wu(Fd,Fd.POW,4),Pp=Wu(Fd,Fd.TRANSFORM_DIRECTION),Fp=e=>md(ap(e),Cp(op(e),1/3)),zp=e=>Np(e,e),Up=Wu(Fd,Fd.MIX),Lp=(e,t=0,s=1)=>Du(new Fd(Fd.CLAMP,Du(e),Du(t),Du(s))),Op=e=>Lp(e),Vp=Wu(Fd,Fd.REFRACT),Dp=Wu(Fd,Fd.SMOOTHSTEP),kp=Wu(Fd,Fd.FACEFORWARD),Gp=ju((([e])=>{const t=Np(e.xy,sc(12.9898,78.233)),s=_p(t,Ld);return Qd(ep(s).mul(43758.5453))})),Wp=(e,t,s)=>Up(t,s,e),Hp=(e,t,s)=>Dp(t,s,e);pu("all",Vd),pu("any",Dd),pu("equals",kd),pu("radians",Gd),pu("degrees",Wd),pu("exp",Hd),pu("exp2",jd),pu("log",qd),pu("log2",$d),pu("sqrt",Xd),pu("inverseSqrt",Yd),pu("floor",Jd),pu("ceil",Zd),pu("normalize",Kd),pu("fract",Qd),pu("sin",ep),pu("cos",tp),pu("tan",sp),pu("asin",ip),pu("acos",rp),pu("atan",np),pu("abs",op),pu("sign",ap),pu("length",hp),pu("lengthSq",zp),pu("negate",lp),pu("oneMinus",up),pu("dFdx",cp),pu("dFdy",dp),pu("round",pp),pu("reciprocal",mp),pu("trunc",gp),pu("fwidth",fp),pu("atan2",bp),pu("min",vp),pu("max",Tp),pu("mod",_p),pu("step",wp),pu("reflect",Sp),pu("distance",Mp),pu("dot",Np),pu("cross",Rp),pu("pow",Cp),pu("pow2",Ep),pu("pow3",Bp),pu("pow4",Ip),pu("transformDirection",Pp),pu("mix",Wp),pu("clamp",Lp),pu("refract",Vp),pu("smoothstep",Hp),pu("faceForward",kp),pu("difference",Ap),pu("saturate",Op),pu("cbrt",Fp),pu("transpose",xp),pu("rand",Gp);class jp extends Kl{constructor(e,t,s=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=s}getNodeType(e){const t=this.ifNode.getNodeType(e);if(null!==this.elseNode){const s=this.elseNode.getNodeType(e);if(e.getTypeLength(s)>e.getTypeLength(t))return s}return t}setup(e){const t=e.getNodeProperties(this);t.condNode=this.condNode.cache(),t.ifNode=this.ifNode.cache(),t.elseNode=this.elseNode?this.elseNode.cache():null}generate(e,t){const s=this.getNodeType(e),i=e.getDataFromNode(this);if(void 0!==i.nodeProperty)return i.nodeProperty;const{condNode:r,ifNode:n,elseNode:o}=e.getNodeProperties(this),a="void"!==t,h=a?Bc(s).build(e):"";i.nodeProperty=h;const l=r.build(e,"bool");e.addFlowCode(`\n${e.tab}if ( ${l} ) {\n\n`).addFlowTab();let u=n.build(e,s);if(u&&(u=a?h+" = "+u+";":"return "+u+";"),e.removeFlowTab().addFlowCode(e.tab+"\t"+u+"\n\n"+e.tab+"}"),null!==o){e.addFlowCode(" else {\n\n").addFlowTab();let t=o.build(e,s);t&&(t=a?h+" = "+t+";":"return "+t+";"),e.removeFlowTab().addFlowCode(e.tab+"\t"+t+"\n\n"+e.tab+"}\n\n")}else e.addFlowCode("\n\n");return e.format(h,s,t)}}jp.type=Ql("Conditional",jp);const qp=Wu(jp);pu("select",qp);const $p=(...e)=>(console.warn("TSL.ConditionalNode: cond() has been renamed to select()."),qp(...e));pu("cond",$p);class Xp extends Kl{constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}analyze(e){this.node.build(e)}setup(e){const t=e.getContext();e.setContext({...e.context,...this.value});const s=this.node.build(e);return e.setContext(t),s}generate(e,t){const s=e.getContext();e.setContext({...e.context,...this.value});const i=this.node.build(e,t);return e.setContext(s),i}}Xp.type=Ql("Context",Xp);const Yp=Wu(Xp),Jp=(e,t)=>Yp(e,{label:t});pu("context",Yp),pu("label",Jp);class Zp extends Kl{constructor(e,t=null){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}generate(e){const{node:t,name:s}=this,i=e.getVarFromNode(this,s,e.getVectorType(this.getNodeType(e))),r=e.getPropertyName(i),n=t.build(e,i.type);return e.addLineFlowCode(`${r} = ${n}`),r}}Zp.type=Ql("Var",Zp);const Kp=Wu(Zp);pu("temp",Kp),pu("toVar",((...e)=>Kp(...e).append()));class Qp extends Kl{constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0}isGlobal(){return!0}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let s=t.varying;if(void 0===s){const i=this.name,r=this.getNodeType(e);t.varying=s=e.getVaryingFromNode(this,i,r),t.node=this.node}return s.needsInterpolation||(s.needsInterpolation="fragment"===e.shaderStage),s}setup(e){this.setupVarying(e)}analyze(e){return this.setupVarying(e),this.node.analyze(e)}generate(e){const t=e.getNodeProperties(this),s=this.setupVarying(e);if(void 0===t.propertyName){const i=this.getNodeType(e),r=e.getPropertyName(s,Wl.VERTEX);e.flowNodeFromShaderStage(Wl.VERTEX,this.node,i,r),t.propertyName=r}return e.getPropertyName(s)}}Qp.type=Ql("Varying",Qp);const em=Wu(Qp);pu("varying",em);const tm=e=>{let t=null;return e===Zt?t="Linear":e===Jt&&(t="sRGB"),t},sm=(e,t)=>tm(e)+"To"+tm(t);class im extends iu{constructor(e,t=null,s=null){super("vec4"),this.colorNode=e,this.target=t,this.source=s}setup(e){const{renderer:t,context:s}=e,i=this.source||s.outputColorSpace||t.outputColorSpace,r=this.target||s.outputColorSpace||t.outputColorSpace,n=this.colorNode;if(i===r)return n;const o=sm(i,r);let a=null;const h=t.nodes.library.getColorSpaceFunction(o);return null!==h?a=uc(h(n.rgb),n.a):(console.error("ColorSpaceNode: Unsupported Color Space configuration.",o),a=n),a}}im.type=Ql("ColorSpace",im);const rm=(e,t=null)=>Du(new im(Du(e),t,Zt)),nm=(e,t=null)=>Du(new im(Du(e),Zt,t));pu("linearSRGBToColorSpace",rm),pu("colorSpaceToLinearSRGB",nm);let om=class extends tu{constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),s=this.referenceNode.getNodeType(),i=this.getNodeType();return e.format(t,s,i)}};class am extends Kl{constructor(e,t,s=null,i=null){super(),this.property=e,this.uniformType=t,this.object=s,this.count=i,this.properties=e.split("."),this.reference=s,this.node=null,this.updateType=Hl.OBJECT}element(e){return Du(new om(this,Du(e)))}setNodeType(e){this.node=Cc(null,e).getSelf()}getNodeType(e){return null===this.node&&this.updateValue(),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let s=e[t[0]];for(let e=1;eDu(new hm(e,t,s));class um extends iu{constructor(e,t=dm,s=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=s}getCacheKey(){let e=super.getCacheKey();return e="{toneMapping:"+this.toneMapping+",nodes:"+e+"}",e}setup(e){const t=this.colorNode||e.context.color,s=this.toneMapping;if(0===s)return t;let i=null;const r=e.renderer.nodes.library.getToneMappingFunction(s);return null!==r?i=uc(r(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",s),i=t),i}}um.type=Ql("ToneMapping",um);const cm=(e,t,s)=>Du(new um(e,Du(t),Du(s))),dm=lm("toneMappingExposure","float");pu("toneMapping",((e,t,s)=>cm(t,s,e)));class pm extends lu{constructor(e,t=null,s=0,i=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=s,this.bufferOffset=i,this.usage=Rs,this.instanced=!1,this.attribute=null,this.global=!0,e&&!0===e.isBufferAttribute&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(0===this.bufferStride&&0===this.bufferOffset){let t=e.globalCache.getData(this.value);return void 0===t&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return null===this.bufferType&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(null!==this.attribute)return;const t=this.getNodeType(e),s=this.value,i=e.getTypeLength(t),r=this.bufferStride||i,n=this.bufferOffset,o=!0===s.isInterleavedBuffer?s:new oo(s,r),a=new ho(o,i,n);o.setUsage(this.usage),this.attribute=a,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),s=e.getBufferAttributeFromNode(this,t),i=e.getPropertyName(s);let r=null;if("vertex"===e.shaderStage||"compute"===e.shaderStage)this.name=i,r=i;else{r=em(this).build(e,t)}return r}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&!0===this.attribute.isBufferAttribute&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}pm.type=Ql("BufferAttribute",pm);const mm=(e,t,s,i)=>Du(new pm(e,t,s,i)),gm=(e,t,s,i)=>mm(e,t,s,i).setUsage(Cs),fm=(e,t,s,i)=>mm(e,t,s,i).setInstanced(!0),ym=(e,t,s,i)=>gm(e,t,s,i).setInstanced(!0);pu("toAttribute",(e=>mm(e.value)));class xm extends Kl{constructor(e,t,s=[64]){super("void"),this.isComputeNode=!0,this.computeNode=e,this.count=t,this.workgroupSize=s,this.dispatchCount=0,this.version=1,this.updateBeforeType=Hl.OBJECT,this.updateDispatchCount()}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){!0===e&&this.version++}updateDispatchCount(){const{count:e,workgroupSize:t}=this;let s=t[0];for(let e=1;eDu(new xm(Du(e),t,s));pu("compute",bm);class vm extends Kl{constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!0}getNodeType(e){return this.node.getNodeType(e)}build(e,...t){const s=e.getCache(),i=e.getCacheFromNode(this,parent);e.setCache(i);const r=this.node.build(e,...t);return e.setCache(s),r}}vm.type=Ql("Cache",vm);const Tm=(e,...t)=>Du(new vm(Du(e),...t));pu("cache",Tm);class _m extends Kl{constructor(e,t){super(),this.isBypassNode=!0,this.outputNode=e,this.callNode=t}getNodeType(e){return this.outputNode.getNodeType(e)}generate(e){const t=this.callNode.build(e,"void");return""!==t&&e.addLineFlowCode(t),this.outputNode.build(e)}}_m.type=Ql("Bypass",_m);const wm=Wu(_m);pu("bypass",wm);class Sm extends Kl{constructor(e,t,s,i=Ku(0),r=Ku(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=s,this.outLowNode=i,this.outHighNode=r,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:s,outLowNode:i,outHighNode:r,doClamp:n}=this;let o=e.sub(t).div(s.sub(t));return!0===n&&(o=o.clamp()),o.mul(r.sub(i)).add(i)}}Sm.type=Ql("Remap",Sm);const Mm=Wu(Sm,null,null,{doClamp:!1}),Am=Wu(Sm);pu("remap",Mm),pu("remapClamp",Am);class Nm extends Kl{constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const s=this.getNodeType(e),i=this.snippet;if("void"!==s)return e.format(`( ${i} )`,s,t);e.addLineFlowCode(i)}}Nm.type=Ql("Expression",Nm);const Rm=Wu(Nm),Cm=e=>(e?qp(e,Rm("discard")):Rm("discard")).append(),Em=()=>Rm("return").append();pu("discard",Cm);class Bm extends iu{constructor(e,t,s){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=s,this.isRenderOutput=!0}setup({context:e}){let t=this.colorNode||e.color;const s=(null!==this.toneMapping?this.toneMapping:e.toneMapping)||0,i=(null!==this.outputColorSpace?this.outputColorSpace:e.outputColorSpace)||Zt;return 0!==s&&(t=t.toneMapping(s)),i===Jt&&(t=t.linearSRGBToColorSpace(i)),t}}Bm.type=Ql("RenderOutput",Bm);const Im=(e,t=null,s=null)=>Du(new Bm(Du(e),t,s));function Pm(e){console.warn("THREE.TSLBase: AddNodeElement has been removed in favor of tree-shaking. Trying add",e)}pu("renderOutput",Im);class Fm extends Kl{constructor(e,t=null){super(t),this.global=!0,this._attributeName=e}getHash(e){return this.getAttributeName(e)}getNodeType(e){let t=this.nodeType;if(null===t){const s=this.getAttributeName(e);if(e.hasGeometryAttribute(s)){const i=e.geometry.getAttribute(s);t=e.getTypeFromAttribute(i)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),s=this.getNodeType(e);if(!0===e.hasGeometryAttribute(t)){const i=e.geometry.getAttribute(t),r=e.getTypeFromAttribute(i),n=e.getAttribute(t,r);if("vertex"===e.shaderStage)return e.format(n.name,r,s);return em(this).build(e,s)}return console.warn(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(s)}serialize(e){super.serialize(e),e.global=this.global,e._attributeName=this._attributeName}deserialize(e){super.deserialize(e),this.global=e.global,this._attributeName=e._attributeName}}Fm.type=Ql("Attribute",Fm);const zm=(e,t)=>Du(new Fm(e,t)),Um=e=>zm("uv"+(e>0?e:""),"vec2");class Lm extends Kl{constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const s=this.textureNode.build(e,"property"),i=this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${s}, ${i} )`,this.getNodeType(e),t)}}Lm.type=Ql("TextureSize",Lm);const Om=Wu(Lm);class Vm extends Rc{constructor(e){super(0),this._textureNode=e,this.updateType=Hl.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,s=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(s&&void 0!==s.width){const{width:e,height:t}=s;this.value=Math.log2(Math.max(e,t))}}}Vm.type=Ql("MaxMipLevel",Vm);const Dm=Wu(Vm);class km extends Rc{constructor(e,t=null,s=null,i=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=s,this.biasNode=i,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=Hl.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this.setUpdateMatrix(null===t)}set value(e){this.referenceNode?this.referenceNode.value=e:this._value=e}get value(){return this.referenceNode?this.referenceNode.value:this._value}getUniformHash(){return this.value.uuid}getNodeType(){return!0===this.value.isDepthTexture?"float":this.value.type===Be?"uvec4":this.value.type===Ee?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return Um(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return null===this._matrixUniform&&(this._matrixUniform=Cc(this.value.matrix)),this._matrixUniform.mul(oc(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?Hl.FRAME:Hl.NONE,this}setupUV(e,t){const s=this.value;return!e.isFlipY()||!0!==s.isRenderTargetTexture&&!0!==s.isFramebufferTexture&&!0!==s.isDepthTexture||(t=t.setY(t.y.oneMinus())),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;let s=this.uvNode;null!==s&&!0!==e.context.forceUVContext||!e.context.getUV||(s=e.context.getUV(this)),s||(s=this.getDefaultUV()),!0===this.updateMatrix&&(s=this.getTransformedUV(s)),s=this.setupUV(e,s);let i=this.levelNode;null===i&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this)),t.uvNode=s,t.levelNode=i,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode}generateUV(e,t){return t.build(e,!0===this.sampler?"vec2":"ivec2")}generateSnippet(e,t,s,i,r,n,o,a){const h=this.value;let l;return l=i?e.generateTextureLevel(h,t,s,i,n):r?e.generateTextureBias(h,t,s,r,n):a?e.generateTextureGrad(h,t,s,a,n):o?e.generateTextureCompare(h,t,s,o,n):!1===this.sampler?e.generateTextureLoad(h,t,s,n):e.generateTexture(h,t,s,n),l}generate(e,t){const s=e.getNodeProperties(this),i=this.value;if(!i||!0!==i.isTexture)throw new Error("TextureNode: Need a three.js texture.");const r=super.generate(e,"property");if("sampler"===t)return r+"_sampler";if(e.isReference(t))return r;{const n=e.getDataFromNode(this);let o=n.propertyName;if(void 0===o){const{uvNode:t,levelNode:i,biasNode:a,compareNode:h,depthNode:l,gradNode:u}=s,c=this.generateUV(e,t),d=i?i.build(e,"float"):null,p=a?a.build(e,"float"):null,m=l?l.build(e,"int"):null,g=h?h.build(e,"float"):null,f=u?[u[0].build(e,"vec2"),u[1].build(e,"vec2")]:null,y=e.getVarFromNode(this);o=e.getPropertyName(y);const x=this.generateSnippet(e,r,c,d,p,m,g,f);e.addLineFlowCode(`${o} = ${x}`),n.snippet=x,n.propertyName=o}let a=o;const h=this.getNodeType(e);return e.needsColorSpaceToLinearSRGB(i)&&(a=nm(Rm(a,h),i.colorSpace).setup(e).build(e,h)),e.format(a,h,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){const t=this.clone();return t.uvNode=Du(e),t.referenceNode=this.getSelf(),Du(t)}blur(e){const t=this.clone();return t.biasNode=Du(e).mul(Dm(t)),t.referenceNode=this.getSelf(),Du(t)}level(e){const t=this.clone();return t.levelNode=Du(e),t.referenceNode=this.getSelf(),Du(t)}size(e){return Om(this,e)}bias(e){const t=this.clone();return t.biasNode=Du(e),t.referenceNode=this.getSelf(),Du(t)}compare(e){const t=this.clone();return t.compareNode=Du(e),t.referenceNode=this.getSelf(),Du(t)}grad(e,t){const s=this.clone();return s.gradNode=[Du(e),Du(t)],s.referenceNode=this.getSelf(),Du(s)}depth(e){const t=this.clone();return t.depthNode=Du(e),t.referenceNode=this.getSelf(),Du(t)}serialize(e){super.serialize(e),e.value=this.value.toJSON(e.meta).uuid,e.sampler=this.sampler,e.updateMatrix=this.updateMatrix,e.updateType=this.updateType}deserialize(e){super.deserialize(e),this.value=e.meta.textures[e.value],this.sampler=e.sampler,this.updateMatrix=e.updateMatrix,this.updateType=e.updateType}update(){const e=this.value,t=this._matrixUniform;null!==t&&(t.value=e.matrix),!0===e.matrixAutoUpdate&&e.updateMatrix()}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e}}km.type=Ql("Texture",km);const Gm=Wu(km),Wm=(...e)=>Gm(...e).setSampler(!1),Hm=e=>(!0===e.isNode?e:Gm(e)).convert("sampler"),jm=Sc("camera").onRenderUpdate((()=>{jm.needsUpdate=!0})),qm=Cc("float").label("cameraNear").setGroup(jm).onRenderUpdate((({camera:e})=>e.near)),$m=Cc("float").label("cameraFar").setGroup(jm).onRenderUpdate((({camera:e})=>e.far)),Xm=Cc("float").label("cameraLogDepth").setGroup(jm).onRenderUpdate((({camera:e})=>2/(Math.log(e.far+1)/Math.LN2))),Ym=Cc("mat4").label("cameraProjectionMatrix").setGroup(jm).onRenderUpdate((({camera:e})=>e.projectionMatrix)),Jm=Cc("mat4").label("cameraProjectionMatrixInverse").setGroup(jm).onRenderUpdate((({camera:e})=>e.projectionMatrixInverse)),Zm=Cc("mat4").label("cameraViewMatrix").setGroup(jm).onRenderUpdate((({camera:e})=>e.matrixWorldInverse)),Km=Cc("mat4").label("cameraWorldMatrix").setGroup(jm).onRenderUpdate((({camera:e})=>e.matrixWorld)),Qm=Cc("mat3").label("cameraNormalMatrix").setGroup(jm).onRenderUpdate((({camera:e})=>e.normalMatrix)),eg=Cc(new Ei).label("cameraPosition").setGroup(jm).onRenderUpdate((({camera:e},t)=>t.value.setFromMatrixPosition(e.matrixWorld)));class tg extends Kl{constructor(e=tg.VIEW_MATRIX,t=null){super(),this.scope=e,this.object3d=t,this.updateType=Hl.OBJECT,this._uniformNode=new Rc(null)}getNodeType(){const e=this.scope;return e===tg.WORLD_MATRIX||e===tg.VIEW_MATRIX?"mat4":e===tg.NORMAL_MATRIX?"mat3":e===tg.POSITION||e===tg.VIEW_POSITION||e===tg.DIRECTION||e===tg.SCALE?"vec3":void 0}update(e){const t=this.object3d,s=this._uniformNode,i=this.scope;if(i===tg.VIEW_MATRIX)s.value=t.modelViewMatrix;else if(i===tg.NORMAL_MATRIX)s.value=t.normalMatrix;else if(i===tg.WORLD_MATRIX)s.value=t.matrixWorld;else if(i===tg.POSITION)s.value=s.value||new Ei,s.value.setFromMatrixPosition(t.matrixWorld);else if(i===tg.SCALE)s.value=s.value||new Ei,s.value.setFromMatrixScale(t.matrixWorld);else if(i===tg.DIRECTION)s.value=s.value||new Ei,t.getWorldDirection(s.value);else if(i===tg.VIEW_POSITION){const i=e.camera;s.value=s.value||new Ei,s.value.setFromMatrixPosition(t.matrixWorld),s.value.applyMatrix4(i.matrixWorldInverse)}}generate(e){const t=this.scope;return t===tg.WORLD_MATRIX||t===tg.VIEW_MATRIX?this._uniformNode.nodeType="mat4":t===tg.NORMAL_MATRIX?this._uniformNode.nodeType="mat3":t!==tg.POSITION&&t!==tg.VIEW_POSITION&&t!==tg.DIRECTION&&t!==tg.SCALE||(this._uniformNode.nodeType="vec3"),this._uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}tg.VIEW_MATRIX="viewMatrix",tg.NORMAL_MATRIX="normalMatrix",tg.WORLD_MATRIX="worldMatrix",tg.POSITION="position",tg.SCALE="scale",tg.VIEW_POSITION="viewPosition",tg.DIRECTION="direction",tg.type=Ql("Object3D",tg);const sg=Wu(tg,tg.DIRECTION),ig=Wu(tg,tg.VIEW_MATRIX),rg=Wu(tg,tg.NORMAL_MATRIX),ng=Wu(tg,tg.WORLD_MATRIX),og=Wu(tg,tg.POSITION),ag=Wu(tg,tg.SCALE),hg=Wu(tg,tg.VIEW_POSITION);class lg extends tg{constructor(e=lg.VIEW_MATRIX){super(e)}update(e){this.object3d=e.object,super.update(e)}}lg.type=Ql("Model",lg);const ug=Hu(lg,lg.DIRECTION),cg=Hu(lg,lg.VIEW_MATRIX).label("modelViewMatrix").toVar("ModelViewMatrix"),dg=Hu(lg,lg.NORMAL_MATRIX),pg=Hu(lg,lg.WORLD_MATRIX),mg=Hu(lg,lg.POSITION),gg=Hu(lg,lg.SCALE),fg=Hu(lg,lg.VIEW_POSITION),yg=Cc(new or).onObjectUpdate((({object:e},t)=>t.value.copy(e.matrixWorld).invert())),xg=zm("position","vec3"),bg=xg.varying("positionLocal"),vg=xg.varying("positionPrevious"),Tg=pg.mul(bg).xyz.varying("v_positionWorld"),_g=bg.transformDirection(pg).varying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),wg=cg.mul(bg).xyz.varying("v_positionView"),Sg=wg.negate().varying("v_positionViewDirection").normalize().toVar("positionViewDirection");class Mg extends Kl{constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){const{renderer:t,material:s}=e;return t.coordinateSystem===Vs&&s.side===d?"false":e.getFrontFacing()}}Mg.type=Ql("FrontFacing",Mg);const Ag=Hu(Mg),Ng=Ku(Ag).mul(2).sub(1),Rg=zm("normal","vec3"),Cg=ju((e=>!1===e.geometry.hasAttribute("normal")?(console.warn('TSL.NormalNode: Vertex attribute "normal" not found on geometry.'),oc(0,1,0)):Rg),"vec3").once()().toVar("normalLocal"),Eg=wg.dFdx().cross(wg.dFdy()).normalize().toVar("normalFlat");let Bg=null;const Ig=ju((e=>{let t;return t=!0===e.material.flatShading?Eg:Bg||(Bg=em(dg.mul(Cg),"v_normalView").normalize()),t}),"vec3").once()().toVar("normalView"),Pg=em(Ig.transformDirection(Zm),"v_normalWorld").normalize().toVar("normalWorld"),Fg=ju((e=>e.context.setupNormal()),"vec3").once()().mul(Ng).toVar("transformedNormalView"),zg=Fg.transformDirection(Zm).normalize().toVar("transformedNormalWorld"),Ug=ju((e=>e.context.setupClearcoatNormal()),"vec3").once()().mul(Ng).toVar("transformedClearcoatNormalView"),Lg=Cc(0).onReference((({material:e})=>e)).onRenderUpdate((({material:e})=>e.refractionRatio)),Og=Sg.negate().reflect(Fg),Vg=Sg.negate().refract(Fg,Lg),Dg=Og.transformDirection(Zm).toVar("reflectVector"),kg=Vg.transformDirection(Zm).toVar("reflectVector");class Gg extends km{constructor(e,t=null,s=null,i=null){super(e,t,s,i),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===he?Dg:e.mapping===le?kg:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),oc(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const s=this.value;return e.renderer.coordinateSystem!==Ds&&s.isRenderTargetTexture?t:oc(t.x.negate(),t.yz)}generateUV(e,t){return t.build(e,"vec3")}}Gg.type=Ql("CubeTexture",Gg);const Wg=Wu(Gg);class Hg extends Rc{constructor(e,t,s=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=s}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}Hg.type=Ql("Buffer",Hg);const jg=(e,t,s)=>Du(new Hg(e,t,s));class qg extends tu{constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=super.generate(e),s=this.getNodeType();return e.format(t,"vec4",s)}}class $g extends Hg{constructor(e,t=null){super(null,"vec4"),this.array=e,this.elementType=t,this._elementType=null,this._elementLength=0,this.updateType=Hl.RENDER,this.isArrayBufferNode=!0}getElementType(){return this.elementType||this._elementType}getElementLength(){return this._elementLength}update(){const{array:e,value:t}=this,s=this.getElementLength(),i=this.getElementType();if(1===s)for(let s=0;sDu(new $g(e,t));class Yg extends tu{constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),s=this.referenceNode.getNodeType(),i=this.getNodeType();return e.format(t,s,i)}}class Jg extends Kl{constructor(e,t,s=null,i=null){super(),this.property=e,this.uniformType=t,this.object=s,this.count=i,this.properties=e.split("."),this.reference=s,this.node=null,this.updateType=Hl.OBJECT}element(e){return Du(new Yg(this,Du(e)))}setNodeType(e){let t=null;t=null!==this.count?jg(null,e,this.count):Array.isArray(this.getValueFromReference())?Xg(null,e):"texture"===e?Gm(null):"cubeTexture"===e?Wg(null):Cc(null,e),this.node=t.getSelf()}getNodeType(e){return null===this.node&&this.updateValue(),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let s=e[t[0]];for(let e=1;eDu(new Jg(e,t,s)),Kg=(e,t,s,i)=>Du(new Jg(e,t,i,s));class Qg extends Jg{constructor(e,t,s=null){super(e,t,s),this.material=s,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=null!==this.material?this.material:e.material,this.reference}}Qg.type=Ql("MaterialReference",Qg);const ef=(e,t,s)=>Du(new Qg(e,t,s)),tf=ju((e=>(!1===e.geometry.hasAttribute("tangent")&&e.geometry.computeTangents(),zm("tangent","vec4"))))(),sf=tf.xyz.toVar("tangentLocal"),rf=cg.mul(uc(sf,0)).xyz.varying("v_tangentView").normalize().toVar("tangentView"),nf=rf.transformDirection(Zm).varying("v_tangentWorld").normalize().toVar("tangentWorld"),of=rf.toVar("transformedTangentView"),af=of.transformDirection(Zm).normalize().toVar("transformedTangentWorld"),hf=e=>e.mul(tf.w).xyz,lf=em(hf(Rg.cross(tf)),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),uf=em(hf(Cg.cross(sf)),"v_bitangentLocal").normalize().toVar("bitangentLocal"),cf=em(hf(Ig.cross(rf)),"v_bitangentView").normalize().toVar("bitangentView"),df=em(hf(Pg.cross(nf)),"v_bitangentWorld").normalize().toVar("bitangentWorld"),pf=hf(Fg.cross(of)).normalize().toVar("transformedBitangentView"),mf=pf.transformDirection(Zm).normalize().toVar("transformedBitangentWorld"),gf=gc(rf,cf,Ig),ff=Sg.mul(gf),yf=(e,t)=>e.sub(ff.mul(t)),xf=(()=>{let e=$c.cross(Sg);return e=e.cross($c).normalize(),e=Up(e,Fg,jc.mul(zc.oneMinus()).oneMinus().pow2().pow2()).normalize(),e})(),bf=ju((e=>{const{eye_pos:t,surf_norm:s,mapN:i,uv:r}=e,n=t.dFdx(),o=t.dFdy(),a=r.dFdx(),h=r.dFdy(),l=s,u=o.cross(l),c=l.cross(n),d=u.mul(a.x).add(c.mul(h.x)),p=u.mul(a.y).add(c.mul(h.y)),m=d.dot(d).max(p.dot(p)),g=Ng.mul(m.inverseSqrt());return dd(d.mul(i.x,g),p.mul(i.y,g),l.mul(i.z)).normalize()}));class vf extends iu{constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=0}setup(e){const{normalMapType:t,scaleNode:s}=this;let i=this.node.mul(2).sub(1);null!==s&&(i=oc(i.xy.mul(s),i.z));let r=null;if(1===t)r=dg.mul(i).normalize();else if(0===t){r=!0===e.hasGeometryAttribute("tangent")?gf.mul(i).normalize():bf({eye_pos:wg,surf_norm:Ig,mapN:i,uv:Um()})}return r}}vf.type=Ql("NormalMap",vf);const Tf=Wu(vf),_f=ju((({textureNode:e,bumpScale:t})=>{const s=t=>e.cache().context({getUV:e=>t(e.uvNode||Um()),forceUVContext:!0}),i=Ku(s((e=>e)));return sc(Ku(s((e=>e.add(e.dFdx())))).sub(i),Ku(s((e=>e.add(e.dFdy())))).sub(i)).mul(t)})),wf=ju((e=>{const{surf_pos:t,surf_norm:s,dHdxy:i}=e,r=t.dFdx().normalize(),n=s,o=t.dFdy().normalize().cross(n),a=n.cross(r),h=r.dot(o).mul(Ng),l=h.sign().mul(i.x.mul(o).add(i.y.mul(a)));return h.abs().mul(s).sub(l).normalize()}));class Sf extends iu{constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=null!==this.scaleNode?this.scaleNode:1,t=_f({textureNode:this.textureNode,bumpScale:e});return wf({surf_pos:wg,surf_norm:Ig,dHdxy:t})}}const Mf=Wu(Sf),Af=new Map;class Nf extends Kl{constructor(e){super(),this.scope=e}getCache(e,t){let s=Af.get(e);return void 0===s&&(s=ef(e,t),Af.set(e,s)),s}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache("map"===e?"map":e+"Map","texture")}setup(e){const t=e.context.material,s=this.scope;let i=null;if(s===Nf.COLOR){const e=void 0!==t.color?this.getColor(s):oc();i=t.map&&!0===t.map.isTexture?e.mul(this.getTexture("map")):e}else if(s===Nf.OPACITY){const e=this.getFloat(s);i=t.alphaMap&&!0===t.alphaMap.isTexture?e.mul(this.getTexture("alpha")):e}else if(s===Nf.SPECULAR_STRENGTH)i=t.specularMap&&!0===t.specularMap.isTexture?this.getTexture("specular").r:Ku(1);else if(s===Nf.SPECULAR_INTENSITY){const e=this.getFloat(s);i=t.specularMap?e.mul(this.getTexture(s).a):e}else if(s===Nf.SPECULAR_COLOR){const e=this.getColor(s);i=t.specularColorMap&&!0===t.specularColorMap.isTexture?e.mul(this.getTexture(s).rgb):e}else if(s===Nf.ROUGHNESS){const e=this.getFloat(s);i=t.roughnessMap&&!0===t.roughnessMap.isTexture?e.mul(this.getTexture(s).g):e}else if(s===Nf.METALNESS){const e=this.getFloat(s);i=t.metalnessMap&&!0===t.metalnessMap.isTexture?e.mul(this.getTexture(s).b):e}else if(s===Nf.EMISSIVE){const e=this.getFloat("emissiveIntensity"),r=this.getColor(s).mul(e);i=t.emissiveMap&&!0===t.emissiveMap.isTexture?r.mul(this.getTexture(s)):r}else if(s===Nf.NORMAL)i=t.normalMap?Tf(this.getTexture("normal"),this.getCache("normalScale","vec2")):t.bumpMap?Mf(this.getTexture("bump").r,this.getFloat("bumpScale")):Ig;else if(s===Nf.CLEARCOAT){const e=this.getFloat(s);i=t.clearcoatMap&&!0===t.clearcoatMap.isTexture?e.mul(this.getTexture(s).r):e}else if(s===Nf.CLEARCOAT_ROUGHNESS){const e=this.getFloat(s);i=t.clearcoatRoughnessMap&&!0===t.clearcoatRoughnessMap.isTexture?e.mul(this.getTexture(s).r):e}else if(s===Nf.CLEARCOAT_NORMAL)i=t.clearcoatNormalMap?Tf(this.getTexture(s),this.getCache(s+"Scale","vec2")):Ig;else if(s===Nf.SHEEN){const e=this.getColor("sheenColor").mul(this.getFloat("sheen"));i=t.sheenColorMap&&!0===t.sheenColorMap.isTexture?e.mul(this.getTexture("sheenColor").rgb):e}else if(s===Nf.SHEEN_ROUGHNESS){const e=this.getFloat(s);i=t.sheenRoughnessMap&&!0===t.sheenRoughnessMap.isTexture?e.mul(this.getTexture(s).a):e,i=i.clamp(.07,1)}else if(s===Nf.ANISOTROPY)if(t.anisotropyMap&&!0===t.anisotropyMap.isTexture){const e=this.getTexture(s);i=mc(cy.x,cy.y,cy.y.negate(),cy.x).mul(e.rg.mul(2).sub(sc(1)).normalize().mul(e.b))}else i=cy;else if(s===Nf.IRIDESCENCE_THICKNESS){const e=Zg("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const r=Zg("0","float",t.iridescenceThicknessRange);i=e.sub(r).mul(this.getTexture(s).g).add(r)}else i=e}else if(s===Nf.TRANSMISSION){const e=this.getFloat(s);i=t.transmissionMap?e.mul(this.getTexture(s).r):e}else if(s===Nf.THICKNESS){const e=this.getFloat(s);i=t.thicknessMap?e.mul(this.getTexture(s).g):e}else if(s===Nf.IOR)i=this.getFloat(s);else if(s===Nf.LIGHT_MAP)i=this.getTexture(s).rgb.mul(this.getFloat("lightMapIntensity"));else if(s===Nf.AO_MAP)i=this.getTexture(s).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else{const t=this.getNodeType(e);i=this.getCache(s,t)}return i}}Nf.ALPHA_TEST="alphaTest",Nf.COLOR="color",Nf.OPACITY="opacity",Nf.SHININESS="shininess",Nf.SPECULAR="specular",Nf.SPECULAR_STRENGTH="specularStrength",Nf.SPECULAR_INTENSITY="specularIntensity",Nf.SPECULAR_COLOR="specularColor",Nf.REFLECTIVITY="reflectivity",Nf.ROUGHNESS="roughness",Nf.METALNESS="metalness",Nf.NORMAL="normal",Nf.CLEARCOAT="clearcoat",Nf.CLEARCOAT_ROUGHNESS="clearcoatRoughness",Nf.CLEARCOAT_NORMAL="clearcoatNormal",Nf.EMISSIVE="emissive",Nf.ROTATION="rotation",Nf.SHEEN="sheen",Nf.SHEEN_ROUGHNESS="sheenRoughness",Nf.ANISOTROPY="anisotropy",Nf.IRIDESCENCE="iridescence",Nf.IRIDESCENCE_IOR="iridescenceIOR",Nf.IRIDESCENCE_THICKNESS="iridescenceThickness",Nf.IOR="ior",Nf.TRANSMISSION="transmission",Nf.THICKNESS="thickness",Nf.ATTENUATION_DISTANCE="attenuationDistance",Nf.ATTENUATION_COLOR="attenuationColor",Nf.LINE_SCALE="scale",Nf.LINE_DASH_SIZE="dashSize",Nf.LINE_GAP_SIZE="gapSize",Nf.LINE_WIDTH="linewidth",Nf.LINE_DASH_OFFSET="dashOffset",Nf.POINT_WIDTH="pointWidth",Nf.DISPERSION="dispersion",Nf.LIGHT_MAP="light",Nf.AO_MAP="ao",Nf.type=Ql("Material",Nf);const Rf=Hu(Nf,Nf.ALPHA_TEST),Cf=Hu(Nf,Nf.COLOR),Ef=Hu(Nf,Nf.SHININESS),Bf=Hu(Nf,Nf.EMISSIVE),If=Hu(Nf,Nf.OPACITY),Pf=Hu(Nf,Nf.SPECULAR),Ff=Hu(Nf,Nf.SPECULAR_INTENSITY),zf=Hu(Nf,Nf.SPECULAR_COLOR),Uf=Hu(Nf,Nf.SPECULAR_STRENGTH),Lf=Hu(Nf,Nf.REFLECTIVITY),Of=Hu(Nf,Nf.ROUGHNESS),Vf=Hu(Nf,Nf.METALNESS),Df=Hu(Nf,Nf.NORMAL).context({getUV:null}),kf=Hu(Nf,Nf.CLEARCOAT),Gf=Hu(Nf,Nf.CLEARCOAT_ROUGHNESS),Wf=Hu(Nf,Nf.CLEARCOAT_NORMAL).context({getUV:null}),Hf=Hu(Nf,Nf.ROTATION),jf=Hu(Nf,Nf.SHEEN),qf=Hu(Nf,Nf.SHEEN_ROUGHNESS),$f=Hu(Nf,Nf.ANISOTROPY),Xf=Hu(Nf,Nf.IRIDESCENCE),Yf=Hu(Nf,Nf.IRIDESCENCE_IOR),Jf=Hu(Nf,Nf.IRIDESCENCE_THICKNESS),Zf=Hu(Nf,Nf.TRANSMISSION),Kf=Hu(Nf,Nf.THICKNESS),Qf=Hu(Nf,Nf.IOR),ey=Hu(Nf,Nf.ATTENUATION_DISTANCE),ty=Hu(Nf,Nf.ATTENUATION_COLOR),sy=Hu(Nf,Nf.LINE_SCALE),iy=Hu(Nf,Nf.LINE_DASH_SIZE),ry=Hu(Nf,Nf.LINE_GAP_SIZE),ny=Hu(Nf,Nf.LINE_WIDTH),oy=Hu(Nf,Nf.LINE_DASH_OFFSET),ay=Hu(Nf,Nf.POINT_WIDTH),hy=Hu(Nf,Nf.DISPERSION),ly=Hu(Nf,Nf.LIGHT_MAP),uy=Hu(Nf,Nf.AO_MAP);Nf.REFRACTION_RATIO;const cy=Cc(new Qs).onReference((function(e){return e.material})).onRenderUpdate((function({material:e}){this.value.set(e.anisotropy*Math.cos(e.anisotropyRotation),e.anisotropy*Math.sin(e.anisotropyRotation))}));class dy extends iu{constructor(e=null){super("vec4"),this.positionNode=e}setup(e){if("fragment"===e.shaderStage)return em(e.context.mvp);const t=this.positionNode||bg;return Ym.mul(cg).mul(t)}}dy.type=Ql("ModelViewProjection",dy);const py=Wu(dy);class my extends Kl{constructor(e){super("uint"),this.scope=e,this.isInstanceIndexNode=!0}generate(e){const t=this.getNodeType(e),s=this.scope;let i,r;if(s===my.VERTEX)i=e.getVertexIndex();else if(s===my.INSTANCE)i=e.getInstanceIndex();else if(s===my.DRAW)i=e.getDrawIndex();else{if(s!==my.INVOCATION_LOCAL)throw new Error("THREE.IndexNode: Unknown scope: "+s);i=e.getInvocationLocalIndex()}if("vertex"===e.shaderStage||"compute"===e.shaderStage)r=i;else{r=em(this).build(e,t)}return r}}my.VERTEX="vertex",my.INSTANCE="instance",my.INVOCATION_LOCAL="invocationLocal",my.DRAW="draw",my.type=Ql("Index",my);const gy=Hu(my,my.VERTEX),fy=Hu(my,my.INSTANCE),yy=Hu(my,my.INVOCATION_LOCAL),xy=Hu(my,my.DRAW);class by extends oo{constructor(e,t,s=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=s}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class vy extends Kl{constructor(e){super("void"),this.instanceMesh=e,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=Hl.FRAME,this.buffer=null,this.bufferColor=null}setup(e){let t=this.instanceMatrixNode,s=this.instanceColorNode;const i=this.instanceMesh;if(null===t){const e=i.instanceMatrix;if(i.count<=1e3)t=jg(e.array,"mat4",i.count).element(fy);else{const s=new by(e.array,16,1);this.buffer=s;const i=e.usage===Cs?ym:fm,r=[i(s,"vec4",16,0),i(s,"vec4",16,4),i(s,"vec4",16,8),i(s,"vec4",16,12)];t=fc(...r)}this.instanceMatrixNode=t}const r=i.instanceColor;if(r&&null===s){const e=new Ho(r.array,3),t=r.usage===Cs?ym:fm;this.bufferColor=e,s=oc(t(e,"vec3",3,0)),this.instanceColorNode=s}const n=t.mul(bg).xyz;if(bg.assign(n),e.hasGeometryAttribute("normal")){const e=gc(t),s=Cg.div(oc(e[0].dot(e[0]),e[1].dot(e[1]),e[2].dot(e[2]))),i=e.mul(s).xyz;Cg.assign(i)}null!==this.instanceColorNode&&Ic("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMesh.instanceMatrix.usage!==Cs&&null!=this.buffer&&this.instanceMesh.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMesh.instanceMatrix.version),this.instanceMesh.instanceColor&&this.instanceMesh.instanceColor.usage!==Cs&&null!=this.bufferColor&&this.instanceMesh.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceMesh.instanceColor.version)}}vy.type=Ql("Instance",vy);const Ty=Wu(vy);class _y extends Kl{constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){null===this.batchingIdNode&&(null===e.getDrawIndex()?this.batchingIdNode=fy:this.batchingIdNode=xy);const t=ju((([e])=>{const t=Om(Wm(this.batchMesh._indirectTexture),0),s=Qu(e).modInt(Qu(t)),i=Qu(e).div(Qu(t));return Wm(this.batchMesh._indirectTexture,ic(s,i)).x})).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]}),s=t(Qu(this.batchingIdNode)),i=this.batchMesh._matricesTexture,r=Om(Wm(i),0),n=Ku(s).mul(4).toInt().toVar(),o=n.modInt(r),a=n.div(Qu(r)),h=fc(Wm(i,ic(o,a)),Wm(i,ic(o.add(1),a)),Wm(i,ic(o.add(2),a)),Wm(i,ic(o.add(3),a))),l=this.batchMesh._colorsTexture;if(null!==l){const e=ju((([e])=>{const t=Om(Wm(l),0).x,s=e,i=s.modInt(t),r=s.div(t);return Wm(l,ic(i,r)).rgb})).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]}),t=e(s);Ic("vec3","vBatchColor").assign(t)}const u=gc(h);bg.assign(h.mul(bg));const c=Cg.div(oc(u[0].dot(u[0]),u[1].dot(u[1]),u[2].dot(u[2]))),d=u.mul(c).xyz;Cg.assign(d),e.hasGeometryAttribute("tangent")&&sf.mulAssign(u)}}_y.type=Ql("Batch",_y);const wy=Wu(_y),Sy=new WeakMap;class My extends Kl{constructor(e,t=!1){let s,i,r;super("void"),this.skinnedMesh=e,this.useReference=t,this.updateType=Hl.OBJECT,this.skinIndexNode=zm("skinIndex","uvec4"),this.skinWeightNode=zm("skinWeight","vec4"),t?(s=Zg("bindMatrix","mat4"),i=Zg("bindMatrixInverse","mat4"),r=Kg("skeleton.boneMatrices","mat4",e.skeleton.bones.length)):(s=Cc(e.bindMatrix,"mat4"),i=Cc(e.bindMatrixInverse,"mat4"),r=jg(e.skeleton.boneMatrices,"mat4",e.skeleton.bones.length)),this.bindMatrixNode=s,this.bindMatrixInverseNode=i,this.boneMatricesNode=r,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=bg){const{skinIndexNode:s,skinWeightNode:i,bindMatrixNode:r,bindMatrixInverseNode:n}=this,o=e.element(s.x),a=e.element(s.y),h=e.element(s.z),l=e.element(s.w),u=r.mul(t),c=dd(o.mul(i.x).mul(u),a.mul(i.y).mul(u),h.mul(i.z).mul(u),l.mul(i.w).mul(u));return n.mul(c).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=Cg){const{skinIndexNode:s,skinWeightNode:i,bindMatrixNode:r,bindMatrixInverseNode:n}=this,o=e.element(s.x),a=e.element(s.y),h=e.element(s.z),l=e.element(s.w);let u=dd(i.x.mul(o),i.y.mul(a),i.z.mul(h),i.w.mul(l));return u=n.mul(u).mul(r),u.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return null===this.previousBoneMatricesNode&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=Kg("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,vg)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")}setup(e){this.needsPreviousBoneMatrices(e)&&vg.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(bg.assign(t),e.hasGeometryAttribute("normal")){const t=this.getSkinnedNormal();Cg.assign(t),e.hasGeometryAttribute("tangent")&&sf.assign(t)}}generate(e,t){if("void"!==t)return bg.build(e,t)}update(e){const t=(this.useReference?e.object:this.skinnedMesh).skeleton;Sy.get(t)!==e.frameId&&(Sy.set(t,e.frameId),null!==this.previousBoneMatricesNode&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}}My.type=Ql("Skinning",My);const Ay=e=>Du(new My(e)),Ny=e=>Du(new My(e,!0));class Ry extends Kl{constructor(e=[]){super(),this.params=e}getVarName(e){return String.fromCharCode("i".charCodeAt()+e)}getProperties(e){const t=e.getNodeProperties(this);if(void 0!==t.stackNode)return t;const s={};for(let e=0,t=this.params.length-1;eNumber(n)?">=":"<"));const u={start:r,end:n,condition:h},c=u.start,d=u.end;let p="",m="",g="";l||(l="int"===a||"uint"===a?h.includes("<")?"++":"--":h.includes("<")?"+= 1.":"-= 1."),p+=e.getVar(a,o)+" = "+c,m+=o+" "+h+" "+d,g+=o+" "+l;const f=`for ( ${p}; ${m}; ${g} )`;e.addFlowCode((0===t?"\n":"")+e.tab+f+" {\n\n").addFlowTab()}const r=i.build(e,"void"),n=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode("\n"+e.tab+r);for(let t=0,s=this.params.length-1;tDu(new Ry(Gu(e,"int"))).append(),Ey=()=>Rm("continue").append(),By=()=>Rm("break").append(),Iy=new WeakMap,Py=new _i,Fy=ju((({bufferMap:e,influence:t,stride:s,width:i,depth:r,offset:n})=>{const o=Qu(gy).mul(s).add(n),a=o.div(i),h=o.sub(a.mul(i));return Wm(e,ic(h,a)).depth(r).mul(t)}));class zy extends Kl{constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=Cc(1),this.updateType=Hl.OBJECT}setup(e){const{geometry:t}=e,s=void 0!==t.morphAttributes.position,i=t.hasAttribute("normal")&&void 0!==t.morphAttributes.normal,r=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,n=void 0!==r?r.length:0,{texture:o,stride:a,size:h}=function(e){const t=void 0!==e.morphAttributes.position,s=void 0!==e.morphAttributes.normal,i=void 0!==e.morphAttributes.color,r=e.morphAttributes.position||e.morphAttributes.normal||e.morphAttributes.color,n=void 0!==r?r.length:0;let o=Iy.get(e);if(void 0===o||o.count!==n){void 0!==o&&o.texture.dispose();const a=e.morphAttributes.position||[],h=e.morphAttributes.normal||[],l=e.morphAttributes.color||[];let u=0;!0===t&&(u=1),!0===s&&(u=2),!0===i&&(u=3);let c=e.attributes.position.count*u,d=1;const p=4096;c>p&&(d=Math.ceil(c/p),c=p);const m=new Float32Array(c*d*4*n),g=new Mi(m,c,d,n);g.type=Ie,g.needsUpdate=!0;const f=4*u;for(let x=0;x{const t=Ku(0).toVar();this.mesh.count>1&&null!==this.mesh.morphTexture&&void 0!==this.mesh.morphTexture?t.assign(Wm(this.mesh.morphTexture,ic(Qu(e).add(1),Qu(fy))).r):t.assign(Zg("morphTargetInfluences","float").element(e).toVar()),!0===s&&bg.addAssign(Fy({bufferMap:o,influence:t,stride:a,width:l,depth:e,offset:Qu(0)})),!0===i&&Cg.addAssign(Fy({bufferMap:o,influence:t,stride:a,width:l,depth:e,offset:Qu(1)}))}))}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce(((e,t)=>e+t),0)}}zy.type=Ql("Morph",zy);const Uy=Wu(zy),Ly=(e,t)=>{for(const s of t)if(s.isAnalyticLightNode&&s.light.id===e)return s;return null};class Oy extends Kl{constructor(e=[]){super("vec3"),this.totalDiffuseNode=oc().toVar("totalDiffuse"),this.totalSpecularNode=oc().toVar("totalSpecular"),this.outgoingLightNode=oc().toVar("outgoingLight"),this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this.global=!0}getHash(e){if(null===this._lightNodesHash){null===this._lightNodes&&this.setupLightsNode(e);const t=[];for(const e of this._lightNodes)t.push(e.getHash());this._lightNodesHash="lights-"+t.join(",")}return this._lightNodesHash}analyze(e){const t=e.getDataFromNode(this);for(const s of t.nodes)s.build(e)}setupLightsNode(e){const t=[],s=this._lightNodes,i=(e=>e.sort(((e,t)=>e.id-t.id)))(this._lights),r=e.renderer.nodes.library;for(const e of i)if(e.isNode)t.push(Du(e));else{let i=null;if(null!==s&&(i=Ly(e.id,s)),null===i){const s=r.getLightNodeClass(e.constructor);if(void 0===s){console.warn(`LightsNode.setupNodeLights: Light node not found for ${e.constructor.name}`);continue}t.push(Du(new s(e)))}}this._lightNodes=t}setup(e){null===this._lightNodes&&this.setupLightsNode(e);const t=e.context,s=t.lightingModel;let i=this.outgoingLightNode;if(s){const{_lightNodes:r,totalDiffuseNode:n,totalSpecularNode:o}=this;t.outgoingLight=i;const a=e.addStack();e.getDataFromNode(this).nodes=a.nodes,s.start(t,a,e);for(const t of r)t.build(e);s.indirect(t,a,e);const{backdrop:h,backdropAlpha:l}=t,{directDiffuse:u,directSpecular:c,indirectDiffuse:d,indirectSpecular:p}=t.reflectedLight;let m=u.add(d);null!==h&&(m=oc(null!==l?l.mix(m,h):h),t.material.transparent=!0),n.assign(m),o.assign(c.add(p)),i.assign(n.add(o)),s.finish(t,a,e),i=i.bypass(e.removeStack())}return i}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}}Oy.type=Ql("Lights",Oy);const Vy=Wu(Oy);class Dy extends Kl{constructor(){super("vec3"),this.isLightingNode=!0}generate(){console.warn("Abstract function.")}}Dy.type=Ql("Lighting",Dy);class ky extends Dy{constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}ky.type=Ql("AO",ky);class Gy extends Xp{constructor(e,t=null,s=null,i=null){super(e),this.lightingModel=t,this.backdropNode=s,this.backdropAlphaNode=i,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,s={directDiffuse:oc().toVar("directDiffuse"),directSpecular:oc().toVar("directSpecular"),indirectDiffuse:oc().toVar("indirectDiffuse"),indirectSpecular:oc().toVar("indirectSpecular")};return{radiance:oc().toVar("radiance"),irradiance:oc().toVar("irradiance"),iblIrradiance:oc().toVar("iblIrradiance"),ambientOcclusion:Ku(1).toVar("ambientOcclusion"),reflectedLight:s,backdrop:e,backdropAlpha:t}}setup(e){return this.value=this._value||(this._value=this.getContext()),this.value.lightingModel=this.lightingModel||e.context.lightingModel,super.setup(e)}}Gy.type=Ql("LightingContext",Gy);const Wy=Wu(Gy);class Hy extends Dy{constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}let jy,qy;Hy.type=Ql("Irradiance",Hy);class $y extends Kl{constructor(e){super(),this.scope=e,this.isViewportNode=!0}getNodeType(){return this.scope===$y.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=Hl.NONE;return this.scope!==$y.RESOLUTION&&this.scope!==$y.VIEWPORT||(e=Hl.RENDER),this.updateType=e,e}update({renderer:e}){this.scope===$y.VIEWPORT?e.getViewport(qy):e.getDrawingBufferSize(jy)}setup(){const e=this.scope;let t=null;return t=e===$y.RESOLUTION?Cc(jy||(jy=new Qs)):e===$y.VIEWPORT?Cc(qy||(qy=new _i)):sc(Xy.div(Yy)),t}generate(e){if(this.scope===$y.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const s=e.getNodeProperties(Yy).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${s}.y - ${t}.y )`}return t}return super.generate(e)}}$y.COORDINATE="coordinate",$y.RESOLUTION="resolution",$y.VIEWPORT="viewport",$y.UV="uv",$y.type=Ql("Viewport",$y);const Xy=Hu($y,$y.COORDINATE),Yy=Hu($y,$y.RESOLUTION),Jy=Hu($y,$y.VIEWPORT),Zy=Hu($y,$y.UV),Ky=ju((()=>(console.warn('TSL.ViewportNode: "viewportTopLeft" is deprecated. Use "viewportUV" instead.'),Zy)),"vec2").once()(),Qy=ju((()=>(console.warn('TSL.ViewportNode: "viewportBottomLeft" is deprecated. Use "viewportUV.flipY()" instead.'),Zy.flipY())),"vec2").once()(),ex=new Qs;class tx extends km{constructor(e=Zy,t=null,s=null){null===s&&((s=new Xa).minFilter=Se),super(s,e,t),this.generateMipmaps=!1,this.isOutputTextureNode=!0,this.updateBeforeType=Hl.FRAME}updateBefore(e){const t=e.renderer;t.getDrawingBufferSize(ex);const s=this.value;s.image.width===ex.width&&s.image.height===ex.height||(s.image.width=ex.width,s.image.height=ex.height,s.needsUpdate=!0);const i=s.generateMipmaps;s.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(s),s.generateMipmaps=i}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}tx.type=Ql("ViewportTexture",tx);const sx=Wu(tx),ix=Wu(tx,null,null,{generateMipmaps:!0});let rx=null;class nx extends tx{constructor(e=Zy,t=null){null===rx&&(rx=new Qa),super(e,t,rx)}}nx.type=Ql("ViewportDepthTexture",nx);const ox=Wu(nx);class ax extends Kl{constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===ax.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,s=this.valueNode;let i=null;if(t===ax.DEPTH_BASE)null!==s&&(i=dx().assign(s));else if(t===ax.DEPTH)i=e.isPerspectiveCamera?ux(wg.z,qm,$m):hx(wg.z,qm,$m);else if(t===ax.LINEAR_DEPTH)if(null!==s)if(e.isPerspectiveCamera){const e=cx(s,qm,$m);i=hx(e,qm,$m)}else i=s;else i=hx(wg.z,qm,$m);return i}}ax.DEPTH_BASE="depthBase",ax.DEPTH="depth",ax.LINEAR_DEPTH="linearDepth",ax.type=Ql("ViewportDepth",ax);const hx=(e,t,s)=>e.add(t).div(t.sub(s)),lx=(e,t,s)=>t.sub(s).mul(e).sub(t),ux=(e,t,s)=>t.add(e).mul(s).div(s.sub(t).mul(e)),cx=(e,t,s)=>t.mul(s).div(s.sub(t).mul(e).sub(s)),dx=Wu(ax,ax.DEPTH_BASE),px=Hu(ax,ax.DEPTH),mx=Wu(ax,ax.LINEAR_DEPTH),gx=mx(ox());px.assign=e=>dx(e);class fx extends Kl{constructor(e=fx.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{localClipIntersection:s,localClippingCount:i,globalClippingCount:r}=t,n=r+i,o=s?n-i:n;return this.scope===fx.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(t.planes,n,o):this.setupDefault(t.planes,n,o)}setupAlphaToCoverage(e,t,s){return ju((()=>{const i=Xg(e),r=Bc("float","distanceToPlane"),n=Bc("float","distanceToGradient"),o=Bc("float","clipOpacity");let a;if(o.assign(1),Cy(s,(({i:e})=>{a=i.element(e),r.assign(wg.dot(a.xyz).negate().add(a.w)),n.assign(r.fwidth().div(2)),o.mulAssign(Dp(n.negate(),n,r)),o.equal(0).discard()})),s{a=i.element(t),r.assign(wg.dot(a.xyz).negate().add(a.w)),n.assign(r.fwidth().div(2)),e.mulAssign(Dp(n.negate(),n,r).oneMinus())})),o.mulAssign(e.oneMinus())}Pc.a.mulAssign(o),Pc.a.equal(0).discard()}))()}setupDefault(e,t,s){return ju((()=>{const i=Xg(e);let r;if(Cy(s,(({i:e})=>{r=i.element(e),wg.dot(r.xyz).greaterThan(r.w).discard()})),s{r=i.element(t),e.assign(wg.dot(r.xyz).greaterThan(r.w).and(e))})),e.discard()}}))()}}fx.ALPHA_TO_COVERAGE="alphaToCoverage",fx.DEFAULT="default",fx.type=Ql("Clipping",fx);const yx=new Map;class xx extends Kr{constructor(){super(),this.isNodeMaterial=!0,this.type=this.constructor.type,this.forceSinglePass=!1,this.fog=!0,this.lights=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.positionNode=null,this.depthNode=null,this.shadowNode=null,this.shadowPositionNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null}customProgramCacheKey(){return this.type+Ul(this)}build(e){this.setup(e)}setup(e){let t;e.context.setupNormal=()=>this.setupNormal(e),e.addStack(),e.stack.outputNode=this.vertexNode||this.setupPosition(e),e.addFlow("vertex",e.removeStack()),e.addStack();const s=this.setupClipping(e);if(!0===this.depthWrite&&this.setupDepth(e),null===this.fragmentNode){this.setupDiffuseColor(e),this.setupVariants(e);const i=this.setupLighting(e);null!==s&&e.stack.add(s);const r=uc(i,Pc.a).max(0);t=this.setupOutput(e,r),Zc.assign(t),null!==this.outputNode&&(t=this.outputNode);if(null!==e.renderer.getRenderTarget()){const s=e.renderer.getMRT(),i=this.mrtNode;null!==s?(t=s,null!==i&&(t=s.merge(i))):null!==i&&(t=i)}}else{let s=this.fragmentNode;!0!==s.isOutputStructNode&&(s=uc(s)),t=this.setupOutput(e,s)}e.stack.outputNode=t,e.addFlow("fragment",e.removeStack())}setupClipping(e){if(null===e.clippingContext)return null;const{globalClippingCount:t,localClippingCount:s}=e.clippingContext;let i=null;return(t||s)&&(this.alphaToCoverage?i=Du(new fx(fx.ALPHA_TO_COVERAGE)):e.stack.add(Du(new fx))),i}setupDepth(e){const{renderer:t}=e;let s=this.depthNode;if(null===s){const e=t.getMRT();if(e&&e.has("depth"))s=e.get("depth");else if(!0===t.logarithmicDepthBuffer){s=py().w.add(1).log2().mul(Xm).mul(.5)}}null!==s&&px.assign(s).append()}setupPosition(e){const{object:t}=e,s=t.geometry;if(e.addStack(),(s.morphAttributes.position||s.morphAttributes.normal||s.morphAttributes.color)&&Uy(t).append(),!0===t.isSkinnedMesh&&Ny(t).append(),this.displacementMap){const e=ef("displacementMap","texture"),t=ef("displacementScale","float"),s=ef("displacementBias","float");bg.addAssign(Cg.normalize().mul(e.x.mul(t).add(s)))}t.isBatchedMesh&&wy(t).append(),t.instanceMatrix&&!0===t.instanceMatrix.isInstancedBufferAttribute&&Ty(t).append(),null!==this.positionNode&&bg.assign(this.positionNode);const i=py();return e.context.vertex=e.removeStack(),e.context.mvp=i,i}setupDiffuseColor({object:e,geometry:t}){let s=this.colorNode?uc(this.colorNode):Cf;if(!0===this.vertexColors&&t.hasAttribute("color")&&(s=uc(s.xyz.mul(zm("color","vec3")),s.a)),e.instanceColor){s=Ic("vec3","vInstanceColor").mul(s)}if(e.isBatchedMesh&&e._colorsTexture){s=Ic("vec3","vBatchColor").mul(s)}Pc.assign(s);const i=this.opacityNode?Ku(this.opacityNode):If;if(Pc.a.assign(Pc.a.mul(i)),null!==this.alphaTestNode||this.alphaTest>0){const e=null!==this.alphaTestNode?Ku(this.alphaTestNode):Rf;Pc.a.lessThanEqual(e).discard()}!1===this.transparent&&1===this.blending&&!1===this.alphaToCoverage&&Pc.a.assign(1)}setupVariants(){}setupOutgoingLight(){return!0===this.lights?oc(0):Pc.rgb}setupNormal(){return this.normalNode?oc(this.normalNode):Df}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?ef("envMap","cubeTexture"):ef("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new Hy(ly)),t}setupLights(e){const t=[],s=this.setupEnvironment(e);s&&s.isLightingNode&&t.push(s);const i=this.setupLightMap(e);if(i&&i.isLightingNode&&t.push(i),null!==this.aoNode||e.material.aoMap){const e=null!==this.aoNode?this.aoNode:uy;t.push(new ky(e))}let r=this.lightsNode||e.lightsNode;return t.length>0&&(r=Vy([...r.getLights(),...t])),r}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:s,backdropAlphaNode:i,emissiveNode:r}=this,n=!0===this.lights||null!==this.lightsNode?this.setupLights(e):null;let o=this.setupOutgoingLight(e);if(n&&n.getScope().getLights().length>0){const t=this.setupLightingModel(e);o=Wy(n,t,s,i)}else null!==s&&(o=oc(null!==i?Up(o,s,i):s));return(r&&!0===r.isNode||t.emissive&&!0===t.emissive.isColor)&&(Fc.assign(oc(r||Bf)),o=o.add(Fc)),o}setupOutput(e,t){if(!0===this.fog){const s=e.fogNode;s&&(t=uc(s.mix(t.rgb,s.colorNode),t.a))}return t}setDefaultValues(e){for(const t in e){const s=e[t];void 0===this[t]&&(this[t]=s,s&&s.clone&&(this[t]=s.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const e in t)void 0===Object.getOwnPropertyDescriptor(this.constructor.prototype,e)&&void 0!==t[e].get&&Object.defineProperty(this.constructor.prototype,e,t[e])}toJSON(e){const t=void 0===e||"string"==typeof e;t&&(e={textures:{},images:{},nodes:{}});const s=Kr.prototype.toJSON.call(this,e),i=Ll(this);s.inputNodes={};for(const{property:t,childNode:r}of i)s.inputNodes[t]=r.toJSON(e).uuid;function r(e){const t=[];for(const s in e){const i=e[s];delete i.metadata,t.push(i)}return t}if(t){const t=r(e.textures),i=r(e.images),n=r(e.nodes);t.length>0&&(s.textures=t),i.length>0&&(s.images=i),n.length>0&&(s.nodes=n)}return s}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.positionNode=e.positionNode,this.depthNode=e.depthNode,this.shadowNode=e.shadowNode,this.shadowPositionNode=e.shadowPositionNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}function bx(e,t){const s="NodeMaterial",i=e+s;if("function"!=typeof t)throw new Error(`THREE.Node: NodeMaterial class "${e}" is not a class.`);if(yx.has(i))console.warn(`THREE.Node: Redefinition of NodeMaterial class "${i}".`);else{if(e.slice(-12)!==s)return yx.set(i,t),t.type=i,i;console.warn(`THREE.NodeMaterial: NodeMaterial class ${i} should not have '${s}' suffix.`)}}xx.type=bx("",xx);const vx=new Va;class Tx extends xx{constructor(e={}){super(),this.lights=!1,this.useAlphaToCoverage=!0,this.useColor=e.vertexColors,this.pointWidth=1,this.pointColorNode=null,this.pointWidthNode=null,this.setDefaultValues(vx),this.setupShaders(),this.setValues(e)}setup(e){this.setupShaders(),super.setup(e)}setupShaders(){const e=this.alphaToCoverage,t=this.useColor;this.vertexNode=ju((()=>{em(sc(),"vUv").assign(Um());const e=zm("instancePosition").xyz,t=Bc("vec4","mvPos");t.assign(cg.mul(uc(e,1)));const s=Jy.z.div(Jy.w),i=Ym.mul(t),r=Bc("vec2","offset");return r.assign(xg.xy),r.mulAssign(this.pointWidthNode?this.pointWidthNode:ay),r.assign(r.div(Jy.z)),r.y.assign(r.y.mul(s)),r.assign(r.mul(i.w)),i.assign(i.add(uc(r,0,0))),i}))(),this.fragmentNode=ju((()=>{const s=em(sc(),"vUv"),i=Bc("float","alpha");i.assign(1);const r=s.x,n=s.y,o=r.mul(r).add(n.mul(n));if(e){const e=Bc("float","dlen");e.assign(o.fwidth()),i.assign(Dp(e.oneMinus(),e.add(1),o).oneMinus())}else o.greaterThan(1).discard();let a;if(this.pointColorNode)a=this.pointColorNode;else if(t){a=zm("instanceColor").mul(Cf)}else a=Cf;return uc(a,i)}))()}get alphaToCoverage(){return this.useAlphaToCoverage}set alphaToCoverage(e){this.useAlphaToCoverage!==e&&(this.useAlphaToCoverage=e,this.needsUpdate=!0)}}Tx.type=bx("InstancedPoints",Tx);const _x=new Ma;class wx extends xx{constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.lights=!1,this.setDefaultValues(_x),this.setValues(e)}}wx.type=bx("LineBasic",wx);const Sx=new zl;class Mx extends xx{constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.lights=!1,this.setDefaultValues(Sx),this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode,t=this.dashScaleNode?Ku(this.dashScaleNode):sy,s=this.dashSizeNode?Ku(this.dashSizeNode):iy,i=this.dashSizeNode?Ku(this.dashGapNode):ry;Kc.assign(s),Qc.assign(i);const r=em(zm("lineDistance").mul(t));(e?r.add(e):r).mod(Kc.add(Qc)).greaterThan(Kc).discard()}}Mx.type=bx("LineDashed",Mx);const Ax=new zl;class Nx extends xx{constructor(e={}){super(),this.lights=!1,this.setDefaultValues(Ax),this.useAlphaToCoverage=!0,this.useColor=e.vertexColors,this.useDash=e.dashed,this.useWorldUnits=!1,this.dashOffset=0,this.lineWidth=1,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setup(e){this.setupShaders(),super.setup(e)}setupShaders(){const e=this.alphaToCoverage,t=this.useColor,s=this.dashed,i=this.worldUnits,r=ju((({start:e,end:t})=>{const s=Ym.element(2).element(2),i=Ym.element(3).element(2).mul(-.5).div(s).sub(e.z).div(t.z.sub(e.z));return uc(Up(e.xyz,t.xyz,i),t.w)}));this.vertexNode=ju((()=>{Ic("vec2","vUv").assign(Um());const e=zm("instanceStart"),t=zm("instanceEnd"),n=Bc("vec4","start"),o=Bc("vec4","end");n.assign(cg.mul(uc(e,1))),o.assign(cg.mul(uc(t,1))),i&&(Ic("vec3","worldStart").assign(n.xyz),Ic("vec3","worldEnd").assign(o.xyz));const a=Jy.z.div(Jy.w),h=Ym.element(2).element(3).equal(-1);Yu(h,(()=>{Yu(n.z.lessThan(0).and(o.z.greaterThan(0)),(()=>{o.assign(r({start:n,end:o}))})).ElseIf(o.z.lessThan(0).and(n.z.greaterThanEqual(0)),(()=>{n.assign(r({start:o,end:n}))}))}));const l=Ym.mul(n),u=Ym.mul(o),c=l.xyz.div(l.w),d=u.xyz.div(u.w),p=d.xy.sub(c.xy).toVar();p.x.assign(p.x.mul(a)),p.assign(p.normalize());const m=uc().toVar();if(i){const e=o.xyz.sub(n.xyz).normalize(),t=Up(n.xyz,o.xyz,.5).normalize(),i=e.cross(t).normalize(),r=e.cross(i),a=Ic("vec4","worldPos");a.assign(xg.y.lessThan(.5).select(n,o));const h=ny.mul(.5);a.addAssign(uc(xg.x.lessThan(0).select(i.mul(h),i.mul(h).negate()),0)),s||(a.addAssign(uc(xg.y.lessThan(.5).select(e.mul(h).negate(),e.mul(h)),0)),a.addAssign(uc(r.mul(h),0)),Yu(xg.y.greaterThan(1).or(xg.y.lessThan(0)),(()=>{a.subAssign(uc(r.mul(2).mul(h),0))}))),m.assign(Ym.mul(a));const l=oc().toVar();l.assign(xg.y.lessThan(.5).select(c,d)),m.z.assign(l.z.mul(m.w))}else{const e=Bc("vec2","offset");e.assign(sc(p.y,p.x.negate())),p.x.assign(p.x.div(a)),e.x.assign(e.x.div(a)),e.assign(xg.x.lessThan(0).select(e.negate(),e)),Yu(xg.y.lessThan(0),(()=>{e.assign(e.sub(p))})).ElseIf(xg.y.greaterThan(1),(()=>{e.assign(e.add(p))})),e.assign(e.mul(ny)),e.assign(e.div(Jy.w)),m.assign(xg.y.lessThan(.5).select(l,u)),e.assign(e.mul(m.w)),m.assign(m.add(uc(e,0,0)))}return m}))();const n=ju((({p1:e,p2:t,p3:s,p4:i})=>{const r=e.sub(s),n=i.sub(s),o=t.sub(e),a=r.dot(n),h=n.dot(o),l=r.dot(o),u=n.dot(n),c=o.dot(o).mul(u).sub(h.mul(h)),d=a.mul(h).sub(l.mul(u)).div(c).clamp(),p=a.add(h.mul(d)).div(u).clamp();return sc(d,p)}));this.fragmentNode=ju((()=>{const r=Ic("vec2","vUv");if(s){const e=this.offsetNode?Ku(this.offsetNodeNode):oy,t=this.dashScaleNode?Ku(this.dashScaleNode):sy,s=this.dashSizeNode?Ku(this.dashSizeNode):iy,i=this.dashSizeNode?Ku(this.dashGapNode):ry;Kc.assign(s),Qc.assign(i);const n=zm("instanceDistanceStart"),o=zm("instanceDistanceEnd"),a=xg.y.lessThan(.5).select(t.mul(n),sy.mul(o)),h=em(a.add(oy)),l=e?h.add(e):h;r.y.lessThan(-1).or(r.y.greaterThan(1)).discard(),l.mod(Kc.add(Qc)).greaterThan(Kc).discard()}const o=Bc("float","alpha");if(o.assign(1),i){const t=Ic("vec3","worldStart"),i=Ic("vec3","worldEnd"),r=Ic("vec4","worldPos").xyz.normalize().mul(1e5),a=i.sub(t),h=n({p1:t,p2:i,p3:oc(0,0,0),p4:r}),l=t.add(a.mul(h.x)),u=r.mul(h.y),c=l.sub(u).length().div(ny);if(!s)if(e){const e=c.fwidth();o.assign(Dp(e.negate().add(.5),e.add(.5),c).oneMinus())}else c.greaterThan(.5).discard()}else if(e){const e=r.x,t=r.y.greaterThan(0).select(r.y.sub(1),r.y.add(1)),s=e.mul(e).add(t.mul(t)),i=Bc("float","dlen");i.assign(s.fwidth()),Yu(r.y.abs().greaterThan(1),(()=>{o.assign(Dp(i.oneMinus(),i.add(1),s).oneMinus())}))}else Yu(r.y.abs().greaterThan(1),(()=>{const e=r.x,t=r.y.greaterThan(0).select(r.y.sub(1),r.y.add(1));e.mul(e).add(t.mul(t)).greaterThan(1).discard()}));let a;if(this.lineColorNode)a=this.lineColorNode;else if(t){const e=zm("instanceColorStart"),t=zm("instanceColorEnd");a=xg.y.lessThan(.5).select(e,t).mul(Cf)}else a=Cf;return uc(a,o)}))()}get worldUnits(){return this.useWorldUnits}set worldUnits(e){this.useWorldUnits!==e&&(this.useWorldUnits=e,this.needsUpdate=!0)}get dashed(){return this.useDash}set dashed(e){this.useDash!==e&&(this.useDash=e,this.needsUpdate=!0)}get alphaToCoverage(){return this.useAlphaToCoverage}set alphaToCoverage(e){this.useAlphaToCoverage!==e&&(this.useAlphaToCoverage=e,this.needsUpdate=!0)}}Nx.type=bx("Line2",Nx);const Rx=e=>Du(e).mul(.5).add(.5),Cx=e=>Du(e).mul(2).sub(1),Ex=new El;class Bx extends xx{constructor(e){super(),this.lights=!1,this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(Ex),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?Ku(this.opacityNode):If;Pc.assign(uc(Rx(Fg),e))}}Bx.type=bx("MeshNormal",Bx);class Ix extends iu{constructor(e=_g){super("vec2"),this.dirNode=e}setup(){const e=this.dirNode,t=e.z.atan2(e.x).mul(1/(2*Math.PI)).add(.5),s=e.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return sc(t,s)}}Ix.type=Ql("EquirectUV",Ix);const Px=Wu(Ix);class Fx extends so{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const s=t.minFilter,i=t.generateMipmaps;t.generateMipmaps=!0,this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const r=new jn(5,5,5),n=Px(_g),o=new xx;o.colorNode=Gm(t,n,0),o.side=d,o.blending=m;const a=new Wn(r,o),h=new no;h.add(a),t.minFilter===Se&&(t.minFilter=Te);const l=new eo(1,10,this),u=e.getMRT();return e.setMRT(null),l.update(e,h),e.setMRT(u),t.minFilter=s,t.currentGenerateMipmaps=i,a.geometry.dispose(),a.material.dispose(),this}}const zx=new WeakMap;class Ux extends iu{constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=Wg();const t=new to;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=Hl.RENDER}updateBefore(e){const{renderer:t,material:s}=e,i=this.envNode;if(i.isTextureNode||i.isMaterialReferenceNode){const e=i.isTextureNode?i.value:s[i.property];if(e&&e.isTexture){const s=e.mapping;if(s===ue||s===ce){if(zx.has(e)){const t=zx.get(e);Ox(t,e.mapping),this._cubeTexture=t}else{const s=e.image;if(function(e){return null!=e&&e.height>0}(s)){const i=new Fx(s.height);i.fromEquirectangularTexture(t,e),Ox(i.texture,e.mapping),this._cubeTexture=i.texture,zx.set(e,i.texture),e.addEventListener("dispose",Lx)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function Lx(e){const t=e.target;t.removeEventListener("dispose",Lx);const s=zx.get(t);void 0!==s&&(zx.delete(t),s.dispose())}function Ox(e,t){t===ue?e.mapping=he:t===ce&&(e.mapping=le)}Ux.type=Ql("CubeMap",Ux);const Vx=Wu(Ux);class Dx extends Dy{constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=Vx(this.envNode)}}Dx.type=Ql("BasicEnvironment",Dx);class kx extends Dy{constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=Ku(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}kx.type=Ql("BasicLightMap",kx);class Gx{start(){}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class Wx extends Gx{constructor(){super()}indirect(e,t,s){const i=e.ambientOcclusion,r=e.reflectedLight,n=s.context.irradianceLightMap;r.indirectDiffuse.assign(uc(0)),n?r.indirectDiffuse.addAssign(n):r.indirectDiffuse.addAssign(uc(1,1,1,0)),r.indirectDiffuse.mulAssign(i),r.indirectDiffuse.mulAssign(Pc.rgb)}finish(e,t,s){const i=s.material,r=e.outgoingLight,n=s.context.environment;if(n)switch(i.combine){case 0:r.rgb.assign(Up(r.rgb,r.rgb.mul(n.rgb),Uf.mul(Lf)));break;case 1:r.rgb.assign(Up(r.rgb,n.rgb,Uf.mul(Lf)));break;case 2:r.rgb.addAssign(n.rgb.mul(Uf.mul(Lf)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",i.combine)}}}const Hx=new Qr;class jx extends xx{constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Hx),this.setValues(e)}setupNormal(){return Ig}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Dx(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new kx(ly)),t}setupOutgoingLight(){return Pc.rgb}setupLightingModel(){return new Wx}}jx.type=bx("MeshBasic",jx);const qx=ju((({f0:e,f90:t,dotVH:s})=>{const i=s.mul(-5.55473).sub(6.98316).mul(s).exp2();return e.mul(i.oneMinus()).add(t.mul(i))})),$x=ju((e=>e.diffuseColor.mul(1/Math.PI))),Xx=ju((({dotNH:e})=>Jc.mul(Ku(.5)).add(1).mul(Ku(1/Math.PI)).mul(e.pow(Jc)))),Yx=ju((({lightDirection:e})=>{const t=e.add(Sg).normalize(),s=Fg.dot(t).clamp(),i=Sg.dot(t).clamp(),r=qx({f0:Xc,f90:1,dotVH:i}),n=Ku(.25),o=Xx({dotNH:s});return r.mul(n).mul(o)}));class Jx extends Wx{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:s}){const i=Fg.dot(e).clamp().mul(t);s.directDiffuse.addAssign(i.mul($x({diffuseColor:Pc.rgb}))),!0===this.specular&&s.directSpecular.addAssign(i.mul(Yx({lightDirection:e})).mul(Uf))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:s}){s.indirectDiffuse.addAssign(t.mul($x({diffuseColor:Pc}))),s.indirectDiffuse.mulAssign(e)}}const Zx=new Bl;class Kx extends xx{constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Zx),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Dx(t):null}setupLightingModel(){return new Jx(!1)}}Kx.type=bx("MeshLambert",Kx);const Qx=new Rl;class eb extends xx{constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(Qx),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Dx(t):null}setupLightingModel(){return new Jx}setupVariants(){const e=(this.shininessNode?Ku(this.shininessNode):Ef).max(1e-4);Jc.assign(e);const t=this.specularNode||Pf;Xc.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}eb.type=bx("MeshPhong",eb);const tb=ju((()=>{const e=Ig.dFdx().abs().max(Ig.dFdy().abs());return e.x.max(e.y).max(e.z)})),sb=ju((e=>{const{roughness:t}=e,s=tb();let i=t.max(.0525);return i=i.add(s),i=i.min(1),i})),ib=ju((({alpha:e,dotNL:t,dotNV:s})=>{const i=e.pow2(),r=t.mul(i.add(i.oneMinus().mul(s.pow2())).sqrt()),n=s.mul(i.add(i.oneMinus().mul(t.pow2())).sqrt());return gd(.5,r.add(n).max(zd))})).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),rb=ju((({alphaT:e,alphaB:t,dotTV:s,dotBV:i,dotTL:r,dotBL:n,dotNV:o,dotNL:a})=>{const h=a.mul(oc(e.mul(s),t.mul(i),o).length()),l=o.mul(oc(e.mul(r),t.mul(n),a).length());return gd(.5,h.add(l)).saturate()})).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),nb=ju((({alpha:e,dotNH:t})=>{const s=e.pow2(),i=t.pow2().mul(s.oneMinus()).oneMinus();return s.div(i.pow2()).mul(1/Math.PI)})).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),ob=Ku(1/Math.PI),ab=ju((({alphaT:e,alphaB:t,dotNH:s,dotTH:i,dotBH:r})=>{const n=e.mul(t),o=oc(t.mul(i),e.mul(r),n.mul(s)),a=o.dot(o),h=n.div(a);return ob.mul(n.mul(h.pow2()))})).setLayout({name:"D_GGX_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotNH",type:"float",qualifier:"in"},{name:"dotTH",type:"float",qualifier:"in"},{name:"dotBH",type:"float",qualifier:"in"}]}),hb=ju((e=>{const{lightDirection:t,f0:s,f90:i,roughness:r,f:n,USE_IRIDESCENCE:o,USE_ANISOTROPY:a}=e,h=e.normalView||Fg,l=r.pow2(),u=t.add(Sg).normalize(),c=h.dot(t).clamp(),d=h.dot(Sg).clamp(),p=h.dot(u).clamp(),m=Sg.dot(u).clamp();let g,f,y=qx({f0:s,f90:i,dotVH:m});if(Lu(o)&&(y=kc.mix(y,n)),Lu(a)){const e=qc.dot(t),s=qc.dot(Sg),i=qc.dot(u),r=$c.dot(t),n=$c.dot(Sg),o=$c.dot(u);g=rb({alphaT:Hc,alphaB:l,dotTV:s,dotBV:n,dotTL:e,dotBL:r,dotNV:d,dotNL:c}),f=ab({alphaT:Hc,alphaB:l,dotNH:p,dotTH:i,dotBH:o})}else g=ib({alpha:l,dotNL:c,dotNV:d}),f=nb({alpha:l,dotNH:p});return y.mul(g).mul(f)})),lb=ju((({roughness:e,dotNV:t})=>{const s=uc(-1,-.0275,-.572,.022),i=uc(1,.0425,1.04,-.04),r=e.mul(s).add(i),n=r.x.mul(r.x).min(t.mul(-9.28).exp2()).mul(r.x).add(r.y);return sc(-1.04,1.04).mul(n).add(r.zw)})).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),ub=ju((e=>{const{dotNV:t,specularColor:s,specularF90:i,roughness:r}=e,n=lb({dotNV:t,roughness:r});return s.mul(n.x).add(i.mul(n.y))})),cb=ju((({f:e,f90:t,dotVH:s})=>{const i=s.oneMinus().saturate(),r=i.mul(i),n=i.mul(r,r).clamp(0,.9999);return e.sub(oc(t).mul(n)).div(n.oneMinus())})).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),db=ju((({roughness:e,dotNH:t})=>{const s=e.pow2(),i=Ku(1).div(s),r=t.pow2().oneMinus().max(.0078125);return Ku(2).add(i).mul(r.pow(i.mul(.5))).div(2*Math.PI)})).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),pb=ju((({dotNV:e,dotNL:t})=>Ku(1).div(Ku(4).mul(t.add(e).sub(t.mul(e)))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),mb=ju((({lightDirection:e})=>{const t=e.add(Sg).normalize(),s=Fg.dot(e).clamp(),i=Fg.dot(Sg).clamp(),r=Fg.dot(t).clamp(),n=db({roughness:Dc,dotNH:r}),o=pb({dotNV:i,dotNL:s});return Vc.mul(n).mul(o)})),gb=ju((({N:e,V:t,roughness:s})=>{const i=e.dot(t).saturate(),r=sc(s,i.oneMinus().sqrt());return r.assign(r.mul(.984375).add(.0078125)),r})).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),fb=ju((({f:e})=>{const t=e.length();return Tp(t.mul(t).add(e.z).div(t.add(1)),0)})).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),yb=ju((({v1:e,v2:t})=>{const s=e.dot(t),i=s.abs().toVar(),r=i.mul(.0145206).add(.4965155).mul(i).add(.8543985).toVar(),n=i.add(4.1616724).mul(i).add(3.417594).toVar(),o=r.div(n),a=s.greaterThan(0).select(o,Tp(s.mul(s).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(o));return e.cross(t).mul(a)})).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),xb=ju((({N:e,V:t,P:s,mInv:i,p0:r,p1:n,p2:o,p3:a})=>{const h=n.sub(r).toVar(),l=a.sub(r).toVar(),u=h.cross(l),c=oc().toVar();return Yu(u.dot(s.sub(r)).greaterThanEqual(0),(()=>{const h=t.sub(e.mul(t.dot(e))).normalize(),l=e.cross(h).negate(),u=i.mul(gc(h,l,e).transpose()).toVar(),d=u.mul(r.sub(s)).normalize().toVar(),p=u.mul(n.sub(s)).normalize().toVar(),m=u.mul(o.sub(s)).normalize().toVar(),g=u.mul(a.sub(s)).normalize().toVar(),f=oc(0).toVar();f.addAssign(yb({v1:d,v2:p})),f.addAssign(yb({v1:p,v2:m})),f.addAssign(yb({v1:m,v2:g})),f.addAssign(yb({v1:g,v2:d})),c.assign(oc(fb({f:f})))})),c})).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"P",type:"vec3"},{name:"mInv",type:"mat3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),bb=1/6,vb=e=>md(bb,md(e,md(e,e.negate().add(3)).sub(3)).add(1)),Tb=e=>md(bb,md(e,md(e,md(3,e).sub(6))).add(4)),_b=e=>md(bb,md(e,md(e,md(-3,e).add(3)).add(3)).add(1)),wb=e=>md(bb,Cp(e,3)),Sb=e=>vb(e).add(Tb(e)),Mb=e=>_b(e).add(wb(e)),Ab=e=>dd(-1,Tb(e).div(vb(e).add(Tb(e)))),Nb=e=>dd(1,wb(e).div(_b(e).add(wb(e)))),Rb=(e,t,s)=>{const i=e.uvNode,r=md(i,t.zw).add(.5),n=Jd(r),o=Qd(r),a=Sb(o.x),h=Mb(o.x),l=Ab(o.x),u=Nb(o.x),c=Ab(o.y),d=Nb(o.y),p=sc(n.x.add(l),n.y.add(c)).sub(.5).mul(t.xy),m=sc(n.x.add(u),n.y.add(c)).sub(.5).mul(t.xy),g=sc(n.x.add(l),n.y.add(d)).sub(.5).mul(t.xy),f=sc(n.x.add(u),n.y.add(d)).sub(.5).mul(t.xy),y=Sb(o.y).mul(dd(a.mul(e.uv(p).level(s)),h.mul(e.uv(m).level(s)))),x=Mb(o.y).mul(dd(a.mul(e.uv(g).level(s)),h.mul(e.uv(f).level(s))));return y.add(x)},Cb=ju((([e,t=Ku(3)])=>{const s=sc(e.size(Qu(t))),i=sc(e.size(Qu(t.add(1)))),r=gd(1,s),n=gd(1,i),o=Rb(e,uc(r,s),Jd(t)),a=Rb(e,uc(n,i),Zd(t));return Qd(t).mix(o,a)})),Eb=ju((([e,t,s,i,r])=>{const n=oc(Vp(t.negate(),Kd(e),gd(1,i))),o=oc(hp(r[0].xyz),hp(r[1].xyz),hp(r[2].xyz));return Kd(n).mul(s.mul(o))})).setLayout({name:"getVolumeTransmissionRay",type:"vec3",inputs:[{name:"n",type:"vec3"},{name:"v",type:"vec3"},{name:"thickness",type:"float"},{name:"ior",type:"float"},{name:"modelMatrix",type:"mat4"}]}),Bb=ju((([e,t])=>e.mul(Lp(t.mul(2).sub(2),0,1)))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),Ib=ix(),Pb=ju((([e,t,s])=>{const i=Ib.uv(e),r=$d(Ku(Yy.x)).mul(Bb(t,s));return Cb(i,r)})),Fb=ju((([e,t,s])=>(Yu(s.notEqual(0),(()=>{const i=qd(t).negate().div(s);return Hd(i.negate().mul(e))})),oc(1)))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),zb=ju((([e,t,s,i,r,n,o,a,h,l,u,c,d,p,m])=>{let g,f;if(m){g=uc().toVar(),f=oc().toVar();const r=u.sub(1).mul(m.mul(.025)),n=oc(u.sub(r),u,u.add(r));Cy({start:0,end:3},(({i:r})=>{const u=n.element(r),m=Eb(e,t,c,u,a),y=o.add(m),x=l.mul(h.mul(uc(y,1))),b=sc(x.xy.div(x.w)).toVar();b.addAssign(1),b.divAssign(2),b.assign(sc(b.x,b.y.oneMinus()));const v=Pb(b,s,u);g.element(r).assign(v.element(r)),g.a.addAssign(v.a),f.element(r).assign(i.element(r).mul(Fb(hp(m),d,p).element(r)))})),g.a.divAssign(3)}else{const r=Eb(e,t,c,u,a),n=o.add(r),m=l.mul(h.mul(uc(n,1))),y=sc(m.xy.div(m.w)).toVar();y.addAssign(1),y.divAssign(2),y.assign(sc(y.x,y.y.oneMinus())),g=Pb(y,s,u),f=i.mul(Fb(hp(r),d,p))}const y=f.rgb.mul(g.rgb),x=e.dot(t).clamp(),b=oc(ub({dotNV:x,specularColor:r,specularF90:n,roughness:s})),v=f.r.add(f.g,f.b).div(3);return uc(b.oneMinus().mul(y),g.a.oneMinus().mul(v).oneMinus())})),Ub=gc(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),Lb=(e,t)=>e.sub(t).div(e.add(t)).pow2(),Ob=(e,t)=>{const s=e.mul(2*Math.PI*1e-9),i=oc(54856e-17,44201e-17,52481e-17),r=oc(1681e3,1795300,2208400),n=oc(43278e5,93046e5,66121e5),o=Ku(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(s.mul(2239900).add(t.x).cos()).mul(s.pow2().mul(-45282e5).exp());let a=i.mul(n.mul(2*Math.PI).sqrt()).mul(r.mul(s).add(t).cos()).mul(s.pow2().negate().mul(n).exp());a=oc(a.x.add(o),a.y,a.z).div(1.0685e-7);return Ub.mul(a)},Vb=ju((({outsideIOR:e,eta2:t,cosTheta1:s,thinFilmThickness:i,baseF0:r})=>{const n=Up(e,t,Dp(0,.03,i)),o=e.div(n).pow2().mul(Ku(1).sub(s.pow2())),a=Ku(1).sub(o).sqrt(),h=Lb(n,e),l=qx({f0:h,f90:1,dotVH:s}),u=l.oneMinus(),c=n.lessThan(e).select(Math.PI,0),d=Ku(Math.PI).sub(c),p=(e=>{const t=e.sqrt();return oc(1).add(t).div(oc(1).sub(t))})(r.clamp(0,.9999)),m=Lb(p,n.toVec3()),g=qx({f0:m,f90:1,dotVH:a}),f=oc(p.x.lessThan(n).select(Math.PI,0),p.y.lessThan(n).select(Math.PI,0),p.z.lessThan(n).select(Math.PI,0)),y=n.mul(i,a,2),x=oc(d).add(f),b=l.mul(g).clamp(1e-5,.9999),v=b.sqrt(),T=u.pow2().mul(g).div(oc(1).sub(b));let _=l.add(T),w=T.sub(u);for(let e=1;e<=2;++e){w=w.mul(v);const t=Ob(Ku(e).mul(y),Ku(e).mul(x)).mul(2);_=_.add(w.mul(t))}return _.max(oc(0))})).setLayout({name:"evalIridescence",type:"vec3",inputs:[{name:"outsideIOR",type:"float"},{name:"eta2",type:"float"},{name:"cosTheta1",type:"float"},{name:"thinFilmThickness",type:"float"},{name:"baseF0",type:"vec3"}]}),Db=ju((({normal:e,viewDir:t,roughness:s})=>{const i=e.dot(t).saturate(),r=s.pow2(),n=qp(s.lessThan(.25),Ku(-339.2).mul(r).add(Ku(161.4).mul(s)).sub(25.9),Ku(-8.48).mul(r).add(Ku(14.3).mul(s)).sub(9.95)),o=qp(s.lessThan(.25),Ku(44).mul(r).sub(Ku(23.7).mul(s)).add(3.26),Ku(1.97).mul(r).sub(Ku(3.27).mul(s)).add(.72));return qp(s.lessThan(.25),0,Ku(.1).mul(s).sub(.025)).add(n.mul(i).add(o).exp()).mul(1/Math.PI).saturate()})),kb=oc(.04),Gb=Ku(1);class Wb extends Gx{constructor(e=!1,t=!1,s=!1,i=!1,r=!1,n=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=s,this.anisotropy=i,this.transmission=r,this.dispersion=n,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(!0===this.clearcoat&&(this.clearcoatRadiance=oc().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=oc().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=oc().toVar("clearcoatSpecularIndirect")),!0===this.sheen&&(this.sheenSpecularDirect=oc().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=oc().toVar("sheenSpecularIndirect")),!0===this.iridescence){const e=Fg.dot(Sg).clamp();this.iridescenceFresnel=Vb({outsideIOR:Ku(1),eta2:Gc,cosTheta1:e,thinFilmThickness:Wc,baseF0:Xc}),this.iridescenceF0=cb({f:this.iridescenceFresnel,f90:1,dotVH:e})}if(!0===this.transmission){const t=Tg,s=eg.sub(Tg).normalize(),i=zg;e.backdrop=zb(i,s,zc,Pc,Xc,Yc,t,pg,Zm,Ym,td,id,nd,rd,this.dispersion?od:null),e.backdropAlpha=sd,Pc.a.mulAssign(Up(1,e.backdrop.a,sd))}}computeMultiscattering(e,t,s){const i=Fg.dot(Sg).clamp(),r=lb({roughness:zc,dotNV:i}),n=(this.iridescenceF0?kc.mix(Xc,this.iridescenceF0):Xc).mul(r.x).add(s.mul(r.y)),o=r.x.add(r.y).oneMinus(),a=Xc.add(Xc.oneMinus().mul(.047619)),h=n.mul(a).div(o.mul(a).oneMinus());e.addAssign(n),t.addAssign(h.mul(o))}direct({lightDirection:e,lightColor:t,reflectedLight:s}){const i=Fg.dot(e).clamp().mul(t);if(!0===this.sheen&&this.sheenSpecularDirect.addAssign(i.mul(mb({lightDirection:e}))),!0===this.clearcoat){const s=Ug.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(s.mul(hb({lightDirection:e,f0:kb,f90:Gb,roughness:Oc,normalView:Ug})))}s.directDiffuse.addAssign(i.mul($x({diffuseColor:Pc.rgb}))),s.directSpecular.addAssign(i.mul(hb({lightDirection:e,f0:Xc,f90:1,roughness:zc,iridescence:this.iridescence,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:s,halfHeight:i,reflectedLight:r,ltc_1:n,ltc_2:o}){const a=t.add(s).sub(i),h=t.sub(s).sub(i),l=t.sub(s).add(i),u=t.add(s).add(i),c=Fg,d=Sg,p=wg.toVar(),m=gb({N:c,V:d,roughness:zc}),g=n.uv(m).toVar(),f=o.uv(m).toVar(),y=gc(oc(g.x,0,g.y),oc(0,1,0),oc(g.z,0,g.w)).toVar(),x=Xc.mul(f.x).add(Xc.oneMinus().mul(f.y)).toVar();r.directSpecular.addAssign(e.mul(x).mul(xb({N:c,V:d,P:p,mInv:y,p0:a,p1:h,p2:l,p3:u}))),r.directDiffuse.addAssign(e.mul(Pc).mul(xb({N:c,V:d,P:p,mInv:gc(1,0,0,0,1,0,0,0,1),p0:a,p1:h,p2:l,p3:u})))}indirect(e,t,s){this.indirectDiffuse(e,t,s),this.indirectSpecular(e,t,s),this.ambientOcclusion(e,t,s)}indirectDiffuse({irradiance:e,reflectedLight:t}){t.indirectDiffuse.addAssign(e.mul($x({diffuseColor:Pc})))}indirectSpecular({radiance:e,iblIrradiance:t,reflectedLight:s}){if(!0===this.sheen&&this.sheenSpecularIndirect.addAssign(t.mul(Vc,Db({normal:Fg,viewDir:Sg,roughness:Dc}))),!0===this.clearcoat){const e=Ug.dot(Sg).clamp(),t=ub({dotNV:e,specularColor:kb,specularF90:Gb,roughness:Oc});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(t))}const i=oc().toVar("singleScattering"),r=oc().toVar("multiScattering"),n=t.mul(1/Math.PI);this.computeMultiscattering(i,r,Yc);const o=i.add(r),a=Pc.mul(o.r.max(o.g).max(o.b).oneMinus());s.indirectSpecular.addAssign(e.mul(i)),s.indirectSpecular.addAssign(r.mul(n)),s.indirectDiffuse.addAssign(a.mul(n))}ambientOcclusion({ambientOcclusion:e,reflectedLight:t}){const s=Fg.dot(Sg).clamp().add(e),i=zc.mul(-16).oneMinus().negate().exp2(),r=e.sub(s.pow(i).oneMinus()).clamp();!0===this.clearcoat&&this.clearcoatSpecularIndirect.mulAssign(e),!0===this.sheen&&this.sheenSpecularIndirect.mulAssign(e),t.indirectDiffuse.mulAssign(e),t.indirectSpecular.mulAssign(r)}finish(e){const{outgoingLight:t}=e;if(!0===this.clearcoat){const e=Ug.dot(Sg).clamp(),s=qx({dotVH:e,f0:kb,f90:Gb}),i=t.mul(Lc.mul(s).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(Lc));t.assign(i)}if(!0===this.sheen){const e=Vc.r.max(Vc.g).max(Vc.b).mul(.157).oneMinus(),s=t.mul(e).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(s)}}}const Hb=Ku(1),jb=Ku(-2),qb=Ku(.8),$b=Ku(-1),Xb=Ku(.4),Yb=Ku(2),Jb=Ku(.305),Zb=Ku(3),Kb=Ku(.21),Qb=Ku(4),ev=Ku(4),tv=Ku(16),sv=ju((([e])=>{const t=oc(op(e)).toVar(),s=Ku(-1).toVar();return Yu(t.x.greaterThan(t.z),(()=>{Yu(t.x.greaterThan(t.y),(()=>{s.assign(qp(e.x.greaterThan(0),0,3))})).Else((()=>{s.assign(qp(e.y.greaterThan(0),1,4))}))})).Else((()=>{Yu(t.z.greaterThan(t.y),(()=>{s.assign(qp(e.z.greaterThan(0),2,5))})).Else((()=>{s.assign(qp(e.y.greaterThan(0),1,4))}))})),s})).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),iv=ju((([e,t])=>{const s=sc().toVar();return Yu(t.equal(0),(()=>{s.assign(sc(e.z,e.y).div(op(e.x)))})).ElseIf(t.equal(1),(()=>{s.assign(sc(e.x.negate(),e.z.negate()).div(op(e.y)))})).ElseIf(t.equal(2),(()=>{s.assign(sc(e.x.negate(),e.y).div(op(e.z)))})).ElseIf(t.equal(3),(()=>{s.assign(sc(e.z.negate(),e.y).div(op(e.x)))})).ElseIf(t.equal(4),(()=>{s.assign(sc(e.x.negate(),e.z).div(op(e.y)))})).Else((()=>{s.assign(sc(e.x,e.y).div(op(e.z)))})),md(.5,s.add(1))})).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),rv=ju((([e])=>{const t=Ku(0).toVar();return Yu(e.greaterThanEqual(qb),(()=>{t.assign(Hb.sub(e).mul($b.sub(jb)).div(Hb.sub(qb)).add(jb))})).ElseIf(e.greaterThanEqual(Xb),(()=>{t.assign(qb.sub(e).mul(Yb.sub($b)).div(qb.sub(Xb)).add($b))})).ElseIf(e.greaterThanEqual(Jb),(()=>{t.assign(Xb.sub(e).mul(Zb.sub(Yb)).div(Xb.sub(Jb)).add(Yb))})).ElseIf(e.greaterThanEqual(Kb),(()=>{t.assign(Jb.sub(e).mul(Qb.sub(Zb)).div(Jb.sub(Kb)).add(Zb))})).Else((()=>{t.assign(Ku(-2).mul($d(md(1.16,e))))})),t})).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),nv=ju((([e,t])=>{const s=e.toVar();s.assign(md(2,s).sub(1));const i=oc(s,1).toVar();return Yu(t.equal(0),(()=>{i.assign(i.zyx)})).ElseIf(t.equal(1),(()=>{i.assign(i.xzy),i.xz.mulAssign(-1)})).ElseIf(t.equal(2),(()=>{i.x.mulAssign(-1)})).ElseIf(t.equal(3),(()=>{i.assign(i.zyx),i.xz.mulAssign(-1)})).ElseIf(t.equal(4),(()=>{i.assign(i.xzy),i.xy.mulAssign(-1)})).ElseIf(t.equal(5),(()=>{i.z.mulAssign(-1)})),i})).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),ov=ju((([e,t,s,i,r,n])=>{const o=Ku(s),a=oc(t),h=Lp(rv(o),jb,n),l=Qd(h),u=Jd(h),c=oc(av(e,a,u,i,r,n)).toVar();return Yu(l.notEqual(0),(()=>{const t=oc(av(e,a,u.add(1),i,r,n)).toVar();c.assign(Up(c,t,l))})),c})),av=ju((([e,t,s,i,r,n])=>{const o=Ku(s).toVar(),a=oc(t),h=Ku(sv(a)).toVar(),l=Ku(Tp(ev.sub(o),0)).toVar();o.assign(Tp(o,ev));const u=Ku(jd(o)).toVar(),c=sc(iv(a,h).mul(u.sub(2)).add(1)).toVar();return Yu(h.greaterThan(2),(()=>{c.y.addAssign(u),h.subAssign(3)})),c.x.addAssign(h.mul(u)),c.x.addAssign(l.mul(md(3,tv))),c.y.addAssign(md(4,jd(n).sub(u))),c.x.mulAssign(i),c.y.mulAssign(r),e.uv(c).grad(sc(),sc())})),hv=ju((({envMap:e,mipInt:t,outputDirection:s,theta:i,axis:r,CUBEUV_TEXEL_WIDTH:n,CUBEUV_TEXEL_HEIGHT:o,CUBEUV_MAX_MIP:a})=>{const h=tp(i),l=s.mul(h).add(r.cross(s).mul(ep(i))).add(r.mul(r.dot(s).mul(h.oneMinus())));return av(e,l,t,n,o,a)})),lv=ju((({n:e,latitudinal:t,poleAxis:s,outputDirection:i,weights:r,samples:n,dTheta:o,mipInt:a,envMap:h,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:c})=>{const d=oc(qp(t,s,Rp(s,i))).toVar();Yu(Vd(d.equals(oc(0))),(()=>{d.assign(oc(i.z,0,i.x.negate()))})),d.assign(Kd(d));const p=oc().toVar();return p.addAssign(r.element(Qu(0)).mul(hv({theta:0,axis:d,outputDirection:i,mipInt:a,envMap:h,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:c}))),Cy({start:Qu(1),end:e},(({i:e})=>{Yu(e.greaterThanEqual(n),(()=>{By()}));const t=Ku(o.mul(Ku(e))).toVar();p.addAssign(r.element(e).mul(hv({theta:t.mul(-1),axis:d,outputDirection:i,mipInt:a,envMap:h,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:c}))),p.addAssign(r.element(e).mul(hv({theta:t,axis:d,outputDirection:i,mipInt:a,envMap:h,CUBEUV_TEXEL_WIDTH:l,CUBEUV_TEXEL_HEIGHT:u,CUBEUV_MAX_MIP:c})))})),uc(p,1)}));let uv=null;const cv=new WeakMap;function dv(e){let t=cv.get(e);if((void 0!==t?t.pmremVersion:-1)!==e.pmremVersion){const s=e.image;if(e.isCubeTexture){if(!function(e){if(null==e)return!1;let t=0;const s=6;for(let i=0;i0}(s))return null;t=uv.fromEquirectangular(e,t)}t.pmremVersion=e.pmremVersion,cv.set(e,t)}return t.texture}class pv extends iu{constructor(e,t=null,s=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=s,this._generator=null;const i=new Ti;i.isRenderTargetTexture=!0,this._texture=Gm(i),this._width=Cc(0),this._height=Cc(0),this._maxMip=Cc(0),this.updateBeforeType=Hl.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=function(e){const t=Math.log2(e)-2,s=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),112)),texelHeight:s,maxMip:t}}(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(){let e=this._pmrem;const t=e?e.pmremVersion:-1,s=this._value;t!==s.pmremVersion&&(e=!0===s.isPMREMTexture?s:dv(s),null!==e&&(this._pmrem=e,this.updateFromTexture(e)))}setup(e){null===uv&&(uv=e.createPMREMGenerator()),this.updateBefore(e);let t=this.uvNode;null===t&&e.context.getUV&&(t=e.context.getUV(this));const s=this.value;e.renderer.coordinateSystem===Vs&&!0!==s.isPMREMTexture&&!0===s.isRenderTargetTexture&&(t=oc(t.x.negate(),t.yz));let i=this.levelNode;return null===i&&e.context.getTextureLevel&&(i=e.context.getTextureLevel(this)),ov(this._texture,t,i,this._width,this._height,this._maxMip)}}pv.type=Ql("PMREM",pv);const mv=Wu(pv),gv=new WeakMap;class fv extends Dy{constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let s=this.envNode;if(s.isTextureNode||s.isMaterialReferenceNode){const e=s.isTextureNode?s.value:t[s.property];let i=gv.get(e);void 0===i&&(i=mv(e),gv.set(e,i)),s=i}const i=t.envMap?Zg("envMapIntensity","float",e.material):Zg("environmentIntensity","float",e.scene),r=!0===t.useAnisotropy||t.anisotropy>0?xf:Fg,n=s.context(yv(zc,r)).mul(i),o=s.context(xv(zg)).mul(Math.PI).mul(i),a=Tm(n),h=Tm(o);e.context.radiance.addAssign(a),e.context.iblIrradiance.addAssign(h);const l=e.context.lightingModel.clearcoatRadiance;if(l){const e=s.context(yv(Oc,Ug)).mul(i),t=Tm(e);l.addAssign(t)}}}fv.type=Ql("Environment",fv);const yv=(e,t)=>{let s=null;return{getUV:()=>(null===s&&(s=Sg.negate().reflect(t),s=e.mul(e).mix(s,t).normalize(),s=s.transformDirection(Zm)),s),getTextureLevel:()=>e}},xv=e=>({getUV:()=>e,getTextureLevel:()=>Ku(1)}),bv=new Al;class vv extends xx{constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(bv),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return null===t&&e.environmentNode&&(t=e.environmentNode),t?new fv(t):null}setupLightingModel(){return new Wb}setupSpecular(){const e=Up(oc(.04),Pc.rgb,Uc);Xc.assign(e),Yc.assign(1)}setupVariants(){const e=this.metalnessNode?Ku(this.metalnessNode):Vf;Uc.assign(e);let t=this.roughnessNode?Ku(this.roughnessNode):Of;t=sb({roughness:t}),zc.assign(t),this.setupSpecular(),Pc.assign(uc(Pc.rgb.mul(e.oneMinus()),Pc.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}vv.type=bx("MeshStandard",vv);const Tv=new Nl;class _v extends vv{constructor(e){super(),this.isMeshPhysicalNodeMaterial=!0,this.clearcoatNode=null,this.clearcoatRoughnessNode=null,this.clearcoatNormalNode=null,this.sheenNode=null,this.sheenRoughnessNode=null,this.iridescenceNode=null,this.iridescenceIORNode=null,this.iridescenceThicknessNode=null,this.specularIntensityNode=null,this.specularColorNode=null,this.iorNode=null,this.transmissionNode=null,this.thicknessNode=null,this.attenuationDistanceNode=null,this.attenuationColorNode=null,this.dispersionNode=null,this.anisotropyNode=null,this.setDefaultValues(Tv),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||null!==this.clearcoatNode}get useIridescence(){return this.iridescence>0||null!==this.iridescenceNode}get useSheen(){return this.sheen>0||null!==this.sheenNode}get useAnisotropy(){return this.anisotropy>0||null!==this.anisotropyNode}get useTransmission(){return this.transmission>0||null!==this.transmissionNode}get useDispersion(){return this.dispersion>0||null!==this.dispersionNode}setupSpecular(){const e=this.iorNode?Ku(this.iorNode):Qf;td.assign(e),Xc.assign(Up(vp(Ep(td.sub(1).div(td.add(1))).mul(zf),oc(1)).mul(Ff),Pc.rgb,Uc)),Yc.assign(Up(Ff,1,Uc))}setupLightingModel(){return new Wb(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const e=this.clearcoatNode?Ku(this.clearcoatNode):kf,t=this.clearcoatRoughnessNode?Ku(this.clearcoatRoughnessNode):Gf;Lc.assign(e),Oc.assign(sb({roughness:t}))}if(this.useSheen){const e=this.sheenNode?oc(this.sheenNode):jf,t=this.sheenRoughnessNode?Ku(this.sheenRoughnessNode):qf;Vc.assign(e),Dc.assign(t)}if(this.useIridescence){const e=this.iridescenceNode?Ku(this.iridescenceNode):Xf,t=this.iridescenceIORNode?Ku(this.iridescenceIORNode):Yf,s=this.iridescenceThicknessNode?Ku(this.iridescenceThicknessNode):Jf;kc.assign(e),Gc.assign(t),Wc.assign(s)}if(this.useAnisotropy){const e=(this.anisotropyNode?sc(this.anisotropyNode):$f).toVar();jc.assign(e.length()),Yu(jc.equal(0),(()=>{e.assign(sc(1,0))})).Else((()=>{e.divAssign(sc(jc)),jc.assign(jc.saturate())})),Hc.assign(jc.pow2().mix(zc.pow2(),1)),qc.assign(gf[0].mul(e.x).add(gf[1].mul(e.y))),$c.assign(gf[1].mul(e.x).sub(gf[0].mul(e.y)))}if(this.useTransmission){const e=this.transmissionNode?Ku(this.transmissionNode):Zf,t=this.thicknessNode?Ku(this.thicknessNode):Kf,s=this.attenuationDistanceNode?Ku(this.attenuationDistanceNode):ey,i=this.attenuationColorNode?oc(this.attenuationColorNode):ty;if(sd.assign(e),id.assign(t),rd.assign(s),nd.assign(i),this.useDispersion){const e=this.dispersionNode?Ku(this.dispersionNode):hy;od.assign(e)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?oc(this.clearcoatNormalNode):Wf}setup(e){e.context.setupClearcoatNormal=()=>this.setupClearcoatNormal(e),super.setup(e)}copy(e){return this.clearcoatNode=e.clearcoatNode,this.clearcoatRoughnessNode=e.clearcoatRoughnessNode,this.clearcoatNormalNode=e.clearcoatNormalNode,this.sheenNode=e.sheenNode,this.sheenRoughnessNode=e.sheenRoughnessNode,this.iridescenceNode=e.iridescenceNode,this.iridescenceIORNode=e.iridescenceIORNode,this.iridescenceThicknessNode=e.iridescenceThicknessNode,this.specularIntensityNode=e.specularIntensityNode,this.specularColorNode=e.specularColorNode,this.transmissionNode=e.transmissionNode,this.thicknessNode=e.thicknessNode,this.attenuationDistanceNode=e.attenuationDistanceNode,this.attenuationColorNode=e.attenuationColorNode,this.dispersionNode=e.dispersionNode,this.anisotropyNode=e.anisotropyNode,super.copy(e)}}_v.type=bx("MeshPhysical",_v);class wv extends Wb{constructor(e,t,s,i){super(e,t,s),this.useSSS=i}direct({lightDirection:e,lightColor:t,reflectedLight:s},i,r){if(!0===this.useSSS){const i=r.material,{thicknessColorNode:n,thicknessDistortionNode:o,thicknessAmbientNode:a,thicknessAttenuationNode:h,thicknessPowerNode:l,thicknessScaleNode:u}=i,c=e.add(Fg.mul(o)).normalize(),d=Ku(Sg.dot(c.negate()).saturate().pow(l).mul(u)),p=oc(d.add(a).mul(n));s.directDiffuse.addAssign(p.mul(h.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:s},i,r)}}class Sv extends _v{constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=Ku(.1),this.thicknessAmbientNode=Ku(0),this.thicknessAttenuationNode=Ku(.1),this.thicknessPowerNode=Ku(2),this.thicknessScaleNode=Ku(10)}get useSSS(){return null!==this.thicknessColorNode}setupLightingModel(){return new wv(this.useClearcoat,this.useSheen,this.useIridescence,this.useSSS)}copy(e){return this.thicknessColorNode=e.thicknessColorNode,this.thicknessDistortionNode=e.thicknessDistortionNode,this.thicknessAmbientNode=e.thicknessAmbientNode,this.thicknessAttenuationNode=e.thicknessAttenuationNode,this.thicknessPowerNode=e.thicknessPowerNode,this.thicknessScaleNode=e.thicknessScaleNode,super.copy(e)}}Sv.type=bx("MeshSSS",Sv);const Mv=ju((({normal:e,lightDirection:t,builder:s})=>{const i=e.dot(t),r=sc(i.mul(.5).add(.5),0);if(s.material.gradientMap){const e=ef("gradientMap","texture").context({getUV:()=>r});return oc(e.r)}{const e=r.fwidth().mul(.5);return Up(oc(.7),oc(1),Dp(Ku(.7).sub(e.x),Ku(.7).add(e.x),r.x))}}));class Av extends Gx{direct({lightDirection:e,lightColor:t,reflectedLight:s},i,r){const n=Mv({normal:Rg,lightDirection:e,builder:r}).mul(t);s.directDiffuse.addAssign(n.mul($x({diffuseColor:Pc.rgb})))}indirect({ambientOcclusion:e,irradiance:t,reflectedLight:s}){s.indirectDiffuse.addAssign(t.mul($x({diffuseColor:Pc}))),s.indirectDiffuse.mulAssign(e)}}const Nv=new Cl;class Rv extends xx{constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Nv),this.setValues(e)}setupLightingModel(){return new Av}}Rv.type=bx("MeshToon",Rv);class Cv extends iu{constructor(){super("vec2")}setup(){const e=oc(Sg.z,0,Sg.x.negate()).normalize(),t=Sg.cross(e);return sc(e.dot(Fg),t.dot(Fg)).mul(.495).add(.5)}}Cv.type=Ql("MatcapUV",Cv);const Ev=Hu(Cv),Bv=new Fl;class Iv extends xx{constructor(e){super(),this.lights=!1,this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(Bv),this.setValues(e)}setupVariants(e){const t=Ev;let s;s=e.material.matcap?ef("matcap","texture").context({getUV:()=>t}):oc(Up(.2,.8,t.y)),Pc.rgb.mulAssign(s.rgb)}}Iv.type=bx("MeshMatcap",Iv);const Pv=new Va;class Fv extends xx{constructor(e){super(),this.isPointsNodeMaterial=!0,this.lights=!1,this.transparent=!0,this.sizeNode=null,this.setDefaultValues(Pv),this.setValues(e)}copy(e){return this.sizeNode=e.sizeNode,super.copy(e)}}Fv.type=bx("Points",Fv);class zv extends iu{constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:s}=this;if("vec2"===this.getNodeType(e)){const e=t.cos(),i=t.sin();return mc(e,i,i.negate(),e).mul(s)}{const e=t,i=fc(uc(1,0,0,0),uc(0,tp(e.x),ep(e.x).negate(),0),uc(0,ep(e.x),tp(e.x),0),uc(0,0,0,1)),r=fc(uc(tp(e.y),0,ep(e.y),0),uc(0,1,0,0),uc(ep(e.y).negate(),0,tp(e.y),0),uc(0,0,0,1)),n=fc(uc(tp(e.z),ep(e.z).negate(),0,0),uc(ep(e.z),tp(e.z),0,0),uc(0,0,1,0),uc(0,0,0,1));return i.mul(r).mul(n).mul(uc(s,1)).xyz}}}zv.type=Ql("Rotate",zv);const Uv=Wu(zv),Lv=new lo;class Ov extends xx{constructor(e){super(),this.isSpriteNodeMaterial=!0,this.lights=!1,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.setDefaultValues(Lv),this.setValues(e)}setupPosition({object:e,context:t}){const{positionNode:s,rotationNode:i,scaleNode:r}=this,n=bg;let o=cg.mul(oc(s||0)),a=sc(pg[0].xyz.length(),pg[1].xyz.length());null!==r&&(a=a.mul(r));let h=n.xy;e.center&&!0===e.center.isVector2&&(h=h.sub(Cc(e.center).sub(.5))),h=h.mul(a);const l=Ku(i||Hf),u=Uv(h,l);o=uc(o.xy.add(u),o.zw);const c=Ym.mul(o);return t.vertex=n,c}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}}Ov.type=bx("Sprite",Ov);class Vv extends Gx{constructor(){super(),this.shadowNode=Ku(1).toVar("shadowMask")}direct({shadowMask:e}){this.shadowNode.mulAssign(e)}finish(e){Pc.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(Pc.rgb)}}const Dv=new Sl;class kv extends xx{constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.setDefaultValues(Dv),this.setValues(e)}setupLightingModel(){return new Vv}}kv.type=bx("Shadow",kv);const Gv=ju((({texture:e,uv:t})=>{const s=1e-4,i=oc().temp();return Yu(t.x.lessThan(s),(()=>{i.assign(oc(1,0,0))})).ElseIf(t.y.lessThan(s),(()=>{i.assign(oc(0,1,0))})).ElseIf(t.z.lessThan(s),(()=>{i.assign(oc(0,0,1))})).ElseIf(t.x.greaterThan(.9999),(()=>{i.assign(oc(-1,0,0))})).ElseIf(t.y.greaterThan(.9999),(()=>{i.assign(oc(0,-1,0))})).ElseIf(t.z.greaterThan(.9999),(()=>{i.assign(oc(0,0,-1))})).Else((()=>{const s=.01,r=e.uv(t.add(oc(-.01,0,0))).r.sub(e.uv(t.add(oc(s,0,0))).r),n=e.uv(t.add(oc(0,-.01,0))).r.sub(e.uv(t.add(oc(0,s,0))).r),o=e.uv(t.add(oc(0,0,-.01))).r.sub(e.uv(t.add(oc(0,0,s))).r);i.assign(oc(r,n,o))})),i.normalize()}));class Wv extends km{constructor(e,t=null,s=null){super(e,t,s),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return oc(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){return t}generateUV(e,t){return t.build(e,"vec3")}normal(e){return Gv({texture:this,uv:e})}}Wv.type=Ql("Texture3D",Wv);const Hv=Wu(Wv);class jv extends xx{constructor(e={}){super(),this.lights=!1,this.isVolumeNodeMaterial=!0,this.testNode=null,this.setValues(e)}setup(e){const t=Hv(this.map,null,0),s=ju((({orig:e,dir:t})=>{const s=oc(-.5),i=oc(.5),r=t.reciprocal(),n=s.sub(e).mul(r),o=i.sub(e).mul(r),a=vp(n,o),h=Tp(n,o),l=Tp(a.x,Tp(a.y,a.z)),u=vp(h.x,vp(h.y,h.z));return sc(l,u)}));this.fragmentNode=ju((()=>{const e=em(oc(yg.mul(uc(eg,1)))),i=em(xg.sub(e)).normalize(),r=Bc("vec2","bounds").assign(s({orig:e,dir:i}));r.x.greaterThan(r.y).discard(),r.assign(sc(Tp(r.x,0),r.y));const n=Bc("vec3","p").assign(e.add(r.x.mul(i))),o=Bc("vec3","inc").assign(oc(i.abs().reciprocal())),a=Bc("float","delta").assign(vp(o.x,vp(o.y,o.z)));a.divAssign(ef("steps","float"));const h=Bc("vec4","ac").assign(uc(ef("base","color"),0));return Cy({type:"float",start:r.x,end:r.y,update:"+= delta"},(()=>{const e=Bc("float","d").assign(t.uv(n.add(.5)).r);null!==this.testNode?this.testNode({map:t,mapValue:e,probe:n,finalColor:h}).append():(h.a.assign(1),By()),n.addAssign(i.mul(a))})),h.a.equal(0).discard(),uc(h)}))(),super.setup(e)}}function qv(e,t,s){return!e||!s&&e.constructor===t?e:"number"==typeof t.BYTES_PER_ELEMENT?new t(e):Array.prototype.slice.call(e)}function $v(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Xv(e){const t=e.length,s=new Array(t);for(let e=0;e!==t;++e)s[e]=e;return s.sort((function(t,s){return e[t]-e[s]})),s}function Yv(e,t,s){const i=e.length,r=new e.constructor(i);for(let n=0,o=0;o!==i;++n){const i=s[n]*t;for(let s=0;s!==t;++s)r[o++]=e[i+s]}return r}function Jv(e,t,s,i){let r=1,n=e[0];for(;void 0!==n&&void 0===n[i];)n=e[r++];if(void 0===n)return;let o=n[i];if(void 0!==o)if(Array.isArray(o))do{o=n[i],void 0!==o&&(t.push(n.time),s.push.apply(s,o)),n=e[r++]}while(void 0!==n);else if(void 0!==o.toArray)do{o=n[i],void 0!==o&&(t.push(n.time),o.toArray(s,s.length)),n=e[r++]}while(void 0!==n);else do{o=n[i],void 0!==o&&(t.push(n.time),s.push(o)),n=e[r++]}while(void 0!==n)}jv.type=bx("Volume",jv);const Zv={convertArray:qv,isTypedArray:$v,getKeyframeOrder:Xv,sortedArray:Yv,flattenJSON:Jv,subclip:function(e,t,s,i,r=30){const n=e.clone();n.name=t;const o=[];for(let e=0;e=i)){h.push(t.times[e]);for(let s=0;sn.tracks[e].times[0]&&(a=n.tracks[e].times[0]);for(let e=0;e=i.times[c]){const e=c*h+a,t=e+h-a;d=i.values.slice(e,t)}else{const e=i.createInterpolant(),t=a,s=h-a;e.evaluate(n),d=e.resultBuffer.slice(t,s)}if("quaternion"===r){(new Ci).fromArray(d).normalize().conjugate().toArray(d)}const p=o.times.length;for(let e=0;e=r)break e;{const o=t[1];e=r)break t}n=s,s=0}}for(;s>>1;et;)--n;if(++n,0!==r||n!==i){r>=n&&(n=Math.max(n,1),r=n-1);const e=this.getValueSize();this.times=s.slice(r,n),this.values=this.values.slice(r*e,n*e)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!=0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const s=this.times,i=this.values,r=s.length;0===r&&(console.error("THREE.KeyframeTrack: Track is empty.",this),e=!1);let n=null;for(let t=0;t!==r;t++){const i=s[t];if("number"==typeof i&&isNaN(i)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,t,i),e=!1;break}if(null!==n&&n>i){console.error("THREE.KeyframeTrack: Out of order keys.",this,t,i,n),e=!1;break}n=i}if(void 0!==i&&$v(i))for(let t=0,s=i.length;t!==s;++t){const s=i[t];if(isNaN(s)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,t,s),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),s=this.getValueSize(),i=this.getInterpolation()===Ft,r=e.length-1;let n=1;for(let o=1;o0){e[n]=e[r];for(let e=r*s,i=n*s,o=0;o!==s;++o)t[i+o]=t[e+o];++n}return n!==e.length?(this.times=e.slice(0,n),this.values=t.slice(0,n*s)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),s=new(0,this.constructor)(this.name,e,t);return s.createInterpolant=this.createInterpolant,s}}sT.prototype.TimeBufferType=Float32Array,sT.prototype.ValueBufferType=Float32Array,sT.prototype.DefaultInterpolation=Pt;class iT extends sT{constructor(e,t,s){super(e,t,s)}}iT.prototype.ValueTypeName="bool",iT.prototype.ValueBufferType=Array,iT.prototype.DefaultInterpolation=It,iT.prototype.InterpolantFactoryMethodLinear=void 0,iT.prototype.InterpolantFactoryMethodSmooth=void 0;class rT extends sT{}rT.prototype.ValueTypeName="color";class nT extends sT{}nT.prototype.ValueTypeName="number";class oT extends Kv{constructor(e,t,s,i){super(e,t,s,i)}interpolate_(e,t,s,i){const r=this.resultBuffer,n=this.sampleValues,o=this.valueSize,a=(s-t)/(i-t);let h=e*o;for(let e=h+o;h!==e;h+=4)Ci.slerpFlat(r,0,n,h-o,n,h,a);return r}}class aT extends sT{InterpolantFactoryMethodLinear(e){return new oT(this.times,this.values,this.getValueSize(),e)}}aT.prototype.ValueTypeName="quaternion",aT.prototype.InterpolantFactoryMethodSmooth=void 0;class hT extends sT{constructor(e,t,s){super(e,t,s)}}hT.prototype.ValueTypeName="string",hT.prototype.ValueBufferType=Array,hT.prototype.DefaultInterpolation=It,hT.prototype.InterpolantFactoryMethodLinear=void 0,hT.prototype.InterpolantFactoryMethodSmooth=void 0;class lT extends sT{}lT.prototype.ValueTypeName="vector";class uT{constructor(e="",t=-1,s=[],i=2500){this.name=e,this.tracks=s,this.duration=t,this.blendMode=i,this.uuid=qs(),this.duration<0&&this.resetDuration()}static parse(e){const t=[],s=e.tracks,i=1/(e.fps||1);for(let e=0,r=s.length;e!==r;++e)t.push(cT(s[e]).scale(i));const r=new this(e.name,e.duration,t,e.blendMode);return r.uuid=e.uuid,r}static toJSON(e){const t=[],s=e.tracks,i={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode};for(let e=0,i=s.length;e!==i;++e)t.push(sT.toJSON(s[e]));return i}static CreateFromMorphTargetSequence(e,t,s,i){const r=t.length,n=[];for(let e=0;e1){const e=n[1];let t=i[e];t||(i[e]=t=[]),t.push(s)}}const n=[];for(const e in i)n.push(this.CreateFromMorphTargetSequence(e,i[e],t,s));return n}static parseAnimation(e,t){if(!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const s=function(e,t,s,i,r){if(0!==s.length){const n=[],o=[];Jv(s,n,o,i),0!==n.length&&r.push(new e(t,n,o))}},i=[],r=e.name||"default",n=e.fps||30,o=e.blendMode;let a=e.length||-1;const h=e.hierarchy||[];for(let e=0;e{t&&t(r),this.manager.itemEnd(e)}),0),r;if(void 0!==fT[e])return void fT[e].push({onLoad:t,onProgress:s,onError:i});fT[e]=[],fT[e].push({onLoad:t,onProgress:s,onError:i});const n=new Request(e,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),o=this.mimeType,a=this.responseType;fetch(n).then((t=>{if(200===t.status||0===t.status){if(0===t.status&&console.warn("THREE.FileLoader: HTTP Status 0 received."),"undefined"==typeof ReadableStream||void 0===t.body||void 0===t.body.getReader)return t;const s=fT[e],i=t.body.getReader(),r=t.headers.get("X-File-Size")||t.headers.get("Content-Length"),n=r?parseInt(r):0,o=0!==n;let a=0;const h=new ReadableStream({start(e){!function t(){i.read().then((({done:i,value:r})=>{if(i)e.close();else{a+=r.byteLength;const i=new ProgressEvent("progress",{lengthComputable:o,loaded:a,total:n});for(let e=0,t=s.length;e{e.error(t)}))}()}});return new Response(h)}throw new yT(`fetch for "${t.url}" responded with ${t.status}: ${t.statusText}`,t)})).then((e=>{switch(a){case"arraybuffer":return e.arrayBuffer();case"blob":return e.blob();case"document":return e.text().then((e=>(new DOMParser).parseFromString(e,o)));case"json":return e.json();default:if(void 0===o)return e.text();{const t=/charset="?([^;"\s]*)"?/i.exec(o),s=t&&t[1]?t[1].toLowerCase():void 0,i=new TextDecoder(s);return e.arrayBuffer().then((e=>i.decode(e)))}}})).then((t=>{dT.add(e,t);const s=fT[e];delete fT[e];for(let e=0,i=s.length;e{const s=fT[e];if(void 0===s)throw this.manager.itemError(e),t;delete fT[e];for(let e=0,i=s.length;e{this.manager.itemEnd(e)})),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}}class bT extends gT{constructor(e){super(e)}load(e,t,s,i){const r=this,n=new xT(this.manager);n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(e,(function(s){try{t(r.parse(JSON.parse(s)))}catch(t){i?i(t):console.error(t),r.manager.itemError(e)}}),s,i)}parse(e){const t=[];for(let s=0;s0:i.vertexColors=e.vertexColors),void 0!==e.uniforms)for(const t in e.uniforms){const r=e.uniforms[t];switch(i.uniforms[t]={},r.type){case"t":i.uniforms[t].value=s(r.value);break;case"c":i.uniforms[t].value=(new Yr).setHex(r.value);break;case"v2":i.uniforms[t].value=(new Qs).fromArray(r.value);break;case"v3":i.uniforms[t].value=(new Ei).fromArray(r.value);break;case"v4":i.uniforms[t].value=(new _i).fromArray(r.value);break;case"m3":i.uniforms[t].value=(new ei).fromArray(r.value);break;case"m4":i.uniforms[t].value=(new or).fromArray(r.value);break;default:i.uniforms[t].value=r.value}}if(void 0!==e.defines&&(i.defines=e.defines),void 0!==e.vertexShader&&(i.vertexShader=e.vertexShader),void 0!==e.fragmentShader&&(i.fragmentShader=e.fragmentShader),void 0!==e.glslVersion&&(i.glslVersion=e.glslVersion),void 0!==e.extensions)for(const t in e.extensions)i.extensions[t]=e.extensions[t];if(void 0!==e.lights&&(i.lights=e.lights),void 0!==e.clipping&&(i.clipping=e.clipping),void 0!==e.size&&(i.size=e.size),void 0!==e.sizeAttenuation&&(i.sizeAttenuation=e.sizeAttenuation),void 0!==e.map&&(i.map=s(e.map)),void 0!==e.matcap&&(i.matcap=s(e.matcap)),void 0!==e.alphaMap&&(i.alphaMap=s(e.alphaMap)),void 0!==e.bumpMap&&(i.bumpMap=s(e.bumpMap)),void 0!==e.bumpScale&&(i.bumpScale=e.bumpScale),void 0!==e.normalMap&&(i.normalMap=s(e.normalMap)),void 0!==e.normalMapType&&(i.normalMapType=e.normalMapType),void 0!==e.normalScale){let t=e.normalScale;!1===Array.isArray(t)&&(t=[t,t]),i.normalScale=(new Qs).fromArray(t)}return void 0!==e.displacementMap&&(i.displacementMap=s(e.displacementMap)),void 0!==e.displacementScale&&(i.displacementScale=e.displacementScale),void 0!==e.displacementBias&&(i.displacementBias=e.displacementBias),void 0!==e.roughnessMap&&(i.roughnessMap=s(e.roughnessMap)),void 0!==e.metalnessMap&&(i.metalnessMap=s(e.metalnessMap)),void 0!==e.emissiveMap&&(i.emissiveMap=s(e.emissiveMap)),void 0!==e.emissiveIntensity&&(i.emissiveIntensity=e.emissiveIntensity),void 0!==e.specularMap&&(i.specularMap=s(e.specularMap)),void 0!==e.specularIntensityMap&&(i.specularIntensityMap=s(e.specularIntensityMap)),void 0!==e.specularColorMap&&(i.specularColorMap=s(e.specularColorMap)),void 0!==e.envMap&&(i.envMap=s(e.envMap)),void 0!==e.envMapRotation&&i.envMapRotation.fromArray(e.envMapRotation),void 0!==e.envMapIntensity&&(i.envMapIntensity=e.envMapIntensity),void 0!==e.reflectivity&&(i.reflectivity=e.reflectivity),void 0!==e.refractionRatio&&(i.refractionRatio=e.refractionRatio),void 0!==e.lightMap&&(i.lightMap=s(e.lightMap)),void 0!==e.lightMapIntensity&&(i.lightMapIntensity=e.lightMapIntensity),void 0!==e.aoMap&&(i.aoMap=s(e.aoMap)),void 0!==e.aoMapIntensity&&(i.aoMapIntensity=e.aoMapIntensity),void 0!==e.gradientMap&&(i.gradientMap=s(e.gradientMap)),void 0!==e.clearcoatMap&&(i.clearcoatMap=s(e.clearcoatMap)),void 0!==e.clearcoatRoughnessMap&&(i.clearcoatRoughnessMap=s(e.clearcoatRoughnessMap)),void 0!==e.clearcoatNormalMap&&(i.clearcoatNormalMap=s(e.clearcoatNormalMap)),void 0!==e.clearcoatNormalScale&&(i.clearcoatNormalScale=(new Qs).fromArray(e.clearcoatNormalScale)),void 0!==e.iridescenceMap&&(i.iridescenceMap=s(e.iridescenceMap)),void 0!==e.iridescenceThicknessMap&&(i.iridescenceThicknessMap=s(e.iridescenceThicknessMap)),void 0!==e.transmissionMap&&(i.transmissionMap=s(e.transmissionMap)),void 0!==e.thicknessMap&&(i.thicknessMap=s(e.thicknessMap)),void 0!==e.anisotropyMap&&(i.anisotropyMap=s(e.anisotropyMap)),void 0!==e.sheenColorMap&&(i.sheenColorMap=s(e.sheenColorMap)),void 0!==e.sheenRoughnessMap&&(i.sheenRoughnessMap=s(e.sheenRoughnessMap)),i}setTextures(e){return this.textures=e,this}static createMaterialFromType(e){return new{ShadowMaterial:Sl,SpriteMaterial:lo,RawShaderMaterial:Ml,ShaderMaterial:$n,PointsMaterial:Va,MeshPhysicalMaterial:Nl,MeshStandardMaterial:Al,MeshPhongMaterial:Rl,MeshToonMaterial:Cl,MeshNormalMaterial:El,MeshLambertMaterial:Bl,MeshDepthMaterial:Il,MeshDistanceMaterial:Pl,MeshBasicMaterial:Qr,MeshMatcapMaterial:Fl,LineDashedMaterial:zl,LineBasicMaterial:Ma,Material:Kr}[e]}}class qT{static decodeText(e){if(console.warn("THREE.LoaderUtils: decodeText() has been deprecated with r165 and will be removed with r175. Use TextDecoder instead."),"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);let t="";for(let s=0,i=e.length;s0){const s=new pT(t);r=new TT(s),r.setCrossOrigin(this.crossOrigin);for(let t=0,s=e.length;t0){i=new TT(this.manager),i.setCrossOrigin(this.crossOrigin);for(let t=0,i=e.length;t{const t=new Pi;t.min.fromArray(e.boxMin),t.max.fromArray(e.boxMax);const s=new Zi;return s.radius=e.sphereRadius,s.center.fromArray(e.sphereCenter),{boxInitialized:e.boxInitialized,box:t,sphereInitialized:e.sphereInitialized,sphere:s}})),n._maxInstanceCount=e.maxInstanceCount,n._maxVertexCount=e.maxVertexCount,n._maxIndexCount=e.maxIndexCount,n._geometryInitialized=e.geometryInitialized,n._geometryCount=e.geometryCount,n._matricesTexture=u(e.matricesTexture.uuid),void 0!==e.colorsTexture&&(n._colorsTexture=u(e.colorsTexture.uuid));break;case"LOD":n=new Ro;break;case"Line":n=new Pa(h(e.geometry),l(e.material));break;case"LineLoop":n=new Oa(h(e.geometry),l(e.material));break;case"LineSegments":n=new La(h(e.geometry),l(e.material));break;case"PointCloud":case"Points":n=new Ha(h(e.geometry),l(e.material));break;case"Sprite":n=new So(l(e.material));break;case"Group":n=new qa;break;case"Bone":n=new Vo;break;default:n=new Pr}if(n.uuid=e.uuid,void 0!==e.name&&(n.name=e.name),void 0!==e.matrix?(n.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(n.matrixAutoUpdate=e.matrixAutoUpdate),n.matrixAutoUpdate&&n.matrix.decompose(n.position,n.quaternion,n.scale)):(void 0!==e.position&&n.position.fromArray(e.position),void 0!==e.rotation&&n.rotation.fromArray(e.rotation),void 0!==e.quaternion&&n.quaternion.fromArray(e.quaternion),void 0!==e.scale&&n.scale.fromArray(e.scale)),void 0!==e.up&&n.up.fromArray(e.up),void 0!==e.castShadow&&(n.castShadow=e.castShadow),void 0!==e.receiveShadow&&(n.receiveShadow=e.receiveShadow),e.shadow&&(void 0!==e.shadow.intensity&&(n.shadow.intensity=e.shadow.intensity),void 0!==e.shadow.bias&&(n.shadow.bias=e.shadow.bias),void 0!==e.shadow.normalBias&&(n.shadow.normalBias=e.shadow.normalBias),void 0!==e.shadow.radius&&(n.shadow.radius=e.shadow.radius),void 0!==e.shadow.mapSize&&n.shadow.mapSize.fromArray(e.shadow.mapSize),void 0!==e.shadow.camera&&(n.shadow.camera=this.parseObject(e.shadow.camera))),void 0!==e.visible&&(n.visible=e.visible),void 0!==e.frustumCulled&&(n.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(n.renderOrder=e.renderOrder),void 0!==e.userData&&(n.userData=e.userData),void 0!==e.layers&&(n.layers.mask=e.layers),void 0!==e.children){const o=e.children;for(let e=0;e{t&&t(s),r.manager.itemEnd(e)})).catch((e=>{i&&i(e)})):(setTimeout((function(){t&&t(n),r.manager.itemEnd(e)}),0),n);const o={};o.credentials="anonymous"===this.crossOrigin?"same-origin":"include",o.headers=this.requestHeader;const a=fetch(e,o).then((function(e){return e.blob()})).then((function(e){return createImageBitmap(e,Object.assign(r.options,{colorSpaceConversion:"none"}))})).then((function(s){return dT.add(e,s),t&&t(s),r.manager.itemEnd(e),s})).catch((function(t){i&&i(t),dT.remove(e),r.manager.itemError(e),r.manager.itemEnd(e)}));dT.add(e,a),r.manager.itemStart(e)}}let e_;class t_{static getContext(){return void 0===e_&&(e_=new(window.AudioContext||window.webkitAudioContext)),e_}static setContext(e){e_=e}}class s_ extends gT{constructor(e){super(e)}load(e,t,s,i){const r=this,n=new xT(this.manager);function o(t){i?i(t):console.error(t),r.manager.itemError(e)}n.setResponseType("arraybuffer"),n.setPath(this.path),n.setRequestHeader(this.requestHeader),n.setWithCredentials(this.withCredentials),n.load(e,(function(e){try{const s=e.slice(0);t_.getContext().decodeAudioData(s,(function(e){t(e)})).catch(o)}catch(e){o(e)}}),s,i)}}const i_=new or,r_=new or,n_=new or;class o_{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Kn,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Kn,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,n_.copy(e.projectionMatrix);const s=t.eyeSep/2,i=s*t.near/t.focus,r=t.near*Math.tan(Hs*t.fov*.5)/t.zoom;let n,o;r_.elements[12]=-s,i_.elements[12]=s,n=-r*t.aspect+i,o=r*t.aspect+i,n_.elements[0]=2*t.near/(o-n),n_.elements[8]=(o+n)/(o-n),this.cameraL.projectionMatrix.copy(n_),n=-r*t.aspect-i,o=r*t.aspect-i,n_.elements[0]=2*t.near/(o-n),n_.elements[8]=(o+n)/(o-n),this.cameraR.projectionMatrix.copy(n_)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(r_),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(i_)}}class a_ extends Kn{constructor(e=[]){super(),this.isArrayCamera=!0,this.cameras=e}}class h_{constructor(e=!0){this.autoStart=e,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=l_(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=l_();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}function l_(){return("undefined"==typeof performance?Date:performance).now()}const u_=new Ei,c_=new Ci,d_=new Ei,p_=new Ei;class m_ extends Pr{constructor(){super(),this.type="AudioListener",this.context=t_.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new h_}getInput(){return this.gain}removeFilter(){return null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null),this}getFilter(){return this.filter}setFilter(e){return null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener,s=this.up;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(u_,c_,d_),p_.set(0,0,-1).applyQuaternion(c_),t.positionX){const e=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(u_.x,e),t.positionY.linearRampToValueAtTime(u_.y,e),t.positionZ.linearRampToValueAtTime(u_.z,e),t.forwardX.linearRampToValueAtTime(p_.x,e),t.forwardY.linearRampToValueAtTime(p_.y,e),t.forwardZ.linearRampToValueAtTime(p_.z,e),t.upX.linearRampToValueAtTime(s.x,e),t.upY.linearRampToValueAtTime(s.y,e),t.upZ.linearRampToValueAtTime(s.z,e)}else t.setPosition(u_.x,u_.y,u_.z),t.setOrientation(p_.x,p_.y,p_.z,s.x,s.y,s.z)}}class g_ extends Pr{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(!0===this.isPlaying)return void console.warn("THREE.Audio: Audio is already playing.");if(!1===this.hasPlaybackControl)return void console.warn("THREE.Audio: this Audio has no playback control.");this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(!1!==this.hasPlaybackControl)return!0===this.isPlaying&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,!0===this.loop&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this;console.warn("THREE.Audio: this Audio has no playback control.")}stop(){if(!1!==this.hasPlaybackControl)return this._progress=0,null!==this.source&&(this.source.stop(),this.source.onended=null),this.isPlaying=!1,this;console.warn("THREE.Audio: this Audio has no playback control.")}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e0){this.source.disconnect(this.filters[0]);for(let e=1,t=this.filters.length;e0&&this._mixBufferRegionAdditive(s,i,this._addIndex*t,1,t);for(let e=t,r=t+t;e!==r;++e)if(s[e]!==s[e+t]){o.setValue(s,i);break}}saveOriginalState(){const e=this.binding,t=this.buffer,s=this.valueSize,i=s*this._origIndex;e.getValue(t,i);for(let e=s,r=i;e!==r;++e)t[e]=t[i+e%s];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=3*this.valueSize;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let s=e;s=.5)for(let i=0;i!==r;++i)e[t+i]=e[s+i]}_slerp(e,t,s,i){Ci.slerpFlat(e,t,e,t,e,s,i)}_slerpAdditive(e,t,s,i,r){const n=this._workIndex*r;Ci.multiplyQuaternionsFlat(e,n,e,t,e,s),Ci.slerpFlat(e,t,e,t,e,n,i)}_lerp(e,t,s,i,r){const n=1-i;for(let o=0;o!==r;++o){const r=t+o;e[r]=e[r]*n+e[s+o]*i}}_lerpAdditive(e,t,s,i,r){for(let n=0;n!==r;++n){const r=t+n;e[r]=e[r]+e[s+n]*i}}}const w_="\\[\\]\\.:\\/",S_=new RegExp("["+w_+"]","g"),M_="[^"+w_+"]",A_="[^"+w_.replace("\\.","")+"]",N_=new RegExp("^"+/((?:WC+[\/:])*)/.source.replace("WC",M_)+/(WCOD+)?/.source.replace("WCOD",A_)+/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",M_)+/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",M_)+"$"),R_=["material","materials","bones","map"];class C_{constructor(e,t,s){this.path=t,this.parsedPath=s||C_.parseTrackName(t),this.node=C_.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,s){return e&&e.isAnimationObjectGroup?new C_.Composite(e,t,s):new C_(e,t,s)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(S_,"")}static parseTrackName(e){const t=N_.exec(e);if(null===t)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const s={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},i=s.nodeName&&s.nodeName.lastIndexOf(".");if(void 0!==i&&-1!==i){const e=s.nodeName.substring(i+1);-1!==R_.indexOf(e)&&(s.nodeName=s.nodeName.substring(0,i),s.objectName=e)}if(null===s.propertyName||0===s.propertyName.length)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return s}static findNode(e,t){if(void 0===t||""===t||"."===t||-1===t||t===e.name||t===e.uuid)return e;if(e.skeleton){const s=e.skeleton.getBoneByName(t);if(void 0!==s)return s}if(e.children){const s=function(e){for(let i=0;i=r){const n=r++,l=e[n];t[l.uuid]=h,e[h]=l,t[a]=n,e[n]=o;for(let e=0,t=i;e!==t;++e){const t=s[e],i=t[n],r=t[h];t[h]=i,t[n]=r}}}this.nCachedObjects_=r}uncache(){const e=this._objects,t=this._indicesByUUID,s=this._bindings,i=s.length;let r=this.nCachedObjects_,n=e.length;for(let o=0,a=arguments.length;o!==a;++o){const a=arguments[o].uuid,h=t[a];if(void 0!==h)if(delete t[a],h0&&(t[o.uuid]=h),e[h]=o,e.pop();for(let e=0,t=i;e!==t;++e){const t=s[e];t[h]=t[r],t.pop()}}}this.nCachedObjects_=r}subscribe_(e,t){const s=this._bindingsIndicesByPath;let i=s[e];const r=this._bindings;if(void 0!==i)return r[i];const n=this._paths,o=this._parsedPaths,a=this._objects,h=a.length,l=this.nCachedObjects_,u=new Array(h);i=r.length,s[e]=i,n.push(e),o.push(t),r.push(u);for(let s=l,i=a.length;s!==i;++s){const i=a[s];u[s]=new C_(i,e,t)}return u}unsubscribe_(e){const t=this._bindingsIndicesByPath,s=t[e];if(void 0!==s){const i=this._paths,r=this._parsedPaths,n=this._bindings,o=n.length-1,a=n[o];t[e[o]]=s,n[s]=a,n.pop(),r[s]=r[o],r.pop(),i[s]=i[o],i.pop()}}}class B_{constructor(e,t,s=null,i=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=s,this.blendMode=i;const r=t.tracks,n=r.length,o=new Array(n),a={endingStart:zt,endingEnd:zt};for(let e=0;e!==n;++e){const t=r[e].createInterpolant(null);o[e]=t,t.settings=a}this._interpolantSettings=a,this._interpolants=o,this._propertyBindings=new Array(n),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=2201,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,s){if(e.fadeOut(t),this.fadeIn(t),s){const s=this._clip.duration,i=e._clip.duration,r=i/s,n=s/i;e.warp(1,r,t),this.warp(n,1,t)}return this}crossFadeTo(e,t,s){return e.crossFadeFrom(this,t,s)}stopFading(){const e=this._weightInterpolant;return null!==e&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,s){const i=this._mixer,r=i.time,n=this.timeScale;let o=this._timeScaleInterpolant;null===o&&(o=i._lendControlInterpolant(),this._timeScaleInterpolant=o);const a=o.parameterPositions,h=o.sampleValues;return a[0]=r,a[1]=r+s,h[0]=e/n,h[1]=t/n,this}stopWarping(){const e=this._timeScaleInterpolant;return null!==e&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,s,i){if(!this.enabled)return void this._updateWeight(e);const r=this._startTime;if(null!==r){const i=(e-r)*s;i<0||0===s?t=0:(this._startTime=null,t=s*i)}t*=this._updateTimeScale(e);const n=this._updateTime(t),o=this._updateWeight(e);if(o>0){const e=this._interpolants,t=this._propertyBindings;if(this.blendMode===Vt)for(let s=0,i=e.length;s!==i;++s)e[s].evaluate(n),t[s].accumulateAdditive(o);else for(let s=0,r=e.length;s!==r;++s)e[s].evaluate(n),t[s].accumulate(i,o)}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const s=this._weightInterpolant;if(null!==s){const i=s.evaluate(e)[0];t*=i,e>s.parameterPositions[1]&&(this.stopFading(),0===i&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const s=this._timeScaleInterpolant;if(null!==s){t*=s.evaluate(e)[0],e>s.parameterPositions[1]&&(this.stopWarping(),0===t?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,s=this.loop;let i=this.time+e,r=this._loopCount;const n=2202===s;if(0===e)return-1===r?i:n&&1==(1&r)?t-i:i;if(2200===s){-1===r&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(i>=t)i=t;else{if(!(i<0)){this.time=i;break e}i=0}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(-1===r&&(e>=0?(r=0,this._setEndings(!0,0===this.repetitions,n)):this._setEndings(0===this.repetitions,!0,n)),i>=t||i<0){const s=Math.floor(i/t);i-=t*s,r+=Math.abs(s);const o=this.repetitions-r;if(o<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,i=e>0?t:0,this.time=i,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(1===o){const t=e<0;this._setEndings(t,!t,n)}else this._setEndings(!1,!1,n);this._loopCount=r,this.time=i,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:s})}}else this.time=i;if(n&&1==(1&r))return t-i}return i}_setEndings(e,t,s){const i=this._interpolantSettings;s?(i.endingStart=Ut,i.endingEnd=Ut):(i.endingStart=e?this.zeroSlopeAtStart?Ut:zt:Lt,i.endingEnd=t?this.zeroSlopeAtEnd?Ut:zt:Lt)}_scheduleFading(e,t,s){const i=this._mixer,r=i.time;let n=this._weightInterpolant;null===n&&(n=i._lendControlInterpolant(),this._weightInterpolant=n);const o=n.parameterPositions,a=n.sampleValues;return o[0]=r,a[0]=t,o[1]=r+e,a[1]=s,this}}const I_=new Float32Array(1);class P_ extends ks{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const s=e._localRoot||this._root,i=e._clip.tracks,r=i.length,n=e._propertyBindings,o=e._interpolants,a=s.uuid,h=this._bindingsByRootAndName;let l=h[a];void 0===l&&(l={},h[a]=l);for(let e=0;e!==r;++e){const r=i[e],h=r.name;let u=l[h];if(void 0!==u)++u.referenceCount,n[e]=u;else{if(u=n[e],void 0!==u){null===u._cacheIndex&&(++u.referenceCount,this._addInactiveBinding(u,a,h));continue}const i=t&&t._propertyBindings[e].binding.parsedPath;u=new __(C_.create(s,h,i),r.ValueTypeName,r.getValueSize()),++u.referenceCount,this._addInactiveBinding(u,a,h),n[e]=u}o[e].resultBuffer=u.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(null===e._cacheIndex){const t=(e._localRoot||this._root).uuid,s=e._clip.uuid,i=this._actionsByClip[s];this._bindAction(e,i&&i.knownActions[0]),this._addInactiveAction(e,s,t)}const t=e._propertyBindings;for(let e=0,s=t.length;e!==s;++e){const s=t[e];0==s.useCount++&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let e=0,s=t.length;e!==s;++e){const s=t[e];0==--s.useCount&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return null!==t&&t=0;--t)e[t].stop();return this}update(e){e*=this.timeScale;const t=this._actions,s=this._nActiveActions,i=this.time+=e,r=Math.sign(e),n=this._accuIndex^=1;for(let o=0;o!==s;++o){t[o]._update(i,e,r,n)}const o=this._bindings,a=this._nActiveBindings;for(let e=0;e!==a;++e)o[e].apply(n);return this}setTime(e){this.time=0;for(let e=0;e=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,j_).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const $_=new Ei,X_=new Ei;class Y_{constructor(e=new Ei,t=new Ei){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){$_.subVectors(e,this.start),X_.subVectors(this.end,this.start);const s=X_.dot(X_);let i=X_.dot($_)/s;return t&&(i=$s(i,0,1)),i}closestPointToPoint(e,t,s){const i=this.closestPointToPointParameter(e,t);return this.delta(s).multiplyScalar(i).add(this.start)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return(new this.constructor).copy(this)}}const J_=new Ei;class Z_ extends Pr{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const s=new Mn,i=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(let e=0,t=1,s=32;e1)for(let s=0;s.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{_w.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(_w,t)}}setLength(e,t=.2*e,s=.2*t){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(s,t,s),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class Aw extends La{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],s=new Mn;s.setAttribute("position",new yn(t,3)),s.setAttribute("color",new yn([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));super(s,new Ma({vertexColors:!0,toneMapped:!1})),this.type="AxesHelper"}setColors(e,t,s){const i=new Yr,r=this.geometry.attributes.color.array;return i.set(e),i.toArray(r,0),i.toArray(r,3),i.set(t),i.toArray(r,6),i.toArray(r,9),i.set(s),i.toArray(r,12),i.toArray(r,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Nw{constructor(){this.type="ShapePath",this.color=new Yr,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new Th,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,s,i){return this.currentPath.quadraticCurveTo(e,t,s,i),this}bezierCurveTo(e,t,s,i,r,n){return this.currentPath.bezierCurveTo(e,t,s,i,r,n),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(e,t){const s=t.length;let i=!1;for(let r=s-1,n=0;nNumber.EPSILON){if(h<0&&(s=t[n],a=-a,o=t[r],h=-h),e.yo.y)continue;if(e.y===s.y){if(e.x===s.x)return!0}else{const t=h*(e.x-s.x)-a*(e.y-s.y);if(0===t)return!0;if(t<0)continue;i=!i}}else{if(e.y!==s.y)continue;if(o.x<=e.x&&e.x<=s.x||s.x<=e.x&&e.x<=o.x)return!0}}return i}const s=ol.isClockWise,i=this.subPaths;if(0===i.length)return[];let r,n,o;const a=[];if(1===i.length)return n=i[0],o=new Fh,o.curves=n.curves,a.push(o),a;let h=!s(i[0].getPoints());h=e?!h:h;const l=[],u=[];let c,d,p=[],m=0;u[m]=void 0,p[m]=[];for(let t=0,o=i.length;t1){let e=!1,s=0;for(let e=0,t=u.length;e0&&!1===e&&(p=l)}for(let e=0,t=u.length;e{this.requestId=self.requestAnimationFrame(e),!0===this.info.autoReset&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,null!==this.animationLoop&&this.animationLoop(t,s)};e()}dispose(){self.cancelAnimationFrame(this.requestId),this.requestId=null}setAnimationLoop(e){this.animationLoop=e}}class Bw{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let s=0;s{this.dispose()},this.material.addEventListener("dispose",this.onMaterialDispose)}updateClipping(e){const t=this.material;let s=this.clippingContext;Array.isArray(t.clippingPlanes)?(s!==e&&s||(s=new Pw,this.clippingContext=s),s.update(e,t)):this.clippingContext!==e&&(this.clippingContext=e)}get clippingNeedsUpdate(){return this.clippingContext.version!==this.clippingContextVersion&&(this.clippingContextVersion=this.clippingContext.version,!0)}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getIndex(){return this._geometries.getIndex(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}getAttributes(){if(null!==this.attributes)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,s=[],i=new Set;for(const r of e){const e=r.node&&r.node.attribute?r.node.attribute:t.getAttribute(r.name);if(void 0===e)continue;s.push(e);const n=e.isInterleavedBufferAttribute?e.data:e;i.add(n)}return this.attributes=s,this.vertexBuffers=Array.from(i.values()),s}getVertexBuffers(){return null===this.vertexBuffers&&this.getAttributes(),this.vertexBuffers}getMaterialCacheKey(){const{object:e,material:t}=this;let s=t.customProgramCacheKey();for(const e of function(e){const t=Object.keys(e);let s=Object.getPrototypeOf(e);for(;s;){const e=Object.getOwnPropertyDescriptors(s);for(const s in e)if(void 0!==e[s]){const i=e[s];i&&"function"==typeof i.get&&t.push(s)}s=Object.getPrototypeOf(s)}return t}(t)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(e))continue;const i=t[e];let r;if(null!==i){const e=typeof i;"number"===e?r=0!==i?"1":"0":"object"===e?(r="{",i.isTexture&&(r+=i.mapping),r+="}"):r=String(i)}else r=String(i);s+=r+","}return s+=this.clippingContext.cacheKey+",",e.skeleton&&(s+=e.skeleton.bones.length+","),e.morphTargetInfluences&&(s+=e.morphTargetInfluences.length+","),e.isBatchedMesh&&(s+=e._matricesTexture.uuid+",",null!==e._colorsTexture&&(s+=e._colorsTexture.uuid+",")),e.count>1&&(s+=e.count+","+e.uuid+","),s}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){return this.object.receiveShadow+","+this._nodes.getCacheKey(this.scene,this.lightsNode)}getCacheKey(){return this.getMaterialCacheKey()+","+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.onDispose()}}class Uw{constructor(e,t,s,i,r,n){this.renderer=e,this.nodes=t,this.geometries=s,this.pipelines=i,this.bindings=r,this.info=n,this.chainMaps={}}get(e,t,s,i,r,n,o){const a=this.getChainMap(o),h=[e,t,n,r];let l=a.get(h);return void 0===l?(l=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,s,i,r,n,o),a.set(h,l)):(l.updateClipping(n.clippingContext),(l.version!==t.version||l.needsUpdate)&&(l.initialCacheKey!==l.getCacheKey()?(l.dispose(),l=this.get(e,t,s,i,r,n,o)):l.version=t.version)),l}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new Bw)}dispose(){this.chainMaps={}}createRenderObject(e,t,s,i,r,n,o,a,h,l){const u=this.getChainMap(l),c=new zw(e,t,s,i,r,n,o,a,h);return c.onDispose=()=>{this.pipelines.delete(c),this.bindings.delete(c),this.nodes.delete(c),u.delete(c.getChainArray())},c}}class Lw{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}delete(e){let t;return this.data.has(e)&&(t=this.data.get(e),this.data.delete(e)),t}has(e){return this.data.has(e)}dispose(){this.data=new WeakMap}}const Ow=1,Vw=2,Dw=4,kw=16;class Gw extends Lw{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return void 0!==t&&this.backend.destroyAttribute(e),t}update(e,t){const s=this.get(e);if(void 0===s.version)t===Ow?this.backend.createAttribute(e):t===Vw?this.backend.createIndexAttribute(e):t===Dw&&this.backend.createStorageAttribute(e),s.version=this._getBufferAttribute(e).version;else{const t=this._getBufferAttribute(e);(s.version=0;--t)if(e[t]>=65535)return!0;return!1}(t)?gn:pn)(t,1);return r.version=Ww(e),r}class jw extends Lw{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap}has(e){const t=e.geometry;return super.has(t)&&!0===this.get(t).initialized}updateForRender(e){!1===this.has(e)&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){const t=e.geometry;this.get(t).initialized=!0,this.info.memory.geometries++;const s=()=>{this.info.memory.geometries--;const i=t.index,r=e.getAttributes();null!==i&&this.attributes.delete(i);for(const e of r)this.attributes.delete(e);const n=this.wireframes.get(t);void 0!==n&&this.attributes.delete(n),t.removeEventListener("dispose",s)};t.addEventListener("dispose",s)}updateAttributes(e){const t=e.getAttributes();for(const e of t)e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute?this.updateAttribute(e,Dw):this.updateAttribute(e,Ow);const s=this.getIndex(e);null!==s&&this.updateAttribute(s,Vw)}updateAttribute(e,t){const s=this.info.render.calls;e.isInterleavedBufferAttribute?void 0===this.attributeCall.get(e)?(this.attributes.update(e,t),this.attributeCall.set(e,s)):this.attributeCall.get(e.data)!==s&&(this.attributes.update(e,t),this.attributeCall.set(e.data,s),this.attributeCall.set(e,s)):this.attributeCall.get(e)!==s&&(this.attributes.update(e,t),this.attributeCall.set(e,s))}getIndex(e){const{geometry:t,material:s}=e;let i=t.index;if(!0===s.wireframe){const e=this.wireframes;let s=e.get(t);void 0===s?(s=Hw(t),e.set(t,s)):s.version!==Ww(t)&&(this.attributes.delete(s),s=Hw(t),e.set(t,s)),i=s}return i}}class qw{constructor(){this.autoReset=!0,this.frame=0,this.calls=0,this.render={calls:0,frameCalls:0,drawCalls:0,triangles:0,points:0,lines:0,timestamp:0,previousFrameCalls:0,timestampCalls:0},this.compute={calls:0,frameCalls:0,timestamp:0,previousFrameCalls:0,timestampCalls:0},this.memory={geometries:0,textures:0}}update(e,t,s){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=s*(t/3):e.isPoints?this.render.points+=s*t:e.isLineSegments?this.render.lines+=s*(t/2):e.isLine?this.render.lines+=s*(t-1):console.error("THREE.WebGPUInfo: Unknown object type.")}updateTimestamp(e,t){0===this[e].timestampCalls&&(this[e].timestamp=0),this[e].timestamp+=t,this[e].timestampCalls++,this[e].timestampCalls>=this[e].previousFrameCalls&&(this[e].timestampCalls=0)}reset(){const e=this.render.frameCalls;this.render.previousFrameCalls=e;const t=this.compute.frameCalls;this.compute.previousFrameCalls=t,this.render.drawCalls=0,this.render.frameCalls=0,this.compute.frameCalls=0,this.render.triangles=0,this.render.points=0,this.render.lines=0}dispose(){this.reset(),this.calls=0,this.render.calls=0,this.compute.calls=0,this.render.timestamp=0,this.compute.timestamp=0,this.memory.geometries=0,this.memory.textures=0}}class $w{constructor(e){this.cacheKey=e,this.usedTimes=0}}class Xw extends $w{constructor(e,t,s){super(e),this.vertexProgram=t,this.fragmentProgram=s}}class Yw extends $w{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let Jw=0;class Zw{constructor(e,t,s=null,i=null){this.id=Jw++,this.code=e,this.stage=t,this.transforms=s,this.attributes=i,this.usedTimes=0}}class Kw extends Lw{constructor(e,t){super(),this.backend=e,this.nodes=t,this.bindings=null,this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}getForCompute(e,t){const{backend:s}=this,i=this.get(e);if(this._needsComputeUpdate(e)){const r=i.pipeline;r&&(r.usedTimes--,r.computeProgram.usedTimes--);const n=this.nodes.getForCompute(e);let o=this.programs.compute.get(n.computeShader);void 0===o&&(r&&0===r.computeProgram.usedTimes&&this._releaseProgram(r.computeProgram),o=new Zw(n.computeShader,"compute",n.transforms,n.nodeAttributes),this.programs.compute.set(n.computeShader,o),s.createProgram(o));const a=this._getComputeCacheKey(e,o);let h=this.caches.get(a);void 0===h&&(r&&0===r.usedTimes&&this._releasePipeline(r),h=this._getComputePipeline(e,o,a,t)),h.usedTimes++,o.usedTimes++,i.version=e.version,i.pipeline=h}return i.pipeline}getForRender(e,t=null){const{backend:s}=this,i=this.get(e);if(this._needsRenderUpdate(e)){const r=i.pipeline;r&&(r.usedTimes--,r.vertexProgram.usedTimes--,r.fragmentProgram.usedTimes--);const n=e.getNodeBuilderState();let o=this.programs.vertex.get(n.vertexShader);void 0===o&&(r&&0===r.vertexProgram.usedTimes&&this._releaseProgram(r.vertexProgram),o=new Zw(n.vertexShader,"vertex"),this.programs.vertex.set(n.vertexShader,o),s.createProgram(o));let a=this.programs.fragment.get(n.fragmentShader);void 0===a&&(r&&0===r.fragmentProgram.usedTimes&&this._releaseProgram(r.fragmentProgram),a=new Zw(n.fragmentShader,"fragment"),this.programs.fragment.set(n.fragmentShader,a),s.createProgram(a));const h=this._getRenderCacheKey(e,o,a);let l=this.caches.get(h);void 0===l?(r&&0===r.usedTimes&&this._releasePipeline(r),l=this._getRenderPipeline(e,o,a,h,t)):e.pipeline=l,l.usedTimes++,o.usedTimes++,a.usedTimes++,i.pipeline=l}return i.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,0===t.usedTimes&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,0===t.computeProgram.usedTimes&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,0===t.vertexProgram.usedTimes&&this._releaseProgram(t.vertexProgram),0===t.fragmentProgram.usedTimes&&this._releaseProgram(t.fragmentProgram))),super.delete(e)}dispose(){super.dispose(),this.caches=new Map,this.programs={vertex:new Map,fragment:new Map,compute:new Map}}updateForRender(e){this.getForRender(e)}_getComputePipeline(e,t,s,i){s=s||this._getComputeCacheKey(e,t);let r=this.caches.get(s);return void 0===r&&(r=new Yw(s,t),this.caches.set(s,r),this.backend.createComputePipeline(r,i)),r}_getRenderPipeline(e,t,s,i,r){i=i||this._getRenderCacheKey(e,t,s);let n=this.caches.get(i);return void 0===n&&(n=new Xw(i,t,s),this.caches.set(i,n),e.pipeline=n,this.backend.createRenderPipeline(e,r)),n}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,s){return t.id+","+s.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,s=e.stage;this.programs[s].delete(t)}_needsComputeUpdate(e){const t=this.get(e);return void 0===t.pipeline||t.version!==e.version}_needsRenderUpdate(e){return void 0===this.get(e).pipeline||this.backend.needsRenderUpdate(e)}}class Qw extends Lw{constructor(e,t,s,i,r,n){super(),this.backend=e,this.textures=s,this.pipelines=r,this.attributes=i,this.nodes=t,this.info=n,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const e of t){const s=this.get(e);void 0===s.bindGroup&&(this._init(e),this.backend.createBindings(e,t),s.bindGroup=e)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const e of t){const s=this.get(e);void 0===s.bindGroup&&(this._init(e),this.backend.createBindings(e,t),s.bindGroup=e)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){const e=t.attribute;this.attributes.update(e,Dw)}}_update(e,t){const{backend:s}=this;let i=!1;for(const t of e.bindings){if(t.isNodeUniformsGroup){if(!this.nodes.updateGroup(t))continue}if(t.isUniformBuffer){t.update()&&s.updateBinding(t)}else if(t.isSampler)t.update();else if(t.isSampledTexture){t.needsBindingsUpdate(this.textures.get(t.texture).generation)&&(i=!0);const e=t.update(),r=t.texture;e&&this.textures.updateTexture(r);const n=s.get(r);if(!0===s.isWebGPUBackend&&void 0===n.texture&&void 0===n.externalTexture&&(console.error("Bindings._update: binding should be available:",t,e,r,t.textureNode.value,i),this.textures.updateTexture(r),i=!0),!0===r.isStorageTexture){const e=this.get(r);!0===t.store?e.needsMipmap=!0:!0===r.generateMipmaps&&this.textures.needsMipmaps(r)&&!0===e.needsMipmap&&(this.backend.generateMipmaps(r),e.needsMipmap=!1)}}}!0===i&&this.backend.updateBindings(e,t)}}class eS{constructor(e,t,s=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=s}}class tS{constructor(e,t,s){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=s.getSelf()}get value(){return this.node.value}set value(e){this.node.value=e}get id(){return this.node.id}get groupNode(){return this.node.groupNode}}class sS{constructor(e,t){this.isNodeVar=!0,this.name=e,this.type=t}}class iS extends sS{constructor(e,t){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0}}class rS{constructor(e,t,s=""){this.name=e,this.type=t,this.code=s,Object.defineProperty(this,"isNodeCode",{value:!0})}}let nS=0;class oS{constructor(e=null){this.id=nS++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return void 0===t&&null!==this.parent&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class aS extends Ec{constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}aS.type=Ql("Parameter",aS);const hS=(e,t)=>Du(new aS(e,t));class lS extends Kl{constructor(e="",t=[],s=""){super("code"),this.isCodeNode=!0,this.code=e,this.language=s,this.includes=t}isGlobal(){return!0}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const s of t)s.build(e);const s=e.getCodeFromNode(this,this.getNodeType(e));return s.code=this.code,s.code}serialize(e){super.serialize(e),e.code=this.code,e.language=this.language}deserialize(e){super.deserialize(e),this.code=e.code,this.language=e.language}}lS.type=Ql("Code",lS);const uS=Wu(lS),cS=(e,t)=>uS(e,t,"js"),dS=(e,t)=>uS(e,t,"wgsl"),pS=(e,t)=>uS(e,t,"glsl");class mS extends lS{constructor(e="",t=[],s=""){super(e,t,s)}getNodeType(e){return this.getNodeFunction(e).type}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let s=t.nodeFunction;return void 0===s&&(s=e.parser.parseFunction(this.code),t.nodeFunction=s),s}generate(e,t){super.generate(e);const s=this.getNodeFunction(e),i=s.name,r=s.type,n=e.getCodeFromNode(this,r);""!==i&&(n.name=i);const o=e.getPropertyName(n),a=this.getNodeFunction(e).getCode(o);return n.code=a+"\n","property"===t?o:e.format(`${o}()`,r,t)}}mS.type=Ql("Function",mS);const gS=(e,t=[],s="")=>{for(let e=0;ei.call(...e);return r.functionNode=i,r},fS=(e,t)=>gS(e,t,"glsl"),yS=(e,t)=>gS(e,t,"wgsl");class xS{constructor(e,t){this.name=e,this.value=t,this.boundary=0,this.itemSize=0,this.offset=0}setValue(e){this.value=e}getValue(){return this.value}}class bS extends xS{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class vS extends xS{constructor(e,t=new Qs){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class TS extends xS{constructor(e,t=new Ei){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class _S extends xS{constructor(e,t=new _i){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class wS extends xS{constructor(e,t=new Yr){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class SS extends xS{constructor(e,t=new ei){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class MS extends xS{constructor(e,t=new or){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class AS extends bS{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class NS extends vS{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class RS extends TS{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class CS extends _S{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class ES extends wS{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class BS extends SS{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class IS extends MS{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}}class PS extends Kl{constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this.isStackNode=!0}getNodeType(e){return this.outputNode?this.outputNode.getNodeType(e):"void"}add(e){return this.nodes.push(e),this}If(e,t){const s=new Vu(t);return this._currentCond=qp(e,s),this.add(this._currentCond)}ElseIf(e,t){const s=new Vu(t),i=qp(e,s);return this._currentCond.elseNode=i,this._currentCond=i,this}Else(e){return this._currentCond.elseNode=new Vu(e),this}build(e,...t){const s=Xu();$u(this);for(const t of this.nodes)t.build(e,"void");return $u(s),this.outputNode?this.outputNode.build(e,...t):super.build(e,...t)}else(...e){return console.warn("TSL.StackNode: .else() has been renamed to .Else()."),this.Else(...e)}elseif(...e){return console.warn("TSL.StackNode: .elseif() has been renamed to .ElseIf()."),this.ElseIf(...e)}}PS.type=Ql("Stack",PS);const FS=Wu(PS),zS=[.125,.215,.35,.446,.526,.582],US=20,LS=new OT(-1,1,1,-1,0,1),OS=new Kn(90,1),VS=new Yr;let DS=null,kS=0,GS=0;const WS=(1+Math.sqrt(5))/2,HS=1/WS,jS=[new Ei(-WS,HS,0),new Ei(WS,HS,0),new Ei(-HS,0,WS),new Ei(HS,0,WS),new Ei(0,WS,-HS),new Ei(0,WS,HS),new Ei(-1,1,-1),new Ei(1,1,-1),new Ei(-1,1,1),new Ei(1,1,1)],qS=[3,1,5,0,4,2],$S=nv(Um(),zm("faceIndex")).normalize(),XS=oc($S.x,$S.y.negate(),$S.z);class YS{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}fromScene(e,t=0,s=.1,i=100){DS=this._renderer.getRenderTarget(),kS=this._renderer.getActiveCubeFace(),GS=this._renderer.getActiveMipmapLevel(),this._setSize(256);const r=this._allocateTargets();return r.depthBuffer=!0,this._sceneToCubeUV(e,s,i,r),t>0&&this._blur(r,0,0,t),this._applyPMREM(r),this._cleanup(r),r}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){null===this._cubemapMaterial&&(this._cubemapMaterial=QS(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){null===this._equirectMaterial&&(this._equirectMaterial=eM(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),null!==this._cubemapMaterial&&this._cubemapMaterial.dispose(),null!==this._equirectMaterial&&this._equirectMaterial.dispose(),null!==this._backgroundBox&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){null!==this._blurMaterial&&this._blurMaterial.dispose(),null!==this._pingPongRenderTarget&&this._pingPongRenderTarget.dispose();for(let e=0;ee-4?h=zS[a-e+4-1]:0===a&&(h=0),i.push(h);const l=1/(o-2),u=-l,c=1+l,d=[u,u,c,u,c,c,u,u,c,c,u,c],p=6,m=6,g=3,f=2,y=1,x=new Float32Array(g*m*p),b=new Float32Array(f*m*p),v=new Float32Array(y*m*p);for(let e=0;e2?0:-1,i=[t,s,0,t+2/3,s,0,t+2/3,s+1,0,t,s,0,t+2/3,s+1,0,t,s+1,0],r=qS[e];x.set(i,g*m*r),b.set(d,f*m*r);const n=[r,r,r,r,r,r];v.set(n,y*m*r)}const T=new Mn;T.setAttribute("position",new hn(x,g)),T.setAttribute("uv",new hn(b,f)),T.setAttribute("faceIndex",new hn(v,y)),t.push(T),r.push(new Wn(T,null)),n>4&&n--}return{lodPlanes:t,sizeLods:s,sigmas:i,lodMeshes:r}}(i)),this._blurMaterial=function(e,t,s){const i=Xg(new Array(US).fill(0)),r=Cc(new Ei(0,1,0)),n=Cc(0),o=Ku(US),a=Cc(0),h=Cc(1),l=Gm(null),u=Cc(0),c=Ku(1/t),d=Ku(1/s),p=Ku(e),m={n:o,latitudinal:a,weights:i,poleAxis:r,outputDirection:XS,dTheta:n,samples:h,envMap:l,mipInt:u,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:d,CUBEUV_MAX_MIP:p},g=KS("blur");return g.uniforms=m,g.fragmentNode=lv({...m,latitudinal:a.equal(1)}),g}(i,e,t)}return i}_compileMaterial(e){const t=this._lodMeshes[0];t.material=e,this._renderer.compile(t,LS)}_sceneToCubeUV(e,t,s,i){const r=OS;r.near=t,r.far=s;const n=[-1,1,-1,-1,-1,-1],o=[1,1,1,-1,-1,-1],a=this._renderer,h=a.autoClear;a.getClearColor(VS),a.autoClear=!1;let l=this._backgroundBox;if(null===l){const e=new Qr({name:"PMREM.Background",side:d,depthWrite:!1,depthTest:!1});l=new Wn(new jn,e)}let u=!1;const c=e.background;c?c.isColor&&(l.material.color.copy(c),e.background=null,u=!0):(l.material.color.copy(VS),u=!0),a.setRenderTarget(i),a.clear(),u&&a.render(l,r);for(let t=0;t<6;t++){const s=t%3;0===s?(r.up.set(0,n[t],0),r.lookAt(o[t],0,0)):1===s?(r.up.set(0,0,n[t]),r.lookAt(0,o[t],0)):(r.up.set(0,n[t],0),r.lookAt(0,0,o[t]));const h=this._cubeSize;ZS(i,s*h,t>2?h:0,h,h),a.render(e,r)}a.autoClear=h,e.background=c}_textureToCubeUV(e,t){const s=this._renderer,i=e.mapping===he||e.mapping===le;i?null===this._cubemapMaterial&&(this._cubemapMaterial=QS(e)):null===this._equirectMaterial&&(this._equirectMaterial=eM(e));const r=i?this._cubemapMaterial:this._equirectMaterial;r.fragmentNode.value=e;const n=this._lodMeshes[0];n.material=r;const o=this._cubeSize;ZS(t,0,0,3*o,2*o),s.setRenderTarget(t),s.render(n,LS)}_applyPMREM(e){const t=this._renderer,s=t.autoClear;t.autoClear=!1;const i=this._lodPlanes.length;for(let t=1;tUS&&console.warn(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to 20`);const g=[];let f=0;for(let e=0;ey-4?i-y+4:0),4*(this._cubeSize-x),3*x,2*x),a.setRenderTarget(t),a.render(l,LS)}}function JS(e,t,s){const i=new wi(e,t,s);return i.texture.mapping=306,i.texture.name="PMREM.cubeUv",i.texture.isPMREMTexture=!0,i.scissorTest=!0,i}function ZS(e,t,s,i,r){e.viewport.set(t,s,i,r),e.scissor.set(t,s,i,r)}function KS(e){const t=new xx;return t.depthTest=!1,t.depthWrite=!1,t.blending=m,t.name=`PMREM_${e}`,t}function QS(e){const t=KS("cubemap");return t.fragmentNode=Wg(e,XS),t}function eM(e){const t=KS("equirect");return t.fragmentNode=Gm(e,Px(XS),0),t}let tM=0;class sM{constructor(e="",t=[],s=0,i=[]){this.name=e,this.bindings=t,this.index=s,this.bindingsReference=i,this.id=tM++}}const iM=new WeakMap,rM=new Map([[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),nM=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),oM=e=>(e=Number(e))+(e%1?"":".0");class aM{constructor(e,t,s){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=s,this.scene=null,this.camera=null,this.nodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.lightsNode=null,this.environmentNode=null,this.fogNode=null,this.clippingContext=null,this.vertexShader=null,this.fragmentShader=null,this.computeShader=null,this.flowNodes={vertex:[],fragment:[],compute:[]},this.flowCode={vertex:"",fragment:"",compute:""},this.uniforms={vertex:[],fragment:[],compute:[],index:0},this.structs={vertex:[],fragment:[],compute:[],index:0},this.bindings={vertex:{},fragment:{},compute:{}},this.bindingsIndexes={},this.bindGroups=null,this.attributes=[],this.bufferAttributes=[],this.varyings=[],this.codes={},this.vars={},this.flow={code:""},this.chaining=[],this.stack=FS(),this.stacks=[],this.tab="\t",this.instanceBindGroups=!0,this.currentFunctionNode=null,this.context={material:this.material},this.cache=new oS,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.useComparisonMethod=!1}getBindGroupsCache(){let e=iM.get(this.renderer);return void 0===e&&(e=new Bw,iM.set(this.renderer,e)),e}createRenderTarget(e,t,s){return new wi(e,t,s)}createCubeRenderTarget(e,t){return new Fx(e,t)}createPMREMGenerator(){return new YS(this.renderer)}includes(e){return this.nodes.includes(e)}_getBindGroup(e,t){const s=this.getBindGroupsCache(),i=[];let r,n=!0;for(const e of t)i.push(e),n=n&&!0!==e.groupNode.shared;return n?(r=s.get(i),void 0===r&&(r=new sM(e,i,this.bindingsIndexes[e].group,i),s.set(i,r))):r=new sM(e,i,this.bindingsIndexes[e].group,i),r}getBindGroupArray(e,t){const s=this.bindings[t];let i=s[e];return void 0===i&&(void 0===this.bindingsIndexes[e]&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),s[e]=i=[]),i}getBindings(){let e=this.bindGroups;if(null===e){const t={},s=this.bindings;for(const e of Xl)for(const i in s[e]){const r=s[e][i];(t[i]||(t[i]=[])).push(...r)}e=[];for(const s in t){const i=t[s],r=this._getBindGroup(s,i);e.push(r)}this.bindGroups=e}return e}setHashNode(e,t){this.hashNodes[t]=e}addNode(e){!1===this.nodes.includes(e)&&(this.nodes.push(e),this.setHashNode(e,e.getHash(this)))}buildUpdateNodes(){for(const e of this.nodes){const t=e.getUpdateType(),s=e.getUpdateBeforeType(),i=e.getUpdateAfterType();t!==Hl.NONE&&this.updateNodes.push(e.getSelf()),s!==Hl.NONE&&this.updateBeforeNodes.push(e),i!==Hl.NONE&&this.updateAfterNodes.push(e)}}get currentNode(){return this.chaining[this.chaining.length-1]}isFilteredTexture(e){return e.magFilter===Te||e.magFilter===_e||e.magFilter===be||e.magFilter===Se||e.minFilter===Te||e.minFilter===_e||e.minFilter===be||e.minFilter===Se}addChain(e){this.chaining.push(e)}removeChain(e){if(this.chaining.pop()!==e)throw new Error("NodeBuilder: Invalid node chaining!")}getMethod(e){return e}getNodeFromHash(e){return this.hashNodes[e]}addFlow(e,t){return this.flowNodes[e].push(t),t}setContext(e){this.context=e}getContext(){return this.context}getSharedContext(){return this.context,this.context}setCache(e){this.cache=e}getCache(){return this.cache}getCacheFromNode(e,t=!0){const s=this.getDataFromNode(e);return void 0===s.cache&&(s.cache=new oS(t?this.getCache():null)),s.cache}isAvailable(){return!1}getVertexIndex(){console.warn("Abstract function.")}getInstanceIndex(){console.warn("Abstract function.")}getDrawIndex(){console.warn("Abstract function.")}getFrontFacing(){console.warn("Abstract function.")}getFragCoord(){console.warn("Abstract function.")}isFlipY(){return!1}increaseUsage(e){const t=this.getDataFromNode(e);return t.usageCount=void 0===t.usageCount?1:t.usageCount+1,t.usageCount}generateTexture(){console.warn("Abstract function.")}generateTextureLod(){console.warn("Abstract function.")}generateConst(e,t=null){if(null===t&&("float"===e||"int"===e||"uint"===e?t=0:"bool"===e?t=!1:"color"===e?t=new Yr:"vec2"===e?t=new Qs:"vec3"===e?t=new Ei:"vec4"===e&&(t=new _i)),"float"===e)return oM(t);if("int"===e)return`${Math.round(t)}`;if("uint"===e)return t>=0?`${Math.round(t)}u`:"0u";if("bool"===e)return t?"true":"false";if("color"===e)return`${this.getType("vec3")}( ${oM(t.r)}, ${oM(t.g)}, ${oM(t.b)} )`;const s=this.getTypeLength(e),i=this.getComponentType(e),r=e=>this.generateConst(i,e);if(2===s)return`${this.getType(e)}( ${r(t.x)}, ${r(t.y)} )`;if(3===s)return`${this.getType(e)}( ${r(t.x)}, ${r(t.y)}, ${r(t.z)} )`;if(4===s)return`${this.getType(e)}( ${r(t.x)}, ${r(t.y)}, ${r(t.z)}, ${r(t.w)} )`;if(s>4&&t&&(t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(r).join(", ")} )`;if(s>4)return`${this.getType(e)}()`;throw new Error(`NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return"color"===e?"vec3":e}hasGeometryAttribute(e){return this.geometry&&void 0!==this.geometry.getAttribute(e)}getAttribute(e,t){const s=this.attributes;for(const t of s)if(t.name===e)return t;const i=new eS(e,t);return s.push(i),i}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return"void"===e||"property"===e||"sampler"===e||"texture"===e||"cubeTexture"===e||"storageTexture"===e||"depthTexture"===e||"texture3D"===e}needsColorSpaceToLinearSRGB(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===Ee)return"int";if(t===Be)return"uint"}return"float"}getElementType(e){return"mat2"===e?"vec2":"mat3"===e?"vec3":"mat4"===e?"vec4":this.getComponentType(e)}getComponentType(e){if("float"===(e=this.getVectorType(e))||"bool"===e||"int"===e||"uint"===e)return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return null===t?null:"b"===t[1]?"bool":"i"===t[1]?"int":"u"===t[1]?"uint":"float"}getVectorType(e){return"color"===e?"vec3":"texture"===e||"cubeTexture"===e||"storageTexture"===e||"texture3D"===e?"vec4":e}getTypeFromLength(e,t="float"){if(1===e)return t;const s=rM.get(e);return("float"===t?"":t[0])+s}getTypeFromArray(e){return nM.get(e.constructor)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const s=t.array,i=e.itemSize,r=e.normalized;let n;return e instanceof fn||!0===r||(n=this.getTypeFromArray(s)),this.getTypeFromLength(i,n)}getTypeLength(e){const t=this.getVectorType(e),s=/vec([2-4])/.exec(t);return null!==s?Number(s[1]):"float"===t||"bool"===t||"int"===t||"uint"===t?1:!0===/mat2/.test(e)?4:!0===/mat3/.test(e)?9:!0===/mat4/.test(e)?16:0}getVectorFromMatrix(e){return e.replace("mat","vec")}changeComponentType(e,t){return this.getTypeFromLength(this.getTypeLength(e),t)}getIntegerType(e){const t=this.getComponentType(e);return"int"===t||"uint"===t?e:this.changeComponentType(e,"int")}addStack(){return this.stack=FS(this.stack),this.stacks.push(Xu()||this.stack),$u(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,$u(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,s=null){let i=(s=null===s?e.isGlobal(this)?this.globalCache:this.cache:s).getData(e);return void 0===i&&(i={},s.setData(e,i)),void 0===i[t]&&(i[t]={}),i[t]}getNodeProperties(e,t="any"){const s=this.getDataFromNode(e,t);return s.properties||(s.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const s=this.getDataFromNode(e);let i=s.bufferAttribute;if(void 0===i){const r=this.uniforms.index++;i=new eS("nodeAttribute"+r,t,e),this.bufferAttributes.push(i),s.bufferAttribute=i}return i}getStructTypeFromNode(e,t=this.shaderStage){const s=this.getDataFromNode(e,t);if(void 0===s.structType){const i=this.structs.index++;e.name=`StructType${i}`,this.structs[t].push(e),s.structType=e}return e}getUniformFromNode(e,t,s=this.shaderStage,i=null){const r=this.getDataFromNode(e,s,this.globalCache);let n=r.uniform;if(void 0===n){const o=this.uniforms.index++;n=new tS(i||"nodeUniform"+o,t,e),this.uniforms[s].push(n),r.uniform=n}return n}getVarFromNode(e,t=null,s=e.getNodeType(this),i=this.shaderStage){const r=this.getDataFromNode(e,i);let n=r.variable;if(void 0===n){const e=this.vars[i]||(this.vars[i]=[]);null===t&&(t="nodeVar"+e.length),n=new sS(t,s),e.push(n),r.variable=n}return n}getVaryingFromNode(e,t=null,s=e.getNodeType(this)){const i=this.getDataFromNode(e,"any");let r=i.varying;if(void 0===r){const e=this.varyings,n=e.length;null===t&&(t="nodeVarying"+n),r=new iS(t,s),e.push(r),i.varying=r}return r}getCodeFromNode(e,t,s=this.shaderStage){const i=this.getDataFromNode(e);let r=i.code;if(void 0===r){const e=this.codes[s]||(this.codes[s]=[]),n=e.length;r=new rS("nodeCode"+n,t),e.push(r),i.code=r}return r}addLineFlowCode(e){return""===e||(e=this.tab+e,/;\s*$/.test(e)||(e+=";\n"),this.flow.code+=e),this}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+="\t",this}removeFlowTab(){return this.tab=this.tab.slice(0,-1),this}getFlowData(e){return this.flowsData.get(e)}flowNode(e){const t=e.getNodeType(this),s=this.flowChildNode(e,t);return this.flowsData.set(e,s),s}buildFunctionNode(e){const t=new mS,s=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=s,t}flowShaderNode(e){const t=e.layout,s={[Symbol.iterator](){let e=0;const t=Object.values(this);return{next:()=>({value:t[e],done:e++>=t.length})}}};for(const e of t.inputs)s[e.name]=new aS(e.type,e.name);e.layout=null;const i=e.call(s),r=this.flowStagesNode(i,t.type);return e.layout=t,r}flowStagesNode(e,t=null){const s=this.flow,i=this.vars,r=this.cache,n=this.buildStage,o=this.stack,a={code:""};this.flow=a,this.vars={},this.cache=new oS,this.stack=FS();for(const s of $l)this.setBuildStage(s),a.result=e.build(this,t);return a.vars=this.getVars(this.shaderStage),this.flow=s,this.vars=i,this.cache=r,this.stack=o,this.setBuildStage(n),a}getFunctionOperator(){return null}flowChildNode(e,t=null){const s=this.flow,i={code:""};return this.flow=i,i.result=e.build(this,t),this.flow=s,i}flowNodeFromShaderStage(e,t,s=null,i=null){const r=this.shaderStage;this.setShaderStage(e);const n=this.flowChildNode(t,s);return null!==i&&(n.code+=`${this.tab+i} = ${n.result};\n`),this.flowCode[e]=this.flowCode[e]+n.code,this.setShaderStage(r),n}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){console.warn("Abstract function.")}getVaryings(){console.warn("Abstract function.")}getVar(e,t){return`${this.getType(e)} ${t}`}getVars(e){let t="";const s=this.vars[e];if(void 0!==s)for(const e of s)t+=`${this.getVar(e.type,e.name)}; `;return t}getUniforms(){console.warn("Abstract function.")}getCodes(e){const t=this.codes[e];let s="";if(void 0!==t)for(const e of t)s+=e.code+"\n";return s}getHash(){return this.vertexShader+this.fragmentShader+this.computeShader}setShaderStage(e){this.shaderStage=e}getShaderStage(){return this.shaderStage}setBuildStage(e){this.buildStage=e}getBuildStage(){return this.buildStage}buildCode(){console.warn("Abstract function.")}build(){const{object:e,material:t,renderer:s}=this;if(null!==t){let e=s.nodes.library.fromMaterial(t);null===e&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),e=new xx),e.build(this)}else this.addFlow("compute",e);for(const e of $l){this.setBuildStage(e),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const t of Xl){this.setShaderStage(t);const s=this.flowNodes[t];for(const t of s)"generate"===e?this.flowNode(t):t.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if("float"===t||"int"===t||"uint"===t)return new AS(e);if("vec2"===t||"ivec2"===t||"uvec2"===t)return new NS(e);if("vec3"===t||"ivec3"===t||"uvec3"===t)return new RS(e);if("vec4"===t||"ivec4"===t||"uvec4"===t)return new CS(e);if("color"===t)return new ES(e);if("mat3"===t)return new BS(e);if("mat4"===t)return new IS(e);throw new Error(`Uniform "${t}" not declared.`)}createNodeMaterial(e="NodeMaterial"){throw new Error(`THREE.NodeBuilder: createNodeMaterial() was deprecated. Use new ${e}() instead.`)}format(e,t,s){if((t=this.getVectorType(t))===(s=this.getVectorType(s))||null===s||this.isReference(s))return e;const i=this.getTypeLength(t),r=this.getTypeLength(s);return 16===i&&9===r?`${this.getType(s)}(${e}[0].xyz, ${e}[1].xyz, ${e}[2].xyz)`:9===i&&4===r?`${this.getType(s)}(${e}[0].xy, ${e}[1].xy)`:i>4||r>4||0===r?e:i===r?`${this.getType(s)}( ${e} )`:i>r?this.format(`${e}.${"xyz".slice(0,r)}`,this.getTypeFromLength(r,this.getComponentType(t)),s):4===r&&i>1?`${this.getType(s)}( ${this.format(e,t,"vec3")}, 1.0 )`:2===i?`${this.getType(s)}( ${this.format(e,t,"vec2")}, 0.0 )`:(1===i&&r>1&&t!==this.getComponentType(s)&&(e=`${this.getType(this.getComponentType(s))}( ${e} )`),`${this.getType(s)}( ${e} )`)}getSignature(){return`// Three.js r${e} - Node System\n`}}class hM{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,this.startTime=null,this.updateMap=new WeakMap,this.updateBeforeMap=new WeakMap,this.updateAfterMap=new WeakMap,this.renderer=null,this.material=null,this.camera=null,this.object=null,this.scene=null}_getMaps(e,t){let s=e.get(t);return void 0===s&&(s={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,s)),s}updateBeforeNode(e){const t=e.getUpdateBeforeType(),s=e.updateReference(this);if(t===Hl.FRAME){const{frameMap:t}=this._getMaps(this.updateBeforeMap,s);t.get(s)!==this.frameId&&!1!==e.updateBefore(this)&&t.set(s,this.frameId)}else if(t===Hl.RENDER){const{renderMap:t}=this._getMaps(this.updateBeforeMap,s);t.get(s)!==this.renderId&&!1!==e.updateBefore(this)&&t.set(s,this.renderId)}else t===Hl.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),s=e.updateReference(this);if(t===Hl.FRAME){const{frameMap:t}=this._getMaps(this.updateAfterMap,s);t.get(s)!==this.frameId&&!1!==e.updateAfter(this)&&t.set(s,this.frameId)}else if(t===Hl.RENDER){const{renderMap:t}=this._getMaps(this.updateAfterMap,s);t.get(s)!==this.renderId&&!1!==e.updateAfter(this)&&t.set(s,this.renderId)}else t===Hl.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),s=e.updateReference(this);if(t===Hl.FRAME){const{frameMap:t}=this._getMaps(this.updateMap,s);t.get(s)!==this.frameId&&!1!==e.update(this)&&t.set(s,this.frameId)}else if(t===Hl.RENDER){const{renderMap:t}=this._getMaps(this.updateMap,s);t.get(s)!==this.renderId&&!1!==e.update(this)&&t.set(s,this.renderId)}else t===Hl.OBJECT&&e.update(this)}update(){this.frameId++,void 0===this.lastTime&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class lM{constructor(e,t,s=null,i="",r=!1){this.type=e,this.name=t,this.count=s,this.qualifier=i,this.isConst=r}}lM.isNodeFunctionInput=!0;class uM extends Kl{constructor(e){super(),this.types=e,this.isStructTypeNode=!0}getMemberTypes(){return this.types}}uM.type=Ql("StructType",uM);class cM extends Kl{constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}setup(e){super.setup(e);const t=this.members,s=[];for(let i=0;ir&&(i=s,r=n)}}this._candidateFnCall=s=i(...t)}return s}}fM.type=Ql("FunctionOverloading",fM);const yM=Wu(fM),xM=e=>(...t)=>yM(e,...t);class bM extends Rc{constructor(e=bM.LOCAL,t=1,s=0){super(s),this.scope=e,this.scale=t,this.updateType=Hl.FRAME}update(e){const t=this.scope,s=this.scale;t===bM.LOCAL?this.value+=e.deltaTime*s:t===bM.DELTA?this.value=e.deltaTime*s:t===bM.FRAME?this.value=e.frameId:this.value=e.time*s}serialize(e){super.serialize(e),e.scope=this.scope,e.scale=this.scale}deserialize(e){super.deserialize(e),this.scope=e.scope,this.scale=e.scale}}bM.LOCAL="local",bM.GLOBAL="global",bM.DELTA="delta",bM.FRAME="frame",bM.type=Ql("Timer",bM);const vM=(e,t=0)=>Du(new bM(bM.LOCAL,e,t)),TM=(e,t=0)=>Du(new bM(bM.GLOBAL,e,t)),_M=(e,t=0)=>Du(new bM(bM.DELTA,e,t)),wM=Hu(bM,bM.FRAME).toUint();class SM extends Kl{constructor(e=SM.SINE,t=vM()){super(),this.method=e,this.timeNode=t}getNodeType(e){return this.timeNode.getNodeType(e)}setup(){const e=this.method,t=Du(this.timeNode);let s=null;return e===SM.SINE?s=t.add(.75).mul(2*Math.PI).sin().mul(.5).add(.5):e===SM.SQUARE?s=t.fract().round():e===SM.TRIANGLE?s=t.add(.5).fract().mul(2).sub(1).abs():e===SM.SAWTOOTH&&(s=t.fract()),s}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}SM.SINE="sine",SM.SQUARE="square",SM.TRIANGLE="triangle",SM.SAWTOOTH="sawtooth",SM.type=Ql("Osc",SM);const MM=Wu(SM,SM.SINE),AM=Wu(SM,SM.SQUARE),NM=Wu(SM,SM.TRIANGLE),RM=Wu(SM,SM.SAWTOOTH);class CM extends Kl{constructor(e,t=Um(),s=Ku(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=s}setup(){const{frameNode:e,uvNode:t,countNode:s}=this,{width:i,height:r}=s,n=e.mod(i.mul(r)).floor(),o=n.mod(i),a=r.sub(n.add(1).div(i).ceil()),h=s.reciprocal(),l=sc(o,a);return t.add(l).mul(h)}}CM.type=Ql("SpriteSheetUV",CM);const EM=Wu(CM);class BM extends tu{constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}setup(e){return!1===e.isAvailable("storageBuffer")&&(this.node.instanceIndex||!0!==this.node.bufferObject||e.setupPBO(this.node)),super.setup(e)}generate(e,t){let s;const i=e.context.assign;if(!1===e.isAvailable("storageBuffer")){const{node:t}=this;s=t.instanceIndex||!0!==this.node.bufferObject||!0===i?t.build(e):e.generatePBO(this)}else s=super.generate(e);if(!0!==i){const i=this.getNodeType(e);s=e.format(s,i,t)}return s}}BM.type=Ql("StorageArrayElement",BM);const IM=Wu(BM);class PM extends Kl{constructor(e,t=null,s=null,i=Ku(1),r=bg,n=Cg){super("vec4"),this.textureXNode=e,this.textureYNode=t,this.textureZNode=s,this.scaleNode=i,this.positionNode=r,this.normalNode=n}setup(){const{textureXNode:e,textureYNode:t,textureZNode:s,scaleNode:i,positionNode:r,normalNode:n}=this;let o=n.abs().normalize();o=o.div(o.dot(oc(1)));const a=r.yz.mul(i),h=r.zx.mul(i),l=r.xy.mul(i),u=e.value,c=null!==t?t.value:u,d=null!==s?s.value:u,p=Gm(u,a).mul(o.x),m=Gm(c,h).mul(o.y),g=Gm(d,l).mul(o.z);return dd(p,m,g)}}PM.type=Ql("TriplanarTextures",PM);const FM=Wu(PM),zM=(...e)=>FM(...e),UM=new sa,LM=new Ei,OM=new Ei,VM=new Ei,DM=new or,kM=new Ei(0,0,-1),GM=new _i,WM=new Ei,HM=new Ei,jM=new _i,qM=new Qs,$M=new wi,XM=Zy.flipX();let YM=!1;class JM extends km{constructor(e={}){super($M.texture,XM);const{target:t=new Pr,resolution:s=1,generateMipmaps:i=!1,bounces:r=!0}=e;this.target=t,this.resolution=s,this.generateMipmaps=i,this.bounces=r,this.updateBeforeType=r?Hl.RENDER:Hl.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new WeakMap}_updateResolution(e,t){const s=this.resolution;t.getDrawingBufferSize(qM),e.setSize(Math.round(qM.width*s),Math.round(qM.height*s))}setup(e){return this._updateResolution($M,e.renderer),super.setup(e)}getTextureNode(){return this.textureNode}getVirtualCamera(e){let t=this.virtualCameras.get(e);return void 0===t&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return void 0===t&&(t=new wi(0,0,{type:Pe}),!0===this.generateMipmaps&&(t.texture.minFilter=1008,t.texture.generateMipmaps=!0),this.renderTargets.set(e,t)),t}updateBefore(e){if(!1===this.bounces&&YM)return!1;YM=!0;const{scene:t,camera:s,renderer:i,material:r}=e,{target:n}=this,o=this.getVirtualCamera(s),a=this.getRenderTarget(o);if(i.getDrawingBufferSize(qM),this._updateResolution(a,i),OM.setFromMatrixPosition(n.matrixWorld),VM.setFromMatrixPosition(s.matrixWorld),DM.extractRotation(n.matrixWorld),LM.set(0,0,1),LM.applyMatrix4(DM),WM.subVectors(OM,VM),WM.dot(LM)>0)return;WM.reflect(LM).negate(),WM.add(OM),DM.extractRotation(s.matrixWorld),kM.set(0,0,-1),kM.applyMatrix4(DM),kM.add(VM),HM.subVectors(OM,kM),HM.reflect(LM).negate(),HM.add(OM),o.coordinateSystem=s.coordinateSystem,o.position.copy(WM),o.up.set(0,1,0),o.up.applyMatrix4(DM),o.up.reflect(LM),o.lookAt(HM),o.near=s.near,o.far=s.far,o.updateMatrixWorld(),o.projectionMatrix.copy(s.projectionMatrix),UM.setFromNormalAndCoplanarPoint(LM,OM),UM.applyMatrix4(o.matrixWorldInverse),GM.set(UM.normal.x,UM.normal.y,UM.normal.z,UM.constant);const h=o.projectionMatrix;jM.x=(Math.sign(GM.x)+h.elements[8])/h.elements[0],jM.y=(Math.sign(GM.y)+h.elements[9])/h.elements[5],jM.z=-1,jM.w=(1+h.elements[10])/h.elements[14],GM.multiplyScalar(1/GM.dot(jM));h.elements[2]=GM.x,h.elements[6]=GM.y,h.elements[10]=GM.z-0,h.elements[14]=GM.w,this.value=a.texture,r.visible=!1;const l=i.getRenderTarget(),u=i.getMRT();i.setMRT(null),i.setRenderTarget(a),i.render(t,o),i.setMRT(u),i.setRenderTarget(l),r.visible=!0,YM=!1}}const ZM=e=>Du(new JM(e));JM.type=Ql("Reflector",JM);const KM=new OT(-1,1,1,-1,0,1);class QM extends Mn{constructor(e=!1){super();const t=!1===e?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new yn([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new yn(t,2))}}const eA=new QM;class tA extends Wn{constructor(e=null){super(eA,e),this.camera=KM,this.isQuadMesh=!0}renderAsync(e){return e.renderAsync(this,KM)}render(e){e.render(this,KM)}}const sA=new Qs;class iA extends km{constructor(e,t=null,s=null,i={type:Pe}){const r=new wi(t,s,i);super(r.texture,Um()),this.node=e,this.width=t,this.height=s,this.renderTarget=r,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this.updateMap=new WeakMap,this._rttNode=null,this._quadMesh=new tA(new xx),this.updateBeforeType=Hl.RENDER}get autoSize(){return null===this.width}setup(e){return this._rttNode=this.node.context(e.getSharedContext()),this._quadMesh.material.name="RTT",this._quadMesh.material.needsUpdate=!0,super.setup(e)}setSize(e,t){this.width=e,this.height=t;const s=e*this.pixelRatio,i=t*this.pixelRatio;this.renderTarget.setSize(s,i),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(!1===this.textureNeedsUpdate&&!1===this.autoUpdate)return;if(this.textureNeedsUpdate=!1,!0===this.autoSize){this.pixelRatio=e.getPixelRatio();const t=e.getSize(sA);this.setSize(t.width,t.height)}this._quadMesh.material.fragmentNode=this._rttNode;const t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new km(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}iA.type=Ql("RTT",iA);const rA=(e,...t)=>Du(new iA(Du(e),...t)),nA=(e,...t)=>e.isTextureNode?e:rA(e,...t);class oA extends Fm{constructor(e=0){super(null,"vec4"),this.isVertexColorNode=!0,this.index=e}getAttributeName(){const e=this.index;return"color"+(e>0?e:"")}generate(e){const t=this.getAttributeName(e);let s;return s=!0===e.hasGeometryAttribute(t)?super.generate(e):e.generateConst(this.nodeType,new _i(1,1,1,1)),s}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}oA.type=Ql("VertexColor",oA);const aA=(...e)=>Du(new oA(...e));class hA extends Kl{constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}hA.type=Ql("PointUV",hA);const lA=Hu(hA);class uA extends Kl{constructor(e=uA.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,s=null!==this.scene?this.scene:e.scene;let i;return t===uA.BACKGROUND_BLURRINESS?i=Zg("backgroundBlurriness","float",s):t===uA.BACKGROUND_INTENSITY?i=Zg("backgroundIntensity","float",s):console.error("THREE.SceneNode: Unknown scope:",t),i}}uA.BACKGROUND_BLURRINESS="backgroundBlurriness",uA.BACKGROUND_INTENSITY="backgroundIntensity",uA.type=Ql("Scene",uA);const cA=Hu(uA,uA.BACKGROUND_BLURRINESS),dA=Hu(uA,uA.BACKGROUND_INTENSITY),pA="point-list",mA="line-list",gA="line-strip",fA="triangle-list",yA="triangle-strip",xA="never",bA="less",vA="equal",TA="less-equal",_A="greater",wA="not-equal",SA="greater-equal",MA="always",AA="store",NA="load",RA="clear",CA="ccw",EA="none",BA="front",IA="back",PA="uint16",FA="uint32",zA={R8Unorm:"r8unorm",R8Snorm:"r8snorm",R8Uint:"r8uint",R8Sint:"r8sint",R16Uint:"r16uint",R16Sint:"r16sint",R16Float:"r16float",RG8Unorm:"rg8unorm",RG8Snorm:"rg8snorm",RG8Uint:"rg8uint",RG8Sint:"rg8sint",R32Uint:"r32uint",R32Sint:"r32sint",R32Float:"r32float",RG16Uint:"rg16uint",RG16Sint:"rg16sint",RG16Float:"rg16float",RGBA8Unorm:"rgba8unorm",RGBA8UnormSRGB:"rgba8unorm-srgb",RGBA8Snorm:"rgba8snorm",RGBA8Uint:"rgba8uint",RGBA8Sint:"rgba8sint",BGRA8Unorm:"bgra8unorm",BGRA8UnormSRGB:"bgra8unorm-srgb",RGB9E5UFloat:"rgb9e5ufloat",RGB10A2Unorm:"rgb10a2unorm",RG11B10uFloat:"rgb10a2unorm",RG32Uint:"rg32uint",RG32Sint:"rg32sint",RG32Float:"rg32float",RGBA16Uint:"rgba16uint",RGBA16Sint:"rgba16sint",RGBA16Float:"rgba16float",RGBA32Uint:"rgba32uint",RGBA32Sint:"rgba32sint",RGBA32Float:"rgba32float",Stencil8:"stencil8",Depth16Unorm:"depth16unorm",Depth24Plus:"depth24plus",Depth24PlusStencil8:"depth24plus-stencil8",Depth32Float:"depth32float",Depth32FloatStencil8:"depth32float-stencil8",BC1RGBAUnorm:"bc1-rgba-unorm",BC1RGBAUnormSRGB:"bc1-rgba-unorm-srgb",BC2RGBAUnorm:"bc2-rgba-unorm",BC2RGBAUnormSRGB:"bc2-rgba-unorm-srgb",BC3RGBAUnorm:"bc3-rgba-unorm",BC3RGBAUnormSRGB:"bc3-rgba-unorm-srgb",BC4RUnorm:"bc4-r-unorm",BC4RSnorm:"bc4-r-snorm",BC5RGUnorm:"bc5-rg-unorm",BC5RGSnorm:"bc5-rg-snorm",BC6HRGBUFloat:"bc6h-rgb-ufloat",BC6HRGBFloat:"bc6h-rgb-float",BC7RGBAUnorm:"bc7-rgba-unorm",BC7RGBAUnormSRGB:"bc7-rgba-srgb",ETC2RGB8Unorm:"etc2-rgb8unorm",ETC2RGB8UnormSRGB:"etc2-rgb8unorm-srgb",ETC2RGB8A1Unorm:"etc2-rgb8a1unorm",ETC2RGB8A1UnormSRGB:"etc2-rgb8a1unorm-srgb",ETC2RGBA8Unorm:"etc2-rgba8unorm",ETC2RGBA8UnormSRGB:"etc2-rgba8unorm-srgb",EACR11Unorm:"eac-r11unorm",EACR11Snorm:"eac-r11snorm",EACRG11Unorm:"eac-rg11unorm",EACRG11Snorm:"eac-rg11snorm",ASTC4x4Unorm:"astc-4x4-unorm",ASTC4x4UnormSRGB:"astc-4x4-unorm-srgb",ASTC5x4Unorm:"astc-5x4-unorm",ASTC5x4UnormSRGB:"astc-5x4-unorm-srgb",ASTC5x5Unorm:"astc-5x5-unorm",ASTC5x5UnormSRGB:"astc-5x5-unorm-srgb",ASTC6x5Unorm:"astc-6x5-unorm",ASTC6x5UnormSRGB:"astc-6x5-unorm-srgb",ASTC6x6Unorm:"astc-6x6-unorm",ASTC6x6UnormSRGB:"astc-6x6-unorm-srgb",ASTC8x5Unorm:"astc-8x5-unorm",ASTC8x5UnormSRGB:"astc-8x5-unorm-srgb",ASTC8x6Unorm:"astc-8x6-unorm",ASTC8x6UnormSRGB:"astc-8x6-unorm-srgb",ASTC8x8Unorm:"astc-8x8-unorm",ASTC8x8UnormSRGB:"astc-8x8-unorm-srgb",ASTC10x5Unorm:"astc-10x5-unorm",ASTC10x5UnormSRGB:"astc-10x5-unorm-srgb",ASTC10x6Unorm:"astc-10x6-unorm",ASTC10x6UnormSRGB:"astc-10x6-unorm-srgb",ASTC10x8Unorm:"astc-10x8-unorm",ASTC10x8UnormSRGB:"astc-10x8-unorm-srgb",ASTC10x10Unorm:"astc-10x10-unorm",ASTC10x10UnormSRGB:"astc-10x10-unorm-srgb",ASTC12x10Unorm:"astc-12x10-unorm",ASTC12x10UnormSRGB:"astc-12x10-unorm-srgb",ASTC12x12Unorm:"astc-12x12-unorm",ASTC12x12UnormSRGB:"astc-12x12-unorm-srgb"},UA="clamp-to-edge",LA="repeat",OA="mirror-repeat",VA="linear",DA="nearest",kA="zero",GA="one",WA="src",HA="one-minus-src",jA="src-alpha",qA="one-minus-src-alpha",$A="dst",XA="one-minus-dst",YA="dst-alpha",JA="one-minus-dst-alpha",ZA="src-alpha-saturated",KA="constant",QA="one-minus-constant",eN="add",tN="subtract",sN="reverse-subtract",iN="min",rN="max",nN=0,oN=15,aN="keep",hN="zero",lN="replace",uN="invert",cN="increment-clamp",dN="decrement-clamp",pN="increment-wrap",mN="decrement-wrap",gN="storage",fN="read-only-storage",yN="write-only",xN="read-only",bN="float",vN="unfilterable-float",TN="depth",_N="sint",wN="uint",SN="2d",MN="3d",AN="2d",NN="2d-array",RN="cube",CN="3d",EN="all",BN="vertex",IN="instance",PN={DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups"};class FN extends Hg{constructor(e,t,s=0){super(e,t,s),this.isStorageBufferNode=!0,this.access=gN,this.bufferObject=!1,this.bufferCount=s,this._attribute=null,this._varying=null,this.global=!0,!0!==e.isStorageBufferAttribute&&!0!==e.isStorageInstancedBufferAttribute&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(0===this.bufferCount){let t=e.globalCache.getData(this.value);return void 0===t&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return"storageBuffer"}element(e){return IM(this,e)}setBufferObject(e){return this.bufferObject=e,this}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(fN)}generate(e){if(e.isAvailable("storageBuffer"))return super.generate(e);const t=this.getNodeType(e);null===this._attribute&&(this._attribute=mm(this.value),this._varying=em(this._attribute));const s=this._varying.build(e,t);return e.registerTransform(s,this._attribute),s}}FN.type=Ql("StorageBuffer",FN);const zN=(e,t,s)=>Du(new FN(e,t,s)),UN=(e,t,s)=>Du(new FN(e,t,s).setBufferObject(!0));class LN extends km{constructor(e,t,s=null){super(e,t),this.storeNode=s,this.isStorageTextureNode=!0,this.access=yN}getInputType(){return"storageTexture"}setup(e){super.setup(e);e.getNodeProperties(this).storeNode=this.storeNode}setAccess(e){return this.access=e,this}generate(e,t){let s;return s=null!==this.storeNode?this.generateStore(e):super.generate(e,t),s}toReadOnly(){return this.setAccess(xN)}toWriteOnly(){return this.setAccess(yN)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:s,storeNode:i}=t,r=super.generate(e,"property"),n=s.build(e,"uvec2"),o=i.build(e,"vec4"),a=e.generateTextureStore(e,r,n,o);e.addLineFlowCode(a)}}LN.type=Ql("StorageTexture",LN);const ON=Wu(LN),VN=(e,t,s)=>{const i=ON(e,t,s);return null!==s&&i.append(),i};class DN extends Jg{constructor(e,t,s=null){super(e,t,s),this.userData=s}update(e){this.reference=null!==this.userData?this.userData:e.object.userData,super.update(e)}}DN.type=Ql("UserData",DN);const kN=(e,t,s)=>Du(new DN(e,t,s));class GN extends iu{constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}GN.type=Ql("Posterize",GN);const WN=Wu(GN);let HN=null;class jN extends tx{constructor(e=Zy,t=null){null===HN&&(HN=new Xa),super(e,t,HN)}updateReference(){return this}}jN.type=Ql("ViewportSharedTexture",jN);const qN=Wu(jN),$N=new Qs;class XN extends km{constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return e.object.isQuadMesh&&this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}XN.type=Ql("PassTexture",XN);class YN extends XN{constructor(e,t,s=!1){super(e,null),this.textureName=t,this.previousTexture=s}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){return new this.constructor(this.passNode,this.textureName,this.previousTexture)}}YN.type=Ql("PassMultipleTexture",YN);class JN extends iu{constructor(e,t,s,i={}){super("vec4"),this.scope=e,this.scene=t,this.camera=s,this.options=i,this._pixelRatio=1,this._width=1,this._height=1;const r=new Qa;r.isRenderTargetTexture=!0,r.name="depth";const n=new wi(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Pe,...i});n.texture.name="output",n.depthTexture=r,this.renderTarget=n,this.updateBeforeType=Hl.FRAME,this._textures={output:n.texture,depth:r},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=Cc(0),this._cameraFar=Cc(0),this._mrt=null,this.isPassNode=!0}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}isGlobal(){return!0}getTexture(e){let t=this._textures[e];if(void 0===t){t=this.renderTarget.texture.clone(),t.isRenderTargetTexture=!0,t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)}return t}getPreviousTexture(e){let t=this._previousTextures[e];return void 0===t&&(t=this.getTexture(e).clone(),t.isRenderTargetTexture=!0,this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(void 0!==t){const s=this._textures[e],i=this.renderTarget.textures.indexOf(s);this.renderTarget.textures[i]=t,this._textures[e]=t,this._previousTextures[e]=s,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return void 0===t&&(this._textureNodes[e]=t=Du(new YN(this,e)),this._textureNodes[e].updateTexture()),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return void 0===t&&(void 0===this._textureNodes[e]&&this.getTextureNode(e),this._previousTextureNodes[e]=t=Du(new YN(this,e,!0)),this._previousTextureNodes[e].updateTexture()),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(void 0===t){const s=this._cameraNear,i=this._cameraFar;this._viewZNodes[e]=t=cx(this.getTextureNode(e),s,i)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(void 0===t){const s=this._cameraNear,i=this._cameraFar,r=this.getViewZNode(e);this._linearDepthNodes[e]=t=hx(r,s,i)}return t}setup({renderer:e}){return this.renderTarget.samples=void 0===this.options.samples?e.samples:this.options.samples,!0===e.backend.isWebGLBackend&&(this.renderTarget.samples=0),this.renderTarget.depthTexture.isMultisampleRenderTargetTexture=this.renderTarget.samples>1,this.scope===JN.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:s,camera:i}=this;this._pixelRatio=t.getPixelRatio();const r=t.getSize($N);this.setSize(r.width,r.height);const n=t.getRenderTarget(),o=t.getMRT();this._cameraNear.value=i.near,this._cameraFar.value=i.far;for(const e in this._previousTextures)this.toggleTexture(e);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(s,i),t.setRenderTarget(n),t.setMRT(o)}setSize(e,t){this._width=e,this._height=t;const s=this._width*this._pixelRatio,i=this._height*this._pixelRatio;this.renderTarget.setSize(s,i)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}JN.COLOR="color",JN.DEPTH="depth",JN.type=Ql("Pass",JN);const ZN=(e,t,s)=>Du(new JN(JN.COLOR,e,t,s)),KN=(e,t)=>Du(new XN(e,t)),QN=(e,t)=>Du(new JN(JN.DEPTH,e,t)),eR=new tA,tR=new tA;class sR extends iu{constructor(e,t=null,s=2){super("vec4"),this.textureNode=e,this.directionNode=t,this.sigma=s,this._invSize=Cc(new Qs),this._passDirection=Cc(new Qs),this._horizontalRT=new wi,this._horizontalRT.texture.name="GaussianBlurNode.horizontal",this._verticalRT=new wi,this._verticalRT.texture.name="GaussianBlurNode.vertical",this._textureNode=KN(this,this._verticalRT.texture),this.updateBeforeType=Hl.RENDER,this.resolution=new Qs(1,1)}setSize(e,t){e=Math.max(Math.round(e*this.resolution.x),1),t=Math.max(Math.round(t*this.resolution.y),1),this._invSize.value.set(1/e,1/t),this._horizontalRT.setSize(e,t),this._verticalRT.setSize(e,t)}updateBefore(e){const{renderer:t}=e,s=this.textureNode,i=s.value,r=t.getRenderTarget(),n=t.getMRT(),o=s.value;eR.material=this._material,tR.material=this._material,this.setSize(i.image.width,i.image.height);const a=i.type;this._horizontalRT.texture.type=a,this._verticalRT.texture.type=a,t.setMRT(null),t.setRenderTarget(this._horizontalRT),this._passDirection.value.set(1,0),eR.render(t),s.value=this._horizontalRT.texture,t.setRenderTarget(this._verticalRT),this._passDirection.value.set(0,1),tR.render(t),t.setRenderTarget(r),t.setMRT(n),s.value=o}getTextureNode(){return this._textureNode}setup(e){const t=this.textureNode;if(!0!==t.isTextureNode)return console.error("GaussianBlurNode requires a TextureNode."),uc();const s=t.uvNode||Um(),i=sc(this.directionNode||1),r=e=>t.uv(e),n=ju((()=>{const e=3+2*this.sigma,t=this._getCoefficients(e),n=this._invSize,o=i.mul(this._passDirection),a=Ku(t[0]).toVar(),h=uc(r(s).mul(a)).toVar();for(let i=1;iDu(new sR(nA(e),t,s)),rR=new Qs,nR=new tA;class oR extends iu{constructor(e,t=.96){super(e),this.textureNode=e,this.textureNodeOld=Gm(),this.damp=Cc(t),this._compRT=new wi,this._compRT.texture.name="AfterImageNode.comp",this._oldRT=new wi,this._oldRT.texture.name="AfterImageNode.old",this._textureNode=KN(this,this._compRT.texture),this.updateBeforeType=Hl.RENDER}getTextureNode(){return this._textureNode}setSize(e,t){this._compRT.setSize(e,t),this._oldRT.setSize(e,t)}updateBefore(e){const{renderer:t}=e,s=this.textureNode,i=s.value.type;this._compRT.texture.type=i,this._oldRT.texture.type=i,t.getDrawingBufferSize(rR),this.setSize(rR.x,rR.y);const r=t.getRenderTarget(),n=s.value;this.textureNodeOld.value=this._oldRT.texture,t.setRenderTarget(this._compRT),nR.render(t);const o=this._oldRT;this._oldRT=this._compRT,this._compRT=o,t.setRenderTarget(r),s.value=n}setup(e){const t=this.textureNode,s=this.textureNodeOld,i=t.uvNode||Um();s.uvNode=i;const r=ju((([e,t])=>{const s=Ku(t).toVar(),i=uc(e).toVar();return Tp(ap(i.sub(s)),0)})),n=ju((()=>{const e=uc(s),n=uc((e=>t.uv(e))(i));return e.mulAssign(this.damp.mul(r(e,.1))),Tp(n,e)})),o=this._materialComposed||(this._materialComposed=new xx);o.name="AfterImage",o.fragmentNode=n(),nR.material=o;return e.getNodeProperties(this).textureNode=t,this._textureNode}dispose(){this._compRT.dispose(),this._oldRT.dispose()}}const aR=(e,t)=>Du(new oR(nA(e),t)),hR=ju((([e])=>pR(e.rgb))),lR=ju((([e,t=Ku(1)])=>t.mix(pR(e.rgb),e.rgb))),uR=ju((([e,t=Ku(1)])=>{const s=dd(e.r,e.g,e.b).div(3),i=e.r.max(e.g.max(e.b)),r=i.sub(s).mul(t).mul(-3);return Up(e.rgb,i,r)})),cR=ju((([e,t=Ku(1)])=>{const s=oc(.57735,.57735,.57735),i=t.cos();return oc(e.rgb.mul(i).add(s.cross(e.rgb).mul(t.sin()).add(s.mul(Np(s,e.rgb).mul(i.oneMinus())))))})),dR=new Ei,pR=(e,t=oc(...di.getLuminanceCoefficients(dR)))=>Np(e,t),mR=(e,t)=>Up(oc(0),e,pR(e).sub(t).max(0)),gR=new tA;class fR extends iu{constructor(e,t,s,i){super("vec4"),this.textureNode=e,this.tresholdNode=t,this.scaleNode=s,this.colorNode=oc(.1,0,1),this.samples=i,this.resolution=new Qs(1,1),this._renderTarget=new wi,this._renderTarget.texture.name="anamorphic",this._invSize=Cc(new Qs),this._textureNode=KN(this,this._renderTarget.texture),this.updateBeforeType=Hl.RENDER}getTextureNode(){return this._textureNode}setSize(e,t){this._invSize.value.set(1/e,1/t),e=Math.max(Math.round(e*this.resolution.x),1),t=Math.max(Math.round(t*this.resolution.y),1),this._renderTarget.setSize(e,t)}updateBefore(e){const{renderer:t}=e,s=this.textureNode,i=s.value;this._renderTarget.texture.type=i.type;const r=t.getRenderTarget(),n=s.value;gR.material=this._material,this.setSize(i.image.width,i.image.height),t.setRenderTarget(this._renderTarget),gR.render(t),t.setRenderTarget(r),s.value=n}setup(e){const t=this.textureNode,s=t.uvNode||Um(),i=ju((()=>{const e=this.samples,i=Math.floor(e/2),r=oc(0).toVar();return Cy({start:-i,end:i},(({i:e})=>{const n=Ku(e).abs().div(i).oneMinus(),o=(e=>t.uv(e))(sc(s.x.add(this._invSize.x.mul(e).mul(this.scaleNode)),s.y)),a=mR(o,this.tresholdNode).mul(n);r.addAssign(a)})),r.mul(this.colorNode)})),r=this._material||(this._material=new xx);r.name="Anamorphic",r.fragmentNode=i();return e.getNodeProperties(this).textureNode=t,this._textureNode}dispose(){this._renderTarget.dispose()}}const yR=(e,t=.9,s=3,i=32)=>Du(new fR(nA(e),Du(t),Du(s),i));class xR extends iu{constructor(e){super(),this.textureNode=e,this.updateBeforeType=Hl.RENDER,this._invSize=Cc(new Qs)}updateBefore(){const e=this.textureNode.value;this._invSize.value.set(1/e.image.width,1/e.image.height)}setup(){const{textureNode:e}=this,t=e.uvNode||Um(),s=t=>e.uv(t);return ju((()=>{const e=this._invSize,i=gc(-1,-2,-1,0,0,0,1,2,1),r=gc(-1,0,1,-2,0,2,-1,0,1),n=pR(s(t.add(e.mul(sc(-1,-1)))).xyz),o=pR(s(t.add(e.mul(sc(-1,0)))).xyz),a=pR(s(t.add(e.mul(sc(-1,1)))).xyz),h=pR(s(t.add(e.mul(sc(0,-1)))).xyz),l=pR(s(t.add(e.mul(sc(0,0)))).xyz),u=pR(s(t.add(e.mul(sc(0,1)))).xyz),c=pR(s(t.add(e.mul(sc(1,-1)))).xyz),d=pR(s(t.add(e.mul(sc(1,0)))).xyz),p=pR(s(t.add(e.mul(sc(1,1)))).xyz),m=dd(i[0][0].mul(n),i[1][0].mul(h),i[2][0].mul(c),i[0][1].mul(o),i[1][1].mul(l),i[2][1].mul(d),i[0][2].mul(a),i[1][2].mul(u),i[2][2].mul(p)),g=dd(r[0][0].mul(n),r[1][0].mul(h),r[2][0].mul(c),r[0][1].mul(o),r[1][1].mul(l),r[2][1].mul(d),r[0][2].mul(a),r[1][2].mul(u),r[2][2].mul(p)),f=m.mul(m).add(g.mul(g)).sqrt();return uc(oc(f),1)}))()}}xR.type=Ql("SobelOperator",xR);const bR=e=>Du(new xR(nA(e)));class vR extends iu{constructor(e,t,s,i,r){super(),this.textureNode=e,this.viewZNode=t,this.focusNode=s,this.apertureNode=i,this.maxblurNode=r,this._aspect=Cc(0),this.updateBeforeType=Hl.RENDER}updateBefore(){const e=this.textureNode.value;this._aspect.value=e.image.width/e.image.height}setup(){const e=this.textureNode,t=e.uvNode||Um(),s=t=>e.uv(t);return ju((()=>{const e=sc(1,this._aspect),i=this.focusNode.add(this.viewZNode),r=sc(Lp(i.mul(this.apertureNode),this.maxblurNode.negate(),this.maxblurNode)),n=r.mul(.9),o=r.mul(.7),a=r.mul(.4);let h=uc(0);return h=h.add(s(t)),h=h.add(s(t.add(sc(0,.4).mul(e).mul(r)))),h=h.add(s(t.add(sc(.15,.37).mul(e).mul(r)))),h=h.add(s(t.add(sc(.29,.29).mul(e).mul(r)))),h=h.add(s(t.add(sc(-.37,.15).mul(e).mul(r)))),h=h.add(s(t.add(sc(.4,0).mul(e).mul(r)))),h=h.add(s(t.add(sc(.37,-.15).mul(e).mul(r)))),h=h.add(s(t.add(sc(.29,-.29).mul(e).mul(r)))),h=h.add(s(t.add(sc(-.15,-.37).mul(e).mul(r)))),h=h.add(s(t.add(sc(0,-.4).mul(e).mul(r)))),h=h.add(s(t.add(sc(-.15,.37).mul(e).mul(r)))),h=h.add(s(t.add(sc(-.29,.29).mul(e).mul(r)))),h=h.add(s(t.add(sc(.37,.15).mul(e).mul(r)))),h=h.add(s(t.add(sc(-.4,0).mul(e).mul(r)))),h=h.add(s(t.add(sc(-.37,-.15).mul(e).mul(r)))),h=h.add(s(t.add(sc(-.29,-.29).mul(e).mul(r)))),h=h.add(s(t.add(sc(.15,-.37).mul(e).mul(r)))),h=h.add(s(t.add(sc(.15,.37).mul(e).mul(n)))),h=h.add(s(t.add(sc(-.37,.15).mul(e).mul(n)))),h=h.add(s(t.add(sc(.37,-.15).mul(e).mul(n)))),h=h.add(s(t.add(sc(-.15,-.37).mul(e).mul(n)))),h=h.add(s(t.add(sc(-.15,.37).mul(e).mul(n)))),h=h.add(s(t.add(sc(.37,.15).mul(e).mul(n)))),h=h.add(s(t.add(sc(-.37,-.15).mul(e).mul(n)))),h=h.add(s(t.add(sc(.15,-.37).mul(e).mul(n)))),h=h.add(s(t.add(sc(.29,.29).mul(e).mul(o)))),h=h.add(s(t.add(sc(.4,0).mul(e).mul(o)))),h=h.add(s(t.add(sc(.29,-.29).mul(e).mul(o)))),h=h.add(s(t.add(sc(0,-.4).mul(e).mul(o)))),h=h.add(s(t.add(sc(-.29,.29).mul(e).mul(o)))),h=h.add(s(t.add(sc(-.4,0).mul(e).mul(o)))),h=h.add(s(t.add(sc(-.29,-.29).mul(e).mul(o)))),h=h.add(s(t.add(sc(0,.4).mul(e).mul(o)))),h=h.add(s(t.add(sc(.29,.29).mul(e).mul(a)))),h=h.add(s(t.add(sc(.4,0).mul(e).mul(a)))),h=h.add(s(t.add(sc(.29,-.29).mul(e).mul(a)))),h=h.add(s(t.add(sc(0,-.4).mul(e).mul(a)))),h=h.add(s(t.add(sc(-.29,.29).mul(e).mul(a)))),h=h.add(s(t.add(sc(-.4,0).mul(e).mul(a)))),h=h.add(s(t.add(sc(-.29,-.29).mul(e).mul(a)))),h=h.add(s(t.add(sc(0,.4).mul(e).mul(a)))),h=h.div(41),h.a=1,uc(h)}))()}}vR.type=Ql("DepthOfField",vR);const TR=(e,t,s=1,i=.025,r=1)=>Du(new vR(nA(e),Du(t),Du(s),Du(i),Du(r)));class _R extends iu{constructor(e,t=new Qs(.5,.5),s=1.57,i=1){super("vec4"),this.inputNode=e,this.center=Cc(t),this.angle=Cc(s),this.scale=Cc(i)}setup(){const e=this.inputNode,t=ju((()=>{const e=ep(this.angle),t=tp(this.angle),s=Um().mul(Yy).sub(this.center),i=sc(t.mul(s.x).sub(e.mul(s.y)),e.mul(s.x).add(t.mul(s.y))).mul(this.scale);return ep(i.x).mul(ep(i.y)).mul(4)})),s=ju((()=>{const s=e,i=dd(s.r,s.g,s.b).div(3);return uc(oc(i.mul(10).sub(5).add(t())),s.a)}));return s()}}_R.type=Ql("DotScreen",_R);const wR=(e,t,s,i)=>Du(new _R(Du(e),t,s,i));class SR extends iu{constructor(e,t=.005,s=0){super("vec4"),this.textureNode=e,this.amount=Cc(t),this.angle=Cc(s)}setup(){const{textureNode:e}=this,t=e.uvNode||Um(),s=t=>e.uv(t);return ju((()=>{const e=sc(tp(this.angle),ep(this.angle)).mul(this.amount),i=s(t.add(e)),r=s(t),n=s(t.sub(e));return uc(i.r,r.g,n.b,r.a)}))()}}SR.type=Ql("RGBShift",SR);const MR=(e,t,s)=>Du(new SR(nA(e),t,s));class AR extends iu{constructor(e,t=null,s=null){super(),this.inputNode=e,this.intensityNode=t,this.uvNode=s}setup(){const e=this.uvNode||Um(),t=ju((()=>{const t=this.inputNode.rgb,s=Gp(Qd(e.add(vM())));let i=t.add(t.mul(Lp(s.add(.1),0,1)));return null!==this.intensityNode&&(i=Up(t,i,this.intensityNode)),uc(i,this.inputNode.a)}));return t()}}AR.type=Ql("Film",AR);const NR=Wu(AR);class RR extends iu{constructor(e,t,s,i){super(),this.inputNode=e,this.lutNode=t,this.size=Cc(s),this.intensityNode=i}setup(){const{inputNode:e,lutNode:t}=this,s=ju((()=>{const s=e,i=Ku(1).div(this.size),r=Ku(.5).div(this.size),n=oc(r).add(s.rgb.mul(Ku(1).sub(i))),o=uc((e=>t.uv(e))(n).rgb,s.a);return uc(Up(s,o,this.intensityNode))}));return s()}}RR.type=Ql("Lut3D",RR);const CR=(e,t,s,i)=>Du(new RR(Du(e),Du(t),s,Du(i))),ER=new tA,BR=new Yr,IR=new Qs;class PR extends iu{constructor(e,t,s){super(),this.depthNode=e,this.normalNode=t,this.radius=Cc(.25),this.resolution=Cc(new Qs),this.thickness=Cc(1),this.distanceExponent=Cc(1),this.distanceFallOff=Cc(1),this.scale=Cc(1),this.noiseNode=Gm(function(e=5){const t=Math.floor(e)%2==0?Math.floor(e)+1:Math.floor(e),s=function(e){const t=Math.floor(e)%2==0?Math.floor(e)+1:Math.floor(e),s=t*t,i=Array(s).fill(0);let r=Math.floor(t/2),n=t-1;for(let e=1;e<=s;)-1===r&&n===t?(n=t-2,r=0):(n===t&&(n=0),r<0&&(r=t-1)),0===i[r*t+n]?(i[r*t+n]=e++,n++,r--):(n-=2,r++);return i}(t),i=s.length,r=new Uint8Array(4*i);for(let e=0;ethis.depthNode.uv(e).x,i=e=>this.noiseNode.uv(e),r=ju((([e])=>{const t=this.cameraProjectionMatrix.mul(uc(e,1));let i=t.xy.div(t.w).mul(.5).add(.5).toVar();i=sc(i.x,i.y.oneMinus());const r=s(i);return oc(i,r)})),n=ju((([e,t])=>{e=sc(e.x,e.y.oneMinus()).mul(2).sub(1);const s=uc(oc(e,t),1),i=uc(this.cameraProjectionMatrixInverse.mul(s));return i.xyz.div(i.w)})),o=ju((()=>{const e=s(t);e.greaterThanEqual(1).discard();const o=n(t,e),a=this.normalNode.rgb.normalize(),h=this.radius,l=Om(this.noiseNode,0);let u=sc(t.x,t.y.oneMinus());u=u.mul(this.resolution.div(l));const c=i(u),d=c.xyz.mul(2).sub(1),p=oc(d.xy,0).normalize(),m=oc(p.y.mul(-1),p.x,0),g=gc(p,m,oc(0,0,1)),f=this.SAMPLES.lessThan(30).select(3,5),y=dd(this.SAMPLES,f.sub(1)).div(f),x=Ku(0).toVar();return Cy({start:Qu(0),end:f,type:"int",condition:"<"},(({i:e})=>{const t=Ku(e).div(Ku(f)).mul(Ld),s=uc(tp(t),ep(t),0,dd(.5,md(.5,c.w)));s.xyz=Kd(g.mul(s.xyz));const i=Kd(o.xyz.negate()),l=Kd(Rp(s.xyz,i)),u=Rp(l,i),d=Kd(a.sub(l.mul(Np(a,l)))),p=Rp(d,l),m=sc(Np(i,p),Np(i,p.negate())).toVar();Cy({end:y,type:"int",name:"j",condition:"<"},(({j:e})=>{const t=s.xyz.mul(h).mul(s.w).mul(Cp(gd(Ku(e).add(1),Ku(y)),this.distanceExponent)),a=r(o.add(t)),l=n(a.xy,a.z).sub(o);Yu(op(l.z).lessThan(this.thickness),(()=>{const t=Np(i,Kd(l));m.x.addAssign(Tp(0,md(t.sub(m.x),Up(1,Ku(2).div(Ku(e).add(2)),this.distanceFallOff))))}));const u=r(o.sub(t)),c=n(u.xy,u.z).sub(o);Yu(op(c.z).lessThan(this.thickness),(()=>{const t=Np(i,Kd(c));m.y.addAssign(Tp(0,md(t.sub(m.y),Up(1,Ku(2).div(Ku(e).add(2)),this.distanceFallOff))))}))}));const b=Xd(pd(1,m.mul(m))),v=Np(d,u),T=Np(d,i),_=md(.5,rp(m.y).sub(rp(m.x)).add(b.x.mul(m.x).sub(b.y.mul(m.y)))),w=md(.5,pd(2,m.x.mul(m.x)).sub(m.y.mul(m.y))),S=v.mul(_).add(T.mul(w));x.addAssign(S)})),x.assign(Lp(x.div(f),0,1)),x.assign(Cp(x,this.scale)),uc(oc(x),1)})),a=this._material||(this._material=new xx);return a.fragmentNode=o().context(e.getSharedContext()),a.name="GTAO",a.needsUpdate=!0,this._textureNode}dispose(){this._aoRenderTarget.dispose()}}PR.type=Ql("GTAO",PR);const FR=(e,t,s)=>Du(new PR(Du(e),Du(t),s));class zR extends iu{constructor(e,t,s,i,r){super(),this.textureNode=e,this.depthNode=t,this.normalNode=s,this.noiseNode=i,this.cameraProjectionMatrixInverse=Cc(r.projectionMatrixInverse),this.lumaPhi=Cc(5),this.depthPhi=Cc(5),this.normalPhi=Cc(5),this.radius=Cc(5),this.index=Cc(0),this._resolution=Cc(new Qs),this._sampleVectors=Xg(function(e,t,s){const i=function(e,t,s){const i=[];for(let r=0;rthis.textureNode.uv(e),s=e=>this.depthNode.uv(e).x,i=e=>this.normalNode.uv(e),r=e=>this.noiseNode.uv(e),n=ju((([e,t])=>{e=sc(e.x,e.y.oneMinus()).mul(2).sub(1);const s=uc(oc(e,t),1),i=uc(this.cameraProjectionMatrixInverse.mul(s));return i.xyz.div(i.w)})),o=ju((([e,r,o,a])=>{const h=t(a),l=s(a),u=i(a).rgb.normalize(),c=h.rgb,d=n(a,l),p=Np(r,u).toVar(),m=Cp(Tp(p,0),this.normalPhi).toVar(),g=op(pR(c).sub(pR(e))).toVar(),f=Tp(Ku(1).sub(g.div(this.lumaPhi)),0).toVar(),y=op(Np(o.sub(d),r)).toVar(),x=Tp(Ku(1).sub(y.div(this.depthPhi)),0),b=f.mul(x).mul(m);return uc(c.mul(b),b)})),a=ju((([e])=>{const a=s(e),h=i(e).rgb.normalize(),l=t(e);Yu(a.greaterThanEqual(1).or(Np(h,h).equal(0)),(()=>l));const u=oc(l.rgb),c=n(e,a),d=Om(this.noiseNode,0);let p=sc(e.x,e.y.oneMinus());p=p.mul(this._resolution.div(d));const m=r(p),g=ep(m.element(this.index.mod(4).mul(2).mul(Ld))),f=tp(m.element(this.index.mod(4).mul(2).mul(Ld))),y=sc(g,f),x=mc(y.x,y.y.negate(),y.x,y.y),b=Ku(1).toVar(),v=oc(l.rgb).toVar();return Cy({start:Qu(0),end:Qu(16),type:"int",condition:"<"},(({i:t})=>{const s=this._sampleVectors.element(t).toVar(),i=x.mul(s.xy.mul(Ku(1).add(s.z.mul(this.radius.sub(1))))).div(this._resolution).toVar(),r=e.add(i).toVar(),n=o(u,h,c,r);v.addAssign(n.xyz),b.addAssign(n.w)})),Yu(b.greaterThan(Ku(0)),(()=>{v.divAssign(b)})),uc(v,l.a)})).setLayout({name:"denoise",type:"vec4",inputs:[{name:"uv",type:"vec2"}]});return ju((()=>a(e)))()}}zR.type=Ql("Denoise",zR);const UR=(e,t,s,i,r)=>Du(new zR(nA(e),Du(t),Du(s),Du(i),r));class LR extends iu{constructor(e){super(),this.textureNode=e,this.updateBeforeType=Hl.RENDER,this._invSize=Cc(new Qs)}updateBefore(){const e=this.textureNode.value;this._invSize.value.set(1/e.image.width,1/e.image.height)}setup(){const e=this.textureNode.bias(-100),t=e.uvNode||Um(),s=t=>e.uv(t),i=(t,s,i)=>e.uv(t.add(s.mul(i))),r=Qu(5),n=ju((([e,t])=>{const s=uc(t).toVar(),i=uc(e).toVar(),r=uc(op(i.sub(s))).toVar();return Tp(Tp(Tp(r.r,r.g),r.b),r.a)})),o=ju((([e,t,o,a])=>{const h=s(e).toVar(),l=i(e,sc(0,-1),t.xy).toVar(),u=i(e,sc(1,0),t.xy).toVar(),c=i(e,sc(0,1),t.xy).toVar(),d=i(e,sc(-1,0),t.xy).toVar(),p=n(h,c).toVar(),m=n(h,l).toVar(),g=n(h,u).toVar(),f=n(h,d).toVar(),y=Tp(p,Tp(m,Tp(g,f))).toVar();Yu(y.lessThan(o),(()=>h));const x=pd(p.add(m),g.add(f)).toVar();x.mulAssign(a),Yu(op(x).lessThan(.3),(()=>{const s=g.greaterThan(f).select(1,-1).toVar(),r=m.greaterThan(p).select(1,-1).toVar(),o=sc(s,r).toVar(),y=i(e,sc(o.x,o.y),t.xy),b=n(h,y).toVar(),v=i(e,sc(o.x.negate(),o.y.negate()),t.xy),T=n(h,v).toVar();x.assign(T.sub(b)),x.mulAssign(a),Yu(op(x).lessThan(.3),(()=>{const e=c.add(l).add(u).add(d);return Up(h,e.mul(.25),.4)}))}));const b=sc().toVar();Yu(x.lessThanEqual(0),(()=>{c.assign(d),l.assign(u),b.x.assign(0),b.y.assign(t.y)})).Else((()=>{b.x.assign(t.x),b.y.assign(0)}));const v=n(h,c).toVar(),T=n(h,l).toVar();Yu(v.lessThanEqual(T),(()=>{c.assign(l)}));const _=Qu(0).toVar(),w=Qu(0).toVar(),S=Ku(0).toVar(),M=Ku(0).toVar(),A=sc(e).toVar(),N=sc(e).toVar(),R=Qu(0).toVar(),C=Qu(0).toVar();Cy(r,(({i:t})=>{const i=t.add(1).toVar();Yu(_.equal(0),(()=>{S.addAssign(i),A.assign(e.add(b.mul(S)));const r=s(A.xy),o=n(r,h).toVar(),a=n(r,c).toVar();Yu(o.greaterThan(a),(()=>{_.assign(1)})),R.assign(t)})),Yu(w.equal(0),(()=>{M.addAssign(i),N.assign(e.sub(b.mul(M)));const r=s(N.xy),o=n(r,h).toVar(),a=n(r,c).toVar();Yu(o.greaterThan(a),(()=>{w.assign(1)})),C.assign(t)})),Yu(_.equal(1).or(w.equal(1)),(()=>{By()}))})),Yu(_.equal(0).and(w.equal(0)),(()=>h));const E=Ku(1).toVar(),B=Ku(1).toVar();Yu(_.equal(1),(()=>{E.assign(Ku(R).div(Ku(r.sub(1))))})),Yu(w.equal(1),(()=>{B.assign(Ku(C).div(Ku(r.sub(1))))}));const I=vp(E,B);return I.assign(Cp(I,.5)),I.assign(Ku(1).sub(I)),Up(h,c,I.mul(.5))})).setLayout({name:"FxaaPixelShader",type:"vec4",inputs:[{name:"uv",type:"vec2"},{name:"fxaaQualityRcpFrame",type:"vec2"},{name:"fxaaQualityEdgeThreshold",type:"float"},{name:"fxaaQualityinvEdgeThreshold",type:"float"}]});return ju((()=>{const e=Ku(.2),s=Ku(1).div(e);return o(t,this._invSize,e,s)}))()}}LR.type=Ql("FXAA",LR);const OR=e=>Du(new LR(nA(e))),VR=new tA,DR=new Yr(0,0,0),kR=new Yr,GR=new Qs,WR=new Qs(1,0),HR=new Qs(0,1);class jR extends iu{constructor(e,t=1,s=0,i=0){super(),this.inputNode=e,this.strength=Cc(t),this.radius=Cc(s),this.threshold=Cc(i),this.smoothWidth=Cc(.01),this._renderTargetsHorizontal=[],this._renderTargetsVertical=[],this._nMips=5,this._renderTargetBright=new wi(1,1,{type:Pe}),this._renderTargetBright.texture.name="UnrealBloomPass.bright",this._renderTargetBright.texture.generateMipmaps=!1;for(let e=0;e{const e=this.inputNode,t=pR(e.rgb),s=Dp(this.threshold,this.threshold.add(this.smoothWidth),t);return Up(uc(0),e,s)}));this._highPassFilterMaterial=this._highPassFilterMaterial||new xx,this._highPassFilterMaterial.fragmentNode=t().context(e.getSharedContext()),this._highPassFilterMaterial.name="Bloom_highPass",this._highPassFilterMaterial.needsUpdate=!0;const s=[3,5,7,9,11];for(let t=0;t{const s=Ku(1.2).sub(e);return Up(e,s,t)})).setLayout({name:"lerpBloomFactor",type:"float",inputs:[{name:"factor",type:"float"},{name:"radius",type:"float"}]}),o=ju((()=>{const e=n(i.element(0),this.radius).mul(uc(r.element(0),1)).mul(this._textureNodeBlur0),t=n(i.element(1),this.radius).mul(uc(r.element(1),1)).mul(this._textureNodeBlur1),s=n(i.element(2),this.radius).mul(uc(r.element(2),1)).mul(this._textureNodeBlur2),o=n(i.element(3),this.radius).mul(uc(r.element(3),1)).mul(this._textureNodeBlur3),a=n(i.element(4),this.radius).mul(uc(r.element(4),1)).mul(this._textureNodeBlur4);return e.add(t).add(s).add(o).add(a).mul(this.strength)}));return this._compositeMaterial=this._compositeMaterial||new xx,this._compositeMaterial.fragmentNode=o().context(e.getSharedContext()),this._compositeMaterial.name="Bloom_comp",this._compositeMaterial.needsUpdate=!0,this._textureOutput}dispose(){for(let e=0;ei.uv(e),l=ju((()=>{const e=r.element(0).toVar(),s=h(a).rgb.mul(e).toVar();return Cy({start:Qu(1),end:Qu(t),type:"int",condition:"<"},(({i:t})=>{const i=Ku(t),l=r.element(t),u=o.mul(n).mul(i),c=h(a.add(u)).rgb,d=h(a.sub(u)).rgb;s.addAssign(dd(c,d).mul(l)),e.addAssign(Ku(2).mul(l))})),uc(s.div(e),1)})),u=new xx;return u.fragmentNode=l().context(e.getSharedContext()),u.name="Bloom_seperable",u.needsUpdate=!0,u.colorTexture=i,u.direction=o,u.invSize=n,u}}const qR=(e,t,s,i)=>Du(new jR(Du(e),t,s,i));class $R extends iu{constructor(e,t,s,i,r,n){super(),this.textureNodeA=e,this.textureNodeB=t,this.mixTextureNode=s,this.mixRatioNode=i,this.thresholdNode=r,this.useTextureNode=n}setup(){const{textureNodeA:e,textureNodeB:t,mixTextureNode:s,mixRatioNode:i,thresholdNode:r,useTextureNode:n}=this,o=e=>{const t=e.uvNode||Um();return e.uv(t)},a=ju((()=>{const a=o(e),h=o(t),l=uc().toVar();return Yu(n.equal(Qu(1)),(()=>{const e=o(s),t=i.mul(r.mul(2).add(1)).sub(r),n=Lp(pd(e.r,t).mul(Ku(1).div(r)),0,1);l.assign(Up(a,h,n))})).Else((()=>{l.assign(Up(h,a,i))})),l}));return a()}}$R.type=Ql("Transition",$R);const XR=(e,t,s,i=0,r=.1,n=0)=>Du(new $R(nA(e),nA(t),nA(s),Du(i),Du(r),Du(n)));class YR extends iu{constructor(e,t,s,i,r,n){super(),this.textureNode=e,this.depthNode=t,this.normalNode=s,this.pixelSize=i,this.normalEdgeStrength=r,this.depthEdgeStrength=n,this._resolution=Cc(new _i),this.updateBeforeType=Hl.RENDER}updateBefore(){const e=this.textureNode.value,t=e.image.width,s=e.image.height;this._resolution.value.set(t,s,1/t,1/s)}setup(){const{textureNode:e,depthNode:t,normalNode:s}=this,i=e.uvNode||Um(),r=t.uvNode||Um(),n=s.uvNode||Um(),o=(e,s)=>t.uv(r.add(sc(e,s).mul(this._resolution.zw))).r,a=(e,t)=>s.uv(n.add(sc(e,t).mul(this._resolution.zw))).rgb.normalize(),h=(e,t,s,i)=>{const r=o(e,t).sub(s),n=a(e,t),h=oc(1,1,1),l=Np(i.sub(n),h),u=Lp(Dp(-.01,.01,l),0,1),c=Lp(ap(r.mul(.25).add(.0025)),0,1);return Ku(1).sub(Np(i,n)).mul(c).mul(u)},l=ju((()=>{const t=e.uv(i),s=Bc("float","depth"),r=Bc("vec3","normal");Yu(this.depthEdgeStrength.greaterThan(0).or(this.normalEdgeStrength.greaterThan(0)),(()=>{s.assign(o(0,0)),r.assign(a(0,0))}));const n=Bc("float","dei");Yu(this.depthEdgeStrength.greaterThan(0),(()=>{n.assign((e=>{const t=Bc("float","diff");return t.addAssign(Lp(o(1,0).sub(e))),t.addAssign(Lp(o(-1,0).sub(e))),t.addAssign(Lp(o(0,1).sub(e))),t.addAssign(Lp(o(0,-1).sub(e))),Jd(Dp(.01,.02,t).mul(2)).div(2)})(s))}));const l=Bc("float","nei");Yu(this.normalEdgeStrength.greaterThan(0),(()=>{l.assign(((e,t)=>{const s=Bc("float","indicator");return s.addAssign(h(0,-1,e,t)),s.addAssign(h(0,1,e,t)),s.addAssign(h(-1,0,e,t)),s.addAssign(h(1,0,e,t)),wp(.1,s)})(s,r))}));const u=n.greaterThan(0).select(Ku(1).sub(n.mul(this.depthEdgeStrength)),l.mul(this.normalEdgeStrength).add(1));return t.mul(u)}));return l()}}YR.type=Ql("Pixelation",YR);class JR extends JN{constructor(e,t,s=6,i=.3,r=.4){super("color",e,t,{minFilter:fe,magFilter:fe}),this.pixelSize=s,this.normalEdgeStrength=i,this.depthEdgeStrength=r,this.isPixelationPassNode=!0,this._mrt=gM({output:Zc,normal:Ig})}setSize(e,t){const s=this.pixelSize.value?this.pixelSize.value:this.pixelSize,i=Math.floor(e/s),r=Math.floor(t/s);super.setSize(i,r)}setup(){return((e,t,s,i=6,r=.3,n=.4)=>Du(new YR(nA(e),nA(t),nA(s),Du(i),Du(r),Du(n))))(super.getTextureNode("output"),super.getTextureNode("depth"),super.getTextureNode("normal"),this.pixelSize,this.normalEdgeStrength,this.depthEdgeStrength)}}const ZR=(e,t,s,i,r)=>Du(new JR(e,t,s,i,r));JR.type=Ql("PixelationPass",JR);const KR=new Qs;class QR extends JN{constructor(e,t){super(JN.COLOR,e,t),this.isSSAAPassNode=!0,this.sampleLevel=4,this.unbiased=!0,this.clearColor=new Yr(0),this.clearAlpha=0,this._currentClearColor=new Yr,this.sampleWeight=Cc(1),this.sampleRenderTarget=null,this._quadMesh=new tA}updateBefore(e){const{renderer:t}=e,{scene:s,camera:i}=this;this._pixelRatio=t.getPixelRatio();const r=t.getSize(KR);this.setSize(r.width,r.height),this.sampleRenderTarget.setSize(this.renderTarget.width,this.renderTarget.height),t.getClearColor(this._currentClearColor);const n=t.getClearAlpha(),o=t.getRenderTarget(),a=t.getMRT(),h=t.autoClear;this._cameraNear.value=i.near,this._cameraFar.value=i.far,t.setMRT(this.getMRT()),t.autoClear=!1;const l=eC[Math.max(0,Math.min(this.sampleLevel,5))],u=1/l.length,c={fullWidth:this.renderTarget.width,fullHeight:this.renderTarget.height,offsetX:0,offsetY:0,width:this.renderTarget.width,height:this.renderTarget.height},d=Object.assign({},i.view);d.enabled&&Object.assign(c,d);for(let e=0;e=0&&(e[t]=Gm(this.sampleRenderTarget.textures[s]).mul(this.sampleWeight))}t=gM(e)}else t=Gm(this.sampleRenderTarget.texture).mul(this.sampleWeight);return this._quadMesh.material=new xx,this._quadMesh.material.fragmentNode=t,this._quadMesh.material.transparent=!0,this._quadMesh.material.depthTest=!1,this._quadMesh.material.depthWrite=!1,this._quadMesh.material.premultipliedAlpha=!0,this._quadMesh.material.blending=2,this._quadMesh.material.normals=!1,this._quadMesh.material.name="SSAA",super.setup(e)}dispose(){super.dispose(),null!==this.sampleRenderTarget&&this.sampleRenderTarget.dispose()}}QR.type=Ql("SSAAPass",QR);const eC=[[[0,0]],[[4,4],[-4,-4]],[[-2,-6],[6,-2],[-6,2],[2,6]],[[1,-3],[-1,3],[5,1],[-3,-5],[-5,5],[-7,-1],[3,7],[7,-7]],[[1,1],[-1,-3],[-3,2],[4,-1],[-5,-2],[2,5],[5,3],[3,-5],[-2,6],[0,-7],[-4,-6],[-6,4],[-8,0],[7,-4],[6,7],[-7,-8]],[[-4,-7],[-7,-5],[-3,-5],[-5,-4],[-1,-4],[-2,-2],[-6,-1],[-4,0],[-7,1],[-1,2],[-6,3],[-3,3],[-7,6],[-3,6],[-5,7],[-1,7],[5,-7],[1,-6],[6,-5],[4,-4],[2,-3],[7,-2],[1,-1],[4,-1],[2,1],[6,2],[0,4],[4,4],[2,5],[7,5],[5,6],[3,7]]],tC=(e,t)=>Du(new QR(e,t)),sC=new Qs;class iC extends JN{constructor(e,t){super(JN.COLOR,e,t),this.isStereoPassNode=!0,this.stereo=new o_,this.stereo.aspect=.5}updateBefore(e){const{renderer:t}=e,{scene:s,camera:i,stereo:r,renderTarget:n}=this;this._pixelRatio=t.getPixelRatio(),r.cameraL.coordinateSystem=t.coordinateSystem,r.cameraR.coordinateSystem=t.coordinateSystem,r.update(i);const o=t.getSize(sC);this.setSize(o.width,o.height);const a=t.autoClear;t.autoClear=!1;const h=t.getRenderTarget(),l=t.getMRT();this._cameraNear.value=i.near,this._cameraFar.value=i.far;for(const e in this._previousTextures)this.toggleTexture(e);t.setRenderTarget(n),t.setMRT(this._mrt),t.clear(),n.scissorTest=!0,n.scissor.set(0,0,n.width/2,n.height),n.viewport.set(0,0,n.width/2,n.height),t.render(s,r.cameraL),n.scissor.set(n.width/2,0,n.width/2,n.height),n.viewport.set(n.width/2,0,n.width/2,n.height),t.render(s,r.cameraR),n.scissorTest=!1,t.setRenderTarget(h),t.setMRT(l),t.autoClear=a}}iC.type=Ql("StereoPass",iC);const rC=(e,t)=>Du(new iC(e,t)),nC=new Qs,oC=new tA;class aC extends JN{constructor(e,t){super(JN.COLOR,e,t),this.isStereoCompositePassNode=!0,this.stereo=new o_;const s={minFilter:Te,magFilter:fe,type:Pe};this._renderTargetL=new wi(1,1,s),this._renderTargetR=new wi(1,1,s),this._mapLeft=Gm(this._renderTargetL.texture),this._mapRight=Gm(this._renderTargetR.texture),this._material=null}updateStereoCamera(e){this.stereo.cameraL.coordinateSystem=e,this.stereo.cameraR.coordinateSystem=e,this.stereo.update(this.camera)}setSize(e,t){super.setSize(e,t),this._renderTargetL.setSize(this.renderTarget.width,this.renderTarget.height),this._renderTargetR.setSize(this.renderTarget.width,this.renderTarget.height)}updateBefore(e){const{renderer:t}=e,{scene:s,stereo:i,renderTarget:r}=this;this._pixelRatio=t.getPixelRatio(),this.updateStereoCamera(t.coordinateSystem);const n=t.getSize(nC);this.setSize(n.width,n.height);const o=t.getRenderTarget();t.setRenderTarget(this._renderTargetL),t.render(s,i.cameraL),t.setRenderTarget(this._renderTargetR),t.render(s,i.cameraR),t.setRenderTarget(r),oC.material=this._material,oC.render(t),t.setRenderTarget(o)}dispose(){super.dispose(),this._renderTargetL.dispose(),this._renderTargetR.dispose(),null!==this._material&&this._material.dispose()}}aC.type=Ql("StereoCompositePass",aC);class hC extends aC{constructor(e,t){super(e,t),this.isAnaglyphPassNode=!0,this._colorMatrixLeft=Cc((new ei).fromArray([.4561,-.0400822,-.0152161,.500484,-.0378246,-.0205971,.176381,-.0157589,-.00546856])),this._colorMatrixRight=Cc((new ei).fromArray([-.0434706,.378476,-.0721527,-.0879388,.73364,-.112961,-.00155529,-.0184503,1.2264]))}setup(e){const t=Um(),s=ju((()=>{const e=this._mapLeft.uv(t),s=this._mapRight.uv(t),i=Lp(this._colorMatrixLeft.mul(e.rgb).add(this._colorMatrixRight.mul(s.rgb)));return uc(i.rgb,Tp(e.a,s.a))})),i=this._material||(this._material=new xx);return i.fragmentNode=s().context(e.getSharedContext()),i.name="Anaglyph",i.needsUpdate=!0,super.setup(e)}}const lC=(e,t)=>Du(new hC(e,t));class uC extends aC{constructor(e,t){super(e,t),this.isParallaxBarrierPassNode=!0}setup(e){const t=Um(),s=ju((()=>{const e=uc().toVar();return Yu(_p(Xy.y,2).greaterThan(1),(()=>{e.assign(this._mapLeft.uv(t))})).Else((()=>{e.assign(this._mapRight.uv(t))})),e})),i=this._material||(this._material=new xx);return i.fragmentNode=s().context(e.getSharedContext()),i.needsUpdate=!0,super.setup(e)}}uC.type=Ql("ParallaxBarrierPass",uC);const cC=(e,t)=>Du(new uC(e,t));class dC extends Kl{constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outpuType=null,this.events=new ks,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return null!==this.outputType}set value(e){this._value!==e&&(this._cache&&"URL"===this.inputType&&this.value.value instanceof ArrayBuffer&&(URL.revokeObjectURL(this._cache),this._cache=null),this._value=e,this.events.dispatchEvent({type:"change"}),this.refresh())}get value(){return this._value}refresh(){this.events.dispatchEvent({type:"refresh"})}getValue(){const e=this.value;if(e&&null===this._cache&&"URL"===this.inputType&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&null!==e.value&&void 0!==e.value&&(("URL"===this.inputType||"String"===this.inputType)&&"string"==typeof e.value||"Number"===this.inputType&&"number"==typeof e.value||"Vector2"===this.inputType&&e.value.isVector2||"Vector3"===this.inputType&&e.value.isVector3||"Vector4"===this.inputType&&e.value.isVector4||"Color"===this.inputType&&e.value.isColor||"Matrix3"===this.inputType&&e.value.isMatrix3||"Matrix4"===this.inputType&&e.value.isMatrix4))return e.value;return this._cache||e}getNodeType(e){return this.value&&this.value.isNode?this.value.getNodeType(e):"float"}setup(){return this.value&&this.value.isNode?this.value:Ku()}serialize(e){super.serialize(e),null!==this.value?"ArrayBuffer"===this.inputType?e.value=Dl(this.value):e.value=this.value?this.value.toJSON(e.meta).uuid:null:e.value=null,e.inputType=this.inputType,e.outputType=this.outputType}deserialize(e){super.deserialize(e);let t=null;null!==e.value&&(t="ArrayBuffer"===e.inputType?kl(e.value):"Texture"===e.inputType?e.meta.textures[e.value]:e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}dC.type=Ql("ScriptableValue",dC);const pC=Wu(dC);class mC extends Map{get(e,t=null,...s){if(this.has(e))return super.get(e);if(null!==t){const i=t(...s);return this.set(e,i),i}}}class gC{constructor(e){this.scriptableNode=e}get parameters(){return this.scriptableNode.parameters}get layout(){return this.scriptableNode.getLayout()}getInputLayout(e){return this.scriptableNode.getInputLayout(e)}get(e){const t=this.parameters[e];return t?t.getValue():null}}const fC=new mC;class yC extends Kl{constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new mC,this._output=pC(),this._outputs={},this._source=this.source,this._method=null,this._object=null,this._value=null,this._needsOutputUpdate=!0,this.onRefresh=this.onRefresh.bind(this),this.isScriptableNode=!0}get source(){return this.codeNode?this.codeNode.code:""}setLocal(e,t){return this._local.set(e,t)}getLocal(e){return this._local.get(e)}onRefresh(){this._refresh()}getInputLayout(e){for(const t of this.getLayout())if(t.inputType&&(t.id===e||t.name===e))return t}getOutputLayout(e){for(const t of this.getLayout())if(t.outputType&&(t.id===e||t.name===e))return t}setOutput(e,t){const s=this._outputs;return void 0===s[e]?s[e]=pC(t):s[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const s=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),s[e]=t,s[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),s[e]=t,s[e].events.addEventListener("refresh",this.onRefresh)):void 0===s[e]?(s[e]=pC(t),s[e].events.addEventListener("refresh",this.onRefresh)):s[e].value=t,this}getValue(){return this.getDefaultOutput().getValue()}deleteParameter(e){let t=this.parameters[e];return t&&(t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.removeEventListener("refresh",this.onRefresh)),this}clearParameters(){for(const e of Object.keys(this.parameters))this.deleteParameter(e);return this.needsUpdate=!0,this}call(e,...t){const s=this.getObject()[e];if("function"==typeof s)return s(...t)}async callAsync(e,...t){const s=this.getObject()[e];if("function"==typeof s)return"AsyncFunction"===s.constructor.name?await s(...t):s(...t)}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){null!==e?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),null!==this._object)return this._object;const e=new gC(this),t=fC.get("THREE"),s=fC.get("TSL"),i=this.getMethod(this.codeNode),r=[e,this._local,fC,()=>this.refresh(),(e,t)=>this.setOutput(e,t),t,s];this._object=i(...r);const n=this._object.layout;if(n&&(!1===n.cache&&this._local.clear(),this._output.outputType=n.outputType||null,Array.isArray(n.elements)))for(const e of n.elements){const t=e.id||e.name;e.inputType&&(void 0===this.getParameter(t)&&this.setParameter(t,null),this.getParameter(t).inputType=e.inputType),e.outputType&&(void 0===this.getOutput(t)&&this.setOutput(t,null),this.getOutput(t).outputType=e.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const e in this.parameters){let t=this.parameters[e];t.isScriptableNode&&(t=t.getDefaultOutput()),t.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:Ku()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),null!==this._method)return this._method;const e=["layout","init","main","dispose"].join(", "),t="\nreturn { ...output, "+e+" };",s="var "+e+"; var output = {};\n"+this.codeNode.code+t;return this._method=new Function(...["parameters","local","global","refresh","setOutput","THREE","TSL"],s),this._method}dispose(){null!==this._method&&(this._object&&"function"==typeof this._object.dispose&&this._object.dispose(),this._method=null,this._object=null,this._source=null,this._value=null,this._needsOutputUpdate=!0,this._output.value=null,this._outputs={})}setup(){return this.getDefaultOutputNode()}getCacheKey(e){const t=[this.source,this.getDefaultOutputNode().getCacheKey(e)];for(const s in this.parameters)t.push(this.parameters[s].getCacheKey(e));return t.join(",")}set needsUpdate(e){!0===e&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return null===this.codeNode||(!0===this._needsOutputUpdate&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value),this}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}yC.type=Ql("Scriptable",yC);const xC=Wu(yC);class bC extends Kl{constructor(e,t){super("float"),this.isFogNode=!0,this.colorNode=e,this.factorNode=t}getViewZNode(e){let t;const s=e.context.getViewZ;return void 0!==s&&(t=s(this)),(t||wg.z).negate()}setup(){return this.factorNode}}bC.type=Ql("Fog",bC);const vC=Wu(bC);class TC extends bC{constructor(e,t,s){super(e),this.isFogRangeNode=!0,this.nearNode=t,this.farNode=s}setup(e){const t=this.getViewZNode(e);return Dp(this.nearNode,this.farNode,t)}}TC.type=Ql("FogRange",TC);const _C=Wu(TC);class wC extends bC{constructor(e,t){super(e),this.isFogExp2Node=!0,this.densityNode=t}setup(e){const t=this.getViewZNode(e),s=this.densityNode;return s.mul(s,t,t).negate().exp().oneMinus()}}wC.type=Ql("FogExp2",wC);const SC=Wu(wC);let MC=null,AC=null;class NC extends Kl{constructor(e=Ku(),t=Ku()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(Ol(this.minNode.value)),s=e.getTypeLength(Ol(this.maxNode.value));return t>s?t:s}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let s=null;if(t.count>1){const i=this.minNode.value,r=this.maxNode.value,n=e.getTypeLength(Ol(i)),o=e.getTypeLength(Ol(r));MC=MC||new _i,AC=AC||new _i,MC.setScalar(0),AC.setScalar(0),1===n?MC.setScalar(i):i.isColor?MC.set(i.r,i.g,i.b):MC.set(i.x,i.y,i.z||0,i.w||0),1===o?AC.setScalar(r):r.isColor?AC.set(r.r,r.g,r.b):AC.set(r.x,r.y,r.z||0,r.w||0);const a=4,h=a*t.count,l=new Float32Array(h);for(let e=0;eGm(e,t.xy).compare(t.z))),IC=ju((({depthTexture:e,shadowCoord:t,shadow:s})=>{const i=(t,s)=>Gm(e,t).compare(s),r=Zg("mapSize","vec2",s),n=Zg("radius","float",s),o=sc(1).div(r),a=o.x.negate().mul(n),h=o.y.negate().mul(n),l=o.x.mul(n),u=o.y.mul(n),c=a.div(2),d=h.div(2),p=l.div(2),m=u.div(2);return dd(i(t.xy.add(sc(a,h)),t.z),i(t.xy.add(sc(0,h)),t.z),i(t.xy.add(sc(l,h)),t.z),i(t.xy.add(sc(c,d)),t.z),i(t.xy.add(sc(0,d)),t.z),i(t.xy.add(sc(p,d)),t.z),i(t.xy.add(sc(a,0)),t.z),i(t.xy.add(sc(c,0)),t.z),i(t.xy,t.z),i(t.xy.add(sc(p,0)),t.z),i(t.xy.add(sc(l,0)),t.z),i(t.xy.add(sc(c,m)),t.z),i(t.xy.add(sc(0,m)),t.z),i(t.xy.add(sc(p,m)),t.z),i(t.xy.add(sc(a,u)),t.z),i(t.xy.add(sc(0,u)),t.z),i(t.xy.add(sc(l,u)),t.z)).mul(1/17)})),PC=ju((({depthTexture:e,shadowCoord:t,shadow:s})=>{const i=(t,s)=>Gm(e,t).compare(s),r=Zg("mapSize","vec2",s),n=sc(1).div(r),o=n.x,a=n.y,h=t.xy,l=Qd(h.mul(r).add(.5));return h.subAssign(l.mul(n)),dd(i(h,t.z),i(h.add(sc(o,0)),t.z),i(h.add(sc(0,a)),t.z),i(h.add(n),t.z),Up(i(h.add(sc(o.negate(),0)),t.z),i(h.add(sc(o.mul(2),0)),t.z),l.x),Up(i(h.add(sc(o.negate(),a)),t.z),i(h.add(sc(o.mul(2),a)),t.z),l.x),Up(i(h.add(sc(0,a.negate())),t.z),i(h.add(sc(0,a.mul(2))),t.z),l.y),Up(i(h.add(sc(o,a.negate())),t.z),i(h.add(sc(o,a.mul(2))),t.z),l.y),Up(Up(i(h.add(sc(o.negate(),a.negate())),t.z),i(h.add(sc(o.mul(2),a.negate())),t.z),l.x),Up(i(h.add(sc(o.negate(),a.mul(2))),t.z),i(h.add(sc(o.mul(2),a.mul(2))),t.z),l.x),l.y)).mul(1/9)})),FC=[BC,IC,PC];let zC=null;class UC extends Dy{constructor(e=null){super(),this.updateType=Hl.FRAME,this.light=e,this.color=new Yr,this.colorNode=Cc(this.color),this.baseColorNode=null,this.shadowMap=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0}getCacheKey(){return super.getCacheKey()+"-"+this.light.id+"-"+(this.light.castShadow?"1":"0")}getHash(){return this.light.uuid}setupShadow(e){const{object:t,renderer:s}=e;let i=this.shadowColorNode;if(null===i){null===zC&&(zC=new xx,zC.fragmentNode=uc(0,0,0,1),zC.isShadowNodeMaterial=!0,zC.name="ShadowMaterial");const r=new Qa;r.compareFunction=Ts;const n=this.light.shadow,o=e.createRenderTarget(n.mapSize.width,n.mapSize.height);o.depthTexture=r,n.camera.updateProjectionMatrix();const a=Zg("intensity","float",n),h=Zg("bias","float",n),l=Zg("normalBias","float",n),u=t.material.shadowPositionNode||Tg;let c=Cc(n.matrix).mul(u.add(Pg.mul(l)));c=c.xyz.div(c.w);let d=c.z.add(h);s.coordinateSystem===Ds&&(d=d.mul(2).sub(1)),c=oc(c.x,c.y.oneMinus(),d);const p=c.x.greaterThanEqual(0).and(c.x.lessThanEqual(1)).and(c.y.greaterThanEqual(0)).and(c.y.lessThanEqual(1)).and(c.z.lessThanEqual(1)),m=n.filterNode||FC[s.shadowMap.type]||null;if(null===m)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const g=Gm(o.texture,c),f=p.select(m({depthTexture:r,shadowCoord:c,shadow:n}),Ku(1));this.shadowMap=o,this.shadowNode=f,this.shadowColorNode=i=this.colorNode.mul(Up(1,f.rgb.mix(g,1),a.mul(g.a))),this.baseColorNode=this.colorNode}this.colorNode=i,this.updateBeforeType=Hl.RENDER}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):null!==this.shadowNode&&this.disposeShadow()}updateShadow(e){const{shadowMap:t,light:s}=this,{renderer:i,scene:r,camera:n}=e,o=t.depthTexture.version;this._depthVersionCached=o;const a=r.overrideMaterial;r.overrideMaterial=zC,t.setSize(s.shadow.mapSize.width,s.shadow.mapSize.height),s.shadow.updateMatrices(s),s.shadow.camera.layers.mask=n.layers.mask;const h=i.getRenderTarget(),l=i.getRenderObjectFunction();i.setRenderObjectFunction(((e,...t)=>{!0===e.castShadow&&i.renderObject(e,...t)})),i.setRenderTarget(t),i.render(r,s.shadow.camera),i.setRenderTarget(h),i.setRenderObjectFunction(l),r.overrideMaterial=a}disposeShadow(){this.shadowMap.dispose(),this.shadowMap=null,this.shadowNode=null,this.shadowColorNode=null,this.baseColorNode=null,this.updateBeforeType=Hl.NONE}updateBefore(e){const t=this.light.shadow;(t.needsUpdate||t.autoUpdate)&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}UC.type=Ql("AnalyticLight",UC);const LC=ju((e=>{const{lightDistance:t,cutoffDistance:s,decayExponent:i}=e,r=t.pow(i).max(.01).reciprocal();return s.greaterThan(0).select(r.mul(t.div(s).pow4().oneMinus().clamp().pow2()),r)}));class OC extends UC{constructor(e=null){super(e),this.cutoffDistanceNode=Cc(0),this.decayExponentNode=Cc(0)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setup(e){const{colorNode:t,cutoffDistanceNode:s,decayExponentNode:i,light:r}=this,n=e.context.lightingModel,o=hg(r).sub(wg),a=o.normalize(),h=o.length(),l=LC({lightDistance:h,cutoffDistance:s,decayExponent:i}),u=t.mul(l),c=e.context.reflectedLight;n.direct({lightDirection:a,lightColor:u,reflectedLight:c},e.stack,e)}}OC.type=Ql("PointLight",OC);class VC extends UC{constructor(e=null){super(e)}setup(e){super.setup(e);const t=e.context.lightingModel,s=this.colorNode,i=EC(this.light),r=e.context.reflectedLight;t.direct({lightDirection:i,lightColor:s,reflectedLight:r},e.stack,e)}}VC.type=Ql("DirectionalLight",VC);const DC=new or,kC=new or;let GC=null;class WC extends UC{constructor(e=null){super(e),this.halfHeight=Cc(new Ei),this.halfWidth=Cc(new Ei)}update(e){super.update(e);const{light:t}=this,s=e.camera.matrixWorldInverse;kC.identity(),DC.copy(t.matrixWorld),DC.premultiply(s),kC.extractRotation(DC),this.halfWidth.value.set(.5*t.width,0,0),this.halfHeight.value.set(0,.5*t.height,0),this.halfWidth.value.applyMatrix4(kC),this.halfHeight.value.applyMatrix4(kC)}setup(e){let t,s;super.setup(e),e.isAvailable("float32Filterable")?(t=Gm(GC.LTC_FLOAT_1),s=Gm(GC.LTC_FLOAT_2)):(t=Gm(GC.LTC_HALF_1),s=Gm(GC.LTC_HALF_2));const{colorNode:i,light:r}=this,n=e.context.lightingModel,o=hg(r),a=e.context.reflectedLight;n.directRectArea({lightColor:i,lightPosition:o,halfWidth:this.halfWidth,halfHeight:this.halfHeight,reflectedLight:a,ltc_1:t,ltc_2:s},e.stack,e)}static setLTC(e){GC=e}}WC.type=Ql("RectAreaLight",WC);class HC extends UC{constructor(e=null){super(e),this.coneCosNode=Cc(0),this.penumbraCosNode=Cc(0),this.cutoffDistanceNode=Cc(0),this.decayExponentNode=Cc(0)}update(e){super.update(e);const{light:t}=this;this.coneCosNode.value=Math.cos(t.angle),this.penumbraCosNode.value=Math.cos(t.angle*(1-t.penumbra)),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}getSpotAttenuation(e){const{coneCosNode:t,penumbraCosNode:s}=this;return Dp(t,s,e)}setup(e){super.setup(e);const t=e.context.lightingModel,{colorNode:s,cutoffDistanceNode:i,decayExponentNode:r,light:n}=this,o=hg(n).sub(wg),a=o.normalize(),h=a.dot(EC(n)),l=this.getSpotAttenuation(h),u=o.length(),c=LC({lightDistance:u,cutoffDistance:i,decayExponent:r}),d=s.mul(l).mul(c),p=e.context.reflectedLight;t.direct({lightDirection:a,lightColor:d,reflectedLight:p},e.stack,e)}}HC.type=Ql("SpotLight",HC);class jC extends HC{getSpotAttenuation(e){const t=this.light.iesMap;let s=null;if(t&&!0===t.isTexture){const i=e.acos().mul(1/Math.PI);s=Gm(t,sc(i,0),0).r}else s=super.getSpotAttenuation(e);return s}}jC.type=Ql("IESSpotLight",jC);class qC extends UC{constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}qC.type=Ql("AmbientLight",qC);class $C extends UC{constructor(e=null){super(e),this.lightPositionNode=og(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=Cc(new Yr)}update(e){const{light:t}=this;super.update(e),this.lightPositionNode.object3d=t,this.groundColorNode.value.copy(t.groundColor).multiplyScalar(t.intensity)}setup(e){const{colorNode:t,groundColorNode:s,lightDirectionNode:i}=this,r=Ig.dot(i).mul(.5).add(.5),n=Up(s,t,r);e.context.irradiance.addAssign(n)}}$C.type=Ql("HemisphereLight",$C);class XC extends UC{constructor(e=null){super(e);const t=[];for(let e=0;e<9;e++)t.push(new Ei);this.lightProbe=Xg(t)}update(e){const{light:t}=this;super.update(e);for(let e=0;e<9;e++)this.lightProbe.array[e].copy(t.sh.coefficients[e]).multiplyScalar(t.intensity)}setup(e){const t=YC(Pg,this.lightProbe);e.context.irradiance.addAssign(t)}}XC.type=Ql("LightProbe",XC);const YC=ju((([e,t])=>{const s=e.x,i=e.y,r=e.z,n=t.element(0).mul(.886227);return n.addAssign(t.element(1).mul(1.023328).mul(i)),n.addAssign(t.element(2).mul(1.023328).mul(r)),n.addAssign(t.element(3).mul(1.023328).mul(s)),n.addAssign(t.element(4).mul(.858086).mul(s).mul(i)),n.addAssign(t.element(5).mul(.858086).mul(i).mul(r)),n.addAssign(t.element(6).mul(r.mul(r).mul(.743125).sub(.247708))),n.addAssign(t.element(7).mul(.858086).mul(s).mul(r)),n.addAssign(t.element(8).mul(.429043).mul(md(s,s).sub(md(i,i)))),n}));class JC{parseFunction(){console.warn("Abstract function.")}}class ZC{constructor(e,t,s="",i=""){this.type=e,this.inputs=t,this.name=s,this.precision=i}getCode(){console.warn("Abstract function.")}}ZC.isNodeFunction=!0;const KC=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,QC=/[a-z_0-9]+/gi,eE="#pragma main";class tE extends ZC{constructor(e){const{type:t,inputs:s,name:i,precision:r,inputsCode:n,blockCode:o,headerCode:a}=(e=>{const t=(e=e.trim()).indexOf(eE),s=-1!==t?e.slice(t+12):e,i=s.match(KC);if(null!==i&&5===i.length){const r=i[4],n=[];let o=null;for(;null!==(o=QC.exec(r));)n.push(o);const a=[];let h=0;for(;h0?this.transparent:this.opaque).push(o)}unshift(e,t,s,i,r,n){const o=this.getNextRenderItem(e,t,s,i,r,n);(!0===s.transparent?this.transparent:this.opaque).unshift(o)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}getLightsNode(){return this.lightsNode.fromLights(this.lightsArray)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||iE),this.transparent.length>1&&this.transparent.sort(t||rE)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e>t,h=o.height>>t;let l=e.depthTexture||r[t],u=!1;void 0===l&&(l=new Qa,l.format=e.stencilBuffer?He:We,l.type=e.stencilBuffer?Ue:Be,l.image.width=a,l.image.height=h,r[t]=l),s.width===o.width&&o.height===s.height||(u=!0,l.needsUpdate=!0,l.image.width=a,l.image.height=h),s.width=o.width,s.height=o.height,s.textures=n,s.depthTexture=l,s.depth=e.depthBuffer,s.stencil=e.stencilBuffer,s.renderTarget=e,s.sampleCount!==i&&(u=!0,l.needsUpdate=!0,s.sampleCount=i);const c={sampleCount:i};for(let e=0;e{e.removeEventListener("dispose",t);for(let e=0;e0){const i=e.image;if(void 0===i)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(!1===i.complete)console.warn("THREE.Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const s=[];for(const t of e.images)s.push(t);t.images=s}else t.image=i;void 0!==s.isDefaultTexture&&!0!==s.isDefaultTexture||(r.createTexture(e,t),s.isDefaultTexture=!1,s.generation=e.version),!0===e.source.dataReady&&r.updateTexture(e,t),t.needsMipmaps&&0===e.mipmaps.length&&r.generateMipmaps(e)}}else r.createDefaultTexture(e),s.isDefaultTexture=!0,s.generation=e.version}if(!0!==s.initialized){s.initialized=!0,s.generation=e.version,this.info.memory.textures++;const t=()=>{e.removeEventListener("dispose",t),this._destroyTexture(e),this.info.memory.textures--};e.addEventListener("dispose",t)}s.version=e.version}getSize(e,t=cE){let s=e.images?e.images[0]:e.image;return s?(void 0!==s.image&&(s=s.image),t.width=s.width,t.height=s.height,t.depth=e.isCubeTexture?6:s.depth||1):t.width=t.height=t.depth=1,t}getMipLevels(e,t,s){let i;return i=e.isCompressedTexture?e.mipmaps.length:Math.floor(Math.log2(Math.max(t,s)))+1,i}needsMipmaps(e){return!!this.isEnvironmentTexture(e)||(!0===e.isCompressedTexture||e.minFilter!==fe&&e.minFilter!==Te)}isEnvironmentTexture(e){const t=e.mapping;return t===ue||t===ce||t===he||t===le}_destroyTexture(e){this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e)}}class pE extends Yr{constructor(e,t,s,i=1){super(e,t,s),this.a=i}set(e,t,s,i=1){return this.a=i,super.set(e,t,s)}copy(e){return void 0!==e.a&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}const mE=ju((([e])=>{const t=e.toUint().mul(747796405).add(2891336453),s=t.shiftRight(t.shiftRight(28).add(4)).bitXor(t).mul(277803737);return s.shiftRight(22).bitXor(s).toFloat().mul(1/2**32)})),gE=(e,t)=>Cp(md(4,e.mul(pd(1,e))),t),fE=(e,t)=>e.lessThan(.5)?gE(e.mul(2),t).div(2):pd(1,gE(md(pd(1,e),2),t).div(2)),yE=(e,t,s)=>Cp(gd(Cp(e,t),dd(Cp(e,t),Cp(pd(1,e),s))),1/t),xE=(e,t)=>ep(Ld.mul(t.mul(e).sub(1))).div(Ld.mul(t.mul(e).sub(1))),bE=ju((([e])=>e.fract().sub(.5).abs())).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),vE=ju((([e])=>oc(bE(e.z.add(bE(e.y.mul(1)))),bE(e.z.add(bE(e.x.mul(1)))),bE(e.y.add(bE(e.x.mul(1))))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),TE=ju((([e,t,s])=>{const i=oc(e).toVar(),r=Ku(1.4).toVar(),n=Ku(0).toVar(),o=oc(i).toVar();return Cy({start:Ku(0),end:Ku(3),type:"float",condition:"<="},(()=>{const e=oc(vE(o.mul(2))).toVar();i.addAssign(e.add(s.mul(Ku(.1).mul(t)))),o.mulAssign(1.8),r.mulAssign(1.5),i.mulAssign(1.2);const a=Ku(bE(i.z.add(bE(i.x.add(bE(i.y)))))).toVar();n.addAssign(a.div(r)),o.addAssign(.14)})),n})).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"p",type:"vec3"},{name:"spd",type:"float"},{name:"time",type:"float"}]}),_E=ju((([e,t,s=sc(.5)])=>Uv(e.sub(s),t).add(s))),wE=ju((([e,t,s=sc(.5)])=>{const i=e.sub(s),r=i.dot(i),n=r.mul(r).mul(t);return e.add(i.mul(n))})),SE=ju((({position:e=null,horizontal:t=!0,vertical:s=!1})=>{let i;null!==e?(i=pg.toVar(),i[3][0]=e.x,i[3][1]=e.y,i[3][2]=e.z):i=pg;const r=Zm.mul(i);return Lu(t)&&(r[0][0]=pg[0].length(),r[0][1]=0,r[0][2]=0),Lu(s)&&(r[1][0]=0,r[1][1]=pg[1].length(),r[1][2]=0),r[2][0]=0,r[2][1]=0,r[2][2]=1,Ym.mul(r).mul(bg)})),ME=ju((([e=null])=>{const t=mx();return mx(ox(e)).sub(t).lessThan(0).select(Zy,e)})),AE=new WeakMap;class NE extends iu{constructor(){super("vec2"),this.updateType=Hl.OBJECT,this.updateAfterType=Hl.OBJECT,this.previousProjectionMatrix=Cc(new or),this.previousModelViewMatrix=Cc(new or)}update({camera:e,object:t}){const s=RE(t),i=RE(e);this.previousModelViewMatrix.value.copy(s),this.previousProjectionMatrix.value.copy(i)}updateAfter({camera:e,object:t}){const s=RE(t),i=RE(e);s.copy(t.modelViewMatrix),i.copy(e.projectionMatrix)}setup(){const e=Ym.mul(cg).mul(bg),t=this.previousProjectionMatrix.mul(this.previousModelViewMatrix).mul(vg),s=e.xy.div(e.w),i=t.xy.div(t.w);return pd(s,i)}}function RE(e){let t=AE.get(e);return void 0===t&&(t=new or,AE.set(e,t)),t}NE.type=Ql("Velocity",NE);const CE=Hu(NE),EE=ju((([e,t])=>vp(1,e.oneMinus().div(t)).oneMinus())).setLayout({name:"burnBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),BE=ju((([e,t])=>vp(e.div(t.oneMinus()),1))).setLayout({name:"dodgeBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),IE=ju((([e,t])=>e.oneMinus().mul(t.oneMinus()).oneMinus())).setLayout({name:"screenBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),PE=ju((([e,t])=>Up(e.mul(2).mul(t),e.oneMinus().mul(2).mul(t.oneMinus()).oneMinus(),wp(.5,e)))).setLayout({name:"overlayBlend",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),FE=ju((([e,t,s=Qu(16)])=>{const i=t=>e.uv(t),r=Um(),n=i(r).toVar(),o=Ku(s);return Cy({start:Qu(1),end:s,type:"int",condition:"<="},(({i:e})=>{const s=t.mul(Ku(e).div(o.sub(1)).sub(.5));n.addAssign(i(r.add(s)))})),n.divAssign(o),n})),zE=ju((([e,t=1])=>{const s=e,i=pR(s.rgb),r=oc(i),n=vp(1,Tp(0,Ku(10).mul(i.sub(.45)))),o=r.mul(s.rgb).mul(2),a=Ku(2).mul(r.oneMinus()).mul(s.rgb.oneMinus()).oneMinus(),h=Up(o,a,n),l=s.a.mul(t),u=l.mul(h.rgb);return u.addAssign(s.rgb.mul(l.oneMinus())),uc(u,s.a)})),UE=ju((([e])=>{const t=oc(e);return uc(Np(t,oc(.393,.769,.189)),Np(t,oc(.349,.686,.168)),Np(t,oc(.272,.534,.131)),e.a)})),LE=ju((([e])=>{const t=e.mul(.9478672986).add(.0521327014).pow(2.4),s=e.mul(.0773993808),i=e.lessThanEqual(.04045);return Up(t,s,i)})).setLayout({name:"sRGBToLinear",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),OE=ju((([e])=>{const t=e.pow(.41666).mul(1.055).sub(.055),s=e.mul(12.92),i=e.lessThanEqual(.0031308);return Up(t,s,i)})).setLayout({name:"LinearTosRGB",type:"vec3",inputs:[{name:"color",type:"vec3"}]});var VE=Object.freeze({__proto__:null,LinearTosRGB:OE,sRGBToLinear:LE});const DE=ju((([e,t])=>e.mul(t).clamp())).setLayout({name:"LinearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),kE=ju((([e,t])=>(e=e.mul(t)).div(e.add(1)).clamp())).setLayout({name:"ReinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),GE=ju((([e,t])=>{const s=(e=(e=e.mul(t)).sub(.004).max(0)).mul(e.mul(6.2).add(.5)),i=e.mul(e.mul(6.2).add(1.7)).add(.06);return s.div(i).pow(2.2)})).setLayout({name:"CineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),WE=ju((([e])=>{const t=e.mul(e.add(.0245786)).sub(90537e-9),s=e.mul(e.add(.432951).mul(.983729)).add(.238081);return t.div(s)})),HE=ju((([e,t])=>{const s=gc(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),i=gc(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return e=e.mul(t).div(.6),e=s.mul(e),e=WE(e),(e=i.mul(e)).clamp()})).setLayout({name:"ACESFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),jE=gc(oc(1.6605,-.1246,-.0182),oc(-.5876,1.1329,-.1006),oc(-.0728,-.0083,1.1187)),qE=gc(oc(.6274,.0691,.0164),oc(.3293,.9195,.088),oc(.0433,.0113,.8956)),$E=ju((([e])=>{const t=oc(e).toVar(),s=oc(t.mul(t)).toVar(),i=oc(s.mul(s)).toVar();return Ku(15.5).mul(i.mul(s)).sub(md(40.14,i.mul(t))).add(md(31.96,i).sub(md(6.868,s.mul(t))).add(md(.4298,s).add(md(.1191,t).sub(.00232))))})),XE=ju((([e,t])=>{const s=oc(e).toVar(),i=gc(oc(.856627153315983,.137318972929847,.11189821299995),oc(.0951212405381588,.761241990602591,.0767994186031903),oc(.0482516061458583,.101439036467562,.811302368396859)),r=gc(oc(1.1271005818144368,-.1413297634984383,-.14132976349843826),oc(-.11060664309660323,1.157823702216272,-.11060664309660294),oc(-.016493938717834573,-.016493938717834257,1.2519364065950405)),n=Ku(-12.47393),o=Ku(4.026069);return s.mulAssign(t),s.assign(qE.mul(s)),s.assign(i.mul(s)),s.assign(Tp(s,1e-10)),s.assign($d(s)),s.assign(s.sub(n).div(o.sub(n))),s.assign(Lp(s,0,1)),s.assign($E(s)),s.assign(r.mul(s)),s.assign(Cp(Tp(oc(0),s),oc(2.2))),s.assign(jE.mul(s)),s.assign(Lp(s,0,1)),s})).setLayout({name:"AgXToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),YE=ju((([e,t])=>{const s=Ku(.76),i=Ku(.15);e=e.mul(t);const r=vp(e.r,vp(e.g,e.b)),n=qp(r.lessThan(.08),r.sub(md(6.25,r.mul(r))),.04);e.subAssign(n);const o=Tp(e.r,Tp(e.g,e.b));Yu(o.lessThan(s),(()=>e));const a=pd(1,s),h=pd(1,a.mul(a).div(o.add(a.sub(s))));e.mulAssign(h.div(o));const l=pd(1,gd(1,i.mul(o.sub(h)).add(1)));return Up(e,oc(h),l)})).setLayout({name:"NeutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});var JE=Object.freeze({__proto__:null,ACESFilmicToneMapping:HE,AgXToneMapping:XE,CineonToneMapping:GE,LinearToneMapping:DE,NeutralToneMapping:YE,ReinhardToneMapping:kE});const ZE=ju((([e=t()])=>{const t=e.mul(2),s=t.x.floor(),i=t.y.floor();return s.add(i).mod(2).sign()})),KE=ju((([e,t,s])=>{const i=Ku(s).toVar(),r=Ku(t).toVar(),n=tc(e).toVar();return qp(n,r,i)})).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),QE=ju((([e,t])=>{const s=tc(t).toVar(),i=Ku(e).toVar();return qp(s,i.negate(),i)})).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),eB=ju((([e])=>{const t=Ku(e).toVar();return Qu(Jd(t))})).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),tB=ju((([e,t])=>{const s=Ku(e).toVar();return t.assign(eB(s)),s.sub(Ku(t))})),sB=xM([ju((([e,t,s,i,r,n])=>{const o=Ku(n).toVar(),a=Ku(r).toVar(),h=Ku(i).toVar(),l=Ku(s).toVar(),u=Ku(t).toVar(),c=Ku(e).toVar(),d=Ku(pd(1,a)).toVar();return pd(1,o).mul(c.mul(d).add(u.mul(a))).add(o.mul(l.mul(d).add(h.mul(a))))})).setLayout({name:"mx_bilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"}]}),ju((([e,t,s,i,r,n])=>{const o=Ku(n).toVar(),a=Ku(r).toVar(),h=oc(i).toVar(),l=oc(s).toVar(),u=oc(t).toVar(),c=oc(e).toVar(),d=Ku(pd(1,a)).toVar();return pd(1,o).mul(c.mul(d).add(u.mul(a))).add(o.mul(l.mul(d).add(h.mul(a))))})).setLayout({name:"mx_bilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"}]})]),iB=xM([ju((([e,t,s,i,r,n,o,a,h,l,u])=>{const c=Ku(u).toVar(),d=Ku(l).toVar(),p=Ku(h).toVar(),m=Ku(a).toVar(),g=Ku(o).toVar(),f=Ku(n).toVar(),y=Ku(r).toVar(),x=Ku(i).toVar(),b=Ku(s).toVar(),v=Ku(t).toVar(),T=Ku(e).toVar(),_=Ku(pd(1,p)).toVar(),w=Ku(pd(1,d)).toVar();return Ku(pd(1,c)).toVar().mul(w.mul(T.mul(_).add(v.mul(p))).add(d.mul(b.mul(_).add(x.mul(p))))).add(c.mul(w.mul(y.mul(_).add(f.mul(p))).add(d.mul(g.mul(_).add(m.mul(p))))))})).setLayout({name:"mx_trilerp_0",type:"float",inputs:[{name:"v0",type:"float"},{name:"v1",type:"float"},{name:"v2",type:"float"},{name:"v3",type:"float"},{name:"v4",type:"float"},{name:"v5",type:"float"},{name:"v6",type:"float"},{name:"v7",type:"float"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]}),ju((([e,t,s,i,r,n,o,a,h,l,u])=>{const c=Ku(u).toVar(),d=Ku(l).toVar(),p=Ku(h).toVar(),m=oc(a).toVar(),g=oc(o).toVar(),f=oc(n).toVar(),y=oc(r).toVar(),x=oc(i).toVar(),b=oc(s).toVar(),v=oc(t).toVar(),T=oc(e).toVar(),_=Ku(pd(1,p)).toVar(),w=Ku(pd(1,d)).toVar();return Ku(pd(1,c)).toVar().mul(w.mul(T.mul(_).add(v.mul(p))).add(d.mul(b.mul(_).add(x.mul(p))))).add(c.mul(w.mul(y.mul(_).add(f.mul(p))).add(d.mul(g.mul(_).add(m.mul(p))))))})).setLayout({name:"mx_trilerp_1",type:"vec3",inputs:[{name:"v0",type:"vec3"},{name:"v1",type:"vec3"},{name:"v2",type:"vec3"},{name:"v3",type:"vec3"},{name:"v4",type:"vec3"},{name:"v5",type:"vec3"},{name:"v6",type:"vec3"},{name:"v7",type:"vec3"},{name:"s",type:"float"},{name:"t",type:"float"},{name:"r",type:"float"}]})]),rB=ju((([e,t,s])=>{const i=Ku(s).toVar(),r=Ku(t).toVar(),n=ec(e).toVar(),o=ec(n.bitAnd(ec(7))).toVar(),a=Ku(KE(o.lessThan(ec(4)),r,i)).toVar(),h=Ku(md(2,KE(o.lessThan(ec(4)),i,r))).toVar();return QE(a,tc(o.bitAnd(ec(1)))).add(QE(h,tc(o.bitAnd(ec(2)))))})).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),nB=ju((([e,t,s,i])=>{const r=Ku(i).toVar(),n=Ku(s).toVar(),o=Ku(t).toVar(),a=ec(e).toVar(),h=ec(a.bitAnd(ec(15))).toVar(),l=Ku(KE(h.lessThan(ec(8)),o,n)).toVar(),u=Ku(KE(h.lessThan(ec(4)),n,KE(h.equal(ec(12)).or(h.equal(ec(14))),o,r))).toVar();return QE(l,tc(h.bitAnd(ec(1)))).add(QE(u,tc(h.bitAnd(ec(2)))))})).setLayout({name:"mx_gradient_float_1",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),oB=xM([rB,nB]),aB=ju((([e,t,s])=>{const i=Ku(s).toVar(),r=Ku(t).toVar(),n=hc(e).toVar();return oc(oB(n.x,r,i),oB(n.y,r,i),oB(n.z,r,i))})).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),hB=ju((([e,t,s,i])=>{const r=Ku(i).toVar(),n=Ku(s).toVar(),o=Ku(t).toVar(),a=hc(e).toVar();return oc(oB(a.x,o,n,r),oB(a.y,o,n,r),oB(a.z,o,n,r))})).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]}),lB=xM([aB,hB]),uB=ju((([e])=>{const t=Ku(e).toVar();return md(.6616,t)})).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),cB=ju((([e])=>{const t=Ku(e).toVar();return md(.982,t)})).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),dB=xM([uB,ju((([e])=>{const t=oc(e).toVar();return md(.6616,t)})).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),pB=xM([cB,ju((([e])=>{const t=oc(e).toVar();return md(.982,t)})).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),mB=ju((([e,t])=>{const s=Qu(t).toVar(),i=ec(e).toVar();return i.shiftLeft(s).bitOr(i.shiftRight(Qu(32).sub(s)))})).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),gB=ju((([e,t,s])=>{e.subAssign(s),e.bitXorAssign(mB(s,Qu(4))),s.addAssign(t),t.subAssign(e),t.bitXorAssign(mB(e,Qu(6))),e.addAssign(s),s.subAssign(t),s.bitXorAssign(mB(t,Qu(8))),t.addAssign(e),e.subAssign(s),e.bitXorAssign(mB(s,Qu(16))),s.addAssign(t),t.subAssign(e),t.bitXorAssign(mB(e,Qu(19))),e.addAssign(s),s.subAssign(t),s.bitXorAssign(mB(t,Qu(4))),t.addAssign(e)})),fB=ju((([e,t,s])=>{const i=ec(s).toVar(),r=ec(t).toVar(),n=ec(e).toVar();return i.bitXorAssign(r),i.subAssign(mB(r,Qu(14))),n.bitXorAssign(i),n.subAssign(mB(i,Qu(11))),r.bitXorAssign(n),r.subAssign(mB(n,Qu(25))),i.bitXorAssign(r),i.subAssign(mB(r,Qu(16))),n.bitXorAssign(i),n.subAssign(mB(i,Qu(4))),r.bitXorAssign(n),r.subAssign(mB(n,Qu(14))),i.bitXorAssign(r),i.subAssign(mB(r,Qu(24))),i})).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),yB=ju((([e])=>{const t=ec(e).toVar();return Ku(t).div(Ku(ec(Qu(4294967295))))})).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),xB=ju((([e])=>{const t=Ku(e).toVar();return t.mul(t).mul(t).mul(t.mul(t.mul(6).sub(15)).add(10))})).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),bB=xM([ju((([e])=>{const t=Qu(e).toVar(),s=ec(ec(1)).toVar(),i=ec(ec(Qu(3735928559)).add(s.shiftLeft(ec(2))).add(ec(13))).toVar();return fB(i.add(ec(t)),i,i)})).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),ju((([e,t])=>{const s=Qu(t).toVar(),i=Qu(e).toVar(),r=ec(ec(2)).toVar(),n=ec().toVar(),o=ec().toVar(),a=ec().toVar();return n.assign(o.assign(a.assign(ec(Qu(3735928559)).add(r.shiftLeft(ec(2))).add(ec(13))))),n.addAssign(ec(i)),o.addAssign(ec(s)),fB(n,o,a)})).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),ju((([e,t,s])=>{const i=Qu(s).toVar(),r=Qu(t).toVar(),n=Qu(e).toVar(),o=ec(ec(3)).toVar(),a=ec().toVar(),h=ec().toVar(),l=ec().toVar();return a.assign(h.assign(l.assign(ec(Qu(3735928559)).add(o.shiftLeft(ec(2))).add(ec(13))))),a.addAssign(ec(n)),h.addAssign(ec(r)),l.addAssign(ec(i)),fB(a,h,l)})).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),ju((([e,t,s,i])=>{const r=Qu(i).toVar(),n=Qu(s).toVar(),o=Qu(t).toVar(),a=Qu(e).toVar(),h=ec(ec(4)).toVar(),l=ec().toVar(),u=ec().toVar(),c=ec().toVar();return l.assign(u.assign(c.assign(ec(Qu(3735928559)).add(h.shiftLeft(ec(2))).add(ec(13))))),l.addAssign(ec(a)),u.addAssign(ec(o)),c.addAssign(ec(n)),gB(l,u,c),l.addAssign(ec(r)),fB(l,u,c)})).setLayout({name:"mx_hash_int_3",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"}]}),ju((([e,t,s,i,r])=>{const n=Qu(r).toVar(),o=Qu(i).toVar(),a=Qu(s).toVar(),h=Qu(t).toVar(),l=Qu(e).toVar(),u=ec(ec(5)).toVar(),c=ec().toVar(),d=ec().toVar(),p=ec().toVar();return c.assign(d.assign(p.assign(ec(Qu(3735928559)).add(u.shiftLeft(ec(2))).add(ec(13))))),c.addAssign(ec(l)),d.addAssign(ec(h)),p.addAssign(ec(a)),gB(c,d,p),c.addAssign(ec(o)),d.addAssign(ec(n)),fB(c,d,p)})).setLayout({name:"mx_hash_int_4",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xx",type:"int"},{name:"yy",type:"int"}]})]),vB=xM([ju((([e,t])=>{const s=Qu(t).toVar(),i=Qu(e).toVar(),r=ec(bB(i,s)).toVar(),n=hc().toVar();return n.x.assign(r.bitAnd(Qu(255))),n.y.assign(r.shiftRight(Qu(8)).bitAnd(Qu(255))),n.z.assign(r.shiftRight(Qu(16)).bitAnd(Qu(255))),n})).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),ju((([e,t,s])=>{const i=Qu(s).toVar(),r=Qu(t).toVar(),n=Qu(e).toVar(),o=ec(bB(n,r,i)).toVar(),a=hc().toVar();return a.x.assign(o.bitAnd(Qu(255))),a.y.assign(o.shiftRight(Qu(8)).bitAnd(Qu(255))),a.z.assign(o.shiftRight(Qu(16)).bitAnd(Qu(255))),a})).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]})]),TB=xM([ju((([e])=>{const t=sc(e).toVar(),s=Qu().toVar(),i=Qu().toVar(),r=Ku(tB(t.x,s)).toVar(),n=Ku(tB(t.y,i)).toVar(),o=Ku(xB(r)).toVar(),a=Ku(xB(n)).toVar(),h=Ku(sB(oB(bB(s,i),r,n),oB(bB(s.add(Qu(1)),i),r.sub(1),n),oB(bB(s,i.add(Qu(1))),r,n.sub(1)),oB(bB(s.add(Qu(1)),i.add(Qu(1))),r.sub(1),n.sub(1)),o,a)).toVar();return dB(h)})).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),ju((([e])=>{const t=oc(e).toVar(),s=Qu().toVar(),i=Qu().toVar(),r=Qu().toVar(),n=Ku(tB(t.x,s)).toVar(),o=Ku(tB(t.y,i)).toVar(),a=Ku(tB(t.z,r)).toVar(),h=Ku(xB(n)).toVar(),l=Ku(xB(o)).toVar(),u=Ku(xB(a)).toVar(),c=Ku(iB(oB(bB(s,i,r),n,o,a),oB(bB(s.add(Qu(1)),i,r),n.sub(1),o,a),oB(bB(s,i.add(Qu(1)),r),n,o.sub(1),a),oB(bB(s.add(Qu(1)),i.add(Qu(1)),r),n.sub(1),o.sub(1),a),oB(bB(s,i,r.add(Qu(1))),n,o,a.sub(1)),oB(bB(s.add(Qu(1)),i,r.add(Qu(1))),n.sub(1),o,a.sub(1)),oB(bB(s,i.add(Qu(1)),r.add(Qu(1))),n,o.sub(1),a.sub(1)),oB(bB(s.add(Qu(1)),i.add(Qu(1)),r.add(Qu(1))),n.sub(1),o.sub(1),a.sub(1)),h,l,u)).toVar();return pB(c)})).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]})]),_B=xM([ju((([e])=>{const t=sc(e).toVar(),s=Qu().toVar(),i=Qu().toVar(),r=Ku(tB(t.x,s)).toVar(),n=Ku(tB(t.y,i)).toVar(),o=Ku(xB(r)).toVar(),a=Ku(xB(n)).toVar(),h=oc(sB(lB(vB(s,i),r,n),lB(vB(s.add(Qu(1)),i),r.sub(1),n),lB(vB(s,i.add(Qu(1))),r,n.sub(1)),lB(vB(s.add(Qu(1)),i.add(Qu(1))),r.sub(1),n.sub(1)),o,a)).toVar();return dB(h)})).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),ju((([e])=>{const t=oc(e).toVar(),s=Qu().toVar(),i=Qu().toVar(),r=Qu().toVar(),n=Ku(tB(t.x,s)).toVar(),o=Ku(tB(t.y,i)).toVar(),a=Ku(tB(t.z,r)).toVar(),h=Ku(xB(n)).toVar(),l=Ku(xB(o)).toVar(),u=Ku(xB(a)).toVar(),c=oc(iB(lB(vB(s,i,r),n,o,a),lB(vB(s.add(Qu(1)),i,r),n.sub(1),o,a),lB(vB(s,i.add(Qu(1)),r),n,o.sub(1),a),lB(vB(s.add(Qu(1)),i.add(Qu(1)),r),n.sub(1),o.sub(1),a),lB(vB(s,i,r.add(Qu(1))),n,o,a.sub(1)),lB(vB(s.add(Qu(1)),i,r.add(Qu(1))),n.sub(1),o,a.sub(1)),lB(vB(s,i.add(Qu(1)),r.add(Qu(1))),n,o.sub(1),a.sub(1)),lB(vB(s.add(Qu(1)),i.add(Qu(1)),r.add(Qu(1))),n.sub(1),o.sub(1),a.sub(1)),h,l,u)).toVar();return pB(c)})).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]})]),wB=xM([ju((([e])=>{const t=Ku(e).toVar(),s=Qu(eB(t)).toVar();return yB(bB(s))})).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),ju((([e])=>{const t=sc(e).toVar(),s=Qu(eB(t.x)).toVar(),i=Qu(eB(t.y)).toVar();return yB(bB(s,i))})).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),ju((([e])=>{const t=oc(e).toVar(),s=Qu(eB(t.x)).toVar(),i=Qu(eB(t.y)).toVar(),r=Qu(eB(t.z)).toVar();return yB(bB(s,i,r))})).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),ju((([e])=>{const t=uc(e).toVar(),s=Qu(eB(t.x)).toVar(),i=Qu(eB(t.y)).toVar(),r=Qu(eB(t.z)).toVar(),n=Qu(eB(t.w)).toVar();return yB(bB(s,i,r,n))})).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),SB=xM([ju((([e])=>{const t=Ku(e).toVar(),s=Qu(eB(t)).toVar();return oc(yB(bB(s,Qu(0))),yB(bB(s,Qu(1))),yB(bB(s,Qu(2))))})).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),ju((([e])=>{const t=sc(e).toVar(),s=Qu(eB(t.x)).toVar(),i=Qu(eB(t.y)).toVar();return oc(yB(bB(s,i,Qu(0))),yB(bB(s,i,Qu(1))),yB(bB(s,i,Qu(2))))})).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),ju((([e])=>{const t=oc(e).toVar(),s=Qu(eB(t.x)).toVar(),i=Qu(eB(t.y)).toVar(),r=Qu(eB(t.z)).toVar();return oc(yB(bB(s,i,r,Qu(0))),yB(bB(s,i,r,Qu(1))),yB(bB(s,i,r,Qu(2))))})).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),ju((([e])=>{const t=uc(e).toVar(),s=Qu(eB(t.x)).toVar(),i=Qu(eB(t.y)).toVar(),r=Qu(eB(t.z)).toVar(),n=Qu(eB(t.w)).toVar();return oc(yB(bB(s,i,r,n,Qu(0))),yB(bB(s,i,r,n,Qu(1))),yB(bB(s,i,r,n,Qu(2))))})).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),MB=ju((([e,t,s,i])=>{const r=Ku(i).toVar(),n=Ku(s).toVar(),o=Qu(t).toVar(),a=oc(e).toVar(),h=Ku(0).toVar(),l=Ku(1).toVar();return Cy(o,(()=>{h.addAssign(l.mul(TB(a))),l.mulAssign(r),a.mulAssign(n)})),h})).setLayout({name:"mx_fractal_noise_float",type:"float",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),AB=ju((([e,t,s,i])=>{const r=Ku(i).toVar(),n=Ku(s).toVar(),o=Qu(t).toVar(),a=oc(e).toVar(),h=oc(0).toVar(),l=Ku(1).toVar();return Cy(o,(()=>{h.addAssign(l.mul(_B(a))),l.mulAssign(r),a.mulAssign(n)})),h})).setLayout({name:"mx_fractal_noise_vec3",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),NB=ju((([e,t,s,i])=>{const r=Ku(i).toVar(),n=Ku(s).toVar(),o=Qu(t).toVar(),a=oc(e).toVar();return sc(MB(a,o,n,r),MB(a.add(oc(Qu(19),Qu(193),Qu(17))),o,n,r))})).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),RB=ju((([e,t,s,i])=>{const r=Ku(i).toVar(),n=Ku(s).toVar(),o=Qu(t).toVar(),a=oc(e).toVar(),h=oc(AB(a,o,n,r)).toVar(),l=Ku(MB(a.add(oc(Qu(19),Qu(193),Qu(17))),o,n,r)).toVar();return uc(h,l)})).setLayout({name:"mx_fractal_noise_vec4",type:"vec4",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),CB=ju((([e,t,s,i,r,n,o])=>{const a=Qu(o).toVar(),h=Ku(n).toVar(),l=Qu(r).toVar(),u=Qu(i).toVar(),c=Qu(s).toVar(),d=Qu(t).toVar(),p=sc(e).toVar(),m=oc(SB(sc(d.add(u),c.add(l)))).toVar(),g=sc(m.x,m.y).toVar();g.subAssign(.5),g.mulAssign(h),g.addAssign(.5);const f=sc(sc(Ku(d),Ku(c)).add(g)).toVar(),y=sc(f.sub(p)).toVar();return Yu(a.equal(Qu(2)),(()=>op(y.x).add(op(y.y)))),Yu(a.equal(Qu(3)),(()=>Tp(op(y.x),op(y.y)))),Np(y,y)})).setLayout({name:"mx_worley_distance_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),EB=xM([CB,ju((([e,t,s,i,r,n,o,a,h])=>{const l=Qu(h).toVar(),u=Ku(a).toVar(),c=Qu(o).toVar(),d=Qu(n).toVar(),p=Qu(r).toVar(),m=Qu(i).toVar(),g=Qu(s).toVar(),f=Qu(t).toVar(),y=oc(e).toVar(),x=oc(SB(oc(f.add(p),g.add(d),m.add(c)))).toVar();x.subAssign(.5),x.mulAssign(u),x.addAssign(.5);const b=oc(oc(Ku(f),Ku(g),Ku(m)).add(x)).toVar(),v=oc(b.sub(y)).toVar();return Yu(l.equal(Qu(2)),(()=>op(v.x).add(op(v.y)).add(op(v.z)))),Yu(l.equal(Qu(3)),(()=>Tp(Tp(op(v.x),op(v.y)),op(v.z)))),Np(v,v)})).setLayout({name:"mx_worley_distance_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"},{name:"xoff",type:"int"},{name:"yoff",type:"int"},{name:"zoff",type:"int"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),BB=ju((([e,t,s])=>{const i=Qu(s).toVar(),r=Ku(t).toVar(),n=sc(e).toVar(),o=Qu().toVar(),a=Qu().toVar(),h=sc(tB(n.x,o),tB(n.y,a)).toVar(),l=Ku(1e6).toVar();return Cy({start:-1,end:Qu(1),name:"x",condition:"<="},(({x:e})=>{Cy({start:-1,end:Qu(1),name:"y",condition:"<="},(({y:t})=>{const s=Ku(EB(h,e,t,o,a,r,i)).toVar();l.assign(vp(l,s))}))})),Yu(i.equal(Qu(0)),(()=>{l.assign(Xd(l))})),l})).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),IB=ju((([e,t,s])=>{const i=Qu(s).toVar(),r=Ku(t).toVar(),n=sc(e).toVar(),o=Qu().toVar(),a=Qu().toVar(),h=sc(tB(n.x,o),tB(n.y,a)).toVar(),l=sc(1e6,1e6).toVar();return Cy({start:-1,end:Qu(1),name:"x",condition:"<="},(({x:e})=>{Cy({start:-1,end:Qu(1),name:"y",condition:"<="},(({y:t})=>{const s=Ku(EB(h,e,t,o,a,r,i)).toVar();Yu(s.lessThan(l.x),(()=>{l.y.assign(l.x),l.x.assign(s)})).ElseIf(s.lessThan(l.y),(()=>{l.y.assign(s)}))}))})),Yu(i.equal(Qu(0)),(()=>{l.assign(Xd(l))})),l})).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),PB=ju((([e,t,s])=>{const i=Qu(s).toVar(),r=Ku(t).toVar(),n=sc(e).toVar(),o=Qu().toVar(),a=Qu().toVar(),h=sc(tB(n.x,o),tB(n.y,a)).toVar(),l=oc(1e6,1e6,1e6).toVar();return Cy({start:-1,end:Qu(1),name:"x",condition:"<="},(({x:e})=>{Cy({start:-1,end:Qu(1),name:"y",condition:"<="},(({y:t})=>{const s=Ku(EB(h,e,t,o,a,r,i)).toVar();Yu(s.lessThan(l.x),(()=>{l.z.assign(l.y),l.y.assign(l.x),l.x.assign(s)})).ElseIf(s.lessThan(l.y),(()=>{l.z.assign(l.y),l.y.assign(s)})).ElseIf(s.lessThan(l.z),(()=>{l.z.assign(s)}))}))})),Yu(i.equal(Qu(0)),(()=>{l.assign(Xd(l))})),l})).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),FB=xM([BB,ju((([e,t,s])=>{const i=Qu(s).toVar(),r=Ku(t).toVar(),n=oc(e).toVar(),o=Qu().toVar(),a=Qu().toVar(),h=Qu().toVar(),l=oc(tB(n.x,o),tB(n.y,a),tB(n.z,h)).toVar(),u=Ku(1e6).toVar();return Cy({start:-1,end:Qu(1),name:"x",condition:"<="},(({x:e})=>{Cy({start:-1,end:Qu(1),name:"y",condition:"<="},(({y:t})=>{Cy({start:-1,end:Qu(1),name:"z",condition:"<="},(({z:s})=>{const n=Ku(EB(l,e,t,s,o,a,h,r,i)).toVar();u.assign(vp(u,n))}))}))})),Yu(i.equal(Qu(0)),(()=>{u.assign(Xd(u))})),u})).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),zB=xM([IB,ju((([e,t,s])=>{const i=Qu(s).toVar(),r=Ku(t).toVar(),n=oc(e).toVar(),o=Qu().toVar(),a=Qu().toVar(),h=Qu().toVar(),l=oc(tB(n.x,o),tB(n.y,a),tB(n.z,h)).toVar(),u=sc(1e6,1e6).toVar();return Cy({start:-1,end:Qu(1),name:"x",condition:"<="},(({x:e})=>{Cy({start:-1,end:Qu(1),name:"y",condition:"<="},(({y:t})=>{Cy({start:-1,end:Qu(1),name:"z",condition:"<="},(({z:s})=>{const n=Ku(EB(l,e,t,s,o,a,h,r,i)).toVar();Yu(n.lessThan(u.x),(()=>{u.y.assign(u.x),u.x.assign(n)})).ElseIf(n.lessThan(u.y),(()=>{u.y.assign(n)}))}))}))})),Yu(i.equal(Qu(0)),(()=>{u.assign(Xd(u))})),u})).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),UB=xM([PB,ju((([e,t,s])=>{const i=Qu(s).toVar(),r=Ku(t).toVar(),n=oc(e).toVar(),o=Qu().toVar(),a=Qu().toVar(),h=Qu().toVar(),l=oc(tB(n.x,o),tB(n.y,a),tB(n.z,h)).toVar(),u=oc(1e6,1e6,1e6).toVar();return Cy({start:-1,end:Qu(1),name:"x",condition:"<="},(({x:e})=>{Cy({start:-1,end:Qu(1),name:"y",condition:"<="},(({y:t})=>{Cy({start:-1,end:Qu(1),name:"z",condition:"<="},(({z:s})=>{const n=Ku(EB(l,e,t,s,o,a,h,r,i)).toVar();Yu(n.lessThan(u.x),(()=>{u.z.assign(u.y),u.y.assign(u.x),u.x.assign(n)})).ElseIf(n.lessThan(u.y),(()=>{u.z.assign(u.y),u.y.assign(n)})).ElseIf(n.lessThan(u.z),(()=>{u.z.assign(n)}))}))}))})),Yu(i.equal(Qu(0)),(()=>{u.assign(Xd(u))})),u})).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),LB=ju((([e])=>{const t=e.y,s=e.z,i=oc().toVar();return Yu(t.lessThan(1e-4),(()=>{i.assign(oc(s,s,s))})).Else((()=>{let r=e.x;r=r.sub(Jd(r)).mul(6).toVar();const n=Qu(gp(r)),o=r.sub(Ku(n)),a=s.mul(t.oneMinus()),h=s.mul(t.mul(o).oneMinus()),l=s.mul(t.mul(o.oneMinus()).oneMinus());Yu(n.equal(Qu(0)),(()=>{i.assign(oc(s,l,a))})).ElseIf(n.equal(Qu(1)),(()=>{i.assign(oc(h,s,a))})).ElseIf(n.equal(Qu(2)),(()=>{i.assign(oc(a,s,l))})).ElseIf(n.equal(Qu(3)),(()=>{i.assign(oc(a,h,s))})).ElseIf(n.equal(Qu(4)),(()=>{i.assign(oc(l,a,s))})).Else((()=>{i.assign(oc(s,a,h))}))})),i})).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),OB=ju((([e])=>{const t=oc(e).toVar(),s=Ku(t.x).toVar(),i=Ku(t.y).toVar(),r=Ku(t.z).toVar(),n=Ku(vp(s,vp(i,r))).toVar(),o=Ku(Tp(s,Tp(i,r))).toVar(),a=Ku(o.sub(n)).toVar(),h=Ku().toVar(),l=Ku().toVar(),u=Ku().toVar();return u.assign(o),Yu(o.greaterThan(0),(()=>{l.assign(a.div(o))})).Else((()=>{l.assign(0)})),Yu(l.lessThanEqual(0),(()=>{h.assign(0)})).Else((()=>{Yu(s.greaterThanEqual(o),(()=>{h.assign(i.sub(r).div(a))})).ElseIf(i.greaterThanEqual(o),(()=>{h.assign(dd(2,r.sub(s).div(a)))})).Else((()=>{h.assign(dd(4,s.sub(i).div(a)))})),h.mulAssign(1/6),Yu(h.lessThan(0),(()=>{h.addAssign(1)}))})),oc(h,l,u)})).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),VB=ju((([e])=>{const t=oc(e).toVar(),s=lc(vd(t,oc(.04045))).toVar(),i=oc(t.div(12.92)).toVar(),r=oc(Cp(Tp(t.add(oc(.055)),oc(0)).div(1.055),oc(2.4))).toVar();return Up(i,r,s)})).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),DB=(e,t)=>{e=Ku(e),t=Ku(t);const s=sc(t.dFdx(),t.dFdy()).length().mul(.7071067811865476);return Dp(e.sub(s),e.add(s),t)},kB=(e,t,s,i)=>Up(e,t,s[i].clamp()),GB=(e,t,s=Um())=>kB(e,t,s,"x"),WB=(e,t,s=Um())=>kB(e,t,s,"y"),HB=(e,t,s,i,r)=>Up(e,t,DB(s,i[r])),jB=(e,t,s,i=Um())=>HB(e,t,s,i,"x"),qB=(e,t,s,i=Um())=>HB(e,t,s,i,"y"),$B=(e=1,t=0,s=Um())=>s.mul(e).add(t),XB=(e,t=1)=>(e=Ku(e)).abs().pow(t).mul(e.sign()),YB=(e,t=1,s=.5)=>Ku(e).sub(s).mul(t).add(s),JB=(e=Um(),t=1,s=0)=>TB(e.convert("vec2|vec3")).mul(t).add(s),ZB=(e=Um(),t=1,s=0)=>_B(e.convert("vec2|vec3")).mul(t).add(s),KB=(e=Um(),t=1,s=0)=>{e=e.convert("vec2|vec3");return uc(_B(e),TB(e.add(sc(19,73)))).mul(t).add(s)},QB=(e=Um(),t=1)=>FB(e.convert("vec2|vec3"),t,Qu(1)),eI=(e=Um(),t=1)=>zB(e.convert("vec2|vec3"),t,Qu(1)),tI=(e=Um(),t=1)=>UB(e.convert("vec2|vec3"),t,Qu(1)),sI=(e=Um())=>wB(e.convert("vec2|vec3")),iI=(e=Um(),t=3,s=2,i=.5,r=1)=>MB(e,Qu(t),s,i).mul(r),rI=(e=Um(),t=3,s=2,i=.5,r=1)=>NB(e,Qu(t),s,i).mul(r),nI=(e=Um(),t=3,s=2,i=.5,r=1)=>AB(e,Qu(t),s,i).mul(r),oI=(e=Um(),t=3,s=2,i=.5,r=1)=>RB(e,Qu(t),s,i).mul(r),aI=new pE;class hI extends Lw{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,s){const i=this.renderer,r=this.nodes.getBackgroundNode(e)||e.background;let n=!1;if(null===r)i._clearColor.getRGB(aI,Zt),aI.a=i._clearColor.a;else if(!0===r.isColor)r.getRGB(aI,Zt),aI.a=1,n=!0;else if(!0===r.isNode){const s=this.get(e),n=r;aI.copy(i._clearColor);let o=s.backgroundMesh;if(void 0===o){const e=Yp(uc(n).mul(dA),{getUV:()=>Pg,getTextureLevel:()=>cA});let t=py();t=t.setZ(t.w);const i=new xx;i.name="Background.material",i.side=d,i.depthTest=!1,i.depthWrite=!1,i.fog=!1,i.lights=!1,i.vertexNode=t,i.colorNode=e,s.backgroundMeshNode=e,s.backgroundMesh=o=new Wn(new fl(1,32,32),i),o.frustumCulled=!1,o.name="Background.mesh",o.onBeforeRender=function(e,t,s){this.matrixWorld.copyPosition(s.matrixWorld)}}const a=n.getCacheKey();s.backgroundCacheKey!==a&&(s.backgroundMeshNode.node=uc(n).mul(dA),s.backgroundMeshNode.needsUpdate=!0,o.material.needsUpdate=!0,s.backgroundCacheKey=a),t.unshift(o,o.geometry,o.material,0,0,null)}else console.error("THREE.Renderer: Unsupported background configuration.",r);if(!0===i.autoClear||!0===n){aI.multiplyScalar(aI.a);const e=s.clearColorValue;e.r=aI.r,e.g=aI.g,e.b=aI.b,e.a=aI.a,s.depthClearValue=i._clearDepth,s.stencilClearValue=i._clearStencil,s.clearColor=!0===i.autoClearColor,s.clearDepth=!0===i.autoClearDepth,s.clearStencil=!0===i.autoClearStencil}else s.clearColor=!1,s.clearDepth=!1,s.clearStencil=!1}}class lI{constructor(e,t,s,i,r,n,o,a,h=!0,l=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=s,this.transforms=l,this.nodeAttributes=i,this.bindings=r,this.updateNodes=n,this.updateBeforeNodes=o,this.updateAfterNodes=a,this.instanceBindGroups=h,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings){if(!0!==(this.instanceBindGroups&&t.bindings[0].groupNode.shared)){const s=new sM(t.name,[],t.index,t);e.push(s);for(const e of t.bindings)s.bindings.push(e.clone())}else e.push(t)}return e}}const uI=new WeakMap;class cI extends Lw{constructor(e,t){super(),this.renderer=e,this.backend=t,this.nodeFrame=new hM,this.nodeBuilderCache=new Map,this.callHashCache=new Bw,this.groupsData=new Bw}updateGroup(e){const t=e.groupNode,s=t.name;if(s===Nc.name)return!0;if(s===Ac.name){const t=this.get(e),s=this.nodeFrame.renderId;return t.renderId!==s&&(t.renderId=s,!0)}if(s===Mc.name){const t=this.get(e),s=this.nodeFrame.frameId;return t.frameId!==s&&(t.frameId=s,!0)}const i=[t,e];let r=this.groupsData.get(i);return void 0===r&&this.groupsData.set(i,r={}),r.version!==t.version&&(r.version=t.version,!0)}getForRenderCacheKey(e){return e.initialCacheKey}getForRender(e){const t=this.get(e);let s=t.nodeBuilderState;if(void 0===s){const{nodeBuilderCache:i}=this,r=this.getForRenderCacheKey(e);if(s=i.get(r),void 0===s){const t=this.backend.createNodeBuilder(e.object,this.renderer);t.scene=e.scene,t.material=e.material,t.camera=e.camera,t.context.material=e.material,t.lightsNode=e.lightsNode,t.environmentNode=this.getEnvironmentNode(e.scene),t.fogNode=this.getFogNode(e.scene),t.clippingContext=e.clippingContext,t.build(),s=this._createNodeBuilderState(t),i.set(r,s)}s.usedTimes++,t.nodeBuilderState=s}return s}delete(e){if(e.isRenderObject){const t=this.get(e).nodeBuilderState;t.usedTimes--,0===t.usedTimes&&this.nodeBuilderCache.delete(this.getForRenderCacheKey(e))}return super.delete(e)}getForCompute(e){const t=this.get(e);let s=t.nodeBuilderState;if(void 0===s){const i=this.backend.createNodeBuilder(e,this.renderer);i.build(),s=this._createNodeBuilderState(i),t.nodeBuilderState=s}return s}_createNodeBuilderState(e){return new lI(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.instanceBindGroups,e.transforms)}getEnvironmentNode(e){return e.environmentNode||this.get(e).environmentNode||null}getBackgroundNode(e){return e.backgroundNode||this.get(e).backgroundNode||null}getFogNode(e){return e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){const s=[e,t],i=this.renderer.info.calls;let r=this.callHashCache.get(s);if(void 0===r||r.callId!==i){const n=this.getEnvironmentNode(e),o=this.getFogNode(e),a=[];t&&a.push(t.getCacheKey(!0)),n&&a.push(n.getCacheKey()),o&&a.push(o.getCacheKey()),r={callId:i,cacheKey:a.join(",")},this.callHashCache.set(s,r)}return r.cacheKey}updateScene(e){this.updateEnvironment(e),this.updateFog(e),this.updateBackground(e)}get isToneMappingState(){return!this.renderer.getRenderTarget()}updateBackground(e){const t=this.get(e),s=e.background;if(s){const i=0===e.backgroundBlurriness&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&0===t.backgroundBlurriness;if(t.background!==s||i){let i=null;if(!0===s.isCubeTexture||s.mapping===ue||s.mapping===ce)if(e.backgroundBlurriness>0)i=mv(s,Pg);else{let e;e=!0===s.isCubeTexture?Wg(s):Gm(s),i=Vx(e)}else!0===s.isTexture?i=Gm(s,Zy.flipY()).setUpdateMatrix(!0):!0!==s.isColor&&console.error("WebGPUNodes: Unsupported background configuration.",s);t.backgroundNode=i,t.background=s,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}updateFog(e){const t=this.get(e),s=e.fog;if(s){if(t.fog!==s){let e=null;s.isFogExp2?e=SC(Zg("color","color",s),Zg("density","float",s)):s.isFog?e=_C(Zg("color","color",s),Zg("near","float",s),Zg("far","float",s)):console.error("WebGPUNodes: Unsupported fog configuration.",s),t.fogNode=e,t.fog=s}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),s=e.environment;if(s){if(t.environment!==s){let e=null;!0===s.isCubeTexture?e=Wg(s):!0===s.isTexture?e=Gm(s):console.error("Nodes: Unsupported environment configuration.",s),t.environmentNode=e,t.environment=s}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,s=null,i=null,r=null){const n=this.nodeFrame;return n.renderer=e,n.scene=t,n.object=s,n.camera=i,n.material=r,n}getNodeFrameForRender(e){return this.getNodeFrame(e.renderer,e.scene,e.object,e.camera,e.material)}getOutputCacheKey(){const e=this.renderer;return e.toneMapping+","+e.currentColorSpace}hasOutputChange(e){return uI.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,s=this.getOutputCacheKey(),i=Gm(e,Zy).renderOutput(t.toneMapping,t.currentColorSpace);return uI.set(e,s),i}updateBefore(e){const t=e.getNodeBuilderState();for(const s of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(s)}updateAfter(e){const t=e.getNodeBuilderState();for(const s of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(s)}updateForCompute(e){const t=this.getNodeFrame(),s=this.getForCompute(e);for(const e of s.updateNodes)t.updateNode(e)}updateForRender(e){const t=this.getNodeFrameForRender(e),s=e.getNodeBuilderState();for(const e of s.updateNodes)t.updateNode(e)}dispose(){super.dispose(),this.nodeFrame=new hM,this.nodeBuilderCache=new Map}}class dI{constructor(e,t){this.scene=e,this.camera=t}clone(){return Object.assign(new this.constructor,this)}}class pI{constructor(){this.lists=new Bw}get(e,t){const s=this.lists,i=[e,t];let r=s.get(i);return void 0===r&&(r=new dI(e,t),s.set(i,r)),r}dispose(){this.lists=new Bw}}class mI{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map,this.colorSpaceNodes=new Map}fromMaterial(e){if(e.isNodeMaterial)return e;let t=null;const s=this.getMaterialNodeClass(e.type);if(null!==s){t=new s;for(const s in e)t[s]=e[s]}return t}addColorSpace(e,t){this.addType(e,t,this.colorSpaceNodes)}getColorSpaceFunction(e){return this.colorSpaceNodes.get(e)||null}addToneMapping(e,t){this.addType(e,t,this.toneMappingNodes)}getToneMappingFunction(e){return this.toneMappingNodes.get(e)||null}getMaterialNodeClass(e){return this.materialNodes.get(e)||null}addMaterial(e,t){this.addType(e,t.name,this.materialNodes)}getLightNodeClass(e){return this.lightNodes.get(e)||null}addLight(e,t){this.addClass(e,t,this.lightNodes)}addType(e,t,s){if(s.has(t))console.warn(`Redefinition of node ${t}`);else{if("function"!=typeof e)throw new Error(`Node class ${e.name} is not a class.`);if("function"==typeof t||"object"==typeof t)throw new Error(`Base class ${t} is not a class.`);s.set(t,e)}}addClass(e,t,s){if(s.has(t))console.warn(`Redefinition of node ${t.name}`);else{if("function"!=typeof e)throw new Error(`Node class ${e.name} is not a class.`);if("function"!=typeof t)throw new Error(`Base class ${t.name} is not a class.`);s.set(t,e)}}}const gI=new no,fI=new Qs,yI=new _i,xI=new na,bI=new or,vI=new Ei;class TI{constructor(e,t={}){this.isRenderer=!0;const{logarithmicDepthBuffer:s=!1,alpha:i=!0,antialias:r=!1,samples:n=0,getFallback:o=null}=t;this.domElement=e.getDomElement(),this.backend=e,this.samples=n||!0===r?4:0,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.alpha=i,this.logarithmicDepthBuffer=s,this.outputColorSpace=Jt,this.toneMapping=0,this.toneMappingExposure=1,this.sortObjects=!0,this.depth=!0,this.stencil=!1,this.clippingPlanes=[],this.info=new qw,this.nodes={library:new mI},this._getFallback=o,this._pixelRatio=1,this._width=this.domElement.width,this._height=this.domElement.height,this._viewport=new _i(0,0,this._width,this._height),this._scissor=new _i(0,0,this._width,this._height),this._scissorTest=!1,this._attributes=null,this._geometries=null,this._nodes=null,this._animation=null,this._bindings=null,this._objects=null,this._pipelines=null,this._bundles=null,this._renderLists=null,this._renderContexts=null,this._textures=null,this._background=null,this._quad=new tA(new xx),this._quad.material.type="Renderer_output",this._currentRenderContext=null,this._opaqueSort=null,this._transparentSort=null,this._frameBufferTarget=null;const a=!0===this.alpha?0:1;this._clearColor=new pE(0,0,0,a),this._clearDepth=1,this._clearStencil=0,this._renderTarget=null,this._activeCubeFace=0,this._activeMipmapLevel=0,this._mrt=null,this._renderObjectFunction=null,this._currentRenderObjectFunction=null,this._currentRenderBundle=null,this._handleObjectFunction=this._renderObjectDirect,this._initialized=!1,this._initPromise=null,this._compilationPromises=null,this.transparent=!0,this.opaque=!0,this.shadowMap={enabled:!1,type:1},this.xr={enabled:!1},this.debug={checkShaderErrors:!0,onShaderError:null,getShaderAsync:async(e,t,s)=>{await this.compileAsync(e,t);const i=this._renderLists.get(e,t),r=this._renderContexts.get(e,t,this._renderTarget),n=e.overrideMaterial||s.material,o=this._objects.get(s,n,e,t,i.lightsNode,r),{fragmentShader:a,vertexShader:h}=o.getNodeBuilderState();return{fragmentShader:a,vertexShader:h}}}}async init(){if(this._initialized)throw new Error("Renderer: Backend has already been initialized.");return null!==this._initPromise||(this._initPromise=new Promise((async(e,t)=>{let s=this.backend;try{await s.init(this)}catch(e){if(null===this._getFallback)return void t(e);try{this.backend=s=this._getFallback(e),await s.init(this)}catch(e){return void t(e)}}this._nodes=new cI(this,s),this._animation=new Ew(this._nodes,this.info),this._attributes=new Gw(s),this._background=new hI(this,this._nodes),this._geometries=new jw(this._attributes,this.info),this._textures=new dE(this,s,this.info),this._pipelines=new Kw(s,this._nodes),this._bindings=new Qw(s,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new Uw(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new oE,this._bundles=new pI,this._renderContexts=new uE,this._initialized=!0,e()}))),this._initPromise}get coordinateSystem(){return this.backend.coordinateSystem}async compileAsync(e,t,s=null){!1===this._initialized&&await this.init();const i=this._nodes.nodeFrame,r=i.renderId,n=this._currentRenderContext,o=this._currentRenderObjectFunction,a=this._compilationPromises,h=!0===e.isScene?e:gI;null===s&&(s=e);const l=this._renderTarget,u=this._renderContexts.get(s,t,l),c=this._activeMipmapLevel,d=[];this._currentRenderContext=u,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=d,i.renderId++,i.update(),u.depth=this.depth,u.stencil=this.stencil,u.clippingContext||(u.clippingContext=new Pw),u.clippingContext.updateGlobal(this,t),h.onBeforeRender(this,e,t,l);const p=this._renderLists.get(e,t);if(p.begin(),this._projectObject(e,t,0,p),s!==e&&s.traverseVisible((function(e){e.isLight&&e.layers.test(t.layers)&&p.pushLight(e)})),p.finish(),null!==l){this._textures.updateRenderTarget(l,c);const e=this._textures.get(l);u.textures=e.textures,u.depthTexture=e.depthTexture}else u.textures=null,u.depthTexture=null;this._nodes.updateScene(h),this._background.update(h,p,u);const m=p.opaque,g=p.transparent,f=p.lightsNode;!0===this.opaque&&m.length>0&&this._renderObjects(m,t,h,f),!0===this.transparent&&g.length>0&&this._renderObjects(g,t,h,f),i.renderId=r,this._currentRenderContext=n,this._currentRenderObjectFunction=o,this._compilationPromises=a,this._handleObjectFunction=this._renderObjectDirect,await Promise.all(d)}async renderAsync(e,t){!1===this._initialized&&await this.init();const s=this._renderScene(e,t);await this.backend.resolveTimestampAsync(s,"render")}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}_renderBundle(e,t,s){const{object:i,camera:r,renderList:n}=e,o=this._currentRenderContext,a=this._bundles.get(i,r),h=this.backend.get(a);void 0===h.renderContexts&&(h.renderContexts=new Set);const l=!1===h.renderContexts.has(o)||!0===i.needsUpdate;if(h.renderContexts.add(o),l){this.backend.beginBundle(o),void 0!==h.renderObjects&&!0!==i.needsUpdate||(h.renderObjects=[]),this._currentRenderBundle=a;const e=n.opaque;e.length>0&&this._renderObjects(e,r,t,s),this._currentRenderBundle=null,this.backend.finishBundle(o,a),i.needsUpdate=!1}else{const e=h.renderObjects;for(let t=0,s=e.length;t>=c,p.viewportValue.height>>=c,p.viewportValue.minDepth=x,p.viewportValue.maxDepth=b,p.viewport=!1===p.viewportValue.equals(yI),p.scissorValue.copy(f).multiplyScalar(y).floor(),p.scissor=this._scissorTest&&!1===p.scissorValue.equals(yI),p.scissorValue.width>>=c,p.scissorValue.height>>=c,p.clippingContext||(p.clippingContext=new Pw),p.clippingContext.updateGlobal(this,t),h.onBeforeRender(this,e,t,d),bI.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),xI.setFromProjectionMatrix(bI,m);const v=this._renderLists.get(e,t);if(v.begin(),this._projectObject(e,t,0,v),v.finish(),!0===this.sortObjects&&v.sort(this._opaqueSort,this._transparentSort),null!==d){this._textures.updateRenderTarget(d,c);const e=this._textures.get(d);p.textures=e.textures,p.depthTexture=e.depthTexture,p.width=e.width,p.height=e.height,p.renderTarget=d,p.depth=d.depthBuffer,p.stencil=d.stencilBuffer}else p.textures=null,p.depthTexture=null,p.width=this.domElement.width,p.height=this.domElement.height,p.depth=this.depth,p.stencil=this.stencil;p.width>>=c,p.height>>=c,p.activeCubeFace=u,p.activeMipmapLevel=c,p.occlusionQueryCount=v.occlusionQueryCount,this._nodes.updateScene(h),this._background.update(h,v,p),this.backend.beginRender(p);const T=v.opaque,_=v.transparent,w=v.bundles,S=v.lightsNode;if(w.length>0&&this._renderBundles(w,h,S),!0===this.opaque&&T.length>0&&this._renderObjects(T,t,h,S),!0===this.transparent&&_.length>0&&this._renderObjects(_,t,h,S),this.backend.finishRender(p),r.renderId=n,this._currentRenderContext=o,this._currentRenderObjectFunction=a,null!==i){this.setRenderTarget(l,u,c);const e=this._quad;this._nodes.hasOutputChange(d.texture)&&(e.material.fragmentNode=this._nodes.getOutputNode(d.texture),e.material.needsUpdate=!0),this._renderScene(e,e.camera,!1)}return h.onAfterRender(this,e,t,d),p}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}async setAnimationLoop(e){!1===this._initialized&&await this.init(),this._animation.setAnimationLoop(e)}async getArrayBufferAsync(e){return await this.backend.getArrayBufferAsync(e)}getContext(){return this.backend.getContext()}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio=e,this.setSize(this._width,this._height,!1)}setDrawingBufferSize(e,t,s){this._width=e,this._height=t,this._pixelRatio=s,this.domElement.width=Math.floor(e*s),this.domElement.height=Math.floor(t*s),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize()}setSize(e,t,s=!0){this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),!0===s&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._initialized&&this.backend.updateSize()}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){const t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,s,i){const r=this._scissor;e.isVector4?r.copy(e):r.set(e,t,s,i)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e,this.backend.setScissorTest(e)}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,s,i,r=0,n=1){const o=this._viewport;e.isVector4?o.copy(e):o.set(e,t,s,i),o.minDepth=r,o.maxDepth=n}getClearColor(e){return e.copy(this._clearColor)}setClearColor(e,t=1){this._clearColor.set(e),this._clearColor.a=t}getClearAlpha(){return this._clearColor.a}setClearAlpha(e){this._clearColor.a=e}getClearDepth(){return this._clearDepth}setClearDepth(e){this._clearDepth=e}getClearStencil(){return this._clearStencil}setClearStencil(e){this._clearStencil=e}isOccluded(e){const t=this._currentRenderContext;return t&&this.backend.isOccluded(t,e)}clear(e=!0,t=!0,s=!0){if(!1===this._initialized)return console.warn("THREE.Renderer: .clear() called before the backend is initialized. Try using .clearAsync() instead."),this.clearAsync(e,t,s);const i=this._renderTarget||this._getFrameBufferTarget();let r=null;if(null!==i&&(this._textures.updateRenderTarget(i),r=this._textures.get(i)),this.backend.clear(e,t,s,r),null!==i&&null===this._renderTarget){const e=this._quad;this._nodes.hasOutputChange(i.texture)&&(e.material.fragmentNode=this._nodes.getOutputNode(i.texture),e.material.needsUpdate=!0),this._renderScene(e,e.camera,!1)}}clearColor(){return this.clear(!0,!1,!1)}clearDepth(){return this.clear(!1,!0,!1)}clearStencil(){return this.clear(!1,!1,!0)}async clearAsync(e=!0,t=!0,s=!0){!1===this._initialized&&await this.init(),this.clear(e,t,s)}clearColorAsync(){return this.clearAsync(!0,!1,!1)}clearDepthAsync(){return this.clearAsync(!1,!0,!1)}clearStencilAsync(){return this.clearAsync(!1,!1,!0)}get currentToneMapping(){return null!==this._renderTarget?0:this.toneMapping}get currentColorSpace(){return null!==this._renderTarget?Zt:this.outputColorSpace}dispose(){this.info.dispose(),this._animation.dispose(),this._objects.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,s=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=s}getRenderTarget(){return this._renderTarget}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}async computeAsync(e){!1===this._initialized&&await this.init();const t=this._nodes.nodeFrame,s=t.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,t.renderId=this.info.calls;const i=this.backend,r=this._pipelines,n=this._bindings,o=this._nodes,a=Array.isArray(e)?e:[e];if(void 0===a[0]||!0!==a[0].isComputeNode)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");i.beginCompute(e);for(const t of a){if(!1===r.has(t)){const e=()=>{t.removeEventListener("dispose",e),r.delete(t),n.delete(t),o.delete(t)};t.addEventListener("dispose",e),t.onInit({renderer:this})}o.updateForCompute(t),n.updateForCompute(t);const s=n.getForCompute(t),a=r.getForCompute(t,s);i.compute(e,t,s,a)}i.finishCompute(e),await this.backend.resolveTimestampAsync(e,"compute"),t.renderId=s}async hasFeatureAsync(e){return!1===this._initialized&&await this.init(),this.backend.hasFeature(e)}hasFeature(e){return!1===this._initialized?(console.warn("THREE.Renderer: .hasFeature() called before the backend is initialized. Try using .hasFeatureAsync() instead."),!1):this.backend.hasFeature(e)}copyFramebufferToTexture(e){const t=this._currentRenderContext;this._textures.updateTexture(e),this.backend.copyFramebufferToTexture(e,t)}copyTextureToTexture(e,t,s=null,i=null,r=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,s,i,r)}readRenderTargetPixelsAsync(e,t,s,i,r,n=0){return this.backend.copyTextureToBuffer(e.textures[n],t,s,i,r)}_projectObject(e,t,s,i){if(!1===e.visible)return;if(e.layers.test(t.layers))if(e.isGroup)s=e.renderOrder;else if(e.isLOD)!0===e.autoUpdate&&e.update(t);else if(e.isLight)i.pushLight(e);else if(e.isSprite){if(!e.frustumCulled||xI.intersectsSprite(e)){!0===this.sortObjects&&vI.setFromMatrixPosition(e.matrixWorld).applyMatrix4(bI);const t=e.geometry,r=e.material;r.visible&&i.push(e,t,r,s,vI.z,null)}}else if(e.isLineLoop)console.error("THREE.Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||xI.intersectsObject(e))){const t=e.geometry,r=e.material;if(!0===this.sortObjects&&(null===t.boundingSphere&&t.computeBoundingSphere(),vI.copy(t.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(bI)),Array.isArray(r)){const n=t.groups;for(let o=0,a=n.length;o0?i:"";t=`${e.name} {\n\t${s} ${r.name}[${n}];\n};\n`}else{t=`${this.getVectorType(r.type)} ${this.getPropertyName(r,e)};`,n=!0}const o=r.node.precision;if(null!==o&&(t=VI[o]+" "+t),n){t="\t"+t;const e=r.groupNode.name;(i[e]||(i[e]=[])).push(t)}else t="uniform "+t,s.push(t)}let r="";for(const t in i){const s=i[t];r+=this._getGLSLUniformStruct(e+"_"+t,s.join("\n"))+"\n"}return r+=s.join("\n"),r}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==Ee){let s=e;e.isInterleavedBufferAttribute&&(s=e.data);const i=s.array;!1==(i instanceof Uint32Array||i instanceof Int32Array)&&(t=t.slice(1))}return t}getAttributes(e){let t="";if("vertex"===e||"compute"===e){const e=this.getAttributesArray();let s=0;for(const i of e)t+=`layout( location = ${s++} ) in ${i.type} ${i.name};\n`}return t}getStructMembers(e){const t=[],s=e.getMemberTypes();for(let e=0;ee*t),1)}u`}getDrawIndex(){return this.renderer.backend.extensions.has("WEBGL_multi_draw")?"uint( gl_DrawID )":null}getFrontFacing(){return"gl_FrontFacing"}getFragCoord(){return"gl_FragCoord.xy"}getFragDepth(){return"gl_FragDepth"}enableExtension(e,t,s=this.shaderStage){const i=this.extensions[s]||(this.extensions[s]=new Map);!1===i.has(e)&&i.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if("vertex"===e){const t=this.renderer.backend.extensions;this.object.isBatchedMesh&&t.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const s=this.extensions[e];if(void 0!==s)for(const{name:e,behavior:i}of s.values())t.push(`#extension ${e} : ${i}`);return t.join("\n")}isAvailable(e){let t=DI[e];if(void 0===t){if("float32Filterable"===e){const e=this.renderer.backend.extensions;e.has("OES_texture_float_linear")?(e.get("OES_texture_float_linear"),t=!0):t=!1}DI[e]=t}return t}isFlipY(){return!0}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let s=0;s0&&(s+="\n"),s+=`\t// flow -> ${n}\n\t`),s+=`${i.code}\n\t`,e===r&&"compute"!==t&&(s+="// result\n\t","vertex"===t?(s+="gl_Position = ",s+=`${i.result};`):"fragment"===t&&(e.outputNode.isOutputStructNode||(s+="fragColor = ",s+=`${i.result};`)))}const n=e[t];n.extensions=this.getExtensions(t),n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.vars=this.getVars(t),n.structs=this.getStructs(t),n.codes=this.getCodes(t),n.transforms=this.getTransforms(t),n.flow=s}null!==this.material?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,s,i=null){const r=super.getUniformFromNode(e,t,s,i),n=this.getDataFromNode(e,s,this.globalCache);let o=n.uniformGPU;if(void 0===o){const i=e.groupNode,a=i.name,h=this.getBindGroupArray(a,s);if("texture"===t)o=new zI(r.name,r.node,i),h.push(o);else if("cubeTexture"===t)o=new UI(r.name,r.node,i),h.push(o);else if("texture3D"===t)o=new LI(r.name,r.node,i),h.push(o);else if("buffer"===t){e.name=`NodeBuffer_${e.id}`,r.name=`buffer${e.id}`;const t=new CI(e,i);t.name=e.name,h.push(t),o=t}else{const e=this.uniformGroups[s]||(this.uniformGroups[s]={});let n=e[a];void 0===n&&(n=new II(s+"_"+a,i),e[a]=n,h.push(n)),o=this.getNodeUniform(r,t),n.addUniform(o)}n.uniformGPU=o}return r}}let WI=null,HI=null,jI=null;class qI{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null}async init(e){this.renderer=e}begin(){}finish(){}draw(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}createRenderPipeline(){}createComputePipeline(){}destroyPipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}createDefaultTexture(){}createTexture(){}copyTextureToBuffer(){}createAttribute(){}createIndexAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}resolveTimestampAsync(){}hasFeatureAsync(){}hasFeature(){}getInstanceCount(e){const{object:t,geometry:s}=e;return s.isInstancedBufferGeometry?s.instanceCount:t.count>1?t.count:1}getDrawingBufferSize(){return WI=WI||new Qs,this.renderer.getDrawingBufferSize(WI)}getScissor(){return HI=HI||new _i,this.renderer.getScissor(HI)}setScissorTest(){}getClearColor(){const e=this.renderer;return jI=jI||new pE,e.getClearColor(jI),jI.getRGB(jI,this.renderer.currentColorSpace),jI}getDomElement(){let t=this.domElement;return null===t&&(t=void 0!==this.parameters.canvas?this.parameters.canvas:ni(),"setAttribute"in t&&t.setAttribute("data-engine",`three.js r${e} webgpu`),this.domElement=t),t}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return void 0===t&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}}let $I=0;class XI{constructor(e,t){this.buffers=[e.bufferGPU,t],this.type=e.type,this.bufferType=e.bufferType,this.pbo=e.pbo,this.byteLength=e.byteLength,this.bytesPerElement=e.BYTES_PER_ELEMENT,this.version=e.version,this.isInteger=e.isInteger,this.activeBufferIndex=0,this.baseId=e.id}get id(){return`${this.baseId}|${this.activeBufferIndex}`}get bufferGPU(){return this.buffers[this.activeBufferIndex]}get transformBuffer(){return this.buffers[1^this.activeBufferIndex]}switchBuffers(){this.activeBufferIndex^=1}}class YI{constructor(e){this.backend=e}createAttribute(e,t){const s=this.backend,{gl:i}=s,r=e.array,n=e.usage||i.STATIC_DRAW,o=e.isInterleavedBufferAttribute?e.data:e,a=s.get(o);let h,l=a.bufferGPU;if(void 0===l&&(l=this._createBuffer(i,t,r,n),a.bufferGPU=l,a.bufferType=t,a.version=o.version),r instanceof Float32Array)h=i.FLOAT;else if(r instanceof Uint16Array)h=e.isFloat16BufferAttribute?i.HALF_FLOAT:i.UNSIGNED_SHORT;else if(r instanceof Int16Array)h=i.SHORT;else if(r instanceof Uint32Array)h=i.UNSIGNED_INT;else if(r instanceof Int32Array)h=i.INT;else if(r instanceof Int8Array)h=i.BYTE;else if(r instanceof Uint8Array)h=i.UNSIGNED_BYTE;else{if(!(r instanceof Uint8ClampedArray))throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+r);h=i.UNSIGNED_BYTE}let u={bufferGPU:l,bufferType:t,type:h,byteLength:r.byteLength,bytesPerElement:r.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:h===i.INT||h===i.UNSIGNED_INT||e.gpuType===Ee,id:$I++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const e=this._createBuffer(i,t,r,n);u=new XI(u,e)}s.set(e,u)}updateAttribute(e){const t=this.backend,{gl:s}=t,i=e.array,r=e.isInterleavedBufferAttribute?e.data:e,n=t.get(r),o=n.bufferType,a=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(s.bindBuffer(o,n.bufferGPU),0===a.length)s.bufferSubData(o,0,i);else{for(let e=0,t=a.length;e{!function r(){const n=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(n===e.WAIT_FAILED)return e.deleteSync(t),void i();n!==e.TIMEOUT_EXPIRED?(e.deleteSync(t),s()):requestAnimationFrame(r)}()}))}}let tP,sP,iP,rP=!1;class nP{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},!1===rP&&(this._init(this.gl),rP=!0)}_init(e){tP={[pe]:e.REPEAT,[me]:e.CLAMP_TO_EDGE,[ge]:e.MIRRORED_REPEAT},sP={[fe]:e.NEAREST,[ye]:e.NEAREST_MIPMAP_NEAREST,[be]:e.NEAREST_MIPMAP_LINEAR,[Te]:e.LINEAR,[_e]:e.LINEAR_MIPMAP_NEAREST,[Se]:e.LINEAR_MIPMAP_LINEAR},iP={512:e.NEVER,519:e.ALWAYS,[Ts]:e.LESS,515:e.LEQUAL,514:e.EQUAL,518:e.GEQUAL,516:e.GREATER,517:e.NOTEQUAL}}filterFallback(e){const{gl:t}=this;return e===fe||e===ye||e===be?t.NEAREST:t.LINEAR}getGLTextureType(e){const{gl:t}=this;let s;return s=!0===e.isCubeTexture?t.TEXTURE_CUBE_MAP:!0===e.isDataArrayTexture||!0===e.isCompressedArrayTexture?t.TEXTURE_2D_ARRAY:!0===e.isData3DTexture?t.TEXTURE_3D:t.TEXTURE_2D,s}getInternalFormat(e,t,s,i,r=!1){const{gl:n,extensions:o}=this;if(null!==e){if(void 0!==n[e])return n[e];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+e+"'")}let a=t;return t===n.RED&&(s===n.FLOAT&&(a=n.R32F),s===n.HALF_FLOAT&&(a=n.R16F),s===n.UNSIGNED_BYTE&&(a=n.R8),s===n.UNSIGNED_SHORT&&(a=n.R16),s===n.UNSIGNED_INT&&(a=n.R32UI),s===n.BYTE&&(a=n.R8I),s===n.SHORT&&(a=n.R16I),s===n.INT&&(a=n.R32I)),t===n.RED_INTEGER&&(s===n.UNSIGNED_BYTE&&(a=n.R8UI),s===n.UNSIGNED_SHORT&&(a=n.R16UI),s===n.UNSIGNED_INT&&(a=n.R32UI),s===n.BYTE&&(a=n.R8I),s===n.SHORT&&(a=n.R16I),s===n.INT&&(a=n.R32I)),t===n.RG&&(s===n.FLOAT&&(a=n.RG32F),s===n.HALF_FLOAT&&(a=n.RG16F),s===n.UNSIGNED_BYTE&&(a=n.RG8),s===n.UNSIGNED_SHORT&&(a=n.RG16),s===n.UNSIGNED_INT&&(a=n.RG32UI),s===n.BYTE&&(a=n.RG8I),s===n.SHORT&&(a=n.RG16I),s===n.INT&&(a=n.RG32I)),t===n.RG_INTEGER&&(s===n.UNSIGNED_BYTE&&(a=n.RG8UI),s===n.UNSIGNED_SHORT&&(a=n.RG16UI),s===n.UNSIGNED_INT&&(a=n.RG32UI),s===n.BYTE&&(a=n.RG8I),s===n.SHORT&&(a=n.RG16I),s===n.INT&&(a=n.RG32I)),t===n.RGB&&(s===n.FLOAT&&(a=n.RGB32F),s===n.HALF_FLOAT&&(a=n.RGB16F),s===n.UNSIGNED_BYTE&&(a=n.RGB8),s===n.UNSIGNED_SHORT&&(a=n.RGB16),s===n.UNSIGNED_INT&&(a=n.RGB32UI),s===n.BYTE&&(a=n.RGB8I),s===n.SHORT&&(a=n.RGB16I),s===n.INT&&(a=n.RGB32I),s===n.UNSIGNED_BYTE&&(a=i===Jt&&!1===r?n.SRGB8:n.RGB8),s===n.UNSIGNED_SHORT_5_6_5&&(a=n.RGB565),s===n.UNSIGNED_SHORT_5_5_5_1&&(a=n.RGB5_A1),s===n.UNSIGNED_SHORT_4_4_4_4&&(a=n.RGB4),s===n.UNSIGNED_INT_5_9_9_9_REV&&(a=n.RGB9_E5)),t===n.RGB_INTEGER&&(s===n.UNSIGNED_BYTE&&(a=n.RGB8UI),s===n.UNSIGNED_SHORT&&(a=n.RGB16UI),s===n.UNSIGNED_INT&&(a=n.RGB32UI),s===n.BYTE&&(a=n.RGB8I),s===n.SHORT&&(a=n.RGB16I),s===n.INT&&(a=n.RGB32I)),t===n.RGBA&&(s===n.FLOAT&&(a=n.RGBA32F),s===n.HALF_FLOAT&&(a=n.RGBA16F),s===n.UNSIGNED_BYTE&&(a=n.RGBA8),s===n.UNSIGNED_SHORT&&(a=n.RGBA16),s===n.UNSIGNED_INT&&(a=n.RGBA32UI),s===n.BYTE&&(a=n.RGBA8I),s===n.SHORT&&(a=n.RGBA16I),s===n.INT&&(a=n.RGBA32I),s===n.UNSIGNED_BYTE&&(a=i===Jt&&!1===r?n.SRGB8_ALPHA8:n.RGBA8),s===n.UNSIGNED_SHORT_4_4_4_4&&(a=n.RGBA4),s===n.UNSIGNED_SHORT_5_5_5_1&&(a=n.RGB5_A1)),t===n.RGBA_INTEGER&&(s===n.UNSIGNED_BYTE&&(a=n.RGBA8UI),s===n.UNSIGNED_SHORT&&(a=n.RGBA16UI),s===n.UNSIGNED_INT&&(a=n.RGBA32UI),s===n.BYTE&&(a=n.RGBA8I),s===n.SHORT&&(a=n.RGBA16I),s===n.INT&&(a=n.RGBA32I)),t===n.DEPTH_COMPONENT&&(s===n.UNSIGNED_INT&&(a=n.DEPTH24_STENCIL8),s===n.FLOAT&&(a=n.DEPTH_COMPONENT32F)),t===n.DEPTH_STENCIL&&s===n.UNSIGNED_INT_24_8&&(a=n.DEPTH24_STENCIL8),a!==n.R16F&&a!==n.R32F&&a!==n.RG16F&&a!==n.RG32F&&a!==n.RGBA16F&&a!==n.RGBA32F||o.get("EXT_color_buffer_float"),a}setTextureParameters(e,t){const{gl:s,extensions:i,backend:r}=this;s.texParameteri(e,s.TEXTURE_WRAP_S,tP[t.wrapS]),s.texParameteri(e,s.TEXTURE_WRAP_T,tP[t.wrapT]),e!==s.TEXTURE_3D&&e!==s.TEXTURE_2D_ARRAY||s.texParameteri(e,s.TEXTURE_WRAP_R,tP[t.wrapR]),s.texParameteri(e,s.TEXTURE_MAG_FILTER,sP[t.magFilter]);const n=void 0!==t.mipmaps&&t.mipmaps.length>0,o=t.minFilter===Te&&n?Se:t.minFilter;if(s.texParameteri(e,s.TEXTURE_MIN_FILTER,sP[o]),t.compareFunction&&(s.texParameteri(e,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(e,s.TEXTURE_COMPARE_FUNC,iP[t.compareFunction])),!0===i.has("EXT_texture_filter_anisotropic")){if(t.magFilter===fe)return;if(t.minFilter!==be&&t.minFilter!==Se)return;if(t.type===Ie&&!1===i.has("OES_texture_float_linear"))return;if(t.anisotropy>1){const n=i.get("EXT_texture_filter_anisotropic");s.texParameterf(e,n.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,r.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:s,defaultTextures:i}=this,r=this.getGLTextureType(e);let n=i[r];void 0===n&&(n=t.createTexture(),s.state.bindTexture(r,n),t.texParameteri(r,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(r,t.TEXTURE_MAG_FILTER,t.NEAREST),i[r]=n),s.set(e,{textureGPU:n,glTextureType:r,isDefault:!0})}createTexture(e,t){const{gl:s,backend:i}=this,{levels:r,width:n,height:o,depth:a}=t,h=i.utils.convert(e.format,e.colorSpace),l=i.utils.convert(e.type),u=this.getInternalFormat(e.internalFormat,h,l,e.colorSpace,e.isVideoTexture),c=s.createTexture(),d=this.getGLTextureType(e);i.state.bindTexture(d,c),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,e.flipY),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,e.premultiplyAlpha),s.pixelStorei(s.UNPACK_ALIGNMENT,e.unpackAlignment),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,s.NONE),this.setTextureParameters(d,e),e.isDataArrayTexture||e.isCompressedArrayTexture?s.texStorage3D(s.TEXTURE_2D_ARRAY,r,u,n,o,a):e.isData3DTexture?s.texStorage3D(s.TEXTURE_3D,r,u,n,o,a):e.isVideoTexture||s.texStorage2D(d,r,u,n,o),i.set(e,{textureGPU:c,glTextureType:d,glFormat:h,glType:l,glInternalFormat:u})}copyBufferToTexture(e,t){const{gl:s,backend:i}=this,{textureGPU:r,glTextureType:n,glFormat:o,glType:a}=i.get(t),{width:h,height:l}=t.source.data;s.bindBuffer(s.PIXEL_UNPACK_BUFFER,e),i.state.bindTexture(n,r),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,!1),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),s.texSubImage2D(n,0,0,0,h,l,o,a,0),s.bindBuffer(s.PIXEL_UNPACK_BUFFER,null),i.state.unbindTexture()}updateTexture(e,t){const{gl:s}=this,{width:i,height:r}=t,{textureGPU:n,glTextureType:o,glFormat:a,glType:h,glInternalFormat:l}=this.backend.get(e);if(e.isRenderTargetTexture||void 0===n)return;const u=e=>e.isDataTexture?e.image.data:e instanceof ImageBitmap||e instanceof OffscreenCanvas||e instanceof HTMLImageElement||e instanceof HTMLCanvasElement?e:e.data;if(this.backend.state.bindTexture(o,n),e.isCompressedTexture){const i=e.mipmaps,r=t.image;for(let t=0;t0){let a,h;!0===e.isDepthTexture?(a=s.DEPTH_BUFFER_BIT,h=s.DEPTH_ATTACHMENT,t.stencil&&(a|=s.STENCIL_BUFFER_BIT)):(a=s.COLOR_BUFFER_BIT,h=s.COLOR_ATTACHMENT0);const l=s.createFramebuffer();i.bindFramebuffer(s.DRAW_FRAMEBUFFER,l),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,h,s.TEXTURE_2D,r,0),s.blitFramebuffer(0,0,n,o,0,0,n,o,a,s.NEAREST),s.deleteFramebuffer(l)}else i.bindTexture(s.TEXTURE_2D,r),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,0,0,n,o),i.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t){const{gl:s}=this,i=t.renderTarget,{samples:r,depthTexture:n,depthBuffer:o,stencilBuffer:a,width:h,height:l}=i;if(s.bindRenderbuffer(s.RENDERBUFFER,e),o&&!a){let t=s.DEPTH_COMPONENT24;r>0?(n&&n.isDepthTexture&&n.type===s.FLOAT&&(t=s.DEPTH_COMPONENT32F),s.renderbufferStorageMultisample(s.RENDERBUFFER,r,t,h,l)):s.renderbufferStorage(s.RENDERBUFFER,t,h,l),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,e)}else o&&a&&(r>0?s.renderbufferStorageMultisample(s.RENDERBUFFER,r,s.DEPTH24_STENCIL8,h,l):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,h,l),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,e))}async copyTextureToBuffer(e,t,s,i,r){const{backend:n,gl:o}=this,{textureGPU:a,glFormat:h,glType:l}=this.backend.get(e),u=o.createFramebuffer();o.bindFramebuffer(o.READ_FRAMEBUFFER,u),o.framebufferTexture2D(o.READ_FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,a,0);const c=this._getTypedArrayType(l),d=i*r*this._getBytesPerTexel(h),p=o.createBuffer();o.bindBuffer(o.PIXEL_PACK_BUFFER,p),o.bufferData(o.PIXEL_PACK_BUFFER,d,o.STREAM_READ),o.readPixels(t,s,i,r,h,l,0),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),await n.utils._clientWaitAsync();const m=new c(d/c.BYTES_PER_ELEMENT);return o.bindBuffer(o.PIXEL_PACK_BUFFER,p),o.getBufferSubData(o.PIXEL_PACK_BUFFER,0,m),o.bindBuffer(o.PIXEL_PACK_BUFFER,null),o.deleteFramebuffer(u),m}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_5_5_1)return Uint16Array;if(e===t.UNSIGNED_SHORT_5_6_5)return Uint16Array;if(e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.FLOAT)return Float32Array;throw new Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e){const{gl:t}=this;return e===t.RGBA?4:e===t.RGB?3:e===t.ALPHA?1:void 0}}class oP{constructor(e){this.backend=e,this.gl=this.backend.gl,this.availableExtensions=this.gl.getSupportedExtensions(),this.extensions={}}get(e){let t=this.extensions[e];return void 0===t&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class aP{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(null!==this.maxAnisotropy)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(!0===t.has("EXT_texture_filter_anisotropic")){const s=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}const hP={WEBGL_multi_draw:"WEBGL_multi_draw",WEBGL_compressed_texture_astc:"texture-compression-astc",WEBGL_compressed_texture_etc:"texture-compression-etc2",WEBGL_compressed_texture_etc1:"texture-compression-etc1",WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBKIT_WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-bc",EXT_texture_compression_bptc:"texture-compression-bptc",EXT_disjoint_timer_query_webgl2:"timestamp-query"};class lP{constructor(e){this.gl=e.gl,this.extensions=e.extensions,this.info=e.renderer.info,this.mode=null,this.index=0,this.type=null,this.object=null}render(e,t){const{gl:s,mode:i,object:r,type:n,info:o,index:a}=this;0!==a?s.drawElements(i,t,n,e):s.drawArrays(i,e,t),o.update(r,t,i,1)}renderInstances(e,t,s){const{gl:i,mode:r,type:n,index:o,object:a,info:h}=this;0!==s&&(0!==o?i.drawElementsInstanced(r,t,n,e,s):i.drawArraysInstanced(r,e,t,s),h.update(a,t,r,s))}renderMultiDraw(e,t,s){const{extensions:i,mode:r,object:n,info:o}=this;if(0===s)return;const a=i.get("WEBGL_multi_draw");if(null===a)for(let i=0;i0)){const e=t.queryQueue.shift();this.initTimestampQuery(e)}}async resolveTimestampAsync(e,t="render"){if(!this.disjoint||!this.trackTimestamp)return;const s=this.get(e);s.gpuQueries||(s.gpuQueries=[]);for(let e=0;e0&&(s.currentOcclusionQueries=s.occlusionQueries,s.currentOcclusionQueryObjects=s.occlusionQueryObjects,s.lastOcclusionObject=null,s.occlusionQueries=new Array(i),s.occlusionQueryObjects=new Array(i),s.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:s}=this,i=this.get(e),r=i.previousContext,n=e.occlusionQueryCount;n>0&&(n>i.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const o=e.textures;if(null!==o)for(let e=0;e0){const r=i.framebuffers[e.getCacheKey()],n=t.COLOR_BUFFER_BIT,o=i.msaaFrameBuffer,a=e.textures;s.bindFramebuffer(t.READ_FRAMEBUFFER,o),s.bindFramebuffer(t.DRAW_FRAMEBUFFER,r);for(let s=0;s{let o=0;for(let t=0;t0&&e.add(i[t]),s[t]=null,r.deleteQuery(n),o++))}o1?f.renderInstances(m,y,x):f.render(m,y),o.bindVertexArray(null)}needsRenderUpdate(){return!1}getRenderCacheKey(){return""}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}copyTextureToBuffer(e,t,s,i,r){return this.textureUtils.copyTextureToBuffer(e,t,s,i,r)}createSampler(){}destroySampler(){}createNodeBuilder(e,t){return new GI(e,t)}createProgram(e){const t=this.gl,{stage:s,code:i}=e,r="fragment"===s?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);t.shaderSource(r,i),t.compileShader(r),this.set(e,{shaderGPU:r})}destroyProgram(){console.warn("Abstract class.")}createRenderPipeline(e,t){const s=this.gl,i=e.pipeline,{fragmentProgram:r,vertexProgram:n}=i,o=s.createProgram(),a=this.get(r).shaderGPU,h=this.get(n).shaderGPU;if(s.attachShader(o,a),s.attachShader(o,h),s.linkProgram(o),this.set(i,{programGPU:o,fragmentShader:a,vertexShader:h}),null!==t&&this.parallel){const r=new Promise((t=>{const r=this.parallel,n=()=>{s.getProgramParameter(o,r.COMPLETION_STATUS_KHR)?(this._completeCompile(e,i),t()):requestAnimationFrame(n)};n()}));t.push(r)}else this._completeCompile(e,i)}_handleSource(e,t){const s=e.split("\n"),i=[],r=Math.max(t-6,0),n=Math.min(t+6,s.length);for(let e=r;e":" "} ${r}: ${s[e]}`)}return i.join("\n")}_getShaderErrors(e,t,s){const i=e.getShaderParameter(t,e.COMPILE_STATUS),r=e.getShaderInfoLog(t).trim();if(i&&""===r)return"";const n=/ERROR: 0:(\d+)/.exec(r);if(n){const i=parseInt(n[1]);return s.toUpperCase()+"\n\n"+r+"\n\n"+this._handleSource(e.getShaderSource(t),i)}return r}_logProgramError(e,t,s){if(this.renderer.debug.checkShaderErrors){const i=this.gl,r=i.getProgramInfoLog(e).trim();if(!1===i.getProgramParameter(e,i.LINK_STATUS))if("function"==typeof this.renderer.debug.onShaderError)this.renderer.debug.onShaderError(i,e,s,t);else{const n=this._getShaderErrors(i,s,"vertex"),o=this._getShaderErrors(i,t,"fragment");console.error("THREE.WebGLProgram: Shader Error "+i.getError()+" - VALIDATE_STATUS "+i.getProgramParameter(e,i.VALIDATE_STATUS)+"\n\nProgram Info Log: "+r+"\n"+n+"\n"+o)}else""!==r&&console.warn("THREE.WebGLProgram: Program Info Log:",r)}}_completeCompile(e,t){const{state:s,gl:i}=this,r=this.get(t),{programGPU:n,fragmentShader:o,vertexShader:a}=r;!1===i.getProgramParameter(n,i.LINK_STATUS)&&this._logProgramError(n,o,a),s.useProgram(n);const h=e.getBindings();this._setupBindings(h,n),this.set(t,{programGPU:n})}createComputePipeline(e,t){const{state:s,gl:i}=this,r={stage:"fragment",code:"#version 300 es\nprecision highp float;\nvoid main() {}"};this.createProgram(r);const{computeProgram:n}=e,o=i.createProgram(),a=this.get(r).shaderGPU,h=this.get(n).shaderGPU,l=n.transforms,u=[],c=[];for(let e=0;ehP[t]===e)),s=this.extensions;for(let e=0;e0){if(void 0===u){const i=[];u=t.createFramebuffer(),s.bindFramebuffer(t.FRAMEBUFFER,u);const r=[],l=e.textures;for(let s=0;s,\n\t@location( 0 ) vTex : vec2\n};\n\n@vertex\nfn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct {\n\n\tvar Varys : VarysStruct;\n\n\tvar pos = array< vec2, 4 >(\n\t\tvec2( -1.0, 1.0 ),\n\t\tvec2( 1.0, 1.0 ),\n\t\tvec2( -1.0, -1.0 ),\n\t\tvec2( 1.0, -1.0 )\n\t);\n\n\tvar tex = array< vec2, 4 >(\n\t\tvec2( 0.0, 0.0 ),\n\t\tvec2( 1.0, 0.0 ),\n\t\tvec2( 0.0, 1.0 ),\n\t\tvec2( 1.0, 1.0 )\n\t);\n\n\tVarys.vTex = tex[ vertexIndex ];\n\tVarys.Position = vec4( pos[ vertexIndex ], 0.0, 1.0 );\n\n\treturn Varys;\n\n}\n"}),this.mipmapFragmentShaderModule=e.createShaderModule({label:"mipmapFragment",code:"\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img : texture_2d;\n\n@fragment\nfn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img, imgSampler, vTex );\n\n}\n"}),this.flipYFragmentShaderModule=e.createShaderModule({label:"flipYFragment",code:"\n@group( 0 ) @binding( 0 )\nvar imgSampler : sampler;\n\n@group( 0 ) @binding( 1 )\nvar img : texture_2d;\n\n@fragment\nfn main( @location( 0 ) vTex : vec2 ) -> @location( 0 ) vec4 {\n\n\treturn textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) );\n\n}\n"})}getTransferPipeline(e){let t=this.transferPipelines[e];return void 0===t&&(t=this.device.createRenderPipeline({label:`mipmap-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.mipmapFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:yA,stripIndexFormat:FA},layout:"auto"}),this.transferPipelines[e]=t),t}getFlipYPipeline(e){let t=this.flipYPipelines[e];return void 0===t&&(t=this.device.createRenderPipeline({label:`flipY-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.flipYFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:yA,stripIndexFormat:FA},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,s=0){const i=t.format,{width:r,height:n}=t.size,o=this.getTransferPipeline(i),a=this.getFlipYPipeline(i),h=this.device.createTexture({size:{width:r,height:n,depthOrArrayLayers:1},format:i,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),l=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:AN,baseArrayLayer:s}),u=h.createView({baseMipLevel:0,mipLevelCount:1,dimension:AN,baseArrayLayer:0}),c=this.device.createCommandEncoder({}),d=(e,t,s)=>{const i=e.getBindGroupLayout(0),r=this.device.createBindGroup({layout:i,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:t}]}),n=c.beginRenderPass({colorAttachments:[{view:s,loadOp:RA,storeOp:AA,clearValue:[0,0,0,0]}]});n.setPipeline(e),n.setBindGroup(0,r),n.draw(4,1,0,0),n.end()};d(o,l,u),d(a,u,l),this.device.queue.submit([c.finish()]),h.destroy()}generateMipmaps(e,t,s=0){const i=this.get(e);void 0===i.useCount&&(i.useCount=0,i.layers=[]);const r=i.layers[s]||this._mipmapCreateBundles(e,t,s),n=this.device.createCommandEncoder({});this._mipmapRunBundles(n,r),this.device.queue.submit([n.finish()]),0!==i.useCount&&(i.layers[s]=r),i.useCount++}_mipmapCreateBundles(e,t,s){const i=this.getTransferPipeline(t.format),r=i.getBindGroupLayout(0);let n=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:AN,baseArrayLayer:s});const o=[];for(let a=1;a1&&!e.isMultisampleRenderTargetTexture){const e=Object.assign({},p);e.label=e.label+"-msaa",e.sampleCount=u,i.msaaTexture=s.device.createTexture(e)}i.initialized=!0,i.textureDescriptorGPU=p}destroyTexture(e){const t=this.backend,s=t.get(e);s.texture.destroy(),void 0!==s.msaaTexture&&s.msaaTexture.destroy(),t.delete(e)}destroySampler(e){delete this.backend.get(e).sampler}generateMipmaps(e){const t=this.backend.get(e);if(e.isCubeTexture)for(let e=0;e<6;e++)this._generateMipmaps(t.texture,t.textureDescriptorGPU,e);else{const s=e.image.depth||1;for(let e=0;e1;for(let o=0;o]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,_P=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/gi,wP={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2":"vec2","vec2":"ivec2","vec2":"uvec2","vec2":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3":"vec3","vec3":"ivec3","vec3":"uvec3","vec3":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4":"vec4","vec4":"ivec4","vec4":"uvec4","vec4":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2":"mat2",mat2x2f:"mat2","mat3x3":"mat3",mat3x3f:"mat3","mat4x4":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_3d:"texture3D",texture_cube:"cubeTexture",texture_cube_array:"cubeTexture",texture_storage_1d:"storageTexture",texture_storage_2d:"storageTexture",texture_storage_2d_array:"storageTexture",texture_storage_3d:"storageTexture"};class SP extends ZC{constructor(e){const{type:t,inputs:s,name:i,inputsCode:r,blockCode:n,outputType:o}=(e=>{const t=(e=e.trim()).match(TP);if(null!==t&&4===t.length){const s=t[2],i=[];let r=null;for(;null!==(r=_P.exec(s));)i.push({name:r[1],type:r[2]});const n=[];for(let e=0;e "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class MP extends JC{parseFunction(e){return new SP(e)}}const AP=self.GPUShaderStage,NP={vertex:AP?AP.VERTEX:1,fragment:AP?AP.FRAGMENT:2,compute:AP?AP.COMPUTE:4},RP={instance:!0,swizzleAssign:!1,storageBuffer:!0},CP={"^^":"tsl_xor"},EP={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3",vec2:"vec2",ivec2:"vec2",uvec2:"vec2",bvec2:"vec2",vec3:"vec3",ivec3:"vec3",uvec3:"vec3",bvec3:"vec3",vec4:"vec4",ivec4:"vec4",uvec4:"vec4",bvec4:"vec4",mat2:"mat2x2",imat2:"mat2x2",umat2:"mat2x2",bmat2:"mat2x2",mat3:"mat3x3",imat3:"mat3x3",umat3:"mat3x3",bmat3:"mat3x3",mat4:"mat4x4",imat4:"mat4x4",umat4:"mat4x4",bmat4:"mat4x4"},BP={tsl_xor:new lS("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new lS("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new lS("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new lS("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new lS("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new lS("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new lS("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2 { return vec2( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new lS("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3 { return vec3( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new lS("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4 { return vec4( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping:new lS("\nfn tsl_repeatWrapping( uv : vec2, dimension : vec2 ) -> vec2 {\n\n\tlet uvScaled = vec2( uv * vec2( dimension ) );\n\n\treturn ( ( uvScaled % dimension ) + dimension ) % dimension;\n\n}\n"),biquadraticTexture:new lS("\nfn tsl_biquadraticTexture( map : texture_2d, coord : vec2f, level : i32 ) -> vec4f {\n\n\tlet res = vec2f( textureDimensions( map, level ) );\n\n\tlet uvScaled = coord * res;\n\tlet uvWrapping = ( ( uvScaled % res ) + res ) % res;\n\n\t// https://www.shadertoy.com/view/WtyXRy\n\n\tlet uv = uvWrapping - 0.5;\n\tlet iuv = floor( uv );\n\tlet f = fract( uv );\n\n\tlet rg1 = textureLoad( map, vec2i( iuv + vec2( 0.5, 0.5 ) ), level );\n\tlet rg2 = textureLoad( map, vec2i( iuv + vec2( 1.5, 0.5 ) ), level );\n\tlet rg3 = textureLoad( map, vec2i( iuv + vec2( 0.5, 1.5 ) ), level );\n\tlet rg4 = textureLoad( map, vec2i( iuv + vec2( 1.5, 1.5 ) ), level );\n\n\treturn mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );\n\n}\n")},IP={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast"};/Windows/g.test(navigator.userAgent)&&(BP.pow_float=new lS("fn tsl_pow_float( a : f32, b : f32 ) -> f32 { return select( -pow( -a, b ), pow( a, b ), a > 0.0 ); }"),BP.pow_vec2=new lS("fn tsl_pow_vec2( a : vec2f, b : vec2f ) -> vec2f { return vec2f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ) ); }",[BP.pow_float]),BP.pow_vec3=new lS("fn tsl_pow_vec3( a : vec3f, b : vec3f ) -> vec3f { return vec3f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ) ); }",[BP.pow_float]),BP.pow_vec4=new lS("fn tsl_pow_vec4( a : vec4f, b : vec4f ) -> vec4f { return vec4f( tsl_pow_float( a.x, b.x ), tsl_pow_float( a.y, b.y ), tsl_pow_float( a.z, b.z ), tsl_pow_float( a.w, b.w ) ); }",[BP.pow_float]),IP.pow_float="tsl_pow_float",IP.pow_vec2="tsl_pow_vec2",IP.pow_vec3="tsl_pow_vec3",IP.pow_vec4="tsl_pow_vec4");class PP extends aM{constructor(e,t){super(e,t,new MP),this.uniformGroups={},this.builtins={},this.directives={}}needsColorSpaceToLinearSRGB(e){return!0===e.isVideoTexture&&""!==e.colorSpace}_generateTextureSample(e,t,s,i,r=this.shaderStage){return"fragment"===r?i?`textureSample( ${t}, ${t}_sampler, ${s}, ${i} )`:`textureSample( ${t}, ${t}_sampler, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,s):this.generateTextureLod(e,t,s,"0")}_generateVideoSample(e,t,s=this.shaderStage){if("fragment"===s)return`textureSampleBaseClampToEdge( ${e}, ${e}_sampler, vec2( ${t}.x, 1.0 - ${t}.y ) )`;console.error(`WebGPURenderer: THREE.VideoTexture does not support ${s} shader.`)}_generateTextureSampleLevel(e,t,s,i,r,n=this.shaderStage){return"fragment"===n&&!1===this.isUnfilterable(e)?`textureSampleLevel( ${t}, ${t}_sampler, ${s}, ${i} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,s,i):this.generateTextureLod(e,t,s,i)}generateFilteredTexture(e,t,s,i="0"){return this._include("biquadraticTexture"),`tsl_biquadraticTexture( ${t}, ${s}, i32( ${i} ) )`}generateTextureLod(e,t,s,i="0"){this._include("repeatWrapping");return`textureLoad( ${t}, tsl_repeatWrapping( ${s}, ${!0===e.isMultisampleRenderTargetTexture?`textureDimensions( ${t} )`:`textureDimensions( ${t}, 0 )`} ), i32( ${i} ) )`}generateTextureLoad(e,t,s,i,r="0u"){return i?`textureLoad( ${t}, ${s}, ${i}, ${r} )`:`textureLoad( ${t}, ${s}, ${r} )`}generateTextureStore(e,t,s,i){return`textureStore( ${t}, ${s}, ${i} )`}isUnfilterable(e){return"float"!==this.getComponentTypeFromTexture(e)||!this.isAvailable("float32Filterable")&&!0===e.isDataTexture&&e.type===Ie||!0===e.isMultisampleRenderTargetTexture}generateTexture(e,t,s,i,r=this.shaderStage){let n=null;return n=!0===e.isVideoTexture?this._generateVideoSample(t,s,r):this.isUnfilterable(e)?this.generateTextureLod(e,t,s,"0",i,r):this._generateTextureSample(e,t,s,i,r),n}generateTextureGrad(e,t,s,i,r,n=this.shaderStage){if("fragment"===n)return`textureSampleGrad( ${t}, ${t}_sampler, ${s}, ${i[0]}, ${i[1]} )`;console.error(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${n} shader.`)}generateTextureCompare(e,t,s,i,r,n=this.shaderStage){if("fragment"===n)return`textureSampleCompare( ${t}, ${t}_sampler, ${s}, ${i} )`;console.error(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${n} shader.`)}generateTextureLevel(e,t,s,i,r,n=this.shaderStage){let o=null;return o=!0===e.isVideoTexture?this._generateVideoSample(t,s,n):this._generateTextureSampleLevel(e,t,s,i,r,n),o}generateTextureBias(e,t,s,i,r,n=this.shaderStage){if("fragment"===n)return`textureSampleBias( ${t}, ${t}_sampler, ${s}, ${i} )`;console.error(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${n} shader.`)}getPropertyName(e,t=this.shaderStage){if(!0===e.isNodeVarying&&!0===e.needsInterpolation){if("vertex"===t)return`varyings.${e.name}`}else if(!0===e.isNodeUniform){const t=e.name,s=e.type;return"texture"===s||"cubeTexture"===s||"storageTexture"===s||"texture3D"===s?t:"buffer"===s||"storageBuffer"===s?`NodeBuffer_${e.id}.${t}`:e.groupNode.name+"."+t}return super.getPropertyName(e)}getOutputStructName(){return"output"}_getUniformGroupCount(e){return Object.keys(this.uniforms[e]).length}getFunctionOperator(e){const t=CP[e];return void 0!==t?(this._include(t),t):null}getStorageAccess(e){if(e.isStorageTextureNode)switch(e.access){case xN:return"read";case yN:return"write";default:return"read_write"}else switch(e.access){case gN:return"read_write";case fN:return"read";default:return"write"}}getUniformFromNode(e,t,s,i=null){const r=super.getUniformFromNode(e,t,s,i),n=this.getDataFromNode(e,s,this.globalCache);if(void 0===n.uniformGPU){let i;const o=e.groupNode,a=o.name,h=this.getBindGroupArray(a,s);if("texture"===t||"cubeTexture"===t||"storageTexture"===t||"texture3D"===t){let n=null;if("texture"===t||"storageTexture"===t?n=new zI(r.name,r.node,o,e.access?e.access:null):"cubeTexture"===t?n=new UI(r.name,r.node,o,e.access?e.access:null):"texture3D"===t&&(n=new LI(r.name,r.node,o,e.access?e.access:null)),n.store=!0===e.isStorageTextureNode,n.setVisibility(NP[s]),"fragment"===s&&!1===this.isUnfilterable(e.value)&&!1===n.store){const e=new dP(`${r.name}_sampler`,r.node,o);e.setVisibility(NP[s]),h.push(e,n),i=[e,n]}else h.push(n),i=[n]}else if("buffer"===t||"storageBuffer"===t){const r=new("storageBuffer"===t?gP:CI)(e,o);r.setVisibility(NP[s]),h.push(r),i=r}else{const e=this.uniformGroups[s]||(this.uniformGroups[s]={});let n=e[a];void 0===n&&(n=new II(a,o),n.setVisibility(NP[s]),e[a]=n,h.push(n)),i=this.getNodeUniform(r,t),n.addUniform(i)}n.uniformGPU=i}return r}getBuiltin(e,t,s,i=this.shaderStage){const r=this.builtins[i]||(this.builtins[i]=new Map);return!1===r.has(e)&&r.set(e,{name:e,property:t,type:s}),t}getVertexIndex(){return"vertex"===this.shaderStage?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,s=this.flowShaderNode(e),i=[];for(const e of t.inputs)i.push(e.name+" : "+this.getType(e.type));let r=`fn ${t.name}( ${i.join(", ")} ) -> ${this.getType(t.type)} {\n${s.vars}\n${s.code}\n`;return s.result&&(r+=`\treturn ${s.result};\n`),r+="\n}\n",r}getInstanceIndex(){return"vertex"===this.shaderStage?this.getBuiltin("instance_index","instanceIndex","u32","attribute"):"instanceIndex"}getInvocationLocalIndex(){return this.getBuiltin("local_invocation_index","invocationLocalIndex","u32","attribute")}getSubgroupSize(){return this.enableSubGroups(),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],s=this.directives[e];if(void 0!==s)for(const e of s)t.push(`enable ${e};`);return t.join("\n")}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}getBuiltins(e){const t=[],s=this.builtins[e];if(void 0!==s)for(const{name:e,property:i,type:r}of s.values())t.push(`@builtin( ${e} ) ${i} : ${r}`);return t.join(",\n\t")}getAttributes(e){const t=[];if("compute"===e&&(this.getBuiltin("global_invocation_id","id","vec3","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3","attribute"),this.getBuiltin("local_invocation_id","localId","vec3","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3","attribute")),"vertex"===e||"compute"===e){const e=this.getBuiltins("attribute");e&&t.push(e);const s=this.getAttributesArray();for(let e=0,i=s.length;e`)}const i=this.getBuiltins("output");return i&&t.push("\t"+i),t.join(",\n")}getStructs(e){const t=[],s=this.structs[e];for(let e=0,i=s.length;e output : ${r};\n\n`)}return t.join("\n\n")}getVar(e,t){return`var ${t} : ${this.getType(e)}`}getVars(e){const t=[],s=this.vars[e];if(void 0!==s)for(const e of s)t.push(`\t${this.getVar(e.type,e.name)};`);return`\n${t.join("\n")}\n`}getVaryings(e){const t=[];if("vertex"===e&&this.getBuiltin("position","Vertex","vec4","vertex"),"vertex"===e||"fragment"===e){const s=this.varyings,i=this.vars[e];for(let r=0;r";else if(!0===t.isDataArrayTexture||!0===t.isCompressedArrayTexture)i="texture_2d_array";else if(!0===t.isDepthTexture)i=`texture_depth${n}_2d`;else if(!0===t.isVideoTexture)i="texture_external";else if(!0===t.isData3DTexture)i="texture_3d";else if(!0===r.node.isStorageTextureNode){i=`texture_storage_2d<${vP(t)}, ${this.getStorageAccess(r.node)}>`}else{i=`texture${n}_2d<${this.getComponentTypeFromTexture(t).charAt(0)}32>`}s.push(`@binding( ${o.binding++} ) @group( ${o.group} ) var ${r.name} : ${i};`)}else if("buffer"===r.type||"storageBuffer"===r.type){const e=r.node,t=this.getType(e.bufferType),s=e.bufferCount,n=s>0?", "+s:"",a=`\t${r.name} : array< ${t}${n} >\n`,h=e.isStorageBufferNode?`storage, ${this.getStorageAccess(e)}`:"uniform";i.push(this._getWGSLStructBinding("NodeBuffer_"+e.id,a,h,o.binding++,o.group))}else{const e=this.getType(this.getVectorType(r.type)),t=r.groupNode.name;(n[t]||(n[t]={index:o.binding++,id:o.group,snippets:[]})).snippets.push(`\t${r.name} : ${e}`)}}for(const e in n){const t=n[e];r.push(this._getWGSLStructBinding(e,t.snippets.join(",\n"),"uniform",t.index,t.id))}let o=s.join("\n");return o+=i.join("\n"),o+=r.join("\n"),o}buildCode(){const e=null!==this.material?{fragment:{},vertex:{}}:{compute:{}};for(const t in e){const s=e[t];s.uniforms=this.getUniforms(t),s.attributes=this.getAttributes(t),s.varyings=this.getVaryings(t),s.structs=this.getStructs(t),s.vars=this.getVars(t),s.codes=this.getCodes(t),s.directives=this.getDirectives(t);let i="// code\n\n";i+=this.flowCode[t];const r=this.flowNodes[t],n=r[r.length-1],o=n.outputNode,a=void 0!==o&&!0===o.isOutputStructNode;for(const e of r){const r=this.getFlowData(e),h=e.name;if(h&&(i.length>0&&(i+="\n"),i+=`\t// flow -> ${h}\n\t`),i+=`${r.code}\n\t`,e===n&&"compute"!==t)if(i+="// result\n\n\t","vertex"===t)i+=`varyings.Vertex = ${r.result};`;else if("fragment"===t)if(a)s.returnType=o.nodeType,i+=`return ${r.result};`;else{let e="\t@location(0) color: vec4";const t=this.getBuiltins("output");t&&(e+=",\n\t"+t),s.returnType="OutputStruct",s.structs+=this._getWGSLStruct("OutputStruct",e),s.structs+="\nvar output : OutputStruct;\n\n",i+=`output.color = ${r.result};\n\n\treturn output;`}}s.flow=i}null!==this.material?(this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment)):this.computeShader=this._getWGSLComputeCode(e.compute,(this.object.workgroupSize||[64]).join(", "))}getMethod(e,t=null){let s;return null!==t&&(s=this._getWGSLMethod(e+"_"+t)),void 0===s&&(s=this._getWGSLMethod(e)),s||e}getType(e){return EP[e]||e}isAvailable(e){let t=RP[e];return void 0===t&&("float32Filterable"===e&&(t=this.renderer.hasFeature("float32-filterable")),RP[e]=t),t}_getWGSLMethod(e){return void 0!==BP[e]&&this._include(e),IP[e]}_include(e){const t=BP[e];return t.build(this),null!==this.currentFunctionNode&&this.currentFunctionNode.includes.push(t),t}_getWGSLVertexCode(e){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// uniforms\n${e.uniforms}\n\n// varyings\n${e.varyings}\nvar varyings : VaryingsStruct;\n\n// codes\n${e.codes}\n\n@vertex\nfn main( ${e.attributes} ) -> VaryingsStruct {\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n\treturn varyings;\n\n}\n`}_getWGSLFragmentCode(e){return`${this.getSignature()}\n\ndiagnostic( off, derivative_uniformity );\n\n// uniforms\n${e.uniforms}\n\n// structs\n${e.structs}\n\n// codes\n${e.codes}\n\n@fragment\nfn main( ${e.varyings} ) -> ${e.returnType} {\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLComputeCode(e,t){return`${this.getSignature()}\n// directives\n${e.directives}\n\n// system\nvar instanceIndex : u32;\n\n// uniforms\n${e.uniforms}\n\n// codes\n${e.codes}\n\n@compute @workgroup_size( ${t} )\nfn main( ${e.attributes} ) {\n\n\t// system\n\tinstanceIndex = id.x + id.y * numWorkgroups.x * u32(${t}) + id.z * numWorkgroups.x * numWorkgroups.y * u32(${t});\n\n\t// vars\n\t${e.vars}\n\n\t// flow\n\t${e.flow}\n\n}\n`}_getWGSLStruct(e,t){return`\nstruct ${e} {\n${t}\n};`}_getWGSLStructBinding(e,t,s,i=0,r=0){const n=e+"Struct";return`${this._getWGSLStruct(n,t)}\n@binding( ${i} ) @group( ${r} )\nvar<${s}> ${e} : ${n};`}}class FP{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return null!==e.depthTexture?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=zA.Depth24PlusStencil8:e.depth&&(t=zA.Depth24Plus),t}getTextureFormatGPU(e){return this.backend.get(e).texture.format}getCurrentColorFormat(e){let t;return t=null!==e.textures?this.getTextureFormatGPU(e.textures[0]):this.getPreferredCanvasFormat(),t}getCurrentColorSpace(e){return null!==e.textures?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){return e.isPoints?pA:e.isLineSegments||e.isMesh&&!0===t.wireframe?mA:e.isLine?gA:e.isMesh?fA:void 0}getSampleCount(e){let t=1;return e>1&&(t=Math.pow(2,Math.floor(Math.log2(e))),2===t&&(t=4)),t}getSampleCountRenderContext(e){return null!==e.textures?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.samples)}getPreferredCanvasFormat(){return navigator.userAgent.includes("Quest")?zA.BGRA8Unorm:navigator.gpu.getPreferredCanvasFormat()}}const zP=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]),UP=new Map([[fn,["float16"]]]),LP=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class OP{constructor(e){this.backend=e}createAttribute(e,t){const s=this._getBufferAttribute(e),i=this.backend,r=i.get(s);let n=r.buffer;if(void 0===n){const o=i.device;let a=s.array;if(!1===e.normalized&&(a.constructor===Int16Array||a.constructor===Uint16Array)){const e=new Uint32Array(a.length);for(let t=0;t{l.createRenderPipelineAsync(M).then((t=>{c.pipeline=t,e()}))}));t.push(e)}}createBundleEncoder(e){const t=this.backend,{utils:s,device:i}=t,r=s.getCurrentDepthStencilFormat(e),n={label:"renderBundleEncoder",colorFormats:[s.getCurrentColorFormat(e)],depthStencilFormat:r,sampleCount:this._getSampleCount(e)};return i.createRenderBundleEncoder(n)}createComputePipeline(e,t){const s=this.backend,i=s.device,r=s.get(e.computeProgram).module,n=s.get(e),o=[];for(const e of t){const t=s.get(e);o.push(t.layout)}n.pipeline=i.createComputePipeline({compute:r,layout:i.createPipelineLayout({bindGroupLayouts:o})})}_getBlending(e){let t,s;const i=e.blending,r=e.blendSrc,n=e.blendDst,o=e.blendEquation;if(5===i){const i=null!==e.blendSrcAlpha?e.blendSrcAlpha:r,a=null!==e.blendDstAlpha?e.blendDstAlpha:n,h=null!==e.blendEquationAlpha?e.blendEquationAlpha:o;t={srcFactor:this._getBlendFactor(r),dstFactor:this._getBlendFactor(n),operation:this._getBlendOperation(o)},s={srcFactor:this._getBlendFactor(i),dstFactor:this._getBlendFactor(a),operation:this._getBlendOperation(h)}}else{const r=(e,i,r,n)=>{t={srcFactor:e,dstFactor:i,operation:eN},s={srcFactor:r,dstFactor:n,operation:eN}};if(e.premultipliedAlpha)switch(i){case 1:r(GA,qA,GA,qA);break;case 2:r(GA,GA,GA,GA);break;case 3:r(kA,HA,kA,GA);break;case 4:r(kA,WA,kA,jA)}else switch(i){case 1:r(jA,qA,GA,qA);break;case 2:r(jA,GA,jA,GA);break;case 3:r(kA,HA,kA,GA);break;case 4:r(kA,WA,kA,WA)}}if(void 0!==t&&void 0!==s)return{color:t,alpha:s};console.error("THREE.WebGPURenderer: Invalid blending: ",i)}_getBlendFactor(e){let t;switch(e){case 200:t=kA;break;case 201:t=GA;break;case 202:t=WA;break;case 203:t=HA;break;case C:t=jA;break;case E:t=qA;break;case 208:t=$A;break;case 209:t=XA;break;case 206:t=YA;break;case 207:t=JA;break;case 210:t=ZA;break;case 211:t=KA;break;case 212:t=QA;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const s=e.stencilFunc;switch(s){case 512:t=xA;break;case bs:t=MA;break;case 513:t=bA;break;case 515:t=TA;break;case 514:t=vA;break;case 518:t=SA;break;case 516:t=_A;break;case 517:t=wA;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",s)}return t}_getStencilOperation(e){let t;switch(e){case ns:t=aN;break;case 0:t=hN;break;case 7681:t=lN;break;case 5386:t=uN;break;case 7682:t=cN;break;case 7683:t=dN;break;case 34055:t=pN;break;case 34056:t=mN;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case v:t=eN;break;case 101:t=tN;break;case 102:t=sN;break;case 103:t=iN;break;case 104:t=rN;break;default:console.error("THREE.WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,s){const i={},r=this.backend.utils;switch(i.topology=r.getPrimitiveTopology(e,s),null!==t.index&&!0===e.isLine&&!0!==e.isLineSegments&&(i.stripIndexFormat=t.index.array instanceof Uint16Array?PA:FA),s.side){case c:i.frontFace=CA,i.cullMode=IA;break;case d:i.frontFace=CA,i.cullMode=BA;break;case 2:i.frontFace=CA,i.cullMode=EA;break;default:console.error("THREE.WebGPUPipelineUtils: Unknown material.side value.",s.side)}return i}_getColorWriteMask(e){return!0===e.colorWrite?oN:nN}_getDepthCompare(e){let t;if(!1===e.depthTest)t=MA;else{const s=e.depthFunc;switch(s){case 0:t=xA;break;case 1:t=MA;break;case 2:t=bA;break;case 3:t=TA;break;case 4:t=vA;break;case 5:t=SA;break;case 6:t=_A;break;case 7:t=wA;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",s)}}return t}}class kP extends qI{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=void 0===e.alpha||e.alpha,this.parameters.requiredLimits=void 0===e.requiredLimits?{}:e.requiredLimits,this.trackTimestamp=!0===e.trackTimestamp,this.device=null,this.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new FP(this),this.attributeUtils=new OP(this),this.bindingUtils=new VP(this),this.pipelineUtils=new DP(this),this.textureUtils=new bP(this),this.occludedResolveCache=new Map}async init(e){await super.init(e);const t=this.parameters;let s;if(void 0===t.device){const e={powerPreference:t.powerPreference},i=await navigator.gpu.requestAdapter(e);if(null===i)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const r=Object.values(PN),n=[];for(const e of r)i.features.has(e)&&n.push(e);const o={requiredFeatures:n,requiredLimits:t.requiredLimits};s=await i.requestDevice(o)}else s=t.device;const i=void 0!==t.context?t.context:e.domElement.getContext("webgpu");this.device=s,this.context=i;const r=t.alpha?"premultiplied":"opaque";this.trackTimestamp=this.trackTimestamp&&this.hasFeature(PN.TimestampQuery),this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:r}),this.updateSize()}get coordinateSystem(){return Ds}async getArrayBufferAsync(e){return await this.attributeUtils.getArrayBufferAsync(e)}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(null===e){const t=this.renderer;e={colorAttachments:[{view:null}],depthStencilAttachment:{view:this.textureUtils.getDepthBuffer(t.depth,t.stencil).createView()}};const s=e.colorAttachments[0];this.renderer.samples>0?s.view=this.colorBuffer.createView():s.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}const t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_getRenderPassDescriptor(e){const t=e.renderTarget,s=this.get(t);let i=s.descriptors;if(void 0===i||s.width!==t.width||s.height!==t.height||s.activeMipmapLevel!==t.activeMipmapLevel||s.samples!==t.samples){i={},s.descriptors=i;const e=()=>{t.removeEventListener("dispose",e),this.delete(t)};t.addEventListener("dispose",e)}const r=e.getCacheKey();let n=i[r];if(void 0===n){const o=e.textures,a=[];for(let t=0;t0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,r=s.createQuerySet({type:"occlusion",count:i}),t.occlusionQuerySet=r,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(i),t.lastOcclusionObject=null),n=null===e.textures?this._getDefaultRenderPassDescriptor():this._getRenderPassDescriptor(e),this.initTimestampQuery(e,n),n.occlusionQuerySet=r;const o=n.depthStencilAttachment;if(null!==e.textures){const t=n.colorAttachments;for(let s=0;s0&&t.currentPass.executeBundles(t.renderBundles),s>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery(),t.currentPass.end(),s>0){const i=8*s;let r=this.occludedResolveCache.get(i);void 0===r&&(r=this.device.createBuffer({size:i,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(i,r));const n=this.device.createBuffer({size:i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,s,r,0),t.encoder.copyBufferToBuffer(r,0,n,0,i),t.occlusionQueryBuffer=n,this.resolveOccludedAsync(e)}if(this.prepareTimestampBuffer(e,t.encoder),this.device.queue.submit([t.encoder.finish()]),null!==e.textures){const t=e.textures;for(let e=0;eo?(h.x=Math.min(t.dispatchCount,o),h.y=Math.ceil(t.dispatchCount/o)):h.x=t.dispatchCount,r.dispatchWorkgroups(h.x,h.y,h.z)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.prepareTimestampBuffer(e,t.cmdEncoderGPU),this.device.queue.submit([t.cmdEncoderGPU.finish()])}draw(e,t){const{object:s,geometry:i,context:r,pipeline:n}=e,o=e.getBindings(),a=this.get(r),h=this.get(n).pipeline,l=a.currentSets,u=a.currentPass;l.pipeline!==h&&(u.setPipeline(h),l.pipeline=h);for(let e=0,t=o.length;e1?0:s;u.drawIndexed(t[s],i,e[s]/n,0,o)}}else if(!0===d){const e=m.count!==1/0?m.count:c.count;u.drawIndexed(e,f,g,0,0),t.update(s,e,f)}else{const e=i.attributes.position,r=m.count!==1/0?m.count:e.count;u.draw(r,f,g,0),t.update(s,r,f)}}needsRenderUpdate(e){const t=this.get(e),{object:s,material:i}=e,r=this.utils,n=r.getSampleCountRenderContext(e.context),o=r.getCurrentColorSpace(e.context),a=r.getCurrentColorFormat(e.context),h=r.getCurrentDepthStencilFormat(e.context),l=r.getPrimitiveTopology(s,i);let u=!1;return t.material===i&&t.materialVersion===i.version&&t.transparent===i.transparent&&t.blending===i.blending&&t.premultipliedAlpha===i.premultipliedAlpha&&t.blendSrc===i.blendSrc&&t.blendDst===i.blendDst&&t.blendEquation===i.blendEquation&&t.blendSrcAlpha===i.blendSrcAlpha&&t.blendDstAlpha===i.blendDstAlpha&&t.blendEquationAlpha===i.blendEquationAlpha&&t.colorWrite===i.colorWrite&&t.depthWrite===i.depthWrite&&t.depthTest===i.depthTest&&t.depthFunc===i.depthFunc&&t.stencilWrite===i.stencilWrite&&t.stencilFunc===i.stencilFunc&&t.stencilFail===i.stencilFail&&t.stencilZFail===i.stencilZFail&&t.stencilZPass===i.stencilZPass&&t.stencilFuncMask===i.stencilFuncMask&&t.stencilWriteMask===i.stencilWriteMask&&t.side===i.side&&t.alphaToCoverage===i.alphaToCoverage&&t.sampleCount===n&&t.colorSpace===o&&t.colorFormat===a&&t.depthStencilFormat===h&&t.primitiveTopology===l&&t.clippingContextCacheKey===e.clippingContext.cacheKey||(t.material=i,t.materialVersion=i.version,t.transparent=i.transparent,t.blending=i.blending,t.premultipliedAlpha=i.premultipliedAlpha,t.blendSrc=i.blendSrc,t.blendDst=i.blendDst,t.blendEquation=i.blendEquation,t.blendSrcAlpha=i.blendSrcAlpha,t.blendDstAlpha=i.blendDstAlpha,t.blendEquationAlpha=i.blendEquationAlpha,t.colorWrite=i.colorWrite,t.depthWrite=i.depthWrite,t.depthTest=i.depthTest,t.depthFunc=i.depthFunc,t.stencilWrite=i.stencilWrite,t.stencilFunc=i.stencilFunc,t.stencilFail=i.stencilFail,t.stencilZFail=i.stencilZFail,t.stencilZPass=i.stencilZPass,t.stencilFuncMask=i.stencilFuncMask,t.stencilWriteMask=i.stencilWriteMask,t.side=i.side,t.alphaToCoverage=i.alphaToCoverage,t.sampleCount=n,t.colorSpace=o,t.colorFormat=a,t.depthStencilFormat=h,t.primitiveTopology=l,t.clippingContextCacheKey=e.clippingContext.cacheKey,u=!0),u}getRenderCacheKey(e){const{object:t,material:s}=e,i=this.utils,r=e.context;return[s.transparent,s.blending,s.premultipliedAlpha,s.blendSrc,s.blendDst,s.blendEquation,s.blendSrcAlpha,s.blendDstAlpha,s.blendEquationAlpha,s.colorWrite,s.depthWrite,s.depthTest,s.depthFunc,s.stencilWrite,s.stencilFunc,s.stencilFail,s.stencilZFail,s.stencilZPass,s.stencilFuncMask,s.stencilWriteMask,s.side,i.getSampleCountRenderContext(r),i.getCurrentColorSpace(r),i.getCurrentColorFormat(r),i.getCurrentDepthStencilFormat(r),i.getPrimitiveTopology(t,s),e.clippingContext.cacheKey].join()}createSampler(e){this.textureUtils.createSampler(e)}destroySampler(e){this.textureUtils.destroySampler(e)}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}copyTextureToBuffer(e,t,s,i,r){return this.textureUtils.copyTextureToBuffer(e,t,s,i,r)}initTimestampQuery(e,t){if(!this.trackTimestamp)return;const s=this.get(e);if(!s.timeStampQuerySet){const e=this.device.createQuerySet({type:"timestamp",count:2}),i={querySet:e,beginningOfPassWriteIndex:0,endOfPassWriteIndex:1};Object.assign(t,{timestampWrites:i}),s.timeStampQuerySet=e}}prepareTimestampBuffer(e,t){if(!this.trackTimestamp)return;const s=this.get(e),i=2*BigInt64Array.BYTES_PER_ELEMENT;void 0===s.currentTimestampQueryBuffers&&(s.currentTimestampQueryBuffers={resolveBuffer:this.device.createBuffer({label:"timestamp resolve buffer",size:i,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),resultBuffer:this.device.createBuffer({label:"timestamp result buffer",size:i,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),isMappingPending:!1});const{resolveBuffer:r,resultBuffer:n,isMappingPending:o}=s.currentTimestampQueryBuffers;!0!==o&&(t.resolveQuerySet(s.timeStampQuerySet,0,2,r,0),t.copyBufferToBuffer(r,0,n,0,i))}async resolveTimestampAsync(e,t="render"){if(!this.trackTimestamp)return;const s=this.get(e);if(void 0===s.currentTimestampQueryBuffers)return;const{resultBuffer:i,isMappingPending:r}=s.currentTimestampQueryBuffers;!0!==r&&(s.currentTimestampQueryBuffers.isMappingPending=!0,i.mapAsync(GPUMapMode.READ).then((()=>{const e=new BigUint64Array(i.getMappedRange()),r=Number(e[1]-e[0])/1e6;this.renderer.info.updateTimestamp(t,r),i.unmap(),s.currentTimestampQueryBuffers.isMappingPending=!1})))}createNodeBuilder(e,t){return new PP(e,t)}createProgram(e){this.get(e).module={module:this.device.createShaderModule({code:e.code,label:e.stage}),entryPoint:"main"}}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){this.pipelineUtils.createRenderPipeline(e,t)}createComputePipeline(e,t){this.pipelineUtils.createComputePipeline(e,t)}beginBundle(e){const t=this.get(e);t._currentPass=t.currentPass,t._currentSets=t.currentSets,t.currentSets={attributes:{},pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){const s=this.get(e),i=s.currentPass.finish();this.get(t).bundleGPU=i,s.currentSets=s._currentSets,s.currentPass=s._currentPass}addBundle(e,t){this.get(e).renderBundles.push(this.get(t).bundleGPU)}createBindings(e){this.bindingUtils.createBindings(e)}updateBindings(e){this.bindingUtils.createBindings(e)}updateBinding(e){this.bindingUtils.updateBinding(e)}createIndexAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}createStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.VERTEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.colorBuffer=this.textureUtils.getColorBuffer(),this.defaultRenderPassdescriptor=null}getMaxAnisotropy(){return 16}hasFeature(e){return this.device.features.has(e)}copyTextureToTexture(e,t,s=null,i=null,r=0){let n=0,o=0,a=0,h=0,l=e.image.width,u=e.image.height;null!==s&&(a=s.x,h=s.y,l=s.width,u=s.height),null!==i&&(n=i.x,o=i.y);const c=this.device.createCommandEncoder({label:"copyTextureToTexture_"+e.id+"_"+t.id}),d=this.get(e).texture,p=this.get(t).texture;c.copyTextureToTexture({texture:d,mipLevel:r,origin:{x:a,y:h,z:0}},{texture:p,mipLevel:r,origin:{x:n,y:o,z:0}},[l,u]),this.device.queue.submit([c.finish()])}copyFramebufferToTexture(e,t){const s=this.get(t),{encoder:i,descriptor:r}=s;let n=null;n=t.renderTarget?e.isDepthTexture?this.get(t.depthTexture).texture:this.get(t.textures[0]).texture:e.isDepthTexture?this.textureUtils.getDepthBuffer(t.depth,t.stencil):this.context.getCurrentTexture();const o=this.get(e).texture;if(n.format===o.format){s.currentPass.end(),i.copyTextureToTexture({texture:n,origin:{x:0,y:0,z:0}},{texture:o},[e.image.width,e.image.height]),e.generateMipmaps&&this.textureUtils.generateMipmaps(e);for(let e=0;e(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new uP(e)));super(new t(e),e),this.isWebGPURenderer=!0}}const WP=new xx,HP=new tA(WP);class jP{constructor(e,t=uc(0,0,1,1)){this.renderer=e,this.outputNode=t,this.outputColorTransform=!0,this.needsUpdate=!0,WP.name="PostProcessing"}render(){this.update();const e=this.renderer,t=e.toneMapping,s=e.outputColorSpace;e.toneMapping=0,e.outputColorSpace=Zt,HP.render(e),e.toneMapping=t,e.outputColorSpace=s}update(){if(!0===this.needsUpdate){const e=this.renderer,t=e.toneMapping,s=e.outputColorSpace;HP.material.fragmentNode=!0===this.outputColorTransform?Im(this.outputNode,t,s):this.outputNode.context({toneMapping:t,outputColorSpace:s}),HP.material.needsUpdate=!0,this.needsUpdate=!1}}async renderAsync(){this.update();const e=this.renderer,t=e.toneMapping,s=e.outputColorSpace;e.toneMapping=0,e.outputColorSpace=Zt,await HP.renderAsync(e),e.toneMapping=t,e.outputColorSpace=s}}class qP extends Ti{constructor(e=1,t=1){super(),this.image={width:e,height:t},this.magFilter=Te,this.minFilter=Te,this.isStorageTexture=!0}}class $P extends hn{constructor(e,t,s=Float32Array){!1===ArrayBuffer.isView(e)&&(e=new s(e*t)),super(e,t),this.isStorageBufferAttribute=!0}}class XP extends Ho{constructor(e,t,s=Float32Array){!1===ArrayBuffer.isView(e)&&(e=new s(e*t)),super(e,t),this.isStorageInstancedBufferAttribute=!0}}class YP extends gT{constructor(e){super(e),this.textures={}}load(e,t,s,i){const r=new xT(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,(s=>{try{t(this.parse(JSON.parse(s)))}catch(t){i?i(t):console.error(t),this.manager.itemError(e)}}),s,i)}parseNodes(e){const t={};if(void 0!==e){for(const s of e){const{uuid:e,type:i}=s;t[e]=Du(eu(i)),t[e].uuid=e}const s={nodes:t,textures:this.textures};for(const i of e){i.meta=s;t[i.uuid].deserialize(i),delete i.meta}}return t}parse(e){const t=Du(eu(e.type));t.uuid=e.uuid;const s={nodes:this.parseNodes(e.nodes),textures:this.textures};return e.meta=s,t.deserialize(e),delete e.meta,t}setTextures(e){return this.textures=e,this}}const JP=jT.createMaterialFromType;jT.createMaterialFromType=function(e){const t=function(e){const t=yx.get(e);if(void 0!==t)return new t}(e);return void 0!==t?t:JP.call(this,e)};class ZP extends jT{constructor(e){super(e),this.nodes={}}parse(e){const t=super.parse(e),s=this.nodes,i=e.inputNodes;for(const e in i){const r=i[e];t[e]=s[r]}return t}setNodes(e){return this.nodes=e,this}}class KP extends YT{constructor(e){super(e),this._nodesJSON=null}parse(e,t){this._nodesJSON=e.nodes;const s=super.parse(e,t);return this._nodesJSON=null,s}parseNodes(e,t){if(void 0!==e){const s=new YP;return s.setTextures(t),s.parseNodes(e)}return{}}parseMaterials(e,t){const s={};if(void 0!==e){const i=this.parseNodes(this._nodesJSON,t),r=new ZP;r.setTextures(t),r.setNodes(i);for(let t=0,i=e.length;t