You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
NewEduCoderBuild/6907.85711476.async.js

5118 lines
1.5 MiB

!(function(){var e4=Object.defineProperty,t4=Object.defineProperties;var n4=Object.getOwnPropertyDescriptors;var c3=Object.getOwnPropertySymbols,i4=Object.getPrototypeOf,r4=Object.prototype.hasOwnProperty,s4=Object.prototype.propertyIsEnumerable,o4=Reflect.get;var Zd=Math.pow,l3=(Qe,Le,ne)=>Le in Qe?e4(Qe,Le,{enumerable:!0,configurable:!0,writable:!0,value:ne}):Qe[Le]=ne,rr=(Qe,Le)=>{for(var ne in Le||(Le={}))r4.call(Le,ne)&&l3(Qe,ne,Le[ne]);if(c3)for(var ne of c3(Le))s4.call(Le,ne)&&l3(Qe,ne,Le[ne]);return Qe},To=(Qe,Le)=>t4(Qe,n4(Le));var u3=(Qe,Le,ne)=>o4(i4(Qe),ne,Le);var nn=(Qe,Le,ne)=>new Promise((d,ge)=>{var ae=$=>{try{Y(ne.next($))}catch(X){ge(X)}},z=$=>{try{Y(ne.throw($))}catch(X){ge(X)}},Y=$=>$.done?d($.value):Promise.resolve($.value).then(ae,z);Y((ne=ne.apply(Qe,Le)).next())});(self.webpackChunk=self.webpackChunk||[]).push([[6907],{91998:function(Qe,Le,ne){Qe.exports=ge,Qe.exports.simulator=ne(72879);var d=ne(82396);function ge(z,Y){if(!z)throw new Error("Graph structure cannot be undefined");var $=Y&&Y.createSimulator||ne(72879),X=$(Y);if(Array.isArray(Y))throw new Error("Physics settings is expected to be an object");var Q=z.version>19?ti:Gt;Y&&typeof Y.nodeMass=="function"&&(Q=Y.nodeMass);var ue=new Map,de={},se=0,_e=X.settings.springTransform||ae;nt(),st();var Ae=!1,Te={step:function(){if(se===0)return ye(!0),!0;var ot=X.step();Te.lastMove=ot,Te.fire("step");var Xt=ot/se,mn=Xt<=.01;return ye(mn),mn},getNodePosition:function(ot){return kt(ot).pos},setNodePosition:function(ot){var Xt=kt(ot);Xt.setPosition.apply(Xt,Array.prototype.slice.call(arguments,1))},getLinkPosition:function(ot){var Xt=de[ot];if(Xt)return{from:Xt.from.pos,to:Xt.to.pos}},getGraphRect:function(){return X.getBBox()},forEachBody:Ie,pinNode:function(ot,Xt){var mn=kt(ot.id);mn.isPinned=!!Xt},isNodePinned:function(ot){return kt(ot.id).isPinned},dispose:function(){z.off("changed",Ke),Te.fire("disposed")},getBody:qe,getSpring:Xe,getForceVectorLength:Ze,simulator:X,graph:z,lastMove:0};return d(Te),Te;function ye(ot){Ae!==ot&&(Ae=ot,rt(ot))}function Ie(ot){ue.forEach(ot)}function Ze(){var ot=0,Xt=0;return Ie(function(mn){ot+=Math.abs(mn.force.x),Xt+=Math.abs(mn.force.y)}),Math.sqrt(ot*ot+Xt*Xt)}function Xe(ot,Xt){var mn;if(Xt===void 0)typeof ot!="object"?mn=ot:mn=ot.id;else{var _i=z.hasLink(ot,Xt);if(!_i)return;mn=_i.id}return de[mn]}function qe(ot){return ue.get(ot)}function st(){z.on("changed",Ke)}function rt(ot){Te.fire("stable",ot)}function Ke(ot){for(var Xt=0;Xt<ot.length;++Xt){var mn=ot[Xt];mn.changeType==="add"?(mn.node&&ut(mn.node.id),mn.link&&un(mn.link)):mn.changeType==="remove"&&(mn.node&&jt(mn.node),mn.link&&hn(mn.link))}se=z.getNodesCount()}function nt(){se=0,z.forEachNode(function(ot){ut(ot.id),se+=1}),z.forEachLink(un)}function ut(ot){var Xt=ue.get(ot);if(!Xt){var mn=z.getNode(ot);if(!mn)throw new Error("initBody() was called with unknown node id");var _i=mn.position;if(!_i){var Kr=pn(mn);_i=X.getBestNewBodyPosition(Kr)}Xt=X.addBodyAt(_i),Xt.id=ot,ue.set(ot,Xt),_t(ot),bn(mn)&&(Xt.isPinned=!0)}}function jt(ot){var Xt=ot.id,mn=ue.get(Xt);mn&&(ue.delete(Xt),X.removeBody(mn))}function un(ot){_t(ot.fromId),_t(ot.toId);var Xt=ue.get(ot.fromId),mn=ue.get(ot.toId),_i=X.addSpring(Xt,mn,ot.length);_e(ot,_i),de[ot.id]=_i}function hn(ot){var Xt=de[ot.id];if(Xt){var mn=z.getNode(ot.fromId),_i=z.getNode(ot.toId);mn&&_t(mn.id),_i&&_t(_i.id),delete de[ot.id],X.removeSpring(Xt)}}function pn(ot){var Xt=[];if(!ot.links)return Xt;for(var mn=Math.min(ot.links.length,2),_i=0;_i<mn;++_i){var Kr=ot.links[_i],Zr=Kr.fromId!==ot.id?ue.get(Kr.fromId):ue.get(Kr.toId);Zr&&Zr.pos&&Xt.push(Zr)}return Xt}function _t(ot){var Xt=ue.get(ot);if(Xt.mass=Q(ot),Number.isNaN(Xt.mass))throw new Error("Node mass should be a number")}function bn(ot){return ot&&(ot.isPinned||ot.data&&ot.data.isPinned)}function kt(ot){var Xt=ue.get(ot);return Xt||(ut(ot),Xt=ue.get(ot)),Xt}function Gt(ot){var Xt=z.getLinks(ot);return Xt?1+Xt.length/3:1}function ti(ot){var Xt=z.getLinks(ot);return Xt?1+Xt.size/3:1}}function ae(){}},98786:function(Qe,Le,ne){const d=ne(59321);Qe.exports=function(ae){return z;function z(Y,$){let X=$&&$.indent||0,Q=$&&$.join!==void 0?$.join:`
`,ue=Array(X+1).join(" "),de=[];for(let se=0;se<ae;++se){let _e=d(se),Ae=se===0?"":ue;de.push(Ae+Y.replace(/{var}/g,_e))}return de.join(Q)}}},41085:function(Qe,Le,ne){Qe.exports=ge,Qe.exports.generateFunctionBody=ae;const d=ne(98786);function ge(z){let Y=ae(z);return new Function("bodies","settings","random",Y)}function ae(z){let Y=d(z);return`
var boundingBox = {
${Y("min_{var}: 0, max_{var}: 0,",{indent:4})}
};
return {
box: boundingBox,
update: updateBoundingBox,
reset: resetBoundingBox,
getBestNewPosition: function (neighbors) {
var ${Y("base_{var} = 0",{join:", "})};
if (neighbors.length) {
for (var i = 0; i < neighbors.length; ++i) {
let neighborPos = neighbors[i].pos;
${Y("base_{var} += neighborPos.{var};",{indent:10})}
}
${Y("base_{var} /= neighbors.length;",{indent:8})}
} else {
${Y("base_{var} = (boundingBox.min_{var} + boundingBox.max_{var}) / 2;",{indent:8})}
}
var springLength = settings.springLength;
return {
${Y("{var}: base_{var} + (random.nextDouble() - 0.5) * springLength,",{indent:8})}
};
}
};
function updateBoundingBox() {
var i = bodies.length;
if (i === 0) return; // No bodies - no borders.
${Y("var max_{var} = -Infinity;",{indent:4})}
${Y("var min_{var} = Infinity;",{indent:4})}
while(i--) {
// this is O(n), it could be done faster with quadtree, if we check the root node bounds
var bodyPos = bodies[i].pos;
${Y("if (bodyPos.{var} < min_{var}) min_{var} = bodyPos.{var};",{indent:6})}
${Y("if (bodyPos.{var} > max_{var}) max_{var} = bodyPos.{var};",{indent:6})}
}
${Y("boundingBox.min_{var} = min_{var};",{indent:4})}
${Y("boundingBox.max_{var} = max_{var};",{indent:4})}
}
function resetBoundingBox() {
${Y("boundingBox.min_{var} = boundingBox.max_{var} = 0;",{indent:4})}
}
`}},53623:function(Qe,Le,ne){const d=ne(98786);Qe.exports=ge,Qe.exports.generateCreateBodyFunctionBody=ae,Qe.exports.getVectorCode=Y,Qe.exports.getBodyCode=z;function ge($,X){let Q=ae($,X),{Body:ue}=new Function(Q)();return ue}function ae($,X){return`
${Y($,X)}
${z($,X)}
return {Body: Body, Vector: Vector};
`}function z($){let X=d($),Q=X("{var}",{join:", "});return`
function Body(${Q}) {
this.isPinned = false;
this.pos = new Vector(${Q});
this.force = new Vector();
this.velocity = new Vector();
this.mass = 1;
this.springCount = 0;
this.springLength = 0;
}
Body.prototype.reset = function() {
this.force.reset();
this.springCount = 0;
this.springLength = 0;
}
Body.prototype.setPosition = function (${Q}) {
${X("this.pos.{var} = {var} || 0;",{indent:2})}
};`}function Y($,X){let Q=d($),ue="";return X&&(ue=`${Q(`
var v{var};
Object.defineProperty(this, '{var}', {
set: function(v) {
if (!Number.isFinite(v)) throw new Error('Cannot set non-numbers to {var}');
v{var} = v;
},
get: function() { return v{var}; }
});`)}`),`function Vector(${Q("{var}",{join:", "})}) {
${ue}
if (typeof arguments[0] === 'object') {
// could be another vector
let v = arguments[0];
${Q('if (!Number.isFinite(v.{var})) throw new Error("Expected value is not a finite number at Vector constructor ({var})");',{indent:4})}
${Q("this.{var} = v.{var};",{indent:4})}
} else {
${Q('this.{var} = typeof {var} === "number" ? {var} : 0;',{indent:4})}
}
}
Vector.prototype.reset = function () {
${Q("this.{var} = ",{join:""})}0;
};`}},48812:function(Qe,Le,ne){const d=ne(98786);Qe.exports=ge,Qe.exports.generateCreateDragForceFunctionBody=ae;function ge(z){let Y=ae(z);return new Function("options",Y)}function ae(z){return`
if (!Number.isFinite(options.dragCoefficient)) throw new Error('dragCoefficient is not a finite number');
return {
update: function(body) {
${d(z)("body.force.{var} -= options.dragCoefficient * body.velocity.{var};",{indent:6})}
}
};
`}},7584:function(Qe,Le,ne){const d=ne(98786);Qe.exports=ge,Qe.exports.generateCreateSpringForceFunctionBody=ae;function ge(z){let Y=ae(z);return new Function("options","random",Y)}function ae(z){let Y=d(z);return`
if (!Number.isFinite(options.springCoefficient)) throw new Error('Spring coefficient is not a number');
if (!Number.isFinite(options.springLength)) throw new Error('Spring length is not a number');
return {
/**
* Updates forces acting on a spring
*/
update: function (spring) {
var body1 = spring.from;
var body2 = spring.to;
var length = spring.length < 0 ? options.springLength : spring.length;
${Y("var d{var} = body2.pos.{var} - body1.pos.{var};",{indent:6})}
var r = Math.sqrt(${Y("d{var} * d{var}",{join:" + "})});
if (r === 0) {
${Y("d{var} = (random.nextDouble() - 0.5) / 50;",{indent:8})}
r = Math.sqrt(${Y("d{var} * d{var}",{join:" + "})});
}
var d = r - length;
var coefficient = ((spring.coefficient > 0) ? spring.coefficient : options.springCoefficient) * d / r;
${Y("body1.force.{var} += coefficient * d{var}",{indent:6})};
body1.springCount += 1;
body1.springLength += r;
${Y("body2.force.{var} -= coefficient * d{var}",{indent:6})};
body2.springCount += 1;
body2.springLength += r;
}
};
`}},26302:function(Qe,Le,ne){const d=ne(98786);Qe.exports=ge,Qe.exports.generateIntegratorFunctionBody=ae;function ge(z){let Y=ae(z);return new Function("bodies","timeStep","adaptiveTimeStepWeight",Y)}function ae(z){let Y=d(z);return`
var length = bodies.length;
if (length === 0) return 0;
${Y("var d{var} = 0, t{var} = 0;",{indent:2})}
for (var i = 0; i < length; ++i) {
var body = bodies[i];
if (body.isPinned) continue;
if (adaptiveTimeStepWeight && body.springCount) {
timeStep = (adaptiveTimeStepWeight * body.springLength/body.springCount);
}
var coeff = timeStep / body.mass;
${Y("body.velocity.{var} += coeff * body.force.{var};",{indent:4})}
${Y("var v{var} = body.velocity.{var};",{indent:4})}
var v = Math.sqrt(${Y("v{var} * v{var}",{join:" + "})});
if (v > 1) {
// We normalize it so that we move within timeStep range.
// for the case when v <= 1 - we let velocity to fade out.
${Y("body.velocity.{var} = v{var} / v;",{indent:6})}
}
${Y("d{var} = timeStep * body.velocity.{var};",{indent:4})}
${Y("body.pos.{var} += d{var};",{indent:4})}
${Y("t{var} += Math.abs(d{var});",{indent:4})}
}
return (${Y("t{var} * t{var}",{join:" + "})})/length;
`}},24454:function(Qe,Le,ne){const d=ne(98786),ge=ne(59321);Qe.exports=ae,Qe.exports.generateQuadTreeFunctionBody=z,Qe.exports.getInsertStackCode=ue,Qe.exports.getQuadNodeCode=Q,Qe.exports.isSamePosition=Y,Qe.exports.getChildBodyCode=X,Qe.exports.setChildBodyCode=$;function ae(de){let se=z(de);return new Function(se)()}function z(de){let se=d(de),_e=Math.pow(2,de);return`
${ue()}
${Q(de)}
${Y(de)}
${X(de)}
${$(de)}
function createQuadTree(options, random) {
options = options || {};
options.gravity = typeof options.gravity === 'number' ? options.gravity : -1;
options.theta = typeof options.theta === 'number' ? options.theta : 0.8;
var gravity = options.gravity;
var updateQueue = [];
var insertStack = new InsertStack();
var theta = options.theta;
var nodesCache = [];
var currentInCache = 0;
var root = newNode();
return {
insertBodies: insertBodies,
/**
* Gets root node if it is present
*/
getRoot: function() {
return root;
},
updateBodyForce: update,
options: function(newOptions) {
if (newOptions) {
if (typeof newOptions.gravity === 'number') {
gravity = newOptions.gravity;
}
if (typeof newOptions.theta === 'number') {
theta = newOptions.theta;
}
return this;
}
return {
gravity: gravity,
theta: theta
};
}
};
function newNode() {
// To avoid pressure on GC we reuse nodes.
var node = nodesCache[currentInCache];
if (node) {
${Ie(" node.")}
node.body = null;
node.mass = ${se("node.mass_{var} = ",{join:""})}0;
${se("node.min_{var} = node.max_{var} = ",{join:""})}0;
} else {
node = new QuadNode();
nodesCache[currentInCache] = node;
}
++currentInCache;
return node;
}
function update(sourceBody) {
var queue = updateQueue;
var v;
${se("var d{var};",{indent:4})}
var r;
${se("var f{var} = 0;",{indent:4})}
var queueLength = 1;
var shiftIdx = 0;
var pushIdx = 1;
queue[0] = root;
while (queueLength) {
var node = queue[shiftIdx];
var body = node.body;
queueLength -= 1;
shiftIdx += 1;
var differentBody = (body !== sourceBody);
if (body && differentBody) {
// If the current node is a leaf node (and it is not source body),
// calculate the force exerted by the current node on body, and add this
// amount to body's net force.
${se("d{var} = body.pos.{var} - sourceBody.pos.{var};",{indent:8})}
r = Math.sqrt(${se("d{var} * d{var}",{join:" + "})});
if (r === 0) {
// Poor man's protection against zero distance.
${se("d{var} = (random.nextDouble() - 0.5) / 50;",{indent:10})}
r = Math.sqrt(${se("d{var} * d{var}",{join:" + "})});
}
// This is standard gravitation force calculation but we divide
// by r^3 to save two operations when normalizing force vector.
v = gravity * body.mass * sourceBody.mass / (r * r * r);
${se("f{var} += v * d{var};",{indent:8})}
} else if (differentBody) {
// Otherwise, calculate the ratio s / r, where s is the width of the region
// represented by the internal node, and r is the distance between the body
// and the node's center-of-mass
${se("d{var} = node.mass_{var} / node.mass - sourceBody.pos.{var};",{indent:8})}
r = Math.sqrt(${se("d{var} * d{var}",{join:" + "})});
if (r === 0) {
// Sorry about code duplication. I don't want to create many functions
// right away. Just want to see performance first.
${se("d{var} = (random.nextDouble() - 0.5) / 50;",{indent:10})}
r = Math.sqrt(${se("d{var} * d{var}",{join:" + "})});
}
// If s / r < \u03B8, treat this internal node as a single body, and calculate the
// force it exerts on sourceBody, and add this amount to sourceBody's net force.
if ((node.max_${ge(0)} - node.min_${ge(0)}) / r < theta) {
// in the if statement above we consider node's width only
// because the region was made into square during tree creation.
// Thus there is no difference between using width or height.
v = gravity * node.mass * sourceBody.mass / (r * r * r);
${se("f{var} += v * d{var};",{indent:10})}
} else {
// Otherwise, run the procedure recursively on each of the current node's children.
// I intentionally unfolded this loop, to save several CPU cycles.
${ye()}
}
}
}
${se("sourceBody.force.{var} += f{var};",{indent:4})}
}
function insertBodies(bodies) {
${se("var {var}min = Number.MAX_VALUE;",{indent:4})}
${se("var {var}max = Number.MIN_VALUE;",{indent:4})}
var i = bodies.length;
// To reduce quad tree depth we are looking for exact bounding box of all particles.
while (i--) {
var pos = bodies[i].pos;
${se("if (pos.{var} < {var}min) {var}min = pos.{var};",{indent:6})}
${se("if (pos.{var} > {var}max) {var}max = pos.{var};",{indent:6})}
}
// Makes the bounds square.
var maxSideLength = -Infinity;
${se("if ({var}max - {var}min > maxSideLength) maxSideLength = {var}max - {var}min ;",{indent:4})}
currentInCache = 0;
root = newNode();
${se("root.min_{var} = {var}min;",{indent:4})}
${se("root.max_{var} = {var}min + maxSideLength;",{indent:4})}
i = bodies.length - 1;
if (i >= 0) {
root.body = bodies[i];
}
while (i--) {
insert(bodies[i], root);
}
}
function insert(newBody) {
insertStack.reset();
insertStack.push(root, newBody);
while (!insertStack.isEmpty()) {
var stackItem = insertStack.pop();
var node = stackItem.node;
var body = stackItem.body;
if (!node.body) {
// This is internal node. Update the total mass of the node and center-of-mass.
${se("var {var} = body.pos.{var};",{indent:8})}
node.mass += body.mass;
${se("node.mass_{var} += body.mass * {var};",{indent:8})}
// Recursively insert the body in the appropriate quadrant.
// But first find the appropriate quadrant.
var quadIdx = 0; // Assume we are in the 0's quad.
${se("var min_{var} = node.min_{var};",{indent:8})}
${se("var max_{var} = (min_{var} + node.max_{var}) / 2;",{indent:8})}
${Te(8)}
var child = getChild(node, quadIdx);
if (!child) {
// The node is internal but this quadrant is not taken. Add
// subnode to it.
child = newNode();
${se("child.min_{var} = min_{var};",{indent:10})}
${se("child.max_{var} = max_{var};",{indent:10})}
child.body = body;
setChild(node, quadIdx, child);
} else {
// continue searching in this quadrant.
insertStack.push(child, body);
}
} else {
// We are trying to add to the leaf node.
// We have to convert current leaf into internal node
// and continue adding two nodes.
var oldBody = node.body;
node.body = null; // internal nodes do not cary bodies
if (isSamePosition(oldBody.pos, body.pos)) {
// Prevent infinite subdivision by bumping one node
// anywhere in this quadrant
var retriesCount = 3;
do {
var offset = random.nextDouble();
${se("var d{var} = (node.max_{var} - node.min_{var}) * offset;",{indent:12})}
${se("oldBody.pos.{var} = node.min_{var} + d{var};",{indent:12})}
retriesCount -= 1;
// Make sure we don't bump it out of the box. If we do, next iteration should fix it
} while (retriesCount > 0 && isSamePosition(oldBody.pos, body.pos));
if (retriesCount === 0 && isSamePosition(oldBody.pos, body.pos)) {
// This is very bad, we ran out of precision.
// if we do not return from the method we'll get into
// infinite loop here. So we sacrifice correctness of layout, and keep the app running
// Next layout iteration should get larger bounding box in the first step and fix this
return;
}
}
// Next iteration should subdivide node further.
insertStack.push(node, oldBody);
insertStack.push(node, body);
}
}
}
}
return createQuadTree;
`;function Te(Ze){let Xe=[],qe=Array(Ze+1).join(" ");for(let st=0;st<de;++st)Xe.push(qe+`if (${ge(st)} > max_${ge(st)}) {`),Xe.push(qe+` quadIdx = quadIdx + ${Math.pow(2,st)};`),Xe.push(qe+` min_${ge(st)} = max_${ge(st)};`),Xe.push(qe+` max_${ge(st)} = node.max_${ge(st)};`),Xe.push(qe+"}");return Xe.join(`
`)}function ye(){let Ze=Array(11).join(" "),Xe=[];for(let qe=0;qe<_e;++qe)Xe.push(Ze+`if (node.quad${qe}) {`),Xe.push(Ze+` queue[pushIdx] = node.quad${qe};`),Xe.push(Ze+" queueLength += 1;"),Xe.push(Ze+" pushIdx += 1;"),Xe.push(Ze+"}");return Xe.join(`
`)}function Ie(Ze){let Xe=[];for(let qe=0;qe<_e;++qe)Xe.push(`${Ze}quad${qe} = null;`);return Xe.join(`
`)}}function Y(de){let se=d(de);return`
function isSamePosition(point1, point2) {
${se("var d{var} = Math.abs(point1.{var} - point2.{var});",{indent:2})}
return ${se("d{var} < 1e-8",{join:" && "})};
}
`}function $(de){var se=Math.pow(2,de);return`
function setChild(node, idx, child) {
${_e()}
}`;function _e(){let Ae=[];for(let Te=0;Te<se;++Te){let ye=Te===0?" ":" else ";Ae.push(`${ye}if (idx === ${Te}) node.quad${Te} = child;`)}return Ae.join(`
`)}}function X(de){return`function getChild(node, idx) {
${se()}
return null;
}`;function se(){let _e=[],Ae=Math.pow(2,de);for(let Te=0;Te<Ae;++Te)_e.push(` if (idx === ${Te}) return node.quad${Te};`);return _e.join(`
`)}}function Q(de){let se=d(de),_e=Math.pow(2,de);var Ae=`
function QuadNode() {
// body stored inside this node. In quad tree only leaf nodes (by construction)
// contain bodies:
this.body = null;
// Child nodes are stored in quads. Each quad is presented by number:
// 0 | 1
// -----
// 2 | 3
${Te(" this.")}
// Total mass of current node
this.mass = 0;
// Center of mass coordinates
${se("this.mass_{var} = 0;",{indent:2})}
// bounding box coordinates
${se("this.min_{var} = 0;",{indent:2})}
${se("this.max_{var} = 0;",{indent:2})}
}
`;return Ae;function Te(ye){let Ie=[];for(let Ze=0;Ze<_e;++Ze)Ie.push(`${ye}quad${Ze} = null;`);return Ie.join(`
`)}}function ue(){return`
/**
* Our implementation of QuadTree is non-recursive to avoid GC hit
* This data structure represent stack of elements
* which we are trying to insert into quad tree.
*/
function InsertStack () {
this.stack = [];
this.popIdx = 0;
}
InsertStack.prototype = {
isEmpty: function() {
return this.popIdx === 0;
},
push: function (node, body) {
var item = this.stack[this.popIdx];
if (!item) {
// we are trying to avoid memory pressure: create new element
// only when absolutely necessary
this.stack[this.popIdx] = new InsertStackElement(node, body);
} else {
item.node = node;
item.body = body;
}
++this.popIdx;
},
pop: function () {
if (this.popIdx > 0) {
return this.stack[--this.popIdx];
}
},
reset: function () {
this.popIdx = 0;
}
};
function InsertStackElement(node, body) {
this.node = node; // QuadTree node
this.body = body; // physical body which needs to be inserted to node
}
`}},59321:function(Qe){Qe.exports=function(ne){return ne===0?"x":ne===1?"y":ne===2?"z":"c"+(ne+1)}},72879:function(Qe,Le,ne){Qe.exports=Q;var d=ne(53623),ge=ne(24454),ae=ne(41085),z=ne(48812),Y=ne(7584),$=ne(26302),X={};function Q(se){var _e=ne(75877),Ae=ne(35764),Te=ne(82396);if(se){if(se.springCoeff!==void 0)throw new Error("springCoeff was renamed to springCoefficient");if(se.dragCoeff!==void 0)throw new Error("dragCoeff was renamed to dragCoefficient")}se=Ae(se,{springLength:10,springCoefficient:.8,gravity:-12,theta:.8,dragCoefficient:.9,timeStep:.5,adaptiveTimeStepWeight:0,dimensions:2,debug:!1});var ye=X[se.dimensions];if(!ye){var Ie=se.dimensions;ye={Body:d(Ie,se.debug),createQuadTree:ge(Ie),createBounds:ae(Ie),createDragForce:z(Ie),createSpringForce:Y(Ie),integrate:$(Ie)},X[Ie]=ye}var Ze=ye.Body,Xe=ye.createQuadTree,qe=ye.createBounds,st=ye.createDragForce,rt=ye.createSpringForce,Ke=ye.integrate,nt=An=>new Ze(An),ut=ne(40232).random(42),jt=[],un=[],hn=Xe(se,ut),pn=qe(jt,se,ut),_t=rt(se,ut),bn=st(se),kt=0,Gt=[],ti=new Map,ot=0;_i("nbody",Mo),_i("spring",Ac);var Xt={bodies:jt,quadTree:hn,springs:un,settings:se,addForce:_i,removeForce:Kr,getForces:Zr,step:function(){for(var An=0;An<Gt.length;++An)Gt[An](ot);var yi=Ke(jt,se.timeStep,se.adaptiveTimeStepWeight);return ot+=1,yi},addBody:function(An){if(!An)throw new Error("Body is required");return jt.push(An),An},addBodyAt:function(An){if(!An)throw new Error("Body position is required");var yi=nt(An);return jt.push(yi),yi},removeBody:function(An){if(An){var yi=jt.indexOf(An);if(!(yi<0))return jt.splice(yi,1),jt.length===0&&pn.reset(),!0}},addSpring:function(An,yi,Qo,Yu){if(!An||!yi)throw new Error("Cannot add null spring to force simulator");typeof Qo!="number"&&(Qo=-1);var Ec=new _e(An,yi,Qo,Yu>=0?Yu:-1);return un.push(Ec),Ec},getTotalMovement:function(){return kt},removeSpring:function(An){if(An){var yi=un.indexOf(An);if(yi>-1)return un.splice(yi,1),!0}},getBestNewBodyPosition:function(An){return pn.getBestNewPosition(An)},getBBox:mn,getBoundingBox:mn,invalidateBBox:function(){console.warn("invalidateBBox() is deprecated, bounds always recomputed on `getBBox()` call")},gravity:function(An){return An!==void 0?(se.gravity=An,hn.options({gravity:An}),this):se.gravity},theta:function(An){return An!==void 0?(se.theta=An,hn.options({theta:An}),this):se.theta},random:ut};return ue(se,Xt),Te(Xt),Xt;function mn(){return pn.update(),pn.box}function _i(An,yi){if(ti.has(An))throw new Error("Force "+An+" is already added");ti.set(An,yi),Gt.push(yi)}function Kr(An){var yi=Gt.indexOf(ti.get(An));yi<0||(Gt.splice(yi,1),ti.delete(An))}function Zr(){return ti}function Mo(){if(jt.length!==0){hn.insertBodies(jt);for(var An=jt.length;An--;){var yi=jt[An];yi.isPinned||(yi.reset(),hn.updateBodyForce(yi),bn.update(yi))}}}function Ac(){for(var An=un.length;An--;)_t.update(un[An])}}function ue(se,_e){for(var Ae in se)de(se,_e,Ae)}function de(se,_e,Ae){if(se.hasOwnProperty(Ae)&&typeof _e[Ae]!="function"){var Te=Number.isFinite(se[Ae]);Te?_e[Ae]=function(ye){if(ye!==void 0){if(!Number.isFinite(ye))throw new Error("Value of "+Ae+" should be a valid number.");return se[Ae]=ye,_e}return se[Ae]}:_e[Ae]=function(ye){return ye!==void 0?(se[Ae]=ye,_e):se[Ae]}}}},75877:function(Qe){Qe.exports=Le;function Le(ne,d,ge,ae){this.from=ne,this.to=d,this.length=ge,this.coefficient=ae}},35764:function(Qe){Qe.exports=Le;function Le(ne,d){var ge;if(ne||(ne={}),d){for(ge in d)if(d.hasOwnProperty(ge)){var ae=ne.hasOwnProperty(ge),z=typeof d[ge],Y=!ae||typeof ne[ge]!==z;Y?ne[ge]=d[ge]:z==="object"&&(ne[ge]=Le(ne[ge],d[ge]))}}return ne}},40232:function(Qe){Qe.exports=Le,Qe.exports.random=Le,Qe.exports.randomIterator=$;function Le(X){var Q=typeof X=="number"?X:+new Date;return new ne(Q)}function ne(X){this.seed=X}ne.prototype.next=Y,ne.prototype.nextDouble=z,ne.prototype.uniform=z,ne.prototype.gaussian=d,ne.prototype.random=z;function d(){var X,Q,ue;do Q=this.nextDouble()*2-1,ue=this.nextDouble()*2-1,X=Q*Q+ue*ue;while(X>=1||X===0);return Q*Math.sqrt(-2*Math.log(X)/X)}ne.prototype.levy=ge;function ge(){var X=1.5,Q=Math.pow(ae(1+X)*Math.sin(Math.PI*X/2)/(ae((1+X)/2)*X*Math.pow(2,(X-1)/2)),1/X);return this.gaussian()*Q/Math.pow(Math.abs(this.gaussian()),1/X)}function ae(X){return Math.sqrt(2*Math.PI/X)*Math.pow(1/Math.E*(X+1/(12*X-1/(10*X))),X)}function z(){var X=this.seed;return X=X+2127912214+(X<<12)&4294967295,X=(X^3345072700^X>>>19)&4294967295,X=X+374761393+(X<<5)&4294967295,X=(X+3550635116^X<<9)&4294967295,X=X+4251993797+(X<<3)&4294967295,X=(X^3042594569^X>>>16)&4294967295,this.seed=X,(X&268435455)/268435456}function Y(X){return Math.floor(this.nextDouble()*X)}function $(X,Q){var ue=Q||Le();if(typeof ue.next!="function")throw new Error("customRandom does not match expected API: next() function is missing");return{forEach:se,shuffle:de};function de(){var _e,Ae,Te;for(_e=X.length-1;_e>0;--_e)Ae=ue.next(_e+1),Te=X[Ae],X[Ae]=X[_e],X[_e]=Te;return X}function se(_e){var Ae,Te,ye;for(Ae=X.length-1;Ae>0;--Ae)Te=ue.next(Ae+1),ye=X[Te],X[Te]=X[Ae],X[Ae]=ye,_e(ye);X.length&&_e(X[0])}}},82396:function(Qe){"use strict";function Le(ge){d(ge);const ae=ne(ge);return ge.on=ae.on,ge.off=ae.off,ge.fire=ae.fire,ge}function ne(ge){let ae=Object.create(null);return{on:function(z,Y,$){if(typeof Y!="function")throw new Error("callback is expected to be a function");let X=ae[z];return X||(X=ae[z]=[]),X.push({callback:Y,ctx:$}),ge},off:function(z,Y){if(typeof z>"u")return ae=Object.create(null),ge;if(ae[z])if(typeof Y!="function")delete ae[z];else{const $=ae[z];for(let X=0;X<$.length;++X)$[X].callback===Y&&$.splice(X,1)}return ge},fire:function(z){const Y=ae[z];if(!Y)return ge;let $;arguments.length>1&&($=Array.prototype.slice.call(arguments,1));for(let X=0;X<Y.length;++X){const Q=Y[X];Q.callback.apply(Q.ctx,$)}return ge}}}function d(ge){if(!ge)throw new Error("Eventify cannot use falsy object as events subject");const ae=["on","fire","off"];for(let z=0;z<ae.length;++z)if(ge.hasOwnProperty(ae[z]))throw new Error("Subject cannot be eventified, since it already has property '"+ae[z]+"'")}Qe.exports=Le},38895:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return jV}});var d=ne(51910);const ge=new d.JOQ,ae=new d.FM8,z=new d.Pa4,Y=new d.FM8,$=new d.FM8,X=new d.Pa4,Q=new d.Pa4,ue=new d.yGw,de=new d.Pa4,se=new d.Pa4;let _e=null,Ae=null;const Te=[],ye={NONE:-1,PAN:0,ROTATE:1};class Ie extends d.ZXd{constructor(e,t,r=null){super(t,r),this.objects=e,this.recursive=!0,this.transformGroup=!1,this.rotateSpeed=1,this.raycaster=new d.iMs,this.mouseButtons={LEFT:d.RsA.PAN,MIDDLE:d.RsA.PAN,RIGHT:d.RsA.ROTATE},this.touches={ONE:d.QmN.PAN},this._onPointerMove=Ze.bind(this),this._onPointerDown=Xe.bind(this),this._onPointerCancel=qe.bind(this),this._onContextMenu=st.bind(this),r!==null&&this.connect(r)}connect(e){super.connect(e),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointerup",this._onPointerCancel),this.domElement.addEventListener("pointerleave",this._onPointerCancel),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointerup",this._onPointerCancel),this.domElement.removeEventListener("pointerleave",this._onPointerCancel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="auto",this.domElement.style.cursor=""}dispose(){this.disconnect()}_updatePointer(e){const t=this.domElement.getBoundingClientRect();ae.x=(e.clientX-t.left)/t.width*2-1,ae.y=-(e.clientY-t.top)/t.height*2+1}_updateState(e){let t;if(e.pointerType==="touch")t=this.touches.ONE;else switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=null}switch(t){case d.RsA.PAN:case d.QmN.PAN:this.state=ye.PAN;break;case d.RsA.ROTATE:case d.QmN.ROTATE:this.state=ye.ROTATE;break;default:this.state=ye.NONE}}}function Ze(i){const e=this.object,t=this.domElement,r=this.raycaster;if(this.enabled!==!1){if(this._updatePointer(i),r.setFromCamera(ae,e),_e)this.state===ye.PAN?r.ray.intersectPlane(ge,X)&&(_e.position.copy(X.sub(z).applyMatrix4(ue)),this.dispatchEvent({type:"drag",object:_e})):this.state===ye.ROTATE&&(Y.subVectors(ae,$).multiplyScalar(this.rotateSpeed),_e.rotateOnWorldAxis(de,Y.x),_e.rotateOnWorldAxis(se.normalize(),-Y.y),this.dispatchEvent({type:"drag",object:_e})),$.copy(ae);else if(i.pointerType==="mouse"||i.pointerType==="pen")if(Te.length=0,r.setFromCamera(ae,e),r.intersectObjects(this.objects,this.recursive,Te),Te.length>0){const s=Te[0].object;ge.setFromNormalAndCoplanarPoint(e.getWorldDirection(ge.normal),Q.setFromMatrixPosition(s.matrixWorld)),Ae!==s&&Ae!==null&&(this.dispatchEvent({type:"hoveroff",object:Ae}),t.style.cursor="auto",Ae=null),Ae!==s&&(this.dispatchEvent({type:"hoveron",object:s}),t.style.cursor="pointer",Ae=s)}else Ae!==null&&(this.dispatchEvent({type:"hoveroff",object:Ae}),t.style.cursor="auto",Ae=null);$.copy(ae)}}function Xe(i){const e=this.object,t=this.domElement,r=this.raycaster;this.enabled!==!1&&(this._updatePointer(i),this._updateState(i),Te.length=0,r.setFromCamera(ae,e),r.intersectObjects(this.objects,this.recursive,Te),Te.length>0&&(this.transformGroup===!0?_e=rt(Te[0].object):_e=Te[0].object,ge.setFromNormalAndCoplanarPoint(e.getWorldDirection(ge.normal),Q.setFromMatrixPosition(_e.matrixWorld)),r.ray.intersectPlane(ge,X)&&(this.state===ye.PAN?(ue.copy(_e.parent.matrixWorld).invert(),z.copy(X).sub(Q.setFromMatrixPosition(_e.matrixWorld)),t.style.cursor="move",this.dispatchEvent({type:"dragstart",object:_e})):this.state===ye.ROTATE&&(de.set(0,1,0).applyQuaternion(e.quaternion).normalize(),se.set(1,0,0).applyQuaternion(e.quaternion).normalize(),t.style.cursor="move",this.dispatchEvent({type:"dragstart",object:_e})))),$.copy(ae))}function qe(){this.enabled!==!1&&(_e&&(this.dispatchEvent({type:"dragend",object:_e}),_e=null),this.domElement.style.cursor=Ae?"pointer":"auto",this.state=ye.NONE)}function st(i){this.enabled!==!1&&i.preventDefault()}function rt(i,e=null){return i.isGroup&&(e=i),i.parent===null?e:rt(i.parent,e)}var Ke=ne(21668),nt=ne(76633),ut=ne(61147),jt=ne(38192),un=ne(85320);function hn(i,e,t,r){var s,a,c=(0,un.Z)(.1),h,f;typeof i!="function"&&(i=(0,un.Z)(+i)),e==null&&(e=0),t==null&&(t=0),r==null&&(r=0);function m(_){for(var v=0,T=s.length;v<T;++v){var w=s[v],P=w.x-e||1e-6,C=(w.y||0)-t||1e-6,E=(w.z||0)-r||1e-6,D=Math.sqrt(P*P+C*C+E*E),F=(f[v]-D)*h[v]*_/D;w.vx+=P*F,a>1&&(w.vy+=C*F),a>2&&(w.vz+=E*F)}}function x(){if(s){var _,v=s.length;for(h=new Array(v),f=new Array(v),_=0;_<v;++_)f[_]=+i(s[_],_,s),h[_]=isNaN(f[_])?0:+c(s[_],_,s)}}return m.initialize=function(_,...v){s=_,a=v.find(T=>[1,2,3].includes(T))||2,x()},m.strength=function(_){return arguments.length?(c=typeof _=="function"?_:(0,un.Z)(+_),x(),m):c},m.radius=function(_){return arguments.length?(i=typeof _=="function"?_:(0,un.Z)(+_),x(),m):i},m.x=function(_){return arguments.length?(e=+_,m):e},m.y=function(_){return arguments.length?(t=+_,m):t},m.z=function(_){return arguments.length?(r=+_,m):r},m}function pn(i){bn(i);const e=_t(i);return i.on=e.on,i.off=e.off,i.fire=e.fire,i}function _t(i){let e=Object.create(null);return{on:function(t,r,s){if(typeof r!="function")throw new Error("callback is expected to be a function");let a=e[t];return a||(a=e[t]=[]),a.push({callback:r,ctx:s}),i},off:function(t,r){if(typeof t=="undefined")return e=Object.create(null),i;if(e[t])if(typeof r!="function")delete e[t];else{const c=e[t];for(let h=0;h<c.length;++h)c[h].callback===r&&c.splice(h,1)}return i},fire:function(t){const r=e[t];if(!r)return i;let s;arguments.length>1&&(s=Array.prototype.slice.call(arguments,1));for(let a=0;a<r.length;++a){const c=r[a];c.callback.apply(c.ctx,s)}return i}}}function bn(i){if(!i)throw new Error("Eventify cannot use falsy object as events subject");const e=["on","fire","off"];for(let t=0;t<e.length;++t)if(i.hasOwnProperty(e[t]))throw new Error("Subject cannot be eventified, since it already has property '"+e[t]+"'")}var kt=Gt;function Gt(i){if(i=i||{},"uniqueLinkId"in i&&(console.warn("ngraph.graph: Starting from version 0.14 `uniqueLinkId` is deprecated.\nUse `multigraph` option instead\n",`
`,`Note: there is also change in default behavior: From now on each graph
is considered to be not a multigraph by default (each edge is unique).`),i.multigraph=i.uniqueLinkId),i.multigraph===void 0&&(i.multigraph=!1),typeof Map!="function")throw new Error("ngraph.graph requires `Map` to be defined. Please polyfill it before using ngraph");var e=new Map,t=new Map,r={},s=0,a=i.multigraph?W:F,c=[],h=ft,f=ft,m=ft,x=ft,_={version:20,addNode:P,addLink:D,removeLink:oe,removeNode:E,getNode:C,getNodeCount:K,getLinkCount:U,getEdgeCount:U,getLinksCount:U,getNodesCount:K,getLinks:j,forEachNode:Pt,forEachLinkedNode:Pe,forEachLink:Ee,beginUpdate:m,endUpdate:x,clear:be,hasLink:O,hasNode:C,getLink:O,getLinkById:le};return pn(_),v(),_;function v(){var Ye=_.on;_.on=yt;function yt(){return _.beginUpdate=m=$e,_.endUpdate=x=Tt,h=T,f=w,_.on=Ye,Ye.apply(_,arguments)}}function T(Ye,yt){c.push({link:Ye,changeType:yt})}function w(Ye,yt){c.push({node:Ye,changeType:yt})}function P(Ye,yt){if(Ye===void 0)throw new Error("Invalid node identifier");m();var Ot=C(Ye);return Ot?(Ot.data=yt,f(Ot,"update")):(Ot=new ti(Ye,yt),f(Ot,"add")),e.set(Ye,Ot),x(),Ot}function C(Ye){return e.get(Ye)}function E(Ye){var yt=C(Ye);if(!yt)return!1;m();var Ot=yt.links;return Ot&&(Ot.forEach(k),yt.links=null),e.delete(Ye),f(yt,"remove"),x(),!0}function D(Ye,yt,Ot){m();var Mn=C(Ye)||P(Ye),tt=C(yt)||P(yt),ve=a(Ye,yt,Ot),Ne=t.has(ve.id);return t.set(ve.id,ve),ot(Mn,ve),Ye!==yt&&ot(tt,ve),h(ve,Ne?"update":"add"),x(),ve}function F(Ye,yt,Ot){var Mn=mn(Ye,yt),tt=t.get(Mn);return tt?(tt.data=Ot,tt):new Xt(Ye,yt,Ot,Mn)}function W(Ye,yt,Ot){var Mn=mn(Ye,yt),tt=r.hasOwnProperty(Mn);if(tt||O(Ye,yt)){tt||(r[Mn]=0);var ve="@"+ ++r[Mn];Mn=mn(Ye+ve,yt+ve)}return new Xt(Ye,yt,Ot,Mn)}function K(){return e.size}function U(){return t.size}function j(Ye){var yt=C(Ye);return yt?yt.links:null}function oe(Ye,yt){return yt!==void 0&&(Ye=O(Ye,yt)),k(Ye)}function k(Ye){if(!Ye||!t.get(Ye.id))return!1;m(),t.delete(Ye.id);var yt=C(Ye.fromId),Ot=C(Ye.toId);return yt&&yt.links.delete(Ye),Ot&&Ot.links.delete(Ye),h(Ye,"remove"),x(),!0}function O(Ye,yt){if(!(Ye===void 0||yt===void 0))return t.get(mn(Ye,yt))}function le(Ye){if(Ye!==void 0)return t.get(Ye)}function be(){m(),Pt(function(Ye){E(Ye.id)}),x()}function Ee(Ye){if(typeof Ye=="function")for(var yt=t.values(),Ot=yt.next();!Ot.done;){if(Ye(Ot.value))return!0;Ot=yt.next()}}function Pe(Ye,yt,Ot){var Mn=C(Ye);if(Mn&&Mn.links&&typeof yt=="function")return Ot?Be(Mn.links,Ye,yt):He(Mn.links,Ye,yt)}function He(Ye,yt,Ot){for(var Mn,tt=Ye.values(),ve=tt.next();!ve.done;){var Ne=ve.value,gt=Ne.fromId===yt?Ne.toId:Ne.fromId;if(Mn=Ot(e.get(gt),Ne),Mn)return!0;ve=tt.next()}}function Be(Ye,yt,Ot){for(var Mn,tt=Ye.values(),ve=tt.next();!ve.done;){var Ne=ve.value;if(Ne.fromId===yt&&(Mn=Ot(e.get(Ne.toId),Ne),Mn))return!0;ve=tt.next()}}function ft(){}function $e(){s+=1}function Tt(){s-=1,s===0&&c.length>0&&(_.fire("changed",c),c.length=0)}function Pt(Ye){if(typeof Ye!="function")throw new Error("Function is expected to iterate over graph nodes. You passed "+Ye);for(var yt=e.values(),Ot=yt.next();!Ot.done;){if(Ye(Ot.value))return!0;Ot=yt.next()}}}function ti(i,e){this.id=i,this.links=null,this.data=e}function ot(i,e){i.links?i.links.add(e):i.links=new Set([e])}function Xt(i,e,t,r){this.fromId=i,this.toId=e,this.data=t,this.id=r}function mn(i,e){return i.toString()+"\u{1F449} "+e.toString()}var _i=ne(91998);function Kr(i){var e=typeof i;return i!=null&&(e=="object"||e=="function")}var Zr=Kr,Mo=typeof global=="object"&&global&&global.Object===Object&&global,Ac=Mo,An=typeof self=="object"&&self&&self.Object===Object&&self,yi=Ac||An||Function("return this")(),Qo=yi,Yu=function(){return Qo.Date.now()},Ec=Yu,x_=/\s/;function __(i){for(var e=i.length;e--&&x_.test(i.charAt(e)););return e}var Qu=__,y_=/^\s+/;function b_(i){return i&&i.slice(0,Qu(i)+1).replace(y_,"")}var v_=b_,S_=Qo.Symbol,Ju=S_,Bm=Object.prototype,T_=Bm.hasOwnProperty,M_=Bm.toString,Al=Ju?Ju.toStringTag:void 0;function w_(i){var e=T_.call(i,Al),t=i[Al];try{i[Al]=void 0;var r=!0}catch(a){}var s=M_.call(i);return r&&(e?i[Al]=t:delete i[Al]),s}var Om=w_,A_=Object.prototype,eh=A_.toString;function th(i){return eh.call(i)}var km=th,Vm="[object Null]",zm="[object Undefined]",Yd=Ju?Ju.toStringTag:void 0;function nh(i){return i==null?i===void 0?zm:Vm:Yd&&Yd in Object(i)?Om(i):km(i)}var Rs=nh;function ih(i){return i!=null&&typeof i=="object"}var ps=ih,Gm="[object Symbol]";function JS(i){return typeof i=="symbol"||ps(i)&&Rs(i)==Gm}var Wm=JS,E_=NaN,Yr=/^[-+]0x[0-9a-f]+$/i,Hm=/^0b[01]+$/i,eT=/^0o[0-7]+$/i,El=parseInt;function C_(i){if(typeof i=="number")return i;if(Wm(i))return E_;if(Zr(i)){var e=typeof i.valueOf=="function"?i.valueOf():i;i=Zr(e)?e+"":e}if(typeof i!="string")return i===0?i:+i;i=v_(i);var t=Hm.test(i);return t||eT.test(i)?El(i.slice(2),t?2:8):Yr.test(i)?E_:+i}var Cl=C_,$m="Expected a function",jm=Math.max,Xm=Math.min;function qm(i,e,t){var r,s,a,c,h,f,m=0,x=!1,_=!1,v=!0;if(typeof i!="function")throw new TypeError($m);e=Cl(e)||0,Zr(t)&&(x=!!t.leading,_="maxWait"in t,a=_?jm(Cl(t.maxWait)||0,e):a,v="trailing"in t?!!t.trailing:v);function T(U){var j=r,oe=s;return r=s=void 0,m=U,c=i.apply(oe,j),c}function w(U){return m=U,h=setTimeout(E,e),x?T(U):c}function P(U){var j=U-f,oe=U-m,k=e-j;return _?Xm(k,a-oe):k}function C(U){var j=U-f,oe=U-m;return f===void 0||j>=e||j<0||_&&oe>=a}function E(){var U=Ec();if(C(U))return D(U);h=setTimeout(E,P(U))}function D(U){return h=void 0,v&&r?T(U):(r=s=void 0,c)}function F(){h!==void 0&&clearTimeout(h),m=0,r=f=s=h=void 0}function W(){return h===void 0?c:D(Ec())}function K(){var U=Ec(),j=C(U);if(r=arguments,s=this,f=U,j){if(h===void 0)return w(f);if(_)return clearTimeout(h),h=setTimeout(E,e),T(f)}return h===void 0&&(h=setTimeout(E,e)),c}return K.cancel=F,K.flush=W,K}var rh=qm;function Jo(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,r=Array(e);t<e;t++)r[t]=i[t];return r}function Km(i){if(Array.isArray(i))return i}function Zm(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")}function Ym(i,e,t){return Object.defineProperty(i,"prototype",{writable:!1}),i}function R_(i,e){var t=i==null?null:typeof Symbol!="undefined"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var r,s,a,c,h=[],f=!0,m=!1;try{if(a=(t=t.call(i)).next,e!==0)for(;!(f=(r=a.call(t)).done)&&(h.push(r.value),h.length!==e);f=!0);}catch(x){m=!0,s=x}finally{try{if(!f&&t.return!=null&&(c=t.return(),Object(c)!==c))return}finally{if(m)throw s}}return h}}function Qm(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Jm(i,e){return Km(i)||R_(i,e)||eg(i,e)||Qm()}function eg(i,e){if(i){if(typeof i=="string")return Jo(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Jo(i,e):void 0}}var tg=Ym(function i(e,t){var r=t.default,s=r===void 0?null:r,a=t.triggerUpdate,c=a===void 0?!0:a,h=t.onChange,f=h===void 0?function(m,x){}:h;Zm(this,i),this.name=e,this.defaultVal=s,this.triggerUpdate=c,this.onChange=f});function wo(i){var e=i.stateInit,t=e===void 0?function(){return{}}:e,r=i.props,s=r===void 0?{}:r,a=i.methods,c=a===void 0?{}:a,h=i.aliases,f=h===void 0?{}:h,m=i.init,x=m===void 0?function(){}:m,_=i.update,v=_===void 0?function(){}:_,T=Object.keys(s).map(function(w){return new tg(w,s[w])});return function w(){for(var P=arguments.length,C=new Array(P),E=0;E<P;E++)C[E]=arguments[E];var D=!!(this instanceof w&&this.constructor),F=D?C.shift():void 0,W=C[0],K=W===void 0?{}:W,U=Object.assign({},t instanceof Function?t(K):t,{initialised:!1}),j={};function oe(le){return k(le,K),O(),oe}var k=function(be,Ee){x.call(oe,be,U,Ee),U.initialised=!0},O=rh(function(){U.initialised&&(v.call(oe,U,j),j={})},1);return T.forEach(function(le){oe[le.name]=be(le);function be(Ee){var Pe=Ee.name,He=Ee.triggerUpdate,Be=He===void 0?!1:He,ft=Ee.onChange,$e=ft===void 0?function(Ye,yt){}:ft,Tt=Ee.defaultVal,Pt=Tt===void 0?null:Tt;return function(Ye){var yt=U[Pe];if(!arguments.length)return yt;var Ot=Ye===void 0?Pt:Ye;return U[Pe]=Ot,$e.call(oe,Ot,U,yt),!j.hasOwnProperty(Pe)&&(j[Pe]=yt),Be&&O(),oe}}}),Object.keys(c).forEach(function(le){oe[le]=function(){for(var be,Ee=arguments.length,Pe=new Array(Ee),He=0;He<Ee;He++)Pe[He]=arguments[He];return(be=c[le]).call.apply(be,[oe,U].concat(Pe))}}),Object.entries(f).forEach(function(le){var be=Jm(le,2),Ee=be[0],Pe=be[1];return oe[Ee]=oe[Pe]}),oe.resetProps=function(){return T.forEach(function(le){oe[le.name](le.defaultVal)}),oe},oe.resetProps(),U._rerender=O,D&&F&&oe(F),oe}}var Wn=function(i){return typeof i=="function"?i:typeof i=="string"?function(e){return e[i]}:function(e){return i}};function ng(i,e){let t;if(e===void 0)for(const r of i)r!=null&&(t>r||t===void 0&&r>=r)&&(t=r);else{let r=-1;for(let s of i)(s=e(s,++r,i))!=null&&(t>s||t===void 0&&s>=s)&&(t=s)}return t}function Qd(i,e){let t;if(e===void 0)for(const r of i)r!=null&&(t<r||t===void 0&&r>=r)&&(t=r);else{let r=-1;for(let s of i)(s=e(s,++r,i))!=null&&(t<s||t===void 0&&s>=s)&&(t=s)}return t}function Rl(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,r=Array(e);t<e;t++)r[t]=i[t];return r}function ig(i){if(Array.isArray(i))return i}function rg(i){if(Array.isArray(i))return Rl(i)}function sg(i,e,t){if(typeof i=="function"?i===e:i.has(e))return arguments.length<3?e:t;throw new TypeError("Private element is not present on this object")}function og(i,e){if(e.has(i))throw new TypeError("Cannot initialize the same private elements twice on an object")}function ag(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")}function pr(i,e){return i.get(sg(i,e))}function Ca(i,e,t){og(i,e),e.set(i,t)}function Nl(i,e,t){return i.set(sg(i,e),t),t}function cg(i,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(i,xg(r.key),r)}}function lg(i,e,t){return e&&cg(i.prototype,e),Object.defineProperty(i,"prototype",{writable:!1}),i}function ug(i){if(typeof Symbol!="undefined"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function hg(i,e){var t=i==null?null:typeof Symbol!="undefined"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var r,s,a,c,h=[],f=!0,m=!1;try{if(a=(t=t.call(i)).next,e!==0)for(;!(f=(r=a.call(t)).done)&&(h.push(r.value),h.length!==e);f=!0);}catch(x){m=!0,s=x}finally{try{if(!f&&t.return!=null&&(c=t.return(),Object(c)!==c))return}finally{if(m)throw s}}return h}}function dg(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function fg(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function pg(i,e){return ig(i)||hg(i,e)||Jd(i,e)||dg()}function mg(i){return rg(i)||ug(i)||Jd(i)||fg()}function gg(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var r=t.call(i,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(i)}function xg(i){var e=gg(i,"string");return typeof e=="symbol"?e:e+""}function Jd(i,e){if(i){if(typeof i=="string")return Rl(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Rl(i,e):void 0}}var Ra=new WeakMap,Cc=new WeakMap,Na=new WeakMap,sh=new WeakMap,oh=new WeakMap,ah=new WeakMap,_g=function(){function i(){ag(this,i),Ca(this,Ra,new Map),Ca(this,Cc,new Map),Ca(this,Na,function(e){return e}),Ca(this,sh,function(){return{}}),Ca(this,oh,function(){}),Ca(this,ah,function(){})}return lg(i,[{key:"getObj",value:function(t){return pr(Ra,this).get(pr(Na,this).call(this,t))}},{key:"getData",value:function(t){return pr(Cc,this).get(t)}},{key:"entries",value:function(){return mg(pr(Cc,this).entries()).map(function(t){var r=pg(t,2),s=r[0],a=r[1];return[a,s]})}},{key:"id",value:function(t){return Nl(Na,this,Wn(t)),this}},{key:"onCreateObj",value:function(t){return Nl(sh,this,t),this}},{key:"onUpdateObj",value:function(t){return Nl(oh,this,t),this}},{key:"onRemoveObj",value:function(t){return Nl(ah,this,t),this}},{key:"digest",value:function(t){var r=this;t.filter(function(a){return!pr(Ra,r).has(pr(Na,r).call(r,a))}).forEach(function(a){var c=pr(sh,r).call(r,a);pr(Ra,r).set(pr(Na,r).call(r,a),c),pr(Cc,r).set(c,a)});var s=new Map(t.map(function(a){return[pr(Na,r).call(r,a),a]}));return pr(Ra,this).forEach(function(a,c){s.has(c)?pr(oh,r).call(r,a,s.get(c)):(pr(ah,r).call(r,a,c),pr(Ra,r).delete(c),pr(Cc,r).delete(a))}),this}},{key:"clear",value:function(){return this.digest([]),this}}])}();class ef extends Map{constructor(e,t=rf){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(const[r,s]of e)this.set(r,s)}get(e){return super.get(ch(this,e))}has(e){return super.has(ch(this,e))}set(e,t){return super.set(tf(this,e),t)}delete(e){return super.delete(nf(this,e))}}class N_ extends null{constructor(e,t=rf){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(const r of e)this.add(r)}has(e){return super.has(ch(this,e))}add(e){return super.add(tf(this,e))}delete(e){return super.delete(nf(this,e))}}function ch({_intern:i,_key:e},t){const r=e(t);return i.has(r)?i.get(r):t}function tf({_intern:i,_key:e},t){const r=e(t);return i.has(r)?i.get(r):(i.set(r,t),t)}function nf({_intern:i,_key:e},t){const r=e(t);return i.has(r)&&(t=i.get(r),i.delete(r)),t}function rf(i){return i!==null&&typeof i=="object"?i.valueOf():i}function yg(i,e){switch(arguments.length){case 0:break;case 1:this.range(i);break;default:this.range(e).domain(i);break}return this}function P_(i,e){switch(arguments.length){case 0:break;case 1:{typeof i=="function"?this.interpolator(i):this.range(i);break}default:{this.domain(i),typeof e=="function"?this.interpolator(e):this.range(e);break}}return this}const sf=Symbol("implicit");function of(){var i=new ef,e=[],t=[],r=sf;function s(a){let c=i.get(a);if(c===void 0){if(r!==sf)return r;i.set(a,c=e.push(a)-1)}return t[c%t.length]}return s.domain=function(a){if(!arguments.length)return e.slice();e=[],i=new ef;for(const c of a)i.has(c)||i.set(c,e.push(c)-1);return s},s.range=function(a){return arguments.length?(t=Array.from(a),s):t.slice()},s.unknown=function(a){return arguments.length?(r=a,s):r},s.copy=function(){return of(e,t).unknown(r)},yg.apply(s,arguments),s}function L_(i){for(var e=i.length/6|0,t=new Array(e),r=0;r<e;)t[r]="#"+i.slice(r*6,++r*6);return t}var I_=L_("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928");function lh(i){"@babel/helpers - typeof";return lh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},lh(i)}var uh=/^\s+/,af=/\s+$/;function Kt(i,e){if(i=i||"",e=e||{},i instanceof Kt)return i;if(!(this instanceof Kt))return new Kt(i,e);var t=Rc(i);this._originalInput=i,this._r=t.r,this._g=t.g,this._b=t.b,this._a=t.a,this._roundA=Math.round(100*this._a)/100,this._format=e.format||t.format,this._gradientType=e.gradientType,this._r<1&&(this._r=Math.round(this._r)),this._g<1&&(this._g=Math.round(this._g)),this._b<1&&(this._b=Math.round(this._b)),this._ok=t.ok}Kt.prototype={isDark:function(){return this.getBrightness()<128},isLight:function(){return!this.isDark()},isValid:function(){return this._ok},getOriginalInput:function(){return this._originalInput},getFormat:function(){return this._format},getAlpha:function(){return this._a},getBrightness:function(){var e=this.toRgb();return(e.r*299+e.g*587+e.b*114)/1e3},getLuminance:function(){var e=this.toRgb(),t,r,s,a,c,h;return t=e.r/255,r=e.g/255,s=e.b/255,t<=.03928?a=t/12.92:a=Math.pow((t+.055)/1.055,2.4),r<=.03928?c=r/12.92:c=Math.pow((r+.055)/1.055,2.4),s<=.03928?h=s/12.92:h=Math.pow((s+.055)/1.055,2.4),.2126*a+.7152*c+.0722*h},setAlpha:function(e){return this._a=vg(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=lf(this._r,this._g,this._b);return{h:e.h*360,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=lf(this._r,this._g,this._b),t=Math.round(e.h*360),r=Math.round(e.s*100),s=Math.round(e.v*100);return this._a==1?"hsv("+t+", "+r+"%, "+s+"%)":"hsva("+t+", "+r+"%, "+s+"%, "+this._roundA+")"},toHsl:function(){var e=Pl(this._r,this._g,this._b);return{h:e.h*360,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=Pl(this._r,this._g,this._b),t=Math.round(e.h*360),r=Math.round(e.s*100),s=Math.round(e.l*100);return this._a==1?"hsl("+t+", "+r+"%, "+s+"%)":"hsla("+t+", "+r+"%, "+s+"%, "+this._roundA+")"},toHex:function(e){return D_(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return nT(this._r,this._g,this._b,this._a,e)},toHex8String:function(e){return"#"+this.toHex8(e)},toRgb:function(){return{r:Math.round(this._r),g:Math.round(this._g),b:Math.round(this._b),a:this._a}},toRgbString:function(){return this._a==1?"rgb("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+")":"rgba("+Math.round(this._r)+", "+Math.round(this._g)+", "+Math.round(this._b)+", "+this._roundA+")"},toPercentageRgb:function(){return{r:Math.round(Ci(this._r,255)*100)+"%",g:Math.round(Ci(this._g,255)*100)+"%",b:Math.round(Ci(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(Ci(this._r,255)*100)+"%, "+Math.round(Ci(this._g,255)*100)+"%, "+Math.round(Ci(this._b,255)*100)+"%)":"rgba("+Math.round(Ci(this._r,255)*100)+"%, "+Math.round(Ci(this._g,255)*100)+"%, "+Math.round(Ci(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:O_[D_(this._r,this._g,this._b,!0)]||!1},toFilter:function(e){var t="#"+bg(this._r,this._g,this._b,this._a),r=t,s=this._gradientType?"GradientType = 1, ":"";if(e){var a=Kt(e);r="#"+bg(a._r,a._g,a._b,a._a)}return"progid:DXImageTransform.Microsoft.gradient("+s+"startColorstr="+t+",endColorstr="+r+")"},toString:function(e){var t=!!e;e=e||this._format;var r=!1,s=this._a<1&&this._a>=0,a=!t&&s&&(e==="hex"||e==="hex6"||e==="hex3"||e==="hex4"||e==="hex8"||e==="name");return a?e==="name"&&this._a===0?this.toName():this.toRgbString():(e==="rgb"&&(r=this.toRgbString()),e==="prgb"&&(r=this.toPercentageRgbString()),(e==="hex"||e==="hex6")&&(r=this.toHexString()),e==="hex3"&&(r=this.toHexString(!0)),e==="hex4"&&(r=this.toHex8String(!0)),e==="hex8"&&(r=this.toHex8String()),e==="name"&&(r=this.toName()),e==="hsl"&&(r=this.toHslString()),e==="hsv"&&(r=this.toHsvString()),r||this.toHexString())},clone:function(){return Kt(this.toString())},_applyModification:function(e,t){var r=e.apply(null,[this].concat([].slice.call(t)));return this._r=r._r,this._g=r._g,this._b=r._b,this.setAlpha(r._a),this},lighten:function(){return this._applyModification(Pa,arguments)},brighten:function(){return this._applyModification(F_,arguments)},darken:function(){return this._applyModification(uf,arguments)},desaturate:function(){return this._applyModification(U_,arguments)},saturate:function(){return this._applyModification(iT,arguments)},greyscale:function(){return this._applyModification(rT,arguments)},spin:function(){return this._applyModification(Qr,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(B_,arguments)},complement:function(){return this._applyCombination(hf,arguments)},monochromatic:function(){return this._applyCombination(La,arguments)},splitcomplement:function(){return this._applyCombination(dh,arguments)},triad:function(){return this._applyCombination(hh,[3])},tetrad:function(){return this._applyCombination(hh,[4])}},Kt.fromRatio=function(i,e){if(lh(i)=="object"){var t={};for(var r in i)i.hasOwnProperty(r)&&(r==="a"?t[r]=i[r]:t[r]=Ll(i[r]));i=t}return Kt(i,e)};function Rc(i){var e={r:0,g:0,b:0},t=1,r=null,s=null,a=null,c=!1,h=!1;return typeof i=="string"&&(i=G_(i)),lh(i)=="object"&&(Ao(i.r)&&Ao(i.g)&&Ao(i.b)?(e=Nc(i.r,i.g,i.b),c=!0,h=String(i.r).substr(-1)==="%"?"prgb":"rgb"):Ao(i.h)&&Ao(i.s)&&Ao(i.v)?(r=Ll(i.s),s=Ll(i.v),e=tT(i.h,r,s),c=!0,h="hsv"):Ao(i.h)&&Ao(i.s)&&Ao(i.l)&&(r=Ll(i.s),a=Ll(i.l),e=cf(i.h,r,a),c=!0,h="hsl"),i.hasOwnProperty("a")&&(t=i.a)),t=vg(t),{ok:c,format:i.format||h,r:Math.min(255,Math.max(e.r,0)),g:Math.min(255,Math.max(e.g,0)),b:Math.min(255,Math.max(e.b,0)),a:t}}function Nc(i,e,t){return{r:Ci(i,255)*255,g:Ci(e,255)*255,b:Ci(t,255)*255}}function Pl(i,e,t){i=Ci(i,255),e=Ci(e,255),t=Ci(t,255);var r=Math.max(i,e,t),s=Math.min(i,e,t),a,c,h=(r+s)/2;if(r==s)a=c=0;else{var f=r-s;switch(c=h>.5?f/(2-r-s):f/(r+s),r){case i:a=(e-t)/f+(e<t?6:0);break;case e:a=(t-i)/f+2;break;case t:a=(i-e)/f+4;break}a/=6}return{h:a,s:c,l:h}}function cf(i,e,t){var r,s,a;i=Ci(i,360),e=Ci(e,100),t=Ci(t,100);function c(m,x,_){return _<0&&(_+=1),_>1&&(_-=1),_<1/6?m+(x-m)*6*_:_<1/2?x:_<2/3?m+(x-m)*(2/3-_)*6:m}if(e===0)r=s=a=t;else{var h=t<.5?t*(1+e):t+e-t*e,f=2*t-h;r=c(f,h,i+1/3),s=c(f,h,i),a=c(f,h,i-1/3)}return{r:r*255,g:s*255,b:a*255}}function lf(i,e,t){i=Ci(i,255),e=Ci(e,255),t=Ci(t,255);var r=Math.max(i,e,t),s=Math.min(i,e,t),a,c,h=r,f=r-s;if(c=r===0?0:f/r,r==s)a=0;else{switch(r){case i:a=(e-t)/f+(e<t?6:0);break;case e:a=(t-i)/f+2;break;case t:a=(i-e)/f+4;break}a/=6}return{h:a,s:c,v:h}}function tT(i,e,t){i=Ci(i,360)*6,e=Ci(e,100),t=Ci(t,100);var r=Math.floor(i),s=i-r,a=t*(1-e),c=t*(1-s*e),h=t*(1-(1-s)*e),f=r%6,m=[t,c,a,a,h,t][f],x=[h,t,t,c,a,a][f],_=[a,a,h,t,t,c][f];return{r:m*255,g:x*255,b:_*255}}function D_(i,e,t,r){var s=[Ns(Math.round(i).toString(16)),Ns(Math.round(e).toString(16)),Ns(Math.round(t).toString(16))];return r&&s[0].charAt(0)==s[0].charAt(1)&&s[1].charAt(0)==s[1].charAt(1)&&s[2].charAt(0)==s[2].charAt(1)?s[0].charAt(0)+s[1].charAt(0)+s[2].charAt(0):s.join("")}function nT(i,e,t,r,s){var a=[Ns(Math.round(i).toString(16)),Ns(Math.round(e).toString(16)),Ns(Math.round(t).toString(16)),Ns(Sg(r))];return s&&a[0].charAt(0)==a[0].charAt(1)&&a[1].charAt(0)==a[1].charAt(1)&&a[2].charAt(0)==a[2].charAt(1)&&a[3].charAt(0)==a[3].charAt(1)?a[0].charAt(0)+a[1].charAt(0)+a[2].charAt(0)+a[3].charAt(0):a.join("")}function bg(i,e,t,r){var s=[Ns(Sg(r)),Ns(Math.round(i).toString(16)),Ns(Math.round(e).toString(16)),Ns(Math.round(t).toString(16))];return s.join("")}Kt.equals=function(i,e){return!i||!e?!1:Kt(i).toRgbString()==Kt(e).toRgbString()},Kt.random=function(){return Kt.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function U_(i,e){e=e===0?0:e||10;var t=Kt(i).toHsl();return t.s-=e/100,t.s=fh(t.s),Kt(t)}function iT(i,e){e=e===0?0:e||10;var t=Kt(i).toHsl();return t.s+=e/100,t.s=fh(t.s),Kt(t)}function rT(i){return Kt(i).desaturate(100)}function Pa(i,e){e=e===0?0:e||10;var t=Kt(i).toHsl();return t.l+=e/100,t.l=fh(t.l),Kt(t)}function F_(i,e){e=e===0?0:e||10;var t=Kt(i).toRgb();return t.r=Math.max(0,Math.min(255,t.r-Math.round(255*-(e/100)))),t.g=Math.max(0,Math.min(255,t.g-Math.round(255*-(e/100)))),t.b=Math.max(0,Math.min(255,t.b-Math.round(255*-(e/100)))),Kt(t)}function uf(i,e){e=e===0?0:e||10;var t=Kt(i).toHsl();return t.l-=e/100,t.l=fh(t.l),Kt(t)}function Qr(i,e){var t=Kt(i).toHsl(),r=(t.h+e)%360;return t.h=r<0?360+r:r,Kt(t)}function hf(i){var e=Kt(i).toHsl();return e.h=(e.h+180)%360,Kt(e)}function hh(i,e){if(isNaN(e)||e<=0)throw new Error("Argument to polyad must be a positive number");for(var t=Kt(i).toHsl(),r=[Kt(i)],s=360/e,a=1;a<e;a++)r.push(Kt({h:(t.h+a*s)%360,s:t.s,l:t.l}));return r}function dh(i){var e=Kt(i).toHsl(),t=e.h;return[Kt(i),Kt({h:(t+72)%360,s:e.s,l:e.l}),Kt({h:(t+216)%360,s:e.s,l:e.l})]}function B_(i,e,t){e=e||6,t=t||30;var r=Kt(i).toHsl(),s=360/t,a=[Kt(i)];for(r.h=(r.h-(s*e>>1)+720)%360;--e;)r.h=(r.h+s)%360,a.push(Kt(r));return a}function La(i,e){e=e||6;for(var t=Kt(i).toHsv(),r=t.h,s=t.s,a=t.v,c=[],h=1/e;e--;)c.push(Kt({h:r,s,v:a})),a=(a+h)%1;return c}Kt.mix=function(i,e,t){t=t===0?0:t||50;var r=Kt(i).toRgb(),s=Kt(e).toRgb(),a=t/100,c={r:(s.r-r.r)*a+r.r,g:(s.g-r.g)*a+r.g,b:(s.b-r.b)*a+r.b,a:(s.a-r.a)*a+r.a};return Kt(c)},Kt.readability=function(i,e){var t=Kt(i),r=Kt(e);return(Math.max(t.getLuminance(),r.getLuminance())+.05)/(Math.min(t.getLuminance(),r.getLuminance())+.05)},Kt.isReadable=function(i,e,t){var r=Kt.readability(i,e),s,a;switch(a=!1,s=W_(t),s.level+s.size){case"AAsmall":case"AAAlarge":a=r>=4.5;break;case"AAlarge":a=r>=3;break;case"AAAsmall":a=r>=7;break}return a},Kt.mostReadable=function(i,e,t){var r=null,s=0,a,c,h,f;t=t||{},c=t.includeFallbackColors,h=t.level,f=t.size;for(var m=0;m<e.length;m++)a=Kt.readability(i,e[m]),a>s&&(s=a,r=Kt(e[m]));return Kt.isReadable(i,r,{level:h,size:f})||!c?r:(t.includeFallbackColors=!1,Kt.mostReadable(i,["#fff","#000"],t))};var df=Kt.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"663399",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},O_=Kt.hexNames=k_(df);function k_(i){var e={};for(var t in i)i.hasOwnProperty(t)&&(e[i[t]]=t);return e}function vg(i){return i=parseFloat(i),(isNaN(i)||i<0||i>1)&&(i=1),i}function Ci(i,e){V_(i)&&(i="100%");var t=z_(i);return i=Math.min(e,Math.max(0,parseFloat(i))),t&&(i=parseInt(i*e,10)/100),Math.abs(i-e)<1e-6?1:i%e/parseFloat(e)}function fh(i){return Math.min(1,Math.max(0,i))}function Jr(i){return parseInt(i,16)}function V_(i){return typeof i=="string"&&i.indexOf(".")!=-1&&parseFloat(i)===1}function z_(i){return typeof i=="string"&&i.indexOf("%")!=-1}function Ns(i){return i.length==1?"0"+i:""+i}function Ll(i){return i<=1&&(i=i*100+"%"),i}function Sg(i){return Math.round(parseFloat(i)*255).toString(16)}function Tg(i){return Jr(i)/255}var es=function(){var i="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",t="(?:"+e+")|(?:"+i+")",r="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",s="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?";return{CSS_UNIT:new RegExp(t),rgb:new RegExp("rgb"+r),rgba:new RegExp("rgba"+s),hsl:new RegExp("hsl"+r),hsla:new RegExp("hsla"+s),hsv:new RegExp("hsv"+r),hsva:new RegExp("hsva"+s),hex3:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex6:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,hex4:/^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,hex8:/^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/}}();function Ao(i){return!!es.CSS_UNIT.exec(i)}function G_(i){i=i.replace(uh,"").replace(af,"").toLowerCase();var e=!1;if(df[i])i=df[i],e=!0;else if(i=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var t;return(t=es.rgb.exec(i))?{r:t[1],g:t[2],b:t[3]}:(t=es.rgba.exec(i))?{r:t[1],g:t[2],b:t[3],a:t[4]}:(t=es.hsl.exec(i))?{h:t[1],s:t[2],l:t[3]}:(t=es.hsla.exec(i))?{h:t[1],s:t[2],l:t[3],a:t[4]}:(t=es.hsv.exec(i))?{h:t[1],s:t[2],v:t[3]}:(t=es.hsva.exec(i))?{h:t[1],s:t[2],v:t[3],a:t[4]}:(t=es.hex8.exec(i))?{r:Jr(t[1]),g:Jr(t[2]),b:Jr(t[3]),a:Tg(t[4]),format:e?"name":"hex8"}:(t=es.hex6.exec(i))?{r:Jr(t[1]),g:Jr(t[2]),b:Jr(t[3]),format:e?"name":"hex"}:(t=es.hex4.exec(i))?{r:Jr(t[1]+""+t[1]),g:Jr(t[2]+""+t[2]),b:Jr(t[3]+""+t[3]),a:Tg(t[4]+""+t[4]),format:e?"name":"hex8"}:(t=es.hex3.exec(i))?{r:Jr(t[1]+""+t[1]),g:Jr(t[2]+""+t[2]),b:Jr(t[3]+""+t[3]),format:e?"name":"hex"}:!1}function W_(i){var e,t;return i=i||{level:"AA",size:"small"},e=(i.level||"AA").toUpperCase(),t=(i.size||"small").toLowerCase(),e!=="AA"&&e!=="AAA"&&(e="AA"),t!=="small"&&t!=="large"&&(t="small"),{level:e,size:t}}function ff(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,r=Array(e);t<e;t++)r[t]=i[t];return r}function H_(i){if(Array.isArray(i))return i}function $_(i){if(Array.isArray(i))return ff(i)}function Mg(i,e,t){if(typeof i=="function"?i===e:i.has(e))return arguments.length<3?e:t;throw new TypeError("Private element is not present on this object")}function j_(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function Pc(i,e,t){return e=Mr(e),ey(i,gf()?Reflect.construct(e,t||[],Mr(i).constructor):e.apply(i,t))}function X_(i,e){if(e.has(i))throw new TypeError("Cannot initialize the same private elements twice on an object")}function q_(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")}function wg(i,e){return i.get(Mg(i,e))}function K_(i,e,t){X_(i,e),e.set(i,t)}function Z_(i,e,t){return i.set(Mg(i,e),t),t}function Y_(i,e,t){if(gf())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,e);var s=new(i.bind.apply(i,r));return s}function sT(i,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(i,Yn(r.key),r)}}function Q_(i,e,t){return e&&sT(i.prototype,e),Object.defineProperty(i,"prototype",{writable:!1}),i}function pf(i,e,t){return(e=Yn(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function mf(){return mf=typeof Reflect!="undefined"&&Reflect.get?Reflect.get.bind():function(i,e,t){var r=cT(i,e);if(r){var s=Object.getOwnPropertyDescriptor(r,e);return s.get?s.get.call(arguments.length<3?i:t):s.value}},mf.apply(null,arguments)}function Mr(i){return Mr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Mr(i)}function Ia(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),Object.defineProperty(i,"prototype",{writable:!1}),e&&ph(i,e)}function gf(){try{var i=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(gf=function(){return!!i})()}function oT(i){if(typeof Symbol!="undefined"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function aT(i,e){var t=i==null?null:typeof Symbol!="undefined"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var r,s,a,c,h=[],f=!0,m=!1;try{if(a=(t=t.call(i)).next,e!==0)for(;!(f=(r=a.call(t)).done)&&(h.push(r.value),h.length!==e);f=!0);}catch(x){m=!0,s=x}finally{try{if(!f&&t.return!=null&&(c=t.return(),Object(c)!==c))return}finally{if(m)throw s}}return h}}function Ag(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function J_(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Da(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,r)}return t}function Il(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Da(Object(t),!0).forEach(function(r){pf(i,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):Da(Object(t)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(t,r))})}return i}function ey(i,e){if(e&&(typeof e=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return j_(i)}function ph(i,e){return ph=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,r){return t.__proto__=r,t},ph(i,e)}function ms(i,e){return H_(i)||aT(i,e)||Cg(i,e)||Ag()}function cT(i,e){for(;!{}.hasOwnProperty.call(i,e)&&(i=Mr(i))!==null;);return i}function Eg(i,e,t,r){var s=mf(Mr(i.prototype),e,t);return typeof s=="function"?function(a){return s.apply(t,a)}:s}function ts(i){return $_(i)||oT(i)||Cg(i)||J_()}function dn(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var r=t.call(i,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function Yn(i){var e=dn(i,"string");return typeof e=="symbol"?e:e+""}function Dl(i){"@babel/helpers - typeof";return Dl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Dl(i)}function Cg(i,e){if(i){if(typeof i=="string")return ff(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?ff(i,e):void 0}}var ea=function(e){e instanceof Array?e.forEach(ea):(e.map&&e.map.dispose(),e.dispose())},mr=function(e){e.geometry&&e.geometry.dispose(),e.material&&ea(e.material),e.texture&&e.texture.dispose(),e.children&&e.children.forEach(mr)},mh=function(e){for(;e.children.length;){var t=e.children[0];e.remove(t),mr(t)}},Eo=new WeakMap,Co=new WeakMap,gr=function(i){function e(t){var r,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},a=s.dataBindAttr,c=a===void 0?"__data":a,h=s.objBindAttr,f=h===void 0?"__threeObj":h;return q_(this,e),r=Pc(this,e),pf(r,"scene",void 0),K_(r,Eo,void 0),K_(r,Co,void 0),r.scene=t,Z_(Eo,r,c),Z_(Co,r,f),r.onRemoveObj(function(){}),r}return Ia(e,i),Q_(e,[{key:"onCreateObj",value:function(r){var s=this;return Eg(e,"onCreateObj",this)([function(a){var c=r(a);return a[wg(Co,s)]=c,c[wg(Eo,s)]=a,s.scene.add(c),c}]),this}},{key:"onRemoveObj",value:function(r){var s=this;return Eg(e,"onRemoveObj",this)([function(a,c){var h=Eg(e,"getData",s)([a]);r(a,c),s.scene.remove(a),mh(a),delete h[wg(Co,s)]}]),this}}])}(_g),an=function(e){return isNaN(e)?parseInt(Kt(e).toHex(),16):e},Ul=function(e){return isNaN(e)?Kt(e).getAlpha():1},ty=of(I_);function Rg(i,e,t){!e||typeof t!="string"||i.filter(function(r){return!r[t]}).forEach(function(r){r[t]=ty(e(r))})}function Fl(i,e){var t=i.nodes,r=i.links,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=s.nodeFilter,c=a===void 0?function(){return!0}:a,h=s.onLoopError,f=h===void 0?function(T){throw"Invalid DAG structure! Found cycle in node path: ".concat(T.join(" -> "),".")}:h,m={};t.forEach(function(T){return m[e(T)]={data:T,out:[],depth:-1,skip:!c(T)}}),r.forEach(function(T){var w=T.source,P=T.target,C=W(w),E=W(P);if(!m.hasOwnProperty(C))throw"Missing source node with id: ".concat(C);if(!m.hasOwnProperty(E))throw"Missing target node with id: ".concat(E);var D=m[C],F=m[E];D.out.push(F);function W(K){return Dl(K)==="object"?e(K):K}});var x=[];v(Object.values(m));var _=Object.assign.apply(Object,[{}].concat(ts(Object.entries(m).filter(function(T){var w=ms(T,2),P=w[1];return!P.skip}).map(function(T){var w=ms(T,2),P=w[0],C=w[1];return pf({},P,C.depth)}))));return _;function v(T){for(var w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],P=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,C=function(){var W=T[E];if(w.indexOf(W)!==-1){var K=[].concat(ts(w.slice(w.indexOf(W))),[W]).map(function(U){return e(U.data)});return x.some(function(U){return U.length===K.length&&U.every(function(j,oe){return j===K[oe]})})||(x.push(K),f(K)),1}P>W.depth&&(W.depth=P,v(W.out,[].concat(ts(w),[W]),P+(W.skip?0:1)))},E=0,D=T.length;E<D;E++)C()}}var gn=window.THREE?window.THREE:{Group:d.ZAu,Mesh:d.Kj0,MeshLambertMaterial:d.YBo,Color:d.Ilk,BufferGeometry:d.u9r,BufferAttribute:d.TlE,Matrix4:d.yGw,Vector3:d.Pa4,SphereGeometry:d.xo$,CylinderGeometry:d.fHI,TubeGeometry:d.WXh,ConeGeometry:d.b_z,Line:d.x12,LineBasicMaterial:d.nls,QuadraticBezierCurve3:d.mXe,CubicBezierCurve3:d.yj7,Box3:d.ZzF},Ng={graph:kt,forcelayout:_i},ny=2,xf=new gn.BufferGeometry().setAttribute?"setAttribute":"addAttribute",gh=new gn.BufferGeometry().applyMatrix4?"applyMatrix4":"applyMatrix",iy=wo({props:{jsonUrl:{onChange:function(e,t){var r=this;e&&!t.fetchingJson&&(t.fetchingJson=!0,t.onLoading(),fetch(e).then(function(s){return s.json()}).then(function(s){t.fetchingJson=!1,t.onFinishLoading(s),r.graphData(s)}))},triggerUpdate:!1},graphData:{default:{nodes:[],links:[]},onChange:function(e,t){t.engineRunning=!1}},numDimensions:{default:3,onChange:function(e,t){var r=t.d3ForceLayout.force("charge");r&&r.strength(e>2?-60:-30),e<3&&s(t.graphData.nodes,"z"),e<2&&s(t.graphData.nodes,"y");function s(a,c){a.forEach(function(h){delete h[c],delete h["v".concat(c)]})}}},dagMode:{onChange:function(e,t){!e&&t.forceEngine==="d3"&&(t.graphData.nodes||[]).forEach(function(r){return r.fx=r.fy=r.fz=void 0})}},dagLevelDistance:{},dagNodeFilter:{default:function(e){return!0}},onDagError:{triggerUpdate:!1},nodeRelSize:{default:4},nodeId:{default:"id"},nodeVal:{default:"val"},nodeResolution:{default:8},nodeColor:{default:"color"},nodeAutoColorBy:{},nodeOpacity:{default:.75},nodeVisibility:{default:!0},nodeThreeObject:{},nodeThreeObjectExtend:{default:!1},nodePositionUpdate:{triggerUpdate:!1},linkSource:{default:"source"},linkTarget:{default:"target"},linkVisibility:{default:!0},linkColor:{default:"color"},linkAutoColorBy:{},linkOpacity:{default:.2},linkWidth:{},linkResolution:{default:6},linkCurvature:{default:0,triggerUpdate:!1},linkCurveRotation:{default:0,triggerUpdate:!1},linkMaterial:{},linkThreeObject:{},linkThreeObjectExtend:{default:!1},linkPositionUpdate:{triggerUpdate:!1},linkDirectionalArrowLength:{default:0},linkDirectionalArrowColor:{},linkDirectionalArrowRelPos:{default:.5,triggerUpdate:!1},linkDirectionalArrowResolution:{default:8},linkDirectionalParticles:{default:0},linkDirectionalParticleSpeed:{default:.01,triggerUpdate:!1},linkDirectionalParticleOffset:{default:0,triggerUpdate:!1},linkDirectionalParticleWidth:{default:.5},linkDirectionalParticleColor:{},linkDirectionalParticleResolution:{default:4},linkDirectionalParticleThreeObject:{},forceEngine:{default:"d3"},d3AlphaMin:{default:0},d3AlphaDecay:{default:.0228,triggerUpdate:!1,onChange:function(e,t){t.d3ForceLayout.alphaDecay(e)}},d3AlphaTarget:{default:0,triggerUpdate:!1,onChange:function(e,t){t.d3ForceLayout.alphaTarget(e)}},d3VelocityDecay:{default:.4,triggerUpdate:!1,onChange:function(e,t){t.d3ForceLayout.velocityDecay(e)}},ngraphPhysics:{default:{timeStep:20,gravity:-1.2,theta:.8,springLength:30,springCoefficient:8e-4,dragCoefficient:.02}},warmupTicks:{default:0,triggerUpdate:!1},cooldownTicks:{default:1/0,triggerUpdate:!1},cooldownTime:{default:15e3,triggerUpdate:!1},onLoading:{default:function(){},triggerUpdate:!1},onFinishLoading:{default:function(){},triggerUpdate:!1},onUpdate:{default:function(){},triggerUpdate:!1},onFinishUpdate:{default:function(){},triggerUpdate:!1},onEngineTick:{default:function(){},triggerUpdate:!1},onEngineStop:{default:function(){},triggerUpdate:!1}},methods:{refresh:function(e){return e._flushObjects=!0,e._rerender(),this},d3Force:function(e,t,r){return r===void 0?e.d3ForceLayout.force(t):(e.d3ForceLayout.force(t,r),this)},d3ReheatSimulation:function(e){return e.d3ForceLayout.alpha(1),this.resetCountdown(),this},resetCountdown:function(e){return e.cntTicks=0,e.startTickTime=new Date,e.engineRunning=!0,this},tickFrame:function(e){var t=e.forceEngine!=="ngraph";return e.engineRunning&&r(),s(),a(),this;function r(){++e.cntTicks>e.cooldownTicks||new Date-e.startTickTime>e.cooldownTime||t&&e.d3AlphaMin>0&&e.d3ForceLayout.alpha()<e.d3AlphaMin?(e.engineRunning=!1,e.onEngineStop()):(e.layout[t?"tick":"step"](),e.onEngineTick());var c=Wn(e.nodeThreeObjectExtend);e.nodeDataMapper.entries().forEach(function(v){var T=ms(v,2),w=T[0],P=T[1];if(P){var C=t?w:e.layout.getNodePosition(w[e.nodeId]),E=c(w);(!e.nodePositionUpdate||!e.nodePositionUpdate(E?P.children[0]:P,{x:C.x,y:C.y,z:C.z},w)||E)&&(P.position.x=C.x,P.position.y=C.y||0,P.position.z=C.z||0)}});var h=Wn(e.linkWidth),f=Wn(e.linkCurvature),m=Wn(e.linkCurveRotation),x=Wn(e.linkThreeObjectExtend);e.linkDataMapper.entries().forEach(function(v){var T=ms(v,2),w=T[0],P=T[1];if(P){var C=t?w:e.layout.getLinkPosition(e.layout.graph.getLink(w.source,w.target).id),E=C[t?"source":"from"],D=C[t?"target":"to"];if(!(!E||!D||!E.hasOwnProperty("x")||!D.hasOwnProperty("x"))){_(w);var F=x(w);if(!(e.linkPositionUpdate&&e.linkPositionUpdate(F?P.children[1]:P,{start:{x:E.x,y:E.y,z:E.z},end:{x:D.x,y:D.y,z:D.z}},w)&&!F)){var W=30,K=w.__curve,U=P.children.length?P.children[0]:P;if(U.type==="Line"){if(K){var oe=K.getPoints(W);U.geometry.getAttribute("position").array.length!==oe.length*3&&U.geometry[xf]("position",new gn.BufferAttribute(new Float32Array(oe.length*3),3)),U.geometry.setFromPoints(oe)}else{var j=U.geometry.getAttribute("position");(!j||!j.array||j.array.length!==6)&&U.geometry[xf]("position",j=new gn.BufferAttribute(new Float32Array(2*3),3)),j.array[0]=E.x,j.array[1]=E.y||0,j.array[2]=E.z||0,j.array[3]=D.x,j.array[4]=D.y||0,j.array[5]=D.z||0,j.needsUpdate=!0}U.geometry.computeBoundingSphere()}else if(U.type==="Mesh")if(K){U.geometry.type.match(/^Tube(Buffer)?Geometry$/)||(U.position.set(0,0,0),U.rotation.set(0,0,0),U.scale.set(1,1,1));var He=Math.ceil(h(w)*10)/10,Be=He/2,ft=new gn.TubeGeometry(K,W,Be,e.linkResolution,!1);U.geometry.dispose(),U.geometry=ft}else{if(!U.geometry.type.match(/^Cylinder(Buffer)?Geometry$/)){var k=Math.ceil(h(w)*10)/10,O=k/2,le=new gn.CylinderGeometry(O,O,1,e.linkResolution,1,!1);le[gh](new gn.Matrix4().makeTranslation(0,1/2,0)),le[gh](new gn.Matrix4().makeRotationX(Math.PI/2)),U.geometry.dispose(),U.geometry=le}var be=new gn.Vector3(E.x,E.y||0,E.z||0),Ee=new gn.Vector3(D.x,D.y||0,D.z||0),Pe=be.distanceTo(Ee);U.position.x=be.x,U.position.y=be.y,U.position.z=be.z,U.scale.z=Pe,U.parent.localToWorld(Ee),U.lookAt(Ee)}}}}});function _(v){var T=t?v:e.layout.getLinkPosition(e.layout.graph.getLink(v.source,v.target).id),w=T[t?"source":"from"],P=T[t?"target":"to"];if(!(!w||!P||!w.hasOwnProperty("x")||!P.hasOwnProperty("x"))){var C=f(v);if(!C)v.__curve=null;else{var E=new gn.Vector3(w.x,w.y||0,w.z||0),D=new gn.Vector3(P.x,P.y||0,P.z||0),F=E.distanceTo(D),W,K=m(v);if(F>0){var U=P.x-w.x,j=P.y-w.y||0,oe=new gn.Vector3().subVectors(D,E),k=oe.clone().multiplyScalar(C).cross(U!==0||j!==0?new gn.Vector3(0,0,1):new gn.Vector3(0,1,0)).applyAxisAngle(oe.normalize(),K).add(new gn.Vector3().addVectors(E,D).divideScalar(2));W=new gn.QuadraticBezierCurve3(E,k,D)}else{var O=C*70,le=-K,be=le+Math.PI/2;W=new gn.CubicBezierCurve3(E,new gn.Vector3(O*Math.cos(be),O*Math.sin(be),0).add(E),new gn.Vector3(O*Math.cos(le),O*Math.sin(le),0).add(E),D)}v.__curve=W}}}}function s(){var c=Wn(e.linkDirectionalArrowRelPos),h=Wn(e.linkDirectionalArrowLength),f=Wn(e.nodeVal);e.arrowDataMapper.entries().forEach(function(m){var x=ms(m,2),_=x[0],v=x[1];if(v){var T=t?_:e.layout.getLinkPosition(e.layout.graph.getLink(_.source,_.target).id),w=T[t?"source":"from"],P=T[t?"target":"to"];if(!(!w||!P||!w.hasOwnProperty("x")||!P.hasOwnProperty("x"))){var C=Math.cbrt(Math.max(0,f(w)||1))*e.nodeRelSize,E=Math.cbrt(Math.max(0,f(P)||1))*e.nodeRelSize,D=h(_),F=c(_),W=_.__curve?function(O){return _.__curve.getPoint(O)}:function(O){var le=function(Ee,Pe,He,Be){return Pe[Ee]+(He[Ee]-Pe[Ee])*Be||0};return{x:le("x",w,P,O),y:le("y",w,P,O),z:le("z",w,P,O)}},K=_.__curve?_.__curve.getLength():Math.sqrt(["x","y","z"].map(function(O){return Math.pow((P[O]||0)-(w[O]||0),2)}).reduce(function(O,le){return O+le},0)),U=C+D+(K-C-E-D)*F,j=W(U/K),oe=W((U-D)/K);["x","y","z"].forEach(function(O){return v.position[O]=oe[O]});var k=Y_(gn.Vector3,ts(["x","y","z"].map(function(O){return j[O]})));v.parent.localToWorld(k),v.lookAt(k)}}})}function a(){var c=Wn(e.linkDirectionalParticleSpeed),h=Wn(e.linkDirectionalParticleOffset);e.graphData.links.forEach(function(f){var m=e.particlesDataMapper.getObj(f),x=m&&m.children,_=f.__singleHopPhotonsObj&&f.__singleHopPhotonsObj.children;if(!((!_||!_.length)&&(!x||!x.length))){var v=t?f:e.layout.getLinkPosition(e.layout.graph.getLink(f.source,f.target).id),T=v[t?"source":"from"],w=v[t?"target":"to"];if(!(!T||!w||!T.hasOwnProperty("x")||!w.hasOwnProperty("x"))){var P=c(f),C=Math.abs(h(f)),E=f.__curve?function(F){return f.__curve.getPoint(F)}:function(F){var W=function(U,j,oe,k){return j[U]+(oe[U]-j[U])*k||0};return{x:W("x",T,w,F),y:W("y",T,w,F),z:W("z",T,w,F)}},D=[].concat(ts(x||[]),ts(_||[]));D.forEach(function(F,W){var K=F.parent.__linkThreeObjType==="singleHopPhotons";if(F.hasOwnProperty("__progressRatio")||(F.__progressRatio=K?0:(W+C)/x.length),F.__progressRatio+=P,F.__progressRatio>=1)if(!K)F.__progressRatio=F.__progressRatio%1;else{F.parent.remove(F),mh(F);return}var U=F.__progressRatio,j=E(U);F.geometry.type!=="SphereGeometry"&&F.lookAt(j.x,j.y,j.z),["x","y","z"].forEach(function(oe){return F.position[oe]=j[oe]})})}}})}},emitParticle:function(e,t){if(t&&e.graphData.links.includes(t)){if(!t.__singleHopPhotonsObj){var r=new gn.Group;r.__linkThreeObjType="singleHopPhotons",t.__singleHopPhotonsObj=r,e.graphScene.add(r)}var s=Wn(e.linkDirectionalParticleThreeObject)(t);if(s&&e.linkDirectionalParticleThreeObject===s&&(s=s.clone()),!s){var a=Wn(e.linkDirectionalParticleWidth),c=Math.ceil(a(t)*10)/10/2,h=e.linkDirectionalParticleResolution,f=new gn.SphereGeometry(c,h,h),m=Wn(e.linkColor),x=Wn(e.linkDirectionalParticleColor),_=x(t)||m(t)||"#f0f0f0",v=new gn.Color(an(_)),T=e.linkOpacity*3,w=new gn.MeshLambertMaterial({color:v,transparent:!0,opacity:T});s=new gn.Mesh(f,w)}t.__singleHopPhotonsObj.add(s)}return this},getGraphBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0};if(!e.initialised)return null;var r=function s(a){var c=[];if(a.geometry){a.geometry.computeBoundingBox();var h=new gn.Box3;h.copy(a.geometry.boundingBox).applyMatrix4(a.matrixWorld),c.push(h)}return c.concat.apply(c,ts((a.children||[]).filter(function(f){return!f.hasOwnProperty("__graphObjType")||f.__graphObjType==="node"&&t(f.__data)}).map(s)))}(e.graphScene);return r.length?Object.assign.apply(Object,ts(["x","y","z"].map(function(s){return pf({},s,[ng(r,function(a){return a.min[s]}),Qd(r,function(a){return a.max[s]})])}))):null}},stateInit:function(){return{d3ForceLayout:(0,Ke.Z)().force("link",(0,nt.Z)()).force("charge",(0,ut.Z)()).force("center",(0,jt.Z)()).force("dagRadial",null).stop(),engineRunning:!1}},init:function(e,t){t.graphScene=e,t.nodeDataMapper=new gr(e,{objBindAttr:"__threeObj"}),t.linkDataMapper=new gr(e,{objBindAttr:"__lineObj"}),t.arrowDataMapper=new gr(e,{objBindAttr:"__arrowObj"}),t.particlesDataMapper=new gr(e,{objBindAttr:"__photonsObj"})},update:function(e,t){var r=function(ve){return ve.some(function(Ne){return t.hasOwnProperty(Ne)})};if(e.engineRunning=!1,typeof e.onUpdate=="function"&&e.onUpdate(),e.nodeAutoColorBy!==null&&r(["nodeAutoColorBy","graphData","nodeColor"])&&Rg(e.graphData.nodes,Wn(e.nodeAutoColorBy),e.nodeColor),e.linkAutoColorBy!==null&&r(["linkAutoColorBy","graphData","linkColor"])&&Rg(e.graphData.links,Wn(e.linkAutoColorBy),e.linkColor),e._flushObjects||r(["graphData","nodeThreeObject","nodeThreeObjectExtend","nodeVal","nodeColor","nodeVisibility","nodeRelSize","nodeResolution","nodeOpacity"])){var s=Wn(e.nodeThreeObject),a=Wn(e.nodeThreeObjectExtend),c=Wn(e.nodeVal),h=Wn(e.nodeColor),f=Wn(e.nodeVisibility),m={},x={};(e._flushObjects||r(["nodeThreeObject","nodeThreeObjectExtend"]))&&e.nodeDataMapper.clear(),e.nodeDataMapper.onCreateObj(function(tt){var ve=s(tt),Ne=a(tt);ve&&e.nodeThreeObject===ve&&(ve=ve.clone());var gt;return ve&&!Ne?gt=ve:(gt=new gn.Mesh,gt.__graphDefaultObj=!0,ve&&Ne&&gt.add(ve)),gt.__graphObjType="node",gt}).onUpdateObj(function(tt,ve){if(tt.__graphDefaultObj){var Ne=c(ve)||1,gt=Math.cbrt(Ne)*e.nodeRelSize,qt=e.nodeResolution;(!tt.geometry.type.match(/^Sphere(Buffer)?Geometry$/)||tt.geometry.parameters.radius!==gt||tt.geometry.parameters.widthSegments!==qt)&&(m.hasOwnProperty(Ne)||(m[Ne]=new gn.SphereGeometry(gt,qt,qt)),tt.geometry.dispose(),tt.geometry=m[Ne]);var Nt=h(ve),en=new gn.Color(an(Nt||"#ffffaa")),vi=e.nodeOpacity*Ul(Nt);(tt.material.type!=="MeshLambertMaterial"||!tt.material.color.equals(en)||tt.material.opacity!==vi)&&(x.hasOwnProperty(Nt)||(x[Nt]=new gn.MeshLambertMaterial({color:en,transparent:!0,opacity:vi})),tt.material.dispose(),tt.material=x[Nt])}}).digest(e.graphData.nodes.filter(f))}if(e._flushObjects||r(["graphData","linkThreeObject","linkThreeObjectExtend","linkMaterial","linkColor","linkWidth","linkVisibility","linkResolution","linkOpacity","linkDirectionalArrowLength","linkDirectionalArrowColor","linkDirectionalArrowResolution","linkDirectionalParticles","linkDirectionalParticleWidth","linkDirectionalParticleColor","linkDirectionalParticleResolution","linkDirectionalParticleThreeObject"])){var _=Wn(e.linkThreeObject),v=Wn(e.linkThreeObjectExtend),T=Wn(e.linkMaterial),w=Wn(e.linkVisibility),P=Wn(e.linkColor),C=Wn(e.linkWidth),E={},D={},F={},W=e.graphData.links.filter(w);if((e._flushObjects||r(["linkThreeObject","linkThreeObjectExtend","linkWidth"]))&&e.linkDataMapper.clear(),e.linkDataMapper.onRemoveObj(function(tt){var ve=tt.__data&&tt.__data.__singleHopPhotonsObj;ve&&(ve.parent.remove(ve),mh(ve),delete tt.__data.__singleHopPhotonsObj)}).onCreateObj(function(tt){var ve=_(tt),Ne=v(tt);ve&&e.linkThreeObject===ve&&(ve=ve.clone());var gt;if(!ve||Ne){var qt=!!C(tt);if(qt)gt=new gn.Mesh;else{var Nt=new gn.BufferGeometry;Nt[xf]("position",new gn.BufferAttribute(new Float32Array(2*3),3)),gt=new gn.Line(Nt)}}var en;return ve?Ne?(en=new gn.Group,en.__graphDefaultObj=!0,en.add(gt),en.add(ve)):en=ve:(en=gt,en.__graphDefaultObj=!0),en.renderOrder=10,en.__graphObjType="link",en}).onUpdateObj(function(tt,ve){if(tt.__graphDefaultObj){var Ne=tt.children.length?tt.children[0]:tt,gt=Math.ceil(C(ve)*10)/10,qt=!!gt;if(qt){var Nt=gt/2,en=e.linkResolution;if(!Ne.geometry.type.match(/^Cylinder(Buffer)?Geometry$/)||Ne.geometry.parameters.radiusTop!==Nt||Ne.geometry.parameters.radialSegments!==en){if(!E.hasOwnProperty(gt)){var vi=new gn.CylinderGeometry(Nt,Nt,1,en,1,!1);vi[gh](new gn.Matrix4().makeTranslation(0,1/2,0)),vi[gh](new gn.Matrix4().makeRotationX(Math.PI/2)),E[gt]=vi}Ne.geometry.dispose(),Ne.geometry=E[gt]}}var Dn=T(ve);if(Dn)Ne.material=Dn;else{var si=P(ve),me=new gn.Color(an(si||"#f0f0f0")),Vn=e.linkOpacity*Ul(si),Un=qt?"MeshLambertMaterial":"LineBasicMaterial";if(Ne.material.type!==Un||!Ne.material.color.equals(me)||Ne.material.opacity!==Vn){var li=qt?D:F;li.hasOwnProperty(si)||(li[si]=new gn[Un]({color:me,transparent:Vn<1,opacity:Vn,depthWrite:Vn>=1})),Ne.material.dispose(),Ne.material=li[si]}}}}).digest(W),e.linkDirectionalArrowLength||t.hasOwnProperty("linkDirectionalArrowLength")){var K=Wn(e.linkDirectionalArrowLength),U=Wn(e.linkDirectionalArrowColor);e.arrowDataMapper.onCreateObj(function(){var tt=new gn.Mesh(void 0,new gn.MeshLambertMaterial({transparent:!0}));return tt.__linkThreeObjType="arrow",tt}).onUpdateObj(function(tt,ve){var Ne=K(ve),gt=e.linkDirectionalArrowResolution;if(!tt.geometry.type.match(/^Cone(Buffer)?Geometry$/)||tt.geometry.parameters.height!==Ne||tt.geometry.parameters.radialSegments!==gt){var qt=new gn.ConeGeometry(Ne*.25,Ne,gt);qt.translate(0,Ne/2,0),qt.rotateX(Math.PI/2),tt.geometry.dispose(),tt.geometry=qt}var Nt=U(ve)||P(ve)||"#f0f0f0";tt.material.color=new gn.Color(an(Nt)),tt.material.opacity=e.linkOpacity*3*Ul(Nt)}).digest(W.filter(K))}if(e.linkDirectionalParticles||t.hasOwnProperty("linkDirectionalParticles")){var j=Wn(e.linkDirectionalParticles),oe=Wn(e.linkDirectionalParticleWidth),k=Wn(e.linkDirectionalParticleColor),O=Wn(e.linkDirectionalParticleThreeObject),le={},be={};e.particlesDataMapper.onCreateObj(function(){var tt=new gn.Group;return tt.__linkThreeObjType="photons",tt.__photonDataMapper=new gr(tt),tt}).onUpdateObj(function(tt,ve){var Ne=!!tt.children.length&&tt.children[0],gt=O(ve),qt,Nt;if(gt)qt=gt.geometry,Nt=gt.material;else{var en=Math.ceil(oe(ve)*10)/10/2,vi=e.linkDirectionalParticleResolution;Ne&&Ne.geometry.parameters.radius===en&&Ne.geometry.parameters.widthSegments===vi?qt=Ne.geometry:(be.hasOwnProperty(en)||(be[en]=new gn.SphereGeometry(en,vi,vi)),qt=be[en]);var Dn=k(ve)||P(ve)||"#f0f0f0",si=new gn.Color(an(Dn)),me=e.linkOpacity*3;Ne&&Ne.material.color.equals(si)&&Ne.material.opacity===me?Nt=Ne.material:(le.hasOwnProperty(Dn)||(le[Dn]=new gn.MeshLambertMaterial({color:si,transparent:!0,opacity:me})),Nt=le[Dn])}Ne&&(Ne.geometry!==qt&&Ne.geometry.dispose(),Ne.material!==Nt&&Ne.material.dispose());var Vn=Math.round(Math.abs(j(ve)));tt.__photonDataMapper.id(function(Un){return Un.idx}).onCreateObj(function(){return new gn.Mesh(qt,Nt)}).onUpdateObj(function(Un){Un.geometry=qt,Un.material=Nt}).digest(ts(new Array(Vn)).map(function(Un,li){return{idx:li}}))}).digest(W.filter(j))}}if(e._flushObjects=!1,r(["graphData","nodeId","linkSource","linkTarget","numDimensions","forceEngine","dagMode","dagNodeFilter","dagLevelDistance"])){e.engineRunning=!1,e.graphData.links.forEach(function(tt){tt.source=tt[e.linkSource],tt.target=tt[e.linkTarget]});var Ee=e.forceEngine!=="ngraph",Pe;if(Ee){(Pe=e.d3ForceLayout).stop().alpha(1).numDimensions(e.numDimensions).nodes(e.graphData.nodes);var He=e.d3ForceLayout.force("link");He&&He.id(function(tt){return tt[e.nodeId]}).links(e.graphData.links);var Be=e.dagMode&&Fl(e.graphData,function(tt){return tt[e.nodeId]},{nodeFilter:e.dagNodeFilter,onLoopError:e.onDagError||void 0}),ft=Math.max.apply(Math,ts(Object.values(Be||[]))),$e=e.dagLevelDistance||e.graphData.nodes.length/(ft||1)*ny*(["radialin","radialout"].indexOf(e.dagMode)!==-1?.7:1);if(["lr","rl","td","bu","zin","zout"].includes(t.dagMode)){var Tt=["lr","rl"].includes(t.dagMode)?"fx":["td","bu"].includes(t.dagMode)?"fy":"fz";e.graphData.nodes.filter(e.dagNodeFilter).forEach(function(tt){return delete tt[Tt]})}if(["lr","rl","td","bu","zin","zout"].includes(e.dagMode)){var Pt=["rl","td","zout"].includes(e.dagMode),Ye=function(ve){return(Be[ve[e.nodeId]]-ft/2)*$e*(Pt?-1:1)},yt=["lr","rl"].includes(e.dagMode)?"fx":["td","bu"].includes(e.dagMode)?"fy":"fz";e.graphData.nodes.filter(e.dagNodeFilter).forEach(function(tt){return tt[yt]=Ye(tt)})}e.d3ForceLayout.force("dagRadial",["radialin","radialout"].indexOf(e.dagMode)!==-1?hn(function(tt){var ve=Be[tt[e.nodeId]]||-1;return(e.dagMode==="radialin"?ft-ve:ve)*$e}).strength(function(tt){return e.dagNodeFilter(tt)?1:0}):null)}else{var Ot=Ng.graph();e.graphData.nodes.forEach(function(tt){Ot.addNode(tt[e.nodeId])}),e.graphData.links.forEach(function(tt){Ot.addLink(tt.source,tt.target)}),Pe=Ng.forcelayout(Ot,Il({dimensions:e.numDimensions},e.ngraphPhysics)),Pe.graph=Ot}for(var Mn=0;Mn<e.warmupTicks&&!(Ee&&e.d3AlphaMin>0&&e.d3ForceLayout.alpha()<e.d3AlphaMin);Mn++)Pe[Ee?"tick":"step"]();e.layout=Pe,this.resetCountdown()}e.engineRunning=!0,e.onFinishUpdate()}});function ry(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Object,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,r=function(s){function a(){var c;q_(this,a);for(var h=arguments.length,f=new Array(h),m=0;m<h;m++)f[m]=arguments[m];return c=Pc(this,a,[].concat(f)),c.__kapsuleInstance=Y_(i,[].concat(ts(t?[c]:[]),f)),c}return Ia(a,s),Q_(a)}(e);return Object.keys(i()).forEach(function(s){return r.prototype[s]=function(){var a,c=(a=this.__kapsuleInstance)[s].apply(a,arguments);return c===this.__kapsuleInstance?this:c}}),r}var sy=window.THREE?window.THREE:{Group:d.ZAu},Pg=ry(iy,sy.Group,!0);function Lg(){let i=null,e=!1,t=null,r=null;function s(a,c){t(a,c),r=i.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&(r=i.requestAnimationFrame(s),e=!0)},stop:function(){i.cancelAnimationFrame(r),e=!1},setAnimationLoop:function(a){t=a},setContext:function(a){i=a}}}function oy(i){const e=new WeakMap;function t(h,f){const m=h.array,x=h.usage,_=m.byteLength,v=i.createBuffer();i.bindBuffer(f,v),i.bufferData(f,m,x),h.onUploadCallback();let T;if(m instanceof Float32Array)T=i.FLOAT;else if(typeof Float16Array!="undefined"&&m instanceof Float16Array)T=i.HALF_FLOAT;else if(m instanceof Uint16Array)h.isFloat16BufferAttribute?T=i.HALF_FLOAT:T=i.UNSIGNED_SHORT;else if(m instanceof Int16Array)T=i.SHORT;else if(m instanceof Uint32Array)T=i.UNSIGNED_INT;else if(m instanceof Int32Array)T=i.INT;else if(m instanceof Int8Array)T=i.BYTE;else if(m instanceof Uint8Array)T=i.UNSIGNED_BYTE;else if(m instanceof Uint8ClampedArray)T=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+m);return{buffer:v,type:T,bytesPerElement:m.BYTES_PER_ELEMENT,version:h.version,size:_}}function r(h,f,m){const x=f.array,_=f.updateRanges;if(i.bindBuffer(m,h),_.length===0)i.bufferSubData(m,0,x);else{_.sort((T,w)=>T.start-w.start);let v=0;for(let T=1;T<_.length;T++){const w=_[v],P=_[T];P.start<=w.start+w.count+1?w.count=Math.max(w.count,P.start+P.count-w.start):(++v,_[v]=P)}_.length=v+1;for(let T=0,w=_.length;T<w;T++){const P=_[T];i.bufferSubData(m,P.start*x.BYTES_PER_ELEMENT,x,P.start,P.count)}f.clearUpdateRanges()}f.onUploadCallback()}function s(h){return h.isInterleavedBufferAttribute&&(h=h.data),e.get(h)}function a(h){h.isInterleavedBufferAttribute&&(h=h.data);const f=e.get(h);f&&(i.deleteBuffer(f.buffer),e.delete(h))}function c(h,f){if(h.isInterleavedBufferAttribute&&(h=h.data),h.isGLBufferAttribute){const x=e.get(h);(!x||x.version<h.version)&&e.set(h,{buffer:h.buffer,type:h.type,bytesPerElement:h.elementSize,version:h.version});return}const m=e.get(h);if(m===void 0)e.set(h,t(h,f));else if(m.version<h.version){if(m.size!==h.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");r(m.buffer,h,f),m.version=h.version}}return{get:s,remove:a,update:c}}var ay=`#ifdef USE_ALPHAHASH
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`,cy=`#ifdef USE_ALPHAHASH
const float ALPHA_HASH_SCALE = 0.05;
float hash2D( vec2 value ) {
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
}
float hash3D( vec3 value ) {
return hash2D( vec2( hash2D( value.xy ), value.z ) );
}
float getAlphaHashThreshold( vec3 position ) {
float maxDeriv = max(
length( dFdx( position.xyz ) ),
length( dFdy( position.xyz ) )
);
float pixScale = 1.0 / ( ALPHA_HASH_SCALE * maxDeriv );
vec2 pixScales = vec2(
exp2( floor( log2( pixScale ) ) ),
exp2( ceil( log2( pixScale ) ) )
);
vec2 alpha = vec2(
hash3D( floor( pixScales.x * position.xyz ) ),
hash3D( floor( pixScales.y * position.xyz ) )
);
float lerpFactor = fract( log2( pixScale ) );
float x = ( 1.0 - lerpFactor ) * alpha.x + lerpFactor * alpha.y;
float a = min( lerpFactor, 1.0 - lerpFactor );
vec3 cases = vec3(
x * x / ( 2.0 * a * ( 1.0 - a ) ),
( x - 0.5 * a ) / ( 1.0 - a ),
1.0 - ( ( 1.0 - x ) * ( 1.0 - x ) / ( 2.0 * a * ( 1.0 - a ) ) )
);
float threshold = ( x < ( 1.0 - a ) )
? ( ( x < a ) ? cases.x : cases.y )
: cases.z;
return clamp( threshold , 1.0e-6, 1.0 );
}
#endif`,ly=`#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`,Nr=`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
#endif`,Fn=`#ifdef USE_ALPHATEST
#ifdef ALPHA_TO_COVERAGE
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
if ( diffuseColor.a == 0.0 ) discard;
#else
if ( diffuseColor.a < alphaTest ) discard;
#endif
#endif`,uy=`#ifdef USE_ALPHATEST
uniform float alphaTest;
#endif`,dt=`#ifdef USE_AOMAP
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
reflectedLight.indirectDiffuse *= ambientOcclusion;
#if defined( USE_CLEARCOAT )
clearcoatSpecularIndirect *= ambientOcclusion;
#endif
#if defined( USE_SHEEN )
sheenSpecularIndirect *= ambientOcclusion;
#endif
#if defined( USE_ENVMAP ) && defined( STANDARD )
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
#endif
#endif`,Hr=`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
#endif`,ie=`#ifdef USE_BATCHING
#if ! defined( GL_ANGLE_multi_draw )
#define gl_DrawID _gl_DrawID
uniform int _gl_DrawID;
#endif
uniform highp sampler2D batchingTexture;
uniform highp usampler2D batchingIdTexture;
mat4 getBatchingMatrix( const in float i ) {
int size = textureSize( batchingTexture, 0 ).x;
int j = int( i ) * 4;
int x = j % size;
int y = j / size;
vec4 v1 = texelFetch( batchingTexture, ivec2( x, y ), 0 );
vec4 v2 = texelFetch( batchingTexture, ivec2( x + 1, y ), 0 );
vec4 v3 = texelFetch( batchingTexture, ivec2( x + 2, y ), 0 );
vec4 v4 = texelFetch( batchingTexture, ivec2( x + 3, y ), 0 );
return mat4( v1, v2, v3, v4 );
}
float getIndirectIndex( const in int i ) {
int size = textureSize( batchingIdTexture, 0 ).x;
int x = i % size;
int y = i / size;
return float( texelFetch( batchingIdTexture, ivec2( x, y ), 0 ).r );
}
#endif
#ifdef USE_BATCHING_COLOR
uniform sampler2D batchingColorTexture;
vec3 getBatchingColor( const in float i ) {
int size = textureSize( batchingColorTexture, 0 ).x;
int j = int( i );
int x = j % size;
int y = j / size;
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 ).rgb;
}
#endif`,_f=`#ifdef USE_BATCHING
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
#endif`,Ig=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
vPosition = vec3( position );
#endif`,Ps=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
#endif`,yf=`float G_BlinnPhong_Implicit( ) {
return 0.25;
}
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
return RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );
}
vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float shininess ) {
vec3 halfDir = normalize( lightDir + viewDir );
float dotNH = saturate( dot( normal, halfDir ) );
float dotVH = saturate( dot( viewDir, halfDir ) );
vec3 F = F_Schlick( specularColor, 1.0, dotVH );
float G = G_BlinnPhong_Implicit( );
float D = D_BlinnPhong( shininess, dotNH );
return F * ( G * D );
} // validated`,Dg=`#ifdef USE_IRIDESCENCE
const mat3 XYZ_TO_REC709 = mat3(
3.2404542, -0.9692660, 0.0556434,
-1.5371385, 1.8760108, -0.2040259,
-0.4985314, 0.0415560, 1.0572252
);
vec3 Fresnel0ToIor( vec3 fresnel0 ) {
vec3 sqrtF0 = sqrt( fresnel0 );
return ( vec3( 1.0 ) + sqrtF0 ) / ( vec3( 1.0 ) - sqrtF0 );
}
vec3 IorToFresnel0( vec3 transmittedIor, float incidentIor ) {
return pow2( ( transmittedIor - vec3( incidentIor ) ) / ( transmittedIor + vec3( incidentIor ) ) );
}
float IorToFresnel0( float transmittedIor, float incidentIor ) {
return pow2( ( transmittedIor - incidentIor ) / ( transmittedIor + incidentIor ));
}
vec3 evalSensitivity( float OPD, vec3 shift ) {
float phase = 2.0 * PI * OPD * 1.0e-9;
vec3 val = vec3( 5.4856e-13, 4.4201e-13, 5.2481e-13 );
vec3 pos = vec3( 1.6810e+06, 1.7953e+06, 2.2084e+06 );
vec3 var = vec3( 4.3278e+09, 9.3046e+09, 6.6121e+09 );
vec3 xyz = val * sqrt( 2.0 * PI * var ) * cos( pos * phase + shift ) * exp( - pow2( phase ) * var );
xyz.x += 9.7470e-14 * sqrt( 2.0 * PI * 4.5282e+09 ) * cos( 2.2399e+06 * phase + shift[ 0 ] ) * exp( - 4.5282e+09 * pow2( phase ) );
xyz /= 1.0685e-7;
vec3 rgb = XYZ_TO_REC709 * xyz;
return rgb;
}
vec3 evalIridescence( float outsideIOR, float eta2, float cosTheta1, float thinFilmThickness, vec3 baseF0 ) {
vec3 I;
float iridescenceIOR = mix( outsideIOR, eta2, smoothstep( 0.0, 0.03, thinFilmThickness ) );
float sinTheta2Sq = pow2( outsideIOR / iridescenceIOR ) * ( 1.0 - pow2( cosTheta1 ) );
float cosTheta2Sq = 1.0 - sinTheta2Sq;
if ( cosTheta2Sq < 0.0 ) {
return vec3( 1.0 );
}
float cosTheta2 = sqrt( cosTheta2Sq );
float R0 = IorToFresnel0( iridescenceIOR, outsideIOR );
float R12 = F_Schlick( R0, 1.0, cosTheta1 );
float T121 = 1.0 - R12;
float phi12 = 0.0;
if ( iridescenceIOR < outsideIOR ) phi12 = PI;
float phi21 = PI - phi12;
vec3 baseIOR = Fresnel0ToIor( clamp( baseF0, 0.0, 0.9999 ) ); vec3 R1 = IorToFresnel0( baseIOR, iridescenceIOR );
vec3 R23 = F_Schlick( R1, 1.0, cosTheta2 );
vec3 phi23 = vec3( 0.0 );
if ( baseIOR[ 0 ] < iridescenceIOR ) phi23[ 0 ] = PI;
if ( baseIOR[ 1 ] < iridescenceIOR ) phi23[ 1 ] = PI;
if ( baseIOR[ 2 ] < iridescenceIOR ) phi23[ 2 ] = PI;
float OPD = 2.0 * iridescenceIOR * thinFilmThickness * cosTheta2;
vec3 phi = vec3( phi21 ) + phi23;
vec3 R123 = clamp( R12 * R23, 1e-5, 0.9999 );
vec3 r123 = sqrt( R123 );
vec3 Rs = pow2( T121 ) * R23 / ( vec3( 1.0 ) - R123 );
vec3 C0 = R12 + Rs;
I = C0;
vec3 Cm = Rs - T121;
for ( int m = 1; m <= 2; ++ m ) {
Cm *= r123;
vec3 Sm = 2.0 * evalSensitivity( float( m ) * OPD, float( m ) * phi );
I += Cm * Sm;
}
return max( I, vec3( 0.0 ) );
}
#endif`,Ug=`#ifdef USE_BUMPMAP
uniform sampler2D bumpMap;
uniform float bumpScale;
vec2 dHdxy_fwd() {
vec2 dSTdx = dFdx( vBumpMapUv );
vec2 dSTdy = dFdy( vBumpMapUv );
float Hll = bumpScale * texture2D( bumpMap, vBumpMapUv ).x;
float dBx = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdx ).x - Hll;
float dBy = bumpScale * texture2D( bumpMap, vBumpMapUv + dSTdy ).x - Hll;
return vec2( dBx, dBy );
}
vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy, float faceDirection ) {
vec3 vSigmaX = normalize( dFdx( surf_pos.xyz ) );
vec3 vSigmaY = normalize( dFdy( surf_pos.xyz ) );
vec3 vN = surf_norm;
vec3 R1 = cross( vSigmaY, vN );
vec3 R2 = cross( vN, vSigmaX );
float fDet = dot( vSigmaX, R1 ) * faceDirection;
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
return normalize( abs( fDet ) * surf_norm - vGrad );
}
#endif`,hy=`#if NUM_CLIPPING_PLANES > 0
vec4 plane;
#ifdef ALPHA_TO_COVERAGE
float distanceToPlane, distanceGradient;
float clipOpacity = 1.0;
#pragma unroll_loop_start
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
plane = clippingPlanes[ i ];
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
distanceGradient = fwidth( distanceToPlane ) / 2.0;
clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
if ( clipOpacity == 0.0 ) discard;
}
#pragma unroll_loop_end
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
float unionClipOpacity = 1.0;
#pragma unroll_loop_start
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
plane = clippingPlanes[ i ];
distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w;
distanceGradient = fwidth( distanceToPlane ) / 2.0;
unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane );
}
#pragma unroll_loop_end
clipOpacity *= 1.0 - unionClipOpacity;
#endif
diffuseColor.a *= clipOpacity;
if ( diffuseColor.a == 0.0 ) discard;
#else
#pragma unroll_loop_start
for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {
plane = clippingPlanes[ i ];
if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;
}
#pragma unroll_loop_end
#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES
bool clipped = true;
#pragma unroll_loop_start
for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {
plane = clippingPlanes[ i ];
clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;
}
#pragma unroll_loop_end
if ( clipped ) discard;
#endif
#endif
#endif`,$r=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`,Ro=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
#endif`,Lc=`#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
#endif`,Ic=`#if defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
#elif defined( USE_COLOR )
diffuseColor.rgb *= vColor;
#endif`,dy=`#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#elif defined( USE_COLOR )
varying vec3 vColor;
#endif`,fy=`#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
varying vec3 vColor;
#endif`,Ua=`#if defined( USE_COLOR_ALPHA )
vColor = vec4( 1.0 );
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
vColor = vec3( 1.0 );
#endif
#ifdef USE_COLOR
vColor *= color;
#endif
#ifdef USE_INSTANCING_COLOR
vColor.xyz *= instanceColor.xyz;
#endif
#ifdef USE_BATCHING_COLOR
vec3 batchingColor = getBatchingColor( getIndirectIndex( gl_DrawID ) );
vColor.xyz *= batchingColor.xyz;
#endif`,bf=`#define PI 3.141592653589793
#define PI2 6.283185307179586
#define PI_HALF 1.5707963267948966
#define RECIPROCAL_PI 0.3183098861837907
#define RECIPROCAL_PI2 0.15915494309189535
#define EPSILON 1e-6
#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
#define whiteComplement( a ) ( 1.0 - saturate( a ) )
float pow2( const in float x ) { return x*x; }
vec3 pow2( const in vec3 x ) { return x*x; }
float pow3( const in float x ) { return x*x*x; }
float pow4( const in float x ) { float x2 = x*x; return x2*x2; }
float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }
float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }
highp float rand( const in vec2 uv ) {
const highp float a = 12.9898, b = 78.233, c = 43758.5453;
highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );
return fract( sin( sn ) * c );
}
#ifdef HIGH_PRECISION
float precisionSafeLength( vec3 v ) { return length( v ); }
#else
float precisionSafeLength( vec3 v ) {
float maxComponent = max3( abs( v ) );
return length( v / maxComponent ) * maxComponent;
}
#endif
struct IncidentLight {
vec3 color;
vec3 direction;
bool visible;
};
struct ReflectedLight {
vec3 directDiffuse;
vec3 directSpecular;
vec3 indirectDiffuse;
vec3 indirectSpecular;
};
#ifdef USE_ALPHAHASH
varying vec3 vPosition;
#endif
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
vec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {
return normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );
}
bool isPerspectiveMatrix( mat4 m ) {
return m[ 2 ][ 3 ] == - 1.0;
}
vec2 equirectUv( in vec3 dir ) {
float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;
float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;
return vec2( u, v );
}
vec3 BRDF_Lambert( const in vec3 diffuseColor ) {
return RECIPROCAL_PI * diffuseColor;
}
vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
}
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
} // validated`,py=`#ifdef ENVMAP_TYPE_CUBE_UV
#define cubeUV_minMipLevel 4.0
#define cubeUV_minTileSize 16.0
float getFace( vec3 direction ) {
vec3 absDirection = abs( direction );
float face = - 1.0;
if ( absDirection.x > absDirection.z ) {
if ( absDirection.x > absDirection.y )
face = direction.x > 0.0 ? 0.0 : 3.0;
else
face = direction.y > 0.0 ? 1.0 : 4.0;
} else {
if ( absDirection.z > absDirection.y )
face = direction.z > 0.0 ? 2.0 : 5.0;
else
face = direction.y > 0.0 ? 1.0 : 4.0;
}
return face;
}
vec2 getUV( vec3 direction, float face ) {
vec2 uv;
if ( face == 0.0 ) {
uv = vec2( direction.z, direction.y ) / abs( direction.x );
} else if ( face == 1.0 ) {
uv = vec2( - direction.x, - direction.z ) / abs( direction.y );
} else if ( face == 2.0 ) {
uv = vec2( - direction.x, direction.y ) / abs( direction.z );
} else if ( face == 3.0 ) {
uv = vec2( - direction.z, direction.y ) / abs( direction.x );
} else if ( face == 4.0 ) {
uv = vec2( - direction.x, direction.z ) / abs( direction.y );
} else {
uv = vec2( direction.x, direction.y ) / abs( direction.z );
}
return 0.5 * ( uv + 1.0 );
}
vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) {
float face = getFace( direction );
float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 );
mipInt = max( mipInt, cubeUV_minMipLevel );
float faceSize = exp2( mipInt );
highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0;
if ( face > 2.0 ) {
uv.y += faceSize;
face -= 3.0;
}
uv.x += face * faceSize;
uv.x += filterInt * 3.0 * cubeUV_minTileSize;
uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize );
uv.x *= CUBEUV_TEXEL_WIDTH;
uv.y *= CUBEUV_TEXEL_HEIGHT;
#ifdef texture2DGradEXT
return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb;
#else
return texture2D( envMap, uv ).rgb;
#endif
}
#define cubeUV_r0 1.0
#define cubeUV_m0 - 2.0
#define cubeUV_r1 0.8
#define cubeUV_m1 - 1.0
#define cubeUV_r4 0.4
#define cubeUV_m4 2.0
#define cubeUV_r5 0.305
#define cubeUV_m5 3.0
#define cubeUV_r6 0.21
#define cubeUV_m6 4.0
float roughnessToMip( float roughness ) {
float mip = 0.0;
if ( roughness >= cubeUV_r1 ) {
mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0;
} else if ( roughness >= cubeUV_r4 ) {
mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1;
} else if ( roughness >= cubeUV_r5 ) {
mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4;
} else if ( roughness >= cubeUV_r6 ) {
mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5;
} else {
mip = - 2.0 * log2( 1.16 * roughness ); }
return mip;
}
vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) {
float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP );
float mipF = fract( mip );
float mipInt = floor( mip );
vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt );
if ( mipF == 0.0 ) {
return vec4( color0, 1.0 );
} else {
vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 );
return vec4( mix( color0, color1, mipF ), 1.0 );
}
}
#endif`,vf=`vec3 transformedNormal = objectNormal;
#ifdef USE_TANGENT
vec3 transformedTangent = objectTangent;
#endif
#ifdef USE_BATCHING
mat3 bm = mat3( batchingMatrix );
transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) );
transformedNormal = bm * transformedNormal;
#ifdef USE_TANGENT
transformedTangent = bm * transformedTangent;
#endif
#endif
#ifdef USE_INSTANCING
mat3 im = mat3( instanceMatrix );
transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) );
transformedNormal = im * transformedNormal;
#ifdef USE_TANGENT
transformedTangent = im * transformedTangent;
#endif
#endif
transformedNormal = normalMatrix * transformedNormal;
#ifdef FLIP_SIDED
transformedNormal = - transformedNormal;
#endif
#ifdef USE_TANGENT
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
#ifdef FLIP_SIDED
transformedTangent = - transformedTangent;
#endif
#endif`,sr=`#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
#endif`,or=`#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`,Fg=`#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
emissiveColor = sRGBTransferEOTF( emissiveColor );
#endif
totalEmissiveRadiance *= emissiveColor.rgb;
#endif`,Bg=`#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
#endif`,Og="gl_FragColor = linearToOutputTexel( gl_FragColor );",lT=`vec4 LinearTransferOETF( in vec4 value ) {
return value;
}
vec4 sRGBTransferEOTF( in vec4 value ) {
return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );
}
vec4 sRGBTransferOETF( in vec4 value ) {
return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
}`,Sf=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vec3 cameraToFrag;
if ( isOrthographic ) {
cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
} else {
cameraToFrag = normalize( vWorldPosition - cameraPosition );
}
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
#ifdef ENVMAP_MODE_REFLECTION
vec3 reflectVec = reflect( cameraToFrag, worldNormal );
#else
vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );
#endif
#else
vec3 reflectVec = vReflect;
#endif
#ifdef ENVMAP_TYPE_CUBE
vec4 envColor = textureCube( envMap, envMapRotation * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );
#else
vec4 envColor = vec4( 0.0 );
#endif
#ifdef ENVMAP_BLENDING_MULTIPLY
outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );
#elif defined( ENVMAP_BLENDING_MIX )
outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );
#elif defined( ENVMAP_BLENDING_ADD )
outgoingLight += envColor.xyz * specularStrength * reflectivity;
#endif
#endif`,uT=`#ifdef USE_ENVMAP
uniform float envMapIntensity;
uniform float flipEnvMap;
uniform mat3 envMapRotation;
#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#else
uniform sampler2D envMap;
#endif
#endif`,wr=`#ifdef USE_ENVMAP
uniform float reflectivity;
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
#define ENV_WORLDPOS
#endif
#ifdef ENV_WORLDPOS
varying vec3 vWorldPosition;
uniform float refractionRatio;
#else
varying vec3 vReflect;
#endif
#endif`,No=`#ifdef USE_ENVMAP
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
#define ENV_WORLDPOS
#endif
#ifdef ENV_WORLDPOS
varying vec3 vWorldPosition;
#else
varying vec3 vReflect;
uniform float refractionRatio;
#endif
#endif`,Ls=`#ifdef USE_ENVMAP
#ifdef ENV_WORLDPOS
vWorldPosition = worldPosition.xyz;
#else
vec3 cameraToVertex;
if ( isOrthographic ) {
cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );
} else {
cameraToVertex = normalize( worldPosition.xyz - cameraPosition );
}
vec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
#ifdef ENVMAP_MODE_REFLECTION
vReflect = reflect( cameraToVertex, worldNormal );
#else
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
#endif
#endif
#endif`,xh=`#ifdef USE_FOG
vFogDepth = - mvPosition.z;
#endif`,Dc=`#ifdef USE_FOG
varying float vFogDepth;
#endif`,Uc=`#ifdef USE_FOG
#ifdef FOG_EXP2
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
#else
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
#endif
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
#endif`,Fc=`#ifdef USE_FOG
uniform vec3 fogColor;
varying float vFogDepth;
#ifdef FOG_EXP2
uniform float fogDensity;
#else
uniform float fogNear;
uniform float fogFar;
#endif
#endif`,ta=`#ifdef USE_GRADIENTMAP
uniform sampler2D gradientMap;
#endif
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
float dotNL = dot( normal, lightDirection );
vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );
#ifdef USE_GRADIENTMAP
return vec3( texture2D( gradientMap, coord ).r );
#else
vec2 fw = fwidth( coord ) * 0.5;
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
#endif
}`,na=`#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
#endif`,Fa=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`,Bl=`varying vec3 vViewPosition;
struct LambertMaterial {
vec3 diffuseColor;
float specularStrength;
};
void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
vec3 irradiance = dotNL * directLight.color;
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_Lambert
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,_h=`uniform bool receiveShadow;
uniform vec3 ambientLightColor;
#if defined( USE_LIGHT_PROBES )
uniform vec3 lightProbe[ 9 ];
#endif
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
float x = normal.x, y = normal.y, z = normal.z;
vec3 result = shCoefficients[ 0 ] * 0.886227;
result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
return result;
}
vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) {
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );
return irradiance;
}
vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {
vec3 irradiance = ambientLightColor;
return irradiance;
}
float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {
float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );
if ( cutoffDistance > 0.0 ) {
distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );
}
return distanceFalloff;
}
float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) {
return smoothstep( coneCosine, penumbraCosine, angleCosine );
}
#if NUM_DIR_LIGHTS > 0
struct DirectionalLight {
vec3 direction;
vec3 color;
};
uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];
void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) {
light.color = directionalLight.color;
light.direction = directionalLight.direction;
light.visible = true;
}
#endif
#if NUM_POINT_LIGHTS > 0
struct PointLight {
vec3 position;
vec3 color;
float distance;
float decay;
};
uniform PointLight pointLights[ NUM_POINT_LIGHTS ];
void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) {
vec3 lVector = pointLight.position - geometryPosition;
light.direction = normalize( lVector );
float lightDistance = length( lVector );
light.color = pointLight.color;
light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay );
light.visible = ( light.color != vec3( 0.0 ) );
}
#endif
#if NUM_SPOT_LIGHTS > 0
struct SpotLight {
vec3 position;
vec3 direction;
vec3 color;
float distance;
float decay;
float coneCos;
float penumbraCos;
};
uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];
void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) {
vec3 lVector = spotLight.position - geometryPosition;
light.direction = normalize( lVector );
float angleCos = dot( light.direction, spotLight.direction );
float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos );
if ( spotAttenuation > 0.0 ) {
float lightDistance = length( lVector );
light.color = spotLight.color * spotAttenuation;
light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay );
light.visible = ( light.color != vec3( 0.0 ) );
} else {
light.color = vec3( 0.0 );
light.visible = false;
}
}
#endif
#if NUM_RECT_AREA_LIGHTS > 0
struct RectAreaLight {
vec3 color;
vec3 position;
vec3 halfWidth;
vec3 halfHeight;
};
uniform sampler2D ltc_1; uniform sampler2D ltc_2;
uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];
#endif
#if NUM_HEMI_LIGHTS > 0
struct HemisphereLight {
vec3 direction;
vec3 skyColor;
vec3 groundColor;
};
uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];
vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) {
float dotNL = dot( normal, hemiLight.direction );
float hemiDiffuseWeight = 0.5 * dotNL + 0.5;
vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );
return irradiance;
}
#endif`,yh=`#ifdef USE_ENVMAP
vec3 getIBLIrradiance( const in vec3 normal ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 );
return PI * envMapColor.rgb * envMapIntensity;
#else
return vec3( 0.0 );
#endif
}
vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 reflectVec = reflect( - viewDir, normal );
reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) );
reflectVec = inverseTransformDirection( reflectVec, viewMatrix );
vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness );
return envMapColor.rgb * envMapIntensity;
#else
return vec3( 0.0 );
#endif
}
#ifdef USE_ANISOTROPY
vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) {
#ifdef ENVMAP_TYPE_CUBE_UV
vec3 bentNormal = cross( bitangent, viewDir );
bentNormal = normalize( cross( bentNormal, bitangent ) );
bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) );
return getIBLRadiance( viewDir, bentNormal, roughness );
#else
return vec3( 0.0 );
#endif
}
#endif
#endif`,Ba=`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,Tf=`varying vec3 vViewPosition;
struct ToonMaterial {
vec3 diffuseColor;
};
void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color;
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_Toon
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,my=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`,Ol=`varying vec3 vViewPosition;
struct BlinnPhongMaterial {
vec3 diffuseColor;
vec3 specularColor;
float specularShininess;
float specularStrength;
};
void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
vec3 irradiance = dotNL * directLight.color;
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength;
}
void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
#define RE_Direct RE_Direct_BlinnPhong
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Mf=`PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
material.roughness = min( material.roughness, 1.0 );
#ifdef IOR
material.ior = ior;
#ifdef USE_SPECULAR
float specularIntensityFactor = specularIntensity;
vec3 specularColorFactor = specularColor;
#ifdef USE_SPECULAR_COLORMAP
specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
#endif
material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
#else
float specularIntensityFactor = 1.0;
vec3 specularColorFactor = vec3( 1.0 );
material.specularF90 = 1.0;
#endif
material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
#else
material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
material.specularF90 = 1.0;
#endif
#ifdef USE_CLEARCOAT
material.clearcoat = clearcoat;
material.clearcoatRoughness = clearcoatRoughness;
material.clearcoatF0 = vec3( 0.04 );
material.clearcoatF90 = 1.0;
#ifdef USE_CLEARCOATMAP
material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
#endif
material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
material.clearcoatRoughness += geometryRoughness;
material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
#endif
#ifdef USE_DISPERSION
material.dispersion = dispersion;
#endif
#ifdef USE_IRIDESCENCE
material.iridescence = iridescence;
material.iridescenceIOR = iridescenceIOR;
#ifdef USE_IRIDESCENCEMAP
material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
#else
material.iridescenceThickness = iridescenceThicknessMaximum;
#endif
#endif
#ifdef USE_SHEEN
material.sheenColor = sheenColor;
#ifdef USE_SHEEN_COLORMAP
material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
#endif
material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
#ifdef USE_SHEEN_ROUGHNESSMAP
material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
#endif
#endif
#ifdef USE_ANISOTROPY
#ifdef USE_ANISOTROPYMAP
mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
#else
vec2 anisotropyV = anisotropyVector;
#endif
material.anisotropy = length( anisotropyV );
if( material.anisotropy == 0.0 ) {
anisotropyV = vec2( 1.0, 0.0 );
} else {
anisotropyV /= material.anisotropy;
material.anisotropy = saturate( material.anisotropy );
}
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
#endif`,xr=`uniform sampler2D dfgLUT;
struct PhysicalMaterial {
vec3 diffuseColor;
float roughness;
vec3 specularColor;
float specularF90;
float dispersion;
#ifdef USE_CLEARCOAT
float clearcoat;
float clearcoatRoughness;
vec3 clearcoatF0;
float clearcoatF90;
#endif
#ifdef USE_IRIDESCENCE
float iridescence;
float iridescenceIOR;
float iridescenceThickness;
vec3 iridescenceFresnel;
vec3 iridescenceF0;
#endif
#ifdef USE_SHEEN
vec3 sheenColor;
float sheenRoughness;
#endif
#ifdef IOR
float ior;
#endif
#ifdef USE_TRANSMISSION
float transmission;
float transmissionAlpha;
float thickness;
float attenuationDistance;
vec3 attenuationColor;
#endif
#ifdef USE_ANISOTROPY
float anisotropy;
float alphaT;
vec3 anisotropyT;
vec3 anisotropyB;
#endif
};
vec3 clearcoatSpecularDirect = vec3( 0.0 );
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
vec3 sheenSpecularDirect = vec3( 0.0 );
vec3 sheenSpecularIndirect = vec3(0.0 );
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
float x2 = x * x;
float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
}
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
float a2 = pow2( alpha );
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
return 0.5 / max( gv + gl, EPSILON );
}
float D_GGX( const in float alpha, const in float dotNH ) {
float a2 = pow2( alpha );
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
return RECIPROCAL_PI * a2 / pow2( denom );
}
#ifdef USE_ANISOTROPY
float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
float v = 0.5 / ( gv + gl );
return saturate(v);
}
float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
float a2 = alphaT * alphaB;
highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
highp float v2 = dot( v, v );
float w2 = a2 / v2;
return RECIPROCAL_PI * a2 * pow2 ( w2 );
}
#endif
#ifdef USE_CLEARCOAT
vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
vec3 f0 = material.clearcoatF0;
float f90 = material.clearcoatF90;
float roughness = material.clearcoatRoughness;
float alpha = pow2( roughness );
vec3 halfDir = normalize( lightDir + viewDir );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
float dotNH = saturate( dot( normal, halfDir ) );
float dotVH = saturate( dot( viewDir, halfDir ) );
vec3 F = F_Schlick( f0, f90, dotVH );
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
float D = D_GGX( alpha, dotNH );
return F * ( V * D );
}
#endif
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
vec3 f0 = material.specularColor;
float f90 = material.specularF90;
float roughness = material.roughness;
float alpha = pow2( roughness );
vec3 halfDir = normalize( lightDir + viewDir );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
float dotNH = saturate( dot( normal, halfDir ) );
float dotVH = saturate( dot( viewDir, halfDir ) );
vec3 F = F_Schlick( f0, f90, dotVH );
#ifdef USE_IRIDESCENCE
F = mix( F, material.iridescenceFresnel, material.iridescence );
#endif
#ifdef USE_ANISOTROPY
float dotTL = dot( material.anisotropyT, lightDir );
float dotTV = dot( material.anisotropyT, viewDir );
float dotTH = dot( material.anisotropyT, halfDir );
float dotBL = dot( material.anisotropyB, lightDir );
float dotBV = dot( material.anisotropyB, viewDir );
float dotBH = dot( material.anisotropyB, halfDir );
float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
#else
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
float D = D_GGX( alpha, dotNH );
#endif
return F * ( V * D );
}
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
const float LUT_SIZE = 64.0;
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
const float LUT_BIAS = 0.5 / LUT_SIZE;
float dotNV = saturate( dot( N, V ) );
vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
uv = uv * LUT_SCALE + LUT_BIAS;
return uv;
}
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
float l = length( f );
return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
}
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
float x = dot( v1, v2 );
float y = abs( x );
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
float b = 3.4175940 + ( 4.1616724 + y ) * y;
float v = a / b;
float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
return cross( v1, v2 ) * theta_sintheta;
}
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
vec3 lightNormal = cross( v1, v2 );
if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
vec3 T1, T2;
T1 = normalize( V - N * dot( V, N ) );
T2 = - cross( N, T1 );
mat3 mat = mInv * transpose( mat3( T1, T2, N ) );
vec3 coords[ 4 ];
coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
coords[ 0 ] = normalize( coords[ 0 ] );
coords[ 1 ] = normalize( coords[ 1 ] );
coords[ 2 ] = normalize( coords[ 2 ] );
coords[ 3 ] = normalize( coords[ 3 ] );
vec3 vectorFormFactor = vec3( 0.0 );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
return vec3( result );
}
#if defined( USE_SHEEN )
float D_Charlie( float roughness, float dotNH ) {
float alpha = pow2( roughness );
float invAlpha = 1.0 / alpha;
float cos2h = dotNH * dotNH;
float sin2h = max( 1.0 - cos2h, 0.0078125 );
return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
}
float V_Neubelt( float dotNV, float dotNL ) {
return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
}
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
vec3 halfDir = normalize( lightDir + viewDir );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
float dotNH = saturate( dot( normal, halfDir ) );
float D = D_Charlie( sheenRoughness, dotNH );
float V = V_Neubelt( dotNV, dotNL );
return sheenColor * ( D * V );
}
#endif
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
float dotNV = saturate( dot( normal, viewDir ) );
float r2 = roughness * roughness;
float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
return saturate( DG * RECIPROCAL_PI );
}
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
float dotNV = saturate( dot( normal, viewDir ) );
vec2 uv = vec2( roughness, dotNV );
return texture2D( dfgLUT, uv ).rg;
}
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
vec2 fab = DFGApprox( normal, viewDir, roughness );
return specularColor * fab.x + specularF90 * fab.y;
}
#ifdef USE_IRIDESCENCE
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#else
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
#endif
vec2 fab = DFGApprox( normal, viewDir, roughness );
#ifdef USE_IRIDESCENCE
vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
#else
vec3 Fr = specularColor;
#endif
vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
float Ess = fab.x + fab.y;
float Ems = 1.0 - Ess;
vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
singleScatter += FssEss;
multiScatter += Fms * Ems;
}
vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material );
float dotNL = saturate( dot( normal, lightDir ) );
float dotNV = saturate( dot( normal, viewDir ) );
vec2 dfgV = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNV * dotNV), 0.0, dotNV), material.roughness );
vec2 dfgL = DFGApprox( vec3(0.0, 0.0, 1.0), vec3(sqrt(1.0 - dotNL * dotNL), 0.0, dotNL), material.roughness );
vec3 FssEss_V = material.specularColor * dfgV.x + material.specularF90 * dfgV.y;
vec3 FssEss_L = material.specularColor * dfgL.x + material.specularF90 * dfgL.y;
float Ess_V = dfgV.x + dfgV.y;
float Ess_L = dfgL.x + dfgL.y;
float Ems_V = 1.0 - Ess_V;
float Ems_L = 1.0 - Ess_L;
vec3 Favg = material.specularColor + ( 1.0 - material.specularColor ) * 0.047619;
vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg * Favg + EPSILON );
float compensationFactor = Ems_V * Ems_L;
vec3 multiScatter = Fms * compensationFactor;
return singleScatter + multiScatter;
}
#if NUM_RECT_AREA_LIGHTS > 0
void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
vec3 normal = geometryNormal;
vec3 viewDir = geometryViewDir;
vec3 position = geometryPosition;
vec3 lightPos = rectAreaLight.position;
vec3 halfWidth = rectAreaLight.halfWidth;
vec3 halfHeight = rectAreaLight.halfHeight;
vec3 lightColor = rectAreaLight.color;
float roughness = material.roughness;
vec3 rectCoords[ 4 ];
rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
vec2 uv = LTC_Uv( normal, viewDir, roughness );
vec4 t1 = texture2D( ltc_1, uv );
vec4 t2 = texture2D( ltc_2, uv );
mat3 mInv = mat3(
vec3( t1.x, 0, t1.y ),
vec3( 0, 1, 0 ),
vec3( t1.z, 0, t1.w )
);
vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
}
#endif
void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
vec3 irradiance = dotNL * directLight.color;
#ifdef USE_CLEARCOAT
float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
vec3 ccIrradiance = dotNLcc * directLight.color;
clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
#endif
#ifdef USE_SHEEN
sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
#endif
reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
}
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
#ifdef USE_CLEARCOAT
clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
#endif
#ifdef USE_SHEEN
sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
#endif
vec3 singleScattering = vec3( 0.0 );
vec3 multiScattering = vec3( 0.0 );
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
#ifdef USE_IRIDESCENCE
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
#else
computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
#endif
vec3 totalScattering = singleScattering + multiScattering;
vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
reflectedLight.indirectSpecular += radiance * singleScattering;
reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
}
#define RE_Direct RE_Direct_Physical
#define RE_Direct_RectArea RE_Direct_RectArea_Physical
#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
}`,Po=`
vec3 geometryPosition = - vViewPosition;
vec3 geometryNormal = normal;
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
vec3 geometryClearcoatNormal = vec3( 0.0 );
#ifdef USE_CLEARCOAT
geometryClearcoatNormal = clearcoatNormal;
#endif
#ifdef USE_IRIDESCENCE
float dotNVi = saturate( dot( normal, geometryViewDir ) );
if ( material.iridescenceThickness == 0.0 ) {
material.iridescence = 0.0;
} else {
material.iridescence = saturate( material.iridescence );
}
if ( material.iridescence > 0.0 ) {
material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
}
#endif
IncidentLight directLight;
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
PointLight pointLight;
#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
PointLightShadow pointLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
pointLight = pointLights[ i ];
getPointLightInfo( pointLight, geometryPosition, directLight );
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
pointLightShadow = pointLightShadows[ i ];
directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
#endif
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
SpotLight spotLight;
vec4 spotColor;
vec3 spotLightCoord;
bool inSpotLightMap;
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
SpotLightShadow spotLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
spotLight = spotLights[ i ];
getSpotLightInfo( spotLight, geometryPosition, directLight );
#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
#else
#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
#endif
#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
#endif
#undef SPOT_LIGHT_MAP_INDEX
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
spotLightShadow = spotLightShadows[ i ];
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
#endif
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
DirectionalLight directionalLight;
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
DirectionalLightShadow directionalLightShadow;
#endif
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
directionalLight = directionalLights[ i ];
getDirectionalLightInfo( directionalLight, directLight );
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
directionalLightShadow = directionalLightShadows[ i ];
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
#endif
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
RectAreaLight rectAreaLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
rectAreaLight = rectAreaLights[ i ];
RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
}
#pragma unroll_loop_end
#endif
#if defined( RE_IndirectDiffuse )
vec3 iblIrradiance = vec3( 0.0 );
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
#if defined( USE_LIGHT_PROBES )
irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
#endif
#if ( NUM_HEMI_LIGHTS > 0 )
#pragma unroll_loop_start
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
}
#pragma unroll_loop_end
#endif
#endif
#if defined( RE_IndirectSpecular )
vec3 radiance = vec3( 0.0 );
vec3 clearcoatRadiance = vec3( 0.0 );
#endif`,wf=`#if defined( RE_IndirectDiffuse )
#ifdef USE_LIGHTMAP
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
irradiance += lightMapIrradiance;
#endif
#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )
iblIrradiance += getIBLIrradiance( geometryNormal );
#endif
#endif
#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )
#ifdef USE_ANISOTROPY
radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy );
#else
radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness );
#endif
#ifdef USE_CLEARCOAT
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
#endif
#endif`,bh=`#if defined( RE_IndirectDiffuse )
RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif
#if defined( RE_IndirectSpecular )
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
#endif`,ia=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`,Af=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
#endif`,vh=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
varying float vFragDepth;
varying float vIsPerspective;
#endif`,Ef=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
vFragDepth = 1.0 + gl_Position.w;
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#endif`,Bc=`#ifdef USE_MAP
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
#ifdef DECODE_VIDEO_TEXTURE
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
#endif
diffuseColor *= sampledDiffuseColor;
#endif`,Ln=`#ifdef USE_MAP
uniform sampler2D map;
#endif`,Oc=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
#if defined( USE_POINTS_UV )
vec2 uv = vUv;
#else
vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;
#endif
#endif
#ifdef USE_MAP
diffuseColor *= texture2D( map, uv );
#endif
#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, uv ).g;
#endif`,Is=`#if defined( USE_POINTS_UV )
varying vec2 vUv;
#else
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
uniform mat3 uvTransform;
#endif
#endif
#ifdef USE_MAP
uniform sampler2D map;
#endif
#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
#endif`,gy=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
metalnessFactor *= texelMetalness.b;
#endif`,xy=`#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
#endif`,ra=`#ifdef USE_INSTANCING_MORPH
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
}
#endif`,Sh=`#if defined( USE_MORPHCOLORS )
vColor *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
#if defined( USE_COLOR_ALPHA )
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ];
#elif defined( USE_COLOR )
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
#endif
}
#endif`,ns=`#ifdef USE_MORPHNORMALS
objectNormal *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
}
#endif`,kg=`#ifdef USE_MORPHTARGETS
#ifndef USE_INSTANCING_MORPH
uniform float morphTargetBaseInfluence;
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
#endif
uniform sampler2DArray morphTargetsTexture;
uniform ivec2 morphTargetsTextureSize;
vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) {
int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset;
int y = texelIndex / morphTargetsTextureSize.x;
int x = texelIndex - y * morphTargetsTextureSize.x;
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
return texelFetch( morphTargetsTexture, morphUV, 0 );
}
#endif`,Vg=`#ifdef USE_MORPHTARGETS
transformed *= morphTargetBaseInfluence;
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
}
#endif`,Ds=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
#ifdef FLAT_SHADED
vec3 fdx = dFdx( vViewPosition );
vec3 fdy = dFdy( vViewPosition );
vec3 normal = normalize( cross( fdx, fdy ) );
#else
vec3 normal = normalize( vNormal );
#ifdef DOUBLE_SIDED
normal *= faceDirection;
#endif
#endif
#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY )
#ifdef USE_TANGENT
mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
#else
mat3 tbn = getTangentFrame( - vViewPosition, normal,
#if defined( USE_NORMALMAP )
vNormalMapUv
#elif defined( USE_CLEARCOAT_NORMALMAP )
vClearcoatNormalMapUv
#else
vUv
#endif
);
#endif
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
tbn[0] *= faceDirection;
tbn[1] *= faceDirection;
#endif
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
#ifdef USE_TANGENT
mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal );
#else
mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv );
#endif
#if defined( DOUBLE_SIDED ) && ! defined( FLAT_SHADED )
tbn2[0] *= faceDirection;
tbn2[1] *= faceDirection;
#endif
#endif
vec3 nonPerturbedNormal = normal;`,Cf=`#ifdef USE_NORMALMAP_OBJECTSPACE
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
#ifdef FLIP_SIDED
normal = - normal;
#endif
#ifdef DOUBLE_SIDED
normal = normal * faceDirection;
#endif
normal = normalize( normalMatrix * normal );
#elif defined( USE_NORMALMAP_TANGENTSPACE )
vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
mapN.xy *= normalScale;
normal = normalize( tbn * mapN );
#elif defined( USE_BUMPMAP )
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
#endif`,_y=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,zg=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,kc=`#ifndef FLAT_SHADED
vNormal = normalize( transformedNormal );
#ifdef USE_TANGENT
vTangent = normalize( transformedTangent );
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
#endif
#endif`,Lo=`#ifdef USE_NORMALMAP
uniform sampler2D normalMap;
uniform vec2 normalScale;
#endif
#ifdef USE_NORMALMAP_OBJECTSPACE
uniform mat3 normalMatrix;
#endif
#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) )
mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) {
vec3 q0 = dFdx( eye_pos.xyz );
vec3 q1 = dFdy( eye_pos.xyz );
vec2 st0 = dFdx( uv.st );
vec2 st1 = dFdy( uv.st );
vec3 N = surf_norm;
vec3 q1perp = cross( q1, N );
vec3 q0perp = cross( N, q0 );
vec3 T = q1perp * st0.x + q0perp * st1.x;
vec3 B = q1perp * st0.y + q0perp * st1.y;
float det = max( dot( T, T ), dot( B, B ) );
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
return mat3( T * scale, B * scale, N );
}
#endif`,Th=`#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = nonPerturbedNormal;
#endif`,kl=`#ifdef USE_CLEARCOAT_NORMALMAP
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
clearcoatMapN.xy *= clearcoatNormalScale;
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`,yy=`#ifdef USE_CLEARCOATMAP
uniform sampler2D clearcoatMap;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
uniform sampler2D clearcoatNormalMap;
uniform vec2 clearcoatNormalScale;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
uniform sampler2D clearcoatRoughnessMap;
#endif`,by=`#ifdef USE_IRIDESCENCEMAP
uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform sampler2D iridescenceThicknessMap;
#endif`,Gg=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Wg=`vec3 packNormalToRGB( const in vec3 normal ) {
return normalize( normal ) * 0.5 + 0.5;
}
vec3 unpackRGBToNormal( const in vec3 rgb ) {
return 2.0 * rgb.xyz - 1.0;
}
const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.;
const float Inv255 = 1. / 255.;
const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 );
const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g );
const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b );
const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a );
vec4 packDepthToRGBA( const in float v ) {
if( v <= 0.0 )
return vec4( 0., 0., 0., 0. );
if( v >= 1.0 )
return vec4( 1., 1., 1., 1. );
float vuf;
float af = modf( v * PackFactors.a, vuf );
float bf = modf( vuf * ShiftRight8, vuf );
float gf = modf( vuf * ShiftRight8, vuf );
return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af );
}
vec3 packDepthToRGB( const in float v ) {
if( v <= 0.0 )
return vec3( 0., 0., 0. );
if( v >= 1.0 )
return vec3( 1., 1., 1. );
float vuf;
float bf = modf( v * PackFactors.b, vuf );
float gf = modf( vuf * ShiftRight8, vuf );
return vec3( vuf * Inv255, gf * PackUpscale, bf );
}
vec2 packDepthToRG( const in float v ) {
if( v <= 0.0 )
return vec2( 0., 0. );
if( v >= 1.0 )
return vec2( 1., 1. );
float vuf;
float gf = modf( v * 256., vuf );
return vec2( vuf * Inv255, gf );
}
float unpackRGBAToDepth( const in vec4 v ) {
return dot( v, UnpackFactors4 );
}
float unpackRGBToDepth( const in vec3 v ) {
return dot( v, UnpackFactors3 );
}
float unpackRGToDepth( const in vec2 v ) {
return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g;
}
vec4 pack2HalfToRGBA( const in vec2 v ) {
vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) );
return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w );
}
vec2 unpackRGBATo2Half( const in vec4 v ) {
return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );
}
float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {
return ( viewZ + near ) / ( near - far );
}
float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) {
return depth * ( near - far ) - near;
}
float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {
return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ );
}
float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) {
return ( near * far ) / ( ( far - near ) * depth - far );
}`,Hg=`#ifdef PREMULTIPLIED_ALPHA
gl_FragColor.rgb *= gl_FragColor.a;
#endif`,$g=`vec4 mvPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
mvPosition = batchingMatrix * mvPosition;
#endif
#ifdef USE_INSTANCING
mvPosition = instanceMatrix * mvPosition;
#endif
mvPosition = modelViewMatrix * mvPosition;
gl_Position = projectionMatrix * mvPosition;`,vy=`#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`,Vc=`#ifdef DITHERING
vec3 dithering( vec3 color ) {
float grid_position = rand( gl_FragCoord.xy );
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
return color + dither_shift_RGB;
}
#endif`,Rf=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
roughnessFactor *= texelRoughness.g;
#endif`,Ri=`#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
#endif`,Us=`#if NUM_SPOT_LIGHT_COORDS > 0
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#if NUM_SPOT_LIGHT_MAPS > 0
uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
#endif
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
struct DirectionalLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
#endif
#if NUM_SPOT_LIGHT_SHADOWS > 0
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
struct SpotLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
struct PointLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
float shadowCameraNear;
float shadowCameraFar;
};
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
#endif
float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
#ifdef USE_REVERSED_DEPTH_BUFFER
return step( depth, compare );
#else
return step( compare, depth );
#endif
}
vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
return unpackRGBATo2Half( texture2D( shadow, uv ) );
}
float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
float occlusion = 1.0;
vec2 distribution = texture2DDistribution( shadow, uv );
#ifdef USE_REVERSED_DEPTH_BUFFER
float hard_shadow = step( distribution.x, compare );
#else
float hard_shadow = step( compare, distribution.x );
#endif
if ( hard_shadow != 1.0 ) {
float distance = compare - distribution.x;
float variance = max( 0.00000, distribution.y * distribution.y );
float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
}
return occlusion;
}
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
float shadow = 1.0;
shadowCoord.xyz /= shadowCoord.w;
shadowCoord.z += shadowBias;
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
if ( frustumTest ) {
#if defined( SHADOWMAP_TYPE_PCF )
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
float dx0 = - texelSize.x * shadowRadius;
float dy0 = - texelSize.y * shadowRadius;
float dx1 = + texelSize.x * shadowRadius;
float dy1 = + texelSize.y * shadowRadius;
float dx2 = dx0 / 2.0;
float dy2 = dy0 / 2.0;
float dx3 = dx1 / 2.0;
float dy3 = dy1 / 2.0;
shadow = (
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
) * ( 1.0 / 17.0 );
#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
float dx = texelSize.x;
float dy = texelSize.y;
vec2 uv = shadowCoord.xy;
vec2 f = fract( uv * shadowMapSize + 0.5 );
uv -= f * texelSize;
shadow = (
texture2DCompare( shadowMap, uv, shadowCoord.z ) +
texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
f.x ) +
mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
f.x ) +
mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
f.y ) +
mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
f.y ) +
mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
f.x ),
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
f.x ),
f.y )
) * ( 1.0 / 9.0 );
#elif defined( SHADOWMAP_TYPE_VSM )
shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
#else
shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
#endif
}
return mix( 1.0, shadow, shadowIntensity );
}
vec2 cubeToUV( vec3 v, float texelSizeY ) {
vec3 absV = abs( v );
float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
absV *= scaleToCube;
v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
vec2 planar = v.xy;
float almostATexel = 1.5 * texelSizeY;
float almostOne = 1.0 - almostATexel;
if ( absV.z >= almostOne ) {
if ( v.z > 0.0 )
planar.x = 4.0 - v.x;
} else if ( absV.x >= almostOne ) {
float signX = sign( v.x );
planar.x = v.z * signX + 2.0 * signX;
} else if ( absV.y >= almostOne ) {
float signY = sign( v.y );
planar.x = v.x + 2.0 * signY + 2.0;
planar.y = v.z * signY - 2.0;
}
return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
}
float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
float shadow = 1.0;
vec3 lightToPosition = shadowCoord.xyz;
float lightToPositionLength = length( lightToPosition );
if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
vec3 bd3D = normalize( lightToPosition );
vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
shadow = (
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
) * ( 1.0 / 9.0 );
#else
shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
#endif
}
return mix( 1.0, shadow, shadowIntensity );
}
#endif`,Io=`#if NUM_SPOT_LIGHT_COORDS > 0
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
#endif
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0
uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
struct DirectionalLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
#endif
#if NUM_SPOT_LIGHT_SHADOWS > 0
struct SpotLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
};
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
struct PointLightShadow {
float shadowIntensity;
float shadowBias;
float shadowNormalBias;
float shadowRadius;
vec2 shadowMapSize;
float shadowCameraNear;
float shadowCameraFar;
};
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
#endif
#endif`,Nf=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
vec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );
vec4 shadowWorldPosition;
#endif
#if defined( USE_SHADOWMAP )
#if NUM_DIR_LIGHT_SHADOWS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );
vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );
vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
#endif
#endif
#if NUM_SPOT_LIGHT_COORDS > 0
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) {
shadowWorldPosition = worldPosition;
#if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias;
#endif
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
}
#pragma unroll_loop_end
#endif`,Do=`float getShadowMask() {
float shadow = 1.0;
#ifdef USE_SHADOWMAP
#if NUM_DIR_LIGHT_SHADOWS > 0
DirectionalLightShadow directionalLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
directionalLight = directionalLightShadows[ i ];
shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
}
#pragma unroll_loop_end
#endif
#if NUM_SPOT_LIGHT_SHADOWS > 0
SpotLightShadow spotLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
spotLight = spotLightShadows[ i ];
shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
}
#pragma unroll_loop_end
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
PointLightShadow pointLight;
#pragma unroll_loop_start
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
pointLight = pointLightShadows[ i ];
shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
}
#pragma unroll_loop_end
#endif
#endif
return shadow;
}`,zc=`#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`,Gc=`#ifdef USE_SKINNING
uniform mat4 bindMatrix;
uniform mat4 bindMatrixInverse;
uniform highp sampler2D boneTexture;
mat4 getBoneMatrix( const in float i ) {
int size = textureSize( boneTexture, 0 ).x;
int j = int( i ) * 4;
int x = j % size;
int y = j / size;
vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 );
vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 );
vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 );
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
return mat4( v1, v2, v3, v4 );
}
#endif`,jg=`#ifdef USE_SKINNING
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
vec4 skinned = vec4( 0.0 );
skinned += boneMatX * skinVertex * skinWeight.x;
skinned += boneMatY * skinVertex * skinWeight.y;
skinned += boneMatZ * skinVertex * skinWeight.z;
skinned += boneMatW * skinVertex * skinWeight.w;
transformed = ( bindMatrixInverse * skinned ).xyz;
#endif`,Pf=`#ifdef USE_SKINNING
mat4 skinMatrix = mat4( 0.0 );
skinMatrix += skinWeight.x * boneMatX;
skinMatrix += skinWeight.y * boneMatY;
skinMatrix += skinWeight.z * boneMatZ;
skinMatrix += skinWeight.w * boneMatW;
skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;
objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;
#ifdef USE_TANGENT
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
#endif
#endif`,Lf=`float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
#endif`,If=`#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
#endif`,Df=`#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`,Uf=`#ifndef saturate
#define saturate( a ) clamp( a, 0.0, 1.0 )
#endif
uniform float toneMappingExposure;
vec3 LinearToneMapping( vec3 color ) {
return saturate( toneMappingExposure * color );
}
vec3 ReinhardToneMapping( vec3 color ) {
color *= toneMappingExposure;
return saturate( color / ( vec3( 1.0 ) + color ) );
}
vec3 CineonToneMapping( vec3 color ) {
color *= toneMappingExposure;
color = max( vec3( 0.0 ), color - 0.004 );
return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );
}
vec3 RRTAndODTFit( vec3 v ) {
vec3 a = v * ( v + 0.0245786 ) - 0.000090537;
vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;
return a / b;
}
vec3 ACESFilmicToneMapping( vec3 color ) {
const mat3 ACESInputMat = mat3(
vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ),
vec3( 0.04823, 0.01566, 0.83777 )
);
const mat3 ACESOutputMat = mat3(
vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ),
vec3( -0.07367, -0.00605, 1.07602 )
);
color *= toneMappingExposure / 0.6;
color = ACESInputMat * color;
color = RRTAndODTFit( color );
color = ACESOutputMat * color;
return saturate( color );
}
const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3(
vec3( 1.6605, - 0.1246, - 0.0182 ),
vec3( - 0.5876, 1.1329, - 0.1006 ),
vec3( - 0.0728, - 0.0083, 1.1187 )
);
const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3(
vec3( 0.6274, 0.0691, 0.0164 ),
vec3( 0.3293, 0.9195, 0.0880 ),
vec3( 0.0433, 0.0113, 0.8956 )
);
vec3 agxDefaultContrastApprox( vec3 x ) {
vec3 x2 = x * x;
vec3 x4 = x2 * x2;
return + 15.5 * x4 * x2
- 40.14 * x4 * x
+ 31.96 * x4
- 6.868 * x2 * x
+ 0.4298 * x2
+ 0.1191 * x
- 0.00232;
}
vec3 AgXToneMapping( vec3 color ) {
const mat3 AgXInsetMatrix = mat3(
vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ),
vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ),
vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 )
);
const mat3 AgXOutsetMatrix = mat3(
vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ),
vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ),
vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 )
);
const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069;
color *= toneMappingExposure;
color = LINEAR_SRGB_TO_LINEAR_REC2020 * color;
color = AgXInsetMatrix * color;
color = max( color, 1e-10 ); color = log2( color );
color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv );
color = clamp( color, 0.0, 1.0 );
color = agxDefaultContrastApprox( color );
color = AgXOutsetMatrix * color;
color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) );
color = LINEAR_REC2020_TO_LINEAR_SRGB * color;
color = clamp( color, 0.0, 1.0 );
return color;
}
vec3 NeutralToneMapping( vec3 color ) {
const float StartCompression = 0.8 - 0.04;
const float Desaturation = 0.15;
color *= toneMappingExposure;
float x = min( color.r, min( color.g, color.b ) );
float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
color -= offset;
float peak = max( color.r, max( color.g, color.b ) );
if ( peak < StartCompression ) return color;
float d = 1. - StartCompression;
float newPeak = 1. - d * d / ( peak + d - StartCompression );
color *= newPeak / peak;
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
return mix( color, vec3( newPeak ), g );
}
vec3 CustomToneMapping( vec3 color ) { return color; }`,Ff=`#ifdef USE_TRANSMISSION
material.transmission = transmission;
material.transmissionAlpha = 1.0;
material.thickness = thickness;
material.attenuationDistance = attenuationDistance;
material.attenuationColor = attenuationColor;
#ifdef USE_TRANSMISSIONMAP
material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
#endif
#ifdef USE_THICKNESSMAP
material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
#endif
vec3 pos = vWorldPosition;
vec3 v = normalize( cameraPosition - pos );
vec3 n = inverseTransformDirection( normal, viewMatrix );
vec4 transmitted = getIBLVolumeRefraction(
n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
material.attenuationColor, material.attenuationDistance );
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
#endif`,is=`#ifdef USE_TRANSMISSION
uniform float transmission;
uniform float thickness;
uniform float attenuationDistance;
uniform vec3 attenuationColor;
#ifdef USE_TRANSMISSIONMAP
uniform sampler2D transmissionMap;
#endif
#ifdef USE_THICKNESSMAP
uniform sampler2D thicknessMap;
#endif
uniform vec2 transmissionSamplerSize;
uniform sampler2D transmissionSamplerMap;
uniform mat4 modelMatrix;
uniform mat4 projectionMatrix;
varying vec3 vWorldPosition;
float w0( float a ) {
return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 );
}
float w1( float a ) {
return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 );
}
float w2( float a ){
return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 );
}
float w3( float a ) {
return ( 1.0 / 6.0 ) * ( a * a * a );
}
float g0( float a ) {
return w0( a ) + w1( a );
}
float g1( float a ) {
return w2( a ) + w3( a );
}
float h0( float a ) {
return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) );
}
float h1( float a ) {
return 1.0 + w3( a ) / ( w2( a ) + w3( a ) );
}
vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) {
uv = uv * texelSize.zw + 0.5;
vec2 iuv = floor( uv );
vec2 fuv = fract( uv );
float g0x = g0( fuv.x );
float g1x = g1( fuv.x );
float h0x = h0( fuv.x );
float h1x = h1( fuv.x );
float h0y = h0( fuv.y );
float h1y = h1( fuv.y );
vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy;
vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy;
return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) +
g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) );
}
vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) {
vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) );
vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) );
vec2 fLodSizeInv = 1.0 / fLodSize;
vec2 cLodSizeInv = 1.0 / cLodSize;
vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) );
vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) );
return mix( fSample, cSample, fract( lod ) );
}
vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) {
vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior );
vec3 modelScale;
modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) );
modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) );
modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) );
return normalize( refractionVector ) * thickness * modelScale;
}
float applyIorToRoughness( const in float roughness, const in float ior ) {
return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 );
}
vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) {
float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior );
return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod );
}
vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) {
if ( isinf( attenuationDistance ) ) {
return vec3( 1.0 );
} else {
vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance;
vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance;
}
}
vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor,
const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix,
const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness,
const in vec3 attenuationColor, const in float attenuationDistance ) {
vec4 transmittedLight;
vec3 transmittance;
#ifdef USE_DISPERSION
float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion;
vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread );
for ( int i = 0; i < 3; i ++ ) {
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix );
vec3 refractedRayExit = position + transmissionRay;
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
refractionCoords += 1.0;
refractionCoords /= 2.0;
vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] );
transmittedLight[ i ] = transmissionSample[ i ];
transmittedLight.a += transmissionSample.a;
transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ];
}
transmittedLight.a /= 3.0;
#else
vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix );
vec3 refractedRayExit = position + transmissionRay;
vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 );
vec2 refractionCoords = ndcPos.xy / ndcPos.w;
refractionCoords += 1.0;
refractionCoords /= 2.0;
transmittedLight = getTransmissionSample( refractionCoords, roughness, ior );
transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance );
#endif
vec3 attenuatedColor = transmittance * transmittedLight.rgb;
vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness );
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
}
#endif`,Xg=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
varying vec2 vNormalMapUv;
#endif
#ifdef USE_EMISSIVEMAP
varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_SPECULARMAP
varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
uniform mat3 transmissionMapTransform;
varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
#endif`,sa=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
varying vec2 vUv;
#endif
#ifdef USE_MAP
uniform mat3 mapTransform;
varying vec2 vMapUv;
#endif
#ifdef USE_ALPHAMAP
uniform mat3 alphaMapTransform;
varying vec2 vAlphaMapUv;
#endif
#ifdef USE_LIGHTMAP
uniform mat3 lightMapTransform;
varying vec2 vLightMapUv;
#endif
#ifdef USE_AOMAP
uniform mat3 aoMapTransform;
varying vec2 vAoMapUv;
#endif
#ifdef USE_BUMPMAP
uniform mat3 bumpMapTransform;
varying vec2 vBumpMapUv;
#endif
#ifdef USE_NORMALMAP
uniform mat3 normalMapTransform;
varying vec2 vNormalMapUv;
#endif
#ifdef USE_DISPLACEMENTMAP
uniform mat3 displacementMapTransform;
varying vec2 vDisplacementMapUv;
#endif
#ifdef USE_EMISSIVEMAP
uniform mat3 emissiveMapTransform;
varying vec2 vEmissiveMapUv;
#endif
#ifdef USE_METALNESSMAP
uniform mat3 metalnessMapTransform;
varying vec2 vMetalnessMapUv;
#endif
#ifdef USE_ROUGHNESSMAP
uniform mat3 roughnessMapTransform;
varying vec2 vRoughnessMapUv;
#endif
#ifdef USE_ANISOTROPYMAP
uniform mat3 anisotropyMapTransform;
varying vec2 vAnisotropyMapUv;
#endif
#ifdef USE_CLEARCOATMAP
uniform mat3 clearcoatMapTransform;
varying vec2 vClearcoatMapUv;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
uniform mat3 clearcoatNormalMapTransform;
varying vec2 vClearcoatNormalMapUv;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
uniform mat3 clearcoatRoughnessMapTransform;
varying vec2 vClearcoatRoughnessMapUv;
#endif
#ifdef USE_SHEEN_COLORMAP
uniform mat3 sheenColorMapTransform;
varying vec2 vSheenColorMapUv;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
uniform mat3 sheenRoughnessMapTransform;
varying vec2 vSheenRoughnessMapUv;
#endif
#ifdef USE_IRIDESCENCEMAP
uniform mat3 iridescenceMapTransform;
varying vec2 vIridescenceMapUv;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform mat3 iridescenceThicknessMapTransform;
varying vec2 vIridescenceThicknessMapUv;
#endif
#ifdef USE_SPECULARMAP
uniform mat3 specularMapTransform;
varying vec2 vSpecularMapUv;
#endif
#ifdef USE_SPECULAR_COLORMAP
uniform mat3 specularColorMapTransform;
varying vec2 vSpecularColorMapUv;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
uniform mat3 specularIntensityMapTransform;
varying vec2 vSpecularIntensityMapUv;
#endif
#ifdef USE_TRANSMISSIONMAP
uniform mat3 transmissionMapTransform;
varying vec2 vTransmissionMapUv;
#endif
#ifdef USE_THICKNESSMAP
uniform mat3 thicknessMapTransform;
varying vec2 vThicknessMapUv;
#endif`,Mh=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
vUv = vec3( uv, 1 ).xy;
#endif
#ifdef USE_MAP
vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ALPHAMAP
vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_LIGHTMAP
vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_AOMAP
vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_BUMPMAP
vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_NORMALMAP
vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_DISPLACEMENTMAP
vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_EMISSIVEMAP
vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_METALNESSMAP
vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ROUGHNESSMAP
vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_ANISOTROPYMAP
vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOATMAP
vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_NORMALMAP
vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCEMAP
vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_COLORMAP
vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULARMAP
vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_COLORMAP
vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_TRANSMISSIONMAP
vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy;
#endif
#ifdef USE_THICKNESSMAP
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
#endif`,Bf=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
vec4 worldPosition = vec4( transformed, 1.0 );
#ifdef USE_BATCHING
worldPosition = batchingMatrix * worldPosition;
#endif
#ifdef USE_INSTANCING
worldPosition = instanceMatrix * worldPosition;
#endif
worldPosition = modelMatrix * worldPosition;
#endif`;const kn={alphahash_fragment:ay,alphahash_pars_fragment:cy,alphamap_fragment:ly,alphamap_pars_fragment:Nr,alphatest_fragment:Fn,alphatest_pars_fragment:uy,aomap_fragment:dt,aomap_pars_fragment:Hr,batching_pars_vertex:ie,batching_vertex:_f,begin_vertex:Ig,beginnormal_vertex:Ps,bsdfs:yf,iridescence_fragment:Dg,bumpmap_pars_fragment:Ug,clipping_planes_fragment:hy,clipping_planes_pars_fragment:$r,clipping_planes_pars_vertex:Ro,clipping_planes_vertex:Lc,color_fragment:Ic,color_pars_fragment:dy,color_pars_vertex:fy,color_vertex:Ua,common:bf,cube_uv_reflection_fragment:py,defaultnormal_vertex:vf,displacementmap_pars_vertex:sr,displacementmap_vertex:or,emissivemap_fragment:Fg,emissivemap_pars_fragment:Bg,colorspace_fragment:Og,colorspace_pars_fragment:lT,envmap_fragment:Sf,envmap_common_pars_fragment:uT,envmap_pars_fragment:wr,envmap_pars_vertex:No,envmap_physical_pars_fragment:yh,envmap_vertex:Ls,fog_vertex:xh,fog_pars_vertex:Dc,fog_fragment:Uc,fog_pars_fragment:Fc,gradientmap_pars_fragment:ta,lightmap_pars_fragment:na,lights_lambert_fragment:Fa,lights_lambert_pars_fragment:Bl,lights_pars_begin:_h,lights_toon_fragment:Ba,lights_toon_pars_fragment:Tf,lights_phong_fragment:my,lights_phong_pars_fragment:Ol,lights_physical_fragment:Mf,lights_physical_pars_fragment:xr,lights_fragment_begin:Po,lights_fragment_maps:wf,lights_fragment_end:bh,logdepthbuf_fragment:ia,logdepthbuf_pars_fragment:Af,logdepthbuf_pars_vertex:vh,logdepthbuf_vertex:Ef,map_fragment:Bc,map_pars_fragment:Ln,map_particle_fragment:Oc,map_particle_pars_fragment:Is,metalnessmap_fragment:gy,metalnessmap_pars_fragment:xy,morphinstance_vertex:ra,morphcolor_vertex:Sh,morphnormal_vertex:ns,morphtarget_pars_vertex:kg,morphtarget_vertex:Vg,normal_fragment_begin:Ds,normal_fragment_maps:Cf,normal_pars_fragment:_y,normal_pars_vertex:zg,normal_vertex:kc,normalmap_pars_fragment:Lo,clearcoat_normal_fragment_begin:Th,clearcoat_normal_fragment_maps:kl,clearcoat_pars_fragment:yy,iridescence_pars_fragment:by,opaque_fragment:Gg,packing:Wg,premultiplied_alpha_fragment:Hg,project_vertex:$g,dithering_fragment:vy,dithering_pars_fragment:Vc,roughnessmap_fragment:Rf,roughnessmap_pars_fragment:Ri,shadowmap_pars_fragment:Us,shadowmap_pars_vertex:Io,shadowmap_vertex:Nf,shadowmask_pars_fragment:Do,skinbase_vertex:zc,skinning_pars_vertex:Gc,skinning_vertex:jg,skinnormal_vertex:Pf,specularmap_fragment:Lf,specularmap_pars_fragment:If,tonemapping_fragment:Df,tonemapping_pars_fragment:Uf,transmission_fragment:Ff,transmission_pars_fragment:is,uv_pars_fragment:Xg,uv_pars_vertex:sa,uv_vertex:Mh,worldpos_vertex:Bf,background_vert:`varying vec2 vUv;
uniform mat3 uvTransform;
void main() {
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
gl_Position = vec4( position.xy, 1.0, 1.0 );
}`,background_frag:`uniform sampler2D t2D;
uniform float backgroundIntensity;
varying vec2 vUv;
void main() {
vec4 texColor = texture2D( t2D, vUv );
#ifdef DECODE_VIDEO_TEXTURE
texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
#endif
texColor.rgb *= backgroundIntensity;
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,backgroundCube_vert:`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,backgroundCube_frag:`#ifdef ENVMAP_TYPE_CUBE
uniform samplerCube envMap;
#elif defined( ENVMAP_TYPE_CUBE_UV )
uniform sampler2D envMap;
#endif
uniform float flipEnvMap;
uniform float backgroundBlurriness;
uniform float backgroundIntensity;
uniform mat3 backgroundRotation;
varying vec3 vWorldDirection;
#include <cube_uv_reflection_fragment>
void main() {
#ifdef ENVMAP_TYPE_CUBE
vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
#elif defined( ENVMAP_TYPE_CUBE_UV )
vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
#else
vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
#endif
texColor.rgb *= backgroundIntensity;
gl_FragColor = texColor;
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,cube_vert:`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
gl_Position.z = gl_Position.w;
}`,cube_frag:`uniform samplerCube tCube;
uniform float tFlip;
uniform float opacity;
varying vec3 vWorldDirection;
void main() {
vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
gl_FragColor = texColor;
gl_FragColor.a *= opacity;
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,depth_vert:`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
varying vec2 vHighPrecisionZW;
void main() {
#include <uv_vertex>
#include <batching_vertex>
#include <skinbase_vertex>
#include <morphinstance_vertex>
#ifdef USE_DISPLACEMENTMAP
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinnormal_vertex>
#endif
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vHighPrecisionZW = gl_Position.zw;
}`,depth_frag:`#if DEPTH_PACKING == 3200
uniform float opacity;
#endif
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
varying vec2 vHighPrecisionZW;
void main() {
vec4 diffuseColor = vec4( 1.0 );
#include <clipping_planes_fragment>
#if DEPTH_PACKING == 3200
diffuseColor.a = opacity;
#endif
#include <map_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <logdepthbuf_fragment>
#ifdef USE_REVERSED_DEPTH_BUFFER
float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
#else
float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
#endif
#if DEPTH_PACKING == 3200
gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
#elif DEPTH_PACKING == 3201
gl_FragColor = packDepthToRGBA( fragCoordZ );
#elif DEPTH_PACKING == 3202
gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
#elif DEPTH_PACKING == 3203
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
#endif
}`,distanceRGBA_vert:`#define DISTANCE
varying vec3 vWorldPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <batching_vertex>
#include <skinbase_vertex>
#include <morphinstance_vertex>
#ifdef USE_DISPLACEMENTMAP
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinnormal_vertex>
#endif
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <worldpos_vertex>
#include <clipping_planes_vertex>
vWorldPosition = worldPosition.xyz;
}`,distanceRGBA_frag:`#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
varying vec3 vWorldPosition;
#include <common>
#include <packing>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <clipping_planes_pars_fragment>
void main () {
vec4 diffuseColor = vec4( 1.0 );
#include <clipping_planes_fragment>
#include <map_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
float dist = length( vWorldPosition - referencePosition );
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
dist = saturate( dist );
gl_FragColor = packDepthToRGBA( dist );
}`,equirect_vert:`varying vec3 vWorldDirection;
#include <common>
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
}`,equirect_frag:`uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
vec3 direction = normalize( vWorldDirection );
vec2 sampleUV = equirectUv( direction );
gl_FragColor = texture2D( tEquirect, sampleUV );
#include <tonemapping_fragment>
#include <colorspace_fragment>
}`,linedashed_vert:`uniform float scale;
attribute float lineDistance;
varying float vLineDistance;
#include <common>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
vLineDistance = scale * lineDistance;
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
}`,linedashed_frag:`uniform vec3 diffuse;
uniform float opacity;
uniform float dashSize;
uniform float totalSize;
varying float vLineDistance;
#include <common>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
if ( mod( vLineDistance, totalSize ) > dashSize ) {
discard;
}
vec3 outgoingLight = vec3( 0.0 );
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
outgoingLight = diffuseColor.rgb;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
}`,meshbasic_vert:`#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#endif
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <worldpos_vertex>
#include <envmap_vertex>
#include <fog_vertex>
}`,meshbasic_frag:`uniform vec3 diffuse;
uniform float opacity;
#ifndef FLAT_SHADED
varying vec3 vNormal;
#endif
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <specularmap_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
#ifdef USE_LIGHTMAP
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
#else
reflectedLight.indirectDiffuse += vec3( 1.0 );
#endif
#include <aomap_fragment>
reflectedLight.indirectDiffuse *= diffuseColor.rgb;
vec3 outgoingLight = reflectedLight.indirectDiffuse;
#include <envmap_fragment>
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,meshlambert_vert:`#define LAMBERT
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,meshlambert_frag:`#define LAMBERT
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_lambert_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <specularmap_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_lambert_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
#include <envmap_fragment>
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,meshmatcap_vert:`#define MATCAP
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <color_pars_vertex>
#include <displacementmap_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
vViewPosition = - mvPosition.xyz;
}`,meshmatcap_frag:`#define MATCAP
uniform vec3 diffuse;
uniform float opacity;
uniform sampler2D matcap;
varying vec3 vViewPosition;
#include <common>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
vec3 viewDir = normalize( vViewPosition );
vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
vec3 y = cross( viewDir, x );
vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
#ifdef USE_MATCAP
vec4 matcapColor = texture2D( matcap, uv );
#else
vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
#endif
vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,meshnormal_vert:`#define NORMAL
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphinstance_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
vViewPosition = - mvPosition.xyz;
#endif
}`,meshnormal_frag:`#define NORMAL
uniform float opacity;
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
varying vec3 vViewPosition;
#endif
#include <packing>
#include <uv_pars_fragment>
#include <normal_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
#include <clipping_planes_fragment>
#include <logdepthbuf_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
#ifdef OPAQUE
gl_FragColor.a = 1.0;
#endif
}`,meshphong_vert:`#define PHONG
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <envmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphinstance_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <envmap_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,meshphong_frag:`#define PHONG
uniform vec3 diffuse;
uniform vec3 emissive;
uniform vec3 specular;
uniform float shininess;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_phong_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <specularmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <specularmap_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_phong_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
#include <envmap_fragment>
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,meshphysical_vert:`#define STANDARD
varying vec3 vViewPosition;
#ifdef USE_TRANSMISSION
varying vec3 vWorldPosition;
#endif
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
#ifdef USE_TRANSMISSION
vWorldPosition = worldPosition.xyz;
#endif
}`,meshphysical_frag:`#define STANDARD
#ifdef PHYSICAL
#define IOR
#define USE_SPECULAR
#endif
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float roughness;
uniform float metalness;
uniform float opacity;
#ifdef IOR
uniform float ior;
#endif
#ifdef USE_SPECULAR
uniform float specularIntensity;
uniform vec3 specularColor;
#ifdef USE_SPECULAR_COLORMAP
uniform sampler2D specularColorMap;
#endif
#ifdef USE_SPECULAR_INTENSITYMAP
uniform sampler2D specularIntensityMap;
#endif
#endif
#ifdef USE_CLEARCOAT
uniform float clearcoat;
uniform float clearcoatRoughness;
#endif
#ifdef USE_DISPERSION
uniform float dispersion;
#endif
#ifdef USE_IRIDESCENCE
uniform float iridescence;
uniform float iridescenceIOR;
uniform float iridescenceThicknessMinimum;
uniform float iridescenceThicknessMaximum;
#endif
#ifdef USE_SHEEN
uniform vec3 sheenColor;
uniform float sheenRoughness;
#ifdef USE_SHEEN_COLORMAP
uniform sampler2D sheenColorMap;
#endif
#ifdef USE_SHEEN_ROUGHNESSMAP
uniform sampler2D sheenRoughnessMap;
#endif
#endif
#ifdef USE_ANISOTROPY
uniform vec2 anisotropyVector;
#ifdef USE_ANISOTROPYMAP
uniform sampler2D anisotropyMap;
#endif
#endif
varying vec3 vViewPosition;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <iridescence_fragment>
#include <cube_uv_reflection_fragment>
#include <envmap_common_pars_fragment>
#include <envmap_physical_pars_fragment>
#include <fog_pars_fragment>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_physical_pars_fragment>
#include <transmission_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <clearcoat_pars_fragment>
#include <iridescence_pars_fragment>
#include <roughnessmap_pars_fragment>
#include <metalnessmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <roughnessmap_fragment>
#include <metalnessmap_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <clearcoat_normal_fragment_begin>
#include <clearcoat_normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_physical_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
#include <transmission_fragment>
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
#ifdef USE_SHEEN
float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
#endif
#ifdef USE_CLEARCOAT
float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
#endif
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,meshtoon_vert:`#define TOON
varying vec3 vViewPosition;
#include <common>
#include <batching_pars_vertex>
#include <uv_pars_vertex>
#include <displacementmap_pars_vertex>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <normal_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <shadowmap_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <normal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <displacementmap_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
vViewPosition = - mvPosition.xyz;
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,meshtoon_frag:`#define TOON
uniform vec3 diffuse;
uniform vec3 emissive;
uniform float opacity;
#include <common>
#include <packing>
#include <dithering_pars_fragment>
#include <color_pars_fragment>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <aomap_pars_fragment>
#include <lightmap_pars_fragment>
#include <emissivemap_pars_fragment>
#include <gradientmap_pars_fragment>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <normal_pars_fragment>
#include <lights_toon_pars_fragment>
#include <shadowmap_pars_fragment>
#include <bumpmap_pars_fragment>
#include <normalmap_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
vec3 totalEmissiveRadiance = emissive;
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <color_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
#include <normal_fragment_begin>
#include <normal_fragment_maps>
#include <emissivemap_fragment>
#include <lights_toon_fragment>
#include <lights_fragment_begin>
#include <lights_fragment_maps>
#include <lights_fragment_end>
#include <aomap_fragment>
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
#include <dithering_fragment>
}`,points_vert:`uniform float size;
uniform float scale;
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
#ifdef USE_POINTS_UV
varying vec2 vUv;
uniform mat3 uvTransform;
#endif
void main() {
#ifdef USE_POINTS_UV
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
#endif
#include <color_vertex>
#include <morphinstance_vertex>
#include <morphcolor_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <project_vertex>
gl_PointSize = size;
#ifdef USE_SIZEATTENUATION
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
#endif
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <worldpos_vertex>
#include <fog_vertex>
}`,points_frag:`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <color_pars_fragment>
#include <map_particle_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
vec3 outgoingLight = vec3( 0.0 );
#include <logdepthbuf_fragment>
#include <map_particle_fragment>
#include <color_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
outgoingLight = diffuseColor.rgb;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
}`,shadow_vert:`#include <common>
#include <batching_pars_vertex>
#include <fog_pars_vertex>
#include <morphtarget_pars_vertex>
#include <skinning_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <shadowmap_pars_vertex>
void main() {
#include <batching_vertex>
#include <beginnormal_vertex>
#include <morphinstance_vertex>
#include <morphnormal_vertex>
#include <skinbase_vertex>
#include <skinnormal_vertex>
#include <defaultnormal_vertex>
#include <begin_vertex>
#include <morphtarget_vertex>
#include <skinning_vertex>
#include <project_vertex>
#include <logdepthbuf_vertex>
#include <worldpos_vertex>
#include <shadowmap_vertex>
#include <fog_vertex>
}`,shadow_frag:`uniform vec3 color;
uniform float opacity;
#include <common>
#include <packing>
#include <fog_pars_fragment>
#include <bsdfs>
#include <lights_pars_begin>
#include <logdepthbuf_pars_fragment>
#include <shadowmap_pars_fragment>
#include <shadowmask_pars_fragment>
void main() {
#include <logdepthbuf_fragment>
gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
}`,sprite_vert:`uniform float rotation;
uniform vec2 center;
#include <common>
#include <uv_pars_vertex>
#include <fog_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
void main() {
#include <uv_vertex>
vec4 mvPosition = modelViewMatrix[ 3 ];
vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
#ifndef USE_SIZEATTENUATION
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
if ( isPerspective ) scale *= - mvPosition.z;
#endif
vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
vec2 rotatedPosition;
rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
mvPosition.xy += rotatedPosition;
gl_Position = projectionMatrix * mvPosition;
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
}`,sprite_frag:`uniform vec3 diffuse;
uniform float opacity;
#include <common>
#include <uv_pars_fragment>
#include <map_pars_fragment>
#include <alphamap_pars_fragment>
#include <alphatest_pars_fragment>
#include <alphahash_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
void main() {
vec4 diffuseColor = vec4( diffuse, opacity );
#include <clipping_planes_fragment>
vec3 outgoingLight = vec3( 0.0 );
#include <logdepthbuf_fragment>
#include <map_fragment>
#include <alphamap_fragment>
#include <alphatest_fragment>
#include <alphahash_fragment>
outgoingLight = diffuseColor.rgb;
#include <opaque_fragment>
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
}`},wt={common:{diffuse:{value:new d.Ilk(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new d.Vkp},alphaMap:{value:null},alphaMapTransform:{value:new d.Vkp},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new d.Vkp}},envmap:{envMap:{value:null},envMapRotation:{value:new d.Vkp},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new d.Vkp}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new d.Vkp}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new d.Vkp},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new d.Vkp},normalScale:{value:new d.FM8(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new d.Vkp},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new d.Vkp}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new d.Vkp}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new d.Vkp}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new d.Ilk(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotShadowMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null}},points:{diffuse:{value:new d.Ilk(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new d.Vkp},alphaTest:{value:0},uvTransform:{value:new d.Vkp}},sprite:{diffuse:{value:new d.Ilk(16777215)},opacity:{value:1},center:{value:new d.FM8(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new d.Vkp},alphaMap:{value:null},alphaMapTransform:{value:new d.Vkp},alphaTest:{value:0}}},ss={basic:{uniforms:(0,d.Rhp)([wt.common,wt.specularmap,wt.envmap,wt.aomap,wt.lightmap,wt.fog]),vertexShader:kn.meshbasic_vert,fragmentShader:kn.meshbasic_frag},lambert:{uniforms:(0,d.Rhp)([wt.common,wt.specularmap,wt.envmap,wt.aomap,wt.lightmap,wt.emissivemap,wt.bumpmap,wt.normalmap,wt.displacementmap,wt.fog,wt.lights,{emissive:{value:new d.Ilk(0)}}]),vertexShader:kn.meshlambert_vert,fragmentShader:kn.meshlambert_frag},phong:{uniforms:(0,d.Rhp)([wt.common,wt.specularmap,wt.envmap,wt.aomap,wt.lightmap,wt.emissivemap,wt.bumpmap,wt.normalmap,wt.displacementmap,wt.fog,wt.lights,{emissive:{value:new d.Ilk(0)},specular:{value:new d.Ilk(1118481)},shininess:{value:30}}]),vertexShader:kn.meshphong_vert,fragmentShader:kn.meshphong_frag},standard:{uniforms:(0,d.Rhp)([wt.common,wt.envmap,wt.aomap,wt.lightmap,wt.emissivemap,wt.bumpmap,wt.normalmap,wt.displacementmap,wt.roughnessmap,wt.metalnessmap,wt.fog,wt.lights,{emissive:{value:new d.Ilk(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:kn.meshphysical_vert,fragmentShader:kn.meshphysical_frag},toon:{uniforms:(0,d.Rhp)([wt.common,wt.aomap,wt.lightmap,wt.emissivemap,wt.bumpmap,wt.normalmap,wt.displacementmap,wt.gradientmap,wt.fog,wt.lights,{emissive:{value:new d.Ilk(0)}}]),vertexShader:kn.meshtoon_vert,fragmentShader:kn.meshtoon_frag},matcap:{uniforms:(0,d.Rhp)([wt.common,wt.bumpmap,wt.normalmap,wt.displacementmap,wt.fog,{matcap:{value:null}}]),vertexShader:kn.meshmatcap_vert,fragmentShader:kn.meshmatcap_frag},points:{uniforms:(0,d.Rhp)([wt.points,wt.fog]),vertexShader:kn.points_vert,fragmentShader:kn.points_frag},dashed:{uniforms:(0,d.Rhp)([wt.common,wt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:kn.linedashed_vert,fragmentShader:kn.linedashed_frag},depth:{uniforms:(0,d.Rhp)([wt.common,wt.displacementmap]),vertexShader:kn.depth_vert,fragmentShader:kn.depth_frag},normal:{uniforms:(0,d.Rhp)([wt.common,wt.bumpmap,wt.normalmap,wt.displacementmap,{opacity:{value:1}}]),vertexShader:kn.meshnormal_vert,fragmentShader:kn.meshnormal_frag},sprite:{uniforms:(0,d.Rhp)([wt.sprite,wt.fog]),vertexShader:kn.sprite_vert,fragmentShader:kn.sprite_frag},background:{uniforms:{uvTransform:{value:new d.Vkp},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:kn.background_vert,fragmentShader:kn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new d.Vkp}},vertexShader:kn.backgroundCube_vert,fragmentShader:kn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:kn.cube_vert,fragmentShader:kn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:kn.equirect_vert,fragmentShader:kn.equirect_frag},distanceRGBA:{uniforms:(0,d.Rhp)([wt.common,wt.displacementmap,{referencePosition:{value:new d.Pa4},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:kn.distanceRGBA_vert,fragmentShader:kn.distanceRGBA_frag},shadow:{uniforms:(0,d.Rhp)([wt.lights,wt.fog,{color:{value:new d.Ilk(0)},opacity:{value:1}}]),vertexShader:kn.shadow_vert,fragmentShader:kn.shadow_frag}};ss.physical={uniforms:(0,d.Rhp)([ss.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new d.Vkp},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new d.Vkp},clearcoatNormalScale:{value:new d.FM8(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new d.Vkp},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new d.Vkp},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new d.Vkp},sheen:{value:0},sheenColor:{value:new d.Ilk(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new d.Vkp},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new d.Vkp},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new d.Vkp},transmissionSamplerSize:{value:new d.FM8},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new d.Vkp},attenuationDistance:{value:0},attenuationColor:{value:new d.Ilk(0)},specularColor:{value:new d.Ilk(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new d.Vkp},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new d.Vkp},anisotropyVector:{value:new d.FM8},anisotropyMap:{value:null},anisotropyMapTransform:{value:new d.Vkp}}]),vertexShader:kn.meshphysical_vert,fragmentShader:kn.meshphysical_frag};const Oa={r:0,b:0,g:0},Uo=new d.USm,Eh=new d.yGw;function Kg(i,e,t,r,s,a,c){const h=new d.Ilk(0);let f=a===!0?0:1,m,x,_=null,v=0,T=null;function w(F){let W=F.isScene===!0?F.background:null;return W&&W.isTexture&&(W=(F.backgroundBlurriness>0?t:e).get(W)),W}function P(F){let W=!1;const K=w(F);K===null?E(h,f):K&&K.isColor&&(E(K,1),W=!0);const U=i.xr.getEnvironmentBlendMode();U==="additive"?r.buffers.color.setClear(0,0,0,1,c):U==="alpha-blend"&&r.buffers.color.setClear(0,0,0,0,c),(i.autoClear||W)&&(r.buffers.depth.setTest(!0),r.buffers.depth.setMask(!0),r.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function C(F,W){const K=w(W);K&&(K.isCubeTexture||K.mapping===d.g8_)?(x===void 0&&(x=new d.Kj0(new d.DvJ(1,1,1),new d.jyz({name:"BackgroundCubeMaterial",uniforms:(0,d.dwf)(ss.backgroundCube.uniforms),vertexShader:ss.backgroundCube.vertexShader,fragmentShader:ss.backgroundCube.fragmentShader,side:d._Li,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),x.geometry.deleteAttribute("normal"),x.geometry.deleteAttribute("uv"),x.onBeforeRender=function(U,j,oe){this.matrixWorld.copyPosition(oe.matrixWorld)},Object.defineProperty(x.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),s.update(x)),Uo.copy(W.backgroundRotation),Uo.x*=-1,Uo.y*=-1,Uo.z*=-1,K.isCubeTexture&&K.isRenderTargetTexture===!1&&(Uo.y*=-1,Uo.z*=-1),x.material.uniforms.envMap.value=K,x.material.uniforms.flipEnvMap.value=K.isCubeTexture&&K.isRenderTargetTexture===!1?-1:1,x.material.uniforms.backgroundBlurriness.value=W.backgroundBlurriness,x.material.uniforms.backgroundIntensity.value=W.backgroundIntensity,x.material.uniforms.backgroundRotation.value.setFromMatrix4(Eh.makeRotationFromEuler(Uo)),x.material.toneMapped=d.epp.getTransfer(K.colorSpace)!==d.j17,(_!==K||v!==K.version||T!==i.toneMapping)&&(x.material.needsUpdate=!0,_=K,v=K.version,T=i.toneMapping),x.layers.enableAll(),F.unshift(x,x.geometry,x.material,0,0,null)):K&&K.isTexture&&(m===void 0&&(m=new d.Kj0(new d._12(2,2),new d.jyz({name:"BackgroundMaterial",uniforms:(0,d.dwf)(ss.background.uniforms),vertexShader:ss.background.vertexShader,fragmentShader:ss.background.fragmentShader,side:d.Wl3,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),m.geometry.deleteAttribute("normal"),Object.defineProperty(m.material,"map",{get:function(){return this.uniforms.t2D.value}}),s.update(m)),m.material.uniforms.t2D.value=K,m.material.uniforms.backgroundIntensity.value=W.backgroundIntensity,m.material.toneMapped=d.epp.getTransfer(K.colorSpace)!==d.j17,K.matrixAutoUpdate===!0&&K.updateMatrix(),m.material.uniforms.uvTransform.value.copy(K.matrix),(_!==K||v!==K.version||T!==i.toneMapping)&&(m.material.needsUpdate=!0,_=K,v=K.version,T=i.toneMapping),m.layers.enableAll(),F.unshift(m,m.geometry,m.material,0,0,null))}function E(F,W){F.getRGB(Oa,(0,d.oDz)(i)),r.buffers.color.setClear(Oa.r,Oa.g,Oa.b,W,c)}function D(){x!==void 0&&(x.geometry.dispose(),x.material.dispose(),x=void 0),m!==void 0&&(m.geometry.dispose(),m.material.dispose(),m=void 0)}return{getClearColor:function(){return h},setClearColor:function(F,W=1){h.set(F),f=W,E(h,f)},getClearAlpha:function(){return f},setClearAlpha:function(F){f=F,E(h,f)},render:P,addToRenderList:C,dispose:D}}function Ch(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),r={},s=v(null);let a=s,c=!1;function h(O,le,be,Ee,Pe){let He=!1;const Be=_(Ee,be,le);a!==Be&&(a=Be,m(a.object)),He=T(O,Ee,be,Pe),He&&w(O,Ee,be,Pe),Pe!==null&&e.update(Pe,i.ELEMENT_ARRAY_BUFFER),(He||c)&&(c=!1,W(O,le,be,Ee),Pe!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(Pe).buffer))}function f(){return i.createVertexArray()}function m(O){return i.bindVertexArray(O)}function x(O){return i.deleteVertexArray(O)}function _(O,le,be){const Ee=be.wireframe===!0;let Pe=r[O.id];Pe===void 0&&(Pe={},r[O.id]=Pe);let He=Pe[le.id];He===void 0&&(He={},Pe[le.id]=He);let Be=He[Ee];return Be===void 0&&(Be=v(f()),He[Ee]=Be),Be}function v(O){const le=[],be=[],Ee=[];for(let Pe=0;Pe<t;Pe++)le[Pe]=0,be[Pe]=0,Ee[Pe]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:le,enabledAttributes:be,attributeDivisors:Ee,object:O,attributes:{},index:null}}function T(O,le,be,Ee){const Pe=a.attributes,He=le.attributes;let Be=0;const ft=be.getAttributes();for(const $e in ft)if(ft[$e].location>=0){const Pt=Pe[$e];let Ye=He[$e];if(Ye===void 0&&($e==="instanceMatrix"&&O.instanceMatrix&&(Ye=O.instanceMatrix),$e==="instanceColor"&&O.instanceColor&&(Ye=O.instanceColor)),Pt===void 0||Pt.attribute!==Ye||Ye&&Pt.data!==Ye.data)return!0;Be++}return a.attributesNum!==Be||a.index!==Ee}function w(O,le,be,Ee){const Pe={},He=le.attributes;let Be=0;const ft=be.getAttributes();for(const $e in ft)if(ft[$e].location>=0){let Pt=He[$e];Pt===void 0&&($e==="instanceMatrix"&&O.instanceMatrix&&(Pt=O.instanceMatrix),$e==="instanceColor"&&O.instanceColor&&(Pt=O.instanceColor));const Ye={};Ye.attribute=Pt,Pt&&Pt.data&&(Ye.data=Pt.data),Pe[$e]=Ye,Be++}a.attributes=Pe,a.attributesNum=Be,a.index=Ee}function P(){const O=a.newAttributes;for(let le=0,be=O.length;le<be;le++)O[le]=0}function C(O){E(O,0)}function E(O,le){const be=a.newAttributes,Ee=a.enabledAttributes,Pe=a.attributeDivisors;be[O]=1,Ee[O]===0&&(i.enableVertexAttribArray(O),Ee[O]=1),Pe[O]!==le&&(i.vertexAttribDivisor(O,le),Pe[O]=le)}function D(){const O=a.newAttributes,le=a.enabledAttributes;for(let be=0,Ee=le.length;be<Ee;be++)le[be]!==O[be]&&(i.disableVertexAttribArray(be),le[be]=0)}function F(O,le,be,Ee,Pe,He,Be){Be===!0?i.vertexAttribIPointer(O,le,be,Pe,He):i.vertexAttribPointer(O,le,be,Ee,Pe,He)}function W(O,le,be,Ee){P();const Pe=Ee.attributes,He=be.getAttributes(),Be=le.defaultAttributeValues;for(const ft in He){const $e=He[ft];if($e.location>=0){let Tt=Pe[ft];if(Tt===void 0&&(ft==="instanceMatrix"&&O.instanceMatrix&&(Tt=O.instanceMatrix),ft==="instanceColor"&&O.instanceColor&&(Tt=O.instanceColor)),Tt!==void 0){const Pt=Tt.normalized,Ye=Tt.itemSize,yt=e.get(Tt);if(yt===void 0)continue;const Ot=yt.buffer,Mn=yt.type,tt=yt.bytesPerElement,ve=Mn===i.INT||Mn===i.UNSIGNED_INT||Tt.gpuType===d.Kz5;if(Tt.isInterleavedBufferAttribute){const Ne=Tt.data,gt=Ne.stride,qt=Tt.offset;if(Ne.isInstancedInterleavedBuffer){for(let Nt=0;Nt<$e.locationSize;Nt++)E($e.location+Nt,Ne.meshPerAttribute);O.isInstancedMesh!==!0&&Ee._maxInstanceCount===void 0&&(Ee._maxInstanceCount=Ne.meshPerAttribute*Ne.count)}else for(let Nt=0;Nt<$e.locationSize;Nt++)C($e.location+Nt);i.bindBuffer(i.ARRAY_BUFFER,Ot);for(let Nt=0;Nt<$e.locationSize;Nt++)F($e.location+Nt,Ye/$e.locationSize,Mn,Pt,gt*tt,(qt+Ye/$e.locationSize*Nt)*tt,ve)}else{if(Tt.isInstancedBufferAttribute){for(let Ne=0;Ne<$e.locationSize;Ne++)E($e.location+Ne,Tt.meshPerAttribute);O.isInstancedMesh!==!0&&Ee._maxInstanceCount===void 0&&(Ee._maxInstanceCount=Tt.meshPerAttribute*Tt.count)}else for(let Ne=0;Ne<$e.locationSize;Ne++)C($e.location+Ne);i.bindBuffer(i.ARRAY_BUFFER,Ot);for(let Ne=0;Ne<$e.locationSize;Ne++)F($e.location+Ne,Ye/$e.locationSize,Mn,Pt,Ye*tt,Ye/$e.locationSize*Ne*tt,ve)}}else if(Be!==void 0){const Pt=Be[ft];if(Pt!==void 0)switch(Pt.length){case 2:i.vertexAttrib2fv($e.location,Pt);break;case 3:i.vertexAttrib3fv($e.location,Pt);break;case 4:i.vertexAttrib4fv($e.location,Pt);break;default:i.vertexAttrib1fv($e.location,Pt)}}}}D()}function K(){oe();for(const O in r){const le=r[O];for(const be in le){const Ee=le[be];for(const Pe in Ee)x(Ee[Pe].object),delete Ee[Pe];delete le[be]}delete r[O]}}function U(O){if(r[O.id]===void 0)return;const le=r[O.id];for(const be in le){const Ee=le[be];for(const Pe in Ee)x(Ee[Pe].object),delete Ee[Pe];delete le[be]}delete r[O.id]}function j(O){for(const le in r){const be=r[le];if(be[O.id]===void 0)continue;const Ee=be[O.id];for(const Pe in Ee)x(Ee[Pe].object),delete Ee[Pe];delete be[O.id]}}function oe(){k(),c=!0,a!==s&&(a=s,m(a.object))}function k(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:h,reset:oe,resetDefaultState:k,dispose:K,releaseStatesOfGeometry:U,releaseStatesOfProgram:j,initAttributes:P,enableAttribute:C,disableUnusedAttributes:D}}function aa(i,e,t){let r;function s(m){r=m}function a(m,x){i.drawArrays(r,m,x),t.update(x,r,1)}function c(m,x,_){_!==0&&(i.drawArraysInstanced(r,m,x,_),t.update(x,r,_))}function h(m,x,_){if(_===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(r,m,0,x,0,_);let T=0;for(let w=0;w<_;w++)T+=x[w];t.update(T,r,1)}function f(m,x,_,v){if(_===0)return;const T=e.get("WEBGL_multi_draw");if(T===null)for(let w=0;w<m.length;w++)c(m[w],x[w],v[w]);else{T.multiDrawArraysInstancedWEBGL(r,m,0,x,0,v,0,_);let w=0;for(let P=0;P<_;P++)w+=x[P]*v[P];t.update(w,r,1)}}this.setMode=s,this.render=a,this.renderInstances=c,this.renderMultiDraw=h,this.renderMultiDrawInstances=f}function wy(i,e,t,r){let s;function a(){if(s!==void 0)return s;if(e.has("EXT_texture_filter_anisotropic")===!0){const j=e.get("EXT_texture_filter_anisotropic");s=i.getParameter(j.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function c(j){return!(j!==d.wk1&&r.convert(j)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function h(j){const oe=j===d.cLu&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(j!==d.ywz&&r.convert(j)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&j!==d.VzW&&!oe)}function f(j){if(j==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";j="mediump"}return j==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let m=t.precision!==void 0?t.precision:"highp";const x=f(m);x!==m&&((0,d.ZK6)("WebGLRenderer:",m,"not supported, using",x,"instead."),m=x);const _=t.logarithmicDepthBuffer===!0,v=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),T=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),w=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),P=i.getParameter(i.MAX_TEXTURE_SIZE),C=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),E=i.getParameter(i.MAX_VERTEX_ATTRIBS),D=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),F=i.getParameter(i.MAX_VARYING_VECTORS),W=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),K=w>0,U=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:a,getMaxPrecision:f,textureFormatReadable:c,textureTypeReadable:h,precision:m,logarithmicDepthBuffer:_,reversedDepthBuffer:v,maxTextures:T,maxVertexTextures:w,maxTextureSize:P,maxCubemapSize:C,maxAttributes:E,maxVertexUniforms:D,maxVaryings:F,maxFragmentUniforms:W,vertexTextures:K,maxSamples:U}}function Rh(i){const e=this;let t=null,r=0,s=!1,a=!1;const c=new d.JOQ,h=new d.Vkp,f={value:null,needsUpdate:!1};this.uniform=f,this.numPlanes=0,this.numIntersection=0,this.init=function(_,v){const T=_.length!==0||v||r!==0||s;return s=v,r=_.length,T},this.beginShadows=function(){a=!0,x(null)},this.endShadows=function(){a=!1},this.setGlobalState=function(_,v){t=x(_,v,0)},this.setState=function(_,v,T){const w=_.clippingPlanes,P=_.clipIntersection,C=_.clipShadows,E=i.get(_);if(!s||w===null||w.length===0||a&&!C)a?x(null):m();else{const D=a?0:r,F=D*4;let W=E.clippingState||null;f.value=W,W=x(w,v,F,T);for(let K=0;K!==F;++K)W[K]=t[K];E.clippingState=W,this.numIntersection=P?this.numPlanes:0,this.numPlanes+=D}};function m(){f.value!==t&&(f.value=t,f.needsUpdate=r>0),e.numPlanes=r,e.numIntersection=0}function x(_,v,T,w){const P=_!==null?_.length:0;let C=null;if(P!==0){if(C=f.value,w!==!0||C===null){const E=T+P*4,D=v.matrixWorldInverse;h.getNormalMatrix(D),(C===null||C.length<E)&&(C=new Float32Array(E));for(let F=0,W=T;F!==P;++F,W+=4)c.copy(_[F]).applyMatrix4(D,h),c.normal.toArray(C,W),C[W+3]=c.constant}f.value=C,f.needsUpdate=!0}return e.numPlanes=P,e.numIntersection=0,C}}function zl(i){let e=new WeakMap;function t(c,h){return h===d.dSO?c.mapping=d.fY$:h===d.Bf4&&(c.mapping=d.vxC),c}function r(c){if(c&&c.isTexture){const h=c.mapping;if(h===d.dSO||h===d.Bf4)if(e.has(c)){const f=e.get(c).texture;return t(f,c.mapping)}else{const f=c.image;if(f&&f.height>0){const m=new d.oAp(f.height);return m.fromEquirectangularTexture(i,c),e.set(c,m),c.addEventListener("dispose",s),t(m.texture,c.mapping)}else return null}}return c}function s(c){const h=c.target;h.removeEventListener("dispose",s);const f=e.get(h);f!==void 0&&(e.delete(h),f.dispose())}function a(){e=new WeakMap}return{get:r,dispose:a}}const xs=4,Vf=[.125,.215,.35,.446,.526,.582],ka=20,Ay=256,Gl=new d.iKG,Zg=new d.Ilk;let zf=null,Wl=0,$c=0,no=!1;const Yg=new d.Pa4;class Gf{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,r=.1,s=100,a={}){const{size:c=256,position:h=Yg}=a;zf=this._renderer.getRenderTarget(),Wl=this._renderer.getActiveCubeFace(),$c=this._renderer.getActiveMipmapLevel(),no=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(c);const f=this._allocateTargets();return f.depthBuffer=!0,this._sceneToCubeUV(e,r,s,f,h),t>0&&this._blur(f,0,0,t),this._applyPMREM(f),this._cleanup(f),f}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=za(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=Jg(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(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(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(zf,Wl,$c),this._renderer.xr.enabled=no,e.scissorTest=!1,Bs(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===d.fY$||e.mapping===d.vxC?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),zf=this._renderer.getRenderTarget(),Wl=this._renderer.getActiveCubeFace(),$c=this._renderer.getActiveMipmapLevel(),no=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const r=t||this._allocateTargets();return this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,r={magFilter:d.wem,minFilter:d.wem,generateMipmaps:!1,type:d.cLu,format:d.wk1,colorSpace:d.GUF,depthBuffer:!1},s=Va(e,t,r);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Va(e,t,r);const{_lodMax:a}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=os(a)),this._blurMaterial=Nh(a,e,t),this._ggxMaterial=Qg(a,e,t)}return s}_compileMaterial(e){const t=new d.Kj0(new d.u9r,e);this._renderer.compile(t,Gl)}_sceneToCubeUV(e,t,r,s,a){const f=new d.cPb(90,1,t,r),m=[1,-1,1,1,1,1],x=[1,1,1,-1,-1,-1],_=this._renderer,v=_.autoClear,T=_.toneMapping;_.getClearColor(Zg),_.toneMapping=d.uL9,_.autoClear=!1,_.state.buffers.depth.getReversed()&&(_.setRenderTarget(s),_.clearDepth(),_.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new d.Kj0(new d.DvJ,new d.vBJ({name:"PMREM.Background",side:d._Li,depthWrite:!1,depthTest:!1})));const P=this._backgroundBox,C=P.material;let E=!1;const D=e.background;D?D.isColor&&(C.color.copy(D),e.background=null,E=!0):(C.color.copy(Zg),E=!0);for(let F=0;F<6;F++){const W=F%3;W===0?(f.up.set(0,m[F],0),f.position.set(a.x,a.y,a.z),f.lookAt(a.x+x[F],a.y,a.z)):W===1?(f.up.set(0,0,m[F]),f.position.set(a.x,a.y,a.z),f.lookAt(a.x,a.y+x[F],a.z)):(f.up.set(0,m[F],0),f.position.set(a.x,a.y,a.z),f.lookAt(a.x,a.y,a.z+x[F]));const K=this._cubeSize;Bs(s,W*K,F>2?K:0,K,K),_.setRenderTarget(s),E&&_.render(P,f),_.render(e,f)}_.toneMapping=T,_.autoClear=v,e.background=D}_textureToCubeUV(e,t){const r=this._renderer,s=e.mapping===d.fY$||e.mapping===d.vxC;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=za()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=Jg());const a=s?this._cubemapMaterial:this._equirectMaterial,c=this._lodMeshes[0];c.material=a;const h=a.uniforms;h.envMap.value=e;const f=this._cubeSize;Bs(t,0,0,3*f,2*f),r.setRenderTarget(t),r.render(c,Gl)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let a=1;a<s;a++)this._applyGGXFilter(e,a-1,a);t.autoClear=r}_applyGGXFilter(e,t,r){const s=this._renderer,a=this._pingPongRenderTarget,c=this._ggxMaterial,h=this._lodMeshes[r];h.material=c;const f=c.uniforms,m=r/(this._lodMeshes.length-1),x=t/(this._lodMeshes.length-1),_=Math.sqrt(m*m-x*x),v=.05+m*.95,T=_*v,{_lodMax:w}=this,P=this._sizeLods[r],C=3*P*(r>w-xs?r-w+xs:0),E=4*(this._cubeSize-P);f.envMap.value=e.texture,f.roughness.value=T,f.mipInt.value=w-t,Bs(a,C,E,3*P,2*P),s.setRenderTarget(a),s.render(h,Gl),f.envMap.value=a.texture,f.roughness.value=0,f.mipInt.value=w-r,Bs(e,C,E,3*P,2*P),s.setRenderTarget(e),s.render(h,Gl)}_blur(e,t,r,s,a){const c=this._pingPongRenderTarget;this._halfBlur(e,c,t,r,s,"latitudinal",a),this._halfBlur(c,e,r,r,s,"longitudinal",a)}_halfBlur(e,t,r,s,a,c,h){const f=this._renderer,m=this._blurMaterial;c!=="latitudinal"&&c!=="longitudinal"&&(0,d.vUy)("blur direction must be either latitudinal or longitudinal!");const x=3,_=this._lodMeshes[s];_.material=m;const v=m.uniforms,T=this._sizeLods[r]-1,w=isFinite(a)?Math.PI/(2*T):2*Math.PI/(2*ka-1),P=a/w,C=isFinite(a)?1+Math.floor(x*P):ka;C>ka&&(0,d.ZK6)(`sigmaRadians, ${a}, is too large and will clip, as it requested ${C} samples when the maximum is set to ${ka}`);const E=[];let D=0;for(let j=0;j<ka;++j){const oe=j/P,k=Math.exp(-oe*oe/2);E.push(k),j===0?D+=k:j<C&&(D+=2*k)}for(let j=0;j<E.length;j++)E[j]=E[j]/D;v.envMap.value=e.texture,v.samples.value=C,v.weights.value=E,v.latitudinal.value=c==="latitudinal",h&&(v.poleAxis.value=h);const{_lodMax:F}=this;v.dTheta.value=w,v.mipInt.value=F-r;const W=this._sizeLods[s],K=3*W*(s>F-xs?s-F+xs:0),U=4*(this._cubeSize-W);Bs(t,K,U,3*W,2*W),f.setRenderTarget(t),f.render(_,Gl)}}function os(i){const e=[],t=[],r=[];let s=i;const a=i-xs+1+Vf.length;for(let c=0;c<a;c++){const h=Math.pow(2,s);e.push(h);let f=1/h;c>i-xs?f=Vf[c-i+xs-1]:c===0&&(f=0),t.push(f);const m=1/(h-2),x=-m,_=1+m,v=[x,x,_,x,_,_,x,x,_,_,x,_],T=6,w=6,P=3,C=2,E=1,D=new Float32Array(P*w*T),F=new Float32Array(C*w*T),W=new Float32Array(E*w*T);for(let U=0;U<T;U++){const j=U%3*2/3-1,oe=U>2?0:-1,k=[j,oe,0,j+2/3,oe,0,j+2/3,oe+1,0,j,oe,0,j+2/3,oe+1,0,j,oe+1,0];D.set(k,P*w*U),F.set(v,C*w*U);const O=[U,U,U,U,U,U];W.set(O,E*w*U)}const K=new d.u9r;K.setAttribute("position",new d.TlE(D,P)),K.setAttribute("uv",new d.TlE(F,C)),K.setAttribute("faceIndex",new d.TlE(W,E)),r.push(new d.Kj0(K,null)),s>xs&&s--}return{lodMeshes:r,sizeLods:e,sigmas:t}}function Va(i,e,t){const r=new d.dd2(i,e,t);return r.texture.mapping=d.g8_,r.texture.name="PMREM.cubeUv",r.scissorTest=!0,r}function Bs(i,e,t,r,s){i.viewport.set(e,t,r,s),i.scissor.set(e,t,r,s)}function Qg(i,e,t){return new d.jyz({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Ay,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Ph(),fragmentShader:`
precision highp float;
precision highp int;
varying vec3 vOutputDirection;
uniform sampler2D envMap;
uniform float roughness;
uniform float mipInt;
#define ENVMAP_TYPE_CUBE_UV
#include <cube_uv_reflection_fragment>
#define PI 3.14159265359
// Van der Corput radical inverse
float radicalInverse_VdC(uint bits) {
bits = (bits << 16u) | (bits >> 16u);
bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);
bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);
bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);
bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);
return float(bits) * 2.3283064365386963e-10; // / 0x100000000
}
// Hammersley sequence
vec2 hammersley(uint i, uint N) {
return vec2(float(i) / float(N), radicalInverse_VdC(i));
}
// GGX VNDF importance sampling (Eric Heitz 2018)
// "Sampling the GGX Distribution of Visible Normals"
// https://jcgt.org/published/0007/04/01/
vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) {
float alpha = roughness * roughness;
// Section 3.2: Transform view direction to hemisphere configuration
vec3 Vh = normalize(vec3(alpha * V.x, alpha * V.y, V.z));
// Section 4.1: Orthonormal basis
float lensq = Vh.x * Vh.x + Vh.y * Vh.y;
vec3 T1 = lensq > 0.0 ? vec3(-Vh.y, Vh.x, 0.0) / sqrt(lensq) : vec3(1.0, 0.0, 0.0);
vec3 T2 = cross(Vh, T1);
// Section 4.2: Parameterization of projected area
float r = sqrt(Xi.x);
float phi = 2.0 * PI * Xi.y;
float t1 = r * cos(phi);
float t2 = r * sin(phi);
float s = 0.5 * (1.0 + Vh.z);
t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2;
// Section 4.3: Reprojection onto hemisphere
vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * Vh;
// Section 3.4: Transform back to ellipsoid configuration
return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z)));
}
void main() {
vec3 N = normalize(vOutputDirection);
vec3 V = N; // Assume view direction equals normal for pre-filtering
vec3 prefilteredColor = vec3(0.0);
float totalWeight = 0.0;
// For very low roughness, just sample the environment directly
if (roughness < 0.001) {
gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0);
return;
}
// Tangent space basis for VNDF sampling
vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
vec3 tangent = normalize(cross(up, N));
vec3 bitangent = cross(N, tangent);
for(uint i = 0u; i < uint(GGX_SAMPLES); i++) {
vec2 Xi = hammersley(i, uint(GGX_SAMPLES));
// For PMREM, V = N, so in tangent space V is always (0, 0, 1)
vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness);
// Transform H back to world space
vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z);
vec3 L = normalize(2.0 * dot(V, H) * H - V);
float NdotL = max(dot(N, L), 0.0);
if(NdotL > 0.0) {
// Sample environment at fixed mip level
// VNDF importance sampling handles the distribution filtering
vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt);
// Weight by NdotL for the split-sum approximation
// VNDF PDF naturally accounts for the visible microfacet distribution
prefilteredColor += sampleColor * NdotL;
totalWeight += NdotL;
}
}
if (totalWeight > 0.0) {
prefilteredColor = prefilteredColor / totalWeight;
}
gl_FragColor = vec4(prefilteredColor, 1.0);
}
`,blending:d.jFi,depthTest:!1,depthWrite:!1})}function Nh(i,e,t){const r=new Float32Array(ka),s=new d.Pa4(0,1,0);return new d.jyz({name:"SphericalGaussianBlur",defines:{n:ka,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:r},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:Ph(),fragmentShader:`
precision mediump float;
precision mediump int;
varying vec3 vOutputDirection;
uniform sampler2D envMap;
uniform int samples;
uniform float weights[ n ];
uniform bool latitudinal;
uniform float dTheta;
uniform float mipInt;
uniform vec3 poleAxis;
#define ENVMAP_TYPE_CUBE_UV
#include <cube_uv_reflection_fragment>
vec3 getSample( float theta, vec3 axis ) {
float cosTheta = cos( theta );
// Rodrigues' axis-angle rotation
vec3 sampleDirection = vOutputDirection * cosTheta
+ cross( axis, vOutputDirection ) * sin( theta )
+ axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta );
return bilinearCubeUV( envMap, sampleDirection, mipInt );
}
void main() {
vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection );
if ( all( equal( axis, vec3( 0.0 ) ) ) ) {
axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x );
}
axis = normalize( axis );
gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );
gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis );
for ( int i = 1; i < n; i++ ) {
if ( i >= samples ) {
break;
}
float theta = dTheta * float( i );
gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis );
gl_FragColor.rgb += weights[ i ] * getSample( theta, axis );
}
}
`,blending:d.jFi,depthTest:!1,depthWrite:!1})}function Jg(){return new d.jyz({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Ph(),fragmentShader:`
precision mediump float;
precision mediump int;
varying vec3 vOutputDirection;
uniform sampler2D envMap;
#include <common>
void main() {
vec3 outputDirection = normalize( vOutputDirection );
vec2 uv = equirectUv( outputDirection );
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
}
`,blending:d.jFi,depthTest:!1,depthWrite:!1})}function za(){return new d.jyz({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Ph(),fragmentShader:`
precision mediump float;
precision mediump int;
uniform float flipEnvMap;
varying vec3 vOutputDirection;
uniform samplerCube envMap;
void main() {
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
}
`,blending:d.jFi,depthTest:!1,depthWrite:!1})}function Ph(){return`
precision mediump float;
precision mediump int;
attribute float faceIndex;
varying vec3 vOutputDirection;
// RH coordinate system; PMREM face-indexing convention
vec3 getDirection( vec2 uv, float face ) {
uv = 2.0 * uv - 1.0;
vec3 direction = vec3( uv, 1.0 );
if ( face == 0.0 ) {
direction = direction.zyx; // ( 1, v, u ) pos x
} else if ( face == 1.0 ) {
direction = direction.xzy;
direction.xz *= -1.0; // ( -u, 1, -v ) pos y
} else if ( face == 2.0 ) {
direction.x *= -1.0; // ( -u, v, 1 ) pos z
} else if ( face == 3.0 ) {
direction = direction.zyx;
direction.xz *= -1.0; // ( -1, v, -u ) neg x
} else if ( face == 4.0 ) {
direction = direction.xzy;
direction.xy *= -1.0; // ( -u, -1, v ) neg y
} else if ( face == 5.0 ) {
direction.z *= -1.0; // ( u, v, -1 ) neg z
}
return direction;
}
void main() {
vOutputDirection = getDirection( uv, faceIndex );
gl_Position = vec4( position, 1.0 );
}
`}function Ey(i){let e=new WeakMap,t=null;function r(h){if(h&&h.isTexture){const f=h.mapping,m=f===d.dSO||f===d.Bf4,x=f===d.fY$||f===d.vxC;if(m||x){let _=e.get(h);const v=_!==void 0?_.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==v)return t===null&&(t=new Gf(i)),_=m?t.fromEquirectangular(h,_):t.fromCubemap(h,_),_.texture.pmremVersion=h.pmremVersion,e.set(h,_),_.texture;if(_!==void 0)return _.texture;{const T=h.image;return m&&T&&T.height>0||x&&T&&s(T)?(t===null&&(t=new Gf(i)),_=m?t.fromEquirectangular(h):t.fromCubemap(h),_.texture.pmremVersion=h.pmremVersion,e.set(h,_),h.addEventListener("dispose",a),_.texture):null}}}return h}function s(h){let f=0;const m=6;for(let x=0;x<m;x++)h[x]!==void 0&&f++;return f===m}function a(h){const f=h.target;f.removeEventListener("dispose",a);const m=e.get(f);m!==void 0&&(e.delete(f),m.dispose())}function c(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:r,dispose:c}}function Wf(i){const e={};function t(r){if(e[r]!==void 0)return e[r];const s=i.getExtension(r);return e[r]=s,s}return{has:function(r){return t(r)!==null},init:function(){t("EXT_color_buffer_float"),t("WEBGL_clip_cull_distance"),t("OES_texture_float_linear"),t("EXT_color_buffer_half_float"),t("WEBGL_multisampled_render_to_texture"),t("WEBGL_render_shared_exponent")},get:function(r){const s=t(r);return s===null&&(0,d.O4K)("WebGLRenderer: "+r+" extension not supported."),s}}}function Hf(i,e,t,r){const s={},a=new WeakMap;function c(_){const v=_.target;v.index!==null&&e.remove(v.index);for(const w in v.attributes)e.remove(v.attributes[w]);v.removeEventListener("dispose",c),delete s[v.id];const T=a.get(v);T&&(e.remove(T),a.delete(v)),r.releaseStatesOfGeometry(v),v.isInstancedBufferGeometry===!0&&delete v._maxInstanceCount,t.memory.geometries--}function h(_,v){return s[v.id]===!0||(v.addEventListener("dispose",c),s[v.id]=!0,t.memory.geometries++),v}function f(_){const v=_.attributes;for(const T in v)e.update(v[T],i.ARRAY_BUFFER)}function m(_){const v=[],T=_.index,w=_.attributes.position;let P=0;if(T!==null){const D=T.array;P=T.version;for(let F=0,W=D.length;F<W;F+=3){const K=D[F+0],U=D[F+1],j=D[F+2];v.push(K,U,U,j,j,K)}}else if(w!==void 0){const D=w.array;P=w.version;for(let F=0,W=D.length/3-1;F<W;F+=3){const K=F+0,U=F+1,j=F+2;v.push(K,U,U,j,j,K)}}else return;const C=new((0,d.H7L)(v)?d.lCJ:d.qlB)(v,1);C.version=P;const E=a.get(_);E&&e.remove(E),a.set(_,C)}function x(_){const v=a.get(_);if(v){const T=_.index;T!==null&&v.version<T.version&&m(_)}else m(_);return a.get(_)}return{get:h,update:f,getWireframeAttribute:x}}function e0(i,e,t){let r;function s(v){r=v}let a,c;function h(v){a=v.type,c=v.bytesPerElement}function f(v,T){i.drawElements(r,T,a,v*c),t.update(T,r,1)}function m(v,T,w){w!==0&&(i.drawElementsInstanced(r,T,a,v*c,w),t.update(T,r,w))}function x(v,T,w){if(w===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(r,T,0,a,v,0,w);let C=0;for(let E=0;E<w;E++)C+=T[E];t.update(C,r,1)}function _(v,T,w,P){if(w===0)return;const C=e.get("WEBGL_multi_draw");if(C===null)for(let E=0;E<v.length;E++)m(v[E]/c,T[E],P[E]);else{C.multiDrawElementsInstancedWEBGL(r,T,0,a,v,0,P,0,w);let E=0;for(let D=0;D<w;D++)E+=T[D]*P[D];t.update(E,r,1)}}this.setMode=s,this.setIndex=h,this.render=f,this.renderInstances=m,this.renderMultiDraw=x,this.renderMultiDrawInstances=_}function Lh(i){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function r(a,c,h){switch(t.calls++,c){case i.TRIANGLES:t.triangles+=h*(a/3);break;case i.LINES:t.lines+=h*(a/2);break;case i.LINE_STRIP:t.lines+=h*(a-1);break;case i.LINE_LOOP:t.lines+=h*a;break;case i.POINTS:t.points+=h*a;break;default:(0,d.vUy)("WebGLInfo: Unknown draw mode:",c);break}}function s(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:s,update:r}}function Ir(i,e,t){const r=new WeakMap,s=new d.Ltg;function a(c,h,f){const m=c.morphTargetInfluences,x=h.morphAttributes.position||h.morphAttributes.normal||h.morphAttributes.color,_=x!==void 0?x.length:0;let v=r.get(h);if(v===void 0||v.count!==_){let k=function(){j.dispose(),r.delete(h),h.removeEventListener("dispose",k)};v!==void 0&&v.texture.dispose();const T=h.morphAttributes.position!==void 0,w=h.morphAttributes.normal!==void 0,P=h.morphAttributes.color!==void 0,C=h.morphAttributes.position||[],E=h.morphAttributes.normal||[],D=h.morphAttributes.color||[];let F=0;T===!0&&(F=1),w===!0&&(F=2),P===!0&&(F=3);let W=h.attributes.position.count*F,K=1;W>e.maxTextureSize&&(K=Math.ceil(W/e.maxTextureSize),W=e.maxTextureSize);const U=new Float32Array(W*K*4*_),j=new d.p3g(U,W,K,_);j.type=d.VzW,j.needsUpdate=!0;const oe=F*4;for(let O=0;O<_;O++){const le=C[O],be=E[O],Ee=D[O],Pe=W*K*4*O;for(let He=0;He<le.count;He++){const Be=He*oe;T===!0&&(s.fromBufferAttribute(le,He),U[Pe+Be+0]=s.x,U[Pe+Be+1]=s.y,U[Pe+Be+2]=s.z,U[Pe+Be+3]=0),w===!0&&(s.fromBufferAttribute(be,He),U[Pe+Be+4]=s.x,U[Pe+Be+5]=s.y,U[Pe+Be+6]=s.z,U[Pe+Be+7]=0),P===!0&&(s.fromBufferAttribute(Ee,He),U[Pe+Be+8]=s.x,U[Pe+Be+9]=s.y,U[Pe+Be+10]=s.z,U[Pe+Be+11]=Ee.itemSize===4?s.w:1)}}v={count:_,texture:j,size:new d.FM8(W,K)},r.set(h,v),h.addEventListener("dispose",k)}if(c.isInstancedMesh===!0&&c.morphTexture!==null)f.getUniforms().setValue(i,"morphTexture",c.morphTexture,t);else{let T=0;for(let P=0;P<m.length;P++)T+=m[P];const w=h.morphTargetsRelative?1:1-T;f.getUniforms().setValue(i,"morphTargetBaseInfluence",w),f.getUniforms().setValue(i,"morphTargetInfluences",m)}f.getUniforms().setValue(i,"morphTargetsTexture",v.texture,t),f.getUniforms().setValue(i,"morphTargetsTextureSize",v.size)}return{update:a}}function Ga(i,e,t,r){let s=new WeakMap;function a(f){const m=r.render.frame,x=f.geometry,_=e.get(f,x);if(s.get(_)!==m&&(e.update(_),s.set(_,m)),f.isInstancedMesh&&(f.hasEventListener("dispose",h)===!1&&f.addEventListener("dispose",h),s.get(f)!==m&&(t.update(f.instanceMatrix,i.ARRAY_BUFFER),f.instanceColor!==null&&t.update(f.instanceColor,i.ARRAY_BUFFER),s.set(f,m))),f.isSkinnedMesh){const v=f.skeleton;s.get(v)!==m&&(v.update(),s.set(v,m))}return _}function c(){s=new WeakMap}function h(f){const m=f.target;m.removeEventListener("dispose",h),t.remove(m.instanceMatrix),m.instanceColor!==null&&t.remove(m.instanceColor)}return{update:a,dispose:c}}const Ih=new d.xEZ,Wa=new d.$YQ(1,1),jc=new d.p3g,Ha=new d.JUT,$a=new d.BtG,ja=[],Xc=[],$f=new Float32Array(16),Hl=new Float32Array(9),qc=new Float32Array(4);function Fo(i,e,t){const r=i[0];if(r<=0||r>0)return i;const s=e*t;let a=ja[s];if(a===void 0&&(a=new Float32Array(s),ja[s]=a),e!==0){r.toArray(a,0);for(let c=1,h=0;c!==e;++c)h+=t,i[c].toArray(a,h)}return a}function Zi(i,e){if(i.length!==e.length)return!1;for(let t=0,r=i.length;t<r;t++)if(i[t]!==e[t])return!1;return!0}function $i(i,e){for(let t=0,r=e.length;t<r;t++)i[t]=e[t]}function $l(i,e){let t=Xc[e];t===void 0&&(t=new Int32Array(e),Xc[e]=t);for(let r=0;r!==e;++r)t[r]=i.allocateTextureUnit();return t}function t0(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function Dh(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2f(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Zi(t,e))return;i.uniform2fv(this.addr,e),$i(t,e)}}function Uh(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3f(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else if(e.r!==void 0)(t[0]!==e.r||t[1]!==e.g||t[2]!==e.b)&&(i.uniform3f(this.addr,e.r,e.g,e.b),t[0]=e.r,t[1]=e.g,t[2]=e.b);else{if(Zi(t,e))return;i.uniform3fv(this.addr,e),$i(t,e)}}function n0(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4f(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Zi(t,e))return;i.uniform4fv(this.addr,e),$i(t,e)}}function Cy(i,e){const t=this.cache,r=e.elements;if(r===void 0){if(Zi(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),$i(t,e)}else{if(Zi(t,r))return;qc.set(r),i.uniformMatrix2fv(this.addr,!1,qc),$i(t,r)}}function i0(i,e){const t=this.cache,r=e.elements;if(r===void 0){if(Zi(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),$i(t,e)}else{if(Zi(t,r))return;Hl.set(r),i.uniformMatrix3fv(this.addr,!1,Hl),$i(t,r)}}function r0(i,e){const t=this.cache,r=e.elements;if(r===void 0){if(Zi(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),$i(t,e)}else{if(Zi(t,r))return;$f.set(r),i.uniformMatrix4fv(this.addr,!1,$f),$i(t,r)}}function s0(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function Ry(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2i(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Zi(t,e))return;i.uniform2iv(this.addr,e),$i(t,e)}}function o0(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3i(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Zi(t,e))return;i.uniform3iv(this.addr,e),$i(t,e)}}function Fh(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4i(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Zi(t,e))return;i.uniform4iv(this.addr,e),$i(t,e)}}function jf(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function a0(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y)&&(i.uniform2ui(this.addr,e.x,e.y),t[0]=e.x,t[1]=e.y);else{if(Zi(t,e))return;i.uniform2uiv(this.addr,e),$i(t,e)}}function Xf(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z)&&(i.uniform3ui(this.addr,e.x,e.y,e.z),t[0]=e.x,t[1]=e.y,t[2]=e.z);else{if(Zi(t,e))return;i.uniform3uiv(this.addr,e),$i(t,e)}}function Ny(i,e){const t=this.cache;if(e.x!==void 0)(t[0]!==e.x||t[1]!==e.y||t[2]!==e.z||t[3]!==e.w)&&(i.uniform4ui(this.addr,e.x,e.y,e.z,e.w),t[0]=e.x,t[1]=e.y,t[2]=e.z,t[3]=e.w);else{if(Zi(t,e))return;i.uniform4uiv(this.addr,e),$i(t,e)}}function c0(i,e,t){const r=this.cache,s=t.allocateTextureUnit();r[0]!==s&&(i.uniform1i(this.addr,s),r[0]=s);let a;this.type===i.SAMPLER_2D_SHADOW?(Wa.compareFunction=d.M$G,a=Wa):a=Ih,t.setTexture2D(e||a,s)}function io(i,e,t){const r=this.cache,s=t.allocateTextureUnit();r[0]!==s&&(i.uniform1i(this.addr,s),r[0]=s),t.setTexture3D(e||Ha,s)}function l0(i,e,t){const r=this.cache,s=t.allocateTextureUnit();r[0]!==s&&(i.uniform1i(this.addr,s),r[0]=s),t.setTextureCube(e||$a,s)}function Py(i,e,t){const r=this.cache,s=t.allocateTextureUnit();r[0]!==s&&(i.uniform1i(this.addr,s),r[0]=s),t.setTexture2DArray(e||jc,s)}function qf(i){switch(i){case 5126:return t0;case 35664:return Dh;case 35665:return Uh;case 35666:return n0;case 35674:return Cy;case 35675:return i0;case 35676:return r0;case 5124:case 35670:return s0;case 35667:case 35671:return Ry;case 35668:case 35672:return o0;case 35669:case 35673:return Fh;case 5125:return jf;case 36294:return a0;case 36295:return Xf;case 36296:return Ny;case 35678:case 36198:case 36298:case 36306:case 35682:return c0;case 35679:case 36299:case 36307:return io;case 35680:case 36300:case 36308:case 36293:return l0;case 36289:case 36303:case 36311:case 36292:return Py}}function Kc(i,e){i.uniform1fv(this.addr,e)}function Zc(i,e){const t=Fo(e,this.size,2);i.uniform2fv(this.addr,t)}function u0(i,e){const t=Fo(e,this.size,3);i.uniform3fv(this.addr,t)}function Bh(i,e){const t=Fo(e,this.size,4);i.uniform4fv(this.addr,t)}function h0(i,e){const t=Fo(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function Ly(i,e){const t=Fo(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function jl(i,e){const t=Fo(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function Xl(i,e){i.uniform1iv(this.addr,e)}function Iy(i,e){i.uniform2iv(this.addr,e)}function Kf(i,e){i.uniform3iv(this.addr,e)}function Dy(i,e){i.uniform4iv(this.addr,e)}function Uy(i,e){i.uniform1uiv(this.addr,e)}function Xa(i,e){i.uniform2uiv(this.addr,e)}function qa(i,e){i.uniform3uiv(this.addr,e)}function Fy(i,e){i.uniform4uiv(this.addr,e)}function Oh(i,e,t){const r=this.cache,s=e.length,a=$l(t,s);Zi(r,a)||(i.uniform1iv(this.addr,a),$i(r,a));for(let c=0;c!==s;++c)t.setTexture2D(e[c]||Ih,a[c])}function kh(i,e,t){const r=this.cache,s=e.length,a=$l(t,s);Zi(r,a)||(i.uniform1iv(this.addr,a),$i(r,a));for(let c=0;c!==s;++c)t.setTexture3D(e[c]||Ha,a[c])}function ro(i,e,t){const r=this.cache,s=e.length,a=$l(t,s);Zi(r,a)||(i.uniform1iv(this.addr,a),$i(r,a));for(let c=0;c!==s;++c)t.setTextureCube(e[c]||$a,a[c])}function so(i,e,t){const r=this.cache,s=e.length,a=$l(t,s);Zi(r,a)||(i.uniform1iv(this.addr,a),$i(r,a));for(let c=0;c!==s;++c)t.setTexture2DArray(e[c]||jc,a[c])}function Vh(i){switch(i){case 5126:return Kc;case 35664:return Zc;case 35665:return u0;case 35666:return Bh;case 35674:return h0;case 35675:return Ly;case 35676:return jl;case 5124:case 35670:return Xl;case 35667:case 35671:return Iy;case 35668:case 35672:return Kf;case 35669:case 35673:return Dy;case 5125:return Uy;case 36294:return Xa;case 36295:return qa;case 36296:return Fy;case 35678:case 36198:case 36298:case 36306:case 35682:return Oh;case 35679:case 36299:case 36307:return kh;case 35680:case 36300:case 36308:case 36293:return ro;case 36289:case 36303:case 36311:case 36292:return so}}class Zf{constructor(e,t,r){this.id=e,this.addr=r,this.cache=[],this.type=t.type,this.setValue=qf(t.type)}}class By{constructor(e,t,r){this.id=e,this.addr=r,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=Vh(t.type)}}class Oy{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,r){const s=this.seq;for(let a=0,c=s.length;a!==c;++a){const h=s[a];h.setValue(e,t[h.id],r)}}}const Yf=/(\w+)(\])?(\[|\.)?/g;function Dr(i,e){i.seq.push(e),i.map[e.id]=e}function ky(i,e,t){const r=i.name,s=r.length;for(Yf.lastIndex=0;;){const a=Yf.exec(r),c=Yf.lastIndex;let h=a[1];const f=a[2]==="]",m=a[3];if(f&&(h=h|0),m===void 0||m==="["&&c+2===s){Dr(t,m===void 0?new Zf(h,i,e):new By(h,i,e));break}else{let _=t.map[h];_===void 0&&(_=new Oy(h),Dr(t,_)),t=_}}}class ql{constructor(e,t){this.seq=[],this.map={};const r=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let s=0;s<r;++s){const a=e.getActiveUniform(t,s),c=e.getUniformLocation(t,a.name);ky(a,c,this)}}setValue(e,t,r,s){const a=this.map[t];a!==void 0&&a.setValue(e,r,s)}setOptional(e,t,r){const s=t[r];s!==void 0&&this.setValue(e,r,s)}static upload(e,t,r,s){for(let a=0,c=t.length;a!==c;++a){const h=t[a],f=r[h.id];f.needsUpdate!==!1&&h.setValue(e,f.value,s)}}static seqWithValue(e,t){const r=[];for(let s=0,a=e.length;s!==a;++s){const c=e[s];c.id in t&&r.push(c)}return r}}function d0(i,e,t){const r=i.createShader(e);return i.shaderSource(r,t),i.compileShader(r),r}const zh=37297;let Ka=0;function Kl(i,e){const t=i.split(`
`),r=[],s=Math.max(e-6,0),a=Math.min(e+6,t.length);for(let c=s;c<a;c++){const h=c+1;r.push(`${h===e?">":" "} ${h}: ${t[c]}`)}return r.join(`
`)}const Qf=new d.Vkp;function Vy(i){d.epp._getMatrix(Qf,d.epp.workingColorSpace,i);const e=`mat3( ${Qf.elements.map(t=>t.toFixed(4))} )`;switch(d.epp.getTransfer(i)){case d.l6D:return[e,"LinearTransferOETF"];case d.j17:return[e,"sRGBTransferOETF"];default:return(0,d.ZK6)("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function Gh(i,e,t){const r=i.getShaderParameter(e,i.COMPILE_STATUS),a=(i.getShaderInfoLog(e)||"").trim();if(r&&a==="")return"";const c=/ERROR: 0:(\d+)/.exec(a);if(c){const h=parseInt(c[1]);return t.toUpperCase()+`
`+a+`
`+Kl(i.getShaderSource(e),h)}else return a}function Ar(i,e){const t=Vy(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
`)}function Wh(i,e){let t;switch(e){case d.EoG:t="Linear";break;case d.CdI:t="Reinhard";break;case d.YGz:t="Cineon";break;case d.LY2:t="ACESFilmic";break;case d.Bgp:t="AgX";break;case d.ORg:t="Neutral";break;case d.dZ3:t="Custom";break;default:(0,d.ZK6)("WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Hh=new d.Pa4;function Za(){d.epp.getLuminanceCoefficients(Hh);const i=Hh.x.toFixed(4),e=Hh.y.toFixed(4),t=Hh.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
`)}function zy(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ca).join(`
`)}function Ur(i){const e=[];for(const t in i){const r=i[t];r!==!1&&e.push("#define "+t+" "+r)}return e.join(`
`)}function $h(i,e){const t={},r=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let s=0;s<r;s++){const a=i.getActiveAttrib(e,s),c=a.name;let h=1;a.type===i.FLOAT_MAT2&&(h=2),a.type===i.FLOAT_MAT3&&(h=3),a.type===i.FLOAT_MAT4&&(h=4),t[c]={type:a.type,location:i.getAttribLocation(e,c),locationSize:h}}return t}function ca(i){return i!==""}function Jf(i,e){const t=e.numSpotLightShadows+e.numSpotLightMaps-e.numSpotLightShadowsWithMaps;return i.replace(/NUM_DIR_LIGHTS/g,e.numDirLights).replace(/NUM_SPOT_LIGHTS/g,e.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,e.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,t).replace(/NUM_RECT_AREA_LIGHTS/g,e.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,e.numPointLights).replace(/NUM_HEMI_LIGHTS/g,e.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,e.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,e.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,e.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,e.numPointLightShadows)}function Yc(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const jh=/^[ \t]*#include +<([\w\d./]+)>/gm;function Zl(i){return i.replace(jh,Yl)}const f0=new Map;function Yl(i,e){let t=kn[e];if(t===void 0){const r=f0.get(e);if(r!==void 0)t=kn[r],(0,d.ZK6)('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,r);else throw new Error("Can not resolve #include <"+e+">")}return Zl(t)}const Xh=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function ep(i){return i.replace(Xh,p0)}function p0(i,e,t,r){let s="";for(let a=parseInt(e);a<parseInt(t);a++)s+=r.replace(/\[\s*i\s*\]/g,"[ "+a+" ]").replace(/UNROLLED_LOOP_INDEX/g,a);return s}function tp(i){let e=`precision ${i.precision} float;
precision ${i.precision} int;
precision ${i.precision} sampler2D;
precision ${i.precision} samplerCube;
precision ${i.precision} sampler3D;
precision ${i.precision} sampler2DArray;
precision ${i.precision} sampler2DShadow;
precision ${i.precision} samplerCubeShadow;
precision ${i.precision} sampler2DArrayShadow;
precision ${i.precision} isampler2D;
precision ${i.precision} isampler3D;
precision ${i.precision} isamplerCube;
precision ${i.precision} isampler2DArray;
precision ${i.precision} usampler2D;
precision ${i.precision} usampler3D;
precision ${i.precision} usamplerCube;
precision ${i.precision} usampler2DArray;
`;return i.precision==="highp"?e+=`
#define HIGH_PRECISION`:i.precision==="mediump"?e+=`
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
#define LOW_PRECISION`),e}function Gy(i){let e="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===d._iA?e="SHADOWMAP_TYPE_PCF":i.shadowMapType===d.ntZ?e="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===d.dwk&&(e="SHADOWMAP_TYPE_VSM"),e}function np(i){let e="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case d.fY$:case d.vxC:e="ENVMAP_TYPE_CUBE";break;case d.g8_:e="ENVMAP_TYPE_CUBE_UV";break}return e}function m0(i){let e="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case d.vxC:e="ENVMAP_MODE_REFRACTION";break}return e}function ip(i){let e="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case d.Ns1:e="ENVMAP_BLENDING_MULTIPLY";break;case d.qhX:e="ENVMAP_BLENDING_MIX";break;case d.NDo:e="ENVMAP_BLENDING_ADD";break}return e}function qh(i){const e=i.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,r=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:r,maxMip:t}}function Kh(i,e,t,r){const s=i.getContext(),a=t.defines;let c=t.vertexShader,h=t.fragmentShader;const f=Gy(t),m=np(t),x=m0(t),_=ip(t),v=qh(t),T=zy(t),w=Ur(a),P=s.createProgram();let C,E,D=t.glslVersion?"#version "+t.glslVersion+`
`:"";t.isRawShaderMaterial?(C=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,w].filter(ca).join(`
`),C.length>0&&(C+=`
`),E=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,w].filter(ca).join(`
`),E.length>0&&(E+=`
`)):(C=[tp(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,w,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+x:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+f:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
`].filter(ca).join(`
`),E=[tp(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,w,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+m:"",t.envMap?"#define "+x:"",t.envMap?"#define "+_:"",v?"#define CUBEUV_TEXEL_WIDTH "+v.texelWidth:"",v?"#define CUBEUV_TEXEL_HEIGHT "+v.texelHeight:"",v?"#define CUBEUV_MAX_MIP "+v.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor||t.batchingColor?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+f:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==d.uL9?"#define TONE_MAPPING":"",t.toneMapping!==d.uL9?kn.tonemapping_pars_fragment:"",t.toneMapping!==d.uL9?Wh("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",kn.colorspace_pars_fragment,Ar("linearToOutputTexel",t.outputColorSpace),Za(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
`].filter(ca).join(`
`)),c=Zl(c),c=Jf(c,t),c=Yc(c,t),h=Zl(h),h=Jf(h,t),h=Yc(h,t),c=ep(c),h=ep(h),t.isRawShaderMaterial!==!0&&(D=`#version 300 es
`,C=[T,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+C,E=["#define varying in",t.glslVersion===d.LSk?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===d.LSk?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
`)+`
`+E);const F=D+C+c,W=D+E+h,K=d0(s,s.VERTEX_SHADER,F),U=d0(s,s.FRAGMENT_SHADER,W);s.attachShader(P,K),s.attachShader(P,U),t.index0AttributeName!==void 0?s.bindAttribLocation(P,0,t.index0AttributeName):t.morphTargets===!0&&s.bindAttribLocation(P,0,"position"),s.linkProgram(P);function j(le){if(i.debug.checkShaderErrors){const be=s.getProgramInfoLog(P)||"",Ee=s.getShaderInfoLog(K)||"",Pe=s.getShaderInfoLog(U)||"",He=be.trim(),Be=Ee.trim(),ft=Pe.trim();let $e=!0,Tt=!0;if(s.getProgramParameter(P,s.LINK_STATUS)===!1)if($e=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,P,K,U);else{const Pt=Gh(s,K,"vertex"),Ye=Gh(s,U,"fragment");(0,d.vUy)("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(P,s.VALIDATE_STATUS)+`
Material Name: `+le.name+`
Material Type: `+le.type+`
Program Info Log: `+He+`
`+Pt+`
`+Ye)}else He!==""?(0,d.ZK6)("WebGLProgram: Program Info Log:",He):(Be===""||ft==="")&&(Tt=!1);Tt&&(le.diagnostics={runnable:$e,programLog:He,vertexShader:{log:Be,prefix:C},fragmentShader:{log:ft,prefix:E}})}s.deleteShader(K),s.deleteShader(U),oe=new ql(s,P),k=$h(s,P)}let oe;this.getUniforms=function(){return oe===void 0&&j(this),oe};let k;this.getAttributes=function(){return k===void 0&&j(this),k};let O=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return O===!1&&(O=s.getProgramParameter(P,zh)),O},this.destroy=function(){r.releaseStatesOfProgram(this),s.deleteProgram(P),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=Ka++,this.cacheKey=e,this.usedTimes=1,this.program=P,this.vertexShader=K,this.fragmentShader=U,this}let Wy=0;class g0{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,r=e.fragmentShader,s=this._getShaderStage(t),a=this._getShaderStage(r),c=this._getShaderCacheForMaterial(e);return c.has(s)===!1&&(c.add(s),s.usedTimes++),c.has(a)===!1&&(c.add(a),a.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const r of t)r.usedTimes--,r.usedTimes===0&&this.shaderCache.delete(r.code);return this.materialCache.delete(e),this}getVertexShaderID(e){return this._getShaderStage(e.vertexShader).id}getFragmentShaderID(e){return this._getShaderStage(e.fragmentShader).id}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let r=t.get(e);return r===void 0&&(r=new Set,t.set(e,r)),r}_getShaderStage(e){const t=this.shaderCache;let r=t.get(e);return r===void 0&&(r=new gT(e),t.set(e,r)),r}}class gT{constructor(e){this.id=Wy++,this.code=e,this.usedTimes=0}}function xT(i,e,t,r,s,a,c){const h=new d.S9g,f=new g0,m=new Set,x=[],_=s.logarithmicDepthBuffer,v=s.vertexTextures;let T=s.precision;const w={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function P(k){return m.add(k),k===0?"uv":`uv${k}`}function C(k,O,le,be,Ee){const Pe=be.fog,He=Ee.geometry,Be=k.isMeshStandardMaterial?be.environment:null,ft=(k.isMeshStandardMaterial?t:e).get(k.envMap||Be),$e=ft&&ft.mapping===d.g8_?ft.image.height:null,Tt=w[k.type];k.precision!==null&&(T=s.getMaxPrecision(k.precision),T!==k.precision&&(0,d.ZK6)("WebGLProgram.getParameters:",k.precision,"not supported, using",T,"instead."));const Pt=He.morphAttributes.position||He.morphAttributes.normal||He.morphAttributes.color,Ye=Pt!==void 0?Pt.length:0;let yt=0;He.morphAttributes.position!==void 0&&(yt=1),He.morphAttributes.normal!==void 0&&(yt=2),He.morphAttributes.color!==void 0&&(yt=3);let Ot,Mn,tt,ve;if(Tt){const Si=ss[Tt];Ot=Si.vertexShader,Mn=Si.fragmentShader}else Ot=k.vertexShader,Mn=k.fragmentShader,f.update(k),tt=f.getVertexShaderID(k),ve=f.getFragmentShaderID(k);const Ne=i.getRenderTarget(),gt=i.state.buffers.depth.getReversed(),qt=Ee.isInstancedMesh===!0,Nt=Ee.isBatchedMesh===!0,en=!!k.map,vi=!!k.matcap,Dn=!!ft,si=!!k.aoMap,me=!!k.lightMap,Vn=!!k.bumpMap,Un=!!k.normalMap,li=!!k.displacementMap,Jt=!!k.emissiveMap,Xi=!!k.metalnessMap,yn=!!k.roughnessMap,zn=k.anisotropy>0,J=k.clearcoat>0,V=k.dispersion>0,Ce=k.iridescence>0,et=k.sheen>0,ct=k.transmission>0,je=zn&&!!k.anisotropyMap,ln=J&&!!k.clearcoatMap,Lt=J&&!!k.clearcoatNormalMap,vn=J&&!!k.clearcoatRoughnessMap,rn=Ce&&!!k.iridescenceMap,ht=Ce&&!!k.iridescenceThicknessMap,Mt=et&&!!k.sheenColorMap,En=et&&!!k.sheenRoughnessMap,Tn=!!k.specularMap,zt=!!k.specularColorMap,Pn=!!k.specularIntensityMap,xe=ct&&!!k.transmissionMap,It=ct&&!!k.thicknessMap,Et=!!k.gradientMap,Ct=!!k.alphaMap,xt=k.alphaTest>0,it=!!k.alphaHash,Yt=!!k.extensions;let On=d.uL9;k.toneMapped&&(Ne===null||Ne.isXRRenderTarget===!0)&&(On=i.toneMapping);const Bi={shaderID:Tt,shaderType:k.type,shaderName:k.name,vertexShader:Ot,fragmentShader:Mn,defines:k.defines,customVertexShaderID:tt,customFragmentShaderID:ve,isRawShaderMaterial:k.isRawShaderMaterial===!0,glslVersion:k.glslVersion,precision:T,batching:Nt,batchingColor:Nt&&Ee._colorsTexture!==null,instancing:qt,instancingColor:qt&&Ee.instanceColor!==null,instancingMorph:qt&&Ee.morphTexture!==null,supportsVertexTextures:v,outputColorSpace:Ne===null?i.outputColorSpace:Ne.isXRRenderTarget===!0?Ne.texture.colorSpace:d.GUF,alphaToCoverage:!!k.alphaToCoverage,map:en,matcap:vi,envMap:Dn,envMapMode:Dn&&ft.mapping,envMapCubeUVHeight:$e,aoMap:si,lightMap:me,bumpMap:Vn,normalMap:Un,displacementMap:v&&li,emissiveMap:Jt,normalMapObjectSpace:Un&&k.normalMapType===d.PA7,normalMapTangentSpace:Un&&k.normalMapType===d.IOt,metalnessMap:Xi,roughnessMap:yn,anisotropy:zn,anisotropyMap:je,clearcoat:J,clearcoatMap:ln,clearcoatNormalMap:Lt,clearcoatRoughnessMap:vn,dispersion:V,iridescence:Ce,iridescenceMap:rn,iridescenceThicknessMap:ht,sheen:et,sheenColorMap:Mt,sheenRoughnessMap:En,specularMap:Tn,specularColorMap:zt,specularIntensityMap:Pn,transmission:ct,transmissionMap:xe,thicknessMap:It,gradientMap:Et,opaque:k.transparent===!1&&k.blending===d.bdR&&k.alphaToCoverage===!1,alphaMap:Ct,alphaTest:xt,alphaHash:it,combine:k.combine,mapUv:en&&P(k.map.channel),aoMapUv:si&&P(k.aoMap.channel),lightMapUv:me&&P(k.lightMap.channel),bumpMapUv:Vn&&P(k.bumpMap.channel),normalMapUv:Un&&P(k.normalMap.channel),displacementMapUv:li&&P(k.displacementMap.channel),emissiveMapUv:Jt&&P(k.emissiveMap.channel),metalnessMapUv:Xi&&P(k.metalnessMap.channel),roughnessMapUv:yn&&P(k.roughnessMap.channel),anisotropyMapUv:je&&P(k.anisotropyMap.channel),clearcoatMapUv:ln&&P(k.clearcoatMap.channel),clearcoatNormalMapUv:Lt&&P(k.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:vn&&P(k.clearcoatRoughnessMap.channel),iridescenceMapUv:rn&&P(k.iridescenceMap.channel),iridescenceThicknessMapUv:ht&&P(k.iridescenceThicknessMap.channel),sheenColorMapUv:Mt&&P(k.sheenColorMap.channel),sheenRoughnessMapUv:En&&P(k.sheenRoughnessMap.channel),specularMapUv:Tn&&P(k.specularMap.channel),specularColorMapUv:zt&&P(k.specularColorMap.channel),specularIntensityMapUv:Pn&&P(k.specularIntensityMap.channel),transmissionMapUv:xe&&P(k.transmissionMap.channel),thicknessMapUv:It&&P(k.thicknessMap.channel),alphaMapUv:Ct&&P(k.alphaMap.channel),vertexTangents:!!He.attributes.tangent&&(Un||zn),vertexColors:k.vertexColors,vertexAlphas:k.vertexColors===!0&&!!He.attributes.color&&He.attributes.color.itemSize===4,pointsUvs:Ee.isPoints===!0&&!!He.attributes.uv&&(en||Ct),fog:!!Pe,useFog:k.fog===!0,fogExp2:!!Pe&&Pe.isFogExp2,flatShading:k.flatShading===!0&&k.wireframe===!1,sizeAttenuation:k.sizeAttenuation===!0,logarithmicDepthBuffer:_,reversedDepthBuffer:gt,skinning:Ee.isSkinnedMesh===!0,morphTargets:He.morphAttributes.position!==void 0,morphNormals:He.morphAttributes.normal!==void 0,morphColors:He.morphAttributes.color!==void 0,morphTargetsCount:Ye,morphTextureStride:yt,numDirLights:O.directional.length,numPointLights:O.point.length,numSpotLights:O.spot.length,numSpotLightMaps:O.spotLightMap.length,numRectAreaLights:O.rectArea.length,numHemiLights:O.hemi.length,numDirLightShadows:O.directionalShadowMap.length,numPointLightShadows:O.pointShadowMap.length,numSpotLightShadows:O.spotShadowMap.length,numSpotLightShadowsWithMaps:O.numSpotLightShadowsWithMaps,numLightProbes:O.numLightProbes,numClippingPlanes:c.numPlanes,numClipIntersection:c.numIntersection,dithering:k.dithering,shadowMapEnabled:i.shadowMap.enabled&&le.length>0,shadowMapType:i.shadowMap.type,toneMapping:On,decodeVideoTexture:en&&k.map.isVideoTexture===!0&&d.epp.getTransfer(k.map.colorSpace)===d.j17,decodeVideoTextureEmissive:Jt&&k.emissiveMap.isVideoTexture===!0&&d.epp.getTransfer(k.emissiveMap.colorSpace)===d.j17,premultipliedAlpha:k.premultipliedAlpha,doubleSided:k.side===d.ehD,flipSided:k.side===d._Li,useDepthPacking:k.depthPacking>=0,depthPacking:k.depthPacking||0,index0AttributeName:k.index0AttributeName,extensionClipCullDistance:Yt&&k.extensions.clipCullDistance===!0&&r.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Yt&&k.extensions.multiDraw===!0||Nt)&&r.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:r.has("KHR_parallel_shader_compile"),customProgramCacheKey:k.customProgramCacheKey()};return Bi.vertexUv1s=m.has(1),Bi.vertexUv2s=m.has(2),Bi.vertexUv3s=m.has(3),m.clear(),Bi}function E(k){const O=[];if(k.shaderID?O.push(k.shaderID):(O.push(k.customVertexShaderID),O.push(k.customFragmentShaderID)),k.defines!==void 0)for(const le in k.defines)O.push(le),O.push(k.defines[le]);return k.isRawShaderMaterial===!1&&(D(O,k),F(O,k),O.push(i.outputColorSpace)),O.push(k.customProgramCacheKey),O.join()}function D(k,O){k.push(O.precision),k.push(O.outputColorSpace),k.push(O.envMapMode),k.push(O.envMapCubeUVHeight),k.push(O.mapUv),k.push(O.alphaMapUv),k.push(O.lightMapUv),k.push(O.aoMapUv),k.push(O.bumpMapUv),k.push(O.normalMapUv),k.push(O.displacementMapUv),k.push(O.emissiveMapUv),k.push(O.metalnessMapUv),k.push(O.roughnessMapUv),k.push(O.anisotropyMapUv),k.push(O.clearcoatMapUv),k.push(O.clearcoatNormalMapUv),k.push(O.clearcoatRoughnessMapUv),k.push(O.iridescenceMapUv),k.push(O.iridescenceThicknessMapUv),k.push(O.sheenColorMapUv),k.push(O.sheenRoughnessMapUv),k.push(O.specularMapUv),k.push(O.specularColorMapUv),k.push(O.specularIntensityMapUv),k.push(O.transmissionMapUv),k.push(O.thicknessMapUv),k.push(O.combine),k.push(O.fogExp2),k.push(O.sizeAttenuation),k.push(O.morphTargetsCount),k.push(O.morphAttributeCount),k.push(O.numDirLights),k.push(O.numPointLights),k.push(O.numSpotLights),k.push(O.numSpotLightMaps),k.push(O.numHemiLights),k.push(O.numRectAreaLights),k.push(O.numDirLightShadows),k.push(O.numPointLightShadows),k.push(O.numSpotLightShadows),k.push(O.numSpotLightShadowsWithMaps),k.push(O.numLightProbes),k.push(O.shadowMapType),k.push(O.toneMapping),k.push(O.numClippingPlanes),k.push(O.numClipIntersection),k.push(O.depthPacking)}function F(k,O){h.disableAll(),O.supportsVertexTextures&&h.enable(0),O.instancing&&h.enable(1),O.instancingColor&&h.enable(2),O.instancingMorph&&h.enable(3),O.matcap&&h.enable(4),O.envMap&&h.enable(5),O.normalMapObjectSpace&&h.enable(6),O.normalMapTangentSpace&&h.enable(7),O.clearcoat&&h.enable(8),O.iridescence&&h.enable(9),O.alphaTest&&h.enable(10),O.vertexColors&&h.enable(11),O.vertexAlphas&&h.enable(12),O.vertexUv1s&&h.enable(13),O.vertexUv2s&&h.enable(14),O.vertexUv3s&&h.enable(15),O.vertexTangents&&h.enable(16),O.anisotropy&&h.enable(17),O.alphaHash&&h.enable(18),O.batching&&h.enable(19),O.dispersion&&h.enable(20),O.batchingColor&&h.enable(21),O.gradientMap&&h.enable(22),k.push(h.mask),h.disableAll(),O.fog&&h.enable(0),O.useFog&&h.enable(1),O.flatShading&&h.enable(2),O.logarithmicDepthBuffer&&h.enable(3),O.reversedDepthBuffer&&h.enable(4),O.skinning&&h.enable(5),O.morphTargets&&h.enable(6),O.morphNormals&&h.enable(7),O.morphColors&&h.enable(8),O.premultipliedAlpha&&h.enable(9),O.shadowMapEnabled&&h.enable(10),O.doubleSided&&h.enable(11),O.flipSided&&h.enable(12),O.useDepthPacking&&h.enable(13),O.dithering&&h.enable(14),O.transmission&&h.enable(15),O.sheen&&h.enable(16),O.opaque&&h.enable(17),O.pointsUvs&&h.enable(18),O.decodeVideoTexture&&h.enable(19),O.decodeVideoTextureEmissive&&h.enable(20),O.alphaToCoverage&&h.enable(21),k.push(h.mask)}function W(k){const O=w[k.type];let le;if(O){const be=ss[O];le=d.rDY.clone(be.uniforms)}else le=k.uniforms;return le}function K(k,O){let le;for(let be=0,Ee=x.length;be<Ee;be++){const Pe=x[be];if(Pe.cacheKey===O){le=Pe,++le.usedTimes;break}}return le===void 0&&(le=new Kh(i,O,k,a),x.push(le)),le}function U(k){if(--k.usedTimes===0){const O=x.indexOf(k);x[O]=x[x.length-1],x.pop(),k.destroy()}}function j(k){f.remove(k)}function oe(){f.dispose()}return{getParameters:C,getProgramCacheKey:E,getUniforms:W,acquireProgram:K,releaseProgram:U,releaseShaderCache:j,programs:x,dispose:oe}}function Hy(){let i=new WeakMap;function e(c){return i.has(c)}function t(c){let h=i.get(c);return h===void 0&&(h={},i.set(c,h)),h}function r(c){i.delete(c)}function s(c,h,f){i.get(c)[h]=f}function a(){i=new WeakMap}return{has:e,get:t,remove:r,update:s,dispose:a}}function $y(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.z!==e.z?i.z-e.z:i.id-e.id}function jy(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function Xy(){const i=[];let e=0;const t=[],r=[],s=[];function a(){e=0,t.length=0,r.length=0,s.length=0}function c(_,v,T,w,P,C){let E=i[e];return E===void 0?(E={id:_.id,object:_,geometry:v,material:T,groupOrder:w,renderOrder:_.renderOrder,z:P,group:C},i[e]=E):(E.id=_.id,E.object=_,E.geometry=v,E.material=T,E.groupOrder=w,E.renderOrder=_.renderOrder,E.z=P,E.group=C),e++,E}function h(_,v,T,w,P,C){const E=c(_,v,T,w,P,C);T.transmission>0?r.push(E):T.transparent===!0?s.push(E):t.push(E)}function f(_,v,T,w,P,C){const E=c(_,v,T,w,P,C);T.transmission>0?r.unshift(E):T.transparent===!0?s.unshift(E):t.unshift(E)}function m(_,v){t.length>1&&t.sort(_||$y),r.length>1&&r.sort(v||jy),s.length>1&&s.sort(v||jy)}function x(){for(let _=e,v=i.length;_<v;_++){const T=i[_];if(T.id===null)break;T.id=null,T.object=null,T.geometry=null,T.material=null,T.group=null}}return{opaque:t,transmissive:r,transparent:s,init:a,push:h,unshift:f,finish:x,sort:m}}function qy(){let i=new WeakMap;function e(r,s){const a=i.get(r);let c;return a===void 0?(c=new Xy,i.set(r,[c])):s>=a.length?(c=new Xy,a.push(c)):c=a[s],c}function t(){i=new WeakMap}return{get:e,dispose:t}}function Ky(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new d.Pa4,color:new d.Ilk};break;case"SpotLight":t={position:new d.Pa4,direction:new d.Pa4,color:new d.Ilk,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new d.Pa4,color:new d.Ilk,distance:0,decay:0};break;case"HemisphereLight":t={direction:new d.Pa4,skyColor:new d.Ilk,groundColor:new d.Ilk};break;case"RectAreaLight":t={color:new d.Ilk,position:new d.Pa4,halfWidth:new d.Pa4,halfHeight:new d.Pa4};break}return i[e.id]=t,t}}}function Zy(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new d.FM8};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new d.FM8};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new d.FM8,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let rp=0;function sp(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function Ql(i){const e=new Ky,t=Zy(),r={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let m=0;m<9;m++)r.probe.push(new d.Pa4);const s=new d.Pa4,a=new d.yGw,c=new d.yGw;function h(m){let x=0,_=0,v=0;for(let k=0;k<9;k++)r.probe[k].set(0,0,0);let T=0,w=0,P=0,C=0,E=0,D=0,F=0,W=0,K=0,U=0,j=0;m.sort(sp);for(let k=0,O=m.length;k<O;k++){const le=m[k],be=le.color,Ee=le.intensity,Pe=le.distance,He=le.shadow&&le.shadow.map?le.shadow.map.texture:null;if(le.isAmbientLight)x+=be.r*Ee,_+=be.g*Ee,v+=be.b*Ee;else if(le.isLightProbe){for(let Be=0;Be<9;Be++)r.probe[Be].addScaledVector(le.sh.coefficients[Be],Ee);j++}else if(le.isDirectionalLight){const Be=e.get(le);if(Be.color.copy(le.color).multiplyScalar(le.intensity),le.castShadow){const ft=le.shadow,$e=t.get(le);$e.shadowIntensity=ft.intensity,$e.shadowBias=ft.bias,$e.shadowNormalBias=ft.normalBias,$e.shadowRadius=ft.radius,$e.shadowMapSize=ft.mapSize,r.directionalShadow[T]=$e,r.directionalShadowMap[T]=He,r.directionalShadowMatrix[T]=le.shadow.matrix,D++}r.directional[T]=Be,T++}else if(le.isSpotLight){const Be=e.get(le);Be.position.setFromMatrixPosition(le.matrixWorld),Be.color.copy(be).multiplyScalar(Ee),Be.distance=Pe,Be.coneCos=Math.cos(le.angle),Be.penumbraCos=Math.cos(le.angle*(1-le.penumbra)),Be.decay=le.decay,r.spot[P]=Be;const ft=le.shadow;if(le.map&&(r.spotLightMap[K]=le.map,K++,ft.updateMatrices(le),le.castShadow&&U++),r.spotLightMatrix[P]=ft.matrix,le.castShadow){const $e=t.get(le);$e.shadowIntensity=ft.intensity,$e.shadowBias=ft.bias,$e.shadowNormalBias=ft.normalBias,$e.shadowRadius=ft.radius,$e.shadowMapSize=ft.mapSize,r.spotShadow[P]=$e,r.spotShadowMap[P]=He,W++}P++}else if(le.isRectAreaLight){const Be=e.get(le);Be.color.copy(be).multiplyScalar(Ee),Be.halfWidth.set(le.width*.5,0,0),Be.halfHeight.set(0,le.height*.5,0),r.rectArea[C]=Be,C++}else if(le.isPointLight){const Be=e.get(le);if(Be.color.copy(le.color).multiplyScalar(le.intensity),Be.distance=le.distance,Be.decay=le.decay,le.castShadow){const ft=le.shadow,$e=t.get(le);$e.shadowIntensity=ft.intensity,$e.shadowBias=ft.bias,$e.shadowNormalBias=ft.normalBias,$e.shadowRadius=ft.radius,$e.shadowMapSize=ft.mapSize,$e.shadowCameraNear=ft.camera.near,$e.shadowCameraFar=ft.camera.far,r.pointShadow[w]=$e,r.pointShadowMap[w]=He,r.pointShadowMatrix[w]=le.shadow.matrix,F++}r.point[w]=Be,w++}else if(le.isHemisphereLight){const Be=e.get(le);Be.skyColor.copy(le.color).multiplyScalar(Ee),Be.groundColor.copy(le.groundColor).multiplyScalar(Ee),r.hemi[E]=Be,E++}}C>0&&(i.has("OES_texture_float_linear")===!0?(r.rectAreaLTC1=wt.LTC_FLOAT_1,r.rectAreaLTC2=wt.LTC_FLOAT_2):(r.rectAreaLTC1=wt.LTC_HALF_1,r.rectAreaLTC2=wt.LTC_HALF_2)),r.ambient[0]=x,r.ambient[1]=_,r.ambient[2]=v;const oe=r.hash;(oe.directionalLength!==T||oe.pointLength!==w||oe.spotLength!==P||oe.rectAreaLength!==C||oe.hemiLength!==E||oe.numDirectionalShadows!==D||oe.numPointShadows!==F||oe.numSpotShadows!==W||oe.numSpotMaps!==K||oe.numLightProbes!==j)&&(r.directional.length=T,r.spot.length=P,r.rectArea.length=C,r.point.length=w,r.hemi.length=E,r.directionalShadow.length=D,r.directionalShadowMap.length=D,r.pointShadow.length=F,r.pointShadowMap.length=F,r.spotShadow.length=W,r.spotShadowMap.length=W,r.directionalShadowMatrix.length=D,r.pointShadowMatrix.length=F,r.spotLightMatrix.length=W+K-U,r.spotLightMap.length=K,r.numSpotLightShadowsWithMaps=U,r.numLightProbes=j,oe.directionalLength=T,oe.pointLength=w,oe.spotLength=P,oe.rectAreaLength=C,oe.hemiLength=E,oe.numDirectionalShadows=D,oe.numPointShadows=F,oe.numSpotShadows=W,oe.numSpotMaps=K,oe.numLightProbes=j,r.version=rp++)}function f(m,x){let _=0,v=0,T=0,w=0,P=0;const C=x.matrixWorldInverse;for(let E=0,D=m.length;E<D;E++){const F=m[E];if(F.isDirectionalLight){const W=r.directional[_];W.direction.setFromMatrixPosition(F.matrixWorld),s.setFromMatrixPosition(F.target.matrixWorld),W.direction.sub(s),W.direction.transformDirection(C),_++}else if(F.isSpotLight){const W=r.spot[T];W.position.setFromMatrixPosition(F.matrixWorld),W.position.applyMatrix4(C),W.direction.setFromMatrixPosition(F.matrixWorld),s.setFromMatrixPosition(F.target.matrixWorld),W.direction.sub(s),W.direction.transformDirection(C),T++}else if(F.isRectAreaLight){const W=r.rectArea[w];W.position.setFromMatrixPosition(F.matrixWorld),W.position.applyMatrix4(C),c.identity(),a.copy(F.matrixWorld),a.premultiply(C),c.extractRotation(a),W.halfWidth.set(F.width*.5,0,0),W.halfHeight.set(0,F.height*.5,0),W.halfWidth.applyMatrix4(c),W.halfHeight.applyMatrix4(c),w++}else if(F.isPointLight){const W=r.point[v];W.position.setFromMatrixPosition(F.matrixWorld),W.position.applyMatrix4(C),v++}else if(F.isHemisphereLight){const W=r.hemi[P];W.direction.setFromMatrixPosition(F.matrixWorld),W.direction.transformDirection(C),P++}}}return{setup:h,setupView:f,state:r}}function Qc(i){const e=new Ql(i),t=[],r=[];function s(x){m.camera=x,t.length=0,r.length=0}function a(x){t.push(x)}function c(x){r.push(x)}function h(){e.setup(t)}function f(x){e.setupView(t,x)}const m={lightsArray:t,shadowsArray:r,camera:null,lights:e,transmissionRenderTarget:{}};return{init:s,state:m,setupLights:h,setupLightsView:f,pushLight:a,pushShadow:c}}function Ya(i){let e=new WeakMap;function t(s,a=0){const c=e.get(s);let h;return c===void 0?(h=new Qc(i),e.set(s,[h])):a>=c.length?(h=new Qc(i),c.push(h)):h=c[a],h}function r(){e=new WeakMap}return{get:t,dispose:r}}const op=`void main() {
gl_Position = vec4( position, 1.0 );
}`,Zh=`uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
#include <packing>
void main() {
const float samples = float( VSM_SAMPLES );
float mean = 0.0;
float squared_mean = 0.0;
float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
for ( float i = 0.0; i < samples; i ++ ) {
float uvOffset = uvStart + i * uvStride;
#ifdef HORIZONTAL_PASS
vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
mean += distribution.x;
squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
#else
float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
mean += depth;
squared_mean += depth * depth;
#endif
}
mean = mean / samples;
squared_mean = squared_mean / samples;
float std_dev = sqrt( squared_mean - mean * mean );
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
}`;function Yh(i,e,t){let r=new d.iWj;const s=new d.FM8,a=new d.FM8,c=new d.Ltg,h=new d.lRF({depthPacking:d.mSO}),f=new d.Lun,m={},x=t.maxTextureSize,_={[d.Wl3]:d._Li,[d._Li]:d.Wl3,[d.ehD]:d.ehD},v=new d.jyz({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new d.FM8},radius:{value:4}},vertexShader:op,fragmentShader:Zh}),T=v.clone();T.defines.HORIZONTAL_PASS=1;const w=new d.u9r;w.setAttribute("position",new d.TlE(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const P=new d.Kj0(w,v),C=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=d._iA;let E=this.type;this.render=function(U,j,oe){if(C.enabled===!1||C.autoUpdate===!1&&C.needsUpdate===!1||U.length===0)return;const k=i.getRenderTarget(),O=i.getActiveCubeFace(),le=i.getActiveMipmapLevel(),be=i.state;be.setBlending(d.jFi),be.buffers.depth.getReversed()===!0?be.buffers.color.setClear(0,0,0,0):be.buffers.color.setClear(1,1,1,1),be.buffers.depth.setTest(!0),be.setScissorTest(!1);const Ee=E!==d.dwk&&this.type===d.dwk,Pe=E===d.dwk&&this.type!==d.dwk;for(let He=0,Be=U.length;He<Be;He++){const ft=U[He],$e=ft.shadow;if($e===void 0){(0,d.ZK6)("WebGLShadowMap:",ft,"has no shadow.");continue}if($e.autoUpdate===!1&&$e.needsUpdate===!1)continue;s.copy($e.mapSize);const Tt=$e.getFrameExtents();if(s.multiply(Tt),a.copy($e.mapSize),(s.x>x||s.y>x)&&(s.x>x&&(a.x=Math.floor(x/Tt.x),s.x=a.x*Tt.x,$e.mapSize.x=a.x),s.y>x&&(a.y=Math.floor(x/Tt.y),s.y=a.y*Tt.y,$e.mapSize.y=a.y)),$e.map===null||Ee===!0||Pe===!0){const Ye=this.type!==d.dwk?{minFilter:d.TyD,magFilter:d.TyD}:{};$e.map!==null&&$e.map.dispose(),$e.map=new d.dd2(s.x,s.y,Ye),$e.map.texture.name=ft.name+".shadowMap",$e.camera.updateProjectionMatrix()}i.setRenderTarget($e.map),i.clear();const Pt=$e.getViewportCount();for(let Ye=0;Ye<Pt;Ye++){const yt=$e.getViewport(Ye);c.set(a.x*yt.x,a.y*yt.y,a.x*yt.z,a.y*yt.w),be.viewport(c),$e.updateMatrices(ft,Ye),r=$e.getFrustum(),W(j,oe,$e.camera,ft,this.type)}$e.isPointLightShadow!==!0&&this.type===d.dwk&&D($e,oe),$e.needsUpdate=!1}E=this.type,C.needsUpdate=!1,i.setRenderTarget(k,O,le)};function D(U,j){const oe=e.update(P);v.defines.VSM_SAMPLES!==U.blurSamples&&(v.defines.VSM_SAMPLES=U.blurSamples,T.defines.VSM_SAMPLES=U.blurSamples,v.needsUpdate=!0,T.needsUpdate=!0),U.mapPass===null&&(U.mapPass=new d.dd2(s.x,s.y)),v.uniforms.shadow_pass.value=U.map.texture,v.uniforms.resolution.value=U.mapSize,v.uniforms.radius.value=U.radius,i.setRenderTarget(U.mapPass),i.clear(),i.renderBufferDirect(j,null,oe,v,P,null),T.uniforms.shadow_pass.value=U.mapPass.texture,T.uniforms.resolution.value=U.mapSize,T.uniforms.radius.value=U.radius,i.setRenderTarget(U.map),i.clear(),i.renderBufferDirect(j,null,oe,T,P,null)}function F(U,j,oe,k){let O=null;const le=oe.isPointLight===!0?U.customDistanceMaterial:U.customDepthMaterial;if(le!==void 0)O=le;else if(O=oe.isPointLight===!0?f:h,i.localClippingEnabled&&j.clipShadows===!0&&Array.isArray(j.clippingPlanes)&&j.clippingPlanes.length!==0||j.displacementMap&&j.displacementScale!==0||j.alphaMap&&j.alphaTest>0||j.map&&j.alphaTest>0||j.alphaToCoverage===!0){const be=O.uuid,Ee=j.uuid;let Pe=m[be];Pe===void 0&&(Pe={},m[be]=Pe);let He=Pe[Ee];He===void 0&&(He=O.clone(),Pe[Ee]=He,j.addEventListener("dispose",K)),O=He}if(O.visible=j.visible,O.wireframe=j.wireframe,k===d.dwk?O.side=j.shadowSide!==null?j.shadowSide:j.side:O.side=j.shadowSide!==null?j.shadowSide:_[j.side],O.alphaMap=j.alphaMap,O.alphaTest=j.alphaToCoverage===!0?.5:j.alphaTest,O.map=j.map,O.clipShadows=j.clipShadows,O.clippingPlanes=j.clippingPlanes,O.clipIntersection=j.clipIntersection,O.displacementMap=j.displacementMap,O.displacementScale=j.displacementScale,O.displacementBias=j.displacementBias,O.wireframeLinewidth=j.wireframeLinewidth,O.linewidth=j.linewidth,oe.isPointLight===!0&&O.isMeshDistanceMaterial===!0){const be=i.properties.get(O);be.light=oe}return O}function W(U,j,oe,k,O){if(U.visible===!1)return;if(U.layers.test(j.layers)&&(U.isMesh||U.isLine||U.isPoints)&&(U.castShadow||U.receiveShadow&&O===d.dwk)&&(!U.frustumCulled||r.intersectsObject(U))){U.modelViewMatrix.multiplyMatrices(oe.matrixWorldInverse,U.matrixWorld);const Ee=e.update(U),Pe=U.material;if(Array.isArray(Pe)){const He=Ee.groups;for(let Be=0,ft=He.length;Be<ft;Be++){const $e=He[Be],Tt=Pe[$e.materialIndex];if(Tt&&Tt.visible){const Pt=F(U,Tt,k,O);U.onBeforeShadow(i,U,j,oe,Ee,Pt,$e),i.renderBufferDirect(oe,null,Ee,Pt,U,$e),U.onAfterShadow(i,U,j,oe,Ee,Pt,$e)}}}else if(Pe.visible){const He=F(U,Pe,k,O);U.onBeforeShadow(i,U,j,oe,Ee,He,null),i.renderBufferDirect(oe,null,Ee,He,U,null),U.onAfterShadow(i,U,j,oe,Ee,He,null)}}const be=U.children;for(let Ee=0,Pe=be.length;Ee<Pe;Ee++)W(be[Ee],j,oe,k,O)}function K(U){U.target.removeEventListener("dispose",K);for(const oe in m){const k=m[oe],O=U.target.uuid;O in k&&(k[O].dispose(),delete k[O])}}}const ap={[d.BVF]:d.Se2,[d.Zr5]:d.w$m,[d.eD]:d.M6v,[d.vCF]:d.ksN,[d.Se2]:d.BVF,[d.w$m]:d.Zr5,[d.M6v]:d.eD,[d.ksN]:d.vCF};function Qh(i,e){function t(){let xe=!1;const It=new d.Ltg;let Et=null;const Ct=new d.Ltg(0,0,0,0);return{setMask:function(xt){Et!==xt&&!xe&&(i.colorMask(xt,xt,xt,xt),Et=xt)},setLocked:function(xt){xe=xt},setClear:function(xt,it,Yt,On,Bi){Bi===!0&&(xt*=On,it*=On,Yt*=On),It.set(xt,it,Yt,On),Ct.equals(It)===!1&&(i.clearColor(xt,it,Yt,On),Ct.copy(It))},reset:function(){xe=!1,Et=null,Ct.set(-1,0,0,0)}}}function r(){let xe=!1,It=!1,Et=null,Ct=null,xt=null;return{setReversed:function(it){if(It!==it){const Yt=e.get("EXT_clip_control");it?Yt.clipControlEXT(Yt.LOWER_LEFT_EXT,Yt.ZERO_TO_ONE_EXT):Yt.clipControlEXT(Yt.LOWER_LEFT_EXT,Yt.NEGATIVE_ONE_TO_ONE_EXT),It=it;const On=xt;xt=null,this.setClear(On)}},getReversed:function(){return It},setTest:function(it){it?Ne(i.DEPTH_TEST):gt(i.DEPTH_TEST)},setMask:function(it){Et!==it&&!xe&&(i.depthMask(it),Et=it)},setFunc:function(it){if(It&&(it=ap[it]),Ct!==it){switch(it){case d.BVF:i.depthFunc(i.NEVER);break;case d.Se2:i.depthFunc(i.ALWAYS);break;case d.Zr5:i.depthFunc(i.LESS);break;case d.vCF:i.depthFunc(i.LEQUAL);break;case d.eD:i.depthFunc(i.EQUAL);break;case d.ksN:i.depthFunc(i.GEQUAL);break;case d.w$m:i.depthFunc(i.GREATER);break;case d.M6v:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}Ct=it}},setLocked:function(it){xe=it},setClear:function(it){xt!==it&&(It&&(it=1-it),i.clearDepth(it),xt=it)},reset:function(){xe=!1,Et=null,Ct=null,xt=null,It=!1}}}function s(){let xe=!1,It=null,Et=null,Ct=null,xt=null,it=null,Yt=null,On=null,Bi=null;return{setTest:function(Si){xe||(Si?Ne(i.STENCIL_TEST):gt(i.STENCIL_TEST))},setMask:function(Si){It!==Si&&!xe&&(i.stencilMask(Si),It=Si)},setFunc:function(Si,Ea,Yo){(Et!==Si||Ct!==Ea||xt!==Yo)&&(i.stencilFunc(Si,Ea,Yo),Et=Si,Ct=Ea,xt=Yo)},setOp:function(Si,Ea,Yo){(it!==Si||Yt!==Ea||On!==Yo)&&(i.stencilOp(Si,Ea,Yo),it=Si,Yt=Ea,On=Yo)},setLocked:function(Si){xe=Si},setClear:function(Si){Bi!==Si&&(i.clearStencil(Si),Bi=Si)},reset:function(){xe=!1,It=null,Et=null,Ct=null,xt=null,it=null,Yt=null,On=null,Bi=null}}}const a=new t,c=new r,h=new s,f=new WeakMap,m=new WeakMap;let x={},_={},v=new WeakMap,T=[],w=null,P=!1,C=null,E=null,D=null,F=null,W=null,K=null,U=null,j=new d.Ilk(0,0,0),oe=0,k=!1,O=null,le=null,be=null,Ee=null,Pe=null;const He=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Be=!1,ft=0;const $e=i.getParameter(i.VERSION);$e.indexOf("WebGL")!==-1?(ft=parseFloat(/^WebGL (\d)/.exec($e)[1]),Be=ft>=1):$e.indexOf("OpenGL ES")!==-1&&(ft=parseFloat(/^OpenGL ES (\d)/.exec($e)[1]),Be=ft>=2);let Tt=null,Pt={};const Ye=i.getParameter(i.SCISSOR_BOX),yt=i.getParameter(i.VIEWPORT),Ot=new d.Ltg().fromArray(Ye),Mn=new d.Ltg().fromArray(yt);function tt(xe,It,Et,Ct){const xt=new Uint8Array(4),it=i.createTexture();i.bindTexture(xe,it),i.texParameteri(xe,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(xe,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let Yt=0;Yt<Et;Yt++)xe===i.TEXTURE_3D||xe===i.TEXTURE_2D_ARRAY?i.texImage3D(It,0,i.RGBA,1,1,Ct,0,i.RGBA,i.UNSIGNED_BYTE,xt):i.texImage2D(It+Yt,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,xt);return it}const ve={};ve[i.TEXTURE_2D]=tt(i.TEXTURE_2D,i.TEXTURE_2D,1),ve[i.TEXTURE_CUBE_MAP]=tt(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),ve[i.TEXTURE_2D_ARRAY]=tt(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),ve[i.TEXTURE_3D]=tt(i.TEXTURE_3D,i.TEXTURE_3D,1,1),a.setClear(0,0,0,1),c.setClear(1),h.setClear(0),Ne(i.DEPTH_TEST),c.setFunc(d.vCF),Vn(!1),Un(d.tm_),Ne(i.CULL_FACE),si(d.jFi);function Ne(xe){x[xe]!==!0&&(i.enable(xe),x[xe]=!0)}function gt(xe){x[xe]!==!1&&(i.disable(xe),x[xe]=!1)}function qt(xe,It){return _[xe]!==It?(i.bindFramebuffer(xe,It),_[xe]=It,xe===i.DRAW_FRAMEBUFFER&&(_[i.FRAMEBUFFER]=It),xe===i.FRAMEBUFFER&&(_[i.DRAW_FRAMEBUFFER]=It),!0):!1}function Nt(xe,It){let Et=T,Ct=!1;if(xe){Et=v.get(It),Et===void 0&&(Et=[],v.set(It,Et));const xt=xe.textures;if(Et.length!==xt.length||Et[0]!==i.COLOR_ATTACHMENT0){for(let it=0,Yt=xt.length;it<Yt;it++)Et[it]=i.COLOR_ATTACHMENT0+it;Et.length=xt.length,Ct=!0}}else Et[0]!==i.BACK&&(Et[0]=i.BACK,Ct=!0);Ct&&i.drawBuffers(Et)}function en(xe){return w!==xe?(i.useProgram(xe),w=xe,!0):!1}const vi={[d.bGH]:i.FUNC_ADD,[d.Wbm]:i.FUNC_SUBTRACT,[d.rOj]:i.FUNC_REVERSE_SUBTRACT};vi[d.r_]=i.MIN,vi[d.Sm8]=i.MAX;const Dn={[d.c8b]:i.ZERO,[d.ghN]:i.ONE,[d.KhW]:i.SRC_COLOR,[d.k74]:i.SRC_ALPHA,[d.RlZ]:i.SRC_ALPHA_SATURATE,[d.Vdb]:i.DST_COLOR,[d.fSK]:i.DST_ALPHA,[d.iWC]:i.ONE_MINUS_SRC_COLOR,[d.LgZ]:i.ONE_MINUS_SRC_ALPHA,[d.Wpd]:i.ONE_MINUS_DST_COLOR,[d.Hy8]:i.ONE_MINUS_DST_ALPHA,[d._wr]:i.CONSTANT_COLOR,[d.Cy]:i.ONE_MINUS_CONSTANT_COLOR,[d.jes]:i.CONSTANT_ALPHA,[d.NKc]:i.ONE_MINUS_CONSTANT_ALPHA};function si(xe,It,Et,Ct,xt,it,Yt,On,Bi,Si){if(xe===d.jFi){P===!0&&(gt(i.BLEND),P=!1);return}if(P===!1&&(Ne(i.BLEND),P=!0),xe!==d.Xaj){if(xe!==C||Si!==k){if((E!==d.bGH||W!==d.bGH)&&(i.blendEquation(i.FUNC_ADD),E=d.bGH,W=d.bGH),Si)switch(xe){case d.bdR:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case d.WMw:i.blendFunc(i.ONE,i.ONE);break;case d.N4l:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case d.M5h:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:(0,d.vUy)("WebGLState: Invalid blending: ",xe);break}else switch(xe){case d.bdR:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case d.WMw:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case d.N4l:(0,d.vUy)("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case d.M5h:(0,d.vUy)("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:(0,d.vUy)("WebGLState: Invalid blending: ",xe);break}D=null,F=null,K=null,U=null,j.set(0,0,0),oe=0,C=xe,k=Si}return}xt=xt||It,it=it||Et,Yt=Yt||Ct,(It!==E||xt!==W)&&(i.blendEquationSeparate(vi[It],vi[xt]),E=It,W=xt),(Et!==D||Ct!==F||it!==K||Yt!==U)&&(i.blendFuncSeparate(Dn[Et],Dn[Ct],Dn[it],Dn[Yt]),D=Et,F=Ct,K=it,U=Yt),(On.equals(j)===!1||Bi!==oe)&&(i.blendColor(On.r,On.g,On.b,Bi),j.copy(On),oe=Bi),C=xe,k=!1}function me(xe,It){xe.side===d.ehD?gt(i.CULL_FACE):Ne(i.CULL_FACE);let Et=xe.side===d._Li;It&&(Et=!Et),Vn(Et),xe.blending===d.bdR&&xe.transparent===!1?si(d.jFi):si(xe.blending,xe.blendEquation,xe.blendSrc,xe.blendDst,xe.blendEquationAlpha,xe.blendSrcAlpha,xe.blendDstAlpha,xe.blendColor,xe.blendAlpha,xe.premultipliedAlpha),c.setFunc(xe.depthFunc),c.setTest(xe.depthTest),c.setMask(xe.depthWrite),a.setMask(xe.colorWrite);const Ct=xe.stencilWrite;h.setTest(Ct),Ct&&(h.setMask(xe.stencilWriteMask),h.setFunc(xe.stencilFunc,xe.stencilRef,xe.stencilFuncMask),h.setOp(xe.stencilFail,xe.stencilZFail,xe.stencilZPass)),Jt(xe.polygonOffset,xe.polygonOffsetFactor,xe.polygonOffsetUnits),xe.alphaToCoverage===!0?Ne(i.SAMPLE_ALPHA_TO_COVERAGE):gt(i.SAMPLE_ALPHA_TO_COVERAGE)}function Vn(xe){O!==xe&&(xe?i.frontFace(i.CW):i.frontFace(i.CCW),O=xe)}function Un(xe){xe!==d.PeU?(Ne(i.CULL_FACE),xe!==le&&(xe===d.tm_?i.cullFace(i.BACK):xe===d.S2y?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):gt(i.CULL_FACE),le=xe}function li(xe){xe!==be&&(Be&&i.lineWidth(xe),be=xe)}function Jt(xe,It,Et){xe?(Ne(i.POLYGON_OFFSET_FILL),(Ee!==It||Pe!==Et)&&(i.polygonOffset(It,Et),Ee=It,Pe=Et)):gt(i.POLYGON_OFFSET_FILL)}function Xi(xe){xe?Ne(i.SCISSOR_TEST):gt(i.SCISSOR_TEST)}function yn(xe){xe===void 0&&(xe=i.TEXTURE0+He-1),Tt!==xe&&(i.activeTexture(xe),Tt=xe)}function zn(xe,It,Et){Et===void 0&&(Tt===null?Et=i.TEXTURE0+He-1:Et=Tt);let Ct=Pt[Et];Ct===void 0&&(Ct={type:void 0,texture:void 0},Pt[Et]=Ct),(Ct.type!==xe||Ct.texture!==It)&&(Tt!==Et&&(i.activeTexture(Et),Tt=Et),i.bindTexture(xe,It||ve[xe]),Ct.type=xe,Ct.texture=It)}function J(){const xe=Pt[Tt];xe!==void 0&&xe.type!==void 0&&(i.bindTexture(xe.type,null),xe.type=void 0,xe.texture=void 0)}function V(){try{i.compressedTexImage2D(...arguments)}catch(xe){xe("WebGLState:",xe)}}function Ce(){try{i.compressedTexImage3D(...arguments)}catch(xe){xe("WebGLState:",xe)}}function et(){try{i.texSubImage2D(...arguments)}catch(xe){xe("WebGLState:",xe)}}function ct(){try{i.texSubImage3D(...arguments)}catch(xe){xe("WebGLState:",xe)}}function je(){try{i.compressedTexSubImage2D(...arguments)}catch(xe){xe("WebGLState:",xe)}}function ln(){try{i.compressedTexSubImage3D(...arguments)}catch(xe){xe("WebGLState:",xe)}}function Lt(){try{i.texStorage2D(...arguments)}catch(xe){xe("WebGLState:",xe)}}function vn(){try{i.texStorage3D(...arguments)}catch(xe){xe("WebGLState:",xe)}}function rn(){try{i.texImage2D(...arguments)}catch(xe){xe("WebGLState:",xe)}}function ht(){try{i.texImage3D(...arguments)}catch(xe){xe("WebGLState:",xe)}}function Mt(xe){Ot.equals(xe)===!1&&(i.scissor(xe.x,xe.y,xe.z,xe.w),Ot.copy(xe))}function En(xe){Mn.equals(xe)===!1&&(i.viewport(xe.x,xe.y,xe.z,xe.w),Mn.copy(xe))}function Tn(xe,It){let Et=m.get(It);Et===void 0&&(Et=new WeakMap,m.set(It,Et));let Ct=Et.get(xe);Ct===void 0&&(Ct=i.getUniformBlockIndex(It,xe.name),Et.set(xe,Ct))}function zt(xe,It){const Ct=m.get(It).get(xe);f.get(It)!==Ct&&(i.uniformBlockBinding(It,Ct,xe.__bindingPointIndex),f.set(It,Ct))}function Pn(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),c.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),x={},Tt=null,Pt={},_={},v=new WeakMap,T=[],w=null,P=!1,C=null,E=null,D=null,F=null,W=null,K=null,U=null,j=new d.Ilk(0,0,0),oe=0,k=!1,O=null,le=null,be=null,Ee=null,Pe=null,Ot.set(0,0,i.canvas.width,i.canvas.height),Mn.set(0,0,i.canvas.width,i.canvas.height),a.reset(),c.reset(),h.reset()}return{buffers:{color:a,depth:c,stencil:h},enable:Ne,disable:gt,bindFramebuffer:qt,drawBuffers:Nt,useProgram:en,setBlending:si,setMaterial:me,setFlipSided:Vn,setCullFace:Un,setLineWidth:li,setPolygonOffset:Jt,setScissorTest:Xi,activeTexture:yn,bindTexture:zn,unbindTexture:J,compressedTexImage2D:V,compressedTexImage3D:Ce,texImage2D:rn,texImage3D:ht,updateUBOMapping:Tn,uniformBlockBinding:zt,texStorage2D:Lt,texStorage3D:vn,texSubImage2D:et,texSubImage3D:ct,compressedTexSubImage2D:je,compressedTexSubImage3D:ln,scissor:Mt,viewport:En,reset:Pn}}function Yy(i,e,t,r,s,a,c){const h=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,f=typeof navigator=="undefined"?!1:/OculusBrowser/g.test(navigator.userAgent),m=new d.FM8,x=new WeakMap;let _;const v=new WeakMap;let T=!1;try{T=typeof OffscreenCanvas!="undefined"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(J){}function w(J,V){return T?new OffscreenCanvas(J,V):(0,d.cac)("canvas")}function P(J,V,Ce){let et=1;const ct=zn(J);if((ct.width>Ce||ct.height>Ce)&&(et=Ce/Math.max(ct.width,ct.height)),et<1)if(typeof HTMLImageElement!="undefined"&&J instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&J instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&J instanceof ImageBitmap||typeof VideoFrame!="undefined"&&J instanceof VideoFrame){const je=Math.floor(et*ct.width),ln=Math.floor(et*ct.height);_===void 0&&(_=w(je,ln));const Lt=V?w(je,ln):_;return Lt.width=je,Lt.height=ln,Lt.getContext("2d").drawImage(J,0,0,je,ln),(0,d.ZK6)("WebGLRenderer: Texture has been resized from ("+ct.width+"x"+ct.height+") to ("+je+"x"+ln+")."),Lt}else return"data"in J&&(0,d.ZK6)("WebGLRenderer: Image in DataTexture is too big ("+ct.width+"x"+ct.height+")."),J;return J}function C(J){return J.generateMipmaps}function E(J){i.generateMipmap(J)}function D(J){return J.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:J.isWebGL3DRenderTarget?i.TEXTURE_3D:J.isWebGLArrayRenderTarget||J.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function F(J,V,Ce,et,ct=!1){if(J!==null){if(i[J]!==void 0)return i[J];(0,d.ZK6)("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+J+"'")}let je=V;if(V===i.RED&&(Ce===i.FLOAT&&(je=i.R32F),Ce===i.HALF_FLOAT&&(je=i.R16F),Ce===i.UNSIGNED_BYTE&&(je=i.R8)),V===i.RED_INTEGER&&(Ce===i.UNSIGNED_BYTE&&(je=i.R8UI),Ce===i.UNSIGNED_SHORT&&(je=i.R16UI),Ce===i.UNSIGNED_INT&&(je=i.R32UI),Ce===i.BYTE&&(je=i.R8I),Ce===i.SHORT&&(je=i.R16I),Ce===i.INT&&(je=i.R32I)),V===i.RG&&(Ce===i.FLOAT&&(je=i.RG32F),Ce===i.HALF_FLOAT&&(je=i.RG16F),Ce===i.UNSIGNED_BYTE&&(je=i.RG8)),V===i.RG_INTEGER&&(Ce===i.UNSIGNED_BYTE&&(je=i.RG8UI),Ce===i.UNSIGNED_SHORT&&(je=i.RG16UI),Ce===i.UNSIGNED_INT&&(je=i.RG32UI),Ce===i.BYTE&&(je=i.RG8I),Ce===i.SHORT&&(je=i.RG16I),Ce===i.INT&&(je=i.RG32I)),V===i.RGB_INTEGER&&(Ce===i.UNSIGNED_BYTE&&(je=i.RGB8UI),Ce===i.UNSIGNED_SHORT&&(je=i.RGB16UI),Ce===i.UNSIGNED_INT&&(je=i.RGB32UI),Ce===i.BYTE&&(je=i.RGB8I),Ce===i.SHORT&&(je=i.RGB16I),Ce===i.INT&&(je=i.RGB32I)),V===i.RGBA_INTEGER&&(Ce===i.UNSIGNED_BYTE&&(je=i.RGBA8UI),Ce===i.UNSIGNED_SHORT&&(je=i.RGBA16UI),Ce===i.UNSIGNED_INT&&(je=i.RGBA32UI),Ce===i.BYTE&&(je=i.RGBA8I),Ce===i.SHORT&&(je=i.RGBA16I),Ce===i.INT&&(je=i.RGBA32I)),V===i.RGB&&(Ce===i.UNSIGNED_INT_5_9_9_9_REV&&(je=i.RGB9_E5),Ce===i.UNSIGNED_INT_10F_11F_11F_REV&&(je=i.R11F_G11F_B10F)),V===i.RGBA){const ln=ct?d.l6D:d.epp.getTransfer(et);Ce===i.FLOAT&&(je=i.RGBA32F),Ce===i.HALF_FLOAT&&(je=i.RGBA16F),Ce===i.UNSIGNED_BYTE&&(je=ln===d.j17?i.SRGB8_ALPHA8:i.RGBA8),Ce===i.UNSIGNED_SHORT_4_4_4_4&&(je=i.RGBA4),Ce===i.UNSIGNED_SHORT_5_5_5_1&&(je=i.RGB5_A1)}return(je===i.R16F||je===i.R32F||je===i.RG16F||je===i.RG32F||je===i.RGBA16F||je===i.RGBA32F)&&e.get("EXT_color_buffer_float"),je}function W(J,V){let Ce;return J?V===null||V===d.JQ4||V===d.wJv?Ce=i.DEPTH24_STENCIL8:V===d.VzW?Ce=i.DEPTH32F_STENCIL8:V===d.LsT&&(Ce=i.DEPTH24_STENCIL8,(0,d.ZK6)("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):V===null||V===d.JQ4||V===d.wJv?Ce=i.DEPTH_COMPONENT24:V===d.VzW?Ce=i.DEPTH_COMPONENT32F:V===d.LsT&&(Ce=i.DEPTH_COMPONENT16),Ce}function K(J,V){return C(J)===!0||J.isFramebufferTexture&&J.minFilter!==d.TyD&&J.minFilter!==d.wem?Math.log2(Math.max(V.width,V.height))+1:J.mipmaps!==void 0&&J.mipmaps.length>0?J.mipmaps.length:J.isCompressedTexture&&Array.isArray(J.image)?V.mipmaps.length:1}function U(J){const V=J.target;V.removeEventListener("dispose",U),oe(V),V.isVideoTexture&&x.delete(V)}function j(J){const V=J.target;V.removeEventListener("dispose",j),O(V)}function oe(J){const V=r.get(J);if(V.__webglInit===void 0)return;const Ce=J.source,et=v.get(Ce);if(et){const ct=et[V.__cacheKey];ct.usedTimes--,ct.usedTimes===0&&k(J),Object.keys(et).length===0&&v.delete(Ce)}r.remove(J)}function k(J){const V=r.get(J);i.deleteTexture(V.__webglTexture);const Ce=J.source,et=v.get(Ce);delete et[V.__cacheKey],c.memory.textures--}function O(J){const V=r.get(J);if(J.depthTexture&&(J.depthTexture.dispose(),r.remove(J.depthTexture)),J.isWebGLCubeRenderTarget)for(let et=0;et<6;et++){if(Array.isArray(V.__webglFramebuffer[et]))for(let ct=0;ct<V.__webglFramebuffer[et].length;ct++)i.deleteFramebuffer(V.__webglFramebuffer[et][ct]);else i.deleteFramebuffer(V.__webglFramebuffer[et]);V.__webglDepthbuffer&&i.deleteRenderbuffer(V.__webglDepthbuffer[et])}else{if(Array.isArray(V.__webglFramebuffer))for(let et=0;et<V.__webglFramebuffer.length;et++)i.deleteFramebuffer(V.__webglFramebuffer[et]);else i.deleteFramebuffer(V.__webglFramebuffer);if(V.__webglDepthbuffer&&i.deleteRenderbuffer(V.__webglDepthbuffer),V.__webglMultisampledFramebuffer&&i.deleteFramebuffer(V.__webglMultisampledFramebuffer),V.__webglColorRenderbuffer)for(let et=0;et<V.__webglColorRenderbuffer.length;et++)V.__webglColorRenderbuffer[et]&&i.deleteRenderbuffer(V.__webglColorRenderbuffer[et]);V.__webglDepthRenderbuffer&&i.deleteRenderbuffer(V.__webglDepthRenderbuffer)}const Ce=J.textures;for(let et=0,ct=Ce.length;et<ct;et++){const je=r.get(Ce[et]);je.__webglTexture&&(i.deleteTexture(je.__webglTexture),c.memory.textures--),r.remove(Ce[et])}r.remove(J)}let le=0;function be(){le=0}function Ee(){const J=le;return J>=s.maxTextures&&(0,d.ZK6)("WebGLTextures: Trying to use "+J+" texture units while this GPU supports only "+s.maxTextures),le+=1,J}function Pe(J){const V=[];return V.push(J.wrapS),V.push(J.wrapT),V.push(J.wrapR||0),V.push(J.magFilter),V.push(J.minFilter),V.push(J.anisotropy),V.push(J.internalFormat),V.push(J.format),V.push(J.type),V.push(J.generateMipmaps),V.push(J.premultiplyAlpha),V.push(J.flipY),V.push(J.unpackAlignment),V.push(J.colorSpace),V.join()}function He(J,V){const Ce=r.get(J);if(J.isVideoTexture&&Xi(J),J.isRenderTargetTexture===!1&&J.isExternalTexture!==!0&&J.version>0&&Ce.__version!==J.version){const et=J.image;if(et===null)(0,d.ZK6)("WebGLRenderer: Texture marked for update but no image data found.");else if(et.complete===!1)(0,d.ZK6)("WebGLRenderer: Texture marked for update but image is incomplete");else{ve(Ce,J,V);return}}else J.isExternalTexture&&(Ce.__webglTexture=J.sourceTexture?J.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,Ce.__webglTexture,i.TEXTURE0+V)}function Be(J,V){const Ce=r.get(J);if(J.isRenderTargetTexture===!1&&J.version>0&&Ce.__version!==J.version){ve(Ce,J,V);return}else J.isExternalTexture&&(Ce.__webglTexture=J.sourceTexture?J.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,Ce.__webglTexture,i.TEXTURE0+V)}function ft(J,V){const Ce=r.get(J);if(J.isRenderTargetTexture===!1&&J.version>0&&Ce.__version!==J.version){ve(Ce,J,V);return}t.bindTexture(i.TEXTURE_3D,Ce.__webglTexture,i.TEXTURE0+V)}function $e(J,V){const Ce=r.get(J);if(J.version>0&&Ce.__version!==J.version){Ne(Ce,J,V);return}t.bindTexture(i.TEXTURE_CUBE_MAP,Ce.__webglTexture,i.TEXTURE0+V)}const Tt={[d.rpg]:i.REPEAT,[d.uWy]:i.CLAMP_TO_EDGE,[d.OoA]:i.MIRRORED_REPEAT},Pt={[d.TyD]:i.NEAREST,[d.YLQ]:i.NEAREST_MIPMAP_NEAREST,[d.aH4]:i.NEAREST_MIPMAP_LINEAR,[d.wem]:i.LINEAR,[d.qyh]:i.LINEAR_MIPMAP_NEAREST,[d.D1R]:i.LINEAR_MIPMAP_LINEAR},Ye={[d.xoQ]:i.NEVER,[d.T6w]:i.ALWAYS,[d.D67]:i.LESS,[d.M$G]:i.LEQUAL,[d.F1y]:i.EQUAL,[d.Jjb]:i.GEQUAL,[d.Zen]:i.GREATER,[d.O78]:i.NOTEQUAL};function yt(J,V){if(V.type===d.VzW&&e.has("OES_texture_float_linear")===!1&&(V.magFilter===d.wem||V.magFilter===d.qyh||V.magFilter===d.aH4||V.magFilter===d.D1R||V.minFilter===d.wem||V.minFilter===d.qyh||V.minFilter===d.aH4||V.minFilter===d.D1R)&&(0,d.ZK6)("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(J,i.TEXTURE_WRAP_S,Tt[V.wrapS]),i.texParameteri(J,i.TEXTURE_WRAP_T,Tt[V.wrapT]),(J===i.TEXTURE_3D||J===i.TEXTURE_2D_ARRAY)&&i.texParameteri(J,i.TEXTURE_WRAP_R,Tt[V.wrapR]),i.texParameteri(J,i.TEXTURE_MAG_FILTER,Pt[V.magFilter]),i.texParameteri(J,i.TEXTURE_MIN_FILTER,Pt[V.minFilter]),V.compareFunction&&(i.texParameteri(J,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(J,i.TEXTURE_COMPARE_FUNC,Ye[V.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(V.magFilter===d.TyD||V.minFilter!==d.aH4&&V.minFilter!==d.D1R||V.type===d.VzW&&e.has("OES_texture_float_linear")===!1)return;if(V.anisotropy>1||r.get(V).__currentAnisotropy){const Ce=e.get("EXT_texture_filter_anisotropic");i.texParameterf(J,Ce.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(V.anisotropy,s.getMaxAnisotropy())),r.get(V).__currentAnisotropy=V.anisotropy}}}function Ot(J,V){let Ce=!1;J.__webglInit===void 0&&(J.__webglInit=!0,V.addEventListener("dispose",U));const et=V.source;let ct=v.get(et);ct===void 0&&(ct={},v.set(et,ct));const je=Pe(V);if(je!==J.__cacheKey){ct[je]===void 0&&(ct[je]={texture:i.createTexture(),usedTimes:0},c.memory.textures++,Ce=!0),ct[je].usedTimes++;const ln=ct[J.__cacheKey];ln!==void 0&&(ct[J.__cacheKey].usedTimes--,ln.usedTimes===0&&k(V)),J.__cacheKey=je,J.__webglTexture=ct[je].texture}return Ce}function Mn(J,V,Ce){return Math.floor(Math.floor(J/Ce)/V)}function tt(J,V,Ce,et){const je=J.updateRanges;if(je.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,V.width,V.height,Ce,et,V.data);else{je.sort((ht,Mt)=>ht.start-Mt.start);let ln=0;for(let ht=1;ht<je.length;ht++){const Mt=je[ln],En=je[ht],Tn=Mt.start+Mt.count,zt=Mn(En.start,V.width,4),Pn=Mn(Mt.start,V.width,4);En.start<=Tn+1&&zt===Pn&&Mn(En.start+En.count-1,V.width,4)===zt?Mt.count=Math.max(Mt.count,En.start+En.count-Mt.start):(++ln,je[ln]=En)}je.length=ln+1;const Lt=i.getParameter(i.UNPACK_ROW_LENGTH),vn=i.getParameter(i.UNPACK_SKIP_PIXELS),rn=i.getParameter(i.UNPACK_SKIP_ROWS);i.pixelStorei(i.UNPACK_ROW_LENGTH,V.width);for(let ht=0,Mt=je.length;ht<Mt;ht++){const En=je[ht],Tn=Math.floor(En.start/4),zt=Math.ceil(En.count/4),Pn=Tn%V.width,xe=Math.floor(Tn/V.width),It=zt,Et=1;i.pixelStorei(i.UNPACK_SKIP_PIXELS,Pn),i.pixelStorei(i.UNPACK_SKIP_ROWS,xe),t.texSubImage2D(i.TEXTURE_2D,0,Pn,xe,It,Et,Ce,et,V.data)}J.clearUpdateRanges(),i.pixelStorei(i.UNPACK_ROW_LENGTH,Lt),i.pixelStorei(i.UNPACK_SKIP_PIXELS,vn),i.pixelStorei(i.UNPACK_SKIP_ROWS,rn)}}function ve(J,V,Ce){let et=i.TEXTURE_2D;(V.isDataArrayTexture||V.isCompressedArrayTexture)&&(et=i.TEXTURE_2D_ARRAY),V.isData3DTexture&&(et=i.TEXTURE_3D);const ct=Ot(J,V),je=V.source;t.bindTexture(et,J.__webglTexture,i.TEXTURE0+Ce);const ln=r.get(je);if(je.version!==ln.__version||ct===!0){t.activeTexture(i.TEXTURE0+Ce);const Lt=d.epp.getPrimaries(d.epp.workingColorSpace),vn=V.colorSpace===d.aCh?null:d.epp.getPrimaries(V.colorSpace),rn=V.colorSpace===d.aCh||Lt===vn?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,V.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,V.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,V.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,rn);let ht=P(V.image,!1,s.maxTextureSize);ht=yn(V,ht);const Mt=a.convert(V.format,V.colorSpace),En=a.convert(V.type);let Tn=F(V.internalFormat,Mt,En,V.colorSpace,V.isVideoTexture);yt(et,V);let zt;const Pn=V.mipmaps,xe=V.isVideoTexture!==!0,It=ln.__version===void 0||ct===!0,Et=je.dataReady,Ct=K(V,ht);if(V.isDepthTexture)Tn=W(V.format===d.brP,V.type),It&&(xe?t.texStorage2D(i.TEXTURE_2D,1,Tn,ht.width,ht.height):t.texImage2D(i.TEXTURE_2D,0,Tn,ht.width,ht.height,0,Mt,En,null));else if(V.isDataTexture)if(Pn.length>0){xe&&It&&t.texStorage2D(i.TEXTURE_2D,Ct,Tn,Pn[0].width,Pn[0].height);for(let xt=0,it=Pn.length;xt<it;xt++)zt=Pn[xt],xe?Et&&t.texSubImage2D(i.TEXTURE_2D,xt,0,0,zt.width,zt.height,Mt,En,zt.data):t.texImage2D(i.TEXTURE_2D,xt,Tn,zt.width,zt.height,0,Mt,En,zt.data);V.generateMipmaps=!1}else xe?(It&&t.texStorage2D(i.TEXTURE_2D,Ct,Tn,ht.width,ht.height),Et&&tt(V,ht,Mt,En)):t.texImage2D(i.TEXTURE_2D,0,Tn,ht.width,ht.height,0,Mt,En,ht.data);else if(V.isCompressedTexture)if(V.isCompressedArrayTexture){xe&&It&&t.texStorage3D(i.TEXTURE_2D_ARRAY,Ct,Tn,Pn[0].width,Pn[0].height,ht.depth);for(let xt=0,it=Pn.length;xt<it;xt++)if(zt=Pn[xt],V.format!==d.wk1)if(Mt!==null)if(xe){if(Et)if(V.layerUpdates.size>0){const Yt=(0,d.EcG)(zt.width,zt.height,V.format,V.type);for(const On of V.layerUpdates){const Bi=zt.data.subarray(On*Yt/zt.data.BYTES_PER_ELEMENT,(On+1)*Yt/zt.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,xt,0,0,On,zt.width,zt.height,1,Mt,Bi)}V.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,xt,0,0,0,zt.width,zt.height,ht.depth,Mt,zt.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,xt,Tn,zt.width,zt.height,ht.depth,0,zt.data,0,0);else(0,d.ZK6)("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else xe?Et&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,xt,0,0,0,zt.width,zt.height,ht.depth,Mt,En,zt.data):t.texImage3D(i.TEXTURE_2D_ARRAY,xt,Tn,zt.width,zt.height,ht.depth,0,Mt,En,zt.data)}else{xe&&It&&t.texStorage2D(i.TEXTURE_2D,Ct,Tn,Pn[0].width,Pn[0].height);for(let xt=0,it=Pn.length;xt<it;xt++)zt=Pn[xt],V.format!==d.wk1?Mt!==null?xe?Et&&t.compressedTexSubImage2D(i.TEXTURE_2D,xt,0,0,zt.width,zt.height,Mt,zt.data):t.compressedTexImage2D(i.TEXTURE_2D,xt,Tn,zt.width,zt.height,0,zt.data):(0,d.ZK6)("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):xe?Et&&t.texSubImage2D(i.TEXTURE_2D,xt,0,0,zt.width,zt.height,Mt,En,zt.data):t.texImage2D(i.TEXTURE_2D,xt,Tn,zt.width,zt.height,0,Mt,En,zt.data)}else if(V.isDataArrayTexture)if(xe){if(It&&t.texStorage3D(i.TEXTURE_2D_ARRAY,Ct,Tn,ht.width,ht.height,ht.depth),Et)if(V.layerUpdates.size>0){const xt=(0,d.EcG)(ht.width,ht.height,V.format,V.type);for(const it of V.layerUpdates){const Yt=ht.data.subarray(it*xt/ht.data.BYTES_PER_ELEMENT,(it+1)*xt/ht.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,it,ht.width,ht.height,1,Mt,En,Yt)}V.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,ht.width,ht.height,ht.depth,Mt,En,ht.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,Tn,ht.width,ht.height,ht.depth,0,Mt,En,ht.data);else if(V.isData3DTexture)xe?(It&&t.texStorage3D(i.TEXTURE_3D,Ct,Tn,ht.width,ht.height,ht.depth),Et&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,ht.width,ht.height,ht.depth,Mt,En,ht.data)):t.texImage3D(i.TEXTURE_3D,0,Tn,ht.width,ht.height,ht.depth,0,Mt,En,ht.data);else if(V.isFramebufferTexture){if(It)if(xe)t.texStorage2D(i.TEXTURE_2D,Ct,Tn,ht.width,ht.height);else{let xt=ht.width,it=ht.height;for(let Yt=0;Yt<Ct;Yt++)t.texImage2D(i.TEXTURE_2D,Yt,Tn,xt,it,0,Mt,En,null),xt>>=1,it>>=1}}else if(Pn.length>0){if(xe&&It){const xt=zn(Pn[0]);t.texStorage2D(i.TEXTURE_2D,Ct,Tn,xt.width,xt.height)}for(let xt=0,it=Pn.length;xt<it;xt++)zt=Pn[xt],xe?Et&&t.texSubImage2D(i.TEXTURE_2D,xt,0,0,Mt,En,zt):t.texImage2D(i.TEXTURE_2D,xt,Tn,Mt,En,zt);V.generateMipmaps=!1}else if(xe){if(It){const xt=zn(ht);t.texStorage2D(i.TEXTURE_2D,Ct,Tn,xt.width,xt.height)}Et&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,Mt,En,ht)}else t.texImage2D(i.TEXTURE_2D,0,Tn,Mt,En,ht);C(V)&&E(et),ln.__version=je.version,V.onUpdate&&V.onUpdate(V)}J.__version=V.version}function Ne(J,V,Ce){if(V.image.length!==6)return;const et=Ot(J,V),ct=V.source;t.bindTexture(i.TEXTURE_CUBE_MAP,J.__webglTexture,i.TEXTURE0+Ce);const je=r.get(ct);if(ct.version!==je.__version||et===!0){t.activeTexture(i.TEXTURE0+Ce);const ln=d.epp.getPrimaries(d.epp.workingColorSpace),Lt=V.colorSpace===d.aCh?null:d.epp.getPrimaries(V.colorSpace),vn=V.colorSpace===d.aCh||ln===Lt?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,V.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,V.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,V.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,vn);const rn=V.isCompressedTexture||V.image[0].isCompressedTexture,ht=V.image[0]&&V.image[0].isDataTexture,Mt=[];for(let it=0;it<6;it++)!rn&&!ht?Mt[it]=P(V.image[it],!0,s.maxCubemapSize):Mt[it]=ht?V.image[it].image:V.image[it],Mt[it]=yn(V,Mt[it]);const En=Mt[0],Tn=a.convert(V.format,V.colorSpace),zt=a.convert(V.type),Pn=F(V.internalFormat,Tn,zt,V.colorSpace),xe=V.isVideoTexture!==!0,It=je.__version===void 0||et===!0,Et=ct.dataReady;let Ct=K(V,En);yt(i.TEXTURE_CUBE_MAP,V);let xt;if(rn){xe&&It&&t.texStorage2D(i.TEXTURE_CUBE_MAP,Ct,Pn,En.width,En.height);for(let it=0;it<6;it++){xt=Mt[it].mipmaps;for(let Yt=0;Yt<xt.length;Yt++){const On=xt[Yt];V.format!==d.wk1?Tn!==null?xe?Et&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+it,Yt,0,0,On.width,On.height,Tn,On.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+it,Yt,Pn,On.width,On.height,0,On.data):(0,d.ZK6)("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):xe?Et&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+it,Yt,0,0,On.width,On.height,Tn,zt,On.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+it,Yt,Pn,On.width,On.height,0,Tn,zt,On.data)}}}else{if(xt=V.mipmaps,xe&&It){xt.length>0&&Ct++;const it=zn(Mt[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,Ct,Pn,it.width,it.height)}for(let it=0;it<6;it++)if(ht){xe?Et&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+it,0,0,0,Mt[it].width,Mt[it].height,Tn,zt,Mt[it].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+it,0,Pn,Mt[it].width,Mt[it].height,0,Tn,zt,Mt[it].data);for(let Yt=0;Yt<xt.length;Yt++){const Bi=xt[Yt].image[it].image;xe?Et&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+it,Yt+1,0,0,Bi.width,Bi.height,Tn,zt,Bi.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+it,Yt+1,Pn,Bi.width,Bi.height,0,Tn,zt,Bi.data)}}else{xe?Et&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+it,0,0,0,Tn,zt,Mt[it]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+it,0,Pn,Tn,zt,Mt[it]);for(let Yt=0;Yt<xt.length;Yt++){const On=xt[Yt];xe?Et&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+it,Yt+1,0,0,Tn,zt,On.image[it]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+it,Yt+1,Pn,Tn,zt,On.image[it])}}}C(V)&&E(i.TEXTURE_CUBE_MAP),je.__version=ct.version,V.onUpdate&&V.onUpdate(V)}J.__version=V.version}function gt(J,V,Ce,et,ct,je){const ln=a.convert(Ce.format,Ce.colorSpace),Lt=a.convert(Ce.type),vn=F(Ce.internalFormat,ln,Lt,Ce.colorSpace),rn=r.get(V),ht=r.get(Ce);if(ht.__renderTarget=V,!rn.__hasExternalTextures){const Mt=Math.max(1,V.width>>je),En=Math.max(1,V.height>>je);ct===i.TEXTURE_3D||ct===i.TEXTURE_2D_ARRAY?t.texImage3D(ct,je,vn,Mt,En,V.depth,0,ln,Lt,null):t.texImage2D(ct,je,vn,Mt,En,0,ln,Lt,null)}t.bindFramebuffer(i.FRAMEBUFFER,J),Jt(V)?h.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,et,ct,ht.__webglTexture,0,li(V)):(ct===i.TEXTURE_2D||ct>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&ct<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,et,ct,ht.__webglTexture,je),t.bindFramebuffer(i.FRAMEBUFFER,null)}function qt(J,V,Ce){if(i.bindRenderbuffer(i.RENDERBUFFER,J),V.depthBuffer){const et=V.depthTexture,ct=et&&et.isDepthTexture?et.type:null,je=W(V.stencilBuffer,ct),ln=V.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Lt=li(V);Jt(V)?h.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Lt,je,V.width,V.height):Ce?i.renderbufferStorageMultisample(i.RENDERBUFFER,Lt,je,V.width,V.height):i.renderbufferStorage(i.RENDERBUFFER,je,V.width,V.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,ln,i.RENDERBUFFER,J)}else{const et=V.textures;for(let ct=0;ct<et.length;ct++){const je=et[ct],ln=a.convert(je.format,je.colorSpace),Lt=a.convert(je.type),vn=F(je.internalFormat,ln,Lt,je.colorSpace),rn=li(V);Ce&&Jt(V)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,rn,vn,V.width,V.height):Jt(V)?h.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,rn,vn,V.width,V.height):i.renderbufferStorage(i.RENDERBUFFER,vn,V.width,V.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Nt(J,V){if(V&&V.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(i.FRAMEBUFFER,J),!(V.depthTexture&&V.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const et=r.get(V.depthTexture);et.__renderTarget=V,(!et.__webglTexture||V.depthTexture.image.width!==V.width||V.depthTexture.image.height!==V.height)&&(V.depthTexture.image.width=V.width,V.depthTexture.image.height=V.height,V.depthTexture.needsUpdate=!0),He(V.depthTexture,0);const ct=et.__webglTexture,je=li(V);if(V.depthTexture.format===d.qkB)Jt(V)?h.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,ct,0,je):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,ct,0);else if(V.depthTexture.format===d.brP)Jt(V)?h.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,ct,0,je):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,ct,0);else throw new Error("Unknown depthTexture format")}function en(J){const V=r.get(J),Ce=J.isWebGLCubeRenderTarget===!0;if(V.__boundDepthTexture!==J.depthTexture){const et=J.depthTexture;if(V.__depthDisposeCallback&&V.__depthDisposeCallback(),et){const ct=()=>{delete V.__boundDepthTexture,delete V.__depthDisposeCallback,et.removeEventListener("dispose",ct)};et.addEventListener("dispose",ct),V.__depthDisposeCallback=ct}V.__boundDepthTexture=et}if(J.depthTexture&&!V.__autoAllocateDepthBuffer){if(Ce)throw new Error("target.depthTexture not supported in Cube render targets");const et=J.texture.mipmaps;et&&et.length>0?Nt(V.__webglFramebuffer[0],J):Nt(V.__webglFramebuffer,J)}else if(Ce){V.__webglDepthbuffer=[];for(let et=0;et<6;et++)if(t.bindFramebuffer(i.FRAMEBUFFER,V.__webglFramebuffer[et]),V.__webglDepthbuffer[et]===void 0)V.__webglDepthbuffer[et]=i.createRenderbuffer(),qt(V.__webglDepthbuffer[et],J,!1);else{const ct=J.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,je=V.__webglDepthbuffer[et];i.bindRenderbuffer(i.RENDERBUFFER,je),i.framebufferRenderbuffer(i.FRAMEBUFFER,ct,i.RENDERBUFFER,je)}}else{const et=J.texture.mipmaps;if(et&&et.length>0?t.bindFramebuffer(i.FRAMEBUFFER,V.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,V.__webglFramebuffer),V.__webglDepthbuffer===void 0)V.__webglDepthbuffer=i.createRenderbuffer(),qt(V.__webglDepthbuffer,J,!1);else{const ct=J.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,je=V.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,je),i.framebufferRenderbuffer(i.FRAMEBUFFER,ct,i.RENDERBUFFER,je)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function vi(J,V,Ce){const et=r.get(J);V!==void 0&&gt(et.__webglFramebuffer,J,J.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),Ce!==void 0&&en(J)}function Dn(J){const V=J.texture,Ce=r.get(J),et=r.get(V);J.addEventListener("dispose",j);const ct=J.textures,je=J.isWebGLCubeRenderTarget===!0,ln=ct.length>1;if(ln||(et.__webglTexture===void 0&&(et.__webglTexture=i.createTexture()),et.__version=V.version,c.memory.textures++),je){Ce.__webglFramebuffer=[];for(let Lt=0;Lt<6;Lt++)if(V.mipmaps&&V.mipmaps.length>0){Ce.__webglFramebuffer[Lt]=[];for(let vn=0;vn<V.mipmaps.length;vn++)Ce.__webglFramebuffer[Lt][vn]=i.createFramebuffer()}else Ce.__webglFramebuffer[Lt]=i.createFramebuffer()}else{if(V.mipmaps&&V.mipmaps.length>0){Ce.__webglFramebuffer=[];for(let Lt=0;Lt<V.mipmaps.length;Lt++)Ce.__webglFramebuffer[Lt]=i.createFramebuffer()}else Ce.__webglFramebuffer=i.createFramebuffer();if(ln)for(let Lt=0,vn=ct.length;Lt<vn;Lt++){const rn=r.get(ct[Lt]);rn.__webglTexture===void 0&&(rn.__webglTexture=i.createTexture(),c.memory.textures++)}if(J.samples>0&&Jt(J)===!1){Ce.__webglMultisampledFramebuffer=i.createFramebuffer(),Ce.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,Ce.__webglMultisampledFramebuffer);for(let Lt=0;Lt<ct.length;Lt++){const vn=ct[Lt];Ce.__webglColorRenderbuffer[Lt]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,Ce.__webglColorRenderbuffer[Lt]);const rn=a.convert(vn.format,vn.colorSpace),ht=a.convert(vn.type),Mt=F(vn.internalFormat,rn,ht,vn.colorSpace,J.isXRRenderTarget===!0),En=li(J);i.renderbufferStorageMultisample(i.RENDERBUFFER,En,Mt,J.width,J.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Lt,i.RENDERBUFFER,Ce.__webglColorRenderbuffer[Lt])}i.bindRenderbuffer(i.RENDERBUFFER,null),J.depthBuffer&&(Ce.__webglDepthRenderbuffer=i.createRenderbuffer(),qt(Ce.__webglDepthRenderbuffer,J,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(je){t.bindTexture(i.TEXTURE_CUBE_MAP,et.__webglTexture),yt(i.TEXTURE_CUBE_MAP,V);for(let Lt=0;Lt<6;Lt++)if(V.mipmaps&&V.mipmaps.length>0)for(let vn=0;vn<V.mipmaps.length;vn++)gt(Ce.__webglFramebuffer[Lt][vn],J,V,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+Lt,vn);else gt(Ce.__webglFramebuffer[Lt],J,V,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+Lt,0);C(V)&&E(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(ln){for(let Lt=0,vn=ct.length;Lt<vn;Lt++){const rn=ct[Lt],ht=r.get(rn);let Mt=i.TEXTURE_2D;(J.isWebGL3DRenderTarget||J.isWebGLArrayRenderTarget)&&(Mt=J.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(Mt,ht.__webglTexture),yt(Mt,rn),gt(Ce.__webglFramebuffer,J,rn,i.COLOR_ATTACHMENT0+Lt,Mt,0),C(rn)&&E(Mt)}t.unbindTexture()}else{let Lt=i.TEXTURE_2D;if((J.isWebGL3DRenderTarget||J.isWebGLArrayRenderTarget)&&(Lt=J.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(Lt,et.__webglTexture),yt(Lt,V),V.mipmaps&&V.mipmaps.length>0)for(let vn=0;vn<V.mipmaps.length;vn++)gt(Ce.__webglFramebuffer[vn],J,V,i.COLOR_ATTACHMENT0,Lt,vn);else gt(Ce.__webglFramebuffer,J,V,i.COLOR_ATTACHMENT0,Lt,0);C(V)&&E(Lt),t.unbindTexture()}J.depthBuffer&&en(J)}function si(J){const V=J.textures;for(let Ce=0,et=V.length;Ce<et;Ce++){const ct=V[Ce];if(C(ct)){const je=D(J),ln=r.get(ct).__webglTexture;t.bindTexture(je,ln),E(je),t.unbindTexture()}}}const me=[],Vn=[];function Un(J){if(J.samples>0){if(Jt(J)===!1){const V=J.textures,Ce=J.width,et=J.height;let ct=i.COLOR_BUFFER_BIT;const je=J.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ln=r.get(J),Lt=V.length>1;if(Lt)for(let rn=0;rn<V.length;rn++)t.bindFramebuffer(i.FRAMEBUFFER,ln.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+rn,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,ln.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+rn,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,ln.__webglMultisampledFramebuffer);const vn=J.texture.mipmaps;vn&&vn.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ln.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ln.__webglFramebuffer);for(let rn=0;rn<V.length;rn++){if(J.resolveDepthBuffer&&(J.depthBuffer&&(ct|=i.DEPTH_BUFFER_BIT),J.stencilBuffer&&J.resolveStencilBuffer&&(ct|=i.STENCIL_BUFFER_BIT)),Lt){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,ln.__webglColorRenderbuffer[rn]);const ht=r.get(V[rn]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,ht,0)}i.blitFramebuffer(0,0,Ce,et,0,0,Ce,et,ct,i.NEAREST),f===!0&&(me.length=0,Vn.length=0,me.push(i.COLOR_ATTACHMENT0+rn),J.depthBuffer&&J.resolveDepthBuffer===!1&&(me.push(je),Vn.push(je),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,Vn)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,me))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),Lt)for(let rn=0;rn<V.length;rn++){t.bindFramebuffer(i.FRAMEBUFFER,ln.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+rn,i.RENDERBUFFER,ln.__webglColorRenderbuffer[rn]);const ht=r.get(V[rn]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,ln.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+rn,i.TEXTURE_2D,ht,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,ln.__webglMultisampledFramebuffer)}else if(J.depthBuffer&&J.resolveDepthBuffer===!1&&f){const V=J.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[V])}}}function li(J){return Math.min(s.maxSamples,J.samples)}function Jt(J){const V=r.get(J);return J.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&V.__useRenderToTexture!==!1}function Xi(J){const V=c.render.frame;x.get(J)!==V&&(x.set(J,V),J.update())}function yn(J,V){const Ce=J.colorSpace,et=J.format,ct=J.type;return J.isCompressedTexture===!0||J.isVideoTexture===!0||Ce!==d.GUF&&Ce!==d.aCh&&(d.epp.getTransfer(Ce)===d.j17?(et!==d.wk1||ct!==d.ywz)&&(0,d.ZK6)("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):(0,d.vUy)("WebGLTextures: Unsupported texture color space:",Ce)),V}function zn(J){return typeof HTMLImageElement!="undefined"&&J instanceof HTMLImageElement?(m.width=J.naturalWidth||J.width,m.height=J.naturalHeight||J.height):typeof VideoFrame!="undefined"&&J instanceof VideoFrame?(m.width=J.displayWidth,m.height=J.displayHeight):(m.width=J.width,m.height=J.height),m}this.allocateTextureUnit=Ee,this.resetTextureUnits=be,this.setTexture2D=He,this.setTexture2DArray=Be,this.setTexture3D=ft,this.setTextureCube=$e,this.rebindTextures=vi,this.setupRenderTarget=Dn,this.updateRenderTargetMipmap=si,this.updateMultisampleRenderTarget=Un,this.setupDepthRenderbuffer=en,this.setupFrameBufferTexture=gt,this.useMultisampledRTT=Jt}function oo(i,e){function t(r,s=d.aCh){let a;const c=d.epp.getTransfer(s);if(r===d.ywz)return i.UNSIGNED_BYTE;if(r===d.k0A)return i.UNSIGNED_SHORT_4_4_4_4;if(r===d.irR)return i.UNSIGNED_SHORT_5_5_5_1;if(r===d.tQZ)return i.UNSIGNED_INT_5_9_9_9_REV;if(r===d.dVD)return i.UNSIGNED_INT_10F_11F_11F_REV;if(r===d.T95)return i.BYTE;if(r===d.iAb)return i.SHORT;if(r===d.LsT)return i.UNSIGNED_SHORT;if(r===d.Kz5)return i.INT;if(r===d.JQ4)return i.UNSIGNED_INT;if(r===d.VzW)return i.FLOAT;if(r===d.cLu)return i.HALF_FLOAT;if(r===d.OTo)return i.ALPHA;if(r===d.UCm)return i.RGB;if(r===d.wk1)return i.RGBA;if(r===d.qkB)return i.DEPTH_COMPONENT;if(r===d.brP)return i.DEPTH_STENCIL;if(r===d.hEm)return i.RED;if(r===d.D9w)return i.RED_INTEGER;if(r===d.av9)return i.RG;if(r===d.CtA)return i.RG_INTEGER;if(r===d.E2K)return i.RGBA_INTEGER;if(r===d.wuA||r===d.BFQ||r===d.v3W||r===d.ILR)if(c===d.j17)if(a=e.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(r===d.wuA)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(r===d.BFQ)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(r===d.v3W)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(r===d.ILR)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=e.get("WEBGL_compressed_texture_s3tc"),a!==null){if(r===d.wuA)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(r===d.BFQ)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(r===d.v3W)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(r===d.ILR)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(r===d._AM||r===d.vCx||r===d.eaV||r===d.CaW)if(a=e.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(r===d._AM)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(r===d.vCx)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(r===d.eaV)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(r===d.CaW)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(r===d.fto||r===d.l0P||r===d.ekQ)if(a=e.get("WEBGL_compressed_texture_etc"),a!==null){if(r===d.fto||r===d.l0P)return c===d.j17?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(r===d.ekQ)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(r===d.ptH||r===d.jZA||r===d.y2t||r===d.gi4||r===d.Djp||r===d.BG$||r===d.NYV||r===d.xJs||r===d.pKu||r===d.GG6||r===d.Gih||r===d.FUD||r===d.iiP||r===d.SvJ)if(a=e.get("WEBGL_compressed_texture_astc"),a!==null){if(r===d.ptH)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(r===d.jZA)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(r===d.y2t)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(r===d.gi4)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(r===d.Djp)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(r===d.BG$)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(r===d.NYV)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(r===d.xJs)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(r===d.pKu)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(r===d.GG6)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(r===d.Gih)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(r===d.FUD)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(r===d.iiP)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(r===d.SvJ)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(r===d.bsb||r===d.f2y||r===d.QO2)if(a=e.get("EXT_texture_compression_bptc"),a!==null){if(r===d.bsb)return c===d.j17?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(r===d.f2y)return a.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(r===d.QO2)return a.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(r===d.HdW||r===d.vuL||r===d.ZTh||r===d.lGU)if(a=e.get("EXT_texture_compression_rgtc"),a!==null){if(r===d.HdW)return a.COMPRESSED_RED_RGTC1_EXT;if(r===d.vuL)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(r===d.ZTh)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(r===d.lGU)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return r===d.wJv?i.UNSIGNED_INT_24_8:i[r]!==void 0?i[r]:null}return{convert:t}}const cp=`
void main() {
gl_Position = vec4( position, 1.0 );
}`,Qy=`
uniform sampler2DArray depthColor;
uniform float depthWidth;
uniform float depthHeight;
void main() {
vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight );
if ( coord.x >= 1.0 ) {
gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r;
} else {
gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r;
}
}`;class lp{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const r=new d.xnb(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=r}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,r=new d.jyz({vertexShader:cp,fragmentShader:Qy,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new d.Kj0(new d._12(20,20),r)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Jh extends d.pBf{constructor(e,t){super();const r=this;let s=null,a=1,c=null,h="local-floor",f=1,m=null,x=null,_=null,v=null,T=null,w=null;const P=typeof XRWebGLBinding!="undefined",C=new lp,E={},D=t.getContextAttributes();let F=null,W=null;const K=[],U=[],j=new d.FM8;let oe=null;const k=new d.cPb;k.viewport=new d.Ltg;const O=new d.cPb;O.viewport=new d.Ltg;const le=[k,O],be=new d.HkE;let Ee=null,Pe=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(ve){let Ne=K[ve];return Ne===void 0&&(Ne=new d.NiX,K[ve]=Ne),Ne.getTargetRaySpace()},this.getControllerGrip=function(ve){let Ne=K[ve];return Ne===void 0&&(Ne=new d.NiX,K[ve]=Ne),Ne.getGripSpace()},this.getHand=function(ve){let Ne=K[ve];return Ne===void 0&&(Ne=new d.NiX,K[ve]=Ne),Ne.getHandSpace()};function He(ve){const Ne=U.indexOf(ve.inputSource);if(Ne===-1)return;const gt=K[Ne];gt!==void 0&&(gt.update(ve.inputSource,ve.frame,m||c),gt.dispatchEvent({type:ve.type,data:ve.inputSource}))}function Be(){s.removeEventListener("select",He),s.removeEventListener("selectstart",He),s.removeEventListener("selectend",He),s.removeEventListener("squeeze",He),s.removeEventListener("squeezestart",He),s.removeEventListener("squeezeend",He),s.removeEventListener("end",Be),s.removeEventListener("inputsourceschange",ft);for(let ve=0;ve<K.length;ve++){const Ne=U[ve];Ne!==null&&(U[ve]=null,K[ve].disconnect(Ne))}Ee=null,Pe=null,C.reset();for(const ve in E)delete E[ve];e.setRenderTarget(F),T=null,v=null,_=null,s=null,W=null,tt.stop(),r.isPresenting=!1,e.setPixelRatio(oe),e.setSize(j.width,j.height,!1),r.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(ve){a=ve,r.isPresenting===!0&&(0,d.ZK6)("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(ve){h=ve,r.isPresenting===!0&&(0,d.ZK6)("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return m||c},this.setReferenceSpace=function(ve){m=ve},this.getBaseLayer=function(){return v!==null?v:T},this.getBinding=function(){return _===null&&P&&(_=new XRWebGLBinding(s,t)),_},this.getFrame=function(){return w},this.getSession=function(){return s},this.setSession=function(ve){return nn(this,null,function*(){if(s=ve,s!==null){if(F=e.getRenderTarget(),s.addEventListener("select",He),s.addEventListener("selectstart",He),s.addEventListener("selectend",He),s.addEventListener("squeeze",He),s.addEventListener("squeezestart",He),s.addEventListener("squeezeend",He),s.addEventListener("end",Be),s.addEventListener("inputsourceschange",ft),D.xrCompatible!==!0&&(yield t.makeXRCompatible()),oe=e.getPixelRatio(),e.getSize(j),P&&"createProjectionLayer"in XRWebGLBinding.prototype){let gt=null,qt=null,Nt=null;D.depth&&(Nt=D.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,gt=D.stencil?d.brP:d.qkB,qt=D.stencil?d.wJv:d.JQ4);const en={colorFormat:t.RGBA8,depthFormat:Nt,scaleFactor:a};_=this.getBinding(),v=_.createProjectionLayer(en),s.updateRenderState({layers:[v]}),e.setPixelRatio(1),e.setSize(v.textureWidth,v.textureHeight,!1),W=new d.dd2(v.textureWidth,v.textureHeight,{format:d.wk1,type:d.ywz,depthTexture:new d.$YQ(v.textureWidth,v.textureHeight,qt,void 0,void 0,void 0,void 0,void 0,void 0,gt),stencilBuffer:D.stencil,colorSpace:e.outputColorSpace,samples:D.antialias?4:0,resolveDepthBuffer:v.ignoreDepthValues===!1,resolveStencilBuffer:v.ignoreDepthValues===!1})}else{const gt={antialias:D.antialias,alpha:!0,depth:D.depth,stencil:D.stencil,framebufferScaleFactor:a};T=new XRWebGLLayer(s,t,gt),s.updateRenderState({baseLayer:T}),e.setPixelRatio(1),e.setSize(T.framebufferWidth,T.framebufferHeight,!1),W=new d.dd2(T.framebufferWidth,T.framebufferHeight,{format:d.wk1,type:d.ywz,colorSpace:e.outputColorSpace,stencilBuffer:D.stencil,resolveDepthBuffer:T.ignoreDepthValues===!1,resolveStencilBuffer:T.ignoreDepthValues===!1})}W.isXRRenderTarget=!0,this.setFoveation(f),m=null,c=yield s.requestReferenceSpace(h),tt.setContext(s),tt.start(),r.isPresenting=!0,r.dispatchEvent({type:"sessionstart"})}})},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return C.getDepthTexture()};function ft(ve){for(let Ne=0;Ne<ve.removed.length;Ne++){const gt=ve.removed[Ne],qt=U.indexOf(gt);qt>=0&&(U[qt]=null,K[qt].disconnect(gt))}for(let Ne=0;Ne<ve.added.length;Ne++){const gt=ve.added[Ne];let qt=U.indexOf(gt);if(qt===-1){for(let en=0;en<K.length;en++)if(en>=U.length){U.push(gt),qt=en;break}else if(U[en]===null){U[en]=gt,qt=en;break}if(qt===-1)break}const Nt=K[qt];Nt&&Nt.connect(gt)}}const $e=new d.Pa4,Tt=new d.Pa4;function Pt(ve,Ne,gt){$e.setFromMatrixPosition(Ne.matrixWorld),Tt.setFromMatrixPosition(gt.matrixWorld);const qt=$e.distanceTo(Tt),Nt=Ne.projectionMatrix.elements,en=gt.projectionMatrix.elements,vi=Nt[14]/(Nt[10]-1),Dn=Nt[14]/(Nt[10]+1),si=(Nt[9]+1)/Nt[5],me=(Nt[9]-1)/Nt[5],Vn=(Nt[8]-1)/Nt[0],Un=(en[8]+1)/en[0],li=vi*Vn,Jt=vi*Un,Xi=qt/(-Vn+Un),yn=Xi*-Vn;if(Ne.matrixWorld.decompose(ve.position,ve.quaternion,ve.scale),ve.translateX(yn),ve.translateZ(Xi),ve.matrixWorld.compose(ve.position,ve.quaternion,ve.scale),ve.matrixWorldInverse.copy(ve.matrixWorld).invert(),Nt[10]===-1)ve.projectionMatrix.copy(Ne.projectionMatrix),ve.projectionMatrixInverse.copy(Ne.projectionMatrixInverse);else{const zn=vi+Xi,J=Dn+Xi,V=li-yn,Ce=Jt+(qt-yn),et=si*Dn/J*zn,ct=me*Dn/J*zn;ve.projectionMatrix.makePerspective(V,Ce,et,ct,zn,J),ve.projectionMatrixInverse.copy(ve.projectionMatrix).invert()}}function Ye(ve,Ne){Ne===null?ve.matrixWorld.copy(ve.matrix):ve.matrixWorld.multiplyMatrices(Ne.matrixWorld,ve.matrix),ve.matrixWorldInverse.copy(ve.matrixWorld).invert()}this.updateCamera=function(ve){if(s===null)return;let Ne=ve.near,gt=ve.far;C.texture!==null&&(C.depthNear>0&&(Ne=C.depthNear),C.depthFar>0&&(gt=C.depthFar)),be.near=O.near=k.near=Ne,be.far=O.far=k.far=gt,(Ee!==be.near||Pe!==be.far)&&(s.updateRenderState({depthNear:be.near,depthFar:be.far}),Ee=be.near,Pe=be.far),be.layers.mask=ve.layers.mask|6,k.layers.mask=be.layers.mask&3,O.layers.mask=be.layers.mask&5;const qt=ve.parent,Nt=be.cameras;Ye(be,qt);for(let en=0;en<Nt.length;en++)Ye(Nt[en],qt);Nt.length===2?Pt(be,k,O):be.projectionMatrix.copy(k.projectionMatrix),yt(ve,be,qt)};function yt(ve,Ne,gt){gt===null?ve.matrix.copy(Ne.matrixWorld):(ve.matrix.copy(gt.matrixWorld),ve.matrix.invert(),ve.matrix.multiply(Ne.matrixWorld)),ve.matrix.decompose(ve.position,ve.quaternion,ve.scale),ve.updateMatrixWorld(!0),ve.projectionMatrix.copy(Ne.projectionMatrix),ve.projectionMatrixInverse.copy(Ne.projectionMatrixInverse),ve.isPerspectiveCamera&&(ve.fov=d.I3e*2*Math.atan(1/ve.projectionMatrix.elements[5]),ve.zoom=1)}this.getCamera=function(){return be},this.getFoveation=function(){if(!(v===null&&T===null))return f},this.setFoveation=function(ve){f=ve,v!==null&&(v.fixedFoveation=ve),T!==null&&T.fixedFoveation!==void 0&&(T.fixedFoveation=ve)},this.hasDepthSensing=function(){return C.texture!==null},this.getDepthSensingMesh=function(){return C.getMesh(be)},this.getCameraTexture=function(ve){return E[ve]};let Ot=null;function Mn(ve,Ne){if(x=Ne.getViewerPose(m||c),w=Ne,x!==null){const gt=x.views;T!==null&&(e.setRenderTargetFramebuffer(W,T.framebuffer),e.setRenderTarget(W));let qt=!1;gt.length!==be.cameras.length&&(be.cameras.length=0,qt=!0);for(let Dn=0;Dn<gt.length;Dn++){const si=gt[Dn];let me=null;if(T!==null)me=T.getViewport(si);else{const Un=_.getViewSubImage(v,si);me=Un.viewport,Dn===0&&(e.setRenderTargetTextures(W,Un.colorTexture,Un.depthStencilTexture),e.setRenderTarget(W))}let Vn=le[Dn];Vn===void 0&&(Vn=new d.cPb,Vn.layers.enable(Dn),Vn.viewport=new d.Ltg,le[Dn]=Vn),Vn.matrix.fromArray(si.transform.matrix),Vn.matrix.decompose(Vn.position,Vn.quaternion,Vn.scale),Vn.projectionMatrix.fromArray(si.projectionMatrix),Vn.projectionMatrixInverse.copy(Vn.projectionMatrix).invert(),Vn.viewport.set(me.x,me.y,me.width,me.height),Dn===0&&(be.matrix.copy(Vn.matrix),be.matrix.decompose(be.position,be.quaternion,be.scale)),qt===!0&&be.cameras.push(Vn)}const Nt=s.enabledFeatures;if(Nt&&Nt.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&P){_=r.getBinding();const Dn=_.getDepthInformation(gt[0]);Dn&&Dn.isValid&&Dn.texture&&C.init(Dn,s.renderState)}if(Nt&&Nt.includes("camera-access")&&P){e.state.unbindTexture(),_=r.getBinding();for(let Dn=0;Dn<gt.length;Dn++){const si=gt[Dn].camera;if(si){let me=E[si];me||(me=new d.xnb,E[si]=me);const Vn=_.getCameraImage(si);me.sourceTexture=Vn}}}}for(let gt=0;gt<K.length;gt++){const qt=U[gt],Nt=K[gt];qt!==null&&Nt!==void 0&&Nt.update(qt,Ne,m||c)}Ot&&Ot(ve,Ne),Ne.detectedPlanes&&r.dispatchEvent({type:"planesdetected",data:Ne}),w=null}const tt=new Lg;tt.setAnimationLoop(Mn),this.setAnimationLoop=function(ve){Ot=ve},this.dispose=function(){}}}const Bo=new d.USm,up=new d.yGw;function hp(i,e){function t(C,E){C.matrixAutoUpdate===!0&&C.updateMatrix(),E.value.copy(C.matrix)}function r(C,E){E.color.getRGB(C.fogColor.value,(0,d.oDz)(i)),E.isFog?(C.fogNear.value=E.near,C.fogFar.value=E.far):E.isFogExp2&&(C.fogDensity.value=E.density)}function s(C,E,D,F,W){E.isMeshBasicMaterial||E.isMeshLambertMaterial?a(C,E):E.isMeshToonMaterial?(a(C,E),_(C,E)):E.isMeshPhongMaterial?(a(C,E),x(C,E)):E.isMeshStandardMaterial?(a(C,E),v(C,E),E.isMeshPhysicalMaterial&&T(C,E,W)):E.isMeshMatcapMaterial?(a(C,E),w(C,E)):E.isMeshDepthMaterial?a(C,E):E.isMeshDistanceMaterial?(a(C,E),P(C,E)):E.isMeshNormalMaterial?a(C,E):E.isLineBasicMaterial?(c(C,E),E.isLineDashedMaterial&&h(C,E)):E.isPointsMaterial?f(C,E,D,F):E.isSpriteMaterial?m(C,E):E.isShadowMaterial?(C.color.value.copy(E.color),C.opacity.value=E.opacity):E.isShaderMaterial&&(E.uniformsNeedUpdate=!1)}function a(C,E){C.opacity.value=E.opacity,E.color&&C.diffuse.value.copy(E.color),E.emissive&&C.emissive.value.copy(E.emissive).multiplyScalar(E.emissiveIntensity),E.map&&(C.map.value=E.map,t(E.map,C.mapTransform)),E.alphaMap&&(C.alphaMap.value=E.alphaMap,t(E.alphaMap,C.alphaMapTransform)),E.bumpMap&&(C.bumpMap.value=E.bumpMap,t(E.bumpMap,C.bumpMapTransform),C.bumpScale.value=E.bumpScale,E.side===d._Li&&(C.bumpScale.value*=-1)),E.normalMap&&(C.normalMap.value=E.normalMap,t(E.normalMap,C.normalMapTransform),C.normalScale.value.copy(E.normalScale),E.side===d._Li&&C.normalScale.value.negate()),E.displacementMap&&(C.displacementMap.value=E.displacementMap,t(E.displacementMap,C.displacementMapTransform),C.displacementScale.value=E.displacementScale,C.displacementBias.value=E.displacementBias),E.emissiveMap&&(C.emissiveMap.value=E.emissiveMap,t(E.emissiveMap,C.emissiveMapTransform)),E.specularMap&&(C.specularMap.value=E.specularMap,t(E.specularMap,C.specularMapTransform)),E.alphaTest>0&&(C.alphaTest.value=E.alphaTest);const D=e.get(E),F=D.envMap,W=D.envMapRotation;F&&(C.envMap.value=F,Bo.copy(W),Bo.x*=-1,Bo.y*=-1,Bo.z*=-1,F.isCubeTexture&&F.isRenderTargetTexture===!1&&(Bo.y*=-1,Bo.z*=-1),C.envMapRotation.value.setFromMatrix4(up.makeRotationFromEuler(Bo)),C.flipEnvMap.value=F.isCubeTexture&&F.isRenderTargetTexture===!1?-1:1,C.reflectivity.value=E.reflectivity,C.ior.value=E.ior,C.refractionRatio.value=E.refractionRatio),E.lightMap&&(C.lightMap.value=E.lightMap,C.lightMapIntensity.value=E.lightMapIntensity,t(E.lightMap,C.lightMapTransform)),E.aoMap&&(C.aoMap.value=E.aoMap,C.aoMapIntensity.value=E.aoMapIntensity,t(E.aoMap,C.aoMapTransform))}function c(C,E){C.diffuse.value.copy(E.color),C.opacity.value=E.opacity,E.map&&(C.map.value=E.map,t(E.map,C.mapTransform))}function h(C,E){C.dashSize.value=E.dashSize,C.totalSize.value=E.dashSize+E.gapSize,C.scale.value=E.scale}function f(C,E,D,F){C.diffuse.value.copy(E.color),C.opacity.value=E.opacity,C.size.value=E.size*D,C.scale.value=F*.5,E.map&&(C.map.value=E.map,t(E.map,C.uvTransform)),E.alphaMap&&(C.alphaMap.value=E.alphaMap,t(E.alphaMap,C.alphaMapTransform)),E.alphaTest>0&&(C.alphaTest.value=E.alphaTest)}function m(C,E){C.diffuse.value.copy(E.color),C.opacity.value=E.opacity,C.rotation.value=E.rotation,E.map&&(C.map.value=E.map,t(E.map,C.mapTransform)),E.alphaMap&&(C.alphaMap.value=E.alphaMap,t(E.alphaMap,C.alphaMapTransform)),E.alphaTest>0&&(C.alphaTest.value=E.alphaTest)}function x(C,E){C.specular.value.copy(E.specular),C.shininess.value=Math.max(E.shininess,1e-4)}function _(C,E){E.gradientMap&&(C.gradientMap.value=E.gradientMap)}function v(C,E){C.metalness.value=E.metalness,E.metalnessMap&&(C.metalnessMap.value=E.metalnessMap,t(E.metalnessMap,C.metalnessMapTransform)),C.roughness.value=E.roughness,E.roughnessMap&&(C.roughnessMap.value=E.roughnessMap,t(E.roughnessMap,C.roughnessMapTransform)),E.envMap&&(C.envMapIntensity.value=E.envMapIntensity)}function T(C,E,D){C.ior.value=E.ior,E.sheen>0&&(C.sheenColor.value.copy(E.sheenColor).multiplyScalar(E.sheen),C.sheenRoughness.value=E.sheenRoughness,E.sheenColorMap&&(C.sheenColorMap.value=E.sheenColorMap,t(E.sheenColorMap,C.sheenColorMapTransform)),E.sheenRoughnessMap&&(C.sheenRoughnessMap.value=E.sheenRoughnessMap,t(E.sheenRoughnessMap,C.sheenRoughnessMapTransform))),E.clearcoat>0&&(C.clearcoat.value=E.clearcoat,C.clearcoatRoughness.value=E.clearcoatRoughness,E.clearcoatMap&&(C.clearcoatMap.value=E.clearcoatMap,t(E.clearcoatMap,C.clearcoatMapTransform)),E.clearcoatRoughnessMap&&(C.clearcoatRoughnessMap.value=E.clearcoatRoughnessMap,t(E.clearcoatRoughnessMap,C.clearcoatRoughnessMapTransform)),E.clearcoatNormalMap&&(C.clearcoatNormalMap.value=E.clearcoatNormalMap,t(E.clearcoatNormalMap,C.clearcoatNormalMapTransform),C.clearcoatNormalScale.value.copy(E.clearcoatNormalScale),E.side===d._Li&&C.clearcoatNormalScale.value.negate())),E.dispersion>0&&(C.dispersion.value=E.dispersion),E.iridescence>0&&(C.iridescence.value=E.iridescence,C.iridescenceIOR.value=E.iridescenceIOR,C.iridescenceThicknessMinimum.value=E.iridescenceThicknessRange[0],C.iridescenceThicknessMaximum.value=E.iridescenceThicknessRange[1],E.iridescenceMap&&(C.iridescenceMap.value=E.iridescenceMap,t(E.iridescenceMap,C.iridescenceMapTransform)),E.iridescenceThicknessMap&&(C.iridescenceThicknessMap.value=E.iridescenceThicknessMap,t(E.iridescenceThicknessMap,C.iridescenceThicknessMapTransform))),E.transmission>0&&(C.transmission.value=E.transmission,C.transmissionSamplerMap.value=D.texture,C.transmissionSamplerSize.value.set(D.width,D.height),E.transmissionMap&&(C.transmissionMap.value=E.transmissionMap,t(E.transmissionMap,C.transmissionMapTransform)),C.thickness.value=E.thickness,E.thicknessMap&&(C.thicknessMap.value=E.thicknessMap,t(E.thicknessMap,C.thicknessMapTransform)),C.attenuationDistance.value=E.attenuationDistance,C.attenuationColor.value.copy(E.attenuationColor)),E.anisotropy>0&&(C.anisotropyVector.value.set(E.anisotropy*Math.cos(E.anisotropyRotation),E.anisotropy*Math.sin(E.anisotropyRotation)),E.anisotropyMap&&(C.anisotropyMap.value=E.anisotropyMap,t(E.anisotropyMap,C.anisotropyMapTransform))),C.specularIntensity.value=E.specularIntensity,C.specularColor.value.copy(E.specularColor),E.specularColorMap&&(C.specularColorMap.value=E.specularColorMap,t(E.specularColorMap,C.specularColorMapTransform)),E.specularIntensityMap&&(C.specularIntensityMap.value=E.specularIntensityMap,t(E.specularIntensityMap,C.specularIntensityMapTransform))}function w(C,E){E.matcap&&(C.matcap.value=E.matcap)}function P(C,E){const D=e.get(E).light;C.referencePosition.value.setFromMatrixPosition(D.matrixWorld),C.nearDistance.value=D.shadow.camera.near,C.farDistance.value=D.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:s}}function Jy(i,e,t,r){let s={},a={},c=[];const h=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function f(D,F){const W=F.program;r.uniformBlockBinding(D,W)}function m(D,F){let W=s[D.id];W===void 0&&(w(D),W=x(D),s[D.id]=W,D.addEventListener("dispose",C));const K=F.program;r.updateUBOMapping(D,K);const U=e.render.frame;a[D.id]!==U&&(v(D),a[D.id]=U)}function x(D){const F=_();D.__bindingPointIndex=F;const W=i.createBuffer(),K=D.__size,U=D.usage;return i.bindBuffer(i.UNIFORM_BUFFER,W),i.bufferData(i.UNIFORM_BUFFER,K,U),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,F,W),W}function _(){for(let D=0;D<h;D++)if(c.indexOf(D)===-1)return c.push(D),D;return(0,d.vUy)("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function v(D){const F=s[D.id],W=D.uniforms,K=D.__cache;i.bindBuffer(i.UNIFORM_BUFFER,F);for(let U=0,j=W.length;U<j;U++){const oe=Array.isArray(W[U])?W[U]:[W[U]];for(let k=0,O=oe.length;k<O;k++){const le=oe[k];if(T(le,U,k,K)===!0){const be=le.__offset,Ee=Array.isArray(le.value)?le.value:[le.value];let Pe=0;for(let He=0;He<Ee.length;He++){const Be=Ee[He],ft=P(Be);typeof Be=="number"||typeof Be=="boolean"?(le.__data[0]=Be,i.bufferSubData(i.UNIFORM_BUFFER,be+Pe,le.__data)):Be.isMatrix3?(le.__data[0]=Be.elements[0],le.__data[1]=Be.elements[1],le.__data[2]=Be.elements[2],le.__data[3]=0,le.__data[4]=Be.elements[3],le.__data[5]=Be.elements[4],le.__data[6]=Be.elements[5],le.__data[7]=0,le.__data[8]=Be.elements[6],le.__data[9]=Be.elements[7],le.__data[10]=Be.elements[8],le.__data[11]=0):(Be.toArray(le.__data,Pe),Pe+=ft.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,be,le.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function T(D,F,W,K){const U=D.value,j=F+"_"+W;if(K[j]===void 0)return typeof U=="number"||typeof U=="boolean"?K[j]=U:K[j]=U.clone(),!0;{const oe=K[j];if(typeof U=="number"||typeof U=="boolean"){if(oe!==U)return K[j]=U,!0}else if(oe.equals(U)===!1)return oe.copy(U),!0}return!1}function w(D){const F=D.uniforms;let W=0;const K=16;for(let j=0,oe=F.length;j<oe;j++){const k=Array.isArray(F[j])?F[j]:[F[j]];for(let O=0,le=k.length;O<le;O++){const be=k[O],Ee=Array.isArray(be.value)?be.value:[be.value];for(let Pe=0,He=Ee.length;Pe<He;Pe++){const Be=Ee[Pe],ft=P(Be),$e=W%K,Tt=$e%ft.boundary,Pt=$e+Tt;W+=Tt,Pt!==0&&K-Pt<ft.storage&&(W+=K-Pt),be.__data=new Float32Array(ft.storage/Float32Array.BYTES_PER_ELEMENT),be.__offset=W,W+=ft.storage}}}const U=W%K;return U>0&&(W+=K-U),D.__size=W,D.__cache={},this}function P(D){const F={boundary:0,storage:0};return typeof D=="number"||typeof D=="boolean"?(F.boundary=4,F.storage=4):D.isVector2?(F.boundary=8,F.storage=8):D.isVector3||D.isColor?(F.boundary=16,F.storage=12):D.isVector4?(F.boundary=16,F.storage=16):D.isMatrix3?(F.boundary=48,F.storage=48):D.isMatrix4?(F.boundary=64,F.storage=64):D.isTexture?(0,d.ZK6)("WebGLRenderer: Texture samplers can not be part of an uniforms group."):(0,d.ZK6)("WebGLRenderer: Unsupported uniform value type.",D),F}function C(D){const F=D.target;F.removeEventListener("dispose",C);const W=c.indexOf(F.__bindingPointIndex);c.splice(W,1),i.deleteBuffer(s[F.id]),delete s[F.id],delete a[F.id]}function E(){for(const D in s)i.deleteBuffer(s[D]);c=[],s={},a={}}return{bind:f,update:m,dispose:E}}const x0=new Uint16Array([11481,15204,11534,15171,11808,15015,12385,14843,12894,14716,13396,14600,13693,14483,13976,14366,14237,14171,14405,13961,14511,13770,14605,13598,14687,13444,14760,13305,14822,13066,14876,12857,14923,12675,14963,12517,14997,12379,15025,12230,15049,12023,15070,11843,15086,11687,15100,11551,15111,11433,15120,11330,15127,11217,15132,11060,15135,10922,15138,10801,15139,10695,15139,10600,13012,14923,13020,14917,13064,14886,13176,14800,13349,14666,13513,14526,13724,14398,13960,14230,14200,14020,14383,13827,14488,13651,14583,13491,14667,13348,14740,13132,14803,12908,14856,12713,14901,12542,14938,12394,14968,12241,14992,12017,15010,11822,15024,11654,15034,11507,15041,11380,15044,11269,15044,11081,15042,10913,15037,10764,15031,10635,15023,10520,15014,10419,15003,10330,13657,14676,13658,14673,13670,14660,13698,14622,13750,14547,13834,14442,13956,14317,14112,14093,14291,13889,14407,13704,14499,13538,14586,13389,14664,13201,14733,12966,14792,12758,14842,12577,14882,12418,14915,12272,14940,12033,14959,11826,14972,11646,14980,11490,14983,11355,14983,11212,14979,11008,14971,10830,14961,10675,14950,10540,14936,10420,14923,10315,14909,10204,14894,10041,14089,14460,14090,14459,14096,14452,14112,14431,14141,14388,14186,14305,14252,14130,14341,13941,14399,13756,14467,13585,14539,13430,14610,13272,14677,13026,14737,12808,14790,12617,14833,12449,14869,12303,14896,12065,14916,11845,14929,11655,14937,11490,14939,11347,14936,11184,14930,10970,14921,10783,14912,10621,14900,10480,14885,10356,14867,10247,14848,10062,14827,9894,14805,9745,14400,14208,14400,14206,14402,14198,14406,14174,14415,14122,14427,14035,14444,13913,14469,13767,14504,13613,14548,13463,14598,13324,14651,13082,14704,12858,14752,12658,14795,12483,14831,12330,14860,12106,14881,11875,14895,11675,14903,11501,14905,11351,14903,11178,14900,10953,14892,10757,14880,10589,14865,10442,14847,10313,14827,10162,14805,9965,14782,9792,14757,9642,14731,9507,14562,13883,14562,13883,14563,13877,14566,13862,14570,13830,14576,13773,14584,13689,14595,13582,14613,13461,14637,13336,14668,13120,14704,12897,14741,12695,14776,12516,14808,12358,14835,12150,14856,11910,14870,11701,14878,11519,14882,11361,14884,11187,14880,10951,14871,10748,14858,10572,14842,10418,14823,10286,14801,10099,14777,9897,14751,9722,14725,9567,14696,9430,14666,9309,14702,13604,14702,13604,14702,13600,14703,13591,14705,13570,14707,13533,14709,13477,14712,13400,14718,13305,14727,13106,14743,12907,14762,12716,14784,12539,14807,12380,14827,12190,14844,11943,14855,11727,14863,11539,14870,11376,14871,11204,14868,10960,14858,10748,14845,10565,14829,10406,14809,10269,14786,10058,14761,9852,14734,9671,14705,9512,14674,9374,14641,9253,14608,9076,14821,13366,14821,13365,14821,13364,14821,13358,14821,13344,14821,13320,14819,13252,14817,13145,14815,13011,14814,12858,14817,12698,14823,12539,14832,12389,14841,12214,14850,11968,14856,11750,14861,11558,14866,11390,14867,11226,14862,10972,14853,10754,14840,10565,14823,10401,14803,10259,14780,10032,14754,9820,14725,9635,14694,9473,14661,9333,14627,9203,14593,8988,14557,8798,14923,13014,14922,13014,14922,13012,14922,13004,14920,12987,14919,12957,14915,12907,14909,12834,14902,12738,14894,12623,14888,12498,14883,12370,14880,12203,14878,11970,14875,11759,14873,11569,14874,11401,14872,11243,14865,10986,14855,10762,14842,10568,14825,10401,14804,10255,14781,10017,14754,9799,14725,9611,14692,9445,14658,9301,14623,9139,14587,8920,14548,8729,14509,8562,15008,12672,15008,12672,15008,12671,15007,12667,15005,12656,15001,12637,14997,12605,14989,12556,14978,12490,14966,12407,14953,12313,14940,12136,14927,11934,14914,11742,14903,11563,14896,11401,14889,11247,14879,10992,14866,10767,14851,10570,14833,10400,14812,10252,14789,10007,14761,9784,14731,9592,14698,9424,14663,9279,14627,9088,14588,8868,14548,8676,14508,8508,14467,8360,15080,12386,15080,12386,15079,12385,15078,12383,15076,12378,15072,12367,15066,12347,15057,12315,15045,12253,15030,12138,15012,11998,14993,11845,14972,11685,14951,11530,14935,11383,14920,11228,14904,10981,14887,10762,14870,10567,14850,10397,14827,10248,14803,9997,14774,9771,14743,9578,14710,9407,14674,9259,14637,9048,14596,8826,14555,8632,14514,8464,14471,8317,14427,8182,15139,12008,15139,12008,15138,12008,15137,12007,15135,12003,15130,11990,15124,11969,15115,11929,15102,11872,15086,11794,15064,11693,15041,11581,15013,11459,14987,11336,14966,11170,14944,10944,14921,10738,14898,10552,14875,10387,14850,10239,14824,9983,14794,9758,14762,9563,14728,9392,14692,9244,14653,9014,14611,8791,14569,8597,14526,8427,14481,8281,14436,8110,14391,7885,15188,11617,15188,11617,15187,11617,15186,11618,15183,11617,15179,11612,15173,11601,15163,11581,15150,11546,15133,11495,15110,11427,15083,11346,15051,11246,15024,11057,14996,10868,14967,10687,14938,10517,14911,10362,14882,10206,14853,9956,14821,9737,14787,9543,14752,9375,14715,9228,14675,8980,14632,8760,14589,8565,14544,8395,14498,8248,14451,8049,14404,7824,14357,7630,15228,11298,15228,11298,15227,11299,15226,11301,15223,11303,15219,11302,15213,11299,15204,11290,15191,11271,15174,11217,15150,11129,15119,11015,15087,10886,15057,10744,15024,10599,14990,10455,14957,10318,14924,10143,14891,9911,14856,9701,14820,9516,14782,9352,14744,9200,14703,8946,14659,8725,14615,8533,14568,8366,14521,8220,14472,7992,14423,7770,14374,7578,14315,7408,15260,10819,15260,10819,15259,10822,15258,10826,15256,10832,15251,10836,15246,10841,15237,10838,15225,10821,15207,10788,15183,10734,15151,10660,15120,10571,15087,10469,15049,10359,15012,10249,14974,10041,14937,9837,14900,9647,14860,9475,14820,9320,14779,9147,14736,8902,14691,8688,14646,8499,14598,8335,14549,8189,14499,7940,14448,7720,14397,7529,14347,7363,14256,7218,15285,10410,15285,10411,15285,10413,15284,10418,15282,10425,15278,10434,15272,10442,15264,10449,15252,10445,15235,10433,15210,10403,15179,10358,15149,10301,15113,10218,15073,10059,15033,9894,14991,9726,14951,9565,14909,9413,14865,9273,14822,9073,14777,8845,14730,8641,14682,8459,14633,8300,14583,8129,14531,7883,14479,7670,14426,7482,14373,7321,14305,7176,14201,6939,15305,9939,15305,9940,15305,9945,15304,9955,15302,9967,15298,9989,15293,10010,15286,10033,15274,10044,15258,10045,15233,10022,15205,9975,15174,9903,15136,9808,15095,9697,15053,9578,15009,9451,14965,9327,14918,9198,14871,8973,14825,8766,14775,8579,14725,8408,14675,8259,14622,8058,14569,7821,14515,7615,14460,7435,14405,7276,14350,7108,14256,6866,14149,6653,15321,9444,15321,9445,15321,9448,15320,9458,15317,9470,15314,9490,15310,9515,15302,9540,15292,9562,15276,9579,15251,9577,15226,9559,15195,9519,15156,9463,15116,9389,15071,9304,15025,9208,14978,9023,14927,8838,14878,8661,14827,8496,14774,8344,14722,8206,14667,7973,14612,7749,14556,7555,14499,7382,14443,7229,14385,7025,14322,6791,14210,6588,14100,6409,15333,8920,15333,8921,15332,8927,15332,8943,15329,8965,15326,9002,15322,9048,15316,9106,15307,9162,15291,9204,15267,9221,15244,9221,15212,9196,15175,9134,15133,9043,15088,8930,15040,8801,14990,8665,14938,8526,14886,8391,14830,8261,14775,8087,14719,7866,14661,7664,14603,7482,14544,7322,14485,7178,14426,6936,14367,6713,14281,6517,14166,6348,14054,6198,15341,8360,15341,8361,15341,8366,15341,8379,15339,8399,15336,8431,15332,8473,15326,8527,15318,8585,15302,8632,15281,8670,15258,8690,15227,8690,15191,8664,15149,8612,15104,8543,15055,8456,15001,8360,14948,8259,14892,8122,14834,7923,14776,7734,14716,7558,14656,7397,14595,7250,14534,7070,14472,6835,14410,6628,14350,6443,14243,6283,14125,6135,14010,5889,15348,7715,15348,7717,15348,7725,15347,7745,15345,7780,15343,7836,15339,7905,15334,8e3,15326,8103,15310,8193,15293,8239,15270,8270,15240,8287,15204,8283,15163,8260,15118,8223,15067,8143,15014,8014,14958,7873,14899,7723,14839,7573,14778,7430,14715,7293,14652,7164,14588,6931,14524,6720,14460,6531,14396,6362,14330,6210,14207,6015,14086,5781,13969,5576,15352,7114,15352,7116,15352,7128,15352,7159,15350,7195,15348,7237,15345,7299,15340,7374,15332,7457,15317,7544,15301,7633,15280,7703,15251,7754,15216,7775,15176,7767,15131,7733,15079,7670,15026,7588,14967,7492,14906,7387,14844,7278,14779,7171,14714,6965,14648,6770,14581,6587,14515,6420,14448,6269,14382,6123,14299,5881,14172,5665,14049,5477,13929,5310,15355,6329,15355,6330,15355,6339,15355,6362,15353,6410,15351,6472,15349,6572,15344,6688,15337,6835,15323,6985,15309,7142,15287,7220,15260,7277,15226,7310,15188,7326,15142,7318,15090,7285,15036,7239,14976,7177,14914,7045,14849,6892,14782,6736,14714,6581,14645,6433,14576,6293,14506,6164,14438,5946,14369,5733,14270,5540,14140,5369,14014,5216,13892,5043,15357,5483,15357,5484,15357,5496,15357,5528,15356,5597,15354,5692,15351,5835,15347,6011,15339,6195,15328,6317,15314,6446,15293,6566,15268,6668,15235,6746,15197,6796,15152,6811,15101,6790,15046,6748,14985,6673,14921,6583,14854,6479,14785,6371,14714,6259,14643,6149,14571,5946,14499,5750,14428,5567,14358,5401,14242,5250,14109,5111,13980,4870,13856,4657,15359,4555,15359,4557,15358,4573,15358,4633,15357,4715,15355,4841,15353,5061,15349,5216,15342,5391,15331,5577,15318,5770,15299,5967,15274,6150,15243,6223,15206,6280,15161,6310,15111,6317,15055,6300,14994,6262,14928,6208,14860,6141,14788,5994,14715,5838,14641,5684,14566,5529,14492,5384,14418,5247,14346,5121,14216,4892,14079,4682,13948,4496,13822,4330,15359,3498,15359,3501,15359,3520,15359,3598,15358,3719,15356,3860,15355,4137,15351,4305,15344,4563,15334,4809,15321,5116,15303,5273,15280,5418,15250,5547,15214,5653,15170,5722,15120,5761,15064,5763,15002,5733,14935,5673,14865,5597,14792,5504,14716,5400,14640,5294,14563,5185,14486,5041,14410,4841,14335,4655,14191,4482,14051,4325,13918,4183,13790,4012,15360,2282,15360,2285,15360,2306,15360,2401,15359,2547,15357,2748,15355,3103,15352,3349,15345,3675,15336,4020,15324,4272,15307,4496,15285,4716,15255,4908,15220,5086,15178,5170,15128,5214,15072,5234,15010,5231,14943,5206,14871,5166,14796,5102,14718,4971,14639,4833,14559,4687,14480,4541,14402,4401,14315,4268,14167,4142,14025,3958,13888,3747,13759,3556,15360,923,15360,925,15360,946,15360,1052,15359,1214,15357,1494,15356,1892,15352,2274,15346,2663,15338,3099,15326,3393,15309,3679,15288,3980,15260,4183,15226,4325,15185,4437,15136,4517,15080,4570,15018,4591,14950,4581,14877,4545,14800,4485,14720,4411,14638,4325,14556,4231,14475,4136,14395,3988,14297,3803,14145,3628,13999,3465,13861,3314,13729,3177,15360,263,15360,264,15360,272,15360,325,15359,407,15358,548,15356,780,15352,1144,15347,1580,15339,2099,15328,2425,15312,2795,15292,3133,15264,3329,15232,3517,15191,3689,15143,3819,15088,3923,15025,3978,14956,3999,14882,3979,14804,3931,14722,3855,14639,3756,14554,3645,14470,3529,14388,3409,14279,3289,14124,3173,13975,3055,13834,2848,13701,2658,15360,49,15360,49,15360,52,15360,75,15359,111,15358,201,15356,283,15353,519,15348,726,15340,1045,15329,1415,15314,1795,15295,2173,15269,2410,15237,2649,15197,2866,15150,3054,15095,3140,15032,3196,14963,3228,14888,3236,14808,3224,14725,3191,14639,3146,14553,3088,14466,2976,14382,2836,14262,2692,14103,2549,13952,2409,13808,2278,13674,2154,15360,4,15360,4,15360,4,15360,13,15359,33,15358,59,15357,112,15353,199,15348,302,15341,456,15331,628,15316,827,15297,1082,15272,1332,15241,1601,15202,1851,15156,2069,15101,2172,15039,2256,14970,2314,14894,2348,14813,2358,14728,2344,14640,2311,14551,2263,14463,2203,14376,2133,14247,2059,14084,1915,13930,1761,13784,1609,13648,1464,15360,0,15360,0,15360,0,15360,3,15359,18,15358,26,15357,53,15354,80,15348,97,15341,165,15332,238,15318,326,15299,427,15275,529,15245,654,15207,771,15161,885,15108,994,15046,1089,14976,1170,14900,1229,14817,1266,14731,1284,14641,1282,14550,1260,14460,1223,14370,1174,14232,1116,14066,1050,13909,981,13761,910,13623,839]);let Oo=null;function eb(){return Oo===null&&(Oo=new d.IEO(x0,32,32,d.av9,d.cLu),Oo.minFilter=d.wem,Oo.magFilter=d.wem,Oo.wrapS=d.uWy,Oo.wrapT=d.uWy,Oo.generateMipmaps=!1,Oo.needsUpdate=!0),Oo}class tb{constructor(e={}){const{canvas:t=(0,d.O5A)(),context:r=null,depth:s=!0,stencil:a=!1,alpha:c=!1,antialias:h=!1,premultipliedAlpha:f=!0,preserveDrawingBuffer:m=!1,powerPreference:x="default",failIfMajorPerformanceCaveat:_=!1,reversedDepthBuffer:v=!1}=e;this.isWebGLRenderer=!0;let T;if(r!==null){if(typeof WebGLRenderingContext!="undefined"&&r instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");T=r.getContextAttributes().alpha}else T=c;const w=new Set([d.E2K,d.CtA,d.D9w]),P=new Set([d.ywz,d.JQ4,d.LsT,d.wJv,d.k0A,d.irR]),C=new Uint32Array(4),E=new Int32Array(4);let D=null,F=null;const W=[],K=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=d.uL9,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const U=this;let j=!1;this._outputColorSpace=d.KI_;let oe=0,k=0,O=null,le=-1,be=null;const Ee=new d.Ltg,Pe=new d.Ltg;let He=null;const Be=new d.Ilk(0);let ft=0,$e=t.width,Tt=t.height,Pt=1,Ye=null,yt=null;const Ot=new d.Ltg(0,0,$e,Tt),Mn=new d.Ltg(0,0,$e,Tt);let tt=!1;const ve=new d.iWj;let Ne=!1,gt=!1;const qt=new d.yGw,Nt=new d.Pa4,en=new d.Ltg,vi={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Dn=!1;function si(){return O===null?Pt:1}let me=r;function Vn(H,Me){return t.getContext(H,Me)}try{const H={alpha:!0,depth:s,stencil:a,antialias:h,premultipliedAlpha:f,preserveDrawingBuffer:m,powerPreference:x,failIfMajorPerformanceCaveat:_};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${d.UZH}`),t.addEventListener("webglcontextlost",xt,!1),t.addEventListener("webglcontextrestored",it,!1),t.addEventListener("webglcontextcreationerror",Yt,!1),me===null){const Me="webgl2";if(me=Vn(Me,H),me===null)throw Vn(Me)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(H){throw H("WebGLRenderer: "+H.message),H}let Un,li,Jt,Xi,yn,zn,J,V,Ce,et,ct,je,ln,Lt,vn,rn,ht,Mt,En,Tn,zt,Pn,xe,It;function Et(){Un=new Wf(me),Un.init(),Pn=new oo(me,Un),li=new wy(me,Un,e,Pn),Jt=new Qh(me,Un),li.reversedDepthBuffer&&v&&Jt.buffers.depth.setReversed(!0),Xi=new Lh(me),yn=new Hy,zn=new Yy(me,Un,Jt,yn,li,Pn,Xi),J=new zl(U),V=new Ey(U),Ce=new oy(me),xe=new Ch(me,Ce),et=new Hf(me,Ce,Xi,xe),ct=new Ga(me,et,Ce,Xi),En=new Ir(me,li,zn),rn=new Rh(yn),je=new xT(U,J,V,Un,li,xe,rn),ln=new hp(U,yn),Lt=new qy,vn=new Ya(Un),Mt=new Kg(U,J,V,Jt,ct,T,f),ht=new Yh(U,ct,li),It=new Jy(me,Xi,li,Jt),Tn=new aa(me,Un,Xi),zt=new e0(me,Un,Xi),Xi.programs=je.programs,U.capabilities=li,U.extensions=Un,U.properties=yn,U.renderLists=Lt,U.shadowMap=ht,U.state=Jt,U.info=Xi}Et();const Ct=new Jh(U,me);this.xr=Ct,this.getContext=function(){return me},this.getContextAttributes=function(){return me.getContextAttributes()},this.forceContextLoss=function(){const H=Un.get("WEBGL_lose_context");H&&H.loseContext()},this.forceContextRestore=function(){const H=Un.get("WEBGL_lose_context");H&&H.restoreContext()},this.getPixelRatio=function(){return Pt},this.setPixelRatio=function(H){H!==void 0&&(Pt=H,this.setSize($e,Tt,!1))},this.getSize=function(H){return H.set($e,Tt)},this.setSize=function(H,Me,Ue=!0){if(Ct.isPresenting){(0,d.ZK6)("WebGLRenderer: Can't change size while VR device is presenting.");return}$e=H,Tt=Me,t.width=Math.floor(H*Pt),t.height=Math.floor(Me*Pt),Ue===!0&&(t.style.width=H+"px",t.style.height=Me+"px"),this.setViewport(0,0,H,Me)},this.getDrawingBufferSize=function(H){return H.set($e*Pt,Tt*Pt).floor()},this.setDrawingBufferSize=function(H,Me,Ue){$e=H,Tt=Me,Pt=Ue,t.width=Math.floor(H*Ue),t.height=Math.floor(Me*Ue),this.setViewport(0,0,H,Me)},this.getCurrentViewport=function(H){return H.copy(Ee)},this.getViewport=function(H){return H.copy(Ot)},this.setViewport=function(H,Me,Ue,Fe){H.isVector4?Ot.set(H.x,H.y,H.z,H.w):Ot.set(H,Me,Ue,Fe),Jt.viewport(Ee.copy(Ot).multiplyScalar(Pt).round())},this.getScissor=function(H){return H.copy(Mn)},this.setScissor=function(H,Me,Ue,Fe){H.isVector4?Mn.set(H.x,H.y,H.z,H.w):Mn.set(H,Me,Ue,Fe),Jt.scissor(Pe.copy(Mn).multiplyScalar(Pt).round())},this.getScissorTest=function(){return tt},this.setScissorTest=function(H){Jt.setScissorTest(tt=H)},this.setOpaqueSort=function(H){Ye=H},this.setTransparentSort=function(H){yt=H},this.getClearColor=function(H){return H.copy(Mt.getClearColor())},this.setClearColor=function(){Mt.setClearColor(...arguments)},this.getClearAlpha=function(){return Mt.getClearAlpha()},this.setClearAlpha=function(){Mt.setClearAlpha(...arguments)},this.clear=function(H=!0,Me=!0,Ue=!0){let Fe=0;if(H){let we=!1;if(O!==null){const vt=O.texture.format;we=w.has(vt)}if(we){const vt=O.texture.type,Ut=P.has(vt),Qt=Mt.getClearColor(),$t=Mt.getClearAlpha(),wn=Qt.r,Rn=Qt.g,fn=Qt.b;Ut?(C[0]=wn,C[1]=Rn,C[2]=fn,C[3]=$t,me.clearBufferuiv(me.COLOR,0,C)):(E[0]=wn,E[1]=Rn,E[2]=fn,E[3]=$t,me.clearBufferiv(me.COLOR,0,E))}else Fe|=me.COLOR_BUFFER_BIT}Me&&(Fe|=me.DEPTH_BUFFER_BIT),Ue&&(Fe|=me.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),me.clear(Fe)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener("webglcontextlost",xt,!1),t.removeEventListener("webglcontextrestored",it,!1),t.removeEventListener("webglcontextcreationerror",Yt,!1),Mt.dispose(),Lt.dispose(),vn.dispose(),yn.dispose(),J.dispose(),V.dispose(),ct.dispose(),xe.dispose(),It.dispose(),je.dispose(),Ct.dispose(),Ct.removeEventListener("sessionstart",t3),Ct.removeEventListener("sessionend",n3),Ku.stop()};function xt(H){H.preventDefault(),(0,d.cM7)("WebGLRenderer: Context Lost."),j=!0}function it(){(0,d.cM7)("WebGLRenderer: Context Restored."),j=!1;const H=Xi.autoReset,Me=ht.enabled,Ue=ht.autoUpdate,Fe=ht.needsUpdate,we=ht.type;Et(),Xi.autoReset=H,ht.enabled=Me,ht.autoUpdate=Ue,ht.needsUpdate=Fe,ht.type=we}function Yt(H){(0,d.vUy)("WebGLRenderer: A WebGL context could not be created. Reason: ",H.statusMessage)}function On(H){const Me=H.target;Me.removeEventListener("dispose",On),Bi(Me)}function Bi(H){Si(H),yn.remove(H)}function Si(H){const Me=yn.get(H).programs;Me!==void 0&&(Me.forEach(function(Ue){je.releaseProgram(Ue)}),H.isShaderMaterial&&je.releaseShaderCache(H))}this.renderBufferDirect=function(H,Me,Ue,Fe,we,vt){Me===null&&(Me=vi);const Ut=we.isMesh&&we.matrixWorld.determinant()<0,Qt=qV(H,Me,Ue,Fe,we);Jt.setMaterial(Fe,Ut);let $t=Ue.index,wn=1;if(Fe.wireframe===!0){if($t=et.getWireframeAttribute(Ue),$t===void 0)return;wn=2}const Rn=Ue.drawRange,fn=Ue.attributes.position;let Qn=Rn.start*wn,Ti=(Rn.start+Rn.count)*wn;vt!==null&&(Qn=Math.max(Qn,vt.start*wn),Ti=Math.min(Ti,(vt.start+vt.count)*wn)),$t!==null?(Qn=Math.max(Qn,0),Ti=Math.min(Ti,$t.count)):fn!=null&&(Qn=Math.max(Qn,0),Ti=Math.min(Ti,fn.count));const nr=Ti-Qn;if(nr<0||nr===1/0)return;xe.setup(we,Fe,Qt,Ue,$t);let ir,Ei=Tn;if($t!==null&&(ir=Ce.get($t),Ei=zt,Ei.setIndex(ir)),we.isMesh)Fe.wireframe===!0?(Jt.setLineWidth(Fe.wireframeLinewidth*si()),Ei.setMode(me.LINES)):Ei.setMode(me.TRIANGLES);else if(we.isLine){let Sn=Fe.linewidth;Sn===void 0&&(Sn=1),Jt.setLineWidth(Sn*si()),we.isLineSegments?Ei.setMode(me.LINES):we.isLineLoop?Ei.setMode(me.LINE_LOOP):Ei.setMode(me.LINE_STRIP)}else we.isPoints?Ei.setMode(me.POINTS):we.isSprite&&Ei.setMode(me.TRIANGLES);if(we.isBatchedMesh)if(we._multiDrawInstances!==null)(0,d.O4K)("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Ei.renderMultiDrawInstances(we._multiDrawStarts,we._multiDrawCounts,we._multiDrawCount,we._multiDrawInstances);else if(Un.get("WEBGL_multi_draw"))Ei.renderMultiDraw(we._multiDrawStarts,we._multiDrawCounts,we._multiDrawCount);else{const Sn=we._multiDrawStarts,qi=we._multiDrawCounts,ui=we._multiDrawCount,eo=$t?Ce.get($t).bytesPerElement:1,Kd=yn.get(Fe).currentProgram.getUniforms();for(let to=0;to<ui;to++)Kd.setValue(me,"_gl_DrawID",to),Ei.render(Sn[to]/eo,qi[to])}else if(we.isInstancedMesh)Ei.renderInstances(Qn,nr,we.count);else if(Ue.isInstancedBufferGeometry){const Sn=Ue._maxInstanceCount!==void 0?Ue._maxInstanceCount:1/0,qi=Math.min(Ue.instanceCount,Sn);Ei.renderInstances(Qn,nr,qi)}else Ei.render(Qn,nr)};function Ea(H,Me,Ue){H.transparent===!0&&H.side===d.ehD&&H.forceSinglePass===!1?(H.side=d._Li,H.needsUpdate=!0,g_(H,Me,Ue),H.side=d.Wl3,H.needsUpdate=!0,g_(H,Me,Ue),H.side=d.ehD):g_(H,Me,Ue)}this.compile=function(H,Me,Ue=null){Ue===null&&(Ue=H),F=vn.get(Ue),F.init(Me),K.push(F),Ue.traverseVisible(function(we){we.isLight&&we.layers.test(Me.layers)&&(F.pushLight(we),we.castShadow&&F.pushShadow(we))}),H!==Ue&&H.traverseVisible(function(we){we.isLight&&we.layers.test(Me.layers)&&(F.pushLight(we),we.castShadow&&F.pushShadow(we))}),F.setupLights();const Fe=new Set;return H.traverse(function(we){if(!(we.isMesh||we.isPoints||we.isLine||we.isSprite))return;const vt=we.material;if(vt)if(Array.isArray(vt))for(let Ut=0;Ut<vt.length;Ut++){const Qt=vt[Ut];Ea(Qt,Ue,we),Fe.add(Qt)}else Ea(vt,Ue,we),Fe.add(vt)}),F=K.pop(),Fe},this.compileAsync=function(H,Me,Ue=null){const Fe=this.compile(H,Me,Ue);return new Promise(we=>{function vt(){if(Fe.forEach(function(Ut){yn.get(Ut).currentProgram.isReady()&&Fe.delete(Ut)}),Fe.size===0){we(H);return}setTimeout(vt,10)}Un.get("KHR_parallel_shader_compile")!==null?vt():setTimeout(vt,10)})};let Yo=null;function XV(H){Yo&&Yo(H)}function t3(){Ku.stop()}function n3(){Ku.start()}const Ku=new Lg;Ku.setAnimationLoop(XV),typeof self!="undefined"&&Ku.setContext(self),this.setAnimationLoop=function(H){Yo=H,Ct.setAnimationLoop(H),H===null?Ku.stop():Ku.start()},Ct.addEventListener("sessionstart",t3),Ct.addEventListener("sessionend",n3),this.render=function(H,Me){if(Me!==void 0&&Me.isCamera!==!0){(0,d.vUy)("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(j===!0)return;if(H.matrixWorldAutoUpdate===!0&&H.updateMatrixWorld(),Me.parent===null&&Me.matrixWorldAutoUpdate===!0&&Me.updateMatrixWorld(),Ct.enabled===!0&&Ct.isPresenting===!0&&(Ct.cameraAutoUpdate===!0&&Ct.updateCamera(Me),Me=Ct.getCamera()),H.isScene===!0&&H.onBeforeRender(U,H,Me,O),F=vn.get(H,K.length),F.init(Me),K.push(F),qt.multiplyMatrices(Me.projectionMatrix,Me.matrixWorldInverse),ve.setFromProjectionMatrix(qt,d._RZ,Me.reversedDepth),gt=this.localClippingEnabled,Ne=rn.init(this.clippingPlanes,gt),D=Lt.get(H,W.length),D.init(),W.push(D),Ct.enabled===!0&&Ct.isPresenting===!0){const vt=U.xr.getDepthSensingMesh();vt!==null&&YS(vt,Me,-1/0,U.sortObjects)}YS(H,Me,0,U.sortObjects),D.finish(),U.sortObjects===!0&&D.sort(Ye,yt),Dn=Ct.enabled===!1||Ct.isPresenting===!1||Ct.hasDepthSensing()===!1,Dn&&Mt.addToRenderList(D,H),this.info.render.frame++,Ne===!0&&rn.beginShadows();const Ue=F.state.shadowsArray;ht.render(Ue,H,Me),Ne===!0&&rn.endShadows(),this.info.autoReset===!0&&this.info.reset();const Fe=D.opaque,we=D.transmissive;if(F.setupLights(),Me.isArrayCamera){const vt=Me.cameras;if(we.length>0)for(let Ut=0,Qt=vt.length;Ut<Qt;Ut++){const $t=vt[Ut];r3(Fe,we,H,$t)}Dn&&Mt.render(H);for(let Ut=0,Qt=vt.length;Ut<Qt;Ut++){const $t=vt[Ut];i3(D,H,$t,$t.viewport)}}else we.length>0&&r3(Fe,we,H,Me),Dn&&Mt.render(H),i3(D,H,Me);O!==null&&k===0&&(zn.updateMultisampleRenderTarget(O),zn.updateRenderTargetMipmap(O)),H.isScene===!0&&H.onAfterRender(U,H,Me),xe.resetDefaultState(),le=-1,be=null,K.pop(),K.length>0?(F=K[K.length-1],Ne===!0&&rn.setGlobalState(U.clippingPlanes,F.state.camera)):F=null,W.pop(),W.length>0?D=W[W.length-1]:D=null};function YS(H,Me,Ue,Fe){if(H.visible===!1)return;if(H.layers.test(Me.layers)){if(H.isGroup)Ue=H.renderOrder;else if(H.isLOD)H.autoUpdate===!0&&H.update(Me);else if(H.isLight)F.pushLight(H),H.castShadow&&F.pushShadow(H);else if(H.isSprite){if(!H.frustumCulled||ve.intersectsSprite(H)){Fe&&en.setFromMatrixPosition(H.matrixWorld).applyMatrix4(qt);const Ut=ct.update(H),Qt=H.material;Qt.visible&&D.push(H,Ut,Qt,Ue,en.z,null)}}else if((H.isMesh||H.isLine||H.isPoints)&&(!H.frustumCulled||ve.intersectsObject(H))){const Ut=ct.update(H),Qt=H.material;if(Fe&&(H.boundingSphere!==void 0?(H.boundingSphere===null&&H.computeBoundingSphere(),en.copy(H.boundingSphere.center)):(Ut.boundingSphere===null&&Ut.computeBoundingSphere(),en.copy(Ut.boundingSphere.center)),en.applyMatrix4(H.matrixWorld).applyMatrix4(qt)),Array.isArray(Qt)){const $t=Ut.groups;for(let wn=0,Rn=$t.length;wn<Rn;wn++){const fn=$t[wn],Qn=Qt[fn.materialIndex];Qn&&Qn.visible&&D.push(H,Ut,Qn,Ue,en.z,fn)}}else Qt.visible&&D.push(H,Ut,Qt,Ue,en.z,null)}}const vt=H.children;for(let Ut=0,Qt=vt.length;Ut<Qt;Ut++)YS(vt[Ut],Me,Ue,Fe)}function i3(H,Me,Ue,Fe){const{opaque:we,transmissive:vt,transparent:Ut}=H;F.setupLightsView(Ue),Ne===!0&&rn.setGlobalState(U.clippingPlanes,Ue),Fe&&Jt.viewport(Ee.copy(Fe)),we.length>0&&m_(we,Me,Ue),vt.length>0&&m_(vt,Me,Ue),Ut.length>0&&m_(Ut,Me,Ue),Jt.buffers.depth.setTest(!0),Jt.buffers.depth.setMask(!0),Jt.buffers.color.setMask(!0),Jt.setPolygonOffset(!1)}function r3(H,Me,Ue,Fe){if((Ue.isScene===!0?Ue.overrideMaterial:null)!==null)return;F.state.transmissionRenderTarget[Fe.id]===void 0&&(F.state.transmissionRenderTarget[Fe.id]=new d.dd2(1,1,{generateMipmaps:!0,type:Un.has("EXT_color_buffer_half_float")||Un.has("EXT_color_buffer_float")?d.cLu:d.ywz,minFilter:d.D1R,samples:4,stencilBuffer:a,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:d.epp.workingColorSpace}));const vt=F.state.transmissionRenderTarget[Fe.id],Ut=Fe.viewport||Ee;vt.setSize(Ut.z*U.transmissionResolutionScale,Ut.w*U.transmissionResolutionScale);const Qt=U.getRenderTarget(),$t=U.getActiveCubeFace(),wn=U.getActiveMipmapLevel();U.setRenderTarget(vt),U.getClearColor(Be),ft=U.getClearAlpha(),ft<1&&U.setClearColor(16777215,.5),U.clear(),Dn&&Mt.render(Ue);const Rn=U.toneMapping;U.toneMapping=d.uL9;const fn=Fe.viewport;if(Fe.viewport!==void 0&&(Fe.viewport=void 0),F.setupLightsView(Fe),Ne===!0&&rn.setGlobalState(U.clippingPlanes,Fe),m_(H,Ue,Fe),zn.updateMultisampleRenderTarget(vt),zn.updateRenderTargetMipmap(vt),Un.has("WEBGL_multisampled_render_to_texture")===!1){let Qn=!1;for(let Ti=0,nr=Me.length;Ti<nr;Ti++){const ir=Me[Ti],{object:Ei,geometry:Sn,material:qi,group:ui}=ir;if(qi.side===d.ehD&&Ei.layers.test(Fe.layers)){const eo=qi.side;qi.side=d._Li,qi.needsUpdate=!0,s3(Ei,Ue,Fe,Sn,qi,ui),qi.side=eo,qi.needsUpdate=!0,Qn=!0}}Qn===!0&&(zn.updateMultisampleRenderTarget(vt),zn.updateRenderTargetMipmap(vt))}U.setRenderTarget(Qt,$t,wn),U.setClearColor(Be,ft),fn!==void 0&&(Fe.viewport=fn),U.toneMapping=Rn}function m_(H,Me,Ue){const Fe=Me.isScene===!0?Me.overrideMaterial:null;for(let we=0,vt=H.length;we<vt;we++){const Ut=H[we],{object:Qt,geometry:$t,group:wn}=Ut;let Rn=Ut.material;Rn.allowOverride===!0&&Fe!==null&&(Rn=Fe),Qt.layers.test(Ue.layers)&&s3(Qt,Me,Ue,$t,Rn,wn)}}function s3(H,Me,Ue,Fe,we,vt){H.onBeforeRender(U,Me,Ue,Fe,we,vt),H.modelViewMatrix.multiplyMatrices(Ue.matrixWorldInverse,H.matrixWorld),H.normalMatrix.getNormalMatrix(H.modelViewMatrix),we.onBeforeRender(U,Me,Ue,Fe,H,vt),we.transparent===!0&&we.side===d.ehD&&we.forceSinglePass===!1?(we.side=d._Li,we.needsUpdate=!0,U.renderBufferDirect(Ue,Me,Fe,we,H,vt),we.side=d.Wl3,we.needsUpdate=!0,U.renderBufferDirect(Ue,Me,Fe,we,H,vt),we.side=d.ehD):U.renderBufferDirect(Ue,Me,Fe,we,H,vt),H.onAfterRender(U,Me,Ue,Fe,we,vt)}function g_(H,Me,Ue){Me.isScene!==!0&&(Me=vi);const Fe=yn.get(H),we=F.state.lights,vt=F.state.shadowsArray,Ut=we.state.version,Qt=je.getParameters(H,we.state,vt,Me,Ue),$t=je.getProgramCacheKey(Qt);let wn=Fe.programs;Fe.environment=H.isMeshStandardMaterial?Me.environment:null,Fe.fog=Me.fog,Fe.envMap=(H.isMeshStandardMaterial?V:J).get(H.envMap||Fe.environment),Fe.envMapRotation=Fe.environment!==null&&H.envMap===null?Me.environmentRotation:H.envMapRotation,wn===void 0&&(H.addEventListener("dispose",On),wn=new Map,Fe.programs=wn);let Rn=wn.get($t);if(Rn!==void 0){if(Fe.currentProgram===Rn&&Fe.lightsStateVersion===Ut)return a3(H,Qt),Rn}else Qt.uniforms=je.getUniforms(H),H.onBeforeCompile(Qt,U),Rn=je.acquireProgram(Qt,$t),wn.set($t,Rn),Fe.uniforms=Qt.uniforms;const fn=Fe.uniforms;return(!H.isShaderMaterial&&!H.isRawShaderMaterial||H.clipping===!0)&&(fn.clippingPlanes=rn.uniform),a3(H,Qt),Fe.needsLights=ZV(H),Fe.lightsStateVersion=Ut,Fe.needsLights&&(fn.ambientLightColor.value=we.state.ambient,fn.lightProbe.value=we.state.probe,fn.directionalLights.value=we.state.directional,fn.directionalLightShadows.value=we.state.directionalShadow,fn.spotLights.value=we.state.spot,fn.spotLightShadows.value=we.state.spotShadow,fn.rectAreaLights.value=we.state.rectArea,fn.ltc_1.value=we.state.rectAreaLTC1,fn.ltc_2.value=we.state.rectAreaLTC2,fn.pointLights.value=we.state.point,fn.pointLightShadows.value=we.state.pointShadow,fn.hemisphereLights.value=we.state.hemi,fn.directionalShadowMap.value=we.state.directionalShadowMap,fn.directionalShadowMatrix.value=we.state.directionalShadowMatrix,fn.spotShadowMap.value=we.state.spotShadowMap,fn.spotLightMatrix.value=we.state.spotLightMatrix,fn.spotLightMap.value=we.state.spotLightMap,fn.pointShadowMap.value=we.state.pointShadowMap,fn.pointShadowMatrix.value=we.state.pointShadowMatrix),Fe.currentProgram=Rn,Fe.uniformsList=null,Rn}function o3(H){if(H.uniformsList===null){const Me=H.currentProgram.getUniforms();H.uniformsList=ql.seqWithValue(Me.seq,H.uniforms)}return H.uniformsList}function a3(H,Me){const Ue=yn.get(H);Ue.outputColorSpace=Me.outputColorSpace,Ue.batching=Me.batching,Ue.batchingColor=Me.batchingColor,Ue.instancing=Me.instancing,Ue.instancingColor=Me.instancingColor,Ue.instancingMorph=Me.instancingMorph,Ue.skinning=Me.skinning,Ue.morphTargets=Me.morphTargets,Ue.morphNormals=Me.morphNormals,Ue.morphColors=Me.morphColors,Ue.morphTargetsCount=Me.morphTargetsCount,Ue.numClippingPlanes=Me.numClippingPlanes,Ue.numIntersection=Me.numClipIntersection,Ue.vertexAlphas=Me.vertexAlphas,Ue.vertexTangents=Me.vertexTangents,Ue.toneMapping=Me.toneMapping}function qV(H,Me,Ue,Fe,we){Me.isScene!==!0&&(Me=vi),zn.resetTextureUnits();const vt=Me.fog,Ut=Fe.isMeshStandardMaterial?Me.environment:null,Qt=O===null?U.outputColorSpace:O.isXRRenderTarget===!0?O.texture.colorSpace:d.GUF,$t=(Fe.isMeshStandardMaterial?V:J).get(Fe.envMap||Ut),wn=Fe.vertexColors===!0&&!!Ue.attributes.color&&Ue.attributes.color.itemSize===4,Rn=!!Ue.attributes.tangent&&(!!Fe.normalMap||Fe.anisotropy>0),fn=!!Ue.morphAttributes.position,Qn=!!Ue.morphAttributes.normal,Ti=!!Ue.morphAttributes.color;let nr=d.uL9;Fe.toneMapped&&(O===null||O.isXRRenderTarget===!0)&&(nr=U.toneMapping);const ir=Ue.morphAttributes.position||Ue.morphAttributes.normal||Ue.morphAttributes.color,Ei=ir!==void 0?ir.length:0,Sn=yn.get(Fe),qi=F.state.lights;if(Ne===!0&&(gt===!0||H!==be)){const fs=H===be&&Fe.id===le;rn.setState(Fe,H,fs)}let ui=!1;Fe.version===Sn.__version?(Sn.needsLights&&Sn.lightsStateVersion!==qi.state.version||Sn.outputColorSpace!==Qt||we.isBatchedMesh&&Sn.batching===!1||!we.isBatchedMesh&&Sn.batching===!0||we.isBatchedMesh&&Sn.batchingColor===!0&&we.colorTexture===null||we.isBatchedMesh&&Sn.batchingColor===!1&&we.colorTexture!==null||we.isInstancedMesh&&Sn.instancing===!1||!we.isInstancedMesh&&Sn.instancing===!0||we.isSkinnedMesh&&Sn.skinning===!1||!we.isSkinnedMesh&&Sn.skinning===!0||we.isInstancedMesh&&Sn.instancingColor===!0&&we.instanceColor===null||we.isInstancedMesh&&Sn.instancingColor===!1&&we.instanceColor!==null||we.isInstancedMesh&&Sn.instancingMorph===!0&&we.morphTexture===null||we.isInstancedMesh&&Sn.instancingMorph===!1&&we.morphTexture!==null||Sn.envMap!==$t||Fe.fog===!0&&Sn.fog!==vt||Sn.numClippingPlanes!==void 0&&(Sn.numClippingPlanes!==rn.numPlanes||Sn.numIntersection!==rn.numIntersection)||Sn.vertexAlphas!==wn||Sn.vertexTangents!==Rn||Sn.morphTargets!==fn||Sn.morphNormals!==Qn||Sn.morphColors!==Ti||Sn.toneMapping!==nr||Sn.morphTargetsCount!==Ei)&&(ui=!0):(ui=!0,Sn.__version=Fe.version);let eo=Sn.currentProgram;ui===!0&&(eo=g_(Fe,Me,we));let Kd=!1,to=!1,Fm=!1;const Ki=eo.getUniforms(),Es=Sn.uniforms;if(Jt.useProgram(eo.program)&&(Kd=!0,to=!0,Fm=!0),Fe.id!==le&&(le=Fe.id,to=!0),Kd||be!==H){Jt.buffers.depth.getReversed()&&H.reversedDepth!==!0&&(H._reversedDepth=!0,H.updateProjectionMatrix()),Ki.setValue(me,"projectionMatrix",H.projectionMatrix),Ki.setValue(me,"viewMatrix",H.matrixWorldInverse);const Cs=Ki.map.cameraPosition;Cs!==void 0&&Cs.setValue(me,Nt.setFromMatrixPosition(H.matrixWorld)),li.logarithmicDepthBuffer&&Ki.setValue(me,"logDepthBufFC",2/(Math.log(H.far+1)/Math.LN2)),(Fe.isMeshPhongMaterial||Fe.isMeshToonMaterial||Fe.isMeshLambertMaterial||Fe.isMeshBasicMaterial||Fe.isMeshStandardMaterial||Fe.isShaderMaterial)&&Ki.setValue(me,"isOrthographic",H.isOrthographicCamera===!0),be!==H&&(be=H,to=!0,Fm=!0)}if(we.isSkinnedMesh){Ki.setOptional(me,we,"bindMatrix"),Ki.setOptional(me,we,"bindMatrixInverse");const fs=we.skeleton;fs&&(fs.boneTexture===null&&fs.computeBoneTexture(),Ki.setValue(me,"boneTexture",fs.boneTexture,zn))}we.isBatchedMesh&&(Ki.setOptional(me,we,"batchingTexture"),Ki.setValue(me,"batchingTexture",we._matricesTexture,zn),Ki.setOptional(me,we,"batchingIdTexture"),Ki.setValue(me,"batchingIdTexture",we._indirectTexture,zn),Ki.setOptional(me,we,"batchingColorTexture"),we._colorsTexture!==null&&Ki.setValue(me,"batchingColorTexture",we._colorsTexture,zn));const So=Ue.morphAttributes;if((So.position!==void 0||So.normal!==void 0||So.color!==void 0)&&En.update(we,Ue,eo),(to||Sn.receiveShadow!==we.receiveShadow)&&(Sn.receiveShadow=we.receiveShadow,Ki.setValue(me,"receiveShadow",we.receiveShadow)),Fe.isMeshGouraudMaterial&&Fe.envMap!==null&&(Es.envMap.value=$t,Es.flipEnvMap.value=$t.isCubeTexture&&$t.isRenderTargetTexture===!1?-1:1),Fe.isMeshStandardMaterial&&Fe.envMap===null&&Me.environment!==null&&(Es.envMapIntensity.value=Me.environmentIntensity),Es.dfgLUT!==void 0&&(Es.dfgLUT.value=eb()),to&&(Ki.setValue(me,"toneMappingExposure",U.toneMappingExposure),Sn.needsLights&&KV(Es,Fm),vt&&Fe.fog===!0&&ln.refreshFogUniforms(Es,vt),ln.refreshMaterialUniforms(Es,Fe,Pt,Tt,F.state.transmissionRenderTarget[H.id]),ql.upload(me,o3(Sn),Es,zn)),Fe.isShaderMaterial&&Fe.uniformsNeedUpdate===!0&&(ql.upload(me,o3(Sn),Es,zn),Fe.uniformsNeedUpdate=!1),Fe.isSpriteMaterial&&Ki.setValue(me,"center",we.center),Ki.setValue(me,"modelViewMatrix",we.modelViewMatrix),Ki.setValue(me,"normalMatrix",we.normalMatrix),Ki.setValue(me,"modelMatrix",we.matrixWorld),Fe.isShaderMaterial||Fe.isRawShaderMaterial){const fs=Fe.uniformsGroups;for(let Cs=0,QS=fs.length;Cs<QS;Cs++){const Zu=fs[Cs];It.update(Zu,eo),It.bind(Zu,eo)}}return eo}function KV(H,Me){H.ambientLightColor.needsUpdate=Me,H.lightProbe.needsUpdate=Me,H.directionalLights.needsUpdate=Me,H.directionalLightShadows.needsUpdate=Me,H.pointLights.needsUpdate=Me,H.pointLightShadows.needsUpdate=Me,H.spotLights.needsUpdate=Me,H.spotLightShadows.needsUpdate=Me,H.rectAreaLights.needsUpdate=Me,H.hemisphereLights.needsUpdate=Me}function ZV(H){return H.isMeshLambertMaterial||H.isMeshToonMaterial||H.isMeshPhongMaterial||H.isMeshStandardMaterial||H.isShadowMaterial||H.isShaderMaterial&&H.lights===!0}this.getActiveCubeFace=function(){return oe},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return O},this.setRenderTargetTextures=function(H,Me,Ue){const Fe=yn.get(H);Fe.__autoAllocateDepthBuffer=H.resolveDepthBuffer===!1,Fe.__autoAllocateDepthBuffer===!1&&(Fe.__useRenderToTexture=!1),yn.get(H.texture).__webglTexture=Me,yn.get(H.depthTexture).__webglTexture=Fe.__autoAllocateDepthBuffer?void 0:Ue,Fe.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(H,Me){const Ue=yn.get(H);Ue.__webglFramebuffer=Me,Ue.__useDefaultFramebuffer=Me===void 0};const YV=me.createFramebuffer();this.setRenderTarget=function(H,Me=0,Ue=0){O=H,oe=Me,k=Ue;let Fe=!0,we=null,vt=!1,Ut=!1;if(H){const $t=yn.get(H);if($t.__useDefaultFramebuffer!==void 0)Jt.bindFramebuffer(me.FRAMEBUFFER,null),Fe=!1;else if($t.__webglFramebuffer===void 0)zn.setupRenderTarget(H);else if($t.__hasExternalTextures)zn.rebindTextures(H,yn.get(H.texture).__webglTexture,yn.get(H.depthTexture).__webglTexture);else if(H.depthBuffer){const fn=H.depthTexture;if($t.__boundDepthTexture!==fn){if(fn!==null&&yn.has(fn)&&(H.width!==fn.image.width||H.height!==fn.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");zn.setupDepthRenderbuffer(H)}}const wn=H.texture;(wn.isData3DTexture||wn.isDataArrayTexture||wn.isCompressedArrayTexture)&&(Ut=!0);const Rn=yn.get(H).__webglFramebuffer;H.isWebGLCubeRenderTarget?(Array.isArray(Rn[Me])?we=Rn[Me][Ue]:we=Rn[Me],vt=!0):H.samples>0&&zn.useMultisampledRTT(H)===!1?we=yn.get(H).__webglMultisampledFramebuffer:Array.isArray(Rn)?we=Rn[Ue]:we=Rn,Ee.copy(H.viewport),Pe.copy(H.scissor),He=H.scissorTest}else Ee.copy(Ot).multiplyScalar(Pt).floor(),Pe.copy(Mn).multiplyScalar(Pt).floor(),He=tt;if(Ue!==0&&(we=YV),Jt.bindFramebuffer(me.FRAMEBUFFER,we)&&Fe&&Jt.drawBuffers(H,we),Jt.viewport(Ee),Jt.scissor(Pe),Jt.setScissorTest(He),vt){const $t=yn.get(H.texture);me.framebufferTexture2D(me.FRAMEBUFFER,me.COLOR_ATTACHMENT0,me.TEXTURE_CUBE_MAP_POSITIVE_X+Me,$t.__webglTexture,Ue)}else if(Ut){const $t=Me;for(let wn=0;wn<H.textures.length;wn++){const Rn=yn.get(H.textures[wn]);me.framebufferTextureLayer(me.FRAMEBUFFER,me.COLOR_ATTACHMENT0+wn,Rn.__webglTexture,Ue,$t)}}else if(H!==null&&Ue!==0){const $t=yn.get(H.texture);me.framebufferTexture2D(me.FRAMEBUFFER,me.COLOR_ATTACHMENT0,me.TEXTURE_2D,$t.__webglTexture,Ue)}le=-1},this.readRenderTargetPixels=function(H,Me,Ue,Fe,we,vt,Ut,Qt=0){if(!(H&&H.isWebGLRenderTarget)){(0,d.vUy)("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let $t=yn.get(H).__webglFramebuffer;if(H.isWebGLCubeRenderTarget&&Ut!==void 0&&($t=$t[Ut]),$t){Jt.bindFramebuffer(me.FRAMEBUFFER,$t);try{const wn=H.textures[Qt],Rn=wn.format,fn=wn.type;if(!li.textureFormatReadable(Rn)){(0,d.vUy)("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!li.textureTypeReadable(fn)){(0,d.vUy)("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Me>=0&&Me<=H.width-Fe&&Ue>=0&&Ue<=H.height-we&&(H.textures.length>1&&me.readBuffer(me.COLOR_ATTACHMENT0+Qt),me.readPixels(Me,Ue,Fe,we,Pn.convert(Rn),Pn.convert(fn),vt))}finally{const wn=O!==null?yn.get(O).__webglFramebuffer:null;Jt.bindFramebuffer(me.FRAMEBUFFER,wn)}}},this.readRenderTargetPixelsAsync=function(H,Me,Ue,Fe,we,vt,Ut,Qt=0){return nn(this,null,function*(){if(!(H&&H.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let $t=yn.get(H).__webglFramebuffer;if(H.isWebGLCubeRenderTarget&&Ut!==void 0&&($t=$t[Ut]),$t)if(Me>=0&&Me<=H.width-Fe&&Ue>=0&&Ue<=H.height-we){Jt.bindFramebuffer(me.FRAMEBUFFER,$t);const wn=H.textures[Qt],Rn=wn.format,fn=wn.type;if(!li.textureFormatReadable(Rn))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!li.textureTypeReadable(fn))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Qn=me.createBuffer();me.bindBuffer(me.PIXEL_PACK_BUFFER,Qn),me.bufferData(me.PIXEL_PACK_BUFFER,vt.byteLength,me.STREAM_READ),H.textures.length>1&&me.readBuffer(me.COLOR_ATTACHMENT0+Qt),me.readPixels(Me,Ue,Fe,we,Pn.convert(Rn),Pn.convert(fn),0);const Ti=O!==null?yn.get(O).__webglFramebuffer:null;Jt.bindFramebuffer(me.FRAMEBUFFER,Ti);const nr=me.fenceSync(me.SYNC_GPU_COMMANDS_COMPLETE,0);return me.flush(),yield(0,d.Qey)(me,nr,4),me.bindBuffer(me.PIXEL_PACK_BUFFER,Qn),me.getBufferSubData(me.PIXEL_PACK_BUFFER,0,vt),me.deleteBuffer(Qn),me.deleteSync(nr),vt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")})},this.copyFramebufferToTexture=function(H,Me=null,Ue=0){const Fe=Math.pow(2,-Ue),we=Math.floor(H.image.width*Fe),vt=Math.floor(H.image.height*Fe),Ut=Me!==null?Me.x:0,Qt=Me!==null?Me.y:0;zn.setTexture2D(H,0),me.copyTexSubImage2D(me.TEXTURE_2D,Ue,0,0,Ut,Qt,we,vt),Jt.unbindTexture()};const QV=me.createFramebuffer(),JV=me.createFramebuffer();this.copyTextureToTexture=function(H,Me,Ue=null,Fe=null,we=0,vt=null){vt===null&&(we!==0?((0,d.O4K)("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),vt=we,we=0):vt=0);let Ut,Qt,$t,wn,Rn,fn,Qn,Ti,nr;const ir=H.isCompressedTexture?H.mipmaps[vt]:H.image;if(Ue!==null)Ut=Ue.max.x-Ue.min.x,Qt=Ue.max.y-Ue.min.y,$t=Ue.isBox3?Ue.max.z-Ue.min.z:1,wn=Ue.min.x,Rn=Ue.min.y,fn=Ue.isBox3?Ue.min.z:0;else{const So=Math.pow(2,-we);Ut=Math.floor(ir.width*So),Qt=Math.floor(ir.height*So),H.isDataArrayTexture?$t=ir.depth:H.isData3DTexture?$t=Math.floor(ir.depth*So):$t=1,wn=0,Rn=0,fn=0}Fe!==null?(Qn=Fe.x,Ti=Fe.y,nr=Fe.z):(Qn=0,Ti=0,nr=0);const Ei=Pn.convert(Me.format),Sn=Pn.convert(Me.type);let qi;Me.isData3DTexture?(zn.setTexture3D(Me,0),qi=me.TEXTURE_3D):Me.isDataArrayTexture||Me.isCompressedArrayTexture?(zn.setTexture2DArray(Me,0),qi=me.TEXTURE_2D_ARRAY):(zn.setTexture2D(Me,0),qi=me.TEXTURE_2D),me.pixelStorei(me.UNPACK_FLIP_Y_WEBGL,Me.flipY),me.pixelStorei(me.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Me.premultiplyAlpha),me.pixelStorei(me.UNPACK_ALIGNMENT,Me.unpackAlignment);const ui=me.getParameter(me.UNPACK_ROW_LENGTH),eo=me.getParameter(me.UNPACK_IMAGE_HEIGHT),Kd=me.getParameter(me.UNPACK_SKIP_PIXELS),to=me.getParameter(me.UNPACK_SKIP_ROWS),Fm=me.getParameter(me.UNPACK_SKIP_IMAGES);me.pixelStorei(me.UNPACK_ROW_LENGTH,ir.width),me.pixelStorei(me.UNPACK_IMAGE_HEIGHT,ir.height),me.pixelStorei(me.UNPACK_SKIP_PIXELS,wn),me.pixelStorei(me.UNPACK_SKIP_ROWS,Rn),me.pixelStorei(me.UNPACK_SKIP_IMAGES,fn);const Ki=H.isDataArrayTexture||H.isData3DTexture,Es=Me.isDataArrayTexture||Me.isData3DTexture;if(H.isDepthTexture){const So=yn.get(H),fs=yn.get(Me),Cs=yn.get(So.__renderTarget),QS=yn.get(fs.__renderTarget);Jt.bindFramebuffer(me.READ_FRAMEBUFFER,Cs.__webglFramebuffer),Jt.bindFramebuffer(me.DRAW_FRAMEBUFFER,QS.__webglFramebuffer);for(let Zu=0;Zu<$t;Zu++)Ki&&(me.framebufferTextureLayer(me.READ_FRAMEBUFFER,me.COLOR_ATTACHMENT0,yn.get(H).__webglTexture,we,fn+Zu),me.framebufferTextureLayer(me.DRAW_FRAMEBUFFER,me.COLOR_ATTACHMENT0,yn.get(Me).__webglTexture,vt,nr+Zu)),me.blitFramebuffer(wn,Rn,Ut,Qt,Qn,Ti,Ut,Qt,me.DEPTH_BUFFER_BIT,me.NEAREST);Jt.bindFramebuffer(me.READ_FRAMEBUFFER,null),Jt.bindFramebuffer(me.DRAW_FRAMEBUFFER,null)}else if(we!==0||H.isRenderTargetTexture||yn.has(H)){const So=yn.get(H),fs=yn.get(Me);Jt.bindFramebuffer(me.READ_FRAMEBUFFER,QV),Jt.bindFramebuffer(me.DRAW_FRAMEBUFFER,JV);for(let Cs=0;Cs<$t;Cs++)Ki?me.framebufferTextureLayer(me.READ_FRAMEBUFFER,me.COLOR_ATTACHMENT0,So.__webglTexture,we,fn+Cs):me.framebufferTexture2D(me.READ_FRAMEBUFFER,me.COLOR_ATTACHMENT0,me.TEXTURE_2D,So.__webglTexture,we),Es?me.framebufferTextureLayer(me.DRAW_FRAMEBUFFER,me.COLOR_ATTACHMENT0,fs.__webglTexture,vt,nr+Cs):me.framebufferTexture2D(me.DRAW_FRAMEBUFFER,me.COLOR_ATTACHMENT0,me.TEXTURE_2D,fs.__webglTexture,vt),we!==0?me.blitFramebuffer(wn,Rn,Ut,Qt,Qn,Ti,Ut,Qt,me.COLOR_BUFFER_BIT,me.NEAREST):Es?me.copyTexSubImage3D(qi,vt,Qn,Ti,nr+Cs,wn,Rn,Ut,Qt):me.copyTexSubImage2D(qi,vt,Qn,Ti,wn,Rn,Ut,Qt);Jt.bindFramebuffer(me.READ_FRAMEBUFFER,null),Jt.bindFramebuffer(me.DRAW_FRAMEBUFFER,null)}else Es?H.isDataTexture||H.isData3DTexture?me.texSubImage3D(qi,vt,Qn,Ti,nr,Ut,Qt,$t,Ei,Sn,ir.data):Me.isCompressedArrayTexture?me.compressedTexSubImage3D(qi,vt,Qn,Ti,nr,Ut,Qt,$t,Ei,ir.data):me.texSubImage3D(qi,vt,Qn,Ti,nr,Ut,Qt,$t,Ei,Sn,ir):H.isDataTexture?me.texSubImage2D(me.TEXTURE_2D,vt,Qn,Ti,Ut,Qt,Ei,Sn,ir.data):H.isCompressedTexture?me.compressedTexSubImage2D(me.TEXTURE_2D,vt,Qn,Ti,ir.width,ir.height,Ei,ir.data):me.texSubImage2D(me.TEXTURE_2D,vt,Qn,Ti,Ut,Qt,Ei,Sn,ir);me.pixelStorei(me.UNPACK_ROW_LENGTH,ui),me.pixelStorei(me.UNPACK_IMAGE_HEIGHT,eo),me.pixelStorei(me.UNPACK_SKIP_PIXELS,Kd),me.pixelStorei(me.UNPACK_SKIP_ROWS,to),me.pixelStorei(me.UNPACK_SKIP_IMAGES,Fm),vt===0&&Me.generateMipmaps&&me.generateMipmap(qi),Jt.unbindTexture()},this.initRenderTarget=function(H){yn.get(H).__webglFramebuffer===void 0&&zn.setupRenderTarget(H)},this.initTexture=function(H){H.isCubeTexture?zn.setTextureCube(H,0):H.isData3DTexture?zn.setTexture3D(H,0):H.isDataArrayTexture||H.isCompressedArrayTexture?zn.setTexture2DArray(H,0):zn.setTexture2D(H,0),Jt.unbindTexture()},this.resetState=function(){oe=0,k=0,O=null,Jt.reset(),xe.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return d._RZ}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=d.epp._getDrawingBufferColorSpace(e),t.unpackColorSpace=d.epp._getUnpackColorSpace()}}const Jl=["alphaMap","alphaTest","anisotropy","anisotropyMap","anisotropyRotation","aoMap","aoMapIntensity","attenuationColor","attenuationDistance","bumpMap","clearcoat","clearcoatMap","clearcoatNormalMap","clearcoatNormalScale","clearcoatRoughness","color","dispersion","displacementMap","emissive","emissiveIntensity","emissiveMap","envMap","envMapIntensity","gradientMap","ior","iridescence","iridescenceIOR","iridescenceMap","iridescenceThicknessMap","lightMap","lightMapIntensity","map","matcap","metalness","metalnessMap","normalMap","normalScale","opacity","roughness","roughnessMap","sheen","sheenColor","sheenColorMap","sheenRoughnessMap","shininess","specular","specularColor","specularColorMap","specularIntensity","specularIntensityMap","specularMap","thickness","transmission","transmissionMap"],dp=new WeakMap;class nb{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=Jl,this.renderId=0}firstInitialization(e){return this.renderObjects.has(e)===!1?(this.getRenderObjectData(e),!0):!1}needsVelocity(e){const t=e.getMRT();return t!==null&&t.has("velocity")}getRenderObjectData(e){let t=this.renderObjects.get(e);if(t===void 0){const{geometry:r,material:s,object:a}=e;if(t={material:this.getMaterialData(s),geometry:{id:r.id,attributes:this.getAttributesData(r.attributes),indexVersion:r.index?r.index.version:null,drawRange:{start:r.drawRange.start,count:r.drawRange.count}},worldMatrix:a.matrixWorld.clone()},a.center&&(t.center=a.center.clone()),a.morphTargetInfluences&&(t.morphTargetInfluences=a.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),t.material.transmission>0){const{width:c,height:h}=e.context;t.bufferWidth=c,t.bufferHeight=h}t.lights=this.getLightsData(e.lightsNode.getLights()),this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const r in e){const s=e[r];t[r]={version:s.version}}return t}containsNode(e){const t=e.material;for(const r in t)if(t[r]&&t[r].isNode)return!0;return e.renderer.overrideNodes.modelViewMatrix!==null||e.renderer.overrideNodes.modelNormalViewMatrix!==null}getMaterialData(e){const t={};for(const r of this.refreshUniforms){const s=e[r];s!=null&&(typeof s=="object"&&s.clone!==void 0?s.isTexture===!0?t[r]={id:s.id,version:s.version}:t[r]=s.clone():t[r]=s)}return t}equals(e,t){const{object:r,material:s,geometry:a}=e,c=this.getRenderObjectData(e);if(c.worldMatrix.equals(r.matrixWorld)!==!0)return c.worldMatrix.copy(r.matrixWorld),!1;const h=c.material;for(const C in h){const E=h[C],D=s[C];if(E.equals!==void 0){if(E.equals(D)===!1)return E.copy(D),!1}else if(D.isTexture===!0){if(E.id!==D.id||E.version!==D.version)return E.id=D.id,E.version=D.version,!1}else if(E!==D)return h[C]=D,!1}if(h.transmission>0){const{width:C,height:E}=e.context;if(c.bufferWidth!==C||c.bufferHeight!==E)return c.bufferWidth=C,c.bufferHeight=E,!1}const f=c.geometry,m=a.attributes,x=f.attributes,_=Object.keys(x),v=Object.keys(m);if(f.id!==a.id)return f.id=a.id,!1;if(_.length!==v.length)return c.geometry.attributes=this.getAttributesData(m),!1;for(const C of _){const E=x[C],D=m[C];if(D===void 0)return delete x[C],!1;if(E.version!==D.version)return E.version=D.version,!1}const T=a.index,w=f.indexVersion,P=T?T.version:null;if(w!==P)return f.indexVersion=P,!1;if(f.drawRange.start!==a.drawRange.start||f.drawRange.count!==a.drawRange.count)return f.drawRange.start=a.drawRange.start,f.drawRange.count=a.drawRange.count,!1;if(c.morphTargetInfluences){let C=!1;for(let E=0;E<c.morphTargetInfluences.length;E++)c.morphTargetInfluences[E]!==r.morphTargetInfluences[E]&&(c.morphTargetInfluences[E]=r.morphTargetInfluences[E],C=!0);if(C)return!1}if(c.lights){for(let C=0;C<t.length;C++)if(c.lights[C].map!==t[C].map)return!1}return c.center&&c.center.equals(r.center)===!1?(c.center.copy(r.center),!0):(e.bundle!==null&&(c.version=e.bundle.version),!0)}getLightsData(e){const t=[];for(const r of e)r.isSpotLight===!0&&r.map!==null&&t.push({map:r.map.version});return t}getLights(e,t){if(dp.has(e)){const s=dp.get(e);if(s.renderId===t)return s.lightsData}const r=this.getLightsData(e.getLights());return dp.set(e,{renderId:t,lightsData:r}),r}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e)||this.needsVelocity(t.renderer))return!0;const{renderId:r}=t;if(this.renderId!==r)return this.renderId=r,!0;const s=e.object.static===!0,a=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;if(s||a)return!1;const c=this.getLights(e.lightsNode,r);return this.equals(e,c)!==!0}}function fp(i,e=0){let t=3735928559^e,r=1103547991^e;if(i instanceof Array)for(let s=0,a;s<i.length;s++)a=i[s],t=Math.imul(t^a,2654435761),r=Math.imul(r^a,1597334677);else for(let s=0,a;s<i.length;s++)a=i.charCodeAt(s),t=Math.imul(t^a,2654435761),r=Math.imul(r^a,1597334677);return t=Math.imul(t^t>>>16,2246822507),t^=Math.imul(r^r>>>13,3266489909),r=Math.imul(r^r>>>16,2246822507),r^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&r)+(t>>>0)}const Jc=i=>fp(i),Os=i=>fp(i),Qa=(...i)=>fp(i),_0=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),pp=new WeakMap;function mp(i){return _0.get(i)}function el(i){if(/[iu]?vec\d/.test(i))return i.startsWith("ivec")?Int32Array:i.startsWith("uvec")?Uint32Array:Float32Array;if(/mat\d/.test(i)||/float/.test(i))return Float32Array;if(/uint/.test(i))return Uint32Array;if(/int/.test(i))return Int32Array;throw new Error(`THREE.NodeUtils: Unsupported type: ${i}`)}function eu(i){if(/float|int|uint/.test(i))return 1;if(/vec2/.test(i))return 2;if(/vec3/.test(i))return 3;if(/vec4/.test(i)||/mat2/.test(i))return 4;if(/mat3/.test(i))return 9;if(/mat4/.test(i))return 16;(0,d.vUy)("TSL: Unsupported type:",i)}function gp(i){if(/float|int|uint/.test(i))return 1;if(/vec2/.test(i))return 2;if(/vec3/.test(i))return 3;if(/vec4/.test(i)||/mat2/.test(i))return 4;if(/mat3/.test(i))return 12;if(/mat4/.test(i))return 16;(0,d.vUy)("TSL: Unsupported type:",i)}function tu(i){if(/float|int|uint/.test(i))return 4;if(/vec2/.test(i))return 8;if(/vec3/.test(i)||/vec4/.test(i))return 16;if(/mat2/.test(i))return 8;if(/mat3/.test(i))return 48;if(/mat4/.test(i))return 64;(0,d.vUy)("TSL: Unsupported type:",i)}function ko(i){if(i==null)return null;const e=typeof i;return i.isNode===!0?"node":e==="number"?"float":e==="boolean"?"bool":e==="string"?"string":e==="function"?"shader":i.isVector2===!0?"vec2":i.isVector3===!0?"vec3":i.isVector4===!0?"vec4":i.isMatrix2===!0?"mat2":i.isMatrix3===!0?"mat3":i.isMatrix4===!0?"mat4":i.isColor===!0?"color":i instanceof ArrayBuffer?"ArrayBuffer":null}function tl(i,...e){const t=i?i.slice(-4):void 0;return e.length===1&&(t==="vec2"?e=[e[0],e[0]]:t==="vec3"?e=[e[0],e[0],e[0]]:t==="vec4"&&(e=[e[0],e[0],e[0],e[0]])),i==="color"?new d.Ilk(...e):t==="vec2"?new d.FM8(...e):t==="vec3"?new d.Pa4(...e):t==="vec4"?new d.Ltg(...e):t==="mat2"?new d.UcC(...e):t==="mat3"?new d.Vkp(...e):t==="mat4"?new d.yGw(...e):i==="bool"?e[0]||!1:i==="float"||i==="int"||i==="uint"?e[0]||0:i==="string"?e[0]||"":i==="ArrayBuffer"?ed(e[0]):null}function la(i){let e=pp.get(i);return e===void 0&&(e={},pp.set(i,e)),e}function xp(i){let e="";const t=new Uint8Array(i);for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return btoa(e)}function ed(i){return Uint8Array.from(atob(i),e=>e.charCodeAt(0)).buffer}var nl=Object.freeze({__proto__:null,arrayBufferToBase64:xp,base64ToArrayBuffer:ed,getByteBoundaryFromType:tu,getDataFromObject:la,getLengthFromType:eu,getMemoryLengthFromType:gp,getTypeFromLength:mp,getTypedArrayFromType:el,getValueFromType:tl,getValueType:ko,hash:Qa,hashArray:Os,hashString:Jc});const Vo={VERTEX:"vertex",FRAGMENT:"fragment"},xn={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},ib={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},yr={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},y0=["fragment","vertex"],_p=["setup","analyze","generate"],yp=[...y0,"compute"],Ja=["x","y","z","w"],rb={analyze:"setup",generate:"analyze"};let sb=0;class Rt extends d.pBf{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=xn.NONE,this.updateBeforeType=xn.NONE,this.updateAfterType=xn.NONE,this.uuid=d.M8C.generateUUID(),this.version=0,this.name="",this.global=!1,this.parents=!1,this.isNode=!0,this._beforeNodes=null,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:sb++})}set needsUpdate(e){e===!0&&this.version++}get type(){return this.constructor.type}onUpdate(e,t){return this.updateType=t,this.update=e.bind(this),this}onFrameUpdate(e){return this.onUpdate(e,xn.FRAME)}onRenderUpdate(e){return this.onUpdate(e,xn.RENDER)}onObjectUpdate(e){return this.onUpdate(e,xn.OBJECT)}onReference(e){return this.updateReference=e.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of this._getChildren())yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}_getChildren(e=new Set){const t=[];e.add(this);for(const r of Object.getOwnPropertyNames(this)){const s=this[r];if(!(r.startsWith("_")===!0||e.has(s))){if(Array.isArray(s)===!0)for(let a=0;a<s.length;a++){const c=s[a];c&&c.isNode===!0&&t.push({property:r,index:a,childNode:c})}else if(s&&s.isNode===!0)t.push({property:r,childNode:s});else if(s&&Object.getPrototypeOf(s)===Object.prototype)for(const a in s){if(a.startsWith("_")===!0)continue;const c=s[a];c&&c.isNode===!0&&t.push({property:r,index:a,childNode:c})}}}return t}getCacheKey(e=!1,t=null){if(e=e||this.version!==this._cacheKeyVersion,e===!0||this._cacheKey===null){t===null&&(t=new Set);const r=[];for(const{property:s,childNode:a}of this._getChildren(t))r.push(Jc(s.slice(0,-4)),a.getCacheKey(e,t));this._cacheKey=Qa(Os(r),this.customCacheKey()),this._cacheKeyVersion=this.version}return this._cacheKey}customCacheKey(){return this.id}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)}getMemberType(){return"void"}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}getArrayCount(){return null}setup(e){const t=e.getNodeProperties(this);let r=0;for(const s of this.getChildren())t["node"+r++]=s;return t.outputNode||null}analyze(e,t=null){const r=e.increaseUsage(this);if(this.parents===!0){const s=e.getDataFromNode(this,"any");s.stages=s.stages||{},s.stages[e.shaderStage]=s.stages[e.shaderStage]||[],s.stages[e.shaderStage].push(t)}if(r===1){const s=e.getNodeProperties(this);for(const a of Object.values(s))a&&a.isNode===!0&&a.build(e,this)}}generate(e,t){const{outputNode:r}=e.getNodeProperties(this);if(r&&r.isNode===!0)return r.build(e,t)}updateBefore(){(0,d.ZK6)("Abstract function.")}updateAfter(){(0,d.ZK6)("Abstract function.")}update(){(0,d.ZK6)("Abstract function.")}before(e){return this._beforeNodes===null&&(this._beforeNodes=[]),this._beforeNodes.push(e),this}build(e,t=null){const r=this.getShared(e);if(this!==r)return r.build(e,t);if(this._beforeNodes!==null){const f=this._beforeNodes;this._beforeNodes=null;for(const m of f)m.build(e,t);this._beforeNodes=f}const s=e.getDataFromNode(this);s.buildStages=s.buildStages||{},s.buildStages[e.buildStage]=!0;const a=rb[e.buildStage];if(a&&s.buildStages[a]!==!0){const f=e.getBuildStage();e.setBuildStage(a),this.build(e),e.setBuildStage(f)}e.addNode(this),e.addChain(this);let c=null;const h=e.getBuildStage();if(h==="setup"){this.updateReference(e);const f=e.getNodeProperties(this);if(f.initialized!==!0){f.initialized=!0,f.outputNode=this.setup(e)||f.outputNode||null;for(const m of Object.values(f))if(m&&m.isNode===!0){if(m.parents===!0){const x=e.getNodeProperties(m);x.parents=x.parents||[],x.parents.push(this)}m.build(e)}}c=f.outputNode}else if(h==="analyze")this.analyze(e,t);else if(h==="generate"){if(this.generate.length<2){const m=this.getNodeType(e),x=e.getDataFromNode(this);c=x.snippet,c===void 0?x.generated===void 0?(x.generated=!0,c=this.generate(e)||"",x.snippet=c):((0,d.ZK6)("Node: Recursion detected.",this),c="/* Recursion detected. */"):x.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),c=e.format(c,m,t)}else c=this.generate(e,t)||"";c===""&&t!==null&&t!=="void"&&t!=="OutputType"&&((0,d.vUy)(`TSL: Invalid generated code, expected a "${t}".`),c=e.generateConst(t))}return e.removeChain(this),e.addSequentialNode(this),c}getSerializeChildren(){return this._getChildren()}serialize(e){const t=this.getSerializeChildren(),r={};for(const{property:s,index:a,childNode:c}of t)a!==void 0?(r[s]===void 0&&(r[s]=Number.isInteger(a)?[]:{}),r[s][a]=c.toJSON(e.meta).uuid):r[s]=c.toJSON(e.meta).uuid;Object.keys(r).length>0&&(e.inputNodes=r)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const r in e.inputNodes)if(Array.isArray(e.inputNodes[r])){const s=[];for(const a of e.inputNodes[r])s.push(t[a]);this[r]=s}else if(typeof e.inputNodes[r]=="object"){const s={};for(const a in e.inputNodes[r]){const c=e.inputNodes[r][a];s[a]=t[c]}this[r]=s}else{const s=e.inputNodes[r];this[r]=t[s]}}}toJSON(e){const{uuid:t,type:r}=this,s=e===void 0||typeof e=="string";s&&(e={textures:{},images:{},nodes:{}});let a=e.nodes[t];a===void 0&&(a={uuid:t,type:r,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},s!==!0&&(e.nodes[a.uuid]=a),this.serialize(a),delete a.meta);function c(h){const f=[];for(const m in h){const x=h[m];delete x.metadata,f.push(x)}return f}if(s){const h=c(e.textures),f=c(e.images),m=c(e.nodes);h.length>0&&(a.textures=h),f.length>0&&(a.images=f),m.length>0&&(a.nodes=m)}return a}}class ec extends Rt{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.indexNode.getNodeType(e),r=this.node.build(e),s=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint");return`${r}[ ${s} ]`}}class td extends Rt{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let r=null;for(const s of this.convertTo.split("|"))(r===null||e.getTypeLength(t)===e.getTypeLength(s))&&(r=s);return r}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const r=this.node,s=this.getNodeType(e),a=r.build(e,s);return e.format(a,s,t)}}class Oi extends Rt{static get type(){return"TempNode"}constructor(e=null){super(e),this.isTempNode=!0}hasDependencies(e){return e.getDataFromNode(this).usageCount>1}build(e,t){if(e.getBuildStage()==="generate"){const s=e.getVectorType(this.getNodeType(e,t)),a=e.getDataFromNode(this);if(a.propertyName!==void 0)return e.format(a.propertyName,s,t);if(s!=="void"&&t!=="void"&&this.hasDependencies(e)){const c=super.build(e,s),h=e.getVarFromNode(this,null,s),f=e.getPropertyName(h);return e.addLineFlowCode(`${f} = ${c}`,this),a.snippet=c,a.propertyName=f,e.format(a.propertyName,s,t)}}return super.build(e,t)}}class b0 extends Oi{static get type(){return"JoinNode"}constructor(e=[],t=null){super(t),this.nodes=e}getNodeType(e){return this.nodeType!==null?e.getVectorType(this.nodeType):e.getTypeFromLength(this.nodes.reduce((t,r)=>t+e.getTypeLength(r.getNodeType(e)),0))}generate(e,t){const r=this.getNodeType(e),s=e.getTypeLength(r),a=this.nodes,c=e.getComponentType(r),h=[];let f=0;for(const x of a){if(f>=s){(0,d.vUy)(`TSL: Length of parameters exceeds maximum length of function '${r}()' type.`);break}let _=x.getNodeType(e),v=e.getTypeLength(_),T;if(f+v>s&&((0,d.vUy)(`TSL: Length of '${r}()' data exceeds maximum length of output type.`),v=s-f,_=e.getTypeFromLength(v)),f+=v,T=x.build(e,_),e.getComponentType(_)!==c){const P=e.getTypeFromLength(v,c);T=e.format(T,_,P)}h.push(T)}const m=`${e.getType(r)}( ${h.join(", ")} )`;return e.format(m,r,t)}}const nu=Ja.join("");class v0 extends Rt{static get type(){return"SplitNode"}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(Ja.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))}getScope(){return this.node.getScope()}generate(e,t){const r=this.node,s=e.getTypeLength(r.getNodeType(e));let a=null;if(s>1){let c=null;this.getVectorLength()>=s&&(c=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const f=r.build(e,c);this.components.length===s&&this.components===nu.slice(0,this.components.length)?a=e.format(f,c,t):a=e.format(`${f}.${this.components}`,this.getNodeType(e),t)}else a=r.build(e,t);return a}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class Li extends Oi{static get type(){return"SetNode"}constructor(e,t,r){super(),this.sourceNode=e,this.components=t,this.targetNode=r}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:r,targetNode:s}=this,a=this.getNodeType(e),c=e.getComponentType(s.getNodeType(e)),h=e.getTypeFromLength(r.length,c),f=s.build(e,h),m=t.build(e,a),x=e.getTypeLength(a),_=[];for(let v=0;v<x;v++){const T=Ja[v];T===r[0]?(_.push(f),v+=r.length-1):_.push(m+"."+T)}return`${e.getType(a)}( ${_.join(", ")} )`}}class il extends Oi{static get type(){return"FlipNode"}constructor(e,t){super(),this.sourceNode=e,this.components=t}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{components:t,sourceNode:r}=this,s=this.getNodeType(e),a=r.build(e),c=e.getVarFromNode(this),h=e.getPropertyName(c);e.addLineFlowCode(h+" = "+a,this);const f=e.getTypeLength(s),m=[];let x=0;for(let _=0;_<f;_++){const v=Ja[_];v===t[x]?(m.push("1.0 - "+(h+"."+v)),x++):m.push(h+"."+v)}return`${e.getType(s)}( ${m.join(", ")} )`}}class nd extends Rt{static get type(){return"InputNode"}constructor(e,t=null){super(t),this.isInputNode=!0,this.value=e,this.precision=null}getNodeType(){return this.nodeType===null?ko(this.value):this.nodeType}getInputType(e){return this.getNodeType(e)}setPrecision(e){return this.precision=e,this}serialize(e){super.serialize(e),e.value=this.value,this.value&&this.value.toArray&&(e.value=this.value.toArray()),e.valueType=ko(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=xp(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?tl(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){(0,d.ZK6)("Abstract function.")}}const iu=/float|u?int/;class Fr extends nd{static get type(){return"ConstNode"}constructor(e,t=null){super(e,t),this.isConstNode=!0}generateConst(e){return e.generateConst(this.getNodeType(e),this.value)}generate(e,t){const r=this.getNodeType(e);return iu.test(r)&&iu.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),r,t)}}class ob extends Rt{static get type(){return"MemberNode"}constructor(e,t){super(),this.structNode=e,this.property=t,this.isMemberNode=!0}hasMember(e){return this.structNode.isMemberNode&&this.structNode.hasMember(e)===!1?!1:this.structNode.getMemberType(e,this.property)!=="void"}getNodeType(e){return this.hasMember(e)===!1?"float":this.structNode.getMemberType(e,this.property)}getMemberType(e,t){if(this.hasMember(e)===!1)return"float";const r=this.getNodeType(e);return e.getStructTypeNode(r).getMemberType(e,t)}generate(e){if(this.hasMember(e)===!1){(0,d.ZK6)(`TSL: Member "${this.property}" does not exist in struct.`);const r=this.getNodeType(e);return e.generateConst(r)}return this.structNode.build(e)+"."+this.property}}let _s=null;const bp=new Map;function De(i,e){if(bp.has(i)){(0,d.ZK6)(`TSL: Redefinition of method chaining '${i}'.`);return}if(typeof e!="function")throw new Error(`THREE.TSL: Node element ${i} is not a function`);bp.set(i,e),i!=="assign"&&(Rt.prototype[i]=function(...t){return this.isStackNode?this.addToStack(e(...t)):e(this,...t)},Rt.prototype[i+"Assign"]=function(...t){return this.isStackNode?this.assign(t[0],e(...t)):this.assign(e(this,...t))})}const S0=i=>i.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),rl=i=>S0(i).split("").sort().join("");Rt.prototype.assign=function(...i){if(this.isStackNode!==!0)return _s!==null?_s.assign(this,...i):(0,d.vUy)("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn()."),this;{const e=bp.get("assign");return this.addToStack(e(...i))}},Rt.prototype.toVarIntent=function(){return this},Rt.prototype.get=function(i){return new ob(this,i)};const tc={};function id(i,e,t){tc[i]=tc[e]=tc[t]={get(){this._cache=this._cache||{};let c=this._cache[i];return c===void 0&&(c=new v0(this,i),this._cache[i]=c),c},set(c){this[i].assign(Oe(c))}};const r=i.toUpperCase(),s=e.toUpperCase(),a=t.toUpperCase();Rt.prototype["set"+r]=Rt.prototype["set"+s]=Rt.prototype["set"+a]=function(c){const h=rl(i);return new Li(this,h,Oe(c))},Rt.prototype["flip"+r]=Rt.prototype["flip"+s]=Rt.prototype["flip"+a]=function(){const c=rl(i);return new il(this,c)}}const ao=["x","y","z","w"],cr=["r","g","b","a"],ks=["s","t","p","q"];for(let i=0;i<4;i++){let e=ao[i],t=cr[i],r=ks[i];id(e,t,r);for(let s=0;s<4;s++){e=ao[i]+ao[s],t=cr[i]+cr[s],r=ks[i]+ks[s],id(e,t,r);for(let a=0;a<4;a++){e=ao[i]+ao[s]+ao[a],t=cr[i]+cr[s]+cr[a],r=ks[i]+ks[s]+ks[a],id(e,t,r);for(let c=0;c<4;c++)e=ao[i]+ao[s]+ao[a]+ao[c],t=cr[i]+cr[s]+cr[a]+cr[c],r=ks[i]+ks[s]+ks[a]+ks[c],id(e,t,r)}}}for(let i=0;i<32;i++)tc[i]={get(){this._cache=this._cache||{};let e=this._cache[i];return e===void 0&&(e=new ec(this,new Fr(i,"uint")),this._cache[i]=e),e},set(e){this[i].assign(Oe(e))}};Object.defineProperties(Rt.prototype,tc);const vp=new WeakMap,Sp=function(i,e=null){const t=ko(i);return t==="node"?i:e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string"?Oe(Rp(i,e)):t==="shader"?i.isFn?i:fe(i):i},ab=function(i,e=null){for(const t in i)i[t]=Oe(i[t],e);return i},cb=function(i,e=null){const t=i.length;for(let r=0;r<t;r++)i[r]=Oe(i[r],e);return i},rd=function(i,e=null,t=null,r=null){function s(x){return r!==null?(x=Oe(Object.assign(x,r)),r.intent===!0&&(x=x.toVarIntent())):x=Oe(x),x}let a,c=e,h,f;function m(x){let _;return c?_=/[a-z]/i.test(c)?c+"()":c:_=i.type,h!==void 0&&x.length<h?((0,d.vUy)(`TSL: "${_}" parameter length is less than minimum required.`),x.concat(new Array(h-x.length).fill(0))):f!==void 0&&x.length>f?((0,d.vUy)(`TSL: "${_}" parameter length exceeds limit.`),x.slice(0,f)):x}return e===null?a=(...x)=>s(new i(...ua(m(x)))):t!==null?(t=Oe(t),a=(...x)=>s(new i(e,...ua(m(x)),t))):a=(...x)=>s(new i(e,...ua(m(x)))),a.setParameterLength=(...x)=>(x.length===1?h=f=x[0]:x.length===2&&([h,f]=x),a),a.setName=x=>(c=x,a),a},Tp=function(i,...e){return Oe(new i(...ua(e)))};class sd extends Rt{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(e)}getElementType(e){return this.getOutputNode(e).getElementType(e)}getMemberType(e,t){return this.getOutputNode(e).getMemberType(e,t)}call(e){const{shaderNode:t,rawInputs:r}=this,s=e.getNodeProperties(t),a=e.getClosestSubBuild(t.subBuilds)||"",c=a||"default";if(s[c])return s[c];const h=e.subBuildFn,f=e.fnCall;e.subBuildFn=a,e.fnCall=this;let m=null;if(t.layout){let x=vp.get(e.constructor);x===void 0&&(x=new WeakMap,vp.set(e.constructor,x));let _=x.get(t);_===void 0&&(_=Oe(e.buildFunctionNode(t)),x.set(t,_)),e.addInclude(_);const v=r?od(r):null;m=Oe(_.call(v))}else{const x=new Proxy(e,{get:(P,C,E)=>{let D;return Symbol.iterator===C?D=function*(){yield void 0}:D=Reflect.get(P,C,E),D}}),_=r?Mp(r):null,v=Array.isArray(r)?r.length>0:r!==null,T=t.jsFunc,w=v||T.length>1?T(_,x):T(x);m=Oe(w)}return e.subBuildFn=h,e.fnCall=f,t.once&&(s[c]=m),m}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const t=e.getNodeProperties(this),r=e.getSubBuildOutput(this);return t[r]=t[r]||this.setupOutput(e),t[r].subBuild=e.getClosestSubBuild(this),t[r]}build(e,t=null){let r=null;const s=e.getBuildStage(),a=e.getNodeProperties(this),c=e.getSubBuildOutput(this),h=this.getOutputNode(e),f=e.fnCall;if(e.fnCall=this,s==="setup"){const m=e.getSubBuildProperty("initialized",this);if(a[m]!==!0&&(a[m]=!0,a[c]=this.getOutputNode(e),a[c].build(e),this.shaderNode.subBuilds))for(const x of e.chaining){const _=e.getDataFromNode(x,"any");_.subBuilds=_.subBuilds||new Set;for(const v of this.shaderNode.subBuilds)_.subBuilds.add(v)}r=a[c]}else s==="analyze"?h.build(e,t):s==="generate"&&(r=h.build(e,t)||"");return e.fnCall=f,r}}function od(i){let e;return cu(i),i[0]&&(i[0].isNode||Object.getPrototypeOf(i[0])!==Object.prototype)?e=[...i]:e=i[0],e}function Mp(i){let e=0;return cu(i),new Proxy(i,{get:(t,r,s)=>{let a;if(r==="length")return a=i.length,a;if(Symbol.iterator===r)a=function*(){for(const c of i)yield Oe(c)};else{if(i.length>0)if(Object.getPrototypeOf(i[0])===Object.prototype){const c=i[0];c[r]===void 0?a=c[e++]:a=Reflect.get(c,r,s)}else i[0]instanceof Rt&&(i[r]===void 0?a=i[e++]:a=Reflect.get(i,r,s));else a=Reflect.get(t,r,s);a=Oe(a)}return a}})}class wp extends Rt{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}getLayout(){return this.layout}call(e=null){return new sd(this,e)}setup(){return this.call()}}const lb=[!1,!0],ru=[0,1,2,3],Ap=[-1,-2],ad=[.5,1.5,1/3,1e-6,1e6,Math.PI,Math.PI*2,1/Math.PI,2/Math.PI,1/(Math.PI*2),Math.PI/2],su=new Map;for(const i of lb)su.set(i,new Fr(i));const sl=new Map;for(const i of ru)sl.set(i,new Fr(i,"uint"));const Ep=new Map([...sl].map(i=>new Fr(i.value,"int")));for(const i of Ap)Ep.set(i,new Fr(i,"int"));const ou=new Map([...Ep].map(i=>new Fr(i.value)));for(const i of ad)ou.set(i,new Fr(i));for(const i of ad)ou.set(-i,new Fr(-i));const au={bool:su,uint:sl,ints:Ep,float:ou},Cp=new Map([...su,...ou]),Rp=(i,e)=>Cp.has(i)?Cp.get(i):i.isNode===!0?i:new Fr(i,e),ki=function(i,e=null){return(...t)=>{for(const s of t)if(s===void 0)return(0,d.vUy)(`TSL: Invalid parameter for the type "${i}".`),Oe(new Fr(0,i));if((t.length===0||!["bool","float","int","uint"].includes(i)&&t.every(s=>{const a=typeof s;return a!=="object"&&a!=="function"}))&&(t=[tl(i,...t)]),t.length===1&&e!==null&&e.has(t[0]))return al(e.get(t[0]));if(t.length===1){const s=Rp(t[0],i);return s.nodeType===i?al(s):al(new td(s,i))}const r=t.map(s=>Rp(s));return al(new b0(r,i))}},ol=i=>typeof i=="object"&&i!==null?i.value:i,Np=i=>i!=null?i.nodeType||i.convertTo||(typeof i=="string"?i:null):null;function nc(i,e){return new wp(i,e)}const Oe=(i,e=null)=>Sp(i,e),al=(i,e=null)=>Oe(i,e).toVarIntent(),cu=(i,e=null)=>new ab(i,e),ua=(i,e=null)=>new cb(i,e),sn=(i,e=null,t=null,r=null)=>new rd(i,e,t,r),pt=(i,...e)=>new Tp(i,...e),at=(i,e=null,t=null,r={})=>new rd(i,e,t,To(rr({},r),{intent:!0}));let T0=0;class M0 extends Rt{constructor(e,t=null){super();let r=null;t!==null&&(typeof t=="object"?r=t.return:(typeof t=="string"?r=t:(0,d.vUy)("TSL: Invalid layout type."),t=null)),this.shaderNode=new nc(e,r),t!==null&&this.setLayout(t),this.isFn=!0}setLayout(e){const t=this.shaderNode.nodeType;if(typeof e.inputs!="object"){const r={name:"fn"+T0++,type:t,inputs:[]};for(const s in e)s!=="return"&&r.inputs.push({name:s,type:e[s]});e=r}return this.shaderNode.setLayout(e),this}getNodeType(e){return this.shaderNode.getNodeType(e)||"float"}call(...e){const t=this.shaderNode.call(e);return this.shaderNode.nodeType==="void"&&t.toStack(),t.toVarIntent()}once(e=null){return this.shaderNode.once=!0,this.shaderNode.subBuilds=e,this}generate(e){const t=this.getNodeType(e);return(0,d.vUy)('TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".'),e.generateConst(t)}}function fe(i,e=null){const t=new M0(i,e);return new Proxy(()=>{},{apply(r,s,a){return t.call(...a)},get(r,s,a){return Reflect.get(t,s,a)},set(r,s,a,c){return Reflect.set(t,s,a,c)}})}const ic=i=>{_s=i},Pp=()=>_s,Dt=(...i)=>_s.If(...i),_T=(...i)=>_s.Switch(...i);function rc(i){return _s&&_s.addToStack(i),i}De("toStack",rc);const w0=new ki("color"),G=new ki("float",au.float),re=new ki("int",au.ints),Je=new ki("uint",au.uint),br=new ki("bool",au.bool),Ve=new ki("vec2"),Vi=new ki("ivec2"),A0=new ki("uvec2"),lu=new ki("bvec2"),ce=new ki("vec3"),uu=new ki("ivec3"),zo=new ki("uvec3"),Lp=new ki("bvec3"),At=new ki("vec4"),co=new ki("ivec4"),Ip=new ki("uvec4"),E0=new ki("bvec4"),cl=new ki("mat2"),Ni=new ki("mat3"),sc=new ki("mat4"),ha=(i="")=>Oe(new Fr(i,"string")),yT=i=>Oe(new Fr(i,"ArrayBuffer"));De("toColor",w0),De("toFloat",G),De("toInt",re),De("toUint",Je),De("toBool",br),De("toVec2",Ve),De("toIVec2",Vi),De("toUVec2",A0),De("toBVec2",lu),De("toVec3",ce),De("toIVec3",uu),De("toUVec3",zo),De("toBVec3",Lp),De("toVec4",At),De("toIVec4",co),De("toUVec4",Ip),De("toBVec4",E0),De("toMat2",cl),De("toMat3",Ni),De("toMat4",sc);const ub=sn(ec).setParameterLength(2),oc=(i,e)=>Oe(new td(Oe(i),e)),cd=(i,e)=>Oe(new v0(Oe(i),e));De("element",ub),De("convert",oc);const bT=i=>((0,d.ZK6)("TSL: append() has been renamed to Stack()."),rc(i));De("append",i=>((0,d.ZK6)("TSL: .append() has been renamed to .toStack()."),rc(i)));class oi extends Rt{static get type(){return"PropertyNode"}constructor(e,t=null,r=!1){super(e),this.name=t,this.varying=r,this.isPropertyNode=!0,this.global=!0}customCacheKey(){return Jc(this.type+":"+(this.name||"")+":"+(this.varying?"1":"0"))}getHash(e){return this.name||super.getHash(e)}generate(e){let t;return this.varying===!0?(t=e.getVaryingFromNode(this,this.name),t.needsInterpolation=!0):t=e.getVarFromNode(this,this.name),e.getPropertyName(t)}}const Vs=(i,e)=>Oe(new oi(i,e)),lr=(i,e)=>Oe(new oi(i,e,!0)),jn=pt(oi,"vec4","DiffuseColor"),hu=pt(oi,"vec3","EmissiveColor"),zs=pt(oi,"float","Roughness"),ll=pt(oi,"float","Metalness"),ul=pt(oi,"float","Clearcoat"),du=pt(oi,"float","ClearcoatRoughness"),da=pt(oi,"vec3","Sheen"),fu=pt(oi,"float","SheenRoughness"),fa=pt(oi,"float","Iridescence"),pu=pt(oi,"float","IridescenceIOR"),Dp=pt(oi,"float","IridescenceThickness"),mu=pt(oi,"float","AlphaT"),lo=pt(oi,"float","Anisotropy"),gu=pt(oi,"vec3","AnisotropyT"),pa=pt(oi,"vec3","AnisotropyB"),as=pt(oi,"color","SpecularColor"),hl=pt(oi,"float","SpecularF90"),ld=pt(oi,"float","Shininess"),ac=pt(oi,"vec4","Output"),Go=pt(oi,"float","dashSize"),dl=pt(oi,"float","gapSize"),hb=pt(oi,"float","pointWidth"),xu=pt(oi,"float","IOR"),Up=pt(oi,"float","Transmission"),Fp=pt(oi,"float","Thickness"),ud=pt(oi,"float","AttenuationDistance"),hd=pt(oi,"color","AttenuationColor"),_u=pt(oi,"float","Dispersion");class db extends Rt{static get type(){return"UniformGroupNode"}constructor(e,t=!1,r=1){super("string"),this.name=e,this.shared=t,this.order=r,this.isUniformGroup=!0}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}}const yu=i=>new db(i),bu=(i,e=0)=>new db(i,!0,e),fb=bu("frame"),Ft=bu("render"),dd=yu("object");class Gs extends nd{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=dd}setName(e){return this.name=e,this}label(e){return(0,d.ZK6)('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setGroup(e){return this.groupNode=e,this}getGroup(){return this.groupNode}getUniformHash(e){return this.getHash(e)}onUpdate(e,t){return e=e.bind(this),super.onUpdate(r=>{const s=e(r,this);s!==void 0&&(this.value=s)},t)}getInputType(e){let t=super.getInputType(e);return t==="bool"&&(t="uint"),t}generate(e,t){const r=this.getNodeType(e),s=this.getUniformHash(e);let a=e.getNodeFromHash(s);a===void 0&&(e.setHashNode(this,s),a=this);const c=a.getInputType(e),h=e.getUniformFromNode(a,c,e.shaderStage,this.name||e.context.nodeName),f=e.getPropertyName(h);e.context.nodeName!==void 0&&delete e.context.nodeName;let m=f;if(r==="bool"){const x=e.getDataFromNode(this);let _=x.propertyName;if(_===void 0){const v=e.getVarFromNode(this,null,"bool");_=e.getPropertyName(v),x.propertyName=_,m=e.format(f,c,r),e.addLineFlowCode(`${_} = ${m}`,this)}m=_}return e.format(m,r,t)}}const Bt=(i,e)=>{const t=Np(e||i);return t===i&&(i=tl(t)),i=i&&i.isNode===!0?i.node&&i.node.value||i.value:i,Oe(new Gs(i,t))};class C0 extends Oi{static get type(){return"ArrayNode"}constructor(e,t,r=null){super(e),this.count=t,this.values=r,this.isArrayNode=!0}getArrayCount(){return this.count}getNodeType(e){return this.nodeType===null&&(this.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const Bp=(...i)=>{let e;if(i.length===1){const t=i[0];e=new C0(null,t.length,t)}else{const t=i[0],r=i[1];e=new C0(t,r)}return Oe(e)};De("toArray",(i,e)=>Bp(Array(e).fill(i)));class cc extends Oi{static get type(){return"AssignNode"}constructor(e,t){super(),this.targetNode=e,this.sourceNode=t,this.isAssignNode=!0}hasDependencies(){return!1}getNodeType(e,t){return t!=="void"?this.targetNode.getNodeType(e):"void"}needsSplitAssign(e){const{targetNode:t}=this;if(e.isAvailable("swizzleAssign")===!1&&t.isSplitNode&&t.components.length>1){const r=e.getTypeLength(t.node.getNodeType(e));return Ja.join("").slice(0,r)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:r}=this,s=t.getScope(),a=e.getNodeProperties(s);a.assign=!0;const c=e.getNodeProperties(this);c.sourceNode=r,c.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:r,sourceNode:s}=e.getNodeProperties(this),a=this.needsSplitAssign(e),c=r.build(e),h=r.getNodeType(e),f=s.build(e,h),m=s.getNodeType(e),x=e.getDataFromNode(this);let _;if(x.initialized===!0)t!=="void"&&(_=c);else if(a){const v=e.getVarFromNode(this,null,h),T=e.getPropertyName(v);e.addLineFlowCode(`${T} = ${f}`,this);const w=r.node,C=w.node.context({assign:!0}).build(e);for(let E=0;E<w.components.length;E++){const D=w.components[E];e.addLineFlowCode(`${C}.${D} = ${T}[ ${E} ]`,this)}t!=="void"&&(_=c)}else _=`${c} = ${f}`,(t==="void"||m==="void")&&(e.addLineFlowCode(_,this),t!=="void"&&(_=c));return x.initialized=!0,e.format(_,h,t)}}const fd=sn(cc).setParameterLength(2);De("assign",fd);class pb extends Oi{static get type(){return"FunctionCallNode"}constructor(e=null,t={}){super(),this.functionNode=e,this.parameters=t}setParameters(e){return this.parameters=e,this}getParameters(){return this.parameters}getNodeType(e){return this.functionNode.getNodeType(e)}getMemberType(e,t){return this.functionNode.getMemberType(e,t)}generate(e){const t=[],r=this.functionNode,s=r.getInputs(e),a=this.parameters,c=(f,m)=>{const x=m.type,_=x==="pointer";let v;return _?v="&"+f.build(e):v=f.build(e,x),v};if(Array.isArray(a)){if(a.length>s.length)(0,d.vUy)("TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),a.length=s.length;else if(a.length<s.length)for((0,d.vUy)("TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");a.length<s.length;)a.push(G(0));for(let f=0;f<a.length;f++)t.push(c(a[f],s[f]))}else for(const f of s){const m=a[f.name];m!==void 0?t.push(c(m,f)):((0,d.vUy)(`TSL: Input '${f.name}' not found in 'Fn()'.`),t.push(c(G(0),f)))}return`${r.build(e,"property")}( ${t.join(", ")} )`}}const ma=(i,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?ua(e):cu(e[0]),new pb(Oe(i),e));De("call",ma);const lc={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class Ii extends Oi{static get type(){return"OperatorNode"}constructor(e,t,r,...s){if(super(),s.length>0){let a=new Ii(e,t,r);for(let c=0;c<s.length-1;c++)a=new Ii(e,a,s[c]);t=a,r=s[s.length-1]}this.op=e,this.aNode=t,this.bNode=r,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(lc[this.op],t)}getNodeType(e,t=null){const r=this.op,s=this.aNode,a=this.bNode,c=s.getNodeType(e),h=a?a.getNodeType(e):null;if(c==="void"||h==="void")return t||"void";if(r==="%")return c;if(r==="~"||r==="&"||r==="|"||r==="^"||r===">>"||r==="<<")return e.getIntegerType(c);if(r==="!"||r==="&&"||r==="||"||r==="^^")return"bool";if(r==="=="||r==="!="||r==="<"||r===">"||r==="<="||r===">="){const f=Math.max(e.getTypeLength(c),e.getTypeLength(h));return f>1?`bvec${f}`:"bool"}else{if(e.isMatrix(c)){if(h==="float")return c;if(e.isVector(h))return e.getVectorFromMatrix(c);if(e.isMatrix(h))return c}else if(e.isMatrix(h)){if(c==="float")return h;if(e.isVector(c))return e.getVectorFromMatrix(h)}return e.getTypeLength(h)>e.getTypeLength(c)?h:c}}generate(e,t){const r=this.op,{aNode:s,bNode:a}=this,c=this.getNodeType(e,t);let h=null,f=null;c!=="void"?(h=s.getNodeType(e),f=a?a.getNodeType(e):null,r==="<"||r===">"||r==="<="||r===">="||r==="=="||r==="!="?e.isVector(h)?f=h:e.isVector(f)?h=f:h!==f&&(h=f="float"):r===">>"||r==="<<"?(h=c,f=e.changeComponentType(f,"uint")):r==="%"?(h=c,f=e.isInteger(h)&&e.isInteger(f)?f:h):e.isMatrix(h)?f==="float"?f="float":e.isVector(f)?f=e.getVectorFromMatrix(h):e.isMatrix(f)||(h=f=c):e.isMatrix(f)?h==="float"?h="float":e.isVector(h)?h=e.getVectorFromMatrix(f):h=f=c:h=f=c):h=f=c;const m=s.build(e,h),x=a?a.build(e,f):null,_=e.getFunctionOperator(r);if(t!=="void"){const v=e.renderer.coordinateSystem===d._RZ;if(r==="=="||r==="!="||r==="<"||r===">"||r==="<="||r===">=")return v?e.isVector(h)?e.format(`${this.getOperatorMethod(e,t)}( ${m}, ${x} )`,c,t):e.format(`( ${m} ${r} ${x} )`,c,t):e.format(`( ${m} ${r} ${x} )`,c,t);if(r==="%")return e.isInteger(f)?e.format(`( ${m} % ${x} )`,c,t):e.format(`${this.getOperatorMethod(e,c)}( ${m}, ${x} )`,c,t);if(r==="!"||r==="~")return e.format(`(${r}${m})`,h,t);if(_)return e.format(`${_}( ${m}, ${x} )`,c,t);if(e.isMatrix(h)&&f==="float")return e.format(`( ${x} ${r} ${m} )`,c,t);if(h==="float"&&e.isMatrix(f))return e.format(`${m} ${r} ${x}`,c,t);{let T=`( ${m} ${r} ${x} )`;return!v&&c==="bool"&&e.isVector(h)&&e.isVector(f)&&(T=`all${T}`),e.format(T,c,t)}}else if(h!=="void")return _?e.format(`${_}( ${m}, ${x} )`,c,t):e.isMatrix(h)&&f==="float"?e.format(`${x} ${r} ${m}`,c,t):e.format(`${m} ${r} ${x}`,c,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const Yi=at(Ii,"+").setParameterLength(2,1/0).setName("add"),Cn=at(Ii,"-").setParameterLength(2,1/0).setName("sub"),cn=at(Ii,"*").setParameterLength(2,1/0).setName("mul"),cs=at(Ii,"/").setParameterLength(2,1/0).setName("div"),Ws=at(Ii,"%").setParameterLength(2).setName("mod"),R0=at(Ii,"==").setParameterLength(2).setName("equal"),mb=at(Ii,"!=").setParameterLength(2).setName("notEqual"),N0=at(Ii,"<").setParameterLength(2).setName("lessThan"),vu=at(Ii,">").setParameterLength(2).setName("greaterThan"),P0=at(Ii,"<=").setParameterLength(2).setName("lessThanEqual"),pd=at(Ii,">=").setParameterLength(2).setName("greaterThanEqual"),L0=at(Ii,"&&").setParameterLength(2,1/0).setName("and"),I0=at(Ii,"||").setParameterLength(2,1/0).setName("or"),D0=at(Ii,"!").setParameterLength(1).setName("not"),U0=at(Ii,"^^").setParameterLength(2).setName("xor"),F0=at(Ii,"&").setParameterLength(2).setName("bitAnd"),B0=at(Ii,"~").setParameterLength(1).setName("bitNot"),O0=at(Ii,"|").setParameterLength(2).setName("bitOr"),k0=at(Ii,"^").setParameterLength(2).setName("bitXor"),Jn=at(Ii,"<<").setParameterLength(2).setName("shiftLeft"),gb=at(Ii,">>").setParameterLength(2).setName("shiftRight"),V0=fe(([i])=>(i.addAssign(1),i)),z0=fe(([i])=>(i.subAssign(1),i)),xb=fe(([i])=>{const e=re(i).toConst();return i.addAssign(1),e}),_b=fe(([i])=>{const e=re(i).toConst();return i.subAssign(1),e});De("add",Yi),De("sub",Cn),De("mul",cn),De("div",cs),De("mod",Ws),De("equal",R0),De("notEqual",mb),De("lessThan",N0),De("greaterThan",vu),De("lessThanEqual",P0),De("greaterThanEqual",pd),De("and",L0),De("or",I0),De("not",D0),De("xor",U0),De("bitAnd",F0),De("bitNot",B0),De("bitOr",O0),De("bitXor",k0),De("shiftLeft",Jn),De("shiftRight",gb),De("incrementBefore",V0),De("decrementBefore",z0),De("increment",xb),De("decrement",_b);const Op=(i,e)=>((0,d.ZK6)('TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),Ws(re(i),re(e)));De("modInt",Op);class Se extends Oi{static get type(){return"MathNode"}constructor(e,t,r=null,s=null){if(super(),(e===Se.MAX||e===Se.MIN)&&arguments.length>3){let a=new Se(e,t,r);for(let c=2;c<arguments.length-1;c++)a=new Se(e,a,arguments[c]);t=a,r=arguments[arguments.length-1],s=null}this.method=e,this.aNode=t,this.bNode=r,this.cNode=s,this.isMathNode=!0}getInputType(e){const t=this.aNode.getNodeType(e),r=this.bNode?this.bNode.getNodeType(e):null,s=this.cNode?this.cNode.getNodeType(e):null,a=e.isMatrix(t)?0:e.getTypeLength(t),c=e.isMatrix(r)?0:e.getTypeLength(r),h=e.isMatrix(s)?0:e.getTypeLength(s);return a>c&&a>h?t:c>h?r:h>a?s:t}getNodeType(e){const t=this.method;return t===Se.LENGTH||t===Se.DISTANCE||t===Se.DOT?"float":t===Se.CROSS?"vec3":t===Se.ALL||t===Se.ANY?"bool":t===Se.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:t,bNode:r,method:s}=this;let a=null;if(s===Se.ONE_MINUS)a=Cn(1,t);else if(s===Se.RECIPROCAL)a=cs(1,t);else if(s===Se.DIFFERENCE)a=ai(Cn(t,r));else if(s===Se.TRANSFORM_DIRECTION){let c=t,h=r;e.isMatrix(c.getNodeType(e))?h=At(ce(h),0):c=At(ce(c),0);const f=cn(c,h).xyz;a=Er(f)}return a!==null?a:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let s=this.method;const a=this.getNodeType(e),c=this.getInputType(e),h=this.aNode,f=this.bNode,m=this.cNode,x=e.renderer.coordinateSystem;if(s===Se.NEGATE)return e.format("( - "+h.build(e,c)+" )",a,t);{const _=[];return s===Se.CROSS?_.push(h.build(e,a),f.build(e,a)):x===d._RZ&&s===Se.STEP?_.push(h.build(e,e.getTypeLength(h.getNodeType(e))===1?"float":c),f.build(e,c)):x===d._RZ&&(s===Se.MIN||s===Se.MAX)?_.push(h.build(e,c),f.build(e,e.getTypeLength(f.getNodeType(e))===1?"float":c)):s===Se.REFRACT?_.push(h.build(e,c),f.build(e,c),m.build(e,"float")):s===Se.MIX?_.push(h.build(e,c),f.build(e,c),m.build(e,e.getTypeLength(m.getNodeType(e))===1?"float":c)):(x===d.JCZ&&s===Se.ATAN&&f!==null&&(s="atan2"),e.shaderStage!=="fragment"&&(s===Se.DFDX||s===Se.DFDY)&&((0,d.ZK6)(`TSL: '${s}' is not supported in the ${e.shaderStage} stage.`),s="/*"+s+"*/"),_.push(h.build(e,c)),f!==null&&_.push(f.build(e,c)),m!==null&&_.push(m.build(e,c))),e.format(`${e.getMethod(s,a)}( ${_.join(", ")} )`,a,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}Se.ALL="all",Se.ANY="any",Se.RADIANS="radians",Se.DEGREES="degrees",Se.EXP="exp",Se.EXP2="exp2",Se.LOG="log",Se.LOG2="log2",Se.SQRT="sqrt",Se.INVERSE_SQRT="inversesqrt",Se.FLOOR="floor",Se.CEIL="ceil",Se.NORMALIZE="normalize",Se.FRACT="fract",Se.SIN="sin",Se.COS="cos",Se.TAN="tan",Se.ASIN="asin",Se.ACOS="acos",Se.ATAN="atan",Se.ABS="abs",Se.SIGN="sign",Se.LENGTH="length",Se.NEGATE="negate",Se.ONE_MINUS="oneMinus",Se.DFDX="dFdx",Se.DFDY="dFdy",Se.ROUND="round",Se.RECIPROCAL="reciprocal",Se.TRUNC="trunc",Se.FWIDTH="fwidth",Se.TRANSPOSE="transpose",Se.DETERMINANT="determinant",Se.INVERSE="inverse",Se.EQUALS="equals",Se.MIN="min",Se.MAX="max",Se.STEP="step",Se.REFLECT="reflect",Se.DISTANCE="distance",Se.DIFFERENCE="difference",Se.DOT="dot",Se.CROSS="cross",Se.POW="pow",Se.TRANSFORM_DIRECTION="transformDirection",Se.MIX="mix",Se.CLAMP="clamp",Se.REFRACT="refract",Se.SMOOTHSTEP="smoothstep",Se.FACEFORWARD="faceforward";const G0=G(1e-6),yb=G(1e6),kp=G(Math.PI),W0=G(Math.PI*2),bb=G(Math.PI*2),H0=G(Math.PI*.5),md=at(Se,Se.ALL).setParameterLength(1),vb=at(Se,Se.ANY).setParameterLength(1),$0=at(Se,Se.RADIANS).setParameterLength(1),j0=at(Se,Se.DEGREES).setParameterLength(1),X0=at(Se,Se.EXP).setParameterLength(1),ga=at(Se,Se.EXP2).setParameterLength(1),Su=at(Se,Se.LOG).setParameterLength(1),Wo=at(Se,Se.LOG2).setParameterLength(1),Br=at(Se,Se.SQRT).setParameterLength(1),fl=at(Se,Se.INVERSE_SQRT).setParameterLength(1),Or=at(Se,Se.FLOOR).setParameterLength(1),Ho=at(Se,Se.CEIL).setParameterLength(1),Er=at(Se,Se.NORMALIZE).setParameterLength(1),Hs=at(Se,Se.FRACT).setParameterLength(1),jr=at(Se,Se.SIN).setParameterLength(1),$o=at(Se,Se.COS).setParameterLength(1),Vp=at(Se,Se.TAN).setParameterLength(1),Sb=at(Se,Se.ASIN).setParameterLength(1),uo=at(Se,Se.ACOS).setParameterLength(1),uc=at(Se,Se.ATAN).setParameterLength(1,2),ai=at(Se,Se.ABS).setParameterLength(1),gd=at(Se,Se.SIGN).setParameterLength(1),$s=at(Se,Se.LENGTH).setParameterLength(1),Tb=at(Se,Se.NEGATE).setParameterLength(1),q0=at(Se,Se.ONE_MINUS).setParameterLength(1),xd=at(Se,Se.DFDX).setParameterLength(1),_d=at(Se,Se.DFDY).setParameterLength(1),Mb=at(Se,Se.ROUND).setParameterLength(1),wb=at(Se,Se.RECIPROCAL).setParameterLength(1),K0=at(Se,Se.TRUNC).setParameterLength(1),yd=at(Se,Se.FWIDTH).setParameterLength(1),Tu=at(Se,Se.TRANSPOSE).setParameterLength(1),zp=at(Se,Se.DETERMINANT).setParameterLength(1),Ab=at(Se,Se.INVERSE).setParameterLength(1),Mu=(i,e)=>((0,d.ZK6)('TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),R0(i,e)),Kn=at(Se,Se.MIN).setParameterLength(2,1/0),Mi=at(Se,Se.MAX).setParameterLength(2,1/0),Pi=at(Se,Se.STEP).setParameterLength(2),wu=at(Se,Se.REFLECT).setParameterLength(2),Eb=at(Se,Se.DISTANCE).setParameterLength(2),Cb=at(Se,Se.DIFFERENCE).setParameterLength(2),ho=at(Se,Se.DOT).setParameterLength(2),xa=at(Se,Se.CROSS).setParameterLength(2),kr=at(Se,Se.POW).setParameterLength(2),Au=i=>cn(i,i),Rb=i=>cn(i,i,i),Z0=i=>cn(i,i,i,i),Nb=at(Se,Se.TRANSFORM_DIRECTION).setParameterLength(2),Y0=i=>cn(gd(i),kr(ai(i),1/3)),Gp=i=>ho(i,i),Xn=at(Se,Se.MIX).setParameterLength(3),ys=(i,e=0,t=1)=>Oe(new Se(Se.CLAMP,Oe(i),Oe(e),Oe(t))),bd=i=>ys(i),Wp=at(Se,Se.REFRACT).setParameterLength(3),bs=at(Se,Se.SMOOTHSTEP).setParameterLength(3),M=at(Se,Se.FACEFORWARD).setParameterLength(3),n=fe(([i])=>{const r=43758.5453,s=ho(i.xy,Ve(12.9898,78.233)),a=Ws(s,kp);return Hs(jr(a).mul(r))}),o=(i,e,t)=>Xn(e,t,i),l=(i,e,t)=>bs(e,t,i),u=(i,e)=>Pi(e,i),p=(i,e)=>((0,d.ZK6)('TSL: "atan2" is overloaded. Use "atan" instead.'),uc(i,e)),g=M,y=fl;De("all",md),De("any",vb),De("equals",Mu),De("radians",$0),De("degrees",j0),De("exp",X0),De("exp2",ga),De("log",Su),De("log2",Wo),De("sqrt",Br),De("inverseSqrt",fl),De("floor",Or),De("ceil",Ho),De("normalize",Er),De("fract",Hs),De("sin",jr),De("cos",$o),De("tan",Vp),De("asin",Sb),De("acos",uo),De("atan",uc),De("abs",ai),De("sign",gd),De("length",$s),De("lengthSq",Gp),De("negate",Tb),De("oneMinus",q0),De("dFdx",xd),De("dFdy",_d),De("round",Mb),De("reciprocal",wb),De("trunc",K0),De("fwidth",yd),De("atan2",p),De("min",Kn),De("max",Mi),De("step",u),De("reflect",wu),De("distance",Eb),De("dot",ho),De("cross",xa),De("pow",kr),De("pow2",Au),De("pow3",Rb),De("pow4",Z0),De("transformDirection",Nb),De("mix",o),De("clamp",ys),De("refract",Wp),De("smoothstep",l),De("faceForward",M),De("difference",Cb),De("saturate",bd),De("cbrt",Y0),De("transpose",Tu),De("determinant",zp),De("inverse",Ab),De("rand",n);class b extends Rt{static get type(){return"ConditionalNode"}constructor(e,t,r=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=r}getNodeType(e){const{ifNode:t,elseNode:r}=e.getNodeProperties(this);if(t===void 0)return e.flowBuildStage(this,"setup"),this.getNodeType(e);const s=t.getNodeType(e);if(r!==null){const a=r.getNodeType(e);if(e.getTypeLength(a)>e.getTypeLength(s))return a}return s}setup(e){const t=this.condNode,r=this.ifNode.isolate(),s=this.elseNode?this.elseNode.isolate():null,a=e.context.nodeBlock;e.getDataFromNode(r).parentNodeBlock=a,s!==null&&(e.getDataFromNode(s).parentNodeBlock=a);const c=e.context.uniformFlow,h=e.getNodeProperties(this);h.condNode=t,h.ifNode=c?r:r.context({nodeBlock:r}),h.elseNode=s?c?s:s.context({nodeBlock:s}):null}generate(e,t){const r=this.getNodeType(e),s=e.getDataFromNode(this);if(s.nodeProperty!==void 0)return s.nodeProperty;const{condNode:a,ifNode:c,elseNode:h}=e.getNodeProperties(this),f=e.currentFunctionNode,m=t!=="void",x=m?Vs(r).build(e):"";s.nodeProperty=x;const _=a.build(e,"bool");if(e.context.uniformFlow&&h!==null){const w=c.build(e,r),P=h.build(e,r),C=e.getTernary(_,w,P);return e.format(C,r,t)}e.addFlowCode(`
${e.tab}if ( ${_} ) {
`).addFlowTab();let T=c.build(e,r);if(T&&(m?T=x+" = "+T+";":(T="return "+T+";",f===null&&((0,d.ZK6)("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),T="// "+T))),e.removeFlowTab().addFlowCode(e.tab+" "+T+`
`+e.tab+"}"),h!==null){e.addFlowCode(` else {
`).addFlowTab();let w=h.build(e,r);w&&(m?w=x+" = "+w+";":(w="return "+w+";",f===null&&((0,d.ZK6)("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),w="// "+w))),e.removeFlowTab().addFlowCode(e.tab+" "+w+`
`+e.tab+`}
`)}else e.addFlowCode(`
`);return e.format(x,r,t)}}const S=sn(b).setParameterLength(2,3);De("select",S);class A extends Rt{static get type(){return"ContextNode"}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)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){const t=e.addContext(this.value);this.node.build(e),e.setContext(t)}setup(e){const t=e.addContext(this.value);this.node.build(e),e.setContext(t)}generate(e,t){const r=e.addContext(this.value),s=this.node.build(e,t);return e.setContext(r),s}}const R=sn(A).setParameterLength(1,2),N=i=>R(i,{uniformFlow:!0}),L=(i,e)=>R(i,{nodeName:e});function I(i,e){return(0,d.ZK6)('TSL: "label()" has been deprecated. Use "setName()" instead.'),L(i,e)}De("context",R),De("label",I),De("uniformFlow",N),De("setName",L);class B extends Rt{static get type(){return"VarNode"}constructor(e,t=null,r=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=r,this.parents=!0,this.intent=!1}setIntent(e){return this.intent=e,this}getIntent(){return this.intent}getMemberType(e,t){return this.node.getMemberType(e,t)}getElementType(e){return this.node.getElementType(e)}getNodeType(e){return this.node.getNodeType(e)}getArrayCount(e){return this.node.getArrayCount(e)}isAssign(e){let r=e.getNodeProperties(this).assign;return r!==!0&&this.node.isShaderCallNodeInternal&&this.node.shaderNode.getLayout()===null&&e.fnCall&&e.fnCall.shaderNode&&e.getDataFromNode(this.node.shaderNode).hasLoop&&(r=!0),r}build(...e){const t=e[0];return this._hasStack(t)===!1&&t.buildStage==="setup"&&(t.context.nodeLoop||t.context.nodeBlock)&&t.getBaseStack().addToStack(this),this.intent===!0&&this.isAssign(t)!==!0?this.node.build(...e):super.build(...e)}generate(e){const{node:t,name:r,readOnly:s}=this,{renderer:a}=e,c=a.backend.isWebGPUBackend===!0;let h=!1,f=!1;s&&(h=e.isDeterministic(t),f=c?s:h);const m=this.getNodeType(e);if(m=="void")return this.intent!==!0&&(0,d.vUy)('TSL: ".toVar()" can not be used with void type.'),t.build(e);const x=e.getVectorType(m),_=t.build(e,x),v=e.getVarFromNode(this,r,x,void 0,f),T=e.getPropertyName(v);let w=T;if(f)if(c)w=h?`const ${T}`:`let ${T}`;else{const P=t.getArrayCount(e);w=`const ${e.getVar(v.type,T,P)}`}return e.addLineFlowCode(`${w} = ${_}`,this),T}_hasStack(e){return e.getDataFromNode(this).stack!==void 0}}const Z=sn(B),q=(i,e=null)=>Z(i,e).toStack(),ee=(i,e=null)=>Z(i,e,!0).toStack(),te=i=>Z(i).setIntent(!0).toStack();De("toVar",q),De("toConst",ee),De("toVarIntent",te);class he extends Rt{static get type(){return"SubBuild"}constructor(e,t,r=null){super(r),this.node=e,this.name=t,this.isSubBuildNode=!0}getNodeType(e){if(this.nodeType!==null)return this.nodeType;e.addSubBuild(this.name);const t=this.node.getNodeType(e);return e.removeSubBuild(),t}build(e,...t){e.addSubBuild(this.name);const r=this.node.build(e,...t);return e.removeSubBuild(),r}}const Re=(i,e,t=null)=>Oe(new he(Oe(i),e,t));class ke extends Rt{static get type(){return"VaryingNode"}constructor(e,t=null){super(),this.node=e,this.name=t,this.isVaryingNode=!0,this.interpolationType=null,this.interpolationSampling=null,this.global=!0}setInterpolation(e,t=null){return this.interpolationType=e,this.interpolationSampling=t,this}getHash(e){return this.name||super.getHash(e)}getNodeType(e){return this.node.getNodeType(e)}setupVarying(e){const t=e.getNodeProperties(this);let r=t.varying;if(r===void 0){const s=this.name,a=this.getNodeType(e),c=this.interpolationType,h=this.interpolationSampling;t.varying=r=e.getVaryingFromNode(this,s,a,c,h),t.node=Re(this.node,"VERTEX")}return r.needsInterpolation||(r.needsInterpolation=e.shaderStage==="fragment"),r}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(Vo.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(Vo.VERTEX,this.node)}generate(e){const t=e.getSubBuildProperty("property",e.currentStack),r=e.getNodeProperties(this),s=this.setupVarying(e);if(r[t]===void 0){const a=this.getNodeType(e),c=e.getPropertyName(s,Vo.VERTEX);e.flowNodeFromShaderStage(Vo.VERTEX,r.node,a,c),r[t]=c}return e.getPropertyName(s)}}const We=sn(ke).setParameterLength(1,2),ze=i=>We(i);De("toVarying",We),De("toVertexStage",ze),De("varying",(...i)=>((0,d.ZK6)("TSL: .varying() has been renamed to .toVarying()."),We(...i))),De("vertexStage",(...i)=>((0,d.ZK6)("TSL: .vertexStage() has been renamed to .toVertexStage()."),We(...i)));const lt=fe(([i])=>{const e=i.mul(.9478672986).add(.0521327014).pow(2.4),t=i.mul(.0773993808),r=i.lessThanEqual(.04045);return Xn(e,t,r)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),mt=fe(([i])=>{const e=i.pow(.41666).mul(1.055).sub(.055),t=i.mul(12.92),r=i.lessThanEqual(.0031308);return Xn(e,t,r)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),Zt="WorkingColorSpace",Bn="OutputColorSpace";class Hn extends Oi{static get type(){return"ColorSpaceNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this.source=t,this.target=r}resolveColorSpace(e,t){return t===Zt?d.epp.workingColorSpace:t===Bn?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,r=this.resolveColorSpace(e,this.source),s=this.resolveColorSpace(e,this.target);let a=t;return d.epp.enabled===!1||r===s||!r||!s||(d.epp.getTransfer(r)===d.j17&&(a=At(lt(a.rgb),a.a)),d.epp.getPrimaries(r)!==d.epp.getPrimaries(s)&&(a=At(Ni(d.epp._getMatrix(new d.Vkp,r,s)).mul(a.rgb),a.a)),d.epp.getTransfer(s)===d.j17&&(a=At(mt(a.rgb),a.a))),a}}const pi=(i,e)=>Oe(new Hn(Oe(i),Zt,e)),ni=(i,e)=>Oe(new Hn(Oe(i),e,Zt)),ur=(i,e,t)=>Oe(new Hn(Oe(i),e,t));De("workingToColorSpace",pi),De("colorSpaceToWorking",ni);let vr=class extends ec{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,r,s)}};class vs extends Rt{static get type(){return"ReferenceBaseNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.updateType=xn.OBJECT}setGroup(e){return this.group=e,this}element(e){return Oe(new vr(this,Oe(e)))}setNodeType(e){const t=Bt(null,e);this.group!==null&&t.setGroup(this.group),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let s=1;s<t.length;s++)r=r[t[s]];return r}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}const zi=(i,e,t)=>Oe(new vs(i,e,t));class Qi extends vs{static get type(){return"RendererReferenceNode"}constructor(e,t,r=null){super(e,t,r),this.renderer=r,this.setGroup(Ft)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const Di=(i,e,t=null)=>Oe(new Qi(i,e,t));class js extends Oi{static get type(){return"ToneMappingNode"}constructor(e,t=hc,r=null){super("vec3"),this._toneMapping=e,this.exposureNode=t,this.colorNode=r}customCacheKey(){return Qa(this._toneMapping)}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup(e){const t=this.colorNode||e.context.color,r=this._toneMapping;if(r===d.uL9)return t;let s=null;const a=e.renderer.library.getToneMappingFunction(r);return a!==null?s=At(a(t.rgb,this.exposureNode),t.a):((0,d.vUy)("ToneMappingNode: Unsupported Tone Mapping configuration.",r),s=t),s}}const ls=(i,e,t)=>Oe(new js(i,Oe(e),Oe(t))),hc=Di("toneMappingExposure","float");De("toneMapping",(i,e,t)=>ls(e,t,i));class Eu extends nd{static get type(){return"BufferAttributeNode"}constructor(e,t=null,r=0,s=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=r,this.bufferOffset=s,this.usage=d.W2J,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;const t=this.getNodeType(e),r=this.value,s=e.getTypeLength(t),a=this.bufferStride||s,c=this.bufferOffset,h=r.isInterleavedBuffer===!0?r:new d.vpT(r,a),f=new d.kB5(h,s,c);h.setUsage(this.usage),this.attribute=f,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),r=e.getBufferAttributeFromNode(this,t),s=e.getPropertyName(r);let a=null;return e.shaderStage==="vertex"||e.shaderStage==="compute"?(this.name=s,a=s):a=We(this).build(e,t),a}getInputType(){return"bufferAttribute"}setUsage(e){return this.usage=e,this.attribute&&this.attribute.isBufferAttribute===!0&&(this.attribute.usage=e),this}setInstanced(e){return this.instanced=e,this}}const Cu=(i,e=null,t=0,r=0)=>Oe(new Eu(i,e,t,r)),Q0=(i,e=null,t=0,r=0)=>Cu(i,e,t,r).setUsage(d.dj0),Ru=(i,e=null,t=0,r=0)=>Cu(i,e,t,r).setInstanced(!0),Xs=(i,e=null,t=0,r=0)=>Q0(i,e,t,r).setInstanced(!0);De("toAttribute",i=>Cu(i.value));class vd extends Rt{static get type(){return"ComputeNode"}constructor(e,t){super("void"),this.isComputeNode=!0,this.computeNode=e,this.workgroupSize=t,this.count=null,this.version=1,this.name="",this.updateBeforeType=xn.OBJECT,this.onInitFunction=null}setCount(e){return this.count=e,this}getCount(){return this.count}dispose(){this.dispatchEvent({type:"dispose"})}setName(e){return this.name=e,this}label(e){return(0,d.ZK6)('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}onInit(e){return this.onInitFunction=e,this}updateBefore({renderer:e}){e.compute(this)}setup(e){const t=this.computeNode.build(e);if(t){const r=e.getNodeProperties(this);r.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){const{shaderStage:r}=e;if(r==="compute"){const s=this.computeNode.build(e,"void");s!==""&&e.addLineFlowCode(s,this)}else{const a=e.getNodeProperties(this).outputComputeNode;if(a)return a.build(e,t)}}}const Hp=(i,e=[64])=>{(e.length===0||e.length>3)&&(0,d.vUy)("TSL: compute() workgroupSize must have 1, 2, or 3 elements");for(let t=0;t<e.length;t++){const r=e[t];(typeof r!="number"||r<=0||!Number.isInteger(r))&&(0,d.vUy)(`TSL: compute() workgroupSize element at index [ ${t} ] must be a positive integer`)}for(;e.length<3;)e.push(1);return Oe(new vd(Oe(i),e))},fo=(i,e,t)=>Hp(i,t).setCount(e);De("compute",fo),De("computeKernel",Hp);class jo extends Rt{static get type(){return"IsolateNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isIsolateNode=!0}getNodeType(e){const t=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const s=this.node.getNodeType(e);return e.setCache(t),s}build(e,...t){const r=e.getCache(),s=e.getCacheFromNode(this,this.parent);e.setCache(s);const a=this.node.build(e,...t);return e.setCache(r),a}setParent(e){return this.parent=e,this}getParent(){return this.parent}}const St=i=>new jo(Oe(i));function Vt(i,e=!0){return(0,d.ZK6)('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),St(i).setParent(e)}De("cache",Vt),De("isolate",St);class Wt extends Rt{static get type(){return"BypassNode"}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),this.outputNode.build(e)}}const on=sn(Wt).setParameterLength(2);De("bypass",on);class tn extends Rt{static get type(){return"RemapNode"}constructor(e,t,r,s=G(0),a=G(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=r,this.outLowNode=s,this.outHighNode=a,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:r,outLowNode:s,outHighNode:a,doClamp:c}=this;let h=e.sub(t).div(r.sub(t));return c===!0&&(h=h.clamp()),h.mul(a.sub(s)).add(s)}}const ei=sn(tn,null,null,{doClamp:!1}).setParameterLength(3,5),Gn=sn(tn).setParameterLength(3,5);De("remap",ei),De("remapClamp",Gn);class gi extends Rt{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const r=this.getNodeType(e),s=this.snippet;if(r==="void")e.addLineFlowCode(s,this);else return e.format(s,r,t)}}const ii=sn(gi).setParameterLength(1,2),Ji=i=>(i?S(i,ii("discard")):ii("discard")).toStack(),us=()=>ii("return").toStack();De("discard",Ji);class dc extends Oi{static get type(){return"RenderOutputNode"}constructor(e,t,r){super("vec4"),this.colorNode=e,this._toneMapping=t,this.outputColorSpace=r,this.isRenderOutputNode=!0}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup({context:e}){let t=this.colorNode||e.color;const r=(this._toneMapping!==null?this._toneMapping:e.toneMapping)||d.uL9,s=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||d.aCh;return r!==d.uL9&&(t=t.toneMapping(r)),s!==d.aCh&&s!==d.epp.workingColorSpace&&(t=t.workingToColorSpace(s)),t}}const Vr=(i,e=null,t=null)=>Oe(new dc(Oe(i),e,t));De("renderOutput",Vr);class J0 extends Oi{static get type(){return"DebugNode"}constructor(e,t=null){super(),this.node=e,this.callback=t}getNodeType(e){return this.node.getNodeType(e)}setup(e){return this.node.build(e)}analyze(e){return this.node.build(e)}generate(e){const t=this.callback,r=this.node.build(e),s="--- TSL debug - "+e.shaderStage+" shader ---",a="-".repeat(s.length);let c="";return c+="// #"+s+`#
`,c+=e.flow.code.replace(/^\t/mg,"")+`
`,c+="/* ... */ "+r+` /* ... */
`,c+="// #"+a+`#
`,t!==null?t(e,c):(0,d.cM7)(c),r}}const $p=(i,e=null)=>Oe(new J0(Oe(i),e)).toStack();De("debug",$p);class jp{constructor(){this._renderer=null,this.currentFrame=null}get nodeFrame(){return this._renderer._nodes.nodeFrame}setRenderer(e){return this._renderer=e,this}getRenderer(){return this._renderer}init(){}begin(){}finish(){}inspect(){}computeAsync(){}beginCompute(){}finishCompute(){}beginRender(){}finishRender(){}copyTextureToTexture(){}copyFramebufferToTexture(){}}class Pb extends Rt{static get type(){return"InspectorNode"}constructor(e,t="",r=null){super(),this.node=e,this.name=t,this.callback=r,this.updateType=xn.FRAME,this.isInspectorNode=!0}getName(){return this.name||this.node.name}update(e){e.renderer.inspector.inspect(this)}getNodeType(e){return this.node.getNodeType(e)}setup(e){let t=this.node;return e.context.inspector===!0&&this.callback!==null&&(t=this.callback(t)),e.renderer.backend.isWebGPUBackend!==!0&&e.renderer.inspector.constructor!==jp&&(0,d.O4K)('TSL: ".toInspector()" is only available with WebGPU.'),t}}function ex(i,e="",t=null){return i=Oe(i),i.before(new Pb(i,e,t))}De("toInspector",ex);function tx(i){(0,d.ZK6)("TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",i)}class Xp extends Rt{static get type(){return"AttributeNode"}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(t===null){const r=this.getAttributeName(e);if(e.hasGeometryAttribute(r)){const s=e.geometry.getAttribute(r);t=e.getTypeFromAttribute(s)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),r=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){const a=e.geometry.getAttribute(t),c=e.getTypeFromAttribute(a),h=e.getAttribute(t,c);return e.shaderStage==="vertex"?e.format(h.name,c,r):We(this).build(e,r)}else return(0,d.ZK6)(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(r)}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}}const hs=(i,e=null)=>Oe(new Xp(i,e)),hi=(i=0)=>hs("uv"+(i>0?i:""),"vec2");class x3 extends Rt{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const r=this.textureNode.build(e,"property"),s=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${r}, ${s} )`,this.getNodeType(e),t)}}const fc=sn(x3).setParameterLength(1,2);class _3 extends Gs{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=xn.FRAME}get textureNode(){return this._textureNode}get texture(){return this._textureNode.value}update(){const e=this.texture,t=e.images,r=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(r&&r.width!==void 0){const{width:s,height:a}=r;this.value=Math.log2(Math.max(s,a))}}}const Lb=sn(_3).setParameterLength(1),Ib=new d.xEZ;class _a extends Gs{static get type(){return"TextureNode"}constructor(e=Ib,t=null,r=null,s=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=r,this.biasNode=s,this.compareNode=null,this.depthNode=null,this.gradNode=null,this.offsetNode=null,this.sampler=!0,this.updateMatrix=!1,this.updateType=xn.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=null,this._flipYUniform=null,this.setUpdateMatrix(t===null)}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 this.value.isDepthTexture===!0?"float":this.value.type===d.JQ4?"uvec4":this.value.type===d.Kz5?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return hi(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=Bt(this.value.matrix)),this._matrixUniform.mul(ce(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this}setupUV(e,t){return e.isFlipY()&&(this._flipYUniform===null&&(this._flipYUniform=Bt(!1)),t=t.toVar(),this.sampler?t=this._flipYUniform.select(t.flipY(),t):t=this._flipYUniform.select(t.setY(re(fc(this,this.levelNode).y).sub(t.y).sub(1)),t)),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const r=this.value;if(!r||r.isTexture!==!0)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");const s=fe(()=>{let c=this.uvNode;return(c===null||e.context.forceUVContext===!0)&&e.context.getUV&&(c=e.context.getUV(this,e)),c||(c=this.getDefaultUV()),this.updateMatrix===!0&&(c=this.getTransformedUV(c)),c=this.setupUV(e,c),this.updateType=this._matrixUniform!==null||this._flipYUniform!==null?xn.OBJECT:xn.NONE,c})();let a=this.levelNode;a===null&&e.context.getTextureLevel&&(a=e.context.getTextureLevel(this)),t.uvNode=s,t.levelNode=a,t.biasNode=this.biasNode,t.compareNode=this.compareNode,t.gradNode=this.gradNode,t.depthNode=this.depthNode,t.offsetNode=this.offsetNode}generateUV(e,t){return t.build(e,this.sampler===!0?"vec2":"ivec2")}generateOffset(e,t){return t.build(e,"ivec2")}generateSnippet(e,t,r,s,a,c,h,f,m){const x=this.value;let _;return a?_=e.generateTextureBias(x,t,r,a,c,m):f?_=e.generateTextureGrad(x,t,r,f,c,m):h?_=e.generateTextureCompare(x,t,r,h,c,m):this.sampler===!1?_=e.generateTextureLoad(x,t,r,s,c,m):s?_=e.generateTextureLevel(x,t,r,s,c,m):_=e.generateTexture(x,t,r,c,m),_}generate(e,t){const r=this.value,s=e.getNodeProperties(this),a=super.generate(e,"property");if(/^sampler/.test(t))return a+"_sampler";if(e.isReference(t))return a;{const c=e.getDataFromNode(this);let h=c.propertyName;if(h===void 0){const{uvNode:x,levelNode:_,biasNode:v,compareNode:T,depthNode:w,gradNode:P,offsetNode:C}=s,E=this.generateUV(e,x),D=_?_.build(e,"float"):null,F=v?v.build(e,"float"):null,W=w?w.build(e,"int"):null,K=T?T.build(e,"float"):null,U=P?[P[0].build(e,"vec2"),P[1].build(e,"vec2")]:null,j=C?this.generateOffset(e,C):null,oe=e.getVarFromNode(this);h=e.getPropertyName(oe);const k=this.generateSnippet(e,a,E,D,F,W,K,U,j);e.addLineFlowCode(`${h} = ${k}`,this),c.snippet=k,c.propertyName=h}let f=h;const m=this.getNodeType(e);return e.needsToWorkingColorSpace(r)&&(f=ni(ii(f,m),r.colorSpace).setup(e).build(e,m)),e.format(f,m,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return(0,d.ZK6)("TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){const t=this.clone();return t.uvNode=Oe(e),t.referenceNode=this.getBase(),Oe(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){const t=this.clone();t.biasNode=Oe(e).mul(Lb(t)),t.referenceNode=this.getBase();const r=t.value;return t.generateMipmaps===!1&&(r&&r.generateMipmaps===!1||r.minFilter===d.TyD||r.magFilter===d.TyD)&&((0,d.ZK6)("TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),Oe(t)}level(e){const t=this.clone();return t.levelNode=Oe(e),t.referenceNode=this.getBase(),Oe(t)}size(e){return fc(this,e)}bias(e){const t=this.clone();return t.biasNode=Oe(e),t.referenceNode=this.getBase(),Oe(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){const t=this.clone();return t.compareNode=Oe(e),t.referenceNode=this.getBase(),Oe(t)}grad(e,t){const r=this.clone();return r.gradNode=[Oe(e),Oe(t)],r.referenceNode=this.getBase(),Oe(r)}depth(e){const t=this.clone();return t.depthNode=Oe(e),t.referenceNode=this.getBase(),Oe(t)}offset(e){const t=this.clone();return t.offsetNode=Oe(e),t.referenceNode=this.getBase(),Oe(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;t!==null&&(t.value=e.matrix),e.matrixAutoUpdate===!0&&e.updateMatrix();const r=this._flipYUniform;r!==null&&(r.value=e.image instanceof ImageBitmap&&e.flipY===!0||e.isRenderTargetTexture===!0||e.isFramebufferTexture===!0||e.isDepthTexture===!0)}clone(){const e=new this.constructor(this.value,this.uvNode,this.levelNode,this.biasNode);return e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.offsetNode=this.offsetNode,e}}const y3=sn(_a).setParameterLength(1,4).setName("texture"),In=(i=Ib,e=null,t=null,r=null)=>{let s;return i&&i.isTextureNode===!0?(s=Oe(i.clone()),s.referenceNode=i.getBase(),e!==null&&(s.uvNode=Oe(e)),t!==null&&(s.levelNode=Oe(t)),r!==null&&(s.biasNode=Oe(r))):s=y3(i,e,t,r),s},b3=(i=Ib)=>In(i),ji=(...i)=>In(...i).setSampler(!1),v3=(i,e,t)=>In(i,e).level(t),S3=i=>(i.isNode===!0?i:In(i)).convert("sampler"),T3=i=>(i.isNode===!0?i:In(i)).convert("samplerComparison");class Db extends Gs{static get type(){return"BufferNode"}constructor(e,t,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=r}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const qp=(i,e,t)=>Oe(new Db(i,e,t));class M3 extends ec{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),r=this.getNodeType(),s=this.node.getPaddedType();return e.format(t,s,r)}}class w3 extends Db{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?ko(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=xn.RENDER,this.isArrayBufferNode=!0}getNodeType(){return this.paddedType}getElementType(){return this.elementType}getPaddedType(){const e=this.elementType;let t="vec4";return e==="mat2"?t="mat2":/mat/.test(e)===!0?t="mat4":e.charAt(0)==="i"?t="ivec4":e.charAt(0)==="u"&&(t="uvec4"),t}update(){const{array:e,value:t}=this,r=this.elementType;if(r==="float"||r==="int"||r==="uint")for(let s=0;s<e.length;s++){const a=s*4;t[a]=e[s]}else if(r==="color")for(let s=0;s<e.length;s++){const a=s*4,c=e[s];t[a]=c.r,t[a+1]=c.g,t[a+2]=c.b||0}else if(r==="mat2")for(let s=0;s<e.length;s++){const a=s*4,c=e[s];t[a]=c.elements[0],t[a+1]=c.elements[1],t[a+2]=c.elements[2],t[a+3]=c.elements[3]}else if(r==="mat3")for(let s=0;s<e.length;s++){const a=s*16,c=e[s];t[a]=c.elements[0],t[a+1]=c.elements[1],t[a+2]=c.elements[2],t[a+4]=c.elements[3],t[a+5]=c.elements[4],t[a+6]=c.elements[5],t[a+8]=c.elements[6],t[a+9]=c.elements[7],t[a+10]=c.elements[8],t[a+15]=1}else if(r==="mat4")for(let s=0;s<e.length;s++){const a=s*16,c=e[s];for(let h=0;h<c.elements.length;h++)t[a+h]=c.elements[h]}else for(let s=0;s<e.length;s++){const a=s*4,c=e[s];t[a]=c.x,t[a+1]=c.y,t[a+2]=c.z||0,t[a+3]=c.w||0}}setup(e){const t=this.array.length,r=this.elementType;let s=Float32Array;const a=this.paddedType,c=e.getTypeLength(a);return r.charAt(0)==="i"&&(s=Int32Array),r.charAt(0)==="u"&&(s=Uint32Array),this.value=new s(t*c),this.bufferCount=t,this.bufferType=a,super.setup(e)}element(e){return Oe(new M3(this,Oe(e)))}}const Xr=(i,e)=>Oe(new w3(i,e));class A3 extends Rt{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const pc=sn(A3).setParameterLength(1);let Kp,Zp;class wi extends Rt{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}getNodeType(){return this.scope===wi.DPR?"float":this.scope===wi.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=xn.NONE;return(this.scope===wi.SIZE||this.scope===wi.VIEWPORT||this.scope===wi.DPR)&&(e=xn.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===wi.VIEWPORT?t!==null?Zp.copy(t.viewport):(e.getViewport(Zp),Zp.multiplyScalar(e.getPixelRatio())):this.scope===wi.DPR?this._output.value=e.getPixelRatio():t!==null?(Kp.width=t.width,Kp.height=t.height):e.getDrawingBufferSize(Kp)}setup(){const e=this.scope;let t=null;return e===wi.SIZE?t=Bt(Kp||(Kp=new d.FM8)):e===wi.VIEWPORT?t=Bt(Zp||(Zp=new d.Ltg)):e===wi.DPR?t=Bt(1):t=Ve(Yp.div(Nu)),this._output=t,t}generate(e){if(this.scope===wi.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const r=e.getNodeProperties(Nu).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${r}.y - ${t}.y )`}return t}return super.generate(e)}}wi.COORDINATE="coordinate",wi.VIEWPORT="viewport",wi.SIZE="size",wi.UV="uv",wi.DPR="dpr";const vT=pt(wi,wi.DPR),mc=pt(wi,wi.UV),Nu=pt(wi,wi.SIZE),Yp=pt(wi,wi.COORDINATE),Sd=pt(wi,wi.VIEWPORT),Ub=Sd.zw,ST=Yp.sub(Sd.xy),E3=ST.div(Ub),C3=fe(()=>((0,d.ZK6)('TSL: "viewportResolution" is deprecated. Use "screenSize" instead.'),Nu),"vec2").once()(),pl=Bt(0,"uint").setName("u_cameraIndex").setGroup(bu("cameraIndex")).toVarying("v_cameraIndex"),gc=Bt("float").setName("cameraNear").setGroup(Ft).onRenderUpdate(({camera:i})=>i.near),xc=Bt("float").setName("cameraFar").setGroup(Ft).onRenderUpdate(({camera:i})=>i.far),po=fe(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const s of i.cameras)t.push(s.projectionMatrix);e=Xr(t).setGroup(Ft).setName("cameraProjectionMatrices").element(i.isMultiViewCamera?pc("gl_ViewID_OVR"):pl).toConst("cameraProjectionMatrix")}else e=Bt("mat4").setName("cameraProjectionMatrix").setGroup(Ft).onRenderUpdate(({camera:t})=>t.projectionMatrix);return e}).once()(),R3=fe(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const s of i.cameras)t.push(s.projectionMatrixInverse);e=Xr(t).setGroup(Ft).setName("cameraProjectionMatricesInverse").element(i.isMultiViewCamera?pc("gl_ViewID_OVR"):pl).toConst("cameraProjectionMatrixInverse")}else e=Bt("mat4").setName("cameraProjectionMatrixInverse").setGroup(Ft).onRenderUpdate(({camera:t})=>t.projectionMatrixInverse);return e}).once()(),qs=fe(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const s of i.cameras)t.push(s.matrixWorldInverse);e=Xr(t).setGroup(Ft).setName("cameraViewMatrices").element(i.isMultiViewCamera?pc("gl_ViewID_OVR"):pl).toConst("cameraViewMatrix")}else e=Bt("mat4").setName("cameraViewMatrix").setGroup(Ft).onRenderUpdate(({camera:t})=>t.matrixWorldInverse);return e}).once()(),N3=fe(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const s of i.cameras)t.push(s.matrixWorld);e=Xr(t).setGroup(Ft).setName("cameraWorldMatrices").element(i.isMultiViewCamera?pc("gl_ViewID_OVR"):pl).toConst("cameraWorldMatrix")}else e=Bt("mat4").setName("cameraWorldMatrix").setGroup(Ft).onRenderUpdate(({camera:t})=>t.matrixWorld);return e}).once()(),P3=fe(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const s of i.cameras)t.push(s.normalMatrix);e=Xr(t).setGroup(Ft).setName("cameraNormalMatrices").element(i.isMultiViewCamera?pc("gl_ViewID_OVR"):pl).toConst("cameraNormalMatrix")}else e=Bt("mat3").setName("cameraNormalMatrix").setGroup(Ft).onRenderUpdate(({camera:t})=>t.normalMatrix);return e}).once()(),Qp=fe(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(let s=0,a=i.cameras.length;s<a;s++)t.push(new d.Pa4);e=Xr(t).setGroup(Ft).setName("cameraPositions").onRenderUpdate(({camera:s},a)=>{const c=s.cameras,h=a.array;for(let f=0,m=c.length;f<m;f++)h[f].setFromMatrixPosition(c[f].matrixWorld)}).element(i.isMultiViewCamera?pc("gl_ViewID_OVR"):pl).toConst("cameraPosition")}else e=Bt(new d.Pa4).setName("cameraPosition").setGroup(Ft).onRenderUpdate(({camera:t},r)=>r.value.setFromMatrixPosition(t.matrixWorld));return e}).once()(),L3=fe(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const s of i.cameras)t.push(s.viewport);e=Xr(t,"vec4").setGroup(Ft).setName("cameraViewports").element(pl).toConst("cameraViewport")}else e=At(0,0,Nu.x,Nu.y).toConst("cameraViewport");return e}).once()(),TT=new d.aLr;class qn extends Rt{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=xn.OBJECT,this.uniformNode=new Gs(null)}getNodeType(){const e=this.scope;if(e===qn.WORLD_MATRIX)return"mat4";if(e===qn.POSITION||e===qn.VIEW_POSITION||e===qn.DIRECTION||e===qn.SCALE)return"vec3";if(e===qn.RADIUS)return"float"}update(e){const t=this.object3d,r=this.uniformNode,s=this.scope;if(s===qn.WORLD_MATRIX)r.value=t.matrixWorld;else if(s===qn.POSITION)r.value=r.value||new d.Pa4,r.value.setFromMatrixPosition(t.matrixWorld);else if(s===qn.SCALE)r.value=r.value||new d.Pa4,r.value.setFromMatrixScale(t.matrixWorld);else if(s===qn.DIRECTION)r.value=r.value||new d.Pa4,t.getWorldDirection(r.value);else if(s===qn.VIEW_POSITION){const a=e.camera;r.value=r.value||new d.Pa4,r.value.setFromMatrixPosition(t.matrixWorld),r.value.applyMatrix4(a.matrixWorldInverse)}else if(s===qn.RADIUS){const a=e.object.geometry;a.boundingSphere===null&&a.computeBoundingSphere(),TT.copy(a.boundingSphere).applyMatrix4(t.matrixWorld),r.value=TT.radius}}generate(e){const t=this.scope;return t===qn.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===qn.POSITION||t===qn.VIEW_POSITION||t===qn.DIRECTION||t===qn.SCALE?this.uniformNode.nodeType="vec3":t===qn.RADIUS&&(this.uniformNode.nodeType="float"),this.uniformNode.build(e)}serialize(e){super.serialize(e),e.scope=this.scope}deserialize(e){super.deserialize(e),this.scope=e.scope}}qn.WORLD_MATRIX="worldMatrix",qn.POSITION="position",qn.SCALE="scale",qn.VIEW_POSITION="viewPosition",qn.DIRECTION="direction",qn.RADIUS="radius";const I3=sn(qn,qn.DIRECTION).setParameterLength(1),D3=sn(qn,qn.WORLD_MATRIX).setParameterLength(1),MT=sn(qn,qn.POSITION).setParameterLength(1),U3=sn(qn,qn.SCALE).setParameterLength(1),F3=sn(qn,qn.VIEW_POSITION).setParameterLength(1),B3=sn(qn,qn.RADIUS).setParameterLength(1);class mo extends qn{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const O3=pt(mo,mo.DIRECTION),go=pt(mo,mo.WORLD_MATRIX),k3=pt(mo,mo.POSITION),V3=pt(mo,mo.SCALE),z3=pt(mo,mo.VIEW_POSITION),wT=pt(mo,mo.RADIUS),AT=Bt(new d.Vkp).onObjectUpdate(({object:i},e)=>e.value.getNormalMatrix(i.matrixWorld)),G3=Bt(new d.yGw).onObjectUpdate(({object:i},e)=>e.value.copy(i.matrixWorld).invert()),_c=fe(i=>i.renderer.overrideNodes.modelViewMatrix||ET).once()().toVar("modelViewMatrix"),ET=qs.mul(go),Fb=fe(i=>(i.context.isHighPrecisionModelViewMatrix=!0,Bt("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),Bb=fe(i=>{const e=i.context.isHighPrecisionModelViewMatrix;return Bt("mat3").onObjectUpdate(({object:t,camera:r})=>(e!==!0&&t.modelViewMatrix.multiplyMatrices(r.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),zr=hs("position","vec3"),er=zr.toVarying("positionLocal"),nx=zr.toVarying("positionPrevious"),Ks=fe(i=>go.mul(er).xyz.toVarying(i.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),Ob=fe(()=>er.transformDirection(go).toVarying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),"vec3").once(["POSITION"])(),tr=fe(i=>i.context.setupPositionView().toVarying("v_positionView"),"vec3").once(["POSITION"])(),Ai=fe(i=>{let e;return i.camera.isOrthographicCamera?e=ce(0,0,1):e=tr.negate().toVarying("v_positionViewDirection").normalize(),e.toVar("positionViewDirection")},"vec3").once(["POSITION"])();class W3 extends Rt{static get type(){return"FrontFacingNode"}constructor(){super("bool"),this.isFrontFacingNode=!0}generate(e){if(e.shaderStage!=="fragment")return"true";const{material:t}=e;return t.side===d._Li?"false":e.getFrontFacing()}}const CT=pt(W3),kb=G(CT).mul(2).sub(1),Td=fe(([i],{material:e})=>{const t=e.side;return t===d._Li?i=i.mul(-1):t===d.ehD&&(i=i.mul(kb)),i}),ix=hs("normal","vec3"),Ss=fe(i=>i.geometry.hasAttribute("normal")===!1?((0,d.ZK6)('TSL: Vertex attribute "normal" not found on geometry.'),ce(0,1,0)):ix,"vec3").once()().toVar("normalLocal"),RT=tr.dFdx().cross(tr.dFdy()).normalize().toVar("normalFlat"),Md=fe(i=>{let e;return i.material.flatShading===!0?e=RT:e=Vb(Ss).toVarying("v_normalViewGeometry").normalize(),e},"vec3").once()().toVar("normalViewGeometry"),NT=fe(i=>{let e=Md.transformDirection(qs);return i.material.flatShading!==!0&&(e=e.toVarying("v_normalWorldGeometry")),e.normalize().toVar("normalWorldGeometry")},"vec3").once()(),ri=fe(({subBuildFn:i,material:e,context:t})=>{let r;return i==="NORMAL"||i==="VERTEX"?(r=Md,e.flatShading!==!0&&(r=Td(r))):r=t.setupNormal().context({getUV:null}),r},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),ml=ri.transformDirection(qs).toVar("normalWorld"),Pu=fe(({subBuildFn:i,context:e})=>{let t;return i==="NORMAL"||i==="VERTEX"?t=ri:t=e.setupClearcoatNormal().context({getUV:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),PT=fe(([i,e=go])=>{const t=Ni(e),r=i.div(ce(t[0].dot(t[0]),t[1].dot(t[1]),t[2].dot(t[2])));return t.mul(r).xyz}),Vb=fe(([i],e)=>{const t=e.renderer.overrideNodes.modelNormalViewMatrix;if(t!==null)return t.transformDirection(i);const r=AT.mul(i);return qs.transformDirection(r)}),H3=fe(()=>((0,d.ZK6)('TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),ri)).once(["NORMAL","VERTEX"])(),$3=fe(()=>((0,d.ZK6)('TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),ml)).once(["NORMAL","VERTEX"])(),j3=fe(()=>((0,d.ZK6)('TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),Pu)).once(["NORMAL","VERTEX"])(),LT=new d.USm,zb=new d.yGw,IT=Bt(0).onReference(({material:i})=>i).onObjectUpdate(({material:i})=>i.refractionRatio),rx=Bt(1).onReference(({material:i})=>i).onObjectUpdate(function({material:i,scene:e}){return i.envMap?i.envMapIntensity:e.environmentIntensity}),Gb=Bt(new d.yGw).onReference(function(i){return i.material}).onObjectUpdate(function({material:i,scene:e}){const t=e.environment!==null&&i.envMap===null?e.environmentRotation:i.envMapRotation;return t?(LT.copy(t),zb.makeRotationFromEuler(LT)):zb.identity(),zb}),DT=Ai.negate().reflect(ri),UT=Ai.negate().refract(ri,IT),FT=DT.transformDirection(qs).toVar("reflectVector"),BT=UT.transformDirection(qs).toVar("reflectVector"),OT=new d.BtG;class X3 extends _a{static get type(){return"CubeTextureNode"}constructor(e,t=null,r=null,s=null){super(e,t,r,s),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===d.fY$?FT:e.mapping===d.vxC?BT:((0,d.vUy)('CubeTextureNode: Mapping "%s" not supported.',e.mapping),ce(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return(e.renderer.coordinateSystem===d.JCZ||!r.isRenderTargetTexture)&&(t=ce(t.x.negate(),t.yz)),Gb.mul(t)}generateUV(e,t){return t.build(e,this.sampler===!0?"vec3":"ivec3")}}const Wb=sn(X3).setParameterLength(1,4).setName("cubeTexture"),wd=(i=OT,e=null,t=null,r=null)=>{let s;return i&&i.isCubeTextureNode===!0?(s=Oe(i.clone()),s.referenceNode=i,e!==null&&(s.uvNode=Oe(e)),t!==null&&(s.levelNode=Oe(t)),r!==null&&(s.biasNode=Oe(r))):s=Wb(i,e,t,r),s},q3=(i=OT)=>Wb(i);class K3 extends ec{static get type(){return"ReferenceElementNode"}constructor(e,t){super(e,t),this.referenceNode=e,this.isReferenceElementNode=!0}getNodeType(){return this.referenceNode.uniformType}generate(e){const t=super.generate(e),r=this.referenceNode.getNodeType(),s=this.getNodeType();return e.format(t,r,s)}}class sx extends Rt{static get type(){return"ReferenceNode"}constructor(e,t,r=null,s=null){super(),this.property=e,this.uniformType=t,this.object=r,this.count=s,this.properties=e.split("."),this.reference=r,this.node=null,this.group=null,this.name=null,this.updateType=xn.OBJECT}element(e){return Oe(new K3(this,Oe(e)))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return(0,d.ZK6)('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setNodeType(e){let t=null;this.count!==null?t=qp(null,e,this.count):Array.isArray(this.getValueFromReference())?t=Xr(null,e):e==="texture"?t=In(null):e==="cubeTexture"?t=wd(null):t=Bt(null,e),this.group!==null&&t.setGroup(this.group),this.name!==null&&t.setName(this.name),this.node=t}getNodeType(e){return this.node===null&&(this.updateReference(e),this.updateValue()),this.node.getNodeType(e)}getValueFromReference(e=this.reference){const{properties:t}=this;let r=e[t[0]];for(let s=1;s<t.length;s++)r=r[t[s]];return r}updateReference(e){return this.reference=this.object!==null?this.object:e.object,this.reference}setup(){return this.updateValue(),this.node}update(){this.updateValue()}updateValue(){this.node===null&&this.setNodeType(this.uniformType);const e=this.getValueFromReference();Array.isArray(e)?this.node.array=e:this.node.value=e}}const xi=(i,e,t)=>Oe(new sx(i,e,t)),Hb=(i,e,t,r)=>Oe(new sx(i,e,r,t));class Z3 extends sx{static get type(){return"MaterialReferenceNode"}constructor(e,t,r=null){super(e,t,r),this.material=r,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material!==null?this.material:e.material,this.reference}}const yc=(i,e,t=null)=>Oe(new Z3(i,e,t)),kT=hi(),Y3=tr.dFdx(),Q3=tr.dFdy(),VT=kT.dFdx(),zT=kT.dFdy(),GT=ri,WT=Q3.cross(GT),HT=GT.cross(Y3),$b=WT.mul(VT.x).add(HT.mul(zT.x)),jb=WT.mul(VT.y).add(HT.mul(zT.y)),$T=$b.dot($b).max(jb.dot(jb)),jT=$T.equal(0).select(0,$T.inverseSqrt()),J3=$b.mul(jT).toVar("tangentViewFrame"),eC=jb.mul(jT).toVar("bitangentViewFrame"),ox=fe(i=>(i.geometry.hasAttribute("tangent")===!1&&i.geometry.computeTangents(),hs("tangent","vec4")))(),Jp=ox.xyz.toVar("tangentLocal"),ax=fe(({subBuildFn:i,geometry:e,material:t})=>{let r;return i==="VERTEX"||e.hasAttribute("tangent")?r=_c.mul(At(Jp,0)).xyz.toVarying("v_tangentView").normalize():r=J3,t.flatShading!==!0&&(r=Td(r)),r},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),XT=ax.transformDirection(qs).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),cx=fe(([i,e],{subBuildFn:t,material:r})=>{let s=i.mul(ox.w).xyz;return t==="NORMAL"&&r.flatShading!==!0&&(s=s.toVarying(e)),s}).once(["NORMAL"]),tC=cx(ix.cross(ox),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),nC=cx(Ss.cross(Jp),"v_bitangentLocal").normalize().toVar("bitangentLocal"),qT=fe(({subBuildFn:i,geometry:e,material:t})=>{let r;return i==="VERTEX"||e.hasAttribute("tangent")?r=cx(ri.cross(ax),"v_bitangentView").normalize():r=eC,t.flatShading!==!0&&(r=Td(r)),r},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),iC=cx(ml.cross(XT),"v_bitangentWorld").normalize().toVar("bitangentWorld"),Lu=Ni(ax,qT,ri).toVar("TBNViewMatrix"),KT=Ai.mul(Lu),rC=(i,e)=>i.sub(KT.mul(e)),ZT=fe(()=>{let i=pa.cross(Ai);return i=i.cross(pa).normalize(),i=Xn(i,ri,lo.mul(zs.oneMinus()).oneMinus().pow2().pow2()).normalize(),i}).once()();class sC extends Oi{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=d.IOt}setup({material:e}){const{normalMapType:t,scaleNode:r}=this;let s=this.node.mul(2).sub(1);if(r!==null){let c=r;e.flatShading===!0&&(c=Td(c)),s=ce(s.xy.mul(c),s.z)}let a=null;return t===d.PA7?a=Vb(s):t===d.IOt?a=Lu.mul(s).normalize():((0,d.vUy)(`NodeMaterial: Unsupported normal map type: ${t}`),a=ri),a}}const Xb=sn(sC).setParameterLength(1,2),oC=fe(({textureNode:i,bumpScale:e})=>{const t=s=>i.isolate().context({getUV:a=>s(a.uvNode||hi()),forceUVContext:!0}),r=G(t(s=>s));return Ve(G(t(s=>s.add(s.dFdx()))).sub(r),G(t(s=>s.add(s.dFdy()))).sub(r)).mul(e)}),aC=fe(i=>{const{surf_pos:e,surf_norm:t,dHdxy:r}=i,s=e.dFdx().normalize(),a=e.dFdy().normalize(),c=t,h=a.cross(c),f=c.cross(s),m=s.dot(h).mul(kb),x=m.sign().mul(r.x.mul(h).add(r.y.mul(f)));return m.abs().mul(t).sub(x).normalize()});class cC extends Oi{static get type(){return"BumpMapNode"}constructor(e,t=null){super("vec3"),this.textureNode=e,this.scaleNode=t}setup(){const e=this.scaleNode!==null?this.scaleNode:1,t=oC({textureNode:this.textureNode,bumpScale:e});return aC({surf_pos:tr,surf_norm:ri,dHdxy:t})}}const qb=sn(cC).setParameterLength(1,2),YT=new Map;class Ge extends Rt{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let r=YT.get(e);return r===void 0&&(r=yc(e,t),YT.set(e,r)),r}getFloat(e){return this.getCache(e,"float")}getColor(e){return this.getCache(e,"color")}getTexture(e){return this.getCache(e==="map"?"map":e+"Map","texture")}setup(e){const t=e.context.material,r=this.scope;let s=null;if(r===Ge.COLOR){const a=t.color!==void 0?this.getColor(r):ce();t.map&&t.map.isTexture===!0?s=a.mul(this.getTexture("map")):s=a}else if(r===Ge.OPACITY){const a=this.getFloat(r);t.alphaMap&&t.alphaMap.isTexture===!0?s=a.mul(this.getTexture("alpha")):s=a}else if(r===Ge.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?s=this.getTexture("specular").r:s=G(1);else if(r===Ge.SPECULAR_INTENSITY){const a=this.getFloat(r);t.specularIntensityMap&&t.specularIntensityMap.isTexture===!0?s=a.mul(this.getTexture(r).a):s=a}else if(r===Ge.SPECULAR_COLOR){const a=this.getColor(r);t.specularColorMap&&t.specularColorMap.isTexture===!0?s=a.mul(this.getTexture(r).rgb):s=a}else if(r===Ge.ROUGHNESS){const a=this.getFloat(r);t.roughnessMap&&t.roughnessMap.isTexture===!0?s=a.mul(this.getTexture(r).g):s=a}else if(r===Ge.METALNESS){const a=this.getFloat(r);t.metalnessMap&&t.metalnessMap.isTexture===!0?s=a.mul(this.getTexture(r).b):s=a}else if(r===Ge.EMISSIVE){const a=this.getFloat("emissiveIntensity"),c=this.getColor(r).mul(a);t.emissiveMap&&t.emissiveMap.isTexture===!0?s=c.mul(this.getTexture(r)):s=c}else if(r===Ge.NORMAL)t.normalMap?(s=Xb(this.getTexture("normal"),this.getCache("normalScale","vec2")),s.normalMapType=t.normalMapType):t.bumpMap?s=qb(this.getTexture("bump").r,this.getFloat("bumpScale")):s=ri;else if(r===Ge.CLEARCOAT){const a=this.getFloat(r);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?s=a.mul(this.getTexture(r).r):s=a}else if(r===Ge.CLEARCOAT_ROUGHNESS){const a=this.getFloat(r);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?s=a.mul(this.getTexture(r).r):s=a}else if(r===Ge.CLEARCOAT_NORMAL)t.clearcoatNormalMap?s=Xb(this.getTexture(r),this.getCache(r+"Scale","vec2")):s=ri;else if(r===Ge.SHEEN){const a=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?s=a.mul(this.getTexture("sheenColor").rgb):s=a}else if(r===Ge.SHEEN_ROUGHNESS){const a=this.getFloat(r);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?s=a.mul(this.getTexture(r).a):s=a,s=s.clamp(.07,1)}else if(r===Ge.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){const a=this.getTexture(r);s=cl(Ad.x,Ad.y,Ad.y.negate(),Ad.x).mul(a.rg.mul(2).sub(Ve(1)).normalize().mul(a.b))}else s=Ad;else if(r===Ge.IRIDESCENCE_THICKNESS){const a=xi("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const c=xi("0","float",t.iridescenceThicknessRange);s=a.sub(c).mul(this.getTexture(r).g).add(c)}else s=a}else if(r===Ge.TRANSMISSION){const a=this.getFloat(r);t.transmissionMap?s=a.mul(this.getTexture(r).r):s=a}else if(r===Ge.THICKNESS){const a=this.getFloat(r);t.thicknessMap?s=a.mul(this.getTexture(r).g):s=a}else if(r===Ge.IOR)s=this.getFloat(r);else if(r===Ge.LIGHT_MAP)s=this.getTexture(r).rgb.mul(this.getFloat("lightMapIntensity"));else if(r===Ge.AO)s=this.getTexture(r).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(r===Ge.LINE_DASH_OFFSET)s=t.dashOffset?this.getFloat(r):G(0);else{const a=this.getNodeType(e);s=this.getCache(r,a)}return s}}Ge.ALPHA_TEST="alphaTest",Ge.COLOR="color",Ge.OPACITY="opacity",Ge.SHININESS="shininess",Ge.SPECULAR="specular",Ge.SPECULAR_STRENGTH="specularStrength",Ge.SPECULAR_INTENSITY="specularIntensity",Ge.SPECULAR_COLOR="specularColor",Ge.REFLECTIVITY="reflectivity",Ge.ROUGHNESS="roughness",Ge.METALNESS="metalness",Ge.NORMAL="normal",Ge.CLEARCOAT="clearcoat",Ge.CLEARCOAT_ROUGHNESS="clearcoatRoughness",Ge.CLEARCOAT_NORMAL="clearcoatNormal",Ge.EMISSIVE="emissive",Ge.ROTATION="rotation",Ge.SHEEN="sheen",Ge.SHEEN_ROUGHNESS="sheenRoughness",Ge.ANISOTROPY="anisotropy",Ge.IRIDESCENCE="iridescence",Ge.IRIDESCENCE_IOR="iridescenceIOR",Ge.IRIDESCENCE_THICKNESS="iridescenceThickness",Ge.IOR="ior",Ge.TRANSMISSION="transmission",Ge.THICKNESS="thickness",Ge.ATTENUATION_DISTANCE="attenuationDistance",Ge.ATTENUATION_COLOR="attenuationColor",Ge.LINE_SCALE="scale",Ge.LINE_DASH_SIZE="dashSize",Ge.LINE_GAP_SIZE="gapSize",Ge.LINE_WIDTH="linewidth",Ge.LINE_DASH_OFFSET="dashOffset",Ge.POINT_SIZE="size",Ge.DISPERSION="dispersion",Ge.LIGHT_MAP="light",Ge.AO="ao";const QT=pt(Ge,Ge.ALPHA_TEST),lx=pt(Ge,Ge.COLOR),JT=pt(Ge,Ge.SHININESS),e1=pt(Ge,Ge.EMISSIVE),ux=pt(Ge,Ge.OPACITY),t1=pt(Ge,Ge.SPECULAR),Kb=pt(Ge,Ge.SPECULAR_INTENSITY),n1=pt(Ge,Ge.SPECULAR_COLOR),em=pt(Ge,Ge.SPECULAR_STRENGTH),hx=pt(Ge,Ge.REFLECTIVITY),i1=pt(Ge,Ge.ROUGHNESS),r1=pt(Ge,Ge.METALNESS),s1=pt(Ge,Ge.NORMAL),o1=pt(Ge,Ge.CLEARCOAT),a1=pt(Ge,Ge.CLEARCOAT_ROUGHNESS),c1=pt(Ge,Ge.CLEARCOAT_NORMAL),l1=pt(Ge,Ge.ROTATION),u1=pt(Ge,Ge.SHEEN),h1=pt(Ge,Ge.SHEEN_ROUGHNESS),d1=pt(Ge,Ge.ANISOTROPY),f1=pt(Ge,Ge.IRIDESCENCE),p1=pt(Ge,Ge.IRIDESCENCE_IOR),m1=pt(Ge,Ge.IRIDESCENCE_THICKNESS),g1=pt(Ge,Ge.TRANSMISSION),x1=pt(Ge,Ge.THICKNESS),_1=pt(Ge,Ge.IOR),y1=pt(Ge,Ge.ATTENUATION_DISTANCE),b1=pt(Ge,Ge.ATTENUATION_COLOR),Zb=pt(Ge,Ge.LINE_SCALE),Yb=pt(Ge,Ge.LINE_DASH_SIZE),Qb=pt(Ge,Ge.LINE_GAP_SIZE),dx=pt(Ge,Ge.LINE_WIDTH),Jb=pt(Ge,Ge.LINE_DASH_OFFSET),v1=pt(Ge,Ge.POINT_SIZE),S1=pt(Ge,Ge.DISPERSION),ev=pt(Ge,Ge.LIGHT_MAP),T1=pt(Ge,Ge.AO),Ad=Bt(new d.FM8).onReference(function(i){return i.material}).onRenderUpdate(function({material:i}){this.value.set(i.anisotropy*Math.cos(i.anisotropyRotation),i.anisotropy*Math.sin(i.anisotropyRotation))}),tv=fe(i=>i.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class Ui extends Rt{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),r=this.scope;let s;if(r===Ui.VERTEX)s=e.getVertexIndex();else if(r===Ui.INSTANCE)s=e.getInstanceIndex();else if(r===Ui.DRAW)s=e.getDrawIndex();else if(r===Ui.INVOCATION_LOCAL)s=e.getInvocationLocalIndex();else if(r===Ui.INVOCATION_SUBGROUP)s=e.getInvocationSubgroupIndex();else if(r===Ui.SUBGROUP)s=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+r);let a;return e.shaderStage==="vertex"||e.shaderStage==="compute"?a=s:a=We(this).build(e,t),a}}Ui.VERTEX="vertex",Ui.INSTANCE="instance",Ui.SUBGROUP="subgroup",Ui.INVOCATION_LOCAL="invocationLocal",Ui.INVOCATION_SUBGROUP="invocationSubgroup",Ui.DRAW="draw";const M1=pt(Ui,Ui.VERTEX),gl=pt(Ui,Ui.INSTANCE),lC=pt(Ui,Ui.SUBGROUP),uC=pt(Ui,Ui.INVOCATION_SUBGROUP),hC=pt(Ui,Ui.INVOCATION_LOCAL),w1=pt(Ui,Ui.DRAW);class A1 extends Rt{static get type(){return"InstanceNode"}constructor(e,t,r=null){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=r,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=xn.FRAME,this.buffer=null,this.bufferColor=null}setup(e){const{instanceMatrix:t,instanceColor:r}=this,{count:s}=t;let{instanceMatrixNode:a,instanceColorNode:c}=this;if(a===null){if(s<=1e3)a=qp(t.array,"mat4",Math.max(s,1)).element(gl);else{const f=new d.$TI(t.array,16,1);this.buffer=f;const m=t.usage===d.dj0?Xs:Ru,x=[m(f,"vec4",16,0),m(f,"vec4",16,4),m(f,"vec4",16,8),m(f,"vec4",16,12)];a=sc(...x)}this.instanceMatrixNode=a}if(r&&c===null){const f=new d.lb7(r.array,3),m=r.usage===d.dj0?Xs:Ru;this.bufferColor=f,c=ce(m(f,"vec3",3,0)),this.instanceColorNode=c}const h=a.mul(er).xyz;if(er.assign(h),e.hasGeometryAttribute("normal")){const f=PT(Ss,a);Ss.assign(f)}this.instanceColorNode!==null&&lr("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.buffer!==null&&(this.buffer.clearUpdateRanges(),this.buffer.updateRanges.push(...this.instanceMatrix.updateRanges),this.instanceMatrix.usage!==d.dj0&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version)),this.instanceColor&&this.bufferColor!==null&&(this.bufferColor.clearUpdateRanges(),this.bufferColor.updateRanges.push(...this.instanceColor.updateRanges),this.instanceColor.usage!==d.dj0&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version))}}const dC=sn(A1).setParameterLength(2,3);class fC extends A1{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:r,instanceColor:s}=e;super(t,r,s),this.instancedMesh=e}}const E1=sn(fC).setParameterLength(1);class pC extends Rt{static get type(){return"BatchNode"}constructor(e){super("void"),this.batchMesh=e,this.batchingIdNode=null}setup(e){this.batchingIdNode===null&&(e.getDrawIndex()===null?this.batchingIdNode=gl:this.batchingIdNode=w1);const r=fe(([w])=>{const P=re(fc(ji(this.batchMesh._indirectTexture),0).x),C=re(w).mod(P),E=re(w).div(P);return ji(this.batchMesh._indirectTexture,Vi(C,E)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(re(this.batchingIdNode)),s=this.batchMesh._matricesTexture,a=re(fc(ji(s),0).x),c=G(r).mul(4).toInt().toVar(),h=c.mod(a),f=c.div(a),m=sc(ji(s,Vi(h,f)),ji(s,Vi(h.add(1),f)),ji(s,Vi(h.add(2),f)),ji(s,Vi(h.add(3),f))),x=this.batchMesh._colorsTexture;if(x!==null){const P=fe(([C])=>{const E=re(fc(ji(x),0).x),D=C,F=D.mod(E),W=D.div(E);return ji(x,Vi(F,W)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(r);lr("vec3","vBatchColor").assign(P)}const _=Ni(m);er.assign(m.mul(er));const v=Ss.div(ce(_[0].dot(_[0]),_[1].dot(_[1]),_[2].dot(_[2]))),T=_.mul(v).xyz;Ss.assign(T),e.hasGeometryAttribute("tangent")&&Jp.mulAssign(_)}}const C1=sn(pC).setParameterLength(1);class mC extends ec{static get type(){return"StorageArrayElementNode"}constructor(e,t){super(e,t),this.isStorageArrayElementNode=!0}set storageBufferNode(e){this.node=e}get storageBufferNode(){return this.node}getMemberType(e,t){const r=this.storageBufferNode.structTypeNode;return r?r.getMemberType(e,t):"void"}setup(e){return e.isAvailable("storageBuffer")===!1&&this.node.isPBO===!0&&e.setupPBO(this.node),super.setup(e)}generate(e,t){let r;const s=e.context.assign;if(e.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&s!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!=="compute")?r=e.generatePBO(this):r=this.node.build(e):r=super.generate(e),s!==!0){const a=this.getNodeType(e);r=e.format(r,a,t)}return r}}const gC=sn(mC).setParameterLength(2);class xC extends Db{static get type(){return"StorageBufferNode"}constructor(e,t=null,r=0){let s,a=null;t&&t.isStruct?(s="struct",a=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(r=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(s=mp(e.itemSize),r=e.count):s=t,super(e,s,r),this.isStorageBufferNode=!0,this.structTypeNode=a,this.access=yr.READ_WRITE,this.isAtomic=!1,this.isPBO=!1,this._attribute=null,this._varying=null,this.global=!0,e.isStorageBufferAttribute!==!0&&e.isStorageInstancedBufferAttribute!==!0&&(e.isInstancedBufferAttribute?e.isStorageInstancedBufferAttribute=!0:e.isStorageBufferAttribute=!0)}getHash(e){if(this.bufferCount===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getInputType(){return this.value.isIndirectStorageBufferAttribute?"indirectStorageBuffer":"storageBuffer"}element(e){return gC(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(yr.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=Cu(this.value),this._varying=We(this._attribute)),{attribute:this._attribute,varying:this._varying}}getNodeType(e){if(this.structTypeNode!==null)return this.structTypeNode.getNodeType(e);if(e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.getNodeType(e);const{attribute:t}=this.getAttributeData();return t.getNodeType(e)}getMemberType(e,t){return this.structTypeNode!==null?this.structTypeNode.getMemberType(e,t):"void"}generate(e){if(this.structTypeNode!==null&&this.structTypeNode.build(e),e.isAvailable("storageBuffer")||e.isAvailable("indirectStorageBuffer"))return super.generate(e);const{attribute:t,varying:r}=this.getAttributeData(),s=r.build(e);return e.registerTransform(s,t),s}}const Iu=(i,e=null,t=0)=>Oe(new xC(i,e,t)),_C=(i,e,t)=>((0,d.ZK6)('TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),Iu(i,e,t).setPBO(!0)),R1=new WeakMap;class N1 extends Rt{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=xn.OBJECT,this.skinIndexNode=hs("skinIndex","uvec4"),this.skinWeightNode=hs("skinWeight","vec4"),this.bindMatrixNode=xi("bindMatrix","mat4"),this.bindMatrixInverseNode=xi("bindMatrixInverse","mat4"),this.boneMatricesNode=Hb("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=er,this.toPositionNode=er,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){const{skinIndexNode:r,skinWeightNode:s,bindMatrixNode:a,bindMatrixInverseNode:c}=this,h=e.element(r.x),f=e.element(r.y),m=e.element(r.z),x=e.element(r.w),_=a.mul(t),v=Yi(h.mul(s.x).mul(_),f.mul(s.y).mul(_),m.mul(s.z).mul(_),x.mul(s.w).mul(_));return c.mul(v).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=Ss){const{skinIndexNode:r,skinWeightNode:s,bindMatrixNode:a,bindMatrixInverseNode:c}=this,h=e.element(r.x),f=e.element(r.y),m=e.element(r.z),x=e.element(r.w);let _=Yi(s.x.mul(h),s.y.mul(f),s.z.mul(m),s.w.mul(x));return _=c.mul(_).mul(a),_.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=Hb("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,nx)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")||la(e.object).useVelocity===!0}setup(e){this.needsPreviousBoneMatrices(e)&&nx.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){const r=this.getSkinnedNormal();Ss.assign(r),e.hasGeometryAttribute("tangent")&&Jp.assign(r)}return t}generate(e,t){if(t!=="void")return super.generate(e,t)}update(e){const t=e.object&&e.object.skeleton?e.object.skeleton:this.skinnedMesh.skeleton;R1.get(t)!==e.frameId&&(R1.set(t,e.frameId),this.previousBoneMatricesNode!==null&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}}const P1=i=>Oe(new N1(i)),yC=(i,e=null)=>{const t=new N1(i);return t.positionNode=Iu(new d.lb7(i.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(gl).toVar(),t.skinIndexNode=Iu(new d.lb7(new Uint32Array(i.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(gl).toVar(),t.skinWeightNode=Iu(new d.lb7(i.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(gl).toVar(),t.bindMatrixNode=Bt(i.bindMatrix,"mat4"),t.bindMatrixInverseNode=Bt(i.bindMatrixInverse,"mat4"),t.boneMatricesNode=qp(i.skeleton.boneMatrices,"mat4",i.skeleton.bones.length),t.toPositionNode=e,Oe(t)};class bC extends Rt{static get type(){return"LoopNode"}constructor(e=[]){super("void"),this.params=e}getVarName(e){return String.fromCharCode(105+e)}getProperties(e){const t=e.getNodeProperties(this);if(t.stackNode!==void 0)return t;const r={};for(let h=0,f=this.params.length-1;h<f;h++){const m=this.params[h],x=m.isNode!==!0&&m.name||this.getVarName(h),_=m.isNode!==!0&&m.type||"int";r[x]=ii(x,_)}const s=e.addStack(),a=this.params[this.params.length-1](r);t.returnsNode=a.context({nodeLoop:a}),t.stackNode=s;const c=this.params[0];if(c.isNode!==!0&&typeof c.update=="function"){const h=fe(this.params[0].update)(r);t.updateNode=h.context({nodeLoop:h})}return e.removeStack(),t}setup(e){if(this.getProperties(e),e.fnCall){const t=e.getDataFromNode(e.fnCall.shaderNode);t.hasLoop=!0}}generate(e){const t=this.getProperties(e),r=this.params,s=t.stackNode;for(let c=0,h=r.length-1;c<h;c++){const f=r[c];let m=!1,x=null,_=null,v=null,T=null,w=null,P=null;f.isNode?f.getNodeType(e)==="bool"?(m=!0,T="bool",_=f.build(e,T)):(T="int",v=this.getVarName(c),x="0",_=f.build(e,T),w="<"):(T=f.type||"int",v=f.name||this.getVarName(c),x=f.start,_=f.end,w=f.condition,P=f.update,typeof x=="number"?x=e.generateConst(T,x):x&&x.isNode&&(x=x.build(e,T)),typeof _=="number"?_=e.generateConst(T,_):_&&_.isNode&&(_=_.build(e,T)),x!==void 0&&_===void 0?(x=x+" - 1",_="0",w=">="):_!==void 0&&x===void 0&&(x="0",w="<"),w===void 0&&(Number(x)>Number(_)?w=">=":w="<"));let C;if(m)C=`while ( ${_} )`;else{const E={start:x,end:_},D=E.start,F=E.end;let W;const K=()=>w.includes("<")?"+=":"-=";if(P!=null)switch(typeof P){case"function":W=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":W=v+" "+K()+" "+e.generateConst(T,P);break;case"string":W=v+" "+P;break;default:P.isNode?W=v+" "+K()+" "+P.build(e):((0,d.vUy)("TSL: 'Loop( { update: ... } )' is not a function, string or number."),W="break /* invalid update */")}else T==="int"||T==="uint"?P=w.includes("<")?"++":"--":P=K()+" 1.",W=v+" "+P;const U=e.getVar(T,v)+" = "+D,j=v+" "+w+" "+F;C=`for ( ${U}; ${j}; ${W} )`}e.addFlowCode((c===0?`
`:"")+e.tab+C+` {
`).addFlowTab()}const a=s.build(e,"void");t.returnsNode.build(e,"void"),e.removeFlowTab().addFlowCode(`
`+e.tab+a);for(let c=0,h=this.params.length-1;c<h;c++)e.addFlowCode((c===0?"":e.tab)+`}
`).removeFlowTab();e.addFlowTab()}}const ci=(...i)=>new bC(ua(i,"int")).toStack(),vC=()=>ii("continue").toStack(),L1=()=>ii("break").toStack(),nv=new WeakMap,Zs=new d.Ltg,I1=fe(({bufferMap:i,influence:e,stride:t,width:r,depth:s,offset:a})=>{const c=re(M1).mul(t).add(a),h=c.div(r),f=c.sub(h.mul(r));return ji(i,Vi(f,h)).depth(s).xyz.mul(e)});function SC(i){const e=i.morphAttributes.position!==void 0,t=i.morphAttributes.normal!==void 0,r=i.morphAttributes.color!==void 0,s=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,a=s!==void 0?s.length:0;let c=nv.get(i);if(c===void 0||c.count!==a){let E=function(){P.dispose(),nv.delete(i),i.removeEventListener("dispose",E)};c!==void 0&&c.texture.dispose();const h=i.morphAttributes.position||[],f=i.morphAttributes.normal||[],m=i.morphAttributes.color||[];let x=0;e===!0&&(x=1),t===!0&&(x=2),r===!0&&(x=3);let _=i.attributes.position.count*x,v=1;const T=4096;_>T&&(v=Math.ceil(_/T),_=T);const w=new Float32Array(_*v*4*a),P=new d.p3g(w,_,v,a);P.type=d.VzW,P.needsUpdate=!0;const C=x*4;for(let D=0;D<a;D++){const F=h[D],W=f[D],K=m[D],U=_*v*4*D;for(let j=0;j<F.count;j++){const oe=j*C;e===!0&&(Zs.fromBufferAttribute(F,j),w[U+oe+0]=Zs.x,w[U+oe+1]=Zs.y,w[U+oe+2]=Zs.z,w[U+oe+3]=0),t===!0&&(Zs.fromBufferAttribute(W,j),w[U+oe+4]=Zs.x,w[U+oe+5]=Zs.y,w[U+oe+6]=Zs.z,w[U+oe+7]=0),r===!0&&(Zs.fromBufferAttribute(K,j),w[U+oe+8]=Zs.x,w[U+oe+9]=Zs.y,w[U+oe+10]=Zs.z,w[U+oe+11]=K.itemSize===4?Zs.w:1)}}c={count:a,texture:P,stride:x,size:new d.FM8(_,v)},nv.set(i,c),i.addEventListener("dispose",E)}return c}class TC extends Rt{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=Bt(1),this.updateType=xn.OBJECT}setup(e){const{geometry:t}=e,r=t.morphAttributes.position!==void 0,s=t.hasAttribute("normal")&&t.morphAttributes.normal!==void 0,a=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,c=a!==void 0?a.length:0,{texture:h,stride:f,size:m}=SC(t);r===!0&&er.mulAssign(this.morphBaseInfluence),s===!0&&Ss.mulAssign(this.morphBaseInfluence);const x=re(m.width);ci(c,({i:_})=>{const v=G(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?v.assign(ji(this.mesh.morphTexture,Vi(re(_).add(1),re(gl))).r):v.assign(xi("morphTargetInfluences","float").element(_).toVar()),Dt(v.notEqual(0),()=>{r===!0&&er.addAssign(I1({bufferMap:h,influence:v,stride:f,width:x,depth:_,offset:re(0)})),s===!0&&Ss.addAssign(I1({bufferMap:h,influence:v,stride:f,width:x,depth:_,offset:re(1)}))})})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((t,r)=>t+r,0)}}const D1=sn(TC).setParameterLength(1);class Ed extends Rt{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class MC extends Ed{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class wC extends A{static get type(){return"LightingContextNode"}constructor(e,t=null,r=null,s=null){super(e),this.lightingModel=t,this.backdropNode=r,this.backdropAlphaNode=s,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,r=ce().toVar("directDiffuse"),s=ce().toVar("directSpecular"),a=ce().toVar("indirectDiffuse"),c=ce().toVar("indirectSpecular"),h={directDiffuse:r,directSpecular:s,indirectDiffuse:a,indirectSpecular:c};return{radiance:ce().toVar("radiance"),irradiance:ce().toVar("irradiance"),iblIrradiance:ce().toVar("iblIrradiance"),ambientOcclusion:G(1).toVar("ambientOcclusion"),reflectedLight:h,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)}}const U1=sn(wC);class AC extends Ed{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}const Cd=new d.FM8;class fx extends _a{static get type(){return"ViewportTextureNode"}constructor(e=mc,t=null,r=null){let s=null;r===null?(s=new d.Wzm,s.minFilter=d.D1R,r=s):s=r,super(r,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=s,this.isOutputTextureNode=!0,this.updateBeforeType=xn.FRAME,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,r;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,r=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,r=this._cacheTextures),e===null)return t;if(r.has(e)===!1){const s=t.clone();r.set(e,s)}return r.get(e)}updateReference(e){const t=e.renderer.getRenderTarget();return this.value=this.getTextureForReference(t),this.value}updateBefore(e){const t=e.renderer,r=t.getRenderTarget();r===null?t.getDrawingBufferSize(Cd):Cd.set(r.width,r.height);const s=this.getTextureForReference(r);(s.image.width!==Cd.width||s.image.height!==Cd.height)&&(s.image.width=Cd.width,s.image.height=Cd.height,s.needsUpdate=!0);const a=s.generateMipmaps;s.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(s),s.generateMipmaps=a}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const EC=sn(fx).setParameterLength(0,3),iv=sn(fx,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let px=null;class CC extends fx{static get type(){return"ViewportDepthTextureNode"}constructor(e=mc,t=null){px===null&&(px=new d.$YQ),super(e,t,px)}getTextureForReference(){return px}}const rv=sn(CC).setParameterLength(0,2);class Ts extends Rt{static get type(){return"ViewportDepthNode"}constructor(e,t=null){super("float"),this.scope=e,this.valueNode=t,this.isViewportDepthNode=!0}generate(e){const{scope:t}=this;return t===Ts.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,r=this.valueNode;let s=null;if(t===Ts.DEPTH_BASE)r!==null&&(s=F1().assign(r));else if(t===Ts.DEPTH)e.isPerspectiveCamera?s=sv(tr.z,gc,xc):s=Rd(tr.z,gc,xc);else if(t===Ts.LINEAR_DEPTH)if(r!==null)if(e.isPerspectiveCamera){const a=ov(r,gc,xc);s=Rd(a,gc,xc)}else s=r;else s=Rd(tr.z,gc,xc);return s}}Ts.DEPTH_BASE="depthBase",Ts.DEPTH="depth",Ts.LINEAR_DEPTH="linearDepth";const Rd=(i,e,t)=>i.add(e).div(e.sub(t)),RC=(i,e,t)=>e.sub(t).mul(i).sub(e),sv=(i,e,t)=>e.add(i).mul(t).div(t.sub(e).mul(i)),ov=(i,e,t)=>e.mul(t).div(t.sub(e).mul(i).sub(t)),av=(i,e,t)=>{e=e.max(1e-6).toVar();const r=Wo(i.negate().div(e)),s=Wo(t.div(e));return r.div(s)},NC=(i,e,t)=>{const r=i.mul(Su(t.div(e)));return G(Math.E).pow(r).mul(e).negate()},F1=sn(Ts,Ts.DEPTH_BASE),cv=pt(Ts,Ts.DEPTH),Nd=sn(Ts,Ts.LINEAR_DEPTH).setParameterLength(0,1),PC=Nd(rv());cv.assign=i=>F1(i);class xo extends Rt{static get type(){return"ClippingNode"}constructor(e=xo.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:r,unionPlanes:s}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===xo.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(r,s):this.scope===xo.HARDWARE?this.setupHardwareClipping(s,e):this.setupDefault(r,s)}setupAlphaToCoverage(e,t){return fe(()=>{const r=G().toVar("distanceToPlane"),s=G().toVar("distanceToGradient"),a=G(1).toVar("clipOpacity"),c=t.length;if(this.hardwareClipping===!1&&c>0){const f=Xr(t).setGroup(Ft);ci(c,({i:m})=>{const x=f.element(m);r.assign(tr.dot(x.xyz).negate().add(x.w)),s.assign(r.fwidth().div(2)),a.mulAssign(bs(s.negate(),s,r))})}const h=e.length;if(h>0){const f=Xr(e).setGroup(Ft),m=G(1).toVar("intersectionClipOpacity");ci(h,({i:x})=>{const _=f.element(x);r.assign(tr.dot(_.xyz).negate().add(_.w)),s.assign(r.fwidth().div(2)),m.mulAssign(bs(s.negate(),s,r).oneMinus())}),a.mulAssign(m.oneMinus())}jn.a.mulAssign(a),jn.a.equal(0).discard()})()}setupDefault(e,t){return fe(()=>{const r=t.length;if(this.hardwareClipping===!1&&r>0){const a=Xr(t).setGroup(Ft);ci(r,({i:c})=>{const h=a.element(c);tr.dot(h.xyz).greaterThan(h.w).discard()})}const s=e.length;if(s>0){const a=Xr(e).setGroup(Ft),c=br(!0).toVar("clipped");ci(s,({i:h})=>{const f=a.element(h);c.assign(tr.dot(f.xyz).greaterThan(f.w).and(c))}),c.discard()}})()}setupHardwareClipping(e,t){const r=e.length;return t.enableHardwareClipping(r),fe(()=>{const s=Xr(e).setGroup(Ft),a=pc(t.getClipDistance());ci(r,({i:c})=>{const h=s.element(c),f=tr.dot(h.xyz).sub(h.w).negate();a.element(c).assign(f)})})()}}xo.ALPHA_TO_COVERAGE="alphaToCoverage",xo.DEFAULT="default",xo.HARDWARE="hardware";const LC=()=>Oe(new xo),IC=()=>Oe(new xo(xo.ALPHA_TO_COVERAGE)),DC=()=>Oe(new xo(xo.HARDWARE)),UC=.05,B1=fe(([i])=>Hs(cn(1e4,jr(cn(17,i.x).add(cn(.1,i.y)))).mul(Yi(.1,ai(jr(cn(13,i.y).add(i.x))))))),O1=fe(([i])=>B1(Ve(B1(i.xy),i.z))),FC=fe(([i])=>{const e=Mi($s(xd(i.xyz)),$s(_d(i.xyz))),t=G(1).div(G(UC).mul(e)).toVar("pixScale"),r=Ve(ga(Or(Wo(t))),ga(Ho(Wo(t)))),s=Ve(O1(Or(r.x.mul(i.xyz))),O1(Or(r.y.mul(i.xyz)))),a=Hs(Wo(t)),c=Yi(cn(a.oneMinus(),s.x),cn(a,s.y)),h=Kn(a,a.oneMinus()),f=ce(c.mul(c).div(cn(2,h).mul(Cn(1,h))),c.sub(cn(.5,h)).div(Cn(1,h)),Cn(1,Cn(1,c).mul(Cn(1,c)).div(cn(2,h).mul(Cn(1,h))))),m=c.lessThan(h.oneMinus()).select(c.lessThan(h).select(f.x,f.y),f.z);return ys(m,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class BC extends Xp{static get type(){return"VertexColorNode"}constructor(e){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),r=e.hasGeometryAttribute(t);let s;return r===!0?s=super.generate(e):s=e.generateConst(this.nodeType,new d.Ltg(1,1,1,1)),s}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const k1=(i=0)=>Oe(new BC(i)),V1=fe(([i,e])=>Kn(1,i.oneMinus().div(e)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),z1=fe(([i,e])=>Kn(i.div(e.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),G1=fe(([i,e])=>i.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),W1=fe(([i,e])=>Xn(i.mul(2).mul(e),i.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),Pi(.5,i))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),OC=fe(([i,e])=>{const t=e.a.add(i.a.mul(e.a.oneMinus()));return At(e.rgb.mul(e.a).add(i.rgb.mul(i.a).mul(e.a.oneMinus())).div(t),t)}).setLayout({name:"blendColor",type:"vec4",inputs:[{name:"base",type:"vec4"},{name:"blend",type:"vec4"}]}),H1=fe(([i])=>At(i.rgb.mul(i.a),i.a),{color:"vec4",return:"vec4"}),kC=fe(([i])=>(Dt(i.a.equal(0),()=>At(0)),At(i.rgb.div(i.a),i.a)),{color:"vec4",return:"vec4"}),VC=(...i)=>((0,d.ZK6)('TSL: "burn" has been renamed. Use "blendBurn" instead.'),V1(i)),zC=(...i)=>((0,d.ZK6)('TSL: "dodge" has been renamed. Use "blendDodge" instead.'),z1(i)),GC=(...i)=>((0,d.ZK6)('TSL: "screen" has been renamed. Use "blendScreen" instead.'),G1(i)),WC=(...i)=>((0,d.ZK6)('TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),W1(i));class Gi extends d.F5T{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!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.maskNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,Object.defineProperty(this,"shadowPositionNode",{get:()=>this.receivedShadowPositionNode,set:e=>{(0,d.ZK6)('NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".'),this.receivedShadowPositionNode=e}})}_getNodeChildren(){const e=[];for(const t of Object.getOwnPropertyNames(this)){if(t.startsWith("_")===!0)continue;const r=this[t];r&&r.isNode===!0&&e.push({property:t,childNode:r})}return e}customProgramCacheKey(){const e=[];for(const{property:t,childNode:r}of this._getNodeChildren())e.push(Jc(t.slice(0,-4)),r.getCacheKey());return this.type+Os(e)}build(e){this.setup(e)}setupObserver(e){return new nb(e)}setup(e){e.context.setupNormal=()=>Re(this.setupNormal(e),"NORMAL","vec3"),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,r=t.getRenderTarget();e.addStack();const s=Re(this.setupVertex(e),"VERTEX"),a=this.vertexNode||s;e.stack.outputNode=a,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let c;const h=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(r!==null?r.depthBuffer===!0&&this.setupDepth(e):t.depth===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);const f=this.setupLighting(e);h!==null&&e.stack.addToStack(h);const m=At(f,jn.a).max(0);c=this.setupOutput(e,m),ac.assign(c);const x=this.outputNode!==null;if(x&&(c=this.outputNode),r!==null){const _=t.getMRT(),v=this.mrtNode;_!==null?(x&&ac.assign(c),c=_,v!==null&&(c=_.merge(v))):v!==null&&(c=v)}}else{let f=this.fragmentNode;f.isOutputStructNode!==!0&&(f=At(f)),c=this.setupOutput(e,f)}e.stack.outputNode=c,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{unionPlanes:t,intersectionPlanes:r}=e.clippingContext;let s=null;if(t.length>0||r.length>0){const a=e.renderer.currentSamples;this.alphaToCoverage&&a>1?s=IC():e.stack.addToStack(LC())}return s}setupHardwareClipping(e){if(this.hardwareClipping=!1,e.clippingContext===null)return;const t=e.clippingContext.unionPlanes.length;t>0&&t<=8&&e.isAvailable("clipDistance")&&(e.stack.addToStack(DC()),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:r}=e;let s=this.depthNode;if(s===null){const a=t.getMRT();a&&a.has("depth")?s=a.get("depth"):t.logarithmicDepthBuffer===!0&&(r.isPerspectiveCamera?s=av(tr.z,gc,xc):s=Rd(tr.z,gc,xc))}s!==null&&cv.assign(s).toStack()}setupPositionView(){return _c.mul(er).xyz}setupModelViewProjection(){return po.mul(tr)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),tv}setupPosition(e){const{object:t,geometry:r}=e;if((r.morphAttributes.position||r.morphAttributes.normal||r.morphAttributes.color)&&D1(t).toStack(),t.isSkinnedMesh===!0&&P1(t).toStack(),this.displacementMap){const s=yc("displacementMap","texture"),a=yc("displacementScale","float"),c=yc("displacementBias","float");er.addAssign(Ss.normalize().mul(s.x.mul(a).add(c)))}return t.isBatchedMesh&&C1(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&E1(t).toStack(),this.positionNode!==null&&er.assign(Re(this.positionNode,"POSITION","vec3")),er}setupDiffuseColor(e){const{object:t,geometry:r}=e;this.maskNode!==null&&br(this.maskNode).not().discard();let s=this.colorNode?At(this.colorNode):lx;this.vertexColors===!0&&r.hasAttribute("color")&&(s=s.mul(k1())),t.instanceColor&&(s=lr("vec3","vInstanceColor").mul(s)),t.isBatchedMesh&&t._colorsTexture&&(s=lr("vec3","vBatchColor").mul(s)),jn.assign(s);const a=this.opacityNode?G(this.opacityNode):ux;jn.a.assign(jn.a.mul(a));let c=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(c=this.alphaTestNode!==null?G(this.alphaTestNode):QT,this.alphaToCoverage===!0?(jn.a=bs(c,c.add(yd(jn.a)),jn.a),jn.a.lessThanEqual(0).discard()):jn.a.lessThanEqual(c).discard()),this.alphaHash===!0&&jn.a.lessThan(FC(er)).discard(),e.isOpaque()&&jn.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?ce(0):jn.rgb}setupNormal(){return this.normalNode?ce(this.normalNode):s1}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?yc("envMap","cubeTexture"):yc("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new AC(ev)),t}setupLights(e){const t=[],r=this.setupEnvironment(e);r&&r.isLightingNode&&t.push(r);const s=this.setupLightMap(e);if(s&&s.isLightingNode&&t.push(s),this.aoNode!==null||e.material.aoMap){const c=this.aoNode!==null?this.aoNode:T1;t.push(new MC(c))}let a=this.lightsNode||e.lightsNode;return t.length>0&&(a=e.renderer.lighting.createNode([...a.getLights(),...t])),a}setupLightingModel(){}setupLighting(e){const{material:t}=e,{backdropNode:r,backdropAlphaNode:s,emissiveNode:a}=this,h=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null;let f=this.setupOutgoingLight(e);if(h&&h.getScope().hasLights){const m=this.setupLightingModel(e)||null;f=U1(h,m,r,s)}else r!==null&&(f=ce(s!==null?Xn(f,r,s):r));return(a&&a.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(hu.assign(ce(a||e1)),f=f.add(hu)),f}setupFog(e,t){const r=e.fogNode;return r&&(ac.assign(t),t=At(r.toVar())),t}setupPremultipliedAlpha(e,t){return H1(t)}setupOutput(e,t){return this.fog===!0&&(t=this.setupFog(e,t)),this.premultipliedAlpha===!0&&(t=this.setupPremultipliedAlpha(e,t)),t}setDefaultValues(e){for(const r in e){const s=e[r];this[r]===void 0&&(this[r]=s,s&&s.clone&&(this[r]=s.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const r in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,r)===void 0&&t[r].get!==void 0&&Object.defineProperty(this.constructor.prototype,r,t[r])}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{},nodes:{}});const r=d.F5T.prototype.toJSON.call(this,e);r.inputNodes={};for(const{property:a,childNode:c}of this._getNodeChildren())r.inputNodes[a]=c.toJSON(e).uuid;function s(a){const c=[];for(const h in a){const f=a[h];delete f.metadata,c.push(f)}return c}if(t){const a=s(e.textures),c=s(e.images),h=s(e.nodes);a.length>0&&(r.textures=a),c.length>0&&(r.images=c),h.length>0&&(r.nodes=h)}return r}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.aoNode=e.aoNode,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.maskNode=e.maskNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const HC=new d.nls;class $C extends Gi{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(HC),this.setValues(e)}}const jC=new d.FT0;class XC extends Gi{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(jC),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?G(this.offsetNode):Jb,t=this.dashScaleNode?G(this.dashScaleNode):Zb,r=this.dashSizeNode?G(this.dashSizeNode):Yb,s=this.gapSizeNode?G(this.gapSizeNode):Qb;Go.assign(r),dl.assign(s);const a=We(hs("lineDistance").mul(t));(e?a.add(e):a).mod(Go.add(dl)).greaterThan(Go).discard()}}let mx=null;class qC extends fx{static get type(){return"ViewportSharedTextureNode"}constructor(e=mc,t=null){mx===null&&(mx=new d.Wzm),super(e,t,mx)}getTextureForReference(){return mx}updateReference(){return this}}const $1=sn(qC).setParameterLength(0,2),KC=new d.FT0;class a4 extends null{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.isLine2NodeMaterial=!0,this.setDefaultValues(KC),this.useColor=e.vertexColors,this.dashOffset=0,this.lineColorNode=null,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.blending=NoBlending,this._useDash=e.dashed,this._useAlphaToCoverage=!0,this._useWorldUnits=!1,this.setValues(e)}setup(e){const{renderer:t}=e,r=this._useAlphaToCoverage,s=this.useColor,a=this._useDash,c=this._useWorldUnits,h=fe(({start:m,end:x})=>{const _=po.element(2).element(2),w=po.element(3).element(2).mul(-.5).div(_).sub(m.z).div(x.z.sub(m.z));return At(Xn(m.xyz,x.xyz,w),x.w)}).setLayout({name:"trimSegment",type:"vec4",inputs:[{name:"start",type:"vec4"},{name:"end",type:"vec4"}]});this.vertexNode=fe(()=>{const m=hs("instanceStart"),x=hs("instanceEnd"),_=At(_c.mul(At(m,1))).toVar("start"),v=At(_c.mul(At(x,1))).toVar("end");if(a){const K=this.dashScaleNode?G(this.dashScaleNode):Zb,U=this.offsetNode?G(this.offsetNode):Jb,j=hs("instanceDistanceStart"),oe=hs("instanceDistanceEnd");let k=zr.y.lessThan(.5).select(K.mul(j),K.mul(oe));k=k.add(U),lr("float","lineDistance").assign(k)}c&&(lr("vec3","worldStart").assign(_.xyz),lr("vec3","worldEnd").assign(v.xyz));const T=Sd.z.div(Sd.w),w=po.element(2).element(3).equal(-1);Dt(w,()=>{Dt(_.z.lessThan(0).and(v.z.greaterThan(0)),()=>{v.assign(h({start:_,end:v}))}).ElseIf(v.z.lessThan(0).and(_.z.greaterThanEqual(0)),()=>{_.assign(h({start:v,end:_}))})});const P=po.mul(_),C=po.mul(v),E=P.xyz.div(P.w),D=C.xyz.div(C.w),F=D.xy.sub(E.xy).toVar();F.x.assign(F.x.mul(T)),F.assign(F.normalize());const W=At().toVar();if(c){const K=v.xyz.sub(_.xyz).normalize(),U=Xn(_.xyz,v.xyz,.5).normalize(),j=K.cross(U).normalize(),oe=K.cross(j),k=lr("vec4","worldPos");k.assign(zr.y.lessThan(.5).select(_,v));const O=dx.mul(.5);k.addAssign(At(zr.x.lessThan(0).select(j.mul(O),j.mul(O).negate()),0)),a||(k.addAssign(At(zr.y.lessThan(.5).select(K.mul(O).negate(),K.mul(O)),0)),k.addAssign(At(oe.mul(O),0)),Dt(zr.y.greaterThan(1).or(zr.y.lessThan(0)),()=>{k.subAssign(At(oe.mul(2).mul(O),0))})),W.assign(po.mul(k));const le=ce().toVar();le.assign(zr.y.lessThan(.5).select(E,D)),W.z.assign(le.z.mul(W.w))}else{const K=Ve(F.y,F.x.negate()).toVar("offset");F.x.assign(F.x.div(T)),K.x.assign(K.x.div(T)),K.assign(zr.x.lessThan(0).select(K.negate(),K)),Dt(zr.y.lessThan(0),()=>{K.assign(K.sub(F))}).ElseIf(zr.y.greaterThan(1),()=>{K.assign(K.add(F))}),K.assign(K.mul(dx)),K.assign(K.div(Sd.w)),W.assign(zr.y.lessThan(.5).select(P,C)),K.assign(K.mul(W.w)),W.assign(W.add(At(K,0,0)))}return W})();const f=fe(({p1:m,p2:x,p3:_,p4:v})=>{const T=m.sub(_),w=v.sub(_),P=x.sub(m),C=T.dot(w),E=w.dot(P),D=T.dot(P),F=w.dot(w),K=P.dot(P).mul(F).sub(E.mul(E)),j=C.mul(E).sub(D.mul(F)).div(K).clamp(),oe=C.add(E.mul(j)).div(F).clamp();return Ve(j,oe)});if(this.colorNode=fe(()=>{const m=hi();if(a){const v=this.dashSizeNode?G(this.dashSizeNode):Yb,T=this.gapSizeNode?G(this.gapSizeNode):Qb;Go.assign(v),dl.assign(T);const w=lr("float","lineDistance");m.y.lessThan(-1).or(m.y.greaterThan(1)).discard(),w.mod(Go.add(dl)).greaterThan(Go).discard()}const x=G(1).toVar("alpha");if(c){const v=lr("vec3","worldStart"),T=lr("vec3","worldEnd"),w=lr("vec4","worldPos").xyz.normalize().mul(1e5),P=T.sub(v),C=f({p1:v,p2:T,p3:ce(0,0,0),p4:w}),E=v.add(P.mul(C.x)),D=w.mul(C.y),K=E.sub(D).length().div(dx);if(!a)if(r&&t.currentSamples>0){const U=K.fwidth();x.assign(bs(U.negate().add(.5),U.add(.5),K).oneMinus())}else K.greaterThan(.5).discard()}else if(r&&t.currentSamples>0){const v=m.x,T=m.y.greaterThan(0).select(m.y.sub(1),m.y.add(1)),w=v.mul(v).add(T.mul(T)),P=G(w.fwidth()).toVar("dlen");Dt(m.y.abs().greaterThan(1),()=>{x.assign(bs(P.oneMinus(),P.add(1),w).oneMinus())})}else Dt(m.y.abs().greaterThan(1),()=>{const v=m.x,T=m.y.greaterThan(0).select(m.y.sub(1),m.y.add(1));v.mul(v).add(T.mul(T)).greaterThan(1).discard()});let _;if(this.lineColorNode)_=this.lineColorNode;else if(s){const v=hs("instanceColorStart"),T=hs("instanceColorEnd");_=zr.y.lessThan(.5).select(v,T).mul(lx)}else _=lx;return At(_,x)})(),this.transparent){const m=this.opacityNode?G(this.opacityNode):ux;this.outputNode=At(this.colorNode.rgb.mul(m).add($1().rgb.mul(m.oneMinus())),this.colorNode.a)}super.setup(e)}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 j1=i=>Oe(i).mul(.5).add(.5),ZC=i=>Oe(i).mul(2).sub(1),YC=new d.RSm;class QC extends Gi{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(YC),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?G(this.opacityNode):ux;jn.assign(ni(At(j1(ri),e),d.KI_))}}const lv=fe(([i=Ob])=>{const e=i.z.atan(i.x).mul(1/(Math.PI*2)).add(.5),t=i.y.clamp(-1,1).asin().mul(1/Math.PI).add(.5);return Ve(e,t)});class X1 extends d.oAp{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const r=t.minFilter,s=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 a=new d.DvJ(5,5,5),c=lv(Ob),h=new Gi;h.colorNode=In(t,c,0),h.side=d._Li,h.blending=d.jFi;const f=new d.Kj0(a,h),m=new d.xsS;m.add(f),t.minFilter===d.D1R&&(t.minFilter=d.wem);const x=new d._am(1,10,this),_=e.getMRT();return e.setMRT(null),x.update(e,m),e.setMRT(_),t.minFilter=r,t.currentGenerateMipmaps=s,f.geometry.dispose(),f.material.dispose(),this}}const tm=new WeakMap;class JC extends Oi{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=wd(null);const t=new d.BtG;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=xn.RENDER}updateBefore(e){const{renderer:t,material:r}=e,s=this.envNode;if(s.isTextureNode||s.isMaterialReferenceNode){const a=s.isTextureNode?s.value:r[s.property];if(a&&a.isTexture){const c=a.mapping;if(c===d.dSO||c===d.Bf4){if(tm.has(a)){const h=tm.get(a);K1(h,a.mapping),this._cubeTexture=h}else{const h=a.image;if(eR(h)){const f=new X1(h.height);f.fromEquirectangularTexture(t,a),K1(f.texture,a.mapping),this._cubeTexture=f.texture,tm.set(a,f.texture),a.addEventListener("dispose",q1)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function eR(i){return i==null?!1:i.height>0}function q1(i){const e=i.target;e.removeEventListener("dispose",q1);const t=tm.get(e);t!==void 0&&(tm.delete(e),t.dispose())}function K1(i,e){e===d.dSO?i.mapping=d.fY$:e===d.Bf4&&(i.mapping=d.vxC)}const Z1=sn(JC).setParameterLength(1);class uv extends Ed{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=Z1(this.envNode)}}class tR extends Ed{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=G(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class gx{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class Y1 extends gx{constructor(){super()}indirect({context:e}){const t=e.ambientOcclusion,r=e.reflectedLight,s=e.irradianceLightMap;r.indirectDiffuse.assign(At(0)),s?r.indirectDiffuse.addAssign(s):r.indirectDiffuse.addAssign(At(1,1,1,0)),r.indirectDiffuse.mulAssign(t),r.indirectDiffuse.mulAssign(jn.rgb)}finish(e){const{material:t,context:r}=e,s=r.outgoingLight,a=e.context.environment;if(a)switch(t.combine){case d.Ns1:s.rgb.assign(Xn(s.rgb,s.rgb.mul(a.rgb),em.mul(hx)));break;case d.qhX:s.rgb.assign(Xn(s.rgb,a.rgb,em.mul(hx)));break;case d.NDo:s.rgb.addAssign(a.rgb.mul(em.mul(hx)));break;default:(0,d.ZK6)("BasicLightingModel: Unsupported .combine value:",t.combine);break}}}const nR=new d.vBJ;class iR extends Gi{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(nR),this.setValues(e)}setupNormal(){return Td(Md)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new uv(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new tR(ev)),t}setupOutgoingLight(){return jn.rgb}setupLightingModel(){return new Y1}}const Pd=fe(({f0:i,f90:e,dotVH:t})=>{const r=t.mul(-5.55473).sub(6.98316).mul(t).exp2();return i.mul(r.oneMinus()).add(e.mul(r))}),Du=fe(i=>i.diffuseColor.mul(1/Math.PI)),rR=()=>G(.25),sR=fe(({dotNH:i})=>ld.mul(G(.5)).add(1).mul(G(1/Math.PI)).mul(i.pow(ld))),oR=fe(({lightDirection:i})=>{const e=i.add(Ai).normalize(),t=ri.dot(e).clamp(),r=Ai.dot(e).clamp(),s=Pd({f0:as,f90:1,dotVH:r}),a=rR(),c=sR({dotNH:t});return s.mul(a).mul(c)});class Q1 extends Y1{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const a=ri.dot(e).clamp().mul(t);r.directDiffuse.addAssign(a.mul(Du({diffuseColor:jn.rgb}))),this.specular===!0&&r.directSpecular.addAssign(a.mul(oR({lightDirection:e})).mul(em))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul(Du({diffuseColor:jn}))),s.indirectDiffuse.mulAssign(t)}}const aR=new d.YBo;class cR extends Gi{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(aR),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new uv(t):null}setupLightingModel(){return new Q1(!1)}}const lR=new d.xoR;class uR extends Gi{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(lR),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new uv(t):null}setupLightingModel(){return new Q1}setupVariants(){const e=(this.shininessNode?G(this.shininessNode):JT).max(1e-4);ld.assign(e);const t=this.specularNode||t1;as.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const J1=fe(i=>{if(i.geometry.hasAttribute("normal")===!1)return G(0);const e=Md.dFdx().abs().max(Md.dFdy().abs());return e.x.max(e.y).max(e.z)}),hv=fe(i=>{const{roughness:e}=i,t=J1();let r=e.max(.0525);return r=r.add(t),r=r.min(1),r}),eM=fe(({alpha:i,dotNL:e,dotNV:t})=>{const r=i.pow2(),s=e.mul(r.add(r.oneMinus().mul(t.pow2())).sqrt()),a=t.mul(r.add(r.oneMinus().mul(e.pow2())).sqrt());return cs(.5,s.add(a).max(G0))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),hR=fe(({alphaT:i,alphaB:e,dotTV:t,dotBV:r,dotTL:s,dotBL:a,dotNV:c,dotNL:h})=>{const f=h.mul(ce(i.mul(t),e.mul(r),c).length()),m=c.mul(ce(i.mul(s),e.mul(a),h).length());return cs(.5,f.add(m)).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"}]}),tM=fe(({alpha:i,dotNH:e})=>{const t=i.pow2(),r=e.pow2().mul(t.oneMinus()).oneMinus();return t.div(r.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),dR=G(1/Math.PI),fR=fe(({alphaT:i,alphaB:e,dotNH:t,dotTH:r,dotBH:s})=>{const a=i.mul(e),c=ce(e.mul(r),i.mul(s),a.mul(t)),h=c.dot(c),f=a.div(h);return dR.mul(a.mul(f.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"}]}),dv=fe(({lightDirection:i,f0:e,f90:t,roughness:r,f:s,normalView:a=ri,USE_IRIDESCENCE:c,USE_ANISOTROPY:h})=>{const f=r.pow2(),m=i.add(Ai).normalize(),x=a.dot(i).clamp(),_=a.dot(Ai).clamp(),v=a.dot(m).clamp(),T=Ai.dot(m).clamp();let w=Pd({f0:e,f90:t,dotVH:T}),P,C;if(ol(c)&&(w=fa.mix(w,s)),ol(h)){const E=gu.dot(i),D=gu.dot(Ai),F=gu.dot(m),W=pa.dot(i),K=pa.dot(Ai),U=pa.dot(m);P=hR({alphaT:mu,alphaB:f,dotTV:D,dotBV:K,dotTL:E,dotBL:W,dotNV:_,dotNL:x}),C=fR({alphaT:mu,alphaB:f,dotNH:v,dotTH:F,dotBH:U})}else P=eM({alpha:f,dotNL:x,dotNV:_}),C=tM({alpha:f,dotNH:v});return w.mul(P).mul(C)}),pR=new Uint16Array([11481,15204,11534,15171,11808,15015,12385,14843,12894,14716,13396,14600,13693,14483,13976,14366,14237,14171,14405,13961,14511,13770,14605,13598,14687,13444,14760,13305,14822,13066,14876,12857,14923,12675,14963,12517,14997,12379,15025,12230,15049,12023,15070,11843,15086,11687,15100,11551,15111,11433,15120,11330,15127,11217,15132,11060,15135,10922,15138,10801,15139,10695,15139,10600,13012,14923,13020,14917,13064,14886,13176,14800,13349,14666,13513,14526,13724,14398,13960,14230,14200,14020,14383,13827,14488,13651,14583,13491,14667,13348,14740,13132,14803,12908,14856,12713,14901,12542,14938,12394,14968,12241,14992,12017,15010,11822,15024,11654,15034,11507,15041,11380,15044,11269,15044,11081,15042,10913,15037,10764,15031,10635,15023,10520,15014,10419,15003,10330,13657,14676,13658,14673,13670,14660,13698,14622,13750,14547,13834,14442,13956,14317,14112,14093,14291,13889,14407,13704,14499,13538,14586,13389,14664,13201,14733,12966,14792,12758,14842,12577,14882,12418,14915,12272,14940,12033,14959,11826,14972,11646,14980,11490,14983,11355,14983,11212,14979,11008,14971,10830,14961,10675,14950,10540,14936,10420,14923,10315,14909,10204,14894,10041,14089,14460,14090,14459,14096,14452,14112,14431,14141,14388,14186,14305,14252,14130,14341,13941,14399,13756,14467,13585,14539,13430,14610,13272,14677,13026,14737,12808,14790,12617,14833,12449,14869,12303,14896,12065,14916,11845,14929,11655,14937,11490,14939,11347,14936,11184,14930,10970,14921,10783,14912,10621,14900,10480,14885,10356,14867,10247,14848,10062,14827,9894,14805,9745,14400,14208,14400,14206,14402,14198,14406,14174,14415,14122,14427,14035,14444,13913,14469,13767,14504,13613,14548,13463,14598,13324,14651,13082,14704,12858,14752,12658,14795,12483,14831,12330,14860,12106,14881,11875,14895,11675,14903,11501,14905,11351,14903,11178,14900,10953,14892,10757,14880,10589,14865,10442,14847,10313,14827,10162,14805,9965,14782,9792,14757,9642,14731,9507,14562,13883,14562,13883,14563,13877,14566,13862,14570,13830,14576,13773,14584,13689,14595,13582,14613,13461,14637,13336,14668,13120,14704,12897,14741,12695,14776,12516,14808,12358,14835,12150,14856,11910,14870,11701,14878,11519,14882,11361,14884,11187,14880,10951,14871,10748,14858,10572,14842,10418,14823,10286,14801,10099,14777,9897,14751,9722,14725,9567,14696,9430,14666,9309,14702,13604,14702,13604,14702,13600,14703,13591,14705,13570,14707,13533,14709,13477,14712,13400,14718,13305,14727,13106,14743,12907,14762,12716,14784,12539,14807,12380,14827,12190,14844,11943,14855,11727,14863,11539,14870,11376,14871,11204,14868,10960,14858,10748,14845,10565,14829,10406,14809,10269,14786,10058,14761,9852,14734,9671,14705,9512,14674,9374,14641,9253,14608,9076,14821,13366,14821,13365,14821,13364,14821,13358,14821,13344,14821,13320,14819,13252,14817,13145,14815,13011,14814,12858,14817,12698,14823,12539,14832,12389,14841,12214,14850,11968,14856,11750,14861,11558,14866,11390,14867,11226,14862,10972,14853,10754,14840,10565,14823,10401,14803,10259,14780,10032,14754,9820,14725,9635,14694,9473,14661,9333,14627,9203,14593,8988,14557,8798,14923,13014,14922,13014,14922,13012,14922,13004,14920,12987,14919,12957,14915,12907,14909,12834,14902,12738,14894,12623,14888,12498,14883,12370,14880,12203,14878,11970,14875,11759,14873,11569,14874,11401,14872,11243,14865,10986,14855,10762,14842,10568,14825,10401,14804,10255,14781,10017,14754,9799,14725,9611,14692,9445,14658,9301,14623,9139,14587,8920,14548,8729,14509,8562,15008,12672,15008,12672,15008,12671,15007,12667,15005,12656,15001,12637,14997,12605,14989,12556,14978,12490,14966,12407,14953,12313,14940,12136,14927,11934,14914,11742,14903,11563,14896,11401,14889,11247,14879,10992,14866,10767,14851,10570,14833,10400,14812,10252,14789,10007,14761,9784,14731,9592,14698,9424,14663,9279,14627,9088,14588,8868,14548,8676,14508,8508,14467,8360,15080,12386,15080,12386,15079,12385,15078,12383,15076,12378,15072,12367,15066,12347,15057,12315,15045,12253,15030,12138,15012,11998,14993,11845,14972,11685,14951,11530,14935,11383,14920,11228,14904,10981,14887,10762,14870,10567,14850,10397,14827,10248,14803,9997,14774,9771,14743,9578,14710,9407,14674,9259,14637,9048,14596,8826,14555,8632,14514,8464,14471,8317,14427,8182,15139,12008,15139,12008,15138,12008,15137,12007,15135,12003,15130,11990,15124,11969,15115,11929,15102,11872,15086,11794,15064,11693,15041,11581,15013,11459,14987,11336,14966,11170,14944,10944,14921,10738,14898,10552,14875,10387,14850,10239,14824,9983,14794,9758,14762,9563,14728,9392,14692,9244,14653,9014,14611,8791,14569,8597,14526,8427,14481,8281,14436,8110,14391,7885,15188,11617,15188,11617,15187,11617,15186,11618,15183,11617,15179,11612,15173,11601,15163,11581,15150,11546,15133,11495,15110,11427,15083,11346,15051,11246,15024,11057,14996,10868,14967,10687,14938,10517,14911,10362,14882,10206,14853,9956,14821,9737,14787,9543,14752,9375,14715,9228,14675,8980,14632,8760,14589,8565,14544,8395,14498,8248,14451,8049,14404,7824,14357,7630,15228,11298,15228,11298,15227,11299,15226,11301,15223,11303,15219,11302,15213,11299,15204,11290,15191,11271,15174,11217,15150,11129,15119,11015,15087,10886,15057,10744,15024,10599,14990,10455,14957,10318,14924,10143,14891,9911,14856,9701,14820,9516,14782,9352,14744,9200,14703,8946,14659,8725,14615,8533,14568,8366,14521,8220,14472,7992,14423,7770,14374,7578,14315,7408,15260,10819,15260,10819,15259,10822,15258,10826,15256,10832,15251,10836,15246,10841,15237,10838,15225,10821,15207,10788,15183,10734,15151,10660,15120,10571,15087,10469,15049,10359,15012,10249,14974,10041,14937,9837,14900,9647,14860,9475,14820,9320,14779,9147,14736,8902,14691,8688,14646,8499,14598,8335,14549,8189,14499,7940,14448,7720,14397,7529,14347,7363,14256,7218,15285,10410,15285,10411,15285,10413,15284,10418,15282,10425,15278,10434,15272,10442,15264,10449,15252,10445,15235,10433,15210,10403,15179,10358,15149,10301,15113,10218,15073,10059,15033,9894,14991,9726,14951,9565,14909,9413,14865,9273,14822,9073,14777,8845,14730,8641,14682,8459,14633,8300,14583,8129,14531,7883,14479,7670,14426,7482,14373,7321,14305,7176,14201,6939,15305,9939,15305,9940,15305,9945,15304,9955,15302,9967,15298,9989,15293,10010,15286,10033,15274,10044,15258,10045,15233,10022,15205,9975,15174,9903,15136,9808,15095,9697,15053,9578,15009,9451,14965,9327,14918,9198,14871,8973,14825,8766,14775,8579,14725,8408,14675,8259,14622,8058,14569,7821,14515,7615,14460,7435,14405,7276,14350,7108,14256,6866,14149,6653,15321,9444,15321,9445,15321,9448,15320,9458,15317,9470,15314,9490,15310,9515,15302,9540,15292,9562,15276,9579,15251,9577,15226,9559,15195,9519,15156,9463,15116,9389,15071,9304,15025,9208,14978,9023,14927,8838,14878,8661,14827,8496,14774,8344,14722,8206,14667,7973,14612,7749,14556,7555,14499,7382,14443,7229,14385,7025,14322,6791,14210,6588,14100,6409,15333,8920,15333,8921,15332,8927,15332,8943,15329,8965,15326,9002,15322,9048,15316,9106,15307,9162,15291,9204,15267,9221,15244,9221,15212,9196,15175,9134,15133,9043,15088,8930,15040,8801,14990,8665,14938,8526,14886,8391,14830,8261,14775,8087,14719,7866,14661,7664,14603,7482,14544,7322,14485,7178,14426,6936,14367,6713,14281,6517,14166,6348,14054,6198,15341,8360,15341,8361,15341,8366,15341,8379,15339,8399,15336,8431,15332,8473,15326,8527,15318,8585,15302,8632,15281,8670,15258,8690,15227,8690,15191,8664,15149,8612,15104,8543,15055,8456,15001,8360,14948,8259,14892,8122,14834,7923,14776,7734,14716,7558,14656,7397,14595,7250,14534,7070,14472,6835,14410,6628,14350,6443,14243,6283,14125,6135,14010,5889,15348,7715,15348,7717,15348,7725,15347,7745,15345,7780,15343,7836,15339,7905,15334,8e3,15326,8103,15310,8193,15293,8239,15270,8270,15240,8287,15204,8283,15163,8260,15118,8223,15067,8143,15014,8014,14958,7873,14899,7723,14839,7573,14778,7430,14715,7293,14652,7164,14588,6931,14524,6720,14460,6531,14396,6362,14330,6210,14207,6015,14086,5781,13969,5576,15352,7114,15352,7116,15352,7128,15352,7159,15350,7195,15348,7237,15345,7299,15340,7374,15332,7457,15317,7544,15301,7633,15280,7703,15251,7754,15216,7775,15176,7767,15131,7733,15079,7670,15026,7588,14967,7492,14906,7387,14844,7278,14779,7171,14714,6965,14648,6770,14581,6587,14515,6420,14448,6269,14382,6123,14299,5881,14172,5665,14049,5477,13929,5310,15355,6329,15355,6330,15355,6339,15355,6362,15353,6410,15351,6472,15349,6572,15344,6688,15337,6835,15323,6985,15309,7142,15287,7220,15260,7277,15226,7310,15188,7326,15142,7318,15090,7285,15036,7239,14976,7177,14914,7045,14849,6892,14782,6736,14714,6581,14645,6433,14576,6293,14506,6164,14438,5946,14369,5733,14270,5540,14140,5369,14014,5216,13892,5043,15357,5483,15357,5484,15357,5496,15357,5528,15356,5597,15354,5692,15351,5835,15347,6011,15339,6195,15328,6317,15314,6446,15293,6566,15268,6668,15235,6746,15197,6796,15152,6811,15101,6790,15046,6748,14985,6673,14921,6583,14854,6479,14785,6371,14714,6259,14643,6149,14571,5946,14499,5750,14428,5567,14358,5401,14242,5250,14109,5111,13980,4870,13856,4657,15359,4555,15359,4557,15358,4573,15358,4633,15357,4715,15355,4841,15353,5061,15349,5216,15342,5391,15331,5577,15318,5770,15299,5967,15274,6150,15243,6223,15206,6280,15161,6310,15111,6317,15055,6300,14994,6262,14928,6208,14860,6141,14788,5994,14715,5838,14641,5684,14566,5529,14492,5384,14418,5247,14346,5121,14216,4892,14079,4682,13948,4496,13822,4330,15359,3498,15359,3501,15359,3520,15359,3598,15358,3719,15356,3860,15355,4137,15351,4305,15344,4563,15334,4809,15321,5116,15303,5273,15280,5418,15250,5547,15214,5653,15170,5722,15120,5761,15064,5763,15002,5733,14935,5673,14865,5597,14792,5504,14716,5400,14640,5294,14563,5185,14486,5041,14410,4841,14335,4655,14191,4482,14051,4325,13918,4183,13790,4012,15360,2282,15360,2285,15360,2306,15360,2401,15359,2547,15357,2748,15355,3103,15352,3349,15345,3675,15336,4020,15324,4272,15307,4496,15285,4716,15255,4908,15220,5086,15178,5170,15128,5214,15072,5234,15010,5231,14943,5206,14871,5166,14796,5102,14718,4971,14639,4833,14559,4687,14480,4541,14402,4401,14315,4268,14167,4142,14025,3958,13888,3747,13759,3556,15360,923,15360,925,15360,946,15360,1052,15359,1214,15357,1494,15356,1892,15352,2274,15346,2663,15338,3099,15326,3393,15309,3679,15288,3980,15260,4183,15226,4325,15185,4437,15136,4517,15080,4570,15018,4591,14950,4581,14877,4545,14800,4485,14720,4411,14638,4325,14556,4231,14475,4136,14395,3988,14297,3803,14145,3628,13999,3465,13861,3314,13729,3177,15360,263,15360,264,15360,272,15360,325,15359,407,15358,548,15356,780,15352,1144,15347,1580,15339,2099,15328,2425,15312,2795,15292,3133,15264,3329,15232,3517,15191,3689,15143,3819,15088,3923,15025,3978,14956,3999,14882,3979,14804,3931,14722,3855,14639,3756,14554,3645,14470,3529,14388,3409,14279,3289,14124,3173,13975,3055,13834,2848,13701,2658,15360,49,15360,49,15360,52,15360,75,15359,111,15358,201,15356,283,15353,519,15348,726,15340,1045,15329,1415,15314,1795,15295,2173,15269,2410,15237,2649,15197,2866,15150,3054,15095,3140,15032,3196,14963,3228,14888,3236,14808,3224,14725,3191,14639,3146,14553,3088,14466,2976,14382,2836,14262,2692,14103,2549,13952,2409,13808,2278,13674,2154,15360,4,15360,4,15360,4,15360,13,15359,33,15358,59,15357,112,15353,199,15348,302,15341,456,15331,628,15316,827,15297,1082,15272,1332,15241,1601,15202,1851,15156,2069,15101,2172,15039,2256,14970,2314,14894,2348,14813,2358,14728,2344,14640,2311,14551,2263,14463,2203,14376,2133,14247,2059,14084,1915,13930,1761,13784,1609,13648,1464,15360,0,15360,0,15360,0,15360,3,15359,18,15358,26,15357,53,15354,80,15348,97,15341,165,15332,238,15318,326,15299,427,15275,529,15245,654,15207,771,15161,885,15108,994,15046,1089,14976,1170,14900,1229,14817,1266,14731,1284,14641,1282,14550,1260,14460,1223,14370,1174,14232,1116,14066,1050,13909,981,13761,910,13623,839]);let bc=null;const nm=fe(({roughness:i,dotNV:e})=>{bc===null&&(bc=new d.IEO(pR,32,32,d.av9,d.cLu),bc.minFilter=d.wem,bc.magFilter=d.wem,bc.wrapS=d.uWy,bc.wrapT=d.uWy,bc.generateMipmaps=!1,bc.needsUpdate=!0);const t=Ve(i,e);return In(bc,t).rg}),mR=fe(({lightDirection:i,f0:e,f90:t,roughness:r,f:s,USE_IRIDESCENCE:a,USE_ANISOTROPY:c})=>{const h=dv({lightDirection:i,f0:e,f90:t,roughness:r,f:s,USE_IRIDESCENCE:a,USE_ANISOTROPY:c}),f=ri.dot(i).clamp(),m=ri.dot(Ai).clamp(),x=nm({roughness:r,dotNV:m}),_=nm({roughness:r,dotNV:f}),v=e.mul(x.x).add(t.mul(x.y)),T=e.mul(_.x).add(t.mul(_.y)),w=x.x.add(x.y),P=_.x.add(_.y),C=G(1).sub(w),E=G(1).sub(P),D=e.add(e.oneMinus().mul(.047619)),F=v.mul(T).mul(D).div(G(1).sub(C.mul(E).mul(D).mul(D)).add(G0)),W=C.mul(E),K=F.mul(W);return h.add(K)}),nM=fe(i=>{const{dotNV:e,specularColor:t,specularF90:r,roughness:s}=i,a=nm({dotNV:e,roughness:s});return t.mul(a.x).add(r.mul(a.y))}),iM=fe(({f:i,f90:e,dotVH:t})=>{const r=t.oneMinus().saturate(),s=r.mul(r),a=r.mul(s,s).clamp(0,.9999);return i.sub(ce(e).mul(a)).div(a.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),gR=fe(({roughness:i,dotNH:e})=>{const t=i.pow2(),r=G(1).div(t),a=e.pow2().oneMinus().max(.0078125);return G(2).add(r).mul(a.pow(r.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),xR=fe(({dotNV:i,dotNL:e})=>G(1).div(G(4).mul(e.add(i).sub(e.mul(i))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),_R=fe(({lightDirection:i})=>{const e=i.add(Ai).normalize(),t=ri.dot(i).clamp(),r=ri.dot(Ai).clamp(),s=ri.dot(e).clamp(),a=gR({roughness:fu,dotNH:s}),c=xR({dotNV:r,dotNL:t});return da.mul(a).mul(c)}),yR=fe(({N:i,V:e,roughness:t})=>{const a=.0078125,c=i.dot(e).saturate(),h=Ve(t,c.oneMinus().sqrt());return h.assign(h.mul(.984375).add(a)),h}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),rM=fe(({f:i})=>{const e=i.length();return Mi(e.mul(e).add(i.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),xl=fe(({v1:i,v2:e})=>{const t=i.dot(e),r=t.abs().toVar(),s=r.mul(.0145206).add(.4965155).mul(r).add(.8543985).toVar(),a=r.add(4.1616724).mul(r).add(3.417594).toVar(),c=s.div(a),h=t.greaterThan(0).select(c,Mi(t.mul(t).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(c));return i.cross(e).mul(h)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),sM=fe(({N:i,V:e,P:t,mInv:r,p0:s,p1:a,p2:c,p3:h})=>{const f=a.sub(s).toVar(),m=h.sub(s).toVar(),x=f.cross(m),_=ce().toVar();return Dt(x.dot(t.sub(s)).greaterThanEqual(0),()=>{const v=e.sub(i.mul(e.dot(i))).normalize(),T=i.cross(v).negate(),w=r.mul(Ni(v,T,i).transpose()).toVar(),P=w.mul(s.sub(t)).normalize().toVar(),C=w.mul(a.sub(t)).normalize().toVar(),E=w.mul(c.sub(t)).normalize().toVar(),D=w.mul(h.sub(t)).normalize().toVar(),F=ce(0).toVar();F.addAssign(xl({v1:P,v2:C})),F.addAssign(xl({v1:C,v2:E})),F.addAssign(xl({v1:E,v2:D})),F.addAssign(xl({v1:D,v2:P})),_.assign(ce(rM({f:F})))}),_}).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"}]}),bR=fe(({P:i,p0:e,p1:t,p2:r,p3:s})=>{const a=t.sub(e).toVar(),c=s.sub(e).toVar(),h=a.cross(c),f=ce().toVar();return Dt(h.dot(i.sub(e)).greaterThanEqual(0),()=>{const m=e.sub(i).normalize().toVar(),x=t.sub(i).normalize().toVar(),_=r.sub(i).normalize().toVar(),v=s.sub(i).normalize().toVar(),T=ce(0).toVar();T.addAssign(xl({v1:m,v2:x})),T.addAssign(xl({v1:x,v2:_})),T.addAssign(xl({v1:_,v2:v})),T.addAssign(xl({v1:v,v2:m})),f.assign(ce(rM({f:T.abs()})))}),f}).setLayout({name:"LTC_Evaluate",type:"vec3",inputs:[{name:"P",type:"vec3"},{name:"p0",type:"vec3"},{name:"p1",type:"vec3"},{name:"p2",type:"vec3"},{name:"p3",type:"vec3"}]}),xx=1/6,oM=i=>cn(xx,cn(i,cn(i,i.negate().add(3)).sub(3)).add(1)),fv=i=>cn(xx,cn(i,cn(i,cn(3,i).sub(6))).add(4)),aM=i=>cn(xx,cn(i,cn(i,cn(-3,i).add(3)).add(3)).add(1)),pv=i=>cn(xx,kr(i,3)),cM=i=>oM(i).add(fv(i)),lM=i=>aM(i).add(pv(i)),uM=i=>Yi(-1,fv(i).div(oM(i).add(fv(i)))),hM=i=>Yi(1,pv(i).div(aM(i).add(pv(i)))),dM=(i,e,t)=>{const r=i.uvNode,s=cn(r,e.zw).add(.5),a=Or(s),c=Hs(s),h=cM(c.x),f=lM(c.x),m=uM(c.x),x=hM(c.x),_=uM(c.y),v=hM(c.y),T=Ve(a.x.add(m),a.y.add(_)).sub(.5).mul(e.xy),w=Ve(a.x.add(x),a.y.add(_)).sub(.5).mul(e.xy),P=Ve(a.x.add(m),a.y.add(v)).sub(.5).mul(e.xy),C=Ve(a.x.add(x),a.y.add(v)).sub(.5).mul(e.xy),E=cM(c.y).mul(Yi(h.mul(i.sample(T).level(t)),f.mul(i.sample(w).level(t)))),D=lM(c.y).mul(Yi(h.mul(i.sample(P).level(t)),f.mul(i.sample(C).level(t))));return E.add(D)},mv=fe(([i,e])=>{const t=Ve(i.size(re(e))),r=Ve(i.size(re(e.add(1)))),s=cs(1,t),a=cs(1,r),c=dM(i,At(s,t),Or(e)),h=dM(i,At(a,r),Ho(e));return Hs(e).mix(c,h)}),vR=fe(([i,e])=>{const t=e.mul(Lb(i));return mv(i,t)}),fM=fe(([i,e,t,r,s])=>{const a=ce(Wp(e.negate(),Er(i),cs(1,r))),c=ce($s(s[0].xyz),$s(s[1].xyz),$s(s[2].xyz));return Er(a).mul(t.mul(c))}).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"}]}),SR=fe(([i,e])=>i.mul(ys(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),TR=iv(),MR=iv(),pM=fe(([i,e,t],{material:r})=>{const a=(r.side===d._Li?TR:MR).sample(i),c=Wo(Nu.x).mul(SR(e,t));return mv(a,c)}),mM=fe(([i,e,t])=>(Dt(t.notEqual(0),()=>{const r=Su(e).negate().div(t);return X0(r.negate().mul(i))}),ce(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),wR=fe(([i,e,t,r,s,a,c,h,f,m,x,_,v,T,w])=>{let P,C;if(w){P=At().toVar(),C=ce().toVar();const K=x.sub(1).mul(w.mul(.025)),U=ce(x.sub(K),x,x.add(K));ci({start:0,end:3},({i:j})=>{const oe=U.element(j),k=fM(i,e,_,oe,h),O=c.add(k),le=m.mul(f.mul(At(O,1))),be=Ve(le.xy.div(le.w)).toVar();be.addAssign(1),be.divAssign(2),be.assign(Ve(be.x,be.y.oneMinus()));const Ee=pM(be,t,oe);P.element(j).assign(Ee.element(j)),P.a.addAssign(Ee.a),C.element(j).assign(r.element(j).mul(mM($s(k),v,T).element(j)))}),P.a.divAssign(3)}else{const K=fM(i,e,_,x,h),U=c.add(K),j=m.mul(f.mul(At(U,1))),oe=Ve(j.xy.div(j.w)).toVar();oe.addAssign(1),oe.divAssign(2),oe.assign(Ve(oe.x,oe.y.oneMinus())),P=pM(oe,t,x),C=r.mul(mM($s(K),v,T))}const E=C.rgb.mul(P.rgb),D=i.dot(e).clamp(),F=ce(nM({dotNV:D,specularColor:s,specularF90:a,roughness:t})),W=C.r.add(C.g,C.b).div(3);return At(F.oneMinus().mul(E),P.a.oneMinus().mul(W).oneMinus())}),AR=Ni(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),ER=i=>{const e=i.sqrt();return ce(1).add(e).div(ce(1).sub(e))},gM=(i,e)=>i.sub(e).div(i.add(e)).pow2(),CR=(i,e)=>{const t=i.mul(2*Math.PI*1e-9),r=ce(54856e-17,44201e-17,52481e-17),s=ce(1681e3,1795300,2208400),a=ce(43278e5,93046e5,66121e5),c=G(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(t.mul(2239900).add(e.x).cos()).mul(t.pow2().mul(-45282e5).exp());let h=r.mul(a.mul(2*Math.PI).sqrt()).mul(s.mul(t).add(e).cos()).mul(t.pow2().negate().mul(a).exp());return h=ce(h.x.add(c),h.y,h.z).div(10685e-11),AR.mul(h)},RR=fe(({outsideIOR:i,eta2:e,cosTheta1:t,thinFilmThickness:r,baseF0:s})=>{const a=Xn(i,e,bs(0,.03,r)),h=i.div(a).pow2().mul(t.pow2().oneMinus()).oneMinus();Dt(h.lessThan(0),()=>ce(1));const f=h.sqrt(),m=gM(a,i),x=Pd({f0:m,f90:1,dotVH:t}),_=x.oneMinus(),v=a.lessThan(i).select(Math.PI,0),T=G(Math.PI).sub(v),w=ER(s.clamp(0,.9999)),P=gM(w,a.toVec3()),C=Pd({f0:P,f90:1,dotVH:f}),E=ce(w.x.lessThan(a).select(Math.PI,0),w.y.lessThan(a).select(Math.PI,0),w.z.lessThan(a).select(Math.PI,0)),D=a.mul(r,f,2),F=ce(T).add(E),W=x.mul(C).clamp(1e-5,.9999),K=W.sqrt(),U=_.pow2().mul(C).div(ce(1).sub(W)),oe=x.add(U).toVar(),k=U.sub(_).toVar();return ci({start:1,end:2,condition:"<=",name:"m"},({m:O})=>{k.mulAssign(K);const le=CR(G(O).mul(D),G(O).mul(F)).mul(2);oe.addAssign(k.mul(le))}),oe.max(ce(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"}]}),NR=fe(({normal:i,viewDir:e,roughness:t})=>{const r=i.dot(e).saturate(),s=t.pow2(),a=S(t.lessThan(.25),G(-339.2).mul(s).add(G(161.4).mul(t)).sub(25.9),G(-8.48).mul(s).add(G(14.3).mul(t)).sub(9.95)),c=S(t.lessThan(.25),G(44).mul(s).sub(G(23.7).mul(t)).add(3.26),G(1.97).mul(s).sub(G(3.27).mul(t)).add(.72));return S(t.lessThan(.25),0,G(.1).mul(t).sub(.025)).add(a.mul(r).add(c).exp()).mul(1/Math.PI).saturate()}),gv=ce(.04),xv=G(1);class xM extends gx{constructor(e=!1,t=!1,r=!1,s=!1,a=!1,c=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=r,this.anisotropy=s,this.transmission=a,this.dispersion=c,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=ce().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=ce().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=ce().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=ce().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=ce().toVar("sheenSpecularIndirect")),this.iridescence===!0){const t=ri.dot(Ai).clamp();this.iridescenceFresnel=RR({outsideIOR:G(1),eta2:pu,cosTheta1:t,thinFilmThickness:Dp,baseF0:as}),this.iridescenceF0=iM({f:this.iridescenceFresnel,f90:1,dotVH:t})}if(this.transmission===!0){const t=Ks,r=Qp.sub(Ks).normalize(),s=ml,a=e.context;a.backdrop=wR(s,r,zs,jn,as,hl,t,go,qs,po,xu,Fp,hd,ud,this.dispersion?_u:null),a.backdropAlpha=Up,jn.a.mulAssign(Xn(1,a.backdrop.a,Up))}super.start(e)}computeMultiscattering(e,t,r){const s=ri.dot(Ai).clamp(),a=nm({roughness:zs,dotNV:s}),c=this.iridescenceF0?fa.mix(as,this.iridescenceF0):as,h=c.mul(a.x).add(r.mul(a.y)),m=a.x.add(a.y).oneMinus(),x=c.add(c.oneMinus().mul(.047619)),_=h.mul(x).div(m.mul(x).oneMinus());e.addAssign(h),t.addAssign(_.mul(m))}direct({lightDirection:e,lightColor:t,reflectedLight:r}){const a=ri.dot(e).clamp().mul(t);if(this.sheen===!0&&this.sheenSpecularDirect.addAssign(a.mul(_R({lightDirection:e}))),this.clearcoat===!0){const h=Pu.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(h.mul(dv({lightDirection:e,f0:gv,f90:xv,roughness:du,normalView:Pu})))}r.directDiffuse.addAssign(a.mul(Du({diffuseColor:jn.rgb}))),r.directSpecular.addAssign(a.mul(mR({lightDirection:e,f0:as,f90:1,roughness:zs,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s,reflectedLight:a,ltc_1:c,ltc_2:h}){const f=t.add(r).sub(s),m=t.sub(r).sub(s),x=t.sub(r).add(s),_=t.add(r).add(s),v=ri,T=Ai,w=tr.toVar(),P=yR({N:v,V:T,roughness:zs}),C=c.sample(P).toVar(),E=h.sample(P).toVar(),D=Ni(ce(C.x,0,C.y),ce(0,1,0),ce(C.z,0,C.w)).toVar(),F=as.mul(E.x).add(as.oneMinus().mul(E.y)).toVar();a.directSpecular.addAssign(e.mul(F).mul(sM({N:v,V:T,P:w,mInv:D,p0:f,p1:m,p2:x,p3:_}))),a.directDiffuse.addAssign(e.mul(jn).mul(sM({N:v,V:T,P:w,mInv:Ni(1,0,0,0,1,0,0,0,1),p0:f,p1:m,p2:x,p3:_})))}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){const{irradiance:t,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(t.mul(Du({diffuseColor:jn})))}indirectSpecular(e){const{radiance:t,iblIrradiance:r,reflectedLight:s}=e.context;if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(r.mul(da,NR({normal:ri,viewDir:Ai,roughness:fu}))),this.clearcoat===!0){const x=Pu.dot(Ai).clamp(),_=nM({dotNV:x,specularColor:gv,specularF90:xv,roughness:du});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(_))}const a=ce().toVar("singleScattering"),c=ce().toVar("multiScattering"),h=r.mul(1/Math.PI);this.computeMultiscattering(a,c,hl);const f=a.add(c),m=jn.mul(f.r.max(f.g).max(f.b).oneMinus());s.indirectSpecular.addAssign(t.mul(a)),s.indirectSpecular.addAssign(c.mul(h)),s.indirectDiffuse.addAssign(m.mul(h))}ambientOcclusion(e){const{ambientOcclusion:t,reflectedLight:r}=e.context,a=ri.dot(Ai).clamp().add(t),c=zs.mul(-16).oneMinus().negate().exp2(),h=t.sub(a.pow(c).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(t),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(t),r.indirectDiffuse.mulAssign(t),r.indirectSpecular.mulAssign(h)}finish({context:e}){const{outgoingLight:t}=e;if(this.clearcoat===!0){const r=Pu.dot(Ai).clamp(),s=Pd({dotVH:r,f0:gv,f90:xv}),a=t.mul(ul.mul(s).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(ul));t.assign(a)}if(this.sheen===!0){const r=da.r.max(da.g).max(da.b).mul(.157).oneMinus(),s=t.mul(r).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(s)}}}const _M=G(1),_v=G(-2),_x=G(.8),yv=G(-1),yx=G(.4),bv=G(2),bx=G(.305),vv=G(3),yM=G(.21),PR=G(4),bM=G(4),LR=G(16),IR=fe(([i])=>{const e=ce(ai(i)).toVar(),t=G(-1).toVar();return Dt(e.x.greaterThan(e.z),()=>{Dt(e.x.greaterThan(e.y),()=>{t.assign(S(i.x.greaterThan(0),0,3))}).Else(()=>{t.assign(S(i.y.greaterThan(0),1,4))})}).Else(()=>{Dt(e.z.greaterThan(e.y),()=>{t.assign(S(i.z.greaterThan(0),2,5))}).Else(()=>{t.assign(S(i.y.greaterThan(0),1,4))})}),t}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),DR=fe(([i,e])=>{const t=Ve().toVar();return Dt(e.equal(0),()=>{t.assign(Ve(i.z,i.y).div(ai(i.x)))}).ElseIf(e.equal(1),()=>{t.assign(Ve(i.x.negate(),i.z.negate()).div(ai(i.y)))}).ElseIf(e.equal(2),()=>{t.assign(Ve(i.x.negate(),i.y).div(ai(i.z)))}).ElseIf(e.equal(3),()=>{t.assign(Ve(i.z.negate(),i.y).div(ai(i.x)))}).ElseIf(e.equal(4),()=>{t.assign(Ve(i.x.negate(),i.z).div(ai(i.y)))}).Else(()=>{t.assign(Ve(i.x,i.y).div(ai(i.z)))}),cn(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),UR=fe(([i])=>{const e=G(0).toVar();return Dt(i.greaterThanEqual(_x),()=>{e.assign(_M.sub(i).mul(yv.sub(_v)).div(_M.sub(_x)).add(_v))}).ElseIf(i.greaterThanEqual(yx),()=>{e.assign(_x.sub(i).mul(bv.sub(yv)).div(_x.sub(yx)).add(yv))}).ElseIf(i.greaterThanEqual(bx),()=>{e.assign(yx.sub(i).mul(vv.sub(bv)).div(yx.sub(bx)).add(bv))}).ElseIf(i.greaterThanEqual(yM),()=>{e.assign(bx.sub(i).mul(PR.sub(vv)).div(bx.sub(yM)).add(vv))}).Else(()=>{e.assign(G(-2).mul(Wo(cn(1.16,i))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),vM=fe(([i,e])=>{const t=i.toVar();t.assign(cn(2,t).sub(1));const r=ce(t,1).toVar();return Dt(e.equal(0),()=>{r.assign(r.zyx)}).ElseIf(e.equal(1),()=>{r.assign(r.xzy),r.xz.mulAssign(-1)}).ElseIf(e.equal(2),()=>{r.x.mulAssign(-1)}).ElseIf(e.equal(3),()=>{r.assign(r.zyx),r.xz.mulAssign(-1)}).ElseIf(e.equal(4),()=>{r.assign(r.xzy),r.xy.mulAssign(-1)}).ElseIf(e.equal(5),()=>{r.z.mulAssign(-1)}),r}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),SM=fe(([i,e,t,r,s,a])=>{const c=G(t),h=ce(e),f=ys(UR(c),_v,a),m=Hs(f),x=Or(f),_=ce(im(i,h,x,r,s,a)).toVar();return Dt(m.notEqual(0),()=>{const v=ce(im(i,h,x.add(1),r,s,a)).toVar();_.assign(Xn(_,v,m))}),_}),im=fe(([i,e,t,r,s,a])=>{const c=G(t).toVar(),h=ce(e),f=G(IR(h)).toVar(),m=G(Mi(bM.sub(c),0)).toVar();c.assign(Mi(c,bM));const x=G(ga(c)).toVar(),_=Ve(DR(h,f).mul(x.sub(2)).add(1)).toVar();return Dt(f.greaterThan(2),()=>{_.y.addAssign(x),f.subAssign(3)}),_.x.addAssign(f.mul(x)),_.x.addAssign(m.mul(cn(3,LR))),_.y.addAssign(cn(4,ga(a).sub(x))),_.x.mulAssign(r),_.y.mulAssign(s),i.sample(_).grad(Ve(),Ve())}),Sv=fe(({envMap:i,mipInt:e,outputDirection:t,theta:r,axis:s,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:c,CUBEUV_MAX_MIP:h})=>{const f=$o(r),m=t.mul(f).add(s.cross(t).mul(jr(r))).add(s.mul(s.dot(t).mul(f.oneMinus())));return im(i,m,e,a,c,h)}),TM=fe(({n:i,latitudinal:e,poleAxis:t,outputDirection:r,weights:s,samples:a,dTheta:c,mipInt:h,envMap:f,CUBEUV_TEXEL_WIDTH:m,CUBEUV_TEXEL_HEIGHT:x,CUBEUV_MAX_MIP:_})=>{const v=ce(S(e,t,xa(t,r))).toVar();Dt(v.equal(ce(0)),()=>{v.assign(ce(r.z,0,r.x.negate()))}),v.assign(Er(v));const T=ce().toVar();return T.addAssign(s.element(0).mul(Sv({theta:0,axis:v,outputDirection:r,mipInt:h,envMap:f,CUBEUV_TEXEL_WIDTH:m,CUBEUV_TEXEL_HEIGHT:x,CUBEUV_MAX_MIP:_}))),ci({start:re(1),end:i},({i:w})=>{Dt(w.greaterThanEqual(a),()=>{L1()});const P=G(c.mul(G(w))).toVar();T.addAssign(s.element(w).mul(Sv({theta:P.mul(-1),axis:v,outputDirection:r,mipInt:h,envMap:f,CUBEUV_TEXEL_WIDTH:m,CUBEUV_TEXEL_HEIGHT:x,CUBEUV_MAX_MIP:_}))),T.addAssign(s.element(w).mul(Sv({theta:P,axis:v,outputDirection:r,mipInt:h,envMap:f,CUBEUV_TEXEL_WIDTH:m,CUBEUV_TEXEL_HEIGHT:x,CUBEUV_MAX_MIP:_})))}),At(T,1)}),FR=fe(([i])=>{const e=Je(i).toVar();return e.assign(e.shiftLeft(Je(16)).bitOr(e.shiftRight(Je(16)))),e.assign(e.bitAnd(Je(1431655765)).shiftLeft(Je(1)).bitOr(e.bitAnd(Je(2863311530)).shiftRight(Je(1)))),e.assign(e.bitAnd(Je(858993459)).shiftLeft(Je(2)).bitOr(e.bitAnd(Je(3435973836)).shiftRight(Je(2)))),e.assign(e.bitAnd(Je(252645135)).shiftLeft(Je(4)).bitOr(e.bitAnd(Je(4042322160)).shiftRight(Je(4)))),e.assign(e.bitAnd(Je(16711935)).shiftLeft(Je(8)).bitOr(e.bitAnd(Je(4278255360)).shiftRight(Je(8)))),G(e).mul(23283064365386963e-26)}),BR=fe(([i,e])=>Ve(G(i).div(G(e)),FR(i))),OR=fe(([i,e,t])=>{const r=ce(e).toVar(),s=G(t),a=s.mul(s).toVar(),c=Er(ce(a.mul(r.x),a.mul(r.y),r.z)).toVar(),h=c.x.mul(c.x).add(c.y.mul(c.y)),f=S(h.greaterThan(0),ce(c.y.negate(),c.x,0).div(Br(h)),ce(1,0,0)).toVar(),m=xa(c,f).toVar(),x=Br(i.x),_=cn(2,3.14159265359).mul(i.y),v=x.mul($o(_)).toVar(),T=x.mul(jr(_)).toVar(),w=cn(.5,c.z.add(1));T.assign(w.oneMinus().mul(Br(v.mul(v).oneMinus())).add(w.mul(T)));const P=f.mul(v).add(m.mul(T)).add(c.mul(Br(Mi(0,v.mul(v).add(T.mul(T)).oneMinus()))));return Er(ce(a.mul(P.x),a.mul(P.y),Mi(0,P.z)))}),MM=fe(({roughness:i,mipInt:e,envMap:t,N_immutable:r,GGX_SAMPLES:s,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:c,CUBEUV_MAX_MIP:h})=>{const f=ce(r).toVar(),m=ce(0).toVar(),x=G(0).toVar();return Dt(i.lessThan(.001),()=>{m.assign(im(t,f,e,a,c,h))}).Else(()=>{const _=S(ai(f.z).lessThan(.999),ce(0,0,1),ce(1,0,0)),v=Er(xa(_,f)).toVar(),T=xa(f,v).toVar();ci({start:Je(0),end:s},({i:w})=>{const P=BR(w,s),C=OR(P,ce(0,0,1),i),E=Er(v.mul(C.x).add(T.mul(C.y)).add(f.mul(C.z))),D=Er(E.mul(ho(f,E).mul(2)).sub(f)),F=Mi(ho(f,D),0);Dt(F.greaterThan(0),()=>{const W=im(t,D,e,a,c,h);m.addAssign(W.mul(F)),x.addAssign(F)})}),Dt(x.greaterThan(0),()=>{m.assign(m.div(x))})}),At(m,1)}),_l=4,wM=[.125,.215,.35,.446,.526,.582],Uu=20,kR=512,rm=new d.iKG(-1,1,1,-1,0,1),VR=new d.cPb(90,1),AM=new d.Ilk;let Tv=null,Mv=0,wv=0;const zR=new d.Pa4,vx=new WeakMap,GR=[3,1,5,0,4,2],Av=vM(hi(),hs("faceIndex")).normalize(),Sx=ce(Av.x,Av.y,Av.z);class WR{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._ggxMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,r=.1,s=100,a={}){const{size:c=256,position:h=zR,renderTarget:f=null}=a;if(this._setSize(c),this._hasInitialized===!1){(0,d.ZK6)('PMREMGenerator: ".fromScene()" called before the backend is initialized. Try using "await renderer.init()" instead.');const x=f||this._allocateTarget();return a.renderTarget=x,this.fromSceneAsync(e,t,r,s,a),x}Tv=this._renderer.getRenderTarget(),Mv=this._renderer.getActiveCubeFace(),wv=this._renderer.getActiveMipmapLevel();const m=f||this._allocateTarget();return m.depthBuffer=!0,this._init(m),this._sceneToCubeUV(e,r,s,m,h),t>0&&this._blur(m,0,0,t),this._applyPMREM(m),this._cleanup(m),m}fromSceneAsync(c){return nn(this,arguments,function*(e,t=0,r=.1,s=100,a={}){return(0,d.O4K)('PMREMGenerator: ".fromSceneAsync()" is deprecated. Use "await renderer.init()" instead.'),yield this._renderer.init(),this.fromScene(e,t,r,s,a)})}fromEquirectangular(e,t=null){if(this._hasInitialized===!1){(0,d.ZK6)('PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using "await renderer.init()" instead.'),this._setSizeFromTexture(e);const r=t||this._allocateTarget();return this.fromEquirectangularAsync(e,r),r}return this._fromTexture(e,t)}fromEquirectangularAsync(e,t=null){return nn(this,null,function*(){return(0,d.O4K)('PMREMGenerator: ".fromEquirectangularAsync()" is deprecated. Use "await renderer.init()" instead.'),yield this._renderer.init(),this._fromTexture(e,t)})}fromCubemap(e,t=null){if(this._hasInitialized===!1){(0,d.ZK6)("PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);const r=t||this._allocateTarget();return this.fromCubemapAsync(e,t),r}return this._fromTexture(e,t)}fromCubemapAsync(e,t=null){return nn(this,null,function*(){return(0,d.O4K)('PMREMGenerator: ".fromCubemapAsync()" is deprecated. Use "await renderer.init()" instead.'),yield this._renderer.init(),this._fromTexture(e,t)})}compileCubemapShader(){return nn(this,null,function*(){this._cubemapMaterial===null&&(this._cubemapMaterial=CM(),yield this._compileMaterial(this._cubemapMaterial))})}compileEquirectangularShader(){return nn(this,null,function*(){this._equirectMaterial===null&&(this._equirectMaterial=RM(),yield this._compileMaterial(this._equirectMaterial))})}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSizeFromTexture(e){e.mapping===d.fY$||e.mapping===d.vxC?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4)}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Tv,Mv,wv),e.scissorTest=!1,Ld(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),Tv=this._renderer.getRenderTarget(),Mv=this._renderer.getActiveCubeFace(),wv=this._renderer.getActiveMipmapLevel();const r=t||this._allocateTarget();return this._init(r),this._textureToCubeUV(e,r),this._applyPMREM(r),this._cleanup(r),r}_allocateTarget(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize;return EM(e,t)}_init(e){if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e.width||this._pingPongRenderTarget.height!==e.height){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=EM(e.width,e.height);const{_lodMax:t}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=HR(t)),this._blurMaterial=$R(t,e.width,e.height),this._ggxMaterial=jR(t,e.width,e.height)}}_compileMaterial(e){return nn(this,null,function*(){const t=new d.Kj0(new d.u9r,e);yield this._renderer.compile(t,rm)})}_sceneToCubeUV(e,t,r,s,a){const c=VR;c.near=t,c.far=r;const h=[1,1,1,1,-1,1],f=[1,-1,1,-1,1,-1],m=this._renderer,x=m.autoClear;m.getClearColor(AM),m.autoClear=!1,this._backgroundBox===null&&(this._backgroundBox=new d.Kj0(new d.DvJ,new d.vBJ({name:"PMREM.Background",side:d._Li,depthWrite:!1,depthTest:!1})));const _=this._backgroundBox,v=_.material;let T=!1;const w=e.background;w?w.isColor&&(v.color.copy(w),e.background=null,T=!0):(v.color.copy(AM),T=!0),m.setRenderTarget(s),m.clear(),T&&m.render(_,c);for(let P=0;P<6;P++){const C=P%3;C===0?(c.up.set(0,h[P],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x+f[P],a.y,a.z)):C===1?(c.up.set(0,0,h[P]),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y+f[P],a.z)):(c.up.set(0,h[P],0),c.position.set(a.x,a.y,a.z),c.lookAt(a.x,a.y,a.z+f[P]));const E=this._cubeSize;Ld(s,C*E,P>2?E:0,E,E),m.render(e,c)}m.autoClear=x,e.background=w}_textureToCubeUV(e,t){const r=this._renderer,s=e.mapping===d.fY$||e.mapping===d.vxC;s?this._cubemapMaterial===null&&(this._cubemapMaterial=CM(e)):this._equirectMaterial===null&&(this._equirectMaterial=RM(e));const a=s?this._cubemapMaterial:this._equirectMaterial;a.fragmentNode.value=e;const c=this._lodMeshes[0];c.material=a;const h=this._cubeSize;Ld(t,0,0,3*h,2*h),r.setRenderTarget(t),r.render(c,rm)}_applyPMREM(e){const t=this._renderer,r=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let a=1;a<s;a++)this._applyGGXFilter(e,a-1,a);t.autoClear=r}_applyGGXFilter(e,t,r){const s=this._renderer,a=this._pingPongRenderTarget,c=this._ggxMaterial,h=this._lodMeshes[r];h.material=c;const f=vx.get(c),m=r/(this._lodMeshes.length-1),x=t/(this._lodMeshes.length-1),_=Math.sqrt(m*m-x*x),v=.05+m*.95,T=_*v,{_lodMax:w}=this,P=this._sizeLods[r],C=3*P*(r>w-_l?r-w+_l:0),E=4*(this._cubeSize-P);e.texture.frame=(e.texture.frame||0)+1,f.envMap.value=e.texture,f.roughness.value=T,f.mipInt.value=w-t,Ld(a,C,E,3*P,2*P),s.setRenderTarget(a),s.render(h,rm),a.texture.frame=(a.texture.frame||0)+1,f.envMap.value=a.texture,f.roughness.value=0,f.mipInt.value=w-r,Ld(e,C,E,3*P,2*P),s.setRenderTarget(e),s.render(h,rm)}_blur(e,t,r,s,a){const c=this._pingPongRenderTarget;this._halfBlur(e,c,t,r,s,"latitudinal",a),this._halfBlur(c,e,r,r,s,"longitudinal",a)}_halfBlur(e,t,r,s,a,c,h){const f=this._renderer,m=this._blurMaterial;c!=="latitudinal"&&c!=="longitudinal"&&(0,d.vUy)("blur direction must be either latitudinal or longitudinal!");const x=3,_=this._lodMeshes[s];_.material=m;const v=vx.get(m),T=this._sizeLods[r]-1,w=isFinite(a)?Math.PI/(2*T):2*Math.PI/(2*Uu-1),P=a/w,C=isFinite(a)?1+Math.floor(x*P):Uu;C>Uu&&(0,d.ZK6)(`sigmaRadians, ${a}, is too large and will clip, as it requested ${C} samples when the maximum is set to ${Uu}`);const E=[];let D=0;for(let j=0;j<Uu;++j){const oe=j/P,k=Math.exp(-oe*oe/2);E.push(k),j===0?D+=k:j<C&&(D+=2*k)}for(let j=0;j<E.length;j++)E[j]=E[j]/D;e.texture.frame=(e.texture.frame||0)+1,v.envMap.value=e.texture,v.samples.value=C,v.weights.array=E,v.latitudinal.value=c==="latitudinal"?1:0,h&&(v.poleAxis.value=h);const{_lodMax:F}=this;v.dTheta.value=w,v.mipInt.value=F-r;const W=this._sizeLods[s],K=3*W*(s>F-_l?s-F+_l:0),U=4*(this._cubeSize-W);Ld(t,K,U,3*W,2*W),f.setRenderTarget(t),f.render(_,rm)}}function HR(i){const e=[],t=[],r=[];let s=i;const a=i-_l+1+wM.length;for(let c=0;c<a;c++){const h=Math.pow(2,s);e.push(h);let f=1/h;c>i-_l?f=wM[c-i+_l-1]:c===0&&(f=0),t.push(f);const m=1/(h-2),x=-m,_=1+m,v=[x,x,_,x,_,_,x,x,_,_,x,_],T=6,w=6,P=3,C=2,E=1,D=new Float32Array(P*w*T),F=new Float32Array(C*w*T),W=new Float32Array(E*w*T);for(let U=0;U<T;U++){const j=U%3*2/3-1,oe=U>2?0:-1,k=[j,oe,0,j+2/3,oe,0,j+2/3,oe+1,0,j,oe,0,j+2/3,oe+1,0,j,oe+1,0],O=GR[U];D.set(k,P*w*O),F.set(v,C*w*O);const le=[O,O,O,O,O,O];W.set(le,E*w*O)}const K=new d.u9r;K.setAttribute("position",new d.TlE(D,P)),K.setAttribute("uv",new d.TlE(F,C)),K.setAttribute("faceIndex",new d.TlE(W,E)),r.push(new d.Kj0(K,null)),s>_l&&s--}return{lodMeshes:r,sizeLods:e,sigmas:t}}function EM(i,e){const t={magFilter:d.wem,minFilter:d.wem,generateMipmaps:!1,type:d.cLu,format:d.wk1,colorSpace:d.GUF},r=new d.ACn(i,e,t);return r.texture.mapping=d.g8_,r.texture.name="PMREM.cubeUv",r.texture.isPMREMTexture=!0,r.scissorTest=!0,r}function Ld(i,e,t,r,s){i.viewport.set(e,t,r,s),i.scissor.set(e,t,r,s)}function Tx(i){const e=new Gi;return e.depthTest=!1,e.depthWrite=!1,e.blending=d.jFi,e.name=`PMREM_${i}`,e}function $R(i,e,t){const r=Xr(new Array(Uu).fill(0)),s=Bt(new d.Pa4(0,1,0)),a=Bt(0),c=G(Uu),h=Bt(0),f=Bt(1),m=In(),x=Bt(0),_=G(1/e),v=G(1/t),T=G(i),w={n:c,latitudinal:h,weights:r,poleAxis:s,outputDirection:Sx,dTheta:a,samples:f,envMap:m,mipInt:x,CUBEUV_TEXEL_WIDTH:_,CUBEUV_TEXEL_HEIGHT:v,CUBEUV_MAX_MIP:T},P=Tx("blur");return P.fragmentNode=TM(To(rr({},w),{latitudinal:h.equal(1)})),vx.set(P,w),P}function jR(i,e,t){const r=In(),s=Bt(0),a=Bt(0),c=G(1/e),h=G(1/t),f=G(i),m={envMap:r,roughness:s,mipInt:a,CUBEUV_TEXEL_WIDTH:c,CUBEUV_TEXEL_HEIGHT:h,CUBEUV_MAX_MIP:f},x=Tx("ggx");return x.fragmentNode=MM(To(rr({},m),{N_immutable:Sx,GGX_SAMPLES:Je(kR)})),vx.set(x,m),x}function CM(i){const e=Tx("cubemap");return e.fragmentNode=wd(i,Sx),e}function RM(i){const e=Tx("equirect");return e.fragmentNode=In(i,lv(Sx),0),e}const NM=new WeakMap;function XR(i){const e=Math.log2(i)-2,t=1/i;return{texelWidth:1/(3*Math.max(Math.pow(2,e),7*16)),texelHeight:t,maxMip:e}}function qR(i,e,t){const r=KR(e);let s=r.get(i);if((s!==void 0?s.pmremVersion:-1)!==i.pmremVersion){const c=i.image;if(i.isCubeTexture)if(YR(c))s=t.fromCubemap(i,s);else return null;else if(QR(c))s=t.fromEquirectangular(i,s);else return null;s.pmremVersion=i.pmremVersion,r.set(i,s)}return s.texture}function KR(i){let e=NM.get(i);return e===void 0&&(e=new WeakMap,NM.set(i,e)),e}class ZR extends Oi{static get type(){return"PMREMNode"}constructor(e,t=null,r=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=r,this._generator=null;const s=new d.xEZ;s.isRenderTargetTexture=!0,this._texture=In(s),this._width=Bt(0),this._height=Bt(0),this._maxMip=Bt(0),this.updateBeforeType=xn.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=XR(e.image.height);this._texture.value=e,this._width.value=t.texelWidth,this._height.value=t.texelHeight,this._maxMip.value=t.maxMip}updateBefore(e){let t=this._pmrem;const r=t?t.pmremVersion:-1,s=this._value;r!==s.pmremVersion&&(s.isPMREMTexture===!0?t=s:t=qR(s,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new WR(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this)),t=Gb.mul(ce(t.x,t.y.negate(),t.z));let r=this.levelNode;return r===null&&e.context.getTextureLevel&&(r=e.context.getTextureLevel(this)),SM(this._texture,t,r,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}}function YR(i){if(i==null)return!1;let e=0;const t=6;for(let r=0;r<t;r++)i[r]!==void 0&&e++;return e===t}function QR(i){return i==null?!1:i.height>0}const Ev=sn(ZR).setParameterLength(1,3),PM=new WeakMap;class JR extends Ed{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const _=r.isTextureNode?r.value:t[r.property];let v=PM.get(_);v===void 0&&(v=Ev(_),PM.set(_,v)),r=v}const a=t.useAnisotropy===!0||t.anisotropy>0?ZT:ri,c=r.context(LM(zs,a)).mul(rx),h=r.context(e2(ml)).mul(Math.PI).mul(rx),f=St(c),m=St(h);e.context.radiance.addAssign(f),e.context.iblIrradiance.addAssign(m);const x=e.context.lightingModel.clearcoatRadiance;if(x){const _=r.context(LM(du,Pu)).mul(rx),v=St(_);x.addAssign(v)}}}const LM=(i,e)=>{let t=null;return{getUV:()=>(t===null&&(t=Ai.negate().reflect(e),t=Z0(i).mix(t,e).normalize(),t=t.transformDirection(qs)),t),getTextureLevel:()=>i}},e2=i=>({getUV:()=>i,getTextureLevel:()=>G(1)}),t2=new d.Wid;class IM extends Gi{static get type(){return"MeshStandardNodeMaterial"}constructor(e){super(),this.isMeshStandardNodeMaterial=!0,this.lights=!0,this.emissiveNode=null,this.metalnessNode=null,this.roughnessNode=null,this.setDefaultValues(t2),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new JR(t):null}setupLightingModel(){return new xM}setupSpecular(){const e=Xn(ce(.04),jn.rgb,ll);as.assign(e),hl.assign(1)}setupVariants(){const e=this.metalnessNode?G(this.metalnessNode):r1;ll.assign(e);let t=this.roughnessNode?G(this.roughnessNode):i1;t=hv({roughness:t}),zs.assign(t),this.setupSpecular(),jn.assign(At(jn.rgb.mul(e.oneMinus()),jn.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const n2=new d.EJi;class i2 extends IM{static get type(){return"MeshPhysicalNodeMaterial"}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(n2),this.setValues(e)}get useClearcoat(){return this.clearcoat>0||this.clearcoatNode!==null}get useIridescence(){return this.iridescence>0||this.iridescenceNode!==null}get useSheen(){return this.sheen>0||this.sheenNode!==null}get useAnisotropy(){return this.anisotropy>0||this.anisotropyNode!==null}get useTransmission(){return this.transmission>0||this.transmissionNode!==null}get useDispersion(){return this.dispersion>0||this.dispersionNode!==null}setupSpecular(){const e=this.iorNode?G(this.iorNode):_1;xu.assign(e),as.assign(Xn(Kn(Au(xu.sub(1).div(xu.add(1))).mul(n1),ce(1)).mul(Kb),jn.rgb,ll)),hl.assign(Xn(Kb,1,ll))}setupLightingModel(){return new xM(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const t=this.clearcoatNode?G(this.clearcoatNode):o1,r=this.clearcoatRoughnessNode?G(this.clearcoatRoughnessNode):a1;ul.assign(t),du.assign(hv({roughness:r}))}if(this.useSheen){const t=this.sheenNode?ce(this.sheenNode):u1,r=this.sheenRoughnessNode?G(this.sheenRoughnessNode):h1;da.assign(t),fu.assign(r)}if(this.useIridescence){const t=this.iridescenceNode?G(this.iridescenceNode):f1,r=this.iridescenceIORNode?G(this.iridescenceIORNode):p1,s=this.iridescenceThicknessNode?G(this.iridescenceThicknessNode):m1;fa.assign(t),pu.assign(r),Dp.assign(s)}if(this.useAnisotropy){const t=(this.anisotropyNode?Ve(this.anisotropyNode):d1).toVar();lo.assign(t.length()),Dt(lo.equal(0),()=>{t.assign(Ve(1,0))}).Else(()=>{t.divAssign(Ve(lo)),lo.assign(lo.saturate())}),mu.assign(lo.pow2().mix(zs.pow2(),1)),gu.assign(Lu[0].mul(t.x).add(Lu[1].mul(t.y))),pa.assign(Lu[1].mul(t.x).sub(Lu[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?G(this.transmissionNode):g1,r=this.thicknessNode?G(this.thicknessNode):x1,s=this.attenuationDistanceNode?G(this.attenuationDistanceNode):y1,a=this.attenuationColorNode?ce(this.attenuationColorNode):b1;if(Up.assign(t),Fp.assign(r),ud.assign(s),hd.assign(a),this.useDispersion){const c=this.dispersionNode?G(this.dispersionNode):S1;_u.assign(c)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?ce(this.clearcoatNormalNode):c1}setup(e){e.context.setupClearcoatNormal=()=>Re(this.setupClearcoatNormal(e),"NORMAL","vec3"),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 r2 extends null{constructor(e=!1,t=!1,r=!1,s=!1,a=!1,c=!1,h=!1){super(e,t,r,s,a,c),this.useSSS=h}direct({lightDirection:e,lightColor:t,reflectedLight:r},s){if(this.useSSS===!0){const a=s.material,{thicknessColorNode:c,thicknessDistortionNode:h,thicknessAmbientNode:f,thicknessAttenuationNode:m,thicknessPowerNode:x,thicknessScaleNode:_}=a,v=e.add(ri.mul(h)).normalize(),T=G(Ai.dot(v.negate()).saturate().pow(x).mul(_)),w=ce(T.add(f).mul(c));r.directDiffuse.addAssign(w.mul(m.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:r},s)}}class c4 extends null{static get type(){return"MeshSSSNodeMaterial"}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=G(.1),this.thicknessAmbientNode=G(0),this.thicknessAttenuationNode=G(.1),this.thicknessPowerNode=G(2),this.thicknessScaleNode=G(10)}get useSSS(){return this.thicknessColorNode!==null}setupLightingModel(){return new r2(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion,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 s2=fe(({normal:i,lightDirection:e,builder:t})=>{const r=i.dot(e),s=Ve(r.mul(.5).add(.5),0);if(t.material.gradientMap){const a=yc("gradientMap","texture").context({getUV:()=>s});return ce(a.r)}else{const a=s.fwidth().mul(.5);return Xn(ce(.7),ce(1),bs(G(.7).sub(a.x),G(.7).add(a.x),s.x))}});class o2 extends gx{direct({lightDirection:e,lightColor:t,reflectedLight:r},s){const a=s2({normal:ix,lightDirection:e,builder:s}).mul(t);r.directDiffuse.addAssign(a.mul(Du({diffuseColor:jn.rgb})))}indirect(e){const{ambientOcclusion:t,irradiance:r,reflectedLight:s}=e.context;s.indirectDiffuse.addAssign(r.mul(Du({diffuseColor:jn}))),s.indirectDiffuse.mulAssign(t)}}const a2=new d.IKL;class c2 extends Gi{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(a2),this.setValues(e)}setupLightingModel(){return new o2}}const DM=fe(()=>{const i=ce(Ai.z,0,Ai.x.negate()).normalize(),e=Ai.cross(i);return Ve(i.dot(ri),e.dot(ri)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV"),l2=new d.kaV;class u2 extends Gi{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(l2),this.setValues(e)}setupVariants(e){const t=DM;let r;e.material.matcap?r=yc("matcap","texture").context({getUV:()=>t}):r=ce(Xn(.2,.8,t.y)),jn.rgb.mulAssign(r.rgb)}}class h2 extends Oi{static get type(){return"RotateNode"}constructor(e,t){super(),this.positionNode=e,this.rotationNode=t}getNodeType(e){return this.positionNode.getNodeType(e)}setup(e){const{rotationNode:t,positionNode:r}=this;if(this.getNodeType(e)==="vec2"){const a=t.cos(),c=t.sin();return cl(a,c,c.negate(),a).mul(r)}else{const a=t,c=sc(At(1,0,0,0),At(0,$o(a.x),jr(a.x).negate(),0),At(0,jr(a.x),$o(a.x),0),At(0,0,0,1)),h=sc(At($o(a.y),0,jr(a.y),0),At(0,1,0,0),At(jr(a.y).negate(),0,$o(a.y),0),At(0,0,0,1)),f=sc(At($o(a.z),jr(a.z).negate(),0,0),At(jr(a.z),$o(a.z),0,0),At(0,0,1,0),At(0,0,0,1));return c.mul(h).mul(f).mul(At(r,1)).xyz}}}const sm=sn(h2).setParameterLength(2),d2=new d.xeV;class UM extends Gi{static get type(){return"SpriteNodeMaterial"}constructor(e){super(),this.isSpriteNodeMaterial=!0,this._useSizeAttenuation=!0,this.positionNode=null,this.rotationNode=null,this.scaleNode=null,this.transparent=!0,this.setDefaultValues(d2),this.setValues(e)}setupPositionView(e){const{object:t,camera:r}=e,{positionNode:s,rotationNode:a,scaleNode:c,sizeAttenuation:h}=this,f=_c.mul(ce(s||0));let m=Ve(go[0].xyz.length(),go[1].xyz.length());c!==null&&(m=m.mul(Ve(c))),r.isPerspectiveCamera&&h===!1&&(m=m.mul(f.z.negate()));let x=zr.xy;if(t.center&&t.center.isVector2===!0){const T=zi("center","vec2",t);x=x.sub(T.sub(.5))}x=x.mul(m);const _=G(a||l1),v=sm(x,_);return At(f.xy.add(v),f.zw)}copy(e){return this.positionNode=e.positionNode,this.rotationNode=e.rotationNode,this.scaleNode=e.scaleNode,super.copy(e)}get sizeAttenuation(){return this._useSizeAttenuation}set sizeAttenuation(e){this._useSizeAttenuation!==e&&(this._useSizeAttenuation=e,this.needsUpdate=!0)}}const f2=new d.UY4,p2=new d.FM8;class m2 extends UM{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(f2),this.setValues(e)}setupPositionView(){const{positionNode:e}=this;return _c.mul(ce(e||er)).xyz}setupVertexSprite(e){const{material:t,camera:r}=e,{rotationNode:s,scaleNode:a,sizeNode:c,sizeAttenuation:h}=this;let f=super.setupVertex(e);if(t.isNodeMaterial!==!0)return f;let m=c!==null?Ve(c):v1;m=m.mul(vT),r.isPerspectiveCamera&&h===!0&&(m=m.mul(g2.div(tr.z.negate()))),a&&a.isNode&&(m=m.mul(Ve(a)));let x=zr.xy;if(s&&s.isNode){const _=G(s);x=sm(x,_)}return x=x.mul(m),x=x.div(Ub.div(2)),x=x.mul(f.w),f=f.add(At(x,0,0)),f}setupVertex(e){return e.object.isPoints?super.setupVertex(e):this.setupVertexSprite(e)}get alphaToCoverage(){return this._useAlphaToCoverage}set alphaToCoverage(e){this._useAlphaToCoverage!==e&&(this._useAlphaToCoverage=e,this.needsUpdate=!0)}}const g2=Bt(1).onFrameUpdate(function({renderer:i}){const e=i.getSize(p2);this.value=.5*e.y});class x2 extends gx{constructor(){super(),this.shadowNode=G(1).toVar("shadowMask")}direct({lightNode:e}){e.shadowNode!==null&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){jn.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(jn.rgb)}}const _2=new d.Tn7;class y2 extends Gi{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(_2),this.setValues(e)}setupLightingModel(){return new x2}}const om=Vs("vec3"),FM=Vs("vec3"),BM=Vs("vec3");class b2 extends null{constructor(){super()}start(e){const{material:t}=e,r=Vs("vec3"),s=Vs("vec3");Dt(Qp.sub(Ks).length().greaterThan(wT.mul(2)),()=>{r.assign(Qp),s.assign(Ks)}).Else(()=>{r.assign(Ks),s.assign(Qp)});const a=s.sub(r),c=Bt("int").onRenderUpdate(({material:_})=>_.steps),h=a.length().div(c).toVar(),f=a.normalize().toVar(),m=G(0).toVar(),x=ce(1).toVar();t.offsetNode&&m.addAssign(t.offsetNode.mul(h)),ci(c,()=>{const _=r.add(f.mul(m)),v=qs.mul(At(_,1)).xyz;t.depthNode!==null&&(FM.assign(Nd(sv(v.z,gc,xc))),e.context.sceneDepthNode=Nd(t.depthNode).toVar()),e.context.positionWorld=_,e.context.shadowPositionWorld=_,e.context.positionView=v,om.assign(0);let T;t.scatteringNode&&(T=t.scatteringNode({positionRay:_})),super.start(e),T&&om.mulAssign(T);const w=om.mul(.01).negate().mul(h).exp();x.mulAssign(w),m.addAssign(h)}),BM.addAssign(x.saturate().oneMinus())}scatteringLight(e,t){const r=t.context.sceneDepthNode;r?Dt(r.greaterThanEqual(FM),()=>{om.addAssign(e)}):om.addAssign(e)}direct({lightNode:e,lightColor:t},r){if(e.light.distance===void 0)return;const s=t.xyz.toVar();s.mulAssign(e.shadowNode),this.scatteringLight(s,r)}directRectArea({lightColor:e,lightPosition:t,halfWidth:r,halfHeight:s},a){const c=t.add(r).sub(s),h=t.sub(r).sub(s),f=t.sub(r).add(s),m=t.add(r).add(s),x=a.context.positionView,_=e.xyz.mul(bR({P:x,p0:c,p1:h,p2:f,p3:m})).pow(1.5);this.scatteringLight(_,a)}finish(e){e.context.outgoingLight.assign(BM)}}class l4 extends null{static get type(){return"VolumeNodeMaterial"}constructor(e){super(),this.isVolumeNodeMaterial=!0,this.steps=25,this.offsetNode=null,this.scatteringNode=null,this.lights=!0,this.transparent=!0,this.side=BackSide,this.depthTest=!1,this.depthWrite=!1,this.setValues(e)}setupLightingModel(){return new b2}}class v2{constructor(e,t,r){this.renderer=e,this.nodes=t,this.info=r,this._context=typeof self!="undefined"?self:null,this._animationLoop=null,this._requestId=null}start(){const e=(t,r)=>{this._requestId=this._context.requestAnimationFrame(e),this.info.autoReset===!0&&this.info.reset(),this.nodes.nodeFrame.update(),this.info.frame=this.nodes.nodeFrame.frameId,this.renderer._inspector.begin(),this._animationLoop!==null&&this._animationLoop(t,r),this.renderer._inspector.finish()};e()}stop(){this._context.cancelAnimationFrame(this._requestId),this._requestId=null}getAnimationLoop(){return this._animationLoop}setAnimationLoop(e){this._animationLoop=e}getContext(){return this._context}setContext(e){this._context=e}dispose(){this.stop()}}class Xo{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;for(let r=0;r<e.length-1;r++)if(t=t.get(e[r]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let r=this.weakMap;for(let s=0;s<e.length-1;s++){const a=e[s];r.has(a)===!1&&r.set(a,new WeakMap),r=r.get(a)}return r.set(e[e.length-1],t),this}delete(e){let t=this.weakMap;for(let r=0;r<e.length-1;r++)if(t=t.get(e[r]),t===void 0)return!1;return t.delete(e[e.length-1])}}let S2=0;function T2(i){const e=Object.keys(i);let t=Object.getPrototypeOf(i);for(;t;){const r=Object.getOwnPropertyDescriptors(t);for(const s in r)if(r[s]!==void 0){const a=r[s];a&&typeof a.get=="function"&&e.push(s)}t=Object.getPrototypeOf(t)}return e}class M2{constructor(e,t,r,s,a,c,h,f,m,x){this.id=S2++,this._nodes=e,this._geometries=t,this.renderer=r,this.object=s,this.material=a,this.scene=c,this.camera=h,this.lightsNode=f,this.context=m,this.geometry=s.geometry,this.version=a.version,this.drawRange=null,this.attributes=null,this.attributesId=null,this.pipeline=null,this.group=null,this.vertexBuffers=null,this.drawParams=null,this.bundle=null,this.clippingContext=x,this.clippingContextCacheKey=x!==null?x.cacheKey:"",this.initialNodesCacheKey=this.getDynamicCacheKey(),this.initialCacheKey=this.getCacheKey(),this._nodeBuilderState=null,this._bindings=null,this._monitor=null,this.onDispose=null,this.isRenderObject=!0,this.onMaterialDispose=()=>{this.dispose()},this.onGeometryDispose=()=>{this.attributes=null,this.attributesId=null},this.material.addEventListener("dispose",this.onMaterialDispose),this.geometry.addEventListener("dispose",this.onGeometryDispose)}updateClipping(e){this.clippingContext=e}get clippingNeedsUpdate(){return this.clippingContext===null||this.clippingContext.cacheKey===this.clippingContextCacheKey?!1:(this.clippingContextCacheKey=this.clippingContext.cacheKey,!0)}get hardwareClippingPlanes(){return this.material.hardwareClipping===!0?this.clippingContext.unionClippingCount:0}getNodeBuilderState(){return this._nodeBuilderState||(this._nodeBuilderState=this._nodes.getForRender(this))}getMonitor(){return this._monitor||(this._monitor=this.getNodeBuilderState().observer)}getBindings(){return this._bindings||(this._bindings=this.getNodeBuilderState().createBindings())}getBindingGroup(e){for(const t of this.getBindings())if(t.name===e)return t}getIndex(){return this._geometries.getIndex(this)}getIndirect(){return this._geometries.getIndirect(this)}getChainArray(){return[this.object,this.material,this.context,this.lightsNode]}setGeometry(e){this.geometry=e,this.attributes=null,this.attributesId=null}getAttributes(){if(this.attributes!==null)return this.attributes;const e=this.getNodeBuilderState().nodeAttributes,t=this.geometry,r=[],s=new Set,a={};for(const c of e){let h;if(c.node&&c.node.attribute?h=c.node.attribute:(h=t.getAttribute(c.name),a[c.name]=h.version),h===void 0)continue;r.push(h);const f=h.isInterleavedBufferAttribute?h.data:h;s.add(f)}return this.attributes=r,this.attributesId=a,this.vertexBuffers=Array.from(s.values()),r}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:r,group:s,drawRange:a}=this,c=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),h=this.getIndex(),f=h!==null;let m=1;if(r.isInstancedBufferGeometry===!0?m=r.instanceCount:e.count!==void 0&&(m=Math.max(0,e.count)),m===0)return null;if(c.instanceCount=m,e.isBatchedMesh===!0)return c;let x=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(x=2);let _=a.start*x,v=(a.start+a.count)*x;s!==null&&(_=Math.max(_,s.start*x),v=Math.min(v,(s.start+s.count)*x));const T=r.attributes.position;let w=1/0;f?w=h.count:T!=null&&(w=T.count),_=Math.max(_,0),v=Math.min(v,w);const P=v-_;return P<0||P===1/0?null:(c.vertexCount=P,c.firstVertex=_,c)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const r of Object.keys(e.attributes).sort()){const s=e.attributes[r];t+=r+",",s.data&&(t+=s.data.stride+","),s.offset&&(t+=s.offset+","),s.itemSize&&(t+=s.itemSize+","),s.normalized&&(t+="n,")}for(const r of Object.keys(e.morphAttributes).sort()){const s=e.morphAttributes[r];t+="morph-"+r+",";for(let a=0,c=s.length;a<c;a++){const h=s[a];t+=h.id+","}}return e.index&&(t+="index,"),t}getMaterialCacheKey(){const{object:e,material:t,renderer:r}=this;let s=t.customProgramCacheKey();for(const a of T2(t)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(a))continue;const c=t[a];let h;if(c!==null){const f=typeof c;f==="number"?h=c!==0?"1":"0":f==="object"?(h="{",c.isTexture&&(h+=c.mapping,r.backend.isWebGPUBackend===!0&&(h+=c.magFilter,h+=c.minFilter,h+=c.wrapS,h+=c.wrapT,h+=c.wrapR)),h+="}"):h=String(c)}else h=String(c);s+=h+","}return s+=this.clippingContextCacheKey+",",e.geometry&&(s+=this.getGeometryCacheKey()),e.skeleton&&(s+=e.skeleton.bones.length+","),e.isBatchedMesh&&(s+=e._matricesTexture.uuid+",",e._colorsTexture!==null&&(s+=e._colorsTexture.uuid+",")),(e.isInstancedMesh||e.count>1||Array.isArray(e.morphTargetInfluences))&&(s+=e.uuid+","),s+=e.receiveShadow+",",Jc(s)}get needsGeometryUpdate(){if(this.geometry.id!==this.object.geometry.id)return!0;if(this.attributes!==null){const e=this.attributesId;for(const t in e){const r=this.geometry.getAttribute(t);if(r===void 0||e[t]!==r.id)return!0}}return!1}get needsUpdate(){return this.initialNodesCacheKey!==this.getDynamicCacheKey()||this.clippingNeedsUpdate}getDynamicCacheKey(){let e=0;return this.material.isShadowPassMaterial!==!0&&(e=this._nodes.getCacheKey(this.scene,this.lightsNode)),this.camera.isArrayCamera&&(e=Qa(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=Qa(e,1)),e=Qa(e,this.camera.id),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.geometry.removeEventListener("dispose",this.onGeometryDispose),this.onDispose()}}const Fu=[];class w2{constructor(e,t,r,s,a,c){this.renderer=e,this.nodes=t,this.geometries=r,this.pipelines=s,this.bindings=a,this.info=c,this.chainMaps={}}get(e,t,r,s,a,c,h,f){const m=this.getChainMap(f);Fu[0]=e,Fu[1]=t,Fu[2]=c,Fu[3]=a;let x=m.get(Fu);return x===void 0?(x=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,r,s,a,c,h,f),m.set(Fu,x)):(x.updateClipping(h),x.needsGeometryUpdate&&x.setGeometry(e.geometry),(x.version!==t.version||x.needsUpdate)&&(x.initialCacheKey!==x.getCacheKey()?(x.dispose(),x=this.get(e,t,r,s,a,c,h,f)):x.version=t.version)),Fu.length=0,x}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new Xo)}dispose(){this.chainMaps={}}createRenderObject(e,t,r,s,a,c,h,f,m,x,_){const v=this.getChainMap(_),T=new M2(e,t,r,s,a,c,h,f,m,x);return T.onDispose=()=>{this.pipelines.delete(T),this.bindings.deleteForRender(T),this.nodes.delete(T),v.delete(T.getChainArray())},T}}class yl{constructor(){this.data=new WeakMap}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}delete(e){let t=null;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 _o={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},bl=16,A2=211,E2=212;class C2 extends yl{constructor(e){super(),this.backend=e}delete(e){const t=super.delete(e);return t!==null&&this.backend.destroyAttribute(e),t}update(e,t){const r=this.get(e);if(r.version===void 0)t===_o.VERTEX?this.backend.createAttribute(e):t===_o.INDEX?this.backend.createIndexAttribute(e):t===_o.STORAGE?this.backend.createStorageAttribute(e):t===_o.INDIRECT&&this.backend.createIndirectStorageAttribute(e),r.version=this._getBufferAttribute(e).version;else{const s=this._getBufferAttribute(e);(r.version<s.version||s.usage===d.dj0)&&(this.backend.updateAttribute(e),r.version=s.version)}}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}function OM(i){return i.index!==null?i.index.version:i.attributes.position.version}function kM(i){const e=[],t=i.index,r=i.attributes.position;if(t!==null){const a=t.array;for(let c=0,h=a.length;c<h;c+=3){const f=a[c+0],m=a[c+1],x=a[c+2];e.push(f,m,m,x,x,f)}}else{const a=r.array;for(let c=0,h=a.length/3-1;c<h;c+=3){const f=c+0,m=c+1,x=c+2;e.push(f,m,m,x,x,f)}}const s=new((0,d.H7L)(e)?d.lCJ:d.qlB)(e,1);return s.version=OM(i),s}class R2 extends yl{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap,this._geometryDisposeListeners=new Map}has(e){const t=e.geometry;return super.has(t)&&this.get(t).initialized===!0}updateForRender(e){this.has(e)===!1&&this.initGeometry(e),this.updateAttributes(e)}initGeometry(e){const t=e.geometry,r=this.get(t);r.initialized=!0,this.info.memory.geometries++;const s=()=>{this.info.memory.geometries--;const a=t.index,c=e.getAttributes();a!==null&&this.attributes.delete(a);for(const f of c)this.attributes.delete(f);const h=this.wireframes.get(t);h!==void 0&&this.attributes.delete(h),t.removeEventListener("dispose",s),this._geometryDisposeListeners.delete(t)};t.addEventListener("dispose",s),this._geometryDisposeListeners.set(t,s)}updateAttributes(e){const t=e.getAttributes();for(const a of t)a.isStorageBufferAttribute||a.isStorageInstancedBufferAttribute?this.updateAttribute(a,_o.STORAGE):this.updateAttribute(a,_o.VERTEX);const r=this.getIndex(e);r!==null&&this.updateAttribute(r,_o.INDEX);const s=e.geometry.indirect;s!==null&&this.updateAttribute(s,_o.INDIRECT)}updateAttribute(e,t){const r=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,r)):this.attributeCall.get(e.data)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e.data,r),this.attributeCall.set(e,r)):this.attributeCall.get(e)!==r&&(this.attributes.update(e,t),this.attributeCall.set(e,r))}getIndirect(e){return e.geometry.indirect}getIndex(e){const{geometry:t,material:r}=e;let s=t.index;if(r.wireframe===!0){const a=this.wireframes;let c=a.get(t);c===void 0?(c=kM(t),a.set(t,c)):c.version!==OM(t)&&(this.attributes.delete(c),c=kM(t),a.set(t,c)),s=c}return s}dispose(){for(const[e,t]of this._geometryDisposeListeners.entries())e.removeEventListener("dispose",t);this._geometryDisposeListeners.clear()}}class N2{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},this.compute={calls:0,frameCalls:0,timestamp:0},this.memory={geometries:0,textures:0}}update(e,t,r){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=r*(t/3):e.isPoints?this.render.points+=r*t:e.isLineSegments?this.render.lines+=r*(t/2):e.isLine?this.render.lines+=r*(t-1):(0,d.vUy)("WebGPUInfo: Unknown object type.")}reset(){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 VM{constructor(e){this.cacheKey=e,this.usedTimes=0}}class P2 extends VM{constructor(e,t,r){super(e),this.vertexProgram=t,this.fragmentProgram=r}}class L2 extends VM{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let I2=0;class Cv{constructor(e,t,r,s=null,a=null){this.id=I2++,this.code=e,this.stage=t,this.name=r,this.transforms=s,this.attributes=a,this.usedTimes=0}}class D2 extends yl{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:r}=this,s=this.get(e);if(this._needsComputeUpdate(e)){const a=s.pipeline;a&&(a.usedTimes--,a.computeProgram.usedTimes--);const c=this.nodes.getForCompute(e);let h=this.programs.compute.get(c.computeShader);h===void 0&&(a&&a.computeProgram.usedTimes===0&&this._releaseProgram(a.computeProgram),h=new Cv(c.computeShader,"compute",e.name,c.transforms,c.nodeAttributes),this.programs.compute.set(c.computeShader,h),r.createProgram(h));const f=this._getComputeCacheKey(e,h);let m=this.caches.get(f);m===void 0&&(a&&a.usedTimes===0&&this._releasePipeline(a),m=this._getComputePipeline(e,h,f,t)),m.usedTimes++,h.usedTimes++,s.version=e.version,s.pipeline=m}return s.pipeline}getForRender(e,t=null){const{backend:r}=this,s=this.get(e);if(this._needsRenderUpdate(e)){const a=s.pipeline;a&&(a.usedTimes--,a.vertexProgram.usedTimes--,a.fragmentProgram.usedTimes--);const c=e.getNodeBuilderState(),h=e.material?e.material.name:"";let f=this.programs.vertex.get(c.vertexShader);f===void 0&&(a&&a.vertexProgram.usedTimes===0&&this._releaseProgram(a.vertexProgram),f=new Cv(c.vertexShader,"vertex",h),this.programs.vertex.set(c.vertexShader,f),r.createProgram(f));let m=this.programs.fragment.get(c.fragmentShader);m===void 0&&(a&&a.fragmentProgram.usedTimes===0&&this._releaseProgram(a.fragmentProgram),m=new Cv(c.fragmentShader,"fragment",h),this.programs.fragment.set(c.fragmentShader,m),r.createProgram(m));const x=this._getRenderCacheKey(e,f,m);let _=this.caches.get(x);_===void 0?(a&&a.usedTimes===0&&this._releasePipeline(a),_=this._getRenderPipeline(e,f,m,x,t)):e.pipeline=_,_.usedTimes++,f.usedTimes++,m.usedTimes++,s.pipeline=_}return s.pipeline}delete(e){const t=this.get(e).pipeline;return t&&(t.usedTimes--,t.usedTimes===0&&this._releasePipeline(t),t.isComputePipeline?(t.computeProgram.usedTimes--,t.computeProgram.usedTimes===0&&this._releaseProgram(t.computeProgram)):(t.fragmentProgram.usedTimes--,t.vertexProgram.usedTimes--,t.vertexProgram.usedTimes===0&&this._releaseProgram(t.vertexProgram),t.fragmentProgram.usedTimes===0&&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,r,s){r=r||this._getComputeCacheKey(e,t);let a=this.caches.get(r);return a===void 0&&(a=new L2(r,t),this.caches.set(r,a),this.backend.createComputePipeline(a,s)),a}_getRenderPipeline(e,t,r,s,a){s=s||this._getRenderCacheKey(e,t,r);let c=this.caches.get(s);return c===void 0&&(c=new P2(s,t,r),this.caches.set(s,c),e.pipeline=c,this.backend.createRenderPipeline(e,a)),c}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,r){return t.id+","+r.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,r=e.stage;this.programs[r].delete(t)}_needsComputeUpdate(e){const t=this.get(e);return t.pipeline===void 0||t.version!==e.version}_needsRenderUpdate(e){return this.get(e).pipeline===void 0||this.backend.needsRenderUpdate(e)}}class U2 extends yl{constructor(e,t,r,s,a,c){super(),this.backend=e,this.textures=r,this.pipelines=a,this.attributes=s,this.nodes=t,this.info=c,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const r of t){const s=this.get(r);s.bindGroup===void 0&&(this._init(r),this.backend.createBindings(r,t,0),s.bindGroup=r)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const r of t){const s=this.get(r);s.bindGroup===void 0&&(this._init(r),this.backend.createBindings(r,t,0),s.bindGroup=r)}return t}updateForCompute(e){this._updateBindings(this.getForCompute(e))}updateForRender(e){this._updateBindings(this.getForRender(e))}deleteForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const r of t)this.delete(r)}deleteForRender(e){const t=e.getBindings();for(const r of t)this.delete(r)}_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.isSampler)this.textures.updateSampler(t.texture);else if(t.isStorageBuffer){const r=t.attribute,s=r.isIndirectStorageBufferAttribute?_o.INDIRECT:_o.STORAGE;this.attributes.update(r,s)}}_update(e,t){const{backend:r}=this;let s=!1,a=!0,c=0,h=0;for(const f of e.bindings)if(!(f.isNodeUniformsGroup&&this.nodes.updateGroup(f)===!1)){if(f.isStorageBuffer){const m=f.attribute,x=m.isIndirectStorageBufferAttribute?_o.INDIRECT:_o.STORAGE;this.attributes.update(m,x)}if(f.isUniformBuffer)f.update()&&r.updateBinding(f);else if(f.isSampledTexture){const m=f.update(),x=f.texture,_=this.textures.get(x);if(m&&(this.textures.updateTexture(x),f.generation!==_.generation&&(f.generation=_.generation,s=!0,a=!1)),r.get(x).externalTexture!==void 0||_.isDefaultTexture?a=!1:(c=c*10+x.id,h+=x.version),x.isStorageTexture===!0&&x.mipmapsAutoUpdate===!0){const T=this.get(x);f.store===!0?T.needsMipmap=!0:this.textures.needsMipmaps(x)&&T.needsMipmap===!0&&(this.backend.generateMipmaps(x),T.needsMipmap=!1)}}else if(f.isSampler&&f.update()){const x=this.textures.updateSampler(f.texture);f.samplerKey!==x&&(f.samplerKey=x,s=!0,a=!1)}}s===!0&&this.backend.updateBindings(e,t,a?c:0,h)}}function F2(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?i.z-e.z:i.id-e.id}function zM(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function GM(i){return(i.transmission>0||i.transmissionNode&&i.transmissionNode.isNode)&&i.side===d.ehD&&i.forceSinglePass===!1}class B2{constructor(e,t,r){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,r),this.lightsArray=[],this.scene=t,this.camera=r,this.occlusionQueryCount=0}begin(){return this.renderItemsIndex=0,this.opaque.length=0,this.transparentDoublePass.length=0,this.transparent.length=0,this.bundles.length=0,this.lightsArray.length=0,this.occlusionQueryCount=0,this}getNextRenderItem(e,t,r,s,a,c,h){let f=this.renderItems[this.renderItemsIndex];return f===void 0?(f={id:e.id,object:e,geometry:t,material:r,groupOrder:s,renderOrder:e.renderOrder,z:a,group:c,clippingContext:h},this.renderItems[this.renderItemsIndex]=f):(f.id=e.id,f.object=e,f.geometry=t,f.material=r,f.groupOrder=s,f.renderOrder=e.renderOrder,f.z=a,f.group=c,f.clippingContext=h),this.renderItemsIndex++,f}push(e,t,r,s,a,c,h){const f=this.getNextRenderItem(e,t,r,s,a,c,h);e.occlusionTest===!0&&this.occlusionQueryCount++,r.transparent===!0||r.transmission>0||r.transmissionNode&&r.transmissionNode.isNode||r.backdropNode&&r.backdropNode.isNode?(GM(r)&&this.transparentDoublePass.push(f),this.transparent.push(f)):this.opaque.push(f)}unshift(e,t,r,s,a,c,h){const f=this.getNextRenderItem(e,t,r,s,a,c,h);r.transparent===!0||r.transmission>0||r.transmissionNode&&r.transmissionNode.isNode||r.backdropNode&&r.backdropNode.isNode?(GM(r)&&this.transparentDoublePass.unshift(f),this.transparent.unshift(f)):this.opaque.unshift(f)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||F2),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||zM),this.transparent.length>1&&this.transparent.sort(t||zM)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e<t;e++){const r=this.renderItems[e];if(r.id===null)break;r.id=null,r.object=null,r.geometry=null,r.material=null,r.groupOrder=null,r.renderOrder=null,r.z=null,r.group=null,r.clippingContext=null}}}const am=[];class O2{constructor(e){this.lighting=e,this.lists=new Xo}get(e,t){const r=this.lists;am[0]=e,am[1]=t;let s=r.get(am);return s===void 0&&(s=new B2(this.lighting,e,t),r.set(am,s)),am.length=0,s}dispose(){this.lists=new Xo}}let k2=0;class V2{constructor(){this.id=k2++,this.color=!0,this.clearColor=!0,this.clearColorValue={r:0,g:0,b:0,a:1},this.depth=!0,this.clearDepth=!0,this.clearDepthValue=1,this.stencil=!1,this.clearStencil=!0,this.clearStencilValue=1,this.viewport=!1,this.viewportValue=new d.Ltg,this.scissor=!1,this.scissorValue=new d.Ltg,this.renderTarget=null,this.textures=null,this.depthTexture=null,this.activeCubeFace=0,this.activeMipmapLevel=0,this.sampleCount=1,this.width=0,this.height=0,this.occlusionQueryCount=0,this.clippingContext=null,this.isRenderContext=!0}getCacheKey(){return WM(this)}}function WM(i){const{textures:e,activeCubeFace:t,activeMipmapLevel:r}=i,s=[t,r];for(const a of e)s.push(a.id);return Os(s)}const cm=[],z2=new d.xsS,G2=new d.V1s;class W2{constructor(){this.chainMaps={}}get(e,t,r=null){cm[0]=e,cm[1]=t;let s;if(r===null)s="default";else{const h=r.texture.format;s=`${r.textures.length}:${h}:${r.samples}:${r.depthBuffer}:${r.stencilBuffer}`}const a=this._getChainMap(s);let c=a.get(cm);return c===void 0&&(c=new V2,a.set(cm,c)),cm.length=0,r!==null&&(c.sampleCount=r.samples===0?1:r.samples),c}getForClear(e=null){return this.get(z2,G2,e)}_getChainMap(e){return this.chainMaps[e]||(this.chainMaps[e]=new Xo)}dispose(){this.chainMaps={}}}const H2=new d.Pa4;class $2 extends yl{constructor(e,t,r){super(),this.renderer=e,this.backend=t,this.info=r}updateRenderTarget(e,t=0){const r=this.get(e),s=e.samples===0?1:e.samples,a=r.depthTextureMips||(r.depthTextureMips={}),c=e.textures,h=this.getSize(c[0]),f=h.width>>t,m=h.height>>t;let x=e.depthTexture||a[t];const _=e.depthBuffer===!0||e.stencilBuffer===!0;let v=!1;x===void 0&&_&&(x=new d.$YQ,x.format=e.stencilBuffer?d.brP:d.qkB,x.type=e.stencilBuffer?d.wJv:d.JQ4,x.image.width=f,x.image.height=m,x.image.depth=h.depth,x.renderTarget=e,x.isArrayTexture=e.multiview===!0&&h.depth>1,a[t]=x),(r.width!==h.width||h.height!==r.height)&&(v=!0,x&&(x.needsUpdate=!0,x.image.width=f,x.image.height=m,x.image.depth=x.isArrayTexture?x.image.depth:1)),r.width=h.width,r.height=h.height,r.textures=c,r.depthTexture=x||null,r.depth=e.depthBuffer,r.stencil=e.stencilBuffer,r.renderTarget=e,r.sampleCount!==s&&(v=!0,x&&(x.needsUpdate=!0),r.sampleCount=s);const T={sampleCount:s};if(e.isXRRenderTarget!==!0){for(let w=0;w<c.length;w++){const P=c[w];v&&(P.needsUpdate=!0),this.updateTexture(P,T)}x&&this.updateTexture(x,T)}r.initialized!==!0&&(r.initialized=!0,r.onDispose=()=>{this._destroyRenderTarget(e)},e.addEventListener("dispose",r.onDispose))}updateTexture(e,t={}){const r=this.get(e);if(r.initialized===!0&&r.version===e.version)return;const s=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,a=this.backend;if(s&&r.initialized===!0&&a.destroyTexture(e),e.isFramebufferTexture){const m=this.renderer.getRenderTarget();m?e.type=m.texture.type:e.type=d.ywz}const{width:c,height:h,depth:f}=this.getSize(e);if(t.width=c,t.height=h,t.depth=f,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,c,h):1,e.isCubeTexture&&e.mipmaps.length>0&&t.levels++,s||e.isStorageTexture===!0||e.isExternalTexture===!0)a.createTexture(e,t),r.generation=e.version;else if(e.version>0){const m=e.image;if(m===void 0)(0,d.ZK6)("Renderer: Texture marked for update but image is undefined.");else if(m.complete===!1)(0,d.ZK6)("Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const _=[];for(const v of e.images)_.push(v);t.images=_}else t.image=m;(r.isDefaultTexture===void 0||r.isDefaultTexture===!0)&&(a.createTexture(e,t),r.isDefaultTexture=!1,r.generation=e.version),e.source.dataReady===!0&&a.updateTexture(e,t);const x=e.isStorageTexture===!0&&e.mipmapsAutoUpdate===!1;t.needsMipmaps&&e.mipmaps.length===0&&!x&&a.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else a.createDefaultTexture(e),r.isDefaultTexture=!0,r.generation=e.version;r.initialized!==!0&&(r.initialized=!0,r.generation=e.version,this.info.memory.textures++,e.isVideoTexture&&d.epp.getTransfer(e.colorSpace)!==d.j17&&(0,d.ZK6)("WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace."),r.onDispose=()=>{this._destroyTexture(e)},e.addEventListener("dispose",r.onDispose)),r.version=e.version}updateSampler(e){return this.backend.updateSampler(e)}getSize(e,t=H2){let r=e.images?e.images[0]:e.image;return r?(r.image!==void 0&&(r=r.image),typeof HTMLVideoElement!="undefined"&&r instanceof HTMLVideoElement?(t.width=r.videoWidth||1,t.height=r.videoHeight||1,t.depth=1):typeof VideoFrame!="undefined"&&r instanceof VideoFrame?(t.width=r.displayWidth||1,t.height=r.displayHeight||1,t.depth=1):(t.width=r.width||1,t.height=r.height||1,t.depth=e.isCubeTexture?6:r.depth||1)):t.width=t.height=t.depth=1,t}getMipLevels(e,t,r){let s;return e.mipmaps.length>0?s=e.mipmaps.length:e.isCompressedTexture===!0?s=1:s=Math.floor(Math.log2(Math.max(t,r)))+1,s}needsMipmaps(e){return e.generateMipmaps===!0||e.mipmaps.length>0}_destroyRenderTarget(e){if(this.has(e)===!0){const t=this.get(e),r=t.textures,s=t.depthTexture;e.removeEventListener("dispose",t.onDispose);for(let a=0;a<r.length;a++)this._destroyTexture(r[a]);s&&this._destroyTexture(s),this.delete(e),this.backend.delete(e)}}_destroyTexture(e){if(this.has(e)===!0){const t=this.get(e);e.removeEventListener("dispose",t.onDispose);const r=t.isDefaultTexture;this.backend.destroyTexture(e,r),this.delete(e),this.info.memory.textures--}}}class Rv extends d.Ilk{constructor(e,t,r,s=1){super(e,t,r),this.a=s}set(e,t,r,s=1){return this.a=s,super.set(e,t,r)}copy(e){return e.a!==void 0&&(this.a=e.a),super.copy(e)}clone(){return new this.constructor(this.r,this.g,this.b,this.a)}}class HM extends oi{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getMemberType(e,t){const r=this.getNodeType(e),s=e.getStructTypeNode(r);let a;return s!==null?a=s.getMemberType(e,t):((0,d.vUy)(`TSL: Member "${t}" not found in struct "${r}".`),a="float"),a}getHash(){return this.uuid}generate(){return this.name}}const j2=(i,e)=>Oe(new HM(i,e));class X2 extends Rt{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this.isStackNode=!0}getElementType(e){return this.hasOutput?this.outputNode.getElementType(e):"void"}getNodeType(e){return this.hasOutput?this.outputNode.getNodeType(e):"void"}getMemberType(e,t){return this.hasOutput?this.outputNode.getMemberType(e,t):"void"}addToStack(e){return e.isNode!==!0?((0,d.vUy)("TSL: Invalid node added to stack."),this):(this.nodes.push(e),this)}If(e,t){const r=new nc(t);return this._currentCond=S(e,r),this.addToStack(this._currentCond)}ElseIf(e,t){const r=new nc(t),s=S(e,r);return this._currentCond.elseNode=s,this._currentCond=s,this}Else(e){return this._currentCond.elseNode=new nc(e),this}Switch(e){return this._expressionNode=Oe(e),this}Case(...e){const t=[];if(e.length>=2)for(let h=0;h<e.length-1;h++)t.push(this._expressionNode.equal(Oe(e[h])));else(0,d.vUy)("TSL: Invalid parameter length. Case() requires at least two parameters.");const r=e[e.length-1],s=new nc(r);let a=t[0];for(let h=1;h<t.length;h++)a=a.or(t[h]);const c=S(a,s);return this._currentCond===null?(this._currentCond=c,this.addToStack(this._currentCond)):(this._currentCond.elseNode=c,this._currentCond=c,this)}Default(e){return this.Else(e),this}setup(e){const t=e.getNodeProperties(this);let r=0;for(const s of this.getChildren())s.isVarNode&&s.intent===!0&&s.isAssign(e)!==!0||(t["node"+r++]=s);return t.outputNode||null}get hasOutput(){return this.outputNode&&this.outputNode.isNode}build(e,...t){const r=Pp();ic(this),e.setActiveStack(this);const s=e.buildStage;for(const c of this.nodes)if(!(c.isVarNode&&c.intent===!0&&c.isAssign(e)!==!0)){if(s==="setup")c.build(e);else if(s==="analyze")c.build(e,this);else if(s==="generate"){const h=e.getDataFromNode(c,"any").stages,f=h&&h[e.shaderStage];if(c.isVarNode&&f&&f.length===1&&f[0]&&f[0].isStackNode)continue;c.build(e,"void")}}let a;return this.hasOutput?a=this.outputNode.build(e,...t):a=super.build(e,...t),ic(r),e.removeActiveStack(this),a}}const Mx=sn(X2).setParameterLength(0,1);function q2(i){return Object.entries(i).map(([e,t])=>typeof t=="string"?{name:e,type:t,atomic:!1}:{name:e,type:t.type,atomic:t.atomic||!1})}class K2 extends Rt{static get type(){return"StructTypeNode"}constructor(e,t=null){super("struct"),this.membersLayout=q2(e),this.name=t,this.isStructLayoutNode=!0}getLength(){const t=Float32Array.BYTES_PER_ELEMENT;let r=0;for(const s of this.membersLayout){const a=s.type,c=gp(a)*t,h=tu(a),f=r%8,m=f%h,x=f+m;r+=m,x!==0&&8-x<c&&(r+=8-x),r+=c}return Math.ceil(r/8)*8/t}getMemberType(e,t){const r=this.membersLayout.find(s=>s.name===t);return r?r.type:"void"}getNodeType(e){return e.getStructTypeFromNode(this,this.membersLayout,this.name).name}setup(e){e.getStructTypeFromNode(this,this.membersLayout,this.name),e.addInclude(this)}generate(e){return this.getNodeType(e)}}class Z2 extends Rt{static get type(){return"StructNode"}constructor(e,t){super("vec3"),this.structTypeNode=e,this.values=t,this.isStructNode=!0}getNodeType(e){return this.structTypeNode.getNodeType(e)}getMemberType(e,t){return this.structTypeNode.getMemberType(e,t)}generate(e){const t=e.getVarFromNode(this),r=t.type,s=e.getPropertyName(t);return e.addLineFlowCode(`${s} = ${e.generateStruct(r,this.structTypeNode.membersLayout,this.values)}`,this),t.name}}const Y2=(i,e=null)=>{const t=new K2(i,e),r=(...s)=>{let a=null;if(s.length>0)if(s[0].isNode){a={};const c=Object.keys(i);for(let h=0;h<s.length;h++)a[c[h]]=s[h]}else a=s[0];return Oe(new Z2(t,a))};return r.layout=t,r.isStruct=!0,r};class $M extends Rt{static get type(){return"OutputStructNode"}constructor(...e){super(),this.members=e,this.isOutputStructNode=!0}getNodeType(e){const t=e.getNodeProperties(this);if(t.membersLayout===void 0){const r=this.members,s=[];for(let a=0;a<r.length;a++){const c="m"+a,h=r[a].getNodeType(e);s.push({name:c,type:h,index:a})}t.membersLayout=s,t.structType=e.getOutputStructTypeFromNode(this,t.membersLayout)}return t.structType.name}generate(e){const t=e.getOutputStructName(),r=this.members,s=t!==""?t+".":"";for(let a=0;a<r.length;a++){const c=r[a].build(e);e.addLineFlowCode(`${s}m${a} = ${c}`,this)}return t}}const Q2=sn($M);function jM(i,e){for(let t=0;t<i.length;t++)if(i[t].name===e)return t;return-1}class J2 extends $M{static get type(){return"MRTNode"}constructor(e){super(),this.outputNodes=e,this.isMRTNode=!0}has(e){return this.outputNodes[e]!==void 0}get(e){return this.outputNodes[e]}merge(e){const t=rr(rr({},this.outputNodes),e.outputNodes);return XM(t)}setup(e){const t=this.outputNodes,r=e.renderer.getRenderTarget(),s=[],a=r.textures;for(const c in t){const h=jM(a,c);s[h]=At(t[c])}return this.members=s,super.setup(e)}}const XM=sn(J2);class lm extends Oi{static get type(){return"BitcastNode"}constructor(e,t,r=null){super(),this.valueNode=e,this.conversionType=t,this.inputType=r,this.isBitcastNode=!0}getNodeType(e){if(this.inputType!==null){const t=this.valueNode.getNodeType(e),r=e.getTypeLength(t);return e.getTypeFromLength(r,this.conversionType)}return this.conversionType}generate(e){const t=this.getNodeType(e);let r="";if(this.inputType!==null){const s=this.valueNode.getNodeType(e);r=e.getTypeLength(s)===1?this.inputType:e.changeComponentType(s,this.inputType)}else r=this.valueNode.getNodeType(e);return`${e.getBitcastMethod(t,r)}( ${this.valueNode.build(e,r)} )`}}const eN=at(lm).setParameterLength(2),tN=i=>new lm(i,"int","float"),nN=i=>new lm(i,"uint","float"),iN=i=>new lm(i,"float","int"),rN=i=>new lm(i,"float","uint"),sN=fe(([i])=>{const e=i.toUint().mul(747796405).add(2891336453),t=e.shiftRight(e.shiftRight(28).add(4)).bitXor(e).mul(277803737);return t.shiftRight(22).bitXor(t).toFloat().mul(1/Zd(2,32))}),Nv=(i,e)=>kr(cn(4,i.mul(Cn(1,i))),e),oN=(i,e)=>i.lessThan(.5)?Nv(i.mul(2),e).div(2):Cn(1,Nv(cn(Cn(1,i),2),e).div(2)),aN=(i,e,t)=>kr(cs(kr(i,e),Yi(kr(i,e),kr(Cn(1,i),t))),1/e),cN=(i,e)=>jr(kp.mul(e.mul(i).sub(1))).div(kp.mul(e.mul(i).sub(1))),vc=fe(([i])=>i.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),lN=fe(([i])=>ce(vc(i.z.add(vc(i.y.mul(1)))),vc(i.z.add(vc(i.x.mul(1)))),vc(i.y.add(vc(i.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),uN=fe(([i,e,t])=>{const r=ce(i).toVar(),s=G(1.4).toVar(),a=G(0).toVar(),c=ce(r).toVar();return ci({start:G(0),end:G(3),type:"float",condition:"<="},()=>{const h=ce(lN(c.mul(2))).toVar();r.addAssign(h.add(t.mul(G(.1).mul(e)))),c.mulAssign(1.8),s.mulAssign(1.5),r.mulAssign(1.2);const f=G(vc(r.z.add(vc(r.x.add(vc(r.y)))))).toVar();a.addAssign(f.div(s)),c.addAssign(.14)}),a}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]});class hN extends Rt{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFn=null,this.global=!0}getNodeType(e){return this.getCandidateFn(e).shaderNode.layout.type}getCandidateFn(e){const t=this.parametersNodes;let r=this._candidateFn;if(r===null){let s=null,a=-1;for(const c of this.functionNodes){const f=c.shaderNode.layout;if(f===null)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const m=f.inputs;if(t.length===m.length){let x=0;for(let _=0;_<t.length;_++){const v=t[_],T=m[_];v.getNodeType(e)===T.type&&x++}x>a&&(s=c,a=x)}}this._candidateFn=r=s}return r}setup(e){return this.getCandidateFn(e)(...this.parametersNodes)}}const dN=sn(hN),Gr=i=>(...e)=>dN(i,...e),Id=Bt(0).setGroup(Ft).onRenderUpdate(i=>i.time),fN=Bt(0).setGroup(Ft).onRenderUpdate(i=>i.deltaTime),qM=Bt(0,"uint").setGroup(Ft).onRenderUpdate(i=>i.frameId),pN=(i=Id)=>i.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),mN=(i=Id)=>i.fract().round(),gN=(i=Id)=>i.add(.5).fract().mul(2).sub(1).abs(),xN=(i=Id)=>i.fract(),_N=fe(([i,e,t=Ve(.5)])=>sm(i.sub(t),e).add(t)),yN=fe(([i,e,t=Ve(.5)])=>{const r=i.sub(t),s=r.dot(r),c=s.mul(s).mul(e);return i.add(r.mul(c))}),bN=fe(({position:i=null,horizontal:e=!0,vertical:t=!1})=>{let r;i!==null?(r=go.toVar(),r[3][0]=i.x,r[3][1]=i.y,r[3][2]=i.z):r=go;const s=qs.mul(r);return ol(e)&&(s[0][0]=go[0].length(),s[0][1]=0,s[0][2]=0),ol(t)&&(s[1][0]=0,s[1][1]=go[1].length(),s[1][2]=0),s[2][0]=0,s[2][1]=0,s[2][2]=1,po.mul(s).mul(er)}),vN=fe(([i=null])=>{const e=Nd();return Nd(rv(i)).sub(e).lessThan(0).select(mc,i)});class SN extends Rt{static get type(){return"SpriteSheetUVNode"}constructor(e,t=hi(),r=G(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=r}setup(){const{frameNode:e,uvNode:t,countNode:r}=this,{width:s,height:a}=r,c=e.mod(s.mul(a)).floor(),h=c.mod(s),f=a.sub(c.add(1).div(s).ceil()),m=r.reciprocal(),x=Ve(h,f);return t.add(x).mul(m)}}const TN=sn(SN).setParameterLength(3),KM=fe(([i,e=null,t=null,r=G(1),s=er,a=Ss])=>{let c=a.abs().normalize();c=c.div(c.dot(ce(1)));const h=s.yz.mul(r),f=s.zx.mul(r),m=s.xy.mul(r),x=i.value,_=e!==null?e.value:x,v=t!==null?t.value:x,T=In(x,h).mul(c.x),w=In(_,f).mul(c.y),P=In(v,m).mul(c.z);return Yi(T,w,P)}),MN=(...i)=>KM(...i),Dd=new d.JOQ,Bu=new d.Pa4,Ud=new d.Pa4,Pv=new d.Pa4,um=new d.yGw,wx=new d.Pa4(0,0,-1),ya=new d.Ltg,hm=new d.Pa4,Ax=new d.Pa4,dm=new d.Ltg,Ex=new d.FM8,Cx=new d.ACn,wN=mc.flipX();Cx.depthTexture=new d.$YQ(1,1);let Rx=!1;class Lv extends _a{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||Cx.texture,wN),this._reflectorBaseNode=e.reflector||new AN(this,e),this._depthNode=null,this.setUpdateMatrix(!1)}get reflector(){return this._reflectorBaseNode}get target(){return this._reflectorBaseNode.target}getDepthNode(){if(this._depthNode===null){if(this._reflectorBaseNode.depth!==!0)throw new Error("THREE.ReflectorNode: Depth node can only be requested when the reflector is created with { depth: true }. ");this._depthNode=Oe(new Lv({defaultTexture:Cx.depthTexture,reflector:this._reflectorBaseNode}))}return this._depthNode}setup(e){return e.object.isQuadMesh||this._reflectorBaseNode.build(e),super.setup(e)}clone(){const e=new this.constructor(this.reflectorNode);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.offsetNode=this.offsetNode,e._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}}class AN extends Rt{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:r=new d.Tme,resolutionScale:s=1,generateMipmaps:a=!1,bounces:c=!0,depth:h=!1,samples:f=0}=t;this.textureNode=e,this.target=r,this.resolutionScale=s,t.resolution!==void 0&&((0,d.O4K)('ReflectorNode: The "resolution" parameter has been renamed to "resolutionScale".'),this.resolutionScale=t.resolution),this.generateMipmaps=a,this.bounces=c,this.depth=h,this.samples=f,this.updateBeforeType=c?xn.RENDER:xn.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){const r=this.resolutionScale;t.getDrawingBufferSize(Ex),e.setSize(Math.round(Ex.width*r),Math.round(Ex.height*r))}setup(e){return this._updateResolution(Cx,e.renderer),super.setup(e)}dispose(){super.dispose();for(const e of this.renderTargets.values())e.dispose()}getVirtualCamera(e){let t=this.virtualCameras.get(e);return t===void 0&&(t=e.clone(),this.virtualCameras.set(e,t)),t}getRenderTarget(e){let t=this.renderTargets.get(e);return t===void 0&&(t=new d.ACn(0,0,{type:d.cLu,samples:this.samples}),this.generateMipmaps===!0&&(t.texture.minFilter=d.FDw,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new d.$YQ),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&Rx)return!1;Rx=!0;const{scene:t,camera:r,renderer:s,material:a}=e,{target:c}=this,h=this.getVirtualCamera(r),f=this.getRenderTarget(h);s.getDrawingBufferSize(Ex),this._updateResolution(f,s),Ud.setFromMatrixPosition(c.matrixWorld),Pv.setFromMatrixPosition(r.matrixWorld),um.extractRotation(c.matrixWorld),Bu.set(0,0,1),Bu.applyMatrix4(um),hm.subVectors(Ud,Pv);const m=hm.dot(Bu)>0;let x=!1;if(m===!0&&this.forceUpdate===!1){if(this.hasOutput===!1){Rx=!1;return}x=!0}hm.reflect(Bu).negate(),hm.add(Ud),um.extractRotation(r.matrixWorld),wx.set(0,0,-1),wx.applyMatrix4(um),wx.add(Pv),Ax.subVectors(Ud,wx),Ax.reflect(Bu).negate(),Ax.add(Ud),h.coordinateSystem=r.coordinateSystem,h.position.copy(hm),h.up.set(0,1,0),h.up.applyMatrix4(um),h.up.reflect(Bu),h.lookAt(Ax),h.near=r.near,h.far=r.far,h.updateMatrixWorld(),h.projectionMatrix.copy(r.projectionMatrix),Dd.setFromNormalAndCoplanarPoint(Bu,Ud),Dd.applyMatrix4(h.matrixWorldInverse),ya.set(Dd.normal.x,Dd.normal.y,Dd.normal.z,Dd.constant);const _=h.projectionMatrix;dm.x=(Math.sign(ya.x)+_.elements[8])/_.elements[0],dm.y=(Math.sign(ya.y)+_.elements[9])/_.elements[5],dm.z=-1,dm.w=(1+_.elements[10])/_.elements[14],ya.multiplyScalar(1/ya.dot(dm));const v=0;_.elements[2]=ya.x,_.elements[6]=ya.y,_.elements[10]=s.coordinateSystem===d.JCZ?ya.z-v:ya.z+1-v,_.elements[14]=ya.w,this.textureNode.value=f.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=f.depthTexture),a.visible=!1;const T=s.getRenderTarget(),w=s.getMRT(),P=s.autoClear;s.setMRT(null),s.setRenderTarget(f),s.autoClear=!0;const C=t.name;t.name=(t.name||"Scene")+" [ Reflector ]",x?(s.clear(),this.hasOutput=!1):(s.render(t,h),this.hasOutput=!0),t.name=C,s.setMRT(w),s.setRenderTarget(T),s.autoClear=P,a.visible=!0,Rx=!1,this.forceUpdate=!1}get resolution(){return(0,d.O4K)('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale}set resolution(e){(0,d.O4K)('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale=e}}const EN=i=>Oe(new Lv(i)),Iv=new d.iKG(-1,1,1,-1,0,1);class CN extends d.u9r{constructor(e=!1){super();const t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new d.a$l([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new d.a$l(t,2))}}const RN=new CN;class fm extends d.Kj0{constructor(e=null){super(RN,e),this.camera=Iv,this.isQuadMesh=!0}renderAsync(e){return nn(this,null,function*(){(0,d.O4K)('QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),yield e.init(),e.render(this,Iv)})}render(e){e.render(this,Iv)}}const NN=new d.FM8;class PN extends _a{static get type(){return"RTTNode"}constructor(e,t=null,r=null,s={type:d.cLu}){const a=new d.ACn(t,r,s);super(a.texture,hi()),this.isRTTNode=!0,this.node=e,this.width=t,this.height=r,this.pixelRatio=1,this.renderTarget=a,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new fm(new Gi),this.updateBeforeType=xn.RENDER}get autoResize(){return this.width===null}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 r=e*this.pixelRatio,s=t*this.pixelRatio;this.renderTarget.setSize(r,s),this.textureNeedsUpdate=!0}setPixelRatio(e){this.pixelRatio=e,this.setSize(this.width,this.height)}updateBefore({renderer:e}){if(this.textureNeedsUpdate===!1&&this.autoUpdate===!1)return;if(this.textureNeedsUpdate=!1,this.autoResize===!0){const s=e.getPixelRatio(),a=e.getSize(NN),c=Math.floor(a.width*s),h=Math.floor(a.height*s);(c!==this.renderTarget.width||h!==this.renderTarget.height)&&(this.renderTarget.setSize(c,h),this.textureNeedsUpdate=!0)}let t="RTT";this.node.name&&(t=this.node.name+" [ "+t+" ]"),this._quadMesh.material.fragmentNode=this._rttNode,this._quadMesh.name=t;const r=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(r)}clone(){const e=new _a(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const ZM=(i,...e)=>Oe(new PN(Oe(i),...e)),LN=(i,...e)=>i.isSampleNode||i.isTextureNode?i:i.isPassNode?i.getTextureNode():ZM(i,...e),Fd=fe(([i,e,t],r)=>{let s;r.renderer.coordinateSystem===d.JCZ?(i=Ve(i.x,i.y.oneMinus()).mul(2).sub(1),s=At(ce(i,e),1)):s=At(ce(i.x,i.y.oneMinus(),e).mul(2).sub(1),1);const a=At(t.mul(s));return a.xyz.div(a.w)}),IN=fe(([i,e])=>{const t=e.mul(At(i,1)),r=t.xy.div(t.w).mul(.5).add(.5).toVar();return Ve(r.x,r.y.oneMinus())}),DN=fe(([i,e,t])=>{const r=fc(ji(e)),s=Vi(i.mul(r)).toVar(),a=ji(e,s).toVar(),c=ji(e,s.sub(Vi(2,0))).toVar(),h=ji(e,s.sub(Vi(1,0))).toVar(),f=ji(e,s.add(Vi(1,0))).toVar(),m=ji(e,s.add(Vi(2,0))).toVar(),x=ji(e,s.add(Vi(0,2))).toVar(),_=ji(e,s.add(Vi(0,1))).toVar(),v=ji(e,s.sub(Vi(0,1))).toVar(),T=ji(e,s.sub(Vi(0,2))).toVar(),w=ai(Cn(G(2).mul(h).sub(c),a)).toVar(),P=ai(Cn(G(2).mul(f).sub(m),a)).toVar(),C=ai(Cn(G(2).mul(_).sub(x),a)).toVar(),E=ai(Cn(G(2).mul(v).sub(T),a)).toVar(),D=Fd(i,a,t).toVar(),F=w.lessThan(P).select(D.sub(Fd(i.sub(Ve(G(1).div(r.x),0)),h,t)),D.negate().add(Fd(i.add(Ve(G(1).div(r.x),0)),f,t))),W=C.lessThan(E).select(D.sub(Fd(i.add(Ve(0,G(1).div(r.y))),_,t)),D.negate().add(Fd(i.sub(Ve(0,G(1).div(r.y))),v,t)));return Er(xa(F,W))}),UN=fe(([i])=>Hs(G(52.9829189).mul(Hs(ho(i,Ve(.06711056,.00583715)))))).setLayout({name:"interleavedGradientNoise",type:"float",inputs:[{name:"position",type:"vec2"}]});class FN extends Rt{static get type(){return"SampleNode"}constructor(e,t=null){super(),this.callback=e,this.uvNode=t,this.isSampleNode=!0}setup(){return this.sample(hi())}sample(e){return this.callback(e)}}const BN=(i,e=null)=>Oe(new FN(i,Oe(e)));class Ms extends Rt{static get type(){return"EventNode"}constructor(e,t){super("void"),this.eventType=e,this.callback=t,e===Ms.OBJECT?this.updateType=xn.OBJECT:e===Ms.MATERIAL?this.updateType=xn.RENDER:e===Ms.BEFORE_OBJECT?this.updateBeforeType=xn.OBJECT:e===Ms.BEFORE_MATERIAL&&(this.updateBeforeType=xn.RENDER)}update(e){this.callback(e)}updateBefore(e){this.callback(e)}}Ms.OBJECT="object",Ms.MATERIAL="material",Ms.BEFORE_OBJECT="beforeObject",Ms.BEFORE_MATERIAL="beforeMaterial";const Nx=(i,e)=>Oe(new Ms(i,e)).toStack(),ON=i=>Nx(Ms.OBJECT,i),kN=i=>Nx(Ms.MATERIAL,i),VN=i=>Nx(Ms.BEFORE_OBJECT,i),zN=i=>Nx(Ms.BEFORE_MATERIAL,i);class GN extends d.lb7{constructor(e,t,r=Float32Array){const s=ArrayBuffer.isView(e)?e:new r(e*t);super(s,t),this.isStorageInstancedBufferAttribute=!0}}class WN extends d.TlE{constructor(e,t,r=Float32Array){const s=ArrayBuffer.isView(e)?e:new r(e*t);super(s,t),this.isStorageBufferAttribute=!0}}const HN=(i,e="float")=>{let t,r;e.isStruct===!0?(t=e.layout.getLength(),r=el("float")):(t=eu(e),r=el(e));const s=new WN(i,t,r);return Iu(s,e,i)},$N=(i,e="float")=>{let t,r;e.isStruct===!0?(t=e.layout.getLength(),r=el("float")):(t=eu(e),r=el(e));const s=new GN(i,t,r);return Iu(s,e,i)};class jN extends Rt{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const XN=pt(jN),pm=new d.USm,Dv=new d.yGw;class ws extends Rt{static get type(){return"SceneNode"}constructor(e=ws.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,r=this.scene!==null?this.scene:e.scene;let s;return t===ws.BACKGROUND_BLURRINESS?s=xi("backgroundBlurriness","float",r):t===ws.BACKGROUND_INTENSITY?s=xi("backgroundIntensity","float",r):t===ws.BACKGROUND_ROTATION?s=Bt("mat4").setName("backgroundRotation").setGroup(Ft).onRenderUpdate(()=>{const a=r.background;return a!==null&&a.isTexture&&a.mapping!==d.xfE?(pm.copy(r.backgroundRotation),pm.x*=-1,pm.y*=-1,pm.z*=-1,Dv.makeRotationFromEuler(pm)):Dv.identity(),Dv}):(0,d.vUy)("SceneNode: Unknown scope:",t),s}}ws.BACKGROUND_BLURRINESS="backgroundBlurriness",ws.BACKGROUND_INTENSITY="backgroundIntensity",ws.BACKGROUND_ROTATION="backgroundRotation";const YM=pt(ws,ws.BACKGROUND_BLURRINESS),Uv=pt(ws,ws.BACKGROUND_INTENSITY),QM=pt(ws,ws.BACKGROUND_ROTATION);class qN extends _a{static get type(){return"StorageTextureNode"}constructor(e,t,r=null){super(e,t),this.storeNode=r,this.mipLevel=0,this.isStorageTextureNode=!0,this.access=yr.WRITE_ONLY}getInputType(){return"storageTexture"}setup(e){super.setup(e);const t=e.getNodeProperties(this);return t.storeNode=this.storeNode,t}setAccess(e){return this.access=e,this}setMipLevel(e){return this.mipLevel=e,this}generate(e,t){let r;return this.storeNode!==null?r=this.generateStore(e):r=super.generate(e,t),r}toReadWrite(){return this.setAccess(yr.READ_WRITE)}toReadOnly(){return this.setAccess(yr.READ_ONLY)}toWriteOnly(){return this.setAccess(yr.WRITE_ONLY)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:r,storeNode:s,depthNode:a}=t,c=super.generate(e,"property"),h=r.build(e,this.value.is3DTexture===!0?"uvec3":"uvec2"),f=s.build(e,"vec4"),m=a?a.build(e,"int"):null,x=e.generateTextureStore(e,c,h,m,f);e.addLineFlowCode(x,this)}clone(){const e=super.clone();return e.storeNode=this.storeNode,e.mipLevel=this.mipLevel,e}}const JM=sn(qN).setParameterLength(1,3),KN=(i,e,t)=>{const r=JM(i,e,t);return t!==null&&r.toStack(),r},ZN=fe(({texture:i,uv:e})=>{const r=ce().toVar();return Dt(e.x.lessThan(1e-4),()=>{r.assign(ce(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{r.assign(ce(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{r.assign(ce(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{r.assign(ce(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{r.assign(ce(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{r.assign(ce(0,0,-1))}).Else(()=>{const a=i.sample(e.add(ce(-.01,0,0))).r.sub(i.sample(e.add(ce(.01,0,0))).r),c=i.sample(e.add(ce(0,-.01,0))).r.sub(i.sample(e.add(ce(0,.01,0))).r),h=i.sample(e.add(ce(0,0,-.01))).r.sub(i.sample(e.add(ce(0,0,.01))).r);r.assign(ce(a,c,h))}),r.normalize()});class YN extends _a{static get type(){return"Texture3DNode"}constructor(e,t=null,r=null){super(e,t,r),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return ce(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){const r=this.value;return e.isFlipY()&&(r.isRenderTargetTexture===!0||r.isFramebufferTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(re(fc(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,this.sampler===!0?"vec3":"ivec3")}generateOffset(e,t){return t.build(e,"ivec3")}normal(e){return ZN({texture:this,uv:e})}}const ew=sn(YN).setParameterLength(1,3);class QN extends sx{static get type(){return"UserDataNode"}constructor(e,t,r=null){super(e,t,r),this.userData=r}updateReference(e){return this.reference=this.userData!==null?this.userData:e.object.userData,this.reference}}const JN=(i,e,t)=>Oe(new QN(i,e,t)),tw=new WeakMap;class eP extends Oi{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=xn.OBJECT,this.updateAfterType=xn.OBJECT,this.previousModelWorldMatrix=Bt(new d.yGw),this.previousProjectionMatrix=Bt(new d.yGw).setGroup(Ft),this.previousCameraViewMatrix=Bt(new d.yGw)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:r}){const s=iw(r);this.previousModelWorldMatrix.value.copy(s);const a=nw(t);a.frameId!==e&&(a.frameId=e,a.previousProjectionMatrix===void 0?(a.previousProjectionMatrix=new d.yGw,a.previousCameraViewMatrix=new d.yGw,a.currentProjectionMatrix=new d.yGw,a.currentCameraViewMatrix=new d.yGw,a.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),a.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(a.previousProjectionMatrix.copy(a.currentProjectionMatrix),a.previousCameraViewMatrix.copy(a.currentCameraViewMatrix)),a.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),a.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(a.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(a.previousCameraViewMatrix))}updateAfter({object:e}){iw(e).copy(e.matrixWorld)}setup(){const e=this.projectionMatrix===null?po:Bt(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),r=e.mul(_c).mul(er),s=this.previousProjectionMatrix.mul(t).mul(nx),a=r.xy.div(r.w),c=s.xy.div(s.w);return Cn(a,c)}}function nw(i){let e=tw.get(i);return e===void 0&&(e={},tw.set(i,e)),e}function iw(i,e=0){const t=nw(i);let r=t[e];return r===void 0&&(t[e]=r=new d.yGw,t[e].copy(i.matrixWorld)),r}const tP=pt(eP),nP=fe(([i])=>Fv(i.rgb)),iP=fe(([i,e=G(1)])=>e.mix(Fv(i.rgb),i.rgb)),rP=fe(([i,e=G(1)])=>{const t=Yi(i.r,i.g,i.b).div(3),r=i.r.max(i.g.max(i.b)),s=r.sub(t).mul(e).mul(-3);return Xn(i.rgb,r,s)}),sP=fe(([i,e=G(1)])=>{const t=ce(.57735,.57735,.57735),r=e.cos();return ce(i.rgb.mul(r).add(t.cross(i.rgb).mul(e.sin()).add(t.mul(ho(t,i.rgb).mul(r.oneMinus())))))}),Fv=(i,e=ce(d.epp.getLuminanceCoefficients(new d.Pa4)))=>ho(i,e),oP=fe(([i,e=ce(1),t=ce(0),r=ce(1),s=G(1),a=ce(d.epp.getLuminanceCoefficients(new d.Pa4,d.GUF))])=>{const c=i.rgb.dot(ce(a)),h=Mi(i.rgb.mul(e).add(t),0).toVar(),f=h.pow(r).toVar();return Dt(h.r.greaterThan(0),()=>{h.r.assign(f.r)}),Dt(h.g.greaterThan(0),()=>{h.g.assign(f.g)}),Dt(h.b.greaterThan(0),()=>{h.b.assign(f.b)}),h.assign(c.add(h.sub(c).mul(s))),At(h.rgb,i.a)});class aP extends Oi{static get type(){return"PosterizeNode"}constructor(e,t){super(),this.sourceNode=e,this.stepsNode=t}setup(){const{sourceNode:e,stepsNode:t}=this;return e.mul(t).floor().div(t)}}const cP=sn(aP).setParameterLength(2),Px=new d.FM8;class rw extends _a{static get type(){return"PassTextureNode"}constructor(e,t){super(t),this.passNode=e,this.setUpdateMatrix(!1)}setup(e){return this.passNode.build(e),super.setup(e)}clone(){return new this.constructor(this.passNode,this.value)}}class sw extends rw{static get type(){return"PassMultipleTextureNode"}constructor(e,t,r=!1){super(e,null),this.textureName=t,this.previousTexture=r}updateTexture(){this.value=this.previousTexture?this.passNode.getPreviousTexture(this.textureName):this.passNode.getTexture(this.textureName)}setup(e){return this.updateTexture(),super.setup(e)}clone(){const e=new this.constructor(this.passNode,this.textureName,this.previousTexture);return e.uvNode=this.uvNode,e.levelNode=this.levelNode,e.biasNode=this.biasNode,e.sampler=this.sampler,e.depthNode=this.depthNode,e.compareNode=this.compareNode,e.gradNode=this.gradNode,e.offsetNode=this.offsetNode,e}}class ba extends Oi{static get type(){return"PassNode"}constructor(e,t,r,s={}){super("vec4"),this.scope=e,this.scene=t,this.camera=r,this.options=s,this._pixelRatio=1,this._width=1,this._height=1;const a=new d.$YQ;a.isRenderTargetTexture=!0,a.name="depth";const c=new d.ACn(this._width*this._pixelRatio,this._height*this._pixelRatio,rr({type:d.cLu},s));c.texture.name="output",c.depthTexture=a,this.renderTarget=c,this._textures={output:c.texture,depth:a},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=Bt(0),this._cameraFar=Bt(0),this._mrt=null,this._layers=null,this._resolutionScale=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=xn.FRAME,this.global=!0}setResolutionScale(e){return this._resolutionScale=e,this}getResolutionScale(){return this._resolutionScale}setResolution(e){return(0,d.ZK6)("PassNode: .setResolution() is deprecated. Use .setResolutionScale() instead."),this.setResolutionScale(e)}getResolution(){return(0,d.ZK6)("PassNode: .getResolution() is deprecated. Use .getResolutionScale() instead."),this.getResolutionScale()}setLayers(e){return this._layers=e,this}getLayers(){return this._layers}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getTexture(e){let t=this._textures[e];return t===void 0&&(t=this.renderTarget.texture.clone(),t.name=e,this._textures[e]=t,this.renderTarget.textures.push(t)),t}getPreviousTexture(e){let t=this._previousTextures[e];return t===void 0&&(t=this.getTexture(e).clone(),this._previousTextures[e]=t),t}toggleTexture(e){const t=this._previousTextures[e];if(t!==void 0){const r=this._textures[e],s=this.renderTarget.textures.indexOf(r);this.renderTarget.textures[s]=t,this._textures[e]=t,this._previousTextures[e]=r,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return t===void 0&&(t=Oe(new sw(this,e)),t.updateTexture(),this._textureNodes[e]=t),t}getPreviousTextureNode(e="output"){let t=this._previousTextureNodes[e];return t===void 0&&(this._textureNodes[e]===void 0&&this.getTextureNode(e),t=Oe(new sw(this,e,!0)),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===void 0){const r=this._cameraNear,s=this._cameraFar;this._viewZNodes[e]=t=ov(this.getTextureNode(e),r,s)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(t===void 0){const r=this._cameraNear,s=this._cameraFar,a=this.getViewZNode(e);this._linearDepthNodes[e]=t=Rd(a,r,s)}return t}compileAsync(e){return nn(this,null,function*(){const t=e.getRenderTarget(),r=e.getMRT();e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),yield e.compileAsync(this.scene,this.camera),e.setRenderTarget(t),e.setMRT(r)})}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,this.renderTarget.texture.type=e.getColorBufferType(),this.scope===ba.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:r}=this;let s,a;const c=t.getOutputRenderTarget();c&&c.isXRRenderTarget===!0?(a=1,s=t.xr.getCamera(),t.xr.updateCamera(s),Px.set(c.width,c.height)):(s=this.camera,a=t.getPixelRatio(),t.getSize(Px)),this._pixelRatio=a,this.setSize(Px.width,Px.height);const h=t.getRenderTarget(),f=t.getMRT(),m=t.autoClear,x=s.layers.mask;this._cameraNear.value=s.near,this._cameraFar.value=s.far,this._layers!==null&&(s.layers.mask=this._layers.mask);for(const v in this._previousTextures)this.toggleTexture(v);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.autoClear=!0;const _=r.name;r.name=this.name?this.name:r.name,t.render(r,s),r.name=_,t.setRenderTarget(h),t.setMRT(f),t.autoClear=m,s.layers.mask=x}setSize(e,t){this._width=e,this._height=t;const r=Math.floor(this._width*this._pixelRatio*this._resolutionScale),s=Math.floor(this._height*this._pixelRatio*this._resolutionScale);this.renderTarget.setSize(r,s),this._scissor!==null&&this.renderTarget.scissor.copy(this._scissor),this._viewport!==null&&this.renderTarget.viewport.copy(this._viewport)}setScissor(e,t,r,s){e===null?this._scissor=null:(this._scissor===null&&(this._scissor=new d.Ltg),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,r,s),this._scissor.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setViewport(e,t,r,s){e===null?this._viewport=null:(this._viewport===null&&(this._viewport=new d.Ltg),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,r,s),this._viewport.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}ba.COLOR="color",ba.DEPTH="depth";const lP=(i,e,t)=>Oe(new ba(ba.COLOR,i,e,t)),uP=(i,e)=>Oe(new rw(i,e)),hP=(i,e,t)=>Oe(new ba(ba.DEPTH,i,e,t));class dP extends ba{static get type(){return"ToonOutlinePassNode"}constructor(e,t,r,s,a){super(ba.COLOR,e,t),this.colorNode=r,this.thicknessNode=s,this.alphaNode=a,this._materialCache=new WeakMap,this.name="Outline Pass"}updateBefore(e){const{renderer:t}=e,r=t.getRenderObjectFunction();t.setRenderObjectFunction((s,a,c,h,f,m,x,_)=>{if((f.isMeshToonMaterial||f.isMeshToonNodeMaterial)&&f.wireframe===!1){const v=this._getOutlineMaterial(f);t.renderObject(s,a,c,h,v,m,x,_)}t.renderObject(s,a,c,h,f,m,x,_)}),super.updateBefore(e),t.setRenderObjectFunction(r)}_createMaterial(){const e=new Gi;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=d._Li;const t=Ss.negate(),r=po.mul(_c),s=G(1),a=r.mul(At(er,1)),c=r.mul(At(er.add(t),1)),h=Er(a.sub(c));return e.vertexNode=a.add(h.mul(this.thicknessNode).mul(a.w).mul(s)),e.colorNode=At(this.colorNode,this.alphaNode),e}_getOutlineMaterial(e){let t=this._materialCache.get(e);return t===void 0&&(t=this._createMaterial(),this._materialCache.set(e,t)),t}}const fP=(i,e,t=new d.Ilk(0,0,0),r=.003,s=1)=>Oe(new dP(i,e,Oe(t),Oe(r),Oe(s))),ow=fe(([i,e])=>i.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),aw=fe(([i,e])=>(i=i.mul(e),i.div(i.add(1)).clamp())).setLayout({name:"reinhardToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),cw=fe(([i,e])=>{i=i.mul(e),i=i.sub(.004).max(0);const t=i.mul(i.mul(6.2).add(.5)),r=i.mul(i.mul(6.2).add(1.7)).add(.06);return t.div(r).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),pP=fe(([i])=>{const e=i.mul(i.add(.0245786)).sub(90537e-9),t=i.mul(i.add(.432951).mul(.983729)).add(.238081);return e.div(t)}),lw=fe(([i,e])=>{const t=Ni(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),r=Ni(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return i=i.mul(e).div(.6),i=t.mul(i),i=pP(i),i=r.mul(i),i.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),mP=Ni(ce(1.6605,-.1246,-.0182),ce(-.5876,1.1329,-.1006),ce(-.0728,-.0083,1.1187)),gP=Ni(ce(.6274,.0691,.0164),ce(.3293,.9195,.088),ce(.0433,.0113,.8956)),xP=fe(([i])=>{const e=ce(i).toVar(),t=ce(e.mul(e)).toVar(),r=ce(t.mul(t)).toVar();return G(15.5).mul(r.mul(t)).sub(cn(40.14,r.mul(e))).add(cn(31.96,r).sub(cn(6.868,t.mul(e))).add(cn(.4298,t).add(cn(.1191,e).sub(.00232))))}),uw=fe(([i,e])=>{const t=ce(i).toVar(),r=Ni(ce(.856627153315983,.137318972929847,.11189821299995),ce(.0951212405381588,.761241990602591,.0767994186031903),ce(.0482516061458583,.101439036467562,.811302368396859)),s=Ni(ce(1.1271005818144368,-.1413297634984383,-.14132976349843826),ce(-.11060664309660323,1.157823702216272,-.11060664309660294),ce(-.016493938717834573,-.016493938717834257,1.2519364065950405)),a=G(-12.47393),c=G(4.026069);return t.mulAssign(e),t.assign(gP.mul(t)),t.assign(r.mul(t)),t.assign(Mi(t,1e-10)),t.assign(Wo(t)),t.assign(t.sub(a).div(c.sub(a))),t.assign(ys(t,0,1)),t.assign(xP(t)),t.assign(s.mul(t)),t.assign(kr(Mi(ce(0),t),ce(2.2))),t.assign(mP.mul(t)),t.assign(ys(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),hw=fe(([i,e])=>{const t=G(.76),r=G(.15);i=i.mul(e);const s=Kn(i.r,Kn(i.g,i.b)),a=S(s.lessThan(.08),s.sub(cn(6.25,s.mul(s))),.04);i.subAssign(a);const c=Mi(i.r,Mi(i.g,i.b));Dt(c.lessThan(t),()=>i);const h=Cn(1,t),f=Cn(1,h.mul(h).div(c.add(h.sub(t))));i.mulAssign(f.div(c));const m=Cn(1,cs(1,r.mul(c.sub(f)).add(1)));return Xn(i,ce(f),m)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class Cr extends Rt{static get type(){return"CodeNode"}constructor(e="",t=[],r=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=r}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 r=e.getCodeFromNode(this,this.getNodeType(e));return r.code=this.code,r.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}}const Lx=sn(Cr).setParameterLength(1,3),_P=(i,e)=>Lx(i,e,"js"),yP=(i,e)=>Lx(i,e,"wgsl"),bP=(i,e)=>Lx(i,e,"glsl");class dw extends Cr{static get type(){return"FunctionNode"}constructor(e="",t=[],r=""){super(e,t,r)}getNodeType(e){return this.getNodeFunction(e).type}getMemberType(e,t){const r=this.getNodeType(e);return e.getStructTypeNode(r).getMemberType(e,t)}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let r=t.nodeFunction;return r===void 0&&(r=e.parser.parseFunction(this.code),t.nodeFunction=r),r}generate(e,t){super.generate(e);const r=this.getNodeFunction(e),s=r.name,a=r.type,c=e.getCodeFromNode(this,a);s!==""&&(c.name=s);const h=e.getPropertyName(c),f=this.getNodeFunction(e).getCode(h);return c.code=f+`
`,t==="property"?h:e.format(`${h}()`,a,t)}}const fw=(i,e=[],t="")=>{for(let a=0;a<e.length;a++){const c=e[a];typeof c=="function"&&(e[a]=c.functionNode)}const r=Oe(new dw(i,e,t)),s=(...a)=>r.call(...a);return s.functionNode=r,s},vP=(i,e)=>fw(i,e,"glsl"),SP=(i,e)=>fw(i,e,"wgsl");class TP extends Rt{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new d.pBf,this.isScriptableValueNode=!0}get isScriptableOutputNode(){return this.outputType!==null}set value(e){this._value!==e&&(this._cache&&this.inputType==="URL"&&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&&this._cache===null&&this.inputType==="URL"&&e.value instanceof ArrayBuffer)this._cache=URL.createObjectURL(new Blob([e.value]));else if(e&&e.value!==null&&e.value!==void 0&&((this.inputType==="URL"||this.inputType==="String")&&typeof e.value=="string"||this.inputType==="Number"&&typeof e.value=="number"||this.inputType==="Vector2"&&e.value.isVector2||this.inputType==="Vector3"&&e.value.isVector3||this.inputType==="Vector4"&&e.value.isVector4||this.inputType==="Color"&&e.value.isColor||this.inputType==="Matrix3"&&e.value.isMatrix3||this.inputType==="Matrix4"&&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:G()}serialize(e){super.serialize(e),this.value!==null?this.inputType==="ArrayBuffer"?e.value=xp(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;e.value!==null&&(e.inputType==="ArrayBuffer"?t=ed(e.value):e.inputType==="Texture"?t=e.meta.textures[e.value]:t=e.meta.nodes[e.value]||null),this.value=t,this.inputType=e.inputType,this.outputType=e.outputType}}const Ix=sn(TP).setParameterLength(1);class pw extends Map{get(e,t=null,...r){if(this.has(e))return super.get(e);if(t!==null){const s=t(...r);return this.set(e,s),s}}}class MP{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 Dx=new pw;class wP extends Rt{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new pw,this._output=Ix(null),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 r=this._outputs;return r[e]===void 0?r[e]=Ix(t):r[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const r=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),r[e]=t,r[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),r[e]=t,r[e].events.addEventListener("refresh",this.onRefresh)):r[e]===void 0?(r[e]=Ix(t),r[e].events.addEventListener("refresh",this.onRefresh)):r[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(typeof s=="function")return s(...t)}callAsync(e,...t){return nn(this,null,function*(){const s=this.getObject()[e];if(typeof s=="function")return s.constructor.name==="AsyncFunction"?yield s(...t):s(...t)})}getNodeType(e){return this.getDefaultOutputNode().getNodeType(e)}refresh(e=null){e!==null?this.getOutput(e).refresh():this._refresh()}getObject(){if(this.needsUpdate&&this.dispose(),this._object!==null)return this._object;const e=()=>this.refresh(),t=(m,x)=>this.setOutput(m,x),r=new MP(this),s=Dx.get("THREE"),a=Dx.get("TSL"),c=this.getMethod(),h=[r,this._local,Dx,e,t,s,a];this._object=c(...h);const f=this._object.layout;if(f&&(f.cache===!1&&this._local.clear(),this._output.outputType=f.outputType||null,Array.isArray(f.elements)))for(const m of f.elements){const x=m.id||m.name;m.inputType&&(this.getParameter(x)===void 0&&this.setParameter(x,null),this.getParameter(x).inputType=m.inputType),m.outputType&&(this.getOutput(x)===void 0&&this.setOutput(x,null),this.getOutput(x).outputType=m.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const t in this.parameters){let r=this.parameters[t];r.isScriptableNode&&(r=r.getDefaultOutput()),r.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:G()}getDefaultOutput(){return this._exec()._output}getMethod(){if(this.needsUpdate&&this.dispose(),this._method!==null)return this._method;const e=["parameters","local","global","refresh","setOutput","THREE","TSL"],r=["layout","init","main","dispose"].join(", "),s="var "+r+`; var output = {};
`,a=`
return { ...output, `+r+" };",c=s+this.codeNode.code+a;return this._method=new Function(...e,c),this._method}dispose(){this._method!==null&&(this._object&&typeof this._object.dispose=="function"&&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=[Jc(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const r in this.parameters)t.push(this.parameters[r].getCacheKey(e));return Os(t)}set needsUpdate(e){e===!0&&this.dispose()}get needsUpdate(){return this.source!==this._source}_exec(){return this.codeNode===null?this:(this._needsOutputUpdate===!0&&(this._value=this.call("main"),this._needsOutputUpdate=!1),this._output.value=this._value,this)}_refresh(){this.needsUpdate=!0,this._exec(),this._output.refresh()}}const AP=sn(wP).setParameterLength(1,2);function mw(i){let e;const t=i.context.getViewZ;return t!==void 0&&(e=t(this)),(e||tr.z).negate()}const Bv=fe(([i,e],t)=>{const r=mw(t);return bs(i,e,r)}),Ov=fe(([i],e)=>{const t=mw(e);return i.mul(i,t,t).negate().exp().oneMinus()}),mm=fe(([i,e])=>At(e.toFloat().mix(ac.rgb,i.toVec3()),ac.a));function EP(i,e,t){return(0,d.ZK6)('TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),mm(i,Bv(e,t))}function CP(i,e){return(0,d.ZK6)('TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),mm(i,Ov(e))}let Ou=null,ku=null;class RP extends Rt{static get type(){return"RangeNode"}constructor(e=G(),t=G()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=this.getConstNode(this.minNode),r=this.getConstNode(this.maxNode),s=e.getTypeLength(ko(t.value)),a=e.getTypeLength(ko(r.value));return s>a?s:a}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}getConstNode(e){let t=null;if(e.traverse(r=>{r.isConstNode===!0&&(t=r)}),t===null)throw new Error('THREE.TSL: No "ConstNode" found in node graph.');return t}setup(e){const t=e.object;let r=null;if(t.count>1){const s=this.getConstNode(this.minNode),a=this.getConstNode(this.maxNode),c=s.value,h=a.value,f=e.getTypeLength(ko(c)),m=e.getTypeLength(ko(h));Ou=Ou||new d.Ltg,ku=ku||new d.Ltg,Ou.setScalar(0),ku.setScalar(0),f===1?Ou.setScalar(c):c.isColor?Ou.set(c.r,c.g,c.b,1):Ou.set(c.x,c.y,c.z||0,c.w||0),m===1?ku.setScalar(h):h.isColor?ku.set(h.r,h.g,h.b,1):ku.set(h.x,h.y,h.z||0,h.w||0);const x=4,_=x*t.count,v=new Float32Array(_);for(let w=0;w<_;w++){const P=w%x,C=Ou.getComponent(P),E=ku.getComponent(P);v[w]=d.M8C.lerp(C,E,Math.random())}const T=this.getNodeType(e);if(t.count<=4096)r=qp(v,"vec4",t.count).element(gl).convert(T);else{const w=new d.lb7(v,4);e.geometry.setAttribute("__range"+this.id,w),r=Ru(w).convert(T)}}else r=G(0);return r}}const NP=sn(RP).setParameterLength(2);class PP extends Rt{static get type(){return"ComputeBuiltinNode"}constructor(e,t){super(t),this._builtinName=e}getHash(e){return this.getBuiltinName(e)}getNodeType(){return this.nodeType}setBuiltinName(e){return this._builtinName=e,this}getBuiltinName(){return this._builtinName}hasBuiltin(e){return e.hasBuiltin(this._builtinName)}generate(e,t){const r=this.getBuiltinName(e),s=this.getNodeType(e);return e.shaderStage==="compute"?e.format(r,s,t):((0,d.ZK6)(`ComputeBuiltinNode: Compute built-in value ${r} can not be accessed in the ${e.shaderStage} stage`),e.generateConst(s))}serialize(e){super.serialize(e),e.global=this.global,e._builtinName=this._builtinName}deserialize(e){super.deserialize(e),this.global=e.global,this._builtinName=e._builtinName}}const gm=(i,e)=>Oe(new PP(i,e)),LP=gm("numWorkgroups","uvec3"),IP=gm("workgroupId","uvec3"),DP=gm("globalId","uvec3"),UP=gm("localId","uvec3"),FP=gm("subgroupSize","uint");class BP extends Rt{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:r}=e;r.backend.isWebGLBackend===!0?e.addFlowCode(` // ${t}Barrier
`):e.addLineFlowCode(`${t}Barrier()`,this)}}const kv=sn(BP),OP=()=>kv("workgroup").toStack(),kP=()=>kv("storage").toStack(),VP=()=>kv("texture").toStack();class zP extends ec{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let r;const s=e.context.assign;if(r=super.generate(e),s!==!0){const a=this.getNodeType(e);r=e.format(r,a,t)}return r}}class GP extends Rt{constructor(e,t,r=0){super(t),this.bufferType=t,this.bufferCount=r,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e,this.name=""}setName(e){return this.name=e,this}label(e){return(0,d.ZK6)('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setScope(e){return this.scope=e,this}getElementType(){return this.elementType}getInputType(){return`${this.scope}Array`}element(e){return Oe(new zP(this,e))}generate(e){const t=this.name!==""?this.name:`${this.scope}Array_${this.id}`;return e.getScopedArray(t,this.scope.toLowerCase(),this.bufferType,this.bufferCount)}}const WP=(i,e)=>Oe(new GP("Workgroup",i,e));class Sr extends Rt{static get type(){return"AtomicFunctionNode"}constructor(e,t,r){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=r,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=e.getNodeProperties(this),r=t.parents,s=this.method,a=this.getNodeType(e),c=this.getInputType(e),h=this.pointerNode,f=this.valueNode,m=[];m.push(`&${h.build(e,c)}`),f!==null&&m.push(f.build(e,c));const x=`${e.getMethod(s,a)}( ${m.join(", ")} )`;if(r?r.length===1&&r[0].isStackNode===!0:!1)e.addLineFlowCode(x,this);else return t.constNode===void 0&&(t.constNode=ii(x,a).toConst()),t.constNode.build(e)}}Sr.ATOMIC_LOAD="atomicLoad",Sr.ATOMIC_STORE="atomicStore",Sr.ATOMIC_ADD="atomicAdd",Sr.ATOMIC_SUB="atomicSub",Sr.ATOMIC_MAX="atomicMax",Sr.ATOMIC_MIN="atomicMin",Sr.ATOMIC_AND="atomicAnd",Sr.ATOMIC_OR="atomicOr",Sr.ATOMIC_XOR="atomicXor";const HP=sn(Sr),va=(i,e,t)=>HP(i,e,t).toStack(),$P=i=>va(Sr.ATOMIC_LOAD,i,null),jP=(i,e)=>va(Sr.ATOMIC_STORE,i,e),XP=(i,e)=>va(Sr.ATOMIC_ADD,i,e),qP=(i,e)=>va(Sr.ATOMIC_SUB,i,e),KP=(i,e)=>va(Sr.ATOMIC_MAX,i,e),ZP=(i,e)=>va(Sr.ATOMIC_MIN,i,e),YP=(i,e)=>va(Sr.ATOMIC_AND,i,e),QP=(i,e)=>va(Sr.ATOMIC_OR,i,e),JP=(i,e)=>va(Sr.ATOMIC_XOR,i,e);class bt extends Oi{static get type(){return"SubgroupFunctionNode"}constructor(e,t=null,r=null){super(),this.method=e,this.aNode=t,this.bNode=r}getInputType(e){const t=this.aNode?this.aNode.getNodeType(e):null,r=this.bNode?this.bNode.getNodeType(e):null,s=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(r)?0:e.getTypeLength(r);return s>a?t:r}getNodeType(e){const t=this.method;return t===bt.SUBGROUP_ELECT?"bool":t===bt.SUBGROUP_BALLOT?"uvec4":this.getInputType(e)}generate(e,t){const r=this.method,s=this.getNodeType(e),a=this.getInputType(e),c=this.aNode,h=this.bNode,f=[];if(r===bt.SUBGROUP_BROADCAST||r===bt.SUBGROUP_SHUFFLE||r===bt.QUAD_BROADCAST){const x=h.getNodeType(e);f.push(c.build(e,s),h.build(e,x==="float"?"int":s))}else r===bt.SUBGROUP_SHUFFLE_XOR||r===bt.SUBGROUP_SHUFFLE_DOWN||r===bt.SUBGROUP_SHUFFLE_UP?f.push(c.build(e,s),h.build(e,"uint")):(c!==null&&f.push(c.build(e,a)),h!==null&&f.push(h.build(e,a)));const m=f.length===0?"()":`( ${f.join(", ")} )`;return e.format(`${e.getMethod(r,s)}${m}`,s,t)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}bt.SUBGROUP_ELECT="subgroupElect",bt.SUBGROUP_BALLOT="subgroupBallot",bt.SUBGROUP_ADD="subgroupAdd",bt.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd",bt.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd",bt.SUBGROUP_MUL="subgroupMul",bt.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul",bt.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul",bt.SUBGROUP_AND="subgroupAnd",bt.SUBGROUP_OR="subgroupOr",bt.SUBGROUP_XOR="subgroupXor",bt.SUBGROUP_MIN="subgroupMin",bt.SUBGROUP_MAX="subgroupMax",bt.SUBGROUP_ALL="subgroupAll",bt.SUBGROUP_ANY="subgroupAny",bt.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst",bt.QUAD_SWAP_X="quadSwapX",bt.QUAD_SWAP_Y="quadSwapY",bt.QUAD_SWAP_DIAGONAL="quadSwapDiagonal",bt.SUBGROUP_BROADCAST="subgroupBroadcast",bt.SUBGROUP_SHUFFLE="subgroupShuffle",bt.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor",bt.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp",bt.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown",bt.QUAD_BROADCAST="quadBroadcast";const eL=at(bt,bt.SUBGROUP_ELECT).setParameterLength(0),tL=at(bt,bt.SUBGROUP_BALLOT).setParameterLength(1),nL=at(bt,bt.SUBGROUP_ADD).setParameterLength(1),iL=at(bt,bt.SUBGROUP_INCLUSIVE_ADD).setParameterLength(1),rL=at(bt,bt.SUBGROUP_EXCLUSIVE_AND).setParameterLength(1),sL=at(bt,bt.SUBGROUP_MUL).setParameterLength(1),oL=at(bt,bt.SUBGROUP_INCLUSIVE_MUL).setParameterLength(1),aL=at(bt,bt.SUBGROUP_EXCLUSIVE_MUL).setParameterLength(1),cL=at(bt,bt.SUBGROUP_AND).setParameterLength(1),lL=at(bt,bt.SUBGROUP_OR).setParameterLength(1),uL=at(bt,bt.SUBGROUP_XOR).setParameterLength(1),hL=at(bt,bt.SUBGROUP_MIN).setParameterLength(1),dL=at(bt,bt.SUBGROUP_MAX).setParameterLength(1),fL=at(bt,bt.SUBGROUP_ALL).setParameterLength(0),pL=at(bt,bt.SUBGROUP_ANY).setParameterLength(0),mL=at(bt,bt.SUBGROUP_BROADCAST_FIRST).setParameterLength(2),gL=at(bt,bt.QUAD_SWAP_X).setParameterLength(1),xL=at(bt,bt.QUAD_SWAP_Y).setParameterLength(1),_L=at(bt,bt.QUAD_SWAP_DIAGONAL).setParameterLength(1),yL=at(bt,bt.SUBGROUP_BROADCAST).setParameterLength(2),bL=at(bt,bt.SUBGROUP_SHUFFLE).setParameterLength(2),vL=at(bt,bt.SUBGROUP_SHUFFLE_XOR).setParameterLength(2),SL=at(bt,bt.SUBGROUP_SHUFFLE_UP).setParameterLength(2),TL=at(bt,bt.SUBGROUP_SHUFFLE_DOWN).setParameterLength(2),ML=at(bt,bt.QUAD_BROADCAST).setParameterLength(1);let Ux;function Fx(i){Ux=Ux||new WeakMap;let e=Ux.get(i);return e===void 0&&Ux.set(i,e={}),e}function Bx(i){const e=Fx(i);return e.shadowMatrix||(e.shadowMatrix=Bt("mat4").setGroup(Ft).onRenderUpdate(t=>((i.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&(i.shadow.camera.coordinateSystem!==t.camera.coordinateSystem&&(i.shadow.camera.coordinateSystem=t.camera.coordinateSystem,i.shadow.camera.updateProjectionMatrix()),i.shadow.updateMatrices(i)),i.shadow.matrix)))}function gw(i,e=Ks){const t=Bx(i).mul(e);return t.xyz.div(t.w)}function Vv(i){const e=Fx(i);return e.position||(e.position=Bt(new d.Pa4).setGroup(Ft).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(i.matrixWorld)))}function xw(i){const e=Fx(i);return e.targetPosition||(e.targetPosition=Bt(new d.Pa4).setGroup(Ft).onRenderUpdate((t,r)=>r.value.setFromMatrixPosition(i.target.matrixWorld)))}function zv(i){const e=Fx(i);return e.viewPosition||(e.viewPosition=Bt(new d.Pa4).setGroup(Ft).onRenderUpdate(({camera:t},r)=>{r.value=r.value||new d.Pa4,r.value.setFromMatrixPosition(i.matrixWorld),r.value.applyMatrix4(t.matrixWorldInverse)}))}const Gv=i=>qs.transformDirection(Vv(i).sub(xw(i))),wL=i=>i.sort((e,t)=>e.id-t.id),AL=(i,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===i)return t;return null},Wv=new WeakMap,xm=[];class Hv extends Rt{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=Vs("vec3","totalDiffuse"),this.totalSpecularNode=Vs("vec3","totalSpecular"),this.outgoingLightNode=Vs("vec3","outgoingLight"),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=this._lights;for(let r=0;r<e.length;r++){const s=e[r];if(xm.push(s.id),xm.push(s.castShadow?1:0),s.isSpotLight===!0){const a=s.map!==null?s.map.id:-1,c=s.colorNode?s.colorNode.getCacheKey():-1;xm.push(a,c)}}const t=Os(xm);return xm.length=0,t}getHash(e){if(this._lightNodesHash===null){this._lightNodes===null&&this.setupLightsNode(e);const t=[];for(const r of this._lightNodes)t.push(r.getHash());this._lightNodesHash="lights-"+t.join(",")}return this._lightNodesHash}analyze(e){const t=e.getNodeProperties(this);for(const r of t.nodes)r.build(e);t.outputNode.build(e)}setupLightsNode(e){const t=[],r=this._lightNodes,s=wL(this._lights),a=e.renderer.library;for(const c of s)if(c.isNode)t.push(Oe(c));else{let h=null;if(r!==null&&(h=AL(c.id,r)),h===null){const f=a.getLightNodeClass(c.constructor);if(f===null){(0,d.ZK6)(`LightsNode.setupNodeLights: Light node not found for ${c.constructor.name}`);continue}let m=null;Wv.has(c)?m=Wv.get(c):(m=Oe(new f(c)),Wv.set(c,m)),t.push(m)}}this._lightNodes=t}setupDirectLight(e,t,r){const{lightingModel:s,reflectedLight:a}=e.context;s.direct(To(rr({},r),{lightNode:t,reflectedLight:a}),e)}setupDirectRectAreaLight(e,t,r){const{lightingModel:s,reflectedLight:a}=e.context;s.directRectArea(To(rr({},r),{lightNode:t,reflectedLight:a}),e)}setupLights(e,t){for(const r of t)r.build(e)}getLightNodes(e){return this._lightNodes===null&&this.setupLightsNode(e),this._lightNodes}setup(e){const t=e.lightsNode;e.lightsNode=this;let r=this.outgoingLightNode;const s=e.context,a=s.lightingModel,c=e.getNodeProperties(this);if(a){const{totalDiffuseNode:h,totalSpecularNode:f}=this;s.outgoingLight=r;const m=e.addStack();c.nodes=m.nodes,a.start(e);const{backdrop:x,backdropAlpha:_}=s,{directDiffuse:v,directSpecular:T,indirectDiffuse:w,indirectSpecular:P}=s.reflectedLight;let C=v.add(w);x!==null&&(_!==null?C=ce(_.mix(C,x)):C=ce(x)),h.assign(C),f.assign(T.add(P)),r.assign(h.add(f)),a.finish(e),r=r.bypass(e.removeStack())}else c.nodes=[];return e.lightsNode=t,r}setLights(e){return this._lights=e,this._lightNodes=null,this._lightNodesHash=null,this}getLights(){return this._lights}get hasLights(){return this._lights.length>0}}const EL=(i=[])=>Oe(new Hv).setLights(i);class CL extends Rt{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=xn.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){$v.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||Ks)}}const $v=Vs("vec3","shadowPositionWorld");function jv(i,e={}){return e.toneMapping=i.toneMapping,e.toneMappingExposure=i.toneMappingExposure,e.outputColorSpace=i.outputColorSpace,e.renderTarget=i.getRenderTarget(),e.activeCubeFace=i.getActiveCubeFace(),e.activeMipmapLevel=i.getActiveMipmapLevel(),e.renderObjectFunction=i.getRenderObjectFunction(),e.pixelRatio=i.getPixelRatio(),e.mrt=i.getMRT(),e.clearColor=i.getClearColor(e.clearColor||new d.Ilk),e.clearAlpha=i.getClearAlpha(),e.autoClear=i.autoClear,e.scissorTest=i.getScissorTest(),e}function _w(i,e){return e=jv(i,e),i.setMRT(null),i.setRenderObjectFunction(null),i.setClearColor(0,1),i.autoClear=!0,e}function yw(i,e){i.toneMapping=e.toneMapping,i.toneMappingExposure=e.toneMappingExposure,i.outputColorSpace=e.outputColorSpace,i.setRenderTarget(e.renderTarget,e.activeCubeFace,e.activeMipmapLevel),i.setRenderObjectFunction(e.renderObjectFunction),i.setPixelRatio(e.pixelRatio),i.setMRT(e.mrt),i.setClearColor(e.clearColor,e.clearAlpha),i.autoClear=e.autoClear,i.setScissorTest(e.scissorTest)}function Xv(i,e={}){return e.background=i.background,e.backgroundNode=i.backgroundNode,e.overrideMaterial=i.overrideMaterial,e}function bw(i,e){return e=Xv(i,e),i.background=null,i.backgroundNode=null,i.overrideMaterial=null,e}function vw(i,e){i.background=e.background,i.backgroundNode=e.backgroundNode,i.overrideMaterial=e.overrideMaterial}function RL(i,e,t={}){return t=jv(i,t),t=Xv(e,t),t}function Sw(i,e,t){return t=_w(i,t),t=bw(e,t),t}function Tw(i,e,t){yw(i,t),vw(e,t)}var u4=Object.freeze({__proto__:null,resetRendererAndSceneState:Sw,resetRendererState:_w,resetSceneState:bw,restoreRendererAndSceneState:Tw,restoreRendererState:yw,restoreSceneState:vw,saveRendererAndSceneState:RL,saveRendererState:jv,saveSceneState:Xv});const Mw=new WeakMap,ww=fe(({depthTexture:i,shadowCoord:e,depthLayer:t})=>{let r=In(i,e.xy).setName("t_basic");return i.isArrayTexture&&(r=r.depth(t)),r.compare(e.z)}),Aw=fe(({depthTexture:i,shadowCoord:e,shadow:t,depthLayer:r})=>{const s=(C,E)=>{let D=In(i,C);return i.isArrayTexture&&(D=D.depth(r)),D.compare(E)},a=xi("mapSize","vec2",t).setGroup(Ft),c=xi("radius","float",t).setGroup(Ft),h=Ve(1).div(a),f=h.x.negate().mul(c),m=h.y.negate().mul(c),x=h.x.mul(c),_=h.y.mul(c),v=f.div(2),T=m.div(2),w=x.div(2),P=_.div(2);return Yi(s(e.xy.add(Ve(f,m)),e.z),s(e.xy.add(Ve(0,m)),e.z),s(e.xy.add(Ve(x,m)),e.z),s(e.xy.add(Ve(v,T)),e.z),s(e.xy.add(Ve(0,T)),e.z),s(e.xy.add(Ve(w,T)),e.z),s(e.xy.add(Ve(f,0)),e.z),s(e.xy.add(Ve(v,0)),e.z),s(e.xy,e.z),s(e.xy.add(Ve(w,0)),e.z),s(e.xy.add(Ve(x,0)),e.z),s(e.xy.add(Ve(v,P)),e.z),s(e.xy.add(Ve(0,P)),e.z),s(e.xy.add(Ve(w,P)),e.z),s(e.xy.add(Ve(f,_)),e.z),s(e.xy.add(Ve(0,_)),e.z),s(e.xy.add(Ve(x,_)),e.z)).mul(1/17)}),Ew=fe(({depthTexture:i,shadowCoord:e,shadow:t,depthLayer:r})=>{const s=(_,v)=>{let T=In(i,_);return i.isArrayTexture&&(T=T.depth(r)),T.compare(v)},a=xi("mapSize","vec2",t).setGroup(Ft),c=Ve(1).div(a),h=c.x,f=c.y,m=e.xy,x=Hs(m.mul(a).add(.5));return m.subAssign(x.mul(c)),Yi(s(m,e.z),s(m.add(Ve(h,0)),e.z),s(m.add(Ve(0,f)),e.z),s(m.add(c),e.z),Xn(s(m.add(Ve(h.negate(),0)),e.z),s(m.add(Ve(h.mul(2),0)),e.z),x.x),Xn(s(m.add(Ve(h.negate(),f)),e.z),s(m.add(Ve(h.mul(2),f)),e.z),x.x),Xn(s(m.add(Ve(0,f.negate())),e.z),s(m.add(Ve(0,f.mul(2))),e.z),x.y),Xn(s(m.add(Ve(h,f.negate())),e.z),s(m.add(Ve(h,f.mul(2))),e.z),x.y),Xn(Xn(s(m.add(Ve(h.negate(),f.negate())),e.z),s(m.add(Ve(h.mul(2),f.negate())),e.z),x.x),Xn(s(m.add(Ve(h.negate(),f.mul(2))),e.z),s(m.add(Ve(h.mul(2),f.mul(2))),e.z),x.x),x.y)).mul(1/9)}),Cw=fe(({depthTexture:i,shadowCoord:e,depthLayer:t})=>{const r=G(1).toVar();let s=In(i).sample(e.xy);i.isArrayTexture&&(s=s.depth(t)),s=s.rg;const a=Pi(e.z,s.x);return Dt(a.notEqual(G(1)),()=>{const c=e.z.sub(s.x),h=Mi(0,s.y.mul(s.y));let f=h.div(h.add(c.mul(c)));f=ys(Cn(f,.3).div(.95-.3)),r.assign(ys(Mi(a,f)))}),r}),NL=fe(([i,e,t])=>{let r=Ks.sub(i).length();return r=r.sub(e).div(t.sub(e)),r=r.saturate(),r}),PL=i=>{const e=i.shadow.camera,t=xi("near","float",e).setGroup(Ft),r=xi("far","float",e).setGroup(Ft),s=MT(i);return NL(s,t,r)},Rw=i=>{let e=Mw.get(i);if(e===void 0){const t=i.isPointLight?PL(i):null;e=new Gi,e.colorNode=At(0,0,0,1),e.depthNode=t,e.isShadowPassMaterial=!0,e.name="ShadowMaterial",e.fog=!1,Mw.set(i,e)}return e},Nw=new Xo,Bd=[],Pw=(i,e,t,r)=>{Bd[0]=i,Bd[1]=e;let s=Nw.get(Bd);return(s===void 0||s.shadowType!==t||s.useVelocity!==r)&&(s=(a,c,h,f,m,x,..._)=>{(a.castShadow===!0||a.receiveShadow&&t===d.dwk)&&(r&&(la(a).useVelocity=!0),a.onBeforeShadow(i,a,h,e.camera,f,c.overrideMaterial,x),i.renderObject(a,c,h,f,m,x,..._),a.onAfterShadow(i,a,h,e.camera,f,c.overrideMaterial,x))},s.shadowType=t,s.useVelocity=r,Nw.set(Bd,s)),Bd[0]=null,Bd[1]=null,s},LL=fe(({samples:i,radius:e,size:t,shadowPass:r,depthLayer:s})=>{const a=G(0).toVar("meanVertical"),c=G(0).toVar("squareMeanVertical"),h=i.lessThanEqual(G(1)).select(G(0),G(2).div(i.sub(1))),f=i.lessThanEqual(G(1)).select(G(0),G(-1));ci({start:re(0),end:re(i),type:"int",condition:"<"},({i:x})=>{const _=f.add(G(x).mul(h));let v=r.sample(Yi(Yp.xy,Ve(0,_).mul(e)).div(t));r.value.isArrayTexture&&(v=v.depth(s)),v=v.x,a.addAssign(v),c.addAssign(v.mul(v))}),a.divAssign(i),c.divAssign(i);const m=Br(c.sub(a.mul(a)));return Ve(a,m)}),IL=fe(({samples:i,radius:e,size:t,shadowPass:r,depthLayer:s})=>{const a=G(0).toVar("meanHorizontal"),c=G(0).toVar("squareMeanHorizontal"),h=i.lessThanEqual(G(1)).select(G(0),G(2).div(i.sub(1))),f=i.lessThanEqual(G(1)).select(G(0),G(-1));ci({start:re(0),end:re(i),type:"int",condition:"<"},({i:x})=>{const _=f.add(G(x).mul(h));let v=r.sample(Yi(Yp.xy,Ve(_,0).mul(e)).div(t));r.value.isArrayTexture&&(v=v.depth(s)),a.addAssign(v.x),c.addAssign(Yi(v.y.mul(v.y),v.x.mul(v.x)))}),a.divAssign(i),c.divAssign(i);const m=Br(c.sub(a.mul(a)));return Ve(a,m)}),DL=[ww,Aw,Ew,Cw];let qv;const Ox=new fm;class Lw extends CL{static get type(){return"ShadowNode"}constructor(e,t=null){super(e),this.shadow=t||e.shadow,this.shadowMap=null,this.vsmShadowMapVertical=null,this.vsmShadowMapHorizontal=null,this.vsmMaterialVertical=null,this.vsmMaterialHorizontal=null,this._node=null,this._currentShadowType=null,this._cameraFrameId=new WeakMap,this.isShadowNode=!0,this.depthLayer=0}setupShadowFilter(e,{filterFn:t,depthTexture:r,shadowCoord:s,shadow:a,depthLayer:c}){const h=s.x.greaterThanEqual(0).and(s.x.lessThanEqual(1)).and(s.y.greaterThanEqual(0)).and(s.y.lessThanEqual(1)).and(s.z.lessThanEqual(1)),f=t({depthTexture:r,shadowCoord:s,shadow:a,depthLayer:c});return h.select(f,G(1))}setupShadowCoord(e,t){const{shadow:r}=this,{renderer:s}=e,a=xi("bias","float",r).setGroup(Ft);let c=t,h;if(r.camera.isOrthographicCamera||s.logarithmicDepthBuffer!==!0)c=c.xyz.div(c.w),h=c.z,s.coordinateSystem===d.JCZ&&(h=h.mul(2).sub(1));else{const f=c.w;c=c.xy.div(f);const m=xi("near","float",r.camera).setGroup(Ft),x=xi("far","float",r.camera).setGroup(Ft);h=av(f.negate(),m,x)}return c=ce(c.x,c.y.oneMinus(),h.add(a)),c}getShadowFilterFn(e){return DL[e]}setupRenderTarget(e,t){const r=new d.$YQ(e.mapSize.width,e.mapSize.height);r.name="ShadowDepthTexture",r.compareFunction=d.D67;const s=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return s.texture.name="ShadowMap",s.texture.type=e.mapType,s.depthTexture=r,{shadowMap:s,depthTexture:r}}setupShadow(e){const{renderer:t,camera:r}=e,{light:s,shadow:a}=this,c=t.shadowMap.type,{depthTexture:h,shadowMap:f}=this.setupRenderTarget(a,e);if(a.camera.coordinateSystem=r.coordinateSystem,a.camera.updateProjectionMatrix(),c===d.dwk&&a.isPointLightShadow!==!0){h.compareFunction=null,f.depth>1?(f._vsmShadowMapVertical||(f._vsmShadowMapVertical=e.createRenderTarget(a.mapSize.width,a.mapSize.height,{format:d.av9,type:d.cLu,depth:f.depth,depthBuffer:!1}),f._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=f._vsmShadowMapVertical,f._vsmShadowMapHorizontal||(f._vsmShadowMapHorizontal=e.createRenderTarget(a.mapSize.width,a.mapSize.height,{format:d.av9,type:d.cLu,depth:f.depth,depthBuffer:!1}),f._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=f._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(a.mapSize.width,a.mapSize.height,{format:d.av9,type:d.cLu,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(a.mapSize.width,a.mapSize.height,{format:d.av9,type:d.cLu,depthBuffer:!1}));let F=In(h);h.isArrayTexture&&(F=F.depth(this.depthLayer));let W=In(this.vsmShadowMapVertical.texture);h.isArrayTexture&&(W=W.depth(this.depthLayer));const K=xi("blurSamples","float",a).setGroup(Ft),U=xi("radius","float",a).setGroup(Ft),j=xi("mapSize","vec2",a).setGroup(Ft);let oe=this.vsmMaterialVertical||(this.vsmMaterialVertical=new Gi);oe.fragmentNode=LL({samples:K,radius:U,size:j,shadowPass:F,depthLayer:this.depthLayer}).context(e.getSharedContext()),oe.name="VSMVertical",oe=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new Gi),oe.fragmentNode=IL({samples:K,radius:U,size:j,shadowPass:W,depthLayer:this.depthLayer}).context(e.getSharedContext()),oe.name="VSMHorizontal"}const m=xi("intensity","float",a).setGroup(Ft),x=xi("normalBias","float",a).setGroup(Ft),_=Bx(s).mul($v.add(ml.mul(x))),v=this.setupShadowCoord(e,_),T=a.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(T===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const w=c===d.dwk&&a.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:h,P=this.setupShadowFilter(e,{filterFn:T,shadowTexture:f.texture,depthTexture:w,shadowCoord:v,shadow:a,depthLayer:this.depthLayer});let C=In(f.texture,v);h.isArrayTexture&&(C=C.depth(this.depthLayer));const E=Xn(1,P.rgb.mix(C,1),m.mul(C.a)).toVar();this.shadowMap=f,this.shadow.map=f;const D=`${this.light.type} Shadow [ ${this.light.name||"ID: "+this.light.id} ]`;return E.toInspector(`${D} / Color`,()=>In(this.shadowMap.texture)).toInspector(`${D} / Depth`,()=>ji(this.shadowMap.depthTexture,hi().mul(fc(In(this.shadowMap.depthTexture)))).x.oneMinus())}setup(e){if(e.renderer.shadowMap.enabled!==!1)return fe(()=>{const t=e.renderer.shadowMap.type;this._currentShadowType!==t&&(this._reset(),this._node=null);let r=this._node;return this.setupShadowPosition(e),r===null&&(this._node=r=this.setupShadow(e),this._currentShadowType=t),e.material.shadowNode&&(0,d.ZK6)('NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(r=e.material.receivedShadowNode(r)),r})()}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:a,scene:c}=e;t.updateMatrices(s),r.setSize(t.mapSize.width,t.mapSize.height,r.depth);const h=c.name;c.name=`Shadow Map [ ${s.name||"ID: "+s.id} ]`,a.render(c,t.camera),c.name=h}updateShadow(e){const{shadowMap:t,light:r,shadow:s}=this,{renderer:a,scene:c,camera:h}=e,f=a.shadowMap.type,m=t.depthTexture.version;this._depthVersionCached=m;const x=s.camera.layers.mask;s.camera.layers.mask&4294967294||(s.camera.layers.mask=h.layers.mask);const _=a.getRenderObjectFunction(),v=a.getMRT(),T=v?v.has("velocity"):!1;qv=Sw(a,c,qv),c.overrideMaterial=Rw(r),a.setRenderObjectFunction(Pw(a,s,f,T)),a.setClearColor(0,0),a.setRenderTarget(t),this.renderShadow(e),a.setRenderObjectFunction(_),f===d.dwk&&s.isPointLightShadow!==!0&&this.vsmPass(a),s.camera.layers.mask=x,Tw(a,c,qv)}vsmPass(e){const{shadow:t}=this,r=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,r),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,r),e.setRenderTarget(this.vsmShadowMapVertical),Ox.material=this.vsmMaterialVertical,Ox.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),Ox.material=this.vsmMaterialHorizontal,Ox.render(e)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,this.shadowMap&&(this.shadowMap.dispose(),this.shadowMap=null),this.vsmShadowMapVertical!==null&&(this.vsmShadowMapVertical.dispose(),this.vsmShadowMapVertical=null,this.vsmMaterialVertical.dispose(),this.vsmMaterialVertical=null),this.vsmShadowMapHorizontal!==null&&(this.vsmShadowMapHorizontal.dispose(),this.vsmShadowMapHorizontal=null,this.vsmMaterialHorizontal.dispose(),this.vsmMaterialHorizontal=null)}updateBefore(e){const{shadow:t}=this;let r=t.needsUpdate||t.autoUpdate;r&&(this._cameraFrameId[e.camera]===e.frameId&&(r=!1),this._cameraFrameId[e.camera]=e.frameId),r&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const Iw=(i,e)=>Oe(new Lw(i,e)),UL=new d.Ilk,qo=fe(([i,e])=>{const t=i.toVar(),r=ai(t),s=cs(1,Mi(r.x,Mi(r.y,r.z)));r.mulAssign(s),t.mulAssign(s.mul(e.mul(2).oneMinus()));const a=Ve(t.xy).toVar(),h=e.mul(1.5).oneMinus();return Dt(r.z.greaterThanEqual(h),()=>{Dt(t.z.greaterThan(0),()=>{a.x.assign(Cn(4,t.x))})}).ElseIf(r.x.greaterThanEqual(h),()=>{const f=gd(t.x);a.x.assign(t.z.mul(f).add(f.mul(2)))}).ElseIf(r.y.greaterThanEqual(h),()=>{const f=gd(t.y);a.x.assign(t.x.add(f.mul(2)).add(2)),a.y.assign(t.z.mul(f).sub(2))}),Ve(.125,.25).mul(a).add(Ve(.375,.75)).flipY()}).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),Dw=fe(({depthTexture:i,bd3D:e,dp:t,texelSize:r})=>In(i,qo(e,r.y)).compare(t)),Uw=fe(({depthTexture:i,bd3D:e,dp:t,texelSize:r,shadow:s})=>{const a=xi("radius","float",s).setGroup(Ft),c=Ve(-1,1).mul(a).mul(r.y);return In(i,qo(e.add(c.xyy),r.y)).compare(t).add(In(i,qo(e.add(c.yyy),r.y)).compare(t)).add(In(i,qo(e.add(c.xyx),r.y)).compare(t)).add(In(i,qo(e.add(c.yyx),r.y)).compare(t)).add(In(i,qo(e,r.y)).compare(t)).add(In(i,qo(e.add(c.xxy),r.y)).compare(t)).add(In(i,qo(e.add(c.yxy),r.y)).compare(t)).add(In(i,qo(e.add(c.xxx),r.y)).compare(t)).add(In(i,qo(e.add(c.yxx),r.y)).compare(t)).mul(1/9)}),FL=fe(({filterFn:i,depthTexture:e,shadowCoord:t,shadow:r})=>{const s=t.xyz.toVar(),a=s.length(),c=Bt("float").setGroup(Ft).onRenderUpdate(()=>r.camera.near),h=Bt("float").setGroup(Ft).onRenderUpdate(()=>r.camera.far),f=xi("bias","float",r).setGroup(Ft),m=Bt(r.mapSize).setGroup(Ft),x=G(1).toVar();return Dt(a.sub(h).lessThanEqual(0).and(a.sub(c).greaterThanEqual(0)),()=>{const _=a.sub(c).div(h.sub(c)).toVar();_.addAssign(f);const v=s.normalize(),T=Ve(1).div(m.mul(Ve(4,2)));x.assign(i({depthTexture:e,bd3D:v,dp:_,texelSize:T,shadow:r}))}),x}),Fw=new d.Ltg,Od=new d.FM8,_m=new d.FM8;class BL extends Lw{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===d._MY?Dw:Uw}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:r,depthTexture:s,shadowCoord:a,shadow:c}){return FL({filterFn:t,shadowTexture:r,depthTexture:s,shadowCoord:a,shadow:c})}renderShadow(e){const{shadow:t,shadowMap:r,light:s}=this,{renderer:a,scene:c}=e,h=t.getFrameExtents();_m.copy(t.mapSize),_m.multiply(h),r.setSize(_m.width,_m.height),Od.copy(t.mapSize);const f=a.autoClear,m=a.getClearColor(UL),x=a.getClearAlpha();a.autoClear=!1,a.setClearColor(t.clearColor,t.clearAlpha),a.clear();const _=t.getViewportCount();for(let v=0;v<_;v++){const T=t.getViewport(v),w=Od.x*T.x,P=_m.y-Od.y-Od.y*T.y;Fw.set(w,P,Od.x*T.z,Od.y*T.w),r.viewport.copy(Fw),t.updateMatrices(s,v);const C=c.name;c.name=`Point Light Shadow [ ${s.name||"ID: "+s.id} ] - Face ${v+1}`,a.render(c,t.camera),c.name=C}a.autoClear=f,a.setClearColor(m,x)}}const Bw=(i,e)=>Oe(new BL(i,e));class Vu extends Ed{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new d.Ilk,this.colorNode=e&&e.colorNode||Bt(this.color).setGroup(Ft),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=xn.FRAME}getHash(){return this.light.uuid}getLightVector(e){return zv(this.light).sub(e.context.positionView||tr)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return Iw(this.light)}setupShadow(e){const{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let r=this.shadowColorNode;if(r===null){const s=this.light.shadow.shadowNode;let a;s!==void 0?a=Oe(s):a=this.setupShadowNode(),this.shadowNode=a,this.shadowColorNode=r=this.colorNode.mul(a),this.baseColorNode=this.colorNode}this.colorNode=r}setup(e){this.colorNode=this.baseColorNode||this.colorNode,this.light.castShadow?e.object.receiveShadow&&this.setupShadow(e):this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null,this.shadowColorNode=null);const t=this.setupDirect(e),r=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),r&&e.lightsNode.setupDirectRectAreaLight(e,this,r)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const Kv=fe(({lightDistance:i,cutoffDistance:e,decayExponent:t})=>{const r=i.pow(t).max(.01).reciprocal();return e.greaterThan(0).select(r.mul(i.div(e).pow4().oneMinus().clamp().pow2()),r)}),Ow=({color:i,lightVector:e,cutoffDistance:t,decayExponent:r})=>{const s=e.normalize(),a=e.length(),c=Kv({lightDistance:a,cutoffDistance:t,decayExponent:r}),h=i.mul(c);return{lightDirection:s,lightColor:h}};class OL extends Vu{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=Bt(0).setGroup(Ft),this.decayExponentNode=Bt(2).setGroup(Ft)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return Bw(this.light)}setupDirect(e){return Ow({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}const kL=fe(([i=hi()])=>{const e=i.mul(2),t=e.x.floor(),r=e.y.floor();return t.add(r).mod(2).sign()}),VL=fe(([i=hi()],{renderer:e,material:t})=>{const r=Gp(i.mul(2).sub(1));let s;if(t.alphaToCoverage&&e.currentSamples>0){const a=G(r.fwidth()).toVar();s=bs(a.oneMinus(),a.add(1),r).oneMinus()}else s=S(r.greaterThan(1),0,1);return s}),ym=fe(([i,e,t])=>{const r=G(t).toVar(),s=G(e).toVar(),a=br(i).toVar();return S(a,s,r)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),kx=fe(([i,e])=>{const t=br(e).toVar(),r=G(i).toVar();return S(t,r.negate(),r)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),hr=fe(([i])=>{const e=G(i).toVar();return re(Or(e))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),Fi=fe(([i,e])=>{const t=G(i).toVar();return e.assign(hr(t)),t.sub(G(e))}),kw=Gr([fe(([i,e,t,r,s,a])=>{const c=G(a).toVar(),h=G(s).toVar(),f=G(r).toVar(),m=G(t).toVar(),x=G(e).toVar(),_=G(i).toVar(),v=G(Cn(1,h)).toVar();return Cn(1,c).mul(_.mul(v).add(x.mul(h))).add(c.mul(m.mul(v).add(f.mul(h))))}).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"}]}),fe(([i,e,t,r,s,a])=>{const c=G(a).toVar(),h=G(s).toVar(),f=ce(r).toVar(),m=ce(t).toVar(),x=ce(e).toVar(),_=ce(i).toVar(),v=G(Cn(1,h)).toVar();return Cn(1,c).mul(_.mul(v).add(x.mul(h))).add(c.mul(m.mul(v).add(f.mul(h))))}).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"}]})]),Vw=Gr([fe(([i,e,t,r,s,a,c,h,f,m,x])=>{const _=G(x).toVar(),v=G(m).toVar(),T=G(f).toVar(),w=G(h).toVar(),P=G(c).toVar(),C=G(a).toVar(),E=G(s).toVar(),D=G(r).toVar(),F=G(t).toVar(),W=G(e).toVar(),K=G(i).toVar(),U=G(Cn(1,T)).toVar(),j=G(Cn(1,v)).toVar();return G(Cn(1,_)).toVar().mul(j.mul(K.mul(U).add(W.mul(T))).add(v.mul(F.mul(U).add(D.mul(T))))).add(_.mul(j.mul(E.mul(U).add(C.mul(T))).add(v.mul(P.mul(U).add(w.mul(T))))))}).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"}]}),fe(([i,e,t,r,s,a,c,h,f,m,x])=>{const _=G(x).toVar(),v=G(m).toVar(),T=G(f).toVar(),w=ce(h).toVar(),P=ce(c).toVar(),C=ce(a).toVar(),E=ce(s).toVar(),D=ce(r).toVar(),F=ce(t).toVar(),W=ce(e).toVar(),K=ce(i).toVar(),U=G(Cn(1,T)).toVar(),j=G(Cn(1,v)).toVar();return G(Cn(1,_)).toVar().mul(j.mul(K.mul(U).add(W.mul(T))).add(v.mul(F.mul(U).add(D.mul(T))))).add(_.mul(j.mul(E.mul(U).add(C.mul(T))).add(v.mul(P.mul(U).add(w.mul(T))))))}).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"}]})]),Rr=Gr([fe(([i,e,t])=>{const r=G(t).toVar(),s=G(e).toVar(),a=Je(i).toVar(),c=Je(a.bitAnd(Je(7))).toVar(),h=G(ym(c.lessThan(Je(4)),s,r)).toVar(),f=G(cn(2,ym(c.lessThan(Je(4)),r,s))).toVar();return kx(h,br(c.bitAnd(Je(1)))).add(kx(f,br(c.bitAnd(Je(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),fe(([i,e,t,r])=>{const s=G(r).toVar(),a=G(t).toVar(),c=G(e).toVar(),h=Je(i).toVar(),f=Je(h.bitAnd(Je(15))).toVar(),m=G(ym(f.lessThan(Je(8)),c,a)).toVar(),x=G(ym(f.lessThan(Je(4)),a,ym(f.equal(Je(12)).or(f.equal(Je(14))),c,s))).toVar();return kx(m,br(f.bitAnd(Je(1)))).add(kx(x,br(f.bitAnd(Je(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"}]})]),yo=Gr([fe(([i,e,t])=>{const r=G(t).toVar(),s=G(e).toVar(),a=zo(i).toVar();return ce(Rr(a.x,s,r),Rr(a.y,s,r),Rr(a.z,s,r))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),fe(([i,e,t,r])=>{const s=G(r).toVar(),a=G(t).toVar(),c=G(e).toVar(),h=zo(i).toVar();return ce(Rr(h.x,c,a,s),Rr(h.y,c,a,s),Rr(h.z,c,a,s))}).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"}]})]),zL=fe(([i])=>{const e=G(i).toVar();return cn(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),GL=fe(([i])=>{const e=G(i).toVar();return cn(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),zw=Gr([zL,fe(([i])=>{const e=ce(i).toVar();return cn(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),Gw=Gr([GL,fe(([i])=>{const e=ce(i).toVar();return cn(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),Ys=fe(([i,e])=>{const t=re(e).toVar(),r=Je(i).toVar();return r.shiftLeft(t).bitOr(r.shiftRight(re(32).sub(t)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),Ww=fe(([i,e,t])=>{i.subAssign(t),i.bitXorAssign(Ys(t,re(4))),t.addAssign(e),e.subAssign(i),e.bitXorAssign(Ys(i,re(6))),i.addAssign(t),t.subAssign(e),t.bitXorAssign(Ys(e,re(8))),e.addAssign(i),i.subAssign(t),i.bitXorAssign(Ys(t,re(16))),t.addAssign(e),e.subAssign(i),e.bitXorAssign(Ys(i,re(19))),i.addAssign(t),t.subAssign(e),t.bitXorAssign(Ys(e,re(4))),e.addAssign(i)}),bm=fe(([i,e,t])=>{const r=Je(t).toVar(),s=Je(e).toVar(),a=Je(i).toVar();return r.bitXorAssign(s),r.subAssign(Ys(s,re(14))),a.bitXorAssign(r),a.subAssign(Ys(r,re(11))),s.bitXorAssign(a),s.subAssign(Ys(a,re(25))),r.bitXorAssign(s),r.subAssign(Ys(s,re(16))),a.bitXorAssign(r),a.subAssign(Ys(r,re(4))),s.bitXorAssign(a),s.subAssign(Ys(a,re(14))),r.bitXorAssign(s),r.subAssign(Ys(s,re(24))),r}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),qr=fe(([i])=>{const e=Je(i).toVar();return G(e).div(G(Je(re(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),Sa=fe(([i])=>{const e=G(i).toVar();return e.mul(e).mul(e).mul(e.mul(e.mul(6).sub(15)).add(10))}).setLayout({name:"mx_fade",type:"float",inputs:[{name:"t",type:"float"}]}),mi=Gr([fe(([i])=>{const e=re(i).toVar(),t=Je(Je(1)).toVar(),r=Je(Je(re(3735928559)).add(t.shiftLeft(Je(2))).add(Je(13))).toVar();return bm(r.add(Je(e)),r,r)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),fe(([i,e])=>{const t=re(e).toVar(),r=re(i).toVar(),s=Je(Je(2)).toVar(),a=Je().toVar(),c=Je().toVar(),h=Je().toVar();return a.assign(c.assign(h.assign(Je(re(3735928559)).add(s.shiftLeft(Je(2))).add(Je(13))))),a.addAssign(Je(r)),c.addAssign(Je(t)),bm(a,c,h)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),fe(([i,e,t])=>{const r=re(t).toVar(),s=re(e).toVar(),a=re(i).toVar(),c=Je(Je(3)).toVar(),h=Je().toVar(),f=Je().toVar(),m=Je().toVar();return h.assign(f.assign(m.assign(Je(re(3735928559)).add(c.shiftLeft(Je(2))).add(Je(13))))),h.addAssign(Je(a)),f.addAssign(Je(s)),m.addAssign(Je(r)),bm(h,f,m)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),fe(([i,e,t,r])=>{const s=re(r).toVar(),a=re(t).toVar(),c=re(e).toVar(),h=re(i).toVar(),f=Je(Je(4)).toVar(),m=Je().toVar(),x=Je().toVar(),_=Je().toVar();return m.assign(x.assign(_.assign(Je(re(3735928559)).add(f.shiftLeft(Je(2))).add(Je(13))))),m.addAssign(Je(h)),x.addAssign(Je(c)),_.addAssign(Je(a)),Ww(m,x,_),m.addAssign(Je(s)),bm(m,x,_)}).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"}]}),fe(([i,e,t,r,s])=>{const a=re(s).toVar(),c=re(r).toVar(),h=re(t).toVar(),f=re(e).toVar(),m=re(i).toVar(),x=Je(Je(5)).toVar(),_=Je().toVar(),v=Je().toVar(),T=Je().toVar();return _.assign(v.assign(T.assign(Je(re(3735928559)).add(x.shiftLeft(Je(2))).add(Je(13))))),_.addAssign(Je(m)),v.addAssign(Je(f)),T.addAssign(Je(h)),Ww(_,v,T),_.addAssign(Je(c)),v.addAssign(Je(a)),bm(_,v,T)}).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"}]})]),bo=Gr([fe(([i,e])=>{const t=re(e).toVar(),r=re(i).toVar(),s=Je(mi(r,t)).toVar(),a=zo().toVar();return a.x.assign(s.bitAnd(re(255))),a.y.assign(s.shiftRight(re(8)).bitAnd(re(255))),a.z.assign(s.shiftRight(re(16)).bitAnd(re(255))),a}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),fe(([i,e,t])=>{const r=re(t).toVar(),s=re(e).toVar(),a=re(i).toVar(),c=Je(mi(a,s,r)).toVar(),h=zo().toVar();return h.x.assign(c.bitAnd(re(255))),h.y.assign(c.shiftRight(re(8)).bitAnd(re(255))),h.z.assign(c.shiftRight(re(16)).bitAnd(re(255))),h}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]})]),Zv=Gr([fe(([i])=>{const e=Ve(i).toVar(),t=re().toVar(),r=re().toVar(),s=G(Fi(e.x,t)).toVar(),a=G(Fi(e.y,r)).toVar(),c=G(Sa(s)).toVar(),h=G(Sa(a)).toVar(),f=G(kw(Rr(mi(t,r),s,a),Rr(mi(t.add(re(1)),r),s.sub(1),a),Rr(mi(t,r.add(re(1))),s,a.sub(1)),Rr(mi(t.add(re(1)),r.add(re(1))),s.sub(1),a.sub(1)),c,h)).toVar();return zw(f)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),fe(([i])=>{const e=ce(i).toVar(),t=re().toVar(),r=re().toVar(),s=re().toVar(),a=G(Fi(e.x,t)).toVar(),c=G(Fi(e.y,r)).toVar(),h=G(Fi(e.z,s)).toVar(),f=G(Sa(a)).toVar(),m=G(Sa(c)).toVar(),x=G(Sa(h)).toVar(),_=G(Vw(Rr(mi(t,r,s),a,c,h),Rr(mi(t.add(re(1)),r,s),a.sub(1),c,h),Rr(mi(t,r.add(re(1)),s),a,c.sub(1),h),Rr(mi(t.add(re(1)),r.add(re(1)),s),a.sub(1),c.sub(1),h),Rr(mi(t,r,s.add(re(1))),a,c,h.sub(1)),Rr(mi(t.add(re(1)),r,s.add(re(1))),a.sub(1),c,h.sub(1)),Rr(mi(t,r.add(re(1)),s.add(re(1))),a,c.sub(1),h.sub(1)),Rr(mi(t.add(re(1)),r.add(re(1)),s.add(re(1))),a.sub(1),c.sub(1),h.sub(1)),f,m,x)).toVar();return Gw(_)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]})]),vm=Gr([fe(([i])=>{const e=Ve(i).toVar(),t=re().toVar(),r=re().toVar(),s=G(Fi(e.x,t)).toVar(),a=G(Fi(e.y,r)).toVar(),c=G(Sa(s)).toVar(),h=G(Sa(a)).toVar(),f=ce(kw(yo(bo(t,r),s,a),yo(bo(t.add(re(1)),r),s.sub(1),a),yo(bo(t,r.add(re(1))),s,a.sub(1)),yo(bo(t.add(re(1)),r.add(re(1))),s.sub(1),a.sub(1)),c,h)).toVar();return zw(f)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),fe(([i])=>{const e=ce(i).toVar(),t=re().toVar(),r=re().toVar(),s=re().toVar(),a=G(Fi(e.x,t)).toVar(),c=G(Fi(e.y,r)).toVar(),h=G(Fi(e.z,s)).toVar(),f=G(Sa(a)).toVar(),m=G(Sa(c)).toVar(),x=G(Sa(h)).toVar(),_=ce(Vw(yo(bo(t,r,s),a,c,h),yo(bo(t.add(re(1)),r,s),a.sub(1),c,h),yo(bo(t,r.add(re(1)),s),a,c.sub(1),h),yo(bo(t.add(re(1)),r.add(re(1)),s),a.sub(1),c.sub(1),h),yo(bo(t,r,s.add(re(1))),a,c,h.sub(1)),yo(bo(t.add(re(1)),r,s.add(re(1))),a.sub(1),c,h.sub(1)),yo(bo(t,r.add(re(1)),s.add(re(1))),a,c.sub(1),h.sub(1)),yo(bo(t.add(re(1)),r.add(re(1)),s.add(re(1))),a.sub(1),c.sub(1),h.sub(1)),f,m,x)).toVar();return Gw(_)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]})]),WL=Gr([fe(([i])=>{const e=G(i).toVar(),t=re(hr(e)).toVar();return qr(mi(t))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),fe(([i])=>{const e=Ve(i).toVar(),t=re(hr(e.x)).toVar(),r=re(hr(e.y)).toVar();return qr(mi(t,r))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),fe(([i])=>{const e=ce(i).toVar(),t=re(hr(e.x)).toVar(),r=re(hr(e.y)).toVar(),s=re(hr(e.z)).toVar();return qr(mi(t,r,s))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),fe(([i])=>{const e=At(i).toVar(),t=re(hr(e.x)).toVar(),r=re(hr(e.y)).toVar(),s=re(hr(e.z)).toVar(),a=re(hr(e.w)).toVar();return qr(mi(t,r,s,a))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),Vx=Gr([fe(([i])=>{const e=G(i).toVar(),t=re(hr(e)).toVar();return ce(qr(mi(t,re(0))),qr(mi(t,re(1))),qr(mi(t,re(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),fe(([i])=>{const e=Ve(i).toVar(),t=re(hr(e.x)).toVar(),r=re(hr(e.y)).toVar();return ce(qr(mi(t,r,re(0))),qr(mi(t,r,re(1))),qr(mi(t,r,re(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),fe(([i])=>{const e=ce(i).toVar(),t=re(hr(e.x)).toVar(),r=re(hr(e.y)).toVar(),s=re(hr(e.z)).toVar();return ce(qr(mi(t,r,s,re(0))),qr(mi(t,r,s,re(1))),qr(mi(t,r,s,re(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),fe(([i])=>{const e=At(i).toVar(),t=re(hr(e.x)).toVar(),r=re(hr(e.y)).toVar(),s=re(hr(e.z)).toVar(),a=re(hr(e.w)).toVar();return ce(qr(mi(t,r,s,a,re(0))),qr(mi(t,r,s,a,re(1))),qr(mi(t,r,s,a,re(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),zx=fe(([i,e,t,r])=>{const s=G(r).toVar(),a=G(t).toVar(),c=re(e).toVar(),h=ce(i).toVar(),f=G(0).toVar(),m=G(1).toVar();return ci(c,()=>{f.addAssign(m.mul(Zv(h))),m.mulAssign(s),h.mulAssign(a)}),f}).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"}]}),Gx=fe(([i,e,t,r])=>{const s=G(r).toVar(),a=G(t).toVar(),c=re(e).toVar(),h=ce(i).toVar(),f=ce(0).toVar(),m=G(1).toVar();return ci(c,()=>{f.addAssign(m.mul(vm(h))),m.mulAssign(s),h.mulAssign(a)}),f}).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"}]}),HL=fe(([i,e,t,r])=>{const s=G(r).toVar(),a=G(t).toVar(),c=re(e).toVar(),h=ce(i).toVar();return Ve(zx(h,c,a,s),zx(h.add(ce(re(19),re(193),re(17))),c,a,s))}).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"}]}),$L=fe(([i,e,t,r])=>{const s=G(r).toVar(),a=G(t).toVar(),c=re(e).toVar(),h=ce(i).toVar(),f=ce(Gx(h,c,a,s)).toVar(),m=G(zx(h.add(ce(re(19),re(193),re(17))),c,a,s)).toVar();return At(f,m)}).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"}]}),kd=Gr([fe(([i,e,t,r,s,a,c])=>{const h=re(c).toVar(),f=G(a).toVar(),m=re(s).toVar(),x=re(r).toVar(),_=re(t).toVar(),v=re(e).toVar(),T=Ve(i).toVar(),w=ce(Vx(Ve(v.add(x),_.add(m)))).toVar(),P=Ve(w.x,w.y).toVar();P.subAssign(.5),P.mulAssign(f),P.addAssign(.5);const C=Ve(Ve(G(v),G(_)).add(P)).toVar(),E=Ve(C.sub(T)).toVar();return Dt(h.equal(re(2)),()=>ai(E.x).add(ai(E.y))),Dt(h.equal(re(3)),()=>Mi(ai(E.x),ai(E.y))),ho(E,E)}).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"}]}),fe(([i,e,t,r,s,a,c,h,f])=>{const m=re(f).toVar(),x=G(h).toVar(),_=re(c).toVar(),v=re(a).toVar(),T=re(s).toVar(),w=re(r).toVar(),P=re(t).toVar(),C=re(e).toVar(),E=ce(i).toVar(),D=ce(Vx(ce(C.add(T),P.add(v),w.add(_)))).toVar();D.subAssign(.5),D.mulAssign(x),D.addAssign(.5);const F=ce(ce(G(C),G(P),G(w)).add(D)).toVar(),W=ce(F.sub(E)).toVar();return Dt(m.equal(re(2)),()=>ai(W.x).add(ai(W.y)).add(ai(W.z))),Dt(m.equal(re(3)),()=>Mi(ai(W.x),ai(W.y),ai(W.z))),ho(W,W)}).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"}]})]),jL=fe(([i,e,t])=>{const r=re(t).toVar(),s=G(e).toVar(),a=Ve(i).toVar(),c=re().toVar(),h=re().toVar(),f=Ve(Fi(a.x,c),Fi(a.y,h)).toVar(),m=G(1e6).toVar();return ci({start:-1,end:re(1),name:"x",condition:"<="},({x})=>{ci({start:-1,end:re(1),name:"y",condition:"<="},({y:_})=>{const v=G(kd(f,x,_,c,h,s,r)).toVar();m.assign(Kn(m,v))})}),Dt(r.equal(re(0)),()=>{m.assign(Br(m))}),m}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),XL=fe(([i,e,t])=>{const r=re(t).toVar(),s=G(e).toVar(),a=Ve(i).toVar(),c=re().toVar(),h=re().toVar(),f=Ve(Fi(a.x,c),Fi(a.y,h)).toVar(),m=Ve(1e6,1e6).toVar();return ci({start:-1,end:re(1),name:"x",condition:"<="},({x})=>{ci({start:-1,end:re(1),name:"y",condition:"<="},({y:_})=>{const v=G(kd(f,x,_,c,h,s,r)).toVar();Dt(v.lessThan(m.x),()=>{m.y.assign(m.x),m.x.assign(v)}).ElseIf(v.lessThan(m.y),()=>{m.y.assign(v)})})}),Dt(r.equal(re(0)),()=>{m.assign(Br(m))}),m}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),qL=fe(([i,e,t])=>{const r=re(t).toVar(),s=G(e).toVar(),a=Ve(i).toVar(),c=re().toVar(),h=re().toVar(),f=Ve(Fi(a.x,c),Fi(a.y,h)).toVar(),m=ce(1e6,1e6,1e6).toVar();return ci({start:-1,end:re(1),name:"x",condition:"<="},({x})=>{ci({start:-1,end:re(1),name:"y",condition:"<="},({y:_})=>{const v=G(kd(f,x,_,c,h,s,r)).toVar();Dt(v.lessThan(m.x),()=>{m.z.assign(m.y),m.y.assign(m.x),m.x.assign(v)}).ElseIf(v.lessThan(m.y),()=>{m.z.assign(m.y),m.y.assign(v)}).ElseIf(v.lessThan(m.z),()=>{m.z.assign(v)})})}),Dt(r.equal(re(0)),()=>{m.assign(Br(m))}),m}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),KL=Gr([jL,fe(([i,e,t])=>{const r=re(t).toVar(),s=G(e).toVar(),a=ce(i).toVar(),c=re().toVar(),h=re().toVar(),f=re().toVar(),m=ce(Fi(a.x,c),Fi(a.y,h),Fi(a.z,f)).toVar(),x=G(1e6).toVar();return ci({start:-1,end:re(1),name:"x",condition:"<="},({x:_})=>{ci({start:-1,end:re(1),name:"y",condition:"<="},({y:v})=>{ci({start:-1,end:re(1),name:"z",condition:"<="},({z:T})=>{const w=G(kd(m,_,v,T,c,h,f,s,r)).toVar();x.assign(Kn(x,w))})})}),Dt(r.equal(re(0)),()=>{x.assign(Br(x))}),x}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),ZL=Gr([XL,fe(([i,e,t])=>{const r=re(t).toVar(),s=G(e).toVar(),a=ce(i).toVar(),c=re().toVar(),h=re().toVar(),f=re().toVar(),m=ce(Fi(a.x,c),Fi(a.y,h),Fi(a.z,f)).toVar(),x=Ve(1e6,1e6).toVar();return ci({start:-1,end:re(1),name:"x",condition:"<="},({x:_})=>{ci({start:-1,end:re(1),name:"y",condition:"<="},({y:v})=>{ci({start:-1,end:re(1),name:"z",condition:"<="},({z:T})=>{const w=G(kd(m,_,v,T,c,h,f,s,r)).toVar();Dt(w.lessThan(x.x),()=>{x.y.assign(x.x),x.x.assign(w)}).ElseIf(w.lessThan(x.y),()=>{x.y.assign(w)})})})}),Dt(r.equal(re(0)),()=>{x.assign(Br(x))}),x}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),Yv=Gr([qL,fe(([i,e,t])=>{const r=re(t).toVar(),s=G(e).toVar(),a=ce(i).toVar(),c=re().toVar(),h=re().toVar(),f=re().toVar(),m=ce(Fi(a.x,c),Fi(a.y,h),Fi(a.z,f)).toVar(),x=ce(1e6,1e6,1e6).toVar();return ci({start:-1,end:re(1),name:"x",condition:"<="},({x:_})=>{ci({start:-1,end:re(1),name:"y",condition:"<="},({y:v})=>{ci({start:-1,end:re(1),name:"z",condition:"<="},({z:T})=>{const w=G(kd(m,_,v,T,c,h,f,s,r)).toVar();Dt(w.lessThan(x.x),()=>{x.z.assign(x.y),x.y.assign(x.x),x.x.assign(w)}).ElseIf(w.lessThan(x.y),()=>{x.z.assign(x.y),x.y.assign(w)}).ElseIf(w.lessThan(x.z),()=>{x.z.assign(w)})})})}),Dt(r.equal(re(0)),()=>{x.assign(Br(x))}),x}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),YL=fe(([i,e,t,r,s,a,c,h,f,m,x])=>{const _=re(i).toVar(),v=Ve(e).toVar(),T=Ve(t).toVar(),w=Ve(r).toVar(),P=G(s).toVar(),C=G(a).toVar(),E=G(c).toVar(),D=br(h).toVar(),F=re(f).toVar(),W=G(m).toVar(),K=G(x).toVar(),U=v.mul(T).add(w),j=G(0).toVar();return Dt(_.equal(re(0)),()=>{j.assign(vm(U))}),Dt(_.equal(re(1)),()=>{j.assign(Vx(U))}),Dt(_.equal(re(2)),()=>{j.assign(Yv(U,P,re(0)))}),Dt(_.equal(re(3)),()=>{j.assign(Gx(ce(U,0),F,W,K))}),j.assign(j.mul(E.sub(C)).add(C)),Dt(D,()=>{j.assign(ys(j,C,E))}),j}).setLayout({name:"mx_unifiednoise2d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"texcoord",type:"vec2"},{name:"freq",type:"vec2"},{name:"offset",type:"vec2"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),QL=fe(([i,e,t,r,s,a,c,h,f,m,x])=>{const _=re(i).toVar(),v=ce(e).toVar(),T=ce(t).toVar(),w=ce(r).toVar(),P=G(s).toVar(),C=G(a).toVar(),E=G(c).toVar(),D=br(h).toVar(),F=re(f).toVar(),W=G(m).toVar(),K=G(x).toVar(),U=v.mul(T).add(w),j=G(0).toVar();return Dt(_.equal(re(0)),()=>{j.assign(vm(U))}),Dt(_.equal(re(1)),()=>{j.assign(Vx(U))}),Dt(_.equal(re(2)),()=>{j.assign(Yv(U,P,re(0)))}),Dt(_.equal(re(3)),()=>{j.assign(Gx(U,F,W,K))}),j.assign(j.mul(E.sub(C)).add(C)),Dt(D,()=>{j.assign(ys(j,C,E))}),j}).setLayout({name:"mx_unifiednoise3d",type:"float",inputs:[{name:"noiseType",type:"int"},{name:"position",type:"vec3"},{name:"freq",type:"vec3"},{name:"offset",type:"vec3"},{name:"jitter",type:"float"},{name:"outmin",type:"float"},{name:"outmax",type:"float"},{name:"clampoutput",type:"bool"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),JL=fe(([i])=>{const e=i.y,t=i.z,r=ce().toVar();return Dt(e.lessThan(1e-4),()=>{r.assign(ce(t,t,t))}).Else(()=>{let s=i.x;s=s.sub(Or(s)).mul(6).toVar();const a=re(K0(s)),c=s.sub(G(a)),h=t.mul(e.oneMinus()),f=t.mul(e.mul(c).oneMinus()),m=t.mul(e.mul(c.oneMinus()).oneMinus());Dt(a.equal(re(0)),()=>{r.assign(ce(t,m,h))}).ElseIf(a.equal(re(1)),()=>{r.assign(ce(f,t,h))}).ElseIf(a.equal(re(2)),()=>{r.assign(ce(h,t,m))}).ElseIf(a.equal(re(3)),()=>{r.assign(ce(h,f,t))}).ElseIf(a.equal(re(4)),()=>{r.assign(ce(m,h,t))}).Else(()=>{r.assign(ce(t,h,f))})}),r}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),eI=fe(([i])=>{const e=ce(i).toVar(),t=G(e.x).toVar(),r=G(e.y).toVar(),s=G(e.z).toVar(),a=G(Kn(t,Kn(r,s))).toVar(),c=G(Mi(t,Mi(r,s))).toVar(),h=G(c.sub(a)).toVar(),f=G().toVar(),m=G().toVar(),x=G().toVar();return x.assign(c),Dt(c.greaterThan(0),()=>{m.assign(h.div(c))}).Else(()=>{m.assign(0)}),Dt(m.lessThanEqual(0),()=>{f.assign(0)}).Else(()=>{Dt(t.greaterThanEqual(c),()=>{f.assign(r.sub(s).div(h))}).ElseIf(r.greaterThanEqual(c),()=>{f.assign(Yi(2,s.sub(t).div(h)))}).Else(()=>{f.assign(Yi(4,t.sub(r).div(h)))}),f.mulAssign(1/6),Dt(f.lessThan(0),()=>{f.addAssign(1)})}),ce(f,m,x)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),tI=fe(([i])=>{const e=ce(i).toVar(),t=Lp(vu(e,ce(.04045))).toVar(),r=ce(e.div(12.92)).toVar(),s=ce(kr(Mi(e.add(ce(.055)),ce(0)).div(1.055),ce(2.4))).toVar();return Xn(r,s,t)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),Hw=(i,e)=>{i=G(i),e=G(e);const t=Ve(e.dFdx(),e.dFdy()).length().mul(.7071067811865476);return bs(i.sub(t),i.add(t),e)},$w=(i,e,t,r)=>Xn(i,e,t[r].clamp()),nI=(i,e,t=hi())=>$w(i,e,t,"x"),iI=(i,e,t=hi())=>$w(i,e,t,"y"),rI=(i,e,t,r,s=hi())=>{const a=s.x.clamp(),c=s.y.clamp(),h=Xn(i,e,a),f=Xn(t,r,a);return Xn(h,f,c)},jw=(i,e,t,r,s)=>Xn(i,e,Hw(t,r[s])),sI=(i,e,t,r=hi())=>jw(i,e,t,r,"x"),oI=(i,e,t,r=hi())=>jw(i,e,t,r,"y"),aI=(i=1,e=0,t=hi())=>t.mul(i).add(e),cI=(i,e=1)=>(i=G(i),i.abs().pow(e).mul(i.sign())),lI=(i,e=1,t=.5)=>G(i).sub(t).mul(e).add(t),uI=(i=hi(),e=1,t=0)=>Zv(i.convert("vec2|vec3")).mul(e).add(t),hI=(i=hi(),e=1,t=0)=>vm(i.convert("vec2|vec3")).mul(e).add(t),dI=(i=hi(),e=1,t=0)=>(i=i.convert("vec2|vec3"),At(vm(i),Zv(i.add(Ve(19,73)))).mul(e).add(t)),fI=(i,e=hi(),t=Ve(1,1),r=Ve(0,0),s=1,a=0,c=1,h=!1,f=1,m=2,x=.5)=>YL(i,e.convert("vec2|vec3"),t,r,s,a,c,h,f,m,x),pI=(i,e=hi(),t=Ve(1,1),r=Ve(0,0),s=1,a=0,c=1,h=!1,f=1,m=2,x=.5)=>QL(i,e.convert("vec2|vec3"),t,r,s,a,c,h,f,m,x),mI=(i=hi(),e=1)=>KL(i.convert("vec2|vec3"),e,re(1)),gI=(i=hi(),e=1)=>ZL(i.convert("vec2|vec3"),e,re(1)),xI=(i=hi(),e=1)=>Yv(i.convert("vec2|vec3"),e,re(1)),_I=(i=hi())=>WL(i.convert("vec2|vec3")),yI=(i=hi(),e=3,t=2,r=.5,s=1)=>zx(i,re(e),t,r).mul(s),bI=(i=hi(),e=3,t=2,r=.5,s=1)=>HL(i,re(e),t,r).mul(s),vI=(i=hi(),e=3,t=2,r=.5,s=1)=>Gx(i,re(e),t,r).mul(s),SI=(i=hi(),e=3,t=2,r=.5,s=1)=>$L(i,re(e),t,r).mul(s),TI=(i,e=G(0))=>Yi(i,e),MI=(i,e=G(0))=>Cn(i,e),wI=(i,e=G(1))=>cn(i,e),AI=(i,e=G(1))=>cs(i,e),EI=(i,e=G(1))=>Ws(i,e),CI=(i,e=G(1))=>kr(i,e),RI=(i=G(0),e=G(1))=>uc(i,e),NI=()=>Id,PI=()=>qM,LI=(i,e=G(1))=>Cn(e,i),II=(i,e,t,r)=>i.greaterThan(e).mix(t,r),DI=(i,e,t,r)=>i.greaterThanEqual(e).mix(t,r),UI=(i,e,t,r)=>i.equal(e).mix(t,r),FI=(i,e=null)=>{if(typeof e=="string"){const t={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3},r=e.replace(/^out/,"").toLowerCase();if(t[r]!==void 0)return i.element(t[r])}if(typeof e=="number")return i.element(e);if(typeof e=="string"&&e.length===1){const t={x:0,r:0,y:1,g:1,z:2,b:2,w:3,a:3};if(t[e]!==void 0)return i.element(t[e])}return i},BI=(i,e=Ve(.5,.5),t=Ve(1,1),r=G(0),s=Ve(0,0))=>{let a=i;if(e&&(a=a.sub(e)),t&&(a=a.mul(t)),r){const c=r.mul(Math.PI/180),h=c.cos(),f=c.sin();a=Ve(a.x.mul(h).sub(a.y.mul(f)),a.x.mul(f).add(a.y.mul(h)))}return e&&(a=a.add(e)),s&&(a=a.add(s)),a},OI=(i,e)=>{i=Ve(i),e=G(e);const t=e.mul(Math.PI/180);return sm(i,t)},kI=(i,e,t)=>{i=ce(i),e=G(e),t=ce(t);const r=e.mul(Math.PI/180),s=t.normalize(),a=r.cos(),c=r.sin(),h=G(1).sub(a);return i.mul(a).add(s.cross(i).mul(c)).add(s.mul(s.dot(i)).mul(h))},VI=(i,e)=>(i=ce(i),e=G(e),qb(i,e)),zI=fe(([i,e,t])=>{const r=Er(i).toVar(),s=Cn(G(.5).mul(e.sub(t)),Ks).div(r).toVar(),a=Cn(G(-.5).mul(e.sub(t)),Ks).div(r).toVar(),c=ce().toVar();c.x=r.x.greaterThan(G(0)).select(s.x,a.x),c.y=r.y.greaterThan(G(0)).select(s.y,a.y),c.z=r.z.greaterThan(G(0)).select(s.z,a.z);const h=Kn(c.x,c.y,c.z).toVar();return Ks.add(r.mul(h)).toVar().sub(t)}),Xw=fe(([i,e])=>{const t=i.x,r=i.y,s=i.z;let a=e.element(0).mul(.886227);return a=a.add(e.element(1).mul(2*.511664).mul(r)),a=a.add(e.element(2).mul(2*.511664).mul(s)),a=a.add(e.element(3).mul(2*.511664).mul(t)),a=a.add(e.element(4).mul(2*.429043).mul(t).mul(r)),a=a.add(e.element(5).mul(2*.429043).mul(r).mul(s)),a=a.add(e.element(6).mul(s.mul(s).mul(.743125).sub(.247708))),a=a.add(e.element(7).mul(2*.429043).mul(t).mul(s)),a=a.add(e.element(8).mul(.429043).mul(cn(t,t).sub(cn(r,r)))),a});var $4=Object.freeze({__proto__:null,BRDF_GGX:dv,BRDF_Lambert:Du,BasicPointShadowFilter:Dw,BasicShadowFilter:ww,Break:L1,Const:ee,Continue:vC,DFGApprox:nm,D_GGX:tM,Discard:Ji,EPSILON:G0,F_Schlick:Pd,Fn:fe,HALF_PI:H0,INFINITY:yb,If:Dt,Loop:ci,NodeAccess:yr,NodeShaderStage:Vo,NodeType:ib,NodeUpdateType:xn,OnBeforeMaterialUpdate:zN,OnBeforeObjectUpdate:VN,OnMaterialUpdate:kN,OnObjectUpdate:ON,PCFShadowFilter:Aw,PCFSoftShadowFilter:Ew,PI:kp,PI2:W0,PointShadowFilter:Uw,Return:us,Schlick_to_F0:iM,ScriptableNodeResources:Dx,ShaderNode:nc,Stack:rc,Switch:_T,TBNViewMatrix:Lu,TWO_PI:bb,VSMShadowFilter:Cw,V_GGX_SmithCorrelated:eM,Var:q,VarIntent:te,abs:ai,acesFilmicToneMapping:lw,acos:uo,add:Yi,addMethodChaining:De,addNodeElement:tx,agxToneMapping:uw,all:md,alphaT:mu,and:L0,anisotropy:lo,anisotropyB:pa,anisotropyT:gu,any:vb,append:bT,array:Bp,arrayBuffer:yT,asin:Sb,assign:fd,atan:uc,atan2:p,atomicAdd:XP,atomicAnd:YP,atomicFunc:va,atomicLoad:$P,atomicMax:KP,atomicMin:ZP,atomicOr:QP,atomicStore:jP,atomicSub:qP,atomicXor:JP,attenuationColor:hd,attenuationDistance:ud,attribute:hs,attributeArray:HN,backgroundBlurriness:YM,backgroundIntensity:Uv,backgroundRotation:QM,batch:C1,bentNormalView:ZT,billboarding:bN,bitAnd:F0,bitNot:B0,bitOr:O0,bitXor:k0,bitangentGeometry:tC,bitangentLocal:nC,bitangentView:qT,bitangentWorld:iC,bitcast:eN,blendBurn:V1,blendColor:OC,blendDodge:z1,blendOverlay:W1,blendScreen:G1,blur:TM,bool:br,buffer:qp,bufferAttribute:Cu,builtin:pc,bumpMap:qb,burn:VC,bvec2:lu,bvec3:Lp,bvec4:E0,bypass:on,cache:Vt,call:ma,cameraFar:xc,cameraIndex:pl,cameraNear:gc,cameraNormalMatrix:P3,cameraPosition:Qp,cameraProjectionMatrix:po,cameraProjectionMatrixInverse:R3,cameraViewMatrix:qs,cameraViewport:L3,cameraWorldMatrix:N3,cbrt:Y0,cdl:oP,ceil:Ho,checker:kL,cineonToneMapping:cw,clamp:ys,clearcoat:ul,clearcoatNormalView:Pu,clearcoatRoughness:du,code:Lx,color:w0,colorSpaceToWorking:ni,colorToDirection:ZC,compute:fo,computeKernel:Hp,computeSkinning:yC,context:R,convert:oc,convertColorSpace:ur,convertToTexture:LN,cos:$o,cross:xa,cubeTexture:wd,cubeTextureBase:Wb,cubeToUV:qo,dFdx:xd,dFdy:_d,dashSize:Go,debug:$p,decrement:_b,decrementBefore:z0,defaultBuildStages:_p,defaultShaderStages:y0,defined:ol,degrees:j0,deltaTime:fN,densityFog:CP,densityFogFactor:Ov,depth:cv,depthPass:hP,determinant:zp,difference:Cb,diffuseColor:jn,directPointLight:Ow,directionToColor:j1,directionToFaceDirection:Td,dispersion:_u,distance:Eb,div:cs,dodge:zC,dot:ho,drawIndex:w1,dynamicBufferAttribute:Q0,element:ub,emissive:hu,equal:R0,equals:Mu,equirectUV:lv,exp:X0,exp2:ga,expression:ii,faceDirection:kb,faceForward:M,faceforward:g,float:G,floatBitsToInt:tN,floatBitsToUint:nN,floor:Or,fog:mm,fract:Hs,frameGroup:fb,frameId:qM,frontFacing:CT,fwidth:yd,gain:oN,gapSize:dl,getConstNodeType:Np,getCurrentStack:Pp,getDirection:vM,getDistanceAttenuation:Kv,getGeometryRoughness:J1,getNormalFromDepth:DN,getParallaxCorrectNormal:zI,getRoughness:hv,getScreenPosition:IN,getShIrradianceAt:Xw,getShadowMaterial:Rw,getShadowRenderObjectFunction:Pw,getTextureIndex:jM,getViewPosition:Fd,ggxConvolution:MM,globalId:DP,glsl:bP,glslFn:vP,grayscale:nP,greaterThan:vu,greaterThanEqual:pd,hash:sN,highpModelNormalViewMatrix:Bb,highpModelViewMatrix:Fb,hue:sP,increment:xb,incrementBefore:V0,inspector:ex,instance:dC,instanceIndex:gl,instancedArray:$N,instancedBufferAttribute:Ru,instancedDynamicBufferAttribute:Xs,instancedMesh:E1,int:re,intBitsToFloat:iN,interleavedGradientNoise:UN,inverse:Ab,inverseSqrt:fl,inversesqrt:y,invocationLocalIndex:hC,invocationSubgroupIndex:uC,ior:xu,iridescence:fa,iridescenceIOR:pu,iridescenceThickness:Dp,isolate:St,ivec2:Vi,ivec3:uu,ivec4:co,js:_P,label:I,length:$s,lengthSq:Gp,lessThan:N0,lessThanEqual:P0,lightPosition:Vv,lightProjectionUV:gw,lightShadowMatrix:Bx,lightTargetDirection:Gv,lightTargetPosition:xw,lightViewPosition:zv,lightingContext:U1,lights:EL,linearDepth:Nd,linearToneMapping:ow,localId:UP,log:Su,log2:Wo,logarithmicDepthToViewZ:NC,luminance:Fv,mat2:cl,mat3:Ni,mat4:sc,matcapUV:DM,materialAO:T1,materialAlphaTest:QT,materialAnisotropy:d1,materialAnisotropyVector:Ad,materialAttenuationColor:b1,materialAttenuationDistance:y1,materialClearcoat:o1,materialClearcoatNormal:c1,materialClearcoatRoughness:a1,materialColor:lx,materialDispersion:S1,materialEmissive:e1,materialEnvIntensity:rx,materialEnvRotation:Gb,materialIOR:_1,materialIridescence:f1,materialIridescenceIOR:p1,materialIridescenceThickness:m1,materialLightMap:ev,materialLineDashOffset:Jb,materialLineDashSize:Yb,materialLineGapSize:Qb,materialLineScale:Zb,materialLineWidth:dx,materialMetalness:r1,materialNormal:s1,materialOpacity:ux,materialPointSize:v1,materialReference:yc,materialReflectivity:hx,materialRefractionRatio:IT,materialRotation:l1,materialRoughness:i1,materialSheen:u1,materialSheenRoughness:h1,materialShininess:JT,materialSpecular:t1,materialSpecularColor:n1,materialSpecularIntensity:Kb,materialSpecularStrength:em,materialThickness:x1,materialTransmission:g1,max:Mi,maxMipLevel:Lb,mediumpModelViewMatrix:ET,metalness:ll,min:Kn,mix:Xn,mixElement:o,mod:Ws,modInt:Op,modelDirection:O3,modelNormalMatrix:AT,modelPosition:k3,modelRadius:wT,modelScale:V3,modelViewMatrix:_c,modelViewPosition:z3,modelViewProjection:tv,modelWorldMatrix:go,modelWorldMatrixInverse:G3,morphReference:D1,mrt:XM,mul:cn,mx_aastep:Hw,mx_add:TI,mx_atan2:RI,mx_cell_noise_float:_I,mx_contrast:lI,mx_divide:AI,mx_fractal_noise_float:yI,mx_fractal_noise_vec2:bI,mx_fractal_noise_vec3:vI,mx_fractal_noise_vec4:SI,mx_frame:PI,mx_heighttonormal:VI,mx_hsvtorgb:JL,mx_ifequal:UI,mx_ifgreater:II,mx_ifgreatereq:DI,mx_invert:LI,mx_modulo:EI,mx_multiply:wI,mx_noise_float:uI,mx_noise_vec3:hI,mx_noise_vec4:dI,mx_place2d:BI,mx_power:CI,mx_ramp4:rI,mx_ramplr:nI,mx_ramptb:iI,mx_rgbtohsv:eI,mx_rotate2d:OI,mx_rotate3d:kI,mx_safepower:cI,mx_separate:FI,mx_splitlr:sI,mx_splittb:oI,mx_srgb_texture_to_lin_rec709:tI,mx_subtract:MI,mx_timer:NI,mx_transform_uv:aI,mx_unifiednoise2d:fI,mx_unifiednoise3d:pI,mx_worley_noise_float:mI,mx_worley_noise_vec2:gI,mx_worley_noise_vec3:xI,negate:Tb,neutralToneMapping:hw,nodeArray:ua,nodeImmutable:pt,nodeObject:Oe,nodeObjectIntent:al,nodeObjects:cu,nodeProxy:sn,nodeProxyIntent:at,normalFlat:RT,normalGeometry:ix,normalLocal:Ss,normalMap:Xb,normalView:ri,normalViewGeometry:Md,normalWorld:ml,normalWorldGeometry:NT,normalize:Er,not:D0,notEqual:mb,numWorkgroups:LP,objectDirection:I3,objectGroup:dd,objectPosition:MT,objectRadius:B3,objectScale:U3,objectViewPosition:F3,objectWorldMatrix:D3,oneMinus:q0,or:I0,orthographicDepthToViewZ:RC,oscSawtooth:xN,oscSine:pN,oscSquare:mN,oscTriangle:gN,output:ac,outputStruct:Q2,overlay:WC,overloadingFn:Gr,parabola:Nv,parallaxDirection:KT,parallaxUV:rC,parameter:j2,pass:lP,passTexture:uP,pcurve:aN,perspectiveDepthToViewZ:ov,pmremTexture:Ev,pointShadow:Bw,pointUV:XN,pointWidth:hb,positionGeometry:zr,positionLocal:er,positionPrevious:nx,positionView:tr,positionViewDirection:Ai,positionWorld:Ks,positionWorldDirection:Ob,posterize:cP,pow:kr,pow2:Au,pow3:Rb,pow4:Z0,premultiplyAlpha:H1,property:Vs,quadBroadcast:ML,quadSwapDiagonal:_L,quadSwapX:gL,quadSwapY:xL,radians:$0,rand:n,range:NP,rangeFog:EP,rangeFogFactor:Bv,reciprocal:wb,reference:xi,referenceBuffer:Hb,reflect:wu,reflectVector:FT,reflectView:DT,reflector:EN,refract:Wp,refractVector:BT,refractView:UT,reinhardToneMapping:aw,remap:ei,remapClamp:Gn,renderGroup:Ft,renderOutput:Vr,rendererReference:Di,rotate:sm,rotateUV:_N,roughness:zs,round:Mb,rtt:ZM,sRGBTransferEOTF:lt,sRGBTransferOETF:mt,sample:BN,sampler:S3,samplerComparison:T3,saturate:bd,saturation:iP,screen:GC,screenCoordinate:Yp,screenDPR:vT,screenSize:Nu,screenUV:mc,scriptable:AP,scriptableValue:Ix,select:S,setCurrentStack:ic,setName:L,shaderStages:yp,shadow:Iw,shadowPositionWorld:$v,shapeCircle:VL,sharedUniformGroup:bu,sheen:da,sheenRoughness:fu,shiftLeft:Jn,shiftRight:gb,shininess:ld,sign:gd,sin:jr,sinc:cN,skinning:P1,smoothstep:bs,smoothstepElement:l,specularColor:as,specularF90:hl,spherizeUV:yN,split:cd,spritesheetUV:TN,sqrt:Br,stack:Mx,step:Pi,stepElement:u,storage:Iu,storageBarrier:kP,storageObject:_C,storageTexture:JM,string:ha,struct:Y2,sub:Cn,subBuild:Re,subgroupAdd:nL,subgroupAll:fL,subgroupAnd:cL,subgroupAny:pL,subgroupBallot:tL,subgroupBroadcast:yL,subgroupBroadcastFirst:mL,subgroupElect:eL,subgroupExclusiveAdd:rL,subgroupExclusiveMul:aL,subgroupInclusiveAdd:iL,subgroupInclusiveMul:oL,subgroupIndex:lC,subgroupMax:dL,subgroupMin:hL,subgroupMul:sL,subgroupOr:lL,subgroupShuffle:bL,subgroupShuffleDown:TL,subgroupShuffleUp:SL,subgroupShuffleXor:vL,subgroupSize:FP,subgroupXor:uL,tan:Vp,tangentGeometry:ox,tangentLocal:Jp,tangentView:ax,tangentWorld:XT,texture:In,texture3D:ew,textureBarrier:VP,textureBicubic:vR,textureBicubicLevel:mv,textureCubeUV:SM,textureLevel:v3,textureLoad:ji,textureSize:fc,textureStore:KN,thickness:Fp,time:Id,toneMapping:ls,toneMappingExposure:hc,toonOutlinePass:fP,transformDirection:Nb,transformNormal:PT,transformNormalToView:Vb,transformedClearcoatNormalView:j3,transformedNormalView:H3,transformedNormalWorld:$3,transmission:Up,transpose:Tu,triNoise3D:uN,triplanarTexture:MN,triplanarTextures:KM,trunc:K0,uint:Je,uintBitsToFloat:rN,uniform:Bt,uniformArray:Xr,uniformCubeTexture:q3,uniformFlow:N,uniformGroup:yu,uniformTexture:b3,unpremultiplyAlpha:kC,userData:JN,uv:hi,uvec2:A0,uvec3:zo,uvec4:Ip,varying:We,varyingProperty:lr,vec2:Ve,vec3:ce,vec4:At,vectorComponents:Ja,velocity:tP,vertexColor:k1,vertexIndex:M1,vertexStage:ze,vibrance:rP,viewZToLogarithmicDepth:av,viewZToOrthographicDepth:Rd,viewZToPerspectiveDepth:sv,viewport:Sd,viewportCoordinate:ST,viewportDepthTexture:rv,viewportLinearDepth:PC,viewportMipTexture:iv,viewportResolution:C3,viewportSafeUV:vN,viewportSharedTexture:$1,viewportSize:Ub,viewportTexture:EC,viewportUV:E3,wgsl:yP,wgslFn:SP,workgroupArray:WP,workgroupBarrier:OP,workgroupId:IP,workingToColorSpace:pi,xor:U0});const Ko=new Rv;class GI extends yl{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,r){const s=this.renderer,a=this.nodes.getBackgroundNode(e)||e.background;let c=!1;if(a===null)s._clearColor.getRGB(Ko),Ko.a=s._clearColor.a;else if(a.isColor===!0)a.getRGB(Ko),Ko.a=1,c=!0;else if(a.isNode===!0){const f=this.get(e),m=a;Ko.copy(s._clearColor);let x=f.backgroundMesh;if(x===void 0){let P=function(){a.removeEventListener("dispose",P),x.material.dispose(),x.geometry.dispose()};const v=R(At(m).mul(Uv),{getUV:()=>QM.mul(NT),getTextureLevel:()=>YM});let T=tv;T=T.setZ(T.w);const w=new Gi;w.name="Background.material",w.side=d._Li,w.depthTest=!1,w.depthWrite=!1,w.allowOverride=!1,w.fog=!1,w.lights=!1,w.vertexNode=T,w.colorNode=v,f.backgroundMeshNode=v,f.backgroundMesh=x=new d.Kj0(new d.xo$(1,32,32),w),x.frustumCulled=!1,x.name="Background.mesh",x.onBeforeRender=function(C,E,D){this.matrixWorld.copyPosition(D.matrixWorld)},a.addEventListener("dispose",P)}const _=m.getCacheKey();f.backgroundCacheKey!==_&&(f.backgroundMeshNode.node=At(m).mul(Uv),f.backgroundMeshNode.needsUpdate=!0,x.material.needsUpdate=!0,f.backgroundCacheKey=_),t.unshift(x,x.geometry,x.material,0,0,null,null)}else(0,d.vUy)("Renderer: Unsupported background configuration.",a);const h=s.xr.getEnvironmentBlendMode();if(h==="additive"?Ko.set(0,0,0,1):h==="alpha-blend"&&Ko.set(0,0,0,0),s.autoClear===!0||c===!0){const f=r.clearColorValue;f.r=Ko.r,f.g=Ko.g,f.b=Ko.b,f.a=Ko.a,(s.backend.isWebGLBackend===!0||s.alpha===!0)&&(f.r*=f.a,f.g*=f.a,f.b*=f.a),r.depthClearValue=s._clearDepth,r.stencilClearValue=s._clearStencil,r.clearColor=s.autoClearColor===!0,r.clearDepth=s.autoClearDepth===!0,r.clearStencil=s.autoClearStencil===!0}else r.clearColor=!1,r.clearDepth=!1,r.clearStencil=!1}}let WI=0;class Qv{constructor(e="",t=[],r=0,s=[]){this.name=e,this.bindings=t,this.index=r,this.bindingsReference=s,this.id=WI++}}class HI{constructor(e,t,r,s,a,c,h,f,m,x=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=r,this.transforms=x,this.nodeAttributes=s,this.bindings=a,this.updateNodes=c,this.updateBeforeNodes=h,this.updateAfterNodes=f,this.observer=m,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings)if(t.bindings[0].groupNode.shared!==!0){const s=new Qv(t.name,[],t.index,t.bindingsReference);e.push(s);for(const a of t.bindings)s.bindings.push(a.clone())}else e.push(t);return e}}class qw{constructor(e,t,r=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=r}}class $I{constructor(e,t,r){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=r}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 Kw{constructor(e,t,r=!1,s=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=r,this.count=s}}class jI extends Kw{constructor(e,t,r=null,s=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=r,this.interpolationSampling=s}}class XI{constructor(e,t,r=""){this.name=e,this.type=t,this.code=r,Object.defineProperty(this,"isNodeCode",{value:!0})}}let qI=0;class Jv{constructor(e=null){this.id=qI++,this.nodesData=new WeakMap,this.parent=e}getData(e){let t=this.nodesData.get(e);return t===void 0&&this.parent!==null&&(t=this.parent.getData(e)),t}setData(e,t){this.nodesData.set(e,t)}}class KI{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class vl{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 ZI extends vl{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class YI extends vl{constructor(e,t=new d.FM8){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class QI extends vl{constructor(e,t=new d.Pa4){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class JI extends vl{constructor(e,t=new d.Ltg){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class eD extends vl{constructor(e,t=new d.Ilk){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class tD extends vl{constructor(e,t=new d.UcC){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class nD extends vl{constructor(e,t=new d.Vkp){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class iD extends vl{constructor(e,t=new d.yGw){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class rD extends ZI{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class sD extends YI{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class oD extends QI{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class aD extends JI{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class cD extends eD{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class lD extends tD{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class uD extends nD{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class hD extends iD{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}let dD=0;const Zw=new WeakMap,fD=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),Wx=i=>/e/g.test(i)?String(i).replace(/\+/g,""):(i=Number(i),i+(i%1?"":".0"));class Yw{constructor(e,t,r){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=r,this.scene=null,this.camera=null,this.nodes=[],this.sequentialNodes=[],this.updateNodes=[],this.updateBeforeNodes=[],this.updateAfterNodes=[],this.hashNodes={},this.observer=null,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.types={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.declarations={},this.flow={code:""},this.chaining=[],this.stack=Mx(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new Jv,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.activeStacks=[],this.subBuildFn=null,this.fnCall=null,Object.defineProperty(this,"id",{value:dD++})}isOpaque(){const e=this.material;return e.transparent===!1&&e.blending===d.bdR&&e.alphaToCoverage===!1}getBindGroupsCache(){let e=Zw.get(this.renderer);return e===void 0&&(e=new Xo,Zw.set(this.renderer,e)),e}createRenderTarget(e,t,r){return new d.ACn(e,t,r)}createCubeRenderTarget(e,t){return new X1(e,t)}includes(e){return this.nodes.includes(e)}getOutputStructName(){}_getBindGroup(e,t){const r=this.getBindGroupsCache(),s=[];let a=!0;for(const h of t)s.push(h),a=a&&h.groupNode.shared!==!0;let c;return a?(c=r.get(s),c===void 0&&(c=new Qv(e,s,this.bindingsIndexes[e].group,s),r.set(s,c))):c=new Qv(e,s,this.bindingsIndexes[e].group,s),c}getBindGroupArray(e,t){const r=this.bindings[t];let s=r[e];return s===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),r[e]=s=[]),s}getBindings(){let e=this.bindGroups;if(e===null){const t={},r=this.bindings;for(const s of yp)for(const a in r[s]){const c=r[s][a];(t[a]||(t[a]=[])).push(...c)}e=[];for(const s in t){const a=t[s],c=this._getBindGroup(s,a);e.push(c)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((t,r)=>t.bindings[0].groupNode.order-r.bindings[0].groupNode.order);for(let t=0;t<e.length;t++){const r=e[t];this.bindingsIndexes[r.name].group=t,r.index=t}}setHashNode(e,t){this.hashNodes[t]=e}addNode(e){this.nodes.includes(e)===!1&&(this.nodes.push(e),this.setHashNode(e,e.getHash(this)))}addSequentialNode(e){this.sequentialNodes.includes(e)===!1&&this.sequentialNodes.push(e)}buildUpdateNodes(){for(const e of this.nodes)e.getUpdateType()!==xn.NONE&&this.updateNodes.push(e);for(const e of this.sequentialNodes){const t=e.getUpdateBeforeType(),r=e.getUpdateAfterType();t!==xn.NONE&&this.updateBeforeNodes.push(e),r!==xn.NONE&&this.updateAfterNodes.push(e)}}get currentNode(){return this.chaining[this.chaining.length-1]}isFilteredTexture(e){return e.magFilter===d.wem||e.magFilter===d.qyh||e.magFilter===d.aH4||e.magFilter===d.D1R||e.minFilter===d.wem||e.minFilter===d.qyh||e.minFilter===d.aH4||e.minFilter===d.D1R}addChain(e){this.chaining.push(e)}removeChain(e){if(this.chaining.pop()!==e)throw new Error("NodeBuilder: Invalid node chaining!")}getMethod(e){return e}getTernary(){return null}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}addContext(e){const t=this.getContext();return this.setContext(rr(rr({},this.context),e)),t}getSharedContext(){return rr({},this.context),this.context}setCache(e){this.cache=e}getCache(){return this.cache}getCacheFromNode(e,t=!0){const r=this.getDataFromNode(e);return r.cache===void 0&&(r.cache=new Jv(t?this.getCache():null)),r.cache}isAvailable(){return!1}getVertexIndex(){(0,d.ZK6)("Abstract function.")}getInstanceIndex(){(0,d.ZK6)("Abstract function.")}getDrawIndex(){(0,d.ZK6)("Abstract function.")}getFrontFacing(){(0,d.ZK6)("Abstract function.")}getFragCoord(){(0,d.ZK6)("Abstract function.")}isFlipY(){return!1}increaseUsage(e){const t=this.getDataFromNode(e);return t.usageCount=t.usageCount===void 0?1:t.usageCount+1,t.usageCount}generateTexture(){(0,d.ZK6)("Abstract function.")}generateTextureLod(){(0,d.ZK6)("Abstract function.")}generateArrayDeclaration(e,t){return this.getType(e)+"[ "+t+" ]"}generateArray(e,t,r=null){let s=this.generateArrayDeclaration(e,t)+"( ";for(let a=0;a<t;a++){const c=r?r[a]:null;c!==null?s+=c.build(this,e):s+=this.generateConst(e),a<t-1&&(s+=", ")}return s+=" )",s}generateStruct(e,t,r=null){const s=[];for(const a of t){const{name:c,type:h}=a;r&&r[c]&&r[c].isNode?s.push(r[c].build(this,h)):s.push(this.generateConst(h))}return e+"( "+s.join(", ")+" )"}generateConst(e,t=null){if(t===null&&(e==="float"||e==="int"||e==="uint"?t=0:e==="bool"?t=!1:e==="color"?t=new d.Ilk:e==="vec2"?t=new d.FM8:e==="vec3"?t=new d.Pa4:e==="vec4"&&(t=new d.Ltg)),e==="float")return Wx(t);if(e==="int")return`${Math.round(t)}`;if(e==="uint")return t>=0?`${Math.round(t)}u`:"0u";if(e==="bool")return t?"true":"false";if(e==="color")return`${this.getType("vec3")}( ${Wx(t.r)}, ${Wx(t.g)}, ${Wx(t.b)} )`;const r=this.getTypeLength(e),s=this.getComponentType(e),a=c=>this.generateConst(s,c);if(r===2)return`${this.getType(e)}( ${a(t.x)}, ${a(t.y)} )`;if(r===3)return`${this.getType(e)}( ${a(t.x)}, ${a(t.y)}, ${a(t.z)} )`;if(r===4&&e!=="mat2")return`${this.getType(e)}( ${a(t.x)}, ${a(t.y)}, ${a(t.z)}, ${a(t.w)} )`;if(r>=4&&t&&(t.isMatrix2||t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(a).join(", ")} )`;if(r>4)return`${this.getType(e)}()`;throw new Error(`NodeBuilder: Type '${e}' not found in generate constant attempt.`)}getType(e){return e==="color"?"vec3":e}hasGeometryAttribute(e){return this.geometry&&this.geometry.getAttribute(e)!==void 0}getAttribute(e,t){const r=this.attributes;for(const a of r)if(a.name===e)return a;const s=new qw(e,t);return this.registerDeclaration(s),r.push(s),s}getPropertyName(e){return e.name}isVector(e){return/vec\d/.test(e)}isMatrix(e){return/mat\d/.test(e)}isReference(e){return e==="void"||e==="property"||e==="sampler"||e==="samplerComparison"||e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="depthTexture"||e==="texture3D"}needsToWorkingColorSpace(){return!1}getComponentTypeFromTexture(e){const t=e.type;if(e.isDataTexture){if(t===d.Kz5)return"int";if(t===d.JQ4)return"uint"}return"float"}getElementType(e){return e==="mat2"?"vec2":e==="mat3"?"vec3":e==="mat4"?"vec4":this.getComponentType(e)}getComponentType(e){if(e=this.getVectorType(e),e==="float"||e==="bool"||e==="int"||e==="uint")return e;const t=/(b|i|u|)(vec|mat)([2-4])/.exec(e);return t===null?null:t[1]==="b"?"bool":t[1]==="i"?"int":t[1]==="u"?"uint":"float"}getVectorType(e){return e==="color"?"vec3":e==="texture"||e==="cubeTexture"||e==="storageTexture"||e==="texture3D"?"vec4":e}getTypeFromLength(e,t="float"){if(e===1)return t;let r=mp(e);const s=t==="float"?"":t[0];return/mat2/.test(t)===!0&&(r=r.replace("vec","mat")),s+r}getTypeFromArray(e){return fD.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const r=t.array,s=e.itemSize,a=e.normalized;let c;return!(e instanceof d.e62)&&a!==!0&&(c=this.getTypeFromArray(r)),this.getTypeFromLength(s,c)}getTypeLength(e){const t=this.getVectorType(e),r=/vec([2-4])/.exec(t);return r!==null?Number(r[1]):t==="float"||t==="bool"||t==="int"||t==="uint"?1:/mat2/.test(e)===!0?4:/mat3/.test(e)===!0?9:/mat4/.test(e)===!0?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 t==="int"||t==="uint"?e:this.changeComponentType(e,"int")}setActiveStack(e){this.activeStacks.push(e)}removeActiveStack(e){if(this.activeStacks[this.activeStacks.length-1]===e)this.activeStacks.pop();else throw new Error("NodeBuilder: Invalid active stack removal.")}getActiveStack(){return this.activeStacks[this.activeStacks.length-1]}getBaseStack(){return this.activeStacks[0]}addStack(){this.stack=Mx(this.stack);const e=Pp();return this.stacks.push(e),ic(this.stack),this.stack}removeStack(){const e=this.stack;for(const t of e.nodes){const r=this.getDataFromNode(t);r.stack=e}return this.stack=e.parent,ic(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,r=null){r=r===null?e.isGlobal(this)?this.globalCache:this.cache:r;let s=r.getData(e);s===void 0&&(s={},r.setData(e,s)),s[t]===void 0&&(s[t]={});let a=s[t];const c=s.any?s.any.subBuilds:null,h=this.getClosestSubBuild(c);return h&&(a.subBuildsCache===void 0&&(a.subBuildsCache={}),a=a.subBuildsCache[h]||(a.subBuildsCache[h]={}),a.subBuilds=c),a}getNodeProperties(e,t="any"){const r=this.getDataFromNode(e,t);return r.properties||(r.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const r=this.getDataFromNode(e);let s=r.bufferAttribute;if(s===void 0){const a=this.uniforms.index++;s=new qw("nodeAttribute"+a,t,e),this.bufferAttributes.push(s),r.bufferAttribute=s}return s}getStructTypeNode(e,t=this.shaderStage){return this.types[t][e]||null}getStructTypeFromNode(e,t,r=null,s=this.shaderStage){const a=this.getDataFromNode(e,s,this.globalCache);let c=a.structType;if(c===void 0){const h=this.structs.index++;r===null&&(r="StructType"+h),c=new KI(r,t),this.structs[s].push(c),this.types[s][r]=e,a.structType=c}return c}getOutputStructTypeFromNode(e,t){const r=this.getStructTypeFromNode(e,t,"OutputType","fragment");return r.output=!0,r}getUniformFromNode(e,t,r=this.shaderStage,s=null){const a=this.getDataFromNode(e,r,this.globalCache);let c=a.uniform;if(c===void 0){const h=this.uniforms.index++;c=new $I(s||"nodeUniform"+h,t,e),this.uniforms[r].push(c),this.registerDeclaration(c),a.uniform=c}return c}getVarFromNode(e,t=null,r=e.getNodeType(this),s=this.shaderStage,a=!1){const c=this.getDataFromNode(e,s),h=this.getSubBuildProperty("variable",c.subBuilds);let f=c[h];if(f===void 0){const m=a?"_const":"_var",x=this.vars[s]||(this.vars[s]=[]),_=this.vars[m]||(this.vars[m]=0);t===null&&(t=(a?"nodeConst":"nodeVar")+_,this.vars[m]++),h!=="variable"&&(t=this.getSubBuildProperty(t,c.subBuilds));const v=e.getArrayCount(this);f=new Kw(t,r,a,v),a||x.push(f),this.registerDeclaration(f),c[h]=f}return f}isDeterministic(e){if(e.isMathNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0)&&(e.cNode?this.isDeterministic(e.cNode):!0);if(e.isOperatorNode)return this.isDeterministic(e.aNode)&&(e.bNode?this.isDeterministic(e.bNode):!0);if(e.isArrayNode){if(e.values!==null){for(const t of e.values)if(!this.isDeterministic(t))return!1}return!0}else if(e.isConstNode)return!0;return!1}getVaryingFromNode(e,t=null,r=e.getNodeType(this),s=null,a=null){const c=this.getDataFromNode(e,"any"),h=this.getSubBuildProperty("varying",c.subBuilds);let f=c[h];if(f===void 0){const m=this.varyings,x=m.length;t===null&&(t="nodeVarying"+x),h!=="varying"&&(t=this.getSubBuildProperty(t,c.subBuilds)),f=new jI(t,r,s,a),m.push(f),this.registerDeclaration(f),c[h]=f}return f}registerDeclaration(e){const t=this.shaderStage,r=this.declarations[t]||(this.declarations[t]={}),s=this.getPropertyName(e);let a=1,c=s;for(;r[c]!==void 0;)c=s+"_"+a++;a>1&&(e.name=c,(0,d.ZK6)(`TSL: Declaration name '${s}' of '${e.type}' already in use. Renamed to '${c}'.`)),r[c]=e}getCodeFromNode(e,t,r=this.shaderStage){const s=this.getDataFromNode(e);let a=s.code;if(a===void 0){const c=this.codes[r]||(this.codes[r]=[]),h=c.length;a=new XI("nodeCode"+h,t),c.push(a),s.code=a}return a}addFlowCodeHierarchy(e,t){const{flowCodes:r,flowCodeBlock:s}=this.getDataFromNode(e);let a=!0,c=t;for(;c;){if(s.get(c)===!0){a=!1;break}c=this.getDataFromNode(c).parentNodeBlock}if(a)for(const h of r)this.addLineFlowCode(h)}addLineFlowCodeBlock(e,t,r){const s=this.getDataFromNode(e),a=s.flowCodes||(s.flowCodes=[]),c=s.flowCodeBlock||(s.flowCodeBlock=new WeakMap);a.push(t),c.set(r,!0)}addLineFlowCode(e,t=null){return e===""?this:(t!==null&&this.context.nodeBlock&&this.addLineFlowCodeBlock(t,e,this.context.nodeBlock),e=this.tab+e,/;\s*$/.test(e)||(e=e+`;
`),this.flow.code+=e,this)}addFlowCode(e){return this.flow.code+=e,this}addFlowTab(){return this.tab+=" ",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),r=this.flowChildNode(e,t);return this.flowsData.set(e,r),r}addInclude(e){this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){const t=new dw,r=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=r,t}flowShaderNode(e){const t=e.layout,r={[Symbol.iterator](){let c=0;const h=Object.values(this);return{next:()=>({value:h[c],done:c++>=h.length})}}};for(const c of t.inputs)r[c.name]=new HM(c.type,c.name);e.layout=null;const s=e.call(r),a=this.flowStagesNode(s,t.type);return e.layout=t,a}flowBuildStage(e,t,r=null){const s=this.getBuildStage();this.setBuildStage(t);const a=e.build(this,r);return this.setBuildStage(s),a}flowStagesNode(e,t=null){const r=this.flow,s=this.vars,a=this.declarations,c=this.cache,h=this.buildStage,f=this.stack,m={code:""};this.flow=m,this.vars={},this.declarations={},this.cache=new Jv,this.stack=Mx();for(const x of _p)this.setBuildStage(x),m.result=e.build(this,t);return m.vars=this.getVars(this.shaderStage),this.flow=r,this.vars=s,this.declarations=a,this.cache=c,this.stack=f,this.setBuildStage(h),m}getFunctionOperator(){return null}buildFunctionCode(){(0,d.ZK6)("Abstract function.")}flowChildNode(e,t=null){const r=this.flow,s={code:""};return this.flow=s,s.result=e.build(this,t),this.flow=r,s}flowNodeFromShaderStage(e,t,r=null,s=null){const a=this.tab,c=this.cache,h=this.shaderStage,f=this.context;this.setShaderStage(e);const m=rr({},this.context);delete m.nodeBlock,this.cache=this.globalCache,this.tab=" ",this.context=m;let x=null;if(this.buildStage==="generate"){const _=this.flowChildNode(t,r);s!==null&&(_.code+=`${this.tab+s} = ${_.result};
`),this.flowCode[e]=this.flowCode[e]+_.code,x=_}else x=t.build(this);return this.setShaderStage(h),this.cache=c,this.tab=a,this.context=f,x}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){(0,d.ZK6)("Abstract function.")}getVaryings(){(0,d.ZK6)("Abstract function.")}getVar(e,t,r=null){return`${r!==null?this.generateArrayDeclaration(e,r):this.getType(e)} ${t}`}getVars(e){let t="";const r=this.vars[e];if(r!==void 0)for(const s of r)t+=`${this.getVar(s.type,s.name)}; `;return t}getUniforms(){(0,d.ZK6)("Abstract function.")}getCodes(e){const t=this.codes[e];let r="";if(t!==void 0)for(const s of t)r+=s.code+`
`;return r}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(){(0,d.ZK6)("Abstract function.")}get subBuild(){return this.subBuildLayers[this.subBuildLayers.length-1]||null}addSubBuild(e){this.subBuildLayers.push(e)}removeSubBuild(){return this.subBuildLayers.pop()}getClosestSubBuild(e){let t;if(e&&e.isNode?e.isShaderCallNodeInternal?t=e.shaderNode.subBuilds:e.isStackNode?t=[e.subBuild]:t=this.getDataFromNode(e,"any").subBuilds:e instanceof Set?t=[...e]:t=e,!t)return null;const r=this.subBuildLayers;for(let s=t.length-1;s>=0;s--){const a=t[s];if(r.includes(a))return a}return null}getSubBuildOutput(e){return this.getSubBuildProperty("outputNode",e)}getSubBuildProperty(e="",t=null){let r;t!==null?r=this.getClosestSubBuild(t):r=this.subBuildFn;let s;return r?s=e?r+"_"+e:r:s=e,s}build(){const{object:e,material:t,renderer:r}=this;if(t!==null){let s=r.library.fromMaterial(t);s===null&&((0,d.vUy)(`NodeMaterial: Material "${t.type}" is not compatible.`),s=new Gi),s.build(this)}else this.addFlow("compute",e);for(const s of _p){this.setBuildStage(s),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const a of yp){this.setShaderStage(a);const c=this.flowNodes[a];for(const h of c)s==="generate"?this.flowNode(h):h.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getNodeUniform(e,t){if(t==="float"||t==="int"||t==="uint")return new rD(e);if(t==="vec2"||t==="ivec2"||t==="uvec2")return new sD(e);if(t==="vec3"||t==="ivec3"||t==="uvec3")return new oD(e);if(t==="vec4"||t==="ivec4"||t==="uvec4")return new aD(e);if(t==="color")return new cD(e);if(t==="mat2")return new lD(e);if(t==="mat3")return new uD(e);if(t==="mat4")return new hD(e);throw new Error(`Uniform "${t}" not declared.`)}format(e,t,r){if(t=this.getVectorType(t),r=this.getVectorType(r),t===r||r===null||this.isReference(r))return e;const s=this.getTypeLength(t),a=this.getTypeLength(r);return s===16&&a===9?`${this.getType(r)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:s===9&&a===4?`${this.getType(r)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:s>4||a>4||a===0?e:s===a?`${this.getType(r)}( ${e} )`:s>a?(e=r==="bool"?`all( ${e} )`:`${e}.${"xyz".slice(0,a)}`,this.format(e,this.getTypeFromLength(a,this.getComponentType(t)),r)):a===4&&s>1?`${this.getType(r)}( ${this.format(e,t,"vec3")}, 1.0 )`:s===2?`${this.getType(r)}( ${this.format(e,t,"vec2")}, 0.0 )`:(s===1&&a>1&&t!==this.getComponentType(r)&&(e=`${this.getType(this.getComponentType(r))}( ${e} )`),`${this.getType(r)}( ${e} )`)}getSignature(){return`// Three.js r${d.UZH} - Node System
`}}class Qw{constructor(){this.time=0,this.deltaTime=0,this.frameId=0,this.renderId=0,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 r=e.get(t);return r===void 0&&(r={renderId:0,frameId:0},e.set(t,r)),r}updateBeforeNode(e){const t=e.getUpdateBeforeType(),r=e.updateReference(this);if(t===xn.FRAME){const s=this._getMaps(this.updateBeforeMap,r);s.frameId!==this.frameId&&e.updateBefore(this)!==!1&&(s.frameId=this.frameId)}else if(t===xn.RENDER){const s=this._getMaps(this.updateBeforeMap,r);s.renderId!==this.renderId&&e.updateBefore(this)!==!1&&(s.renderId=this.renderId)}else t===xn.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),r=e.updateReference(this);if(t===xn.FRAME){const s=this._getMaps(this.updateAfterMap,r);s.frameId!==this.frameId&&e.updateAfter(this)!==!1&&(s.frameId=this.frameId)}else if(t===xn.RENDER){const s=this._getMaps(this.updateAfterMap,r);s.renderId!==this.renderId&&e.updateAfter(this)!==!1&&(s.renderId=this.renderId)}else t===xn.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),r=e.updateReference(this);if(t===xn.FRAME){const s=this._getMaps(this.updateMap,r);s.frameId!==this.frameId&&e.update(this)!==!1&&(s.frameId=this.frameId)}else if(t===xn.RENDER){const s=this._getMaps(this.updateMap,r);s.renderId!==this.renderId&&e.update(this)!==!1&&(s.renderId=this.renderId)}else t===xn.OBJECT&&e.update(this)}update(){this.frameId++,this.lastTime===void 0&&(this.lastTime=performance.now()),this.deltaTime=(performance.now()-this.lastTime)/1e3,this.lastTime=performance.now(),this.time+=this.deltaTime}}class eS{constructor(e,t,r=null,s="",a=!1){this.type=e,this.name=t,this.count=r,this.qualifier=s,this.isConst=a}}eS.isNodeFunctionInput=!0;class pD extends Vu{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:Gv(this.light),lightColor:e}}}const tS=new d.yGw,Hx=new d.yGw;let Sm=null;class mD extends Vu{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=Bt(new d.Pa4).setGroup(Ft),this.halfWidth=Bt(new d.Pa4).setGroup(Ft),this.updateType=xn.RENDER}update(e){super.update(e);const{light:t}=this,r=e.camera.matrixWorldInverse;Hx.identity(),tS.copy(t.matrixWorld),tS.premultiply(r),Hx.extractRotation(tS),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(Hx),this.halfHeight.value.applyMatrix4(Hx)}setupDirectRectArea(e){let t,r;e.isAvailable("float32Filterable")?(t=In(Sm.LTC_FLOAT_1),r=In(Sm.LTC_FLOAT_2)):(t=In(Sm.LTC_HALF_1),r=In(Sm.LTC_HALF_2));const{colorNode:s,light:a}=this,c=zv(a);return{lightColor:s,lightPosition:c,halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:r}}static setLTC(e){Sm=e}}class nS extends Vu{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=Bt(0).setGroup(Ft),this.penumbraCosNode=Bt(0).setGroup(Ft),this.cutoffDistanceNode=Bt(0).setGroup(Ft),this.decayExponentNode=Bt(0).setGroup(Ft),this.colorNode=Bt(this.color).setGroup(Ft)}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,t){const{coneCosNode:r,penumbraCosNode:s}=this;return bs(r,s,t)}getLightCoord(e){const t=e.getNodeProperties(this);let r=t.projectionUV;return r===void 0&&(r=gw(this.light,e.context.positionWorld),t.projectionUV=r),r}setupDirect(e){const{colorNode:t,cutoffDistanceNode:r,decayExponentNode:s,light:a}=this,c=this.getLightVector(e),h=c.normalize(),f=h.dot(Gv(a)),m=this.getSpotAttenuation(e,f),x=c.length(),_=Kv({lightDistance:x,cutoffDistance:r,decayExponent:s});let v=t.mul(m).mul(_),T,w;return a.colorNode?(w=this.getLightCoord(e),T=a.colorNode(w)):a.map&&(w=this.getLightCoord(e),T=In(a.map,w.xy).onRenderUpdate(()=>a.map)),T&&(v=w.mul(2).sub(1).abs().lessThan(1).all().select(v.mul(T),v)),{lightColor:v,lightDirection:h}}}class gD extends nS{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e,t){const r=this.light.iesMap;let s=null;if(r&&r.isTexture===!0){const a=t.acos().mul(1/Math.PI);s=In(r,Ve(a,0),0).r}else s=super.getSpotAttenuation(t);return s}}const xD=fe(([i,e])=>{const t=i.abs().sub(e);return $s(Mi(t,0)).add(Kn(Mi(t.x,t.y),0))});class _D extends nS{static get type(){return"ProjectorLightNode"}update(e){super.update(e);const t=this.light;if(this.penumbraCosNode.value=Math.min(Math.cos(t.angle*(1-t.penumbra)),.99999),t.aspect===null){let r=1;t.map!==null&&(r=t.map.width/t.map.height),t.shadow.aspect=r}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){const t=G(0),r=this.penumbraCosNode,s=Bx(this.light).mul(e.context.positionWorld||Ks);return Dt(s.w.greaterThan(0),()=>{const a=s.xyz.div(s.w),c=xD(a.xy.sub(Ve(.5)),Ve(.5)),h=cs(-1,Cn(1,uo(r)).sub(1));t.assign(bd(c.mul(-2).mul(h)))}),t}}class yD extends Vu{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class bD extends Vu{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=Vv(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=Bt(new d.Ilk).setGroup(Ft)}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:r,lightDirectionNode:s}=this,c=ml.dot(s).mul(.5).add(.5),h=Xn(r,t,c);e.context.irradiance.addAssign(h)}}class vD extends Vu{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let r=0;r<9;r++)t.push(new d.Pa4);this.lightProbe=Xr(t)}update(e){const{light:t}=this;super.update(e);for(let r=0;r<9;r++)this.lightProbe.array[r].copy(t.sh.coefficients[r]).multiplyScalar(t.intensity)}setup(e){const t=Xw(ml,this.lightProbe);e.context.irradiance.addAssign(t)}}class Jw{parseFunction(){(0,d.ZK6)("Abstract function.")}}class iS{constructor(e,t,r="",s=""){this.type=e,this.inputs=t,this.name=r,this.precision=s}getCode(){(0,d.ZK6)("Abstract function.")}}iS.isNodeFunction=!0;const SD=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,TD=/[a-z_0-9]+/ig,eA="#pragma main",MD=i=>{i=i.trim();const e=i.indexOf(eA),t=e!==-1?i.slice(e+eA.length):i,r=t.match(SD);if(r!==null&&r.length===5){const s=r[4],a=[];let c=null;for(;(c=TD.exec(s))!==null;)a.push(c);const h=[];let f=0;for(;f<a.length;){const w=a[f][0]==="const";w===!0&&f++;let P=a[f][0];P==="in"||P==="out"||P==="inout"?f++:P="";const C=a[f++][0];let E=Number.parseInt(a[f][0]);Number.isNaN(E)===!1?f++:E=null;const D=a[f++][0];h.push(new eS(C,D,E,P,w))}const m=t.substring(r[0].length),x=r[3]!==void 0?r[3]:"",_=r[2],v=r[1]!==void 0?r[1]:"",T=e!==-1?i.slice(0,e):"";return{type:_,inputs:h,name:x,precision:v,inputsCode:s,blockCode:m,headerCode:T}}else throw new Error("FunctionNode: Function is not a GLSL code.")};class wD extends iS{constructor(e){const{type:t,inputs:r,name:s,precision:a,inputsCode:c,blockCode:h,headerCode:f}=MD(e);super(t,r,s,a),this.inputsCode=c,this.blockCode=h,this.headerCode=f}getCode(e=this.name){let t;const r=this.blockCode;if(r!==""){const{type:s,inputsCode:a,headerCode:c,precision:h}=this;let f=`${s} ${e} ( ${a.trim()} )`;h!==""&&(f=`${h} ${f}`),t=c+f+r}else t="";return t}}class AD extends Jw{parseFunction(e){return new wD(e)}}const tA=new WeakMap,Ta=[],Sl=[];class ED extends yl{constructor(e,t){super(),this.renderer=e,this.backend=t,this.nodeFrame=new Qw,this.nodeBuilderCache=new Map,this.callHashCache=new Xo,this.groupsData=new Xo,this.cacheLib={}}updateGroup(e){const t=e.groupNode,r=t.name;if(r===dd.name)return!0;if(r===Ft.name){const a=this.get(e),c=this.nodeFrame.renderId;return a.renderId!==c?(a.renderId=c,!0):!1}if(r===fb.name){const a=this.get(e),c=this.nodeFrame.frameId;return a.frameId!==c?(a.frameId=c,!0):!1}Ta[0]=t,Ta[1]=e;let s=this.groupsData.get(Ta);return s===void 0&&this.groupsData.set(Ta,s={}),Ta.length=0,s.version!==t.version?(s.version=t.version,!0):!1}getForRenderCacheKey(e){return e.initialCacheKey}getForRender(e){const t=this.get(e);let r=t.nodeBuilderState;if(r===void 0){const{nodeBuilderCache:s}=this,a=this.getForRenderCacheKey(e);if(r=s.get(a),r===void 0){const c=f=>{const m=this.backend.createNodeBuilder(e.object,this.renderer);return m.scene=e.scene,m.material=f,m.camera=e.camera,m.context.material=f,m.lightsNode=e.lightsNode,m.environmentNode=this.getEnvironmentNode(e.scene),m.fogNode=this.getFogNode(e.scene),m.clippingContext=e.clippingContext,this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview&&m.enableMultiview(),m};let h=c(e.material);try{h.build()}catch(f){h=c(new Gi),h.build(),(0,d.vUy)("TSL: "+f)}r=this._createNodeBuilderState(h),s.set(a,r)}r.usedTimes++,t.nodeBuilderState=r}return r}delete(e){if(e.isRenderObject){const t=this.get(e).nodeBuilderState;t.usedTimes--,t.usedTimes===0&&this.nodeBuilderCache.delete(this.getForRenderCacheKey(e))}return super.delete(e)}getForCompute(e){const t=this.get(e);let r=t.nodeBuilderState;if(r===void 0){const s=this.backend.createNodeBuilder(e,this.renderer);s.build(),r=this._createNodeBuilderState(s),t.nodeBuilderState=r}return r}_createNodeBuilderState(e){return new HI(e.vertexShader,e.fragmentShader,e.computeShader,e.getAttributesArray(),e.getBindings(),e.updateNodes,e.updateBeforeNodes,e.updateAfterNodes,e.observer,e.transforms)}getEnvironmentNode(e){this.updateEnvironment(e);let t=null;if(e.environmentNode&&e.environmentNode.isNode)t=e.environmentNode;else{const r=this.get(e);r.environmentNode&&(t=r.environmentNode)}return t}getBackgroundNode(e){this.updateBackground(e);let t=null;if(e.backgroundNode&&e.backgroundNode.isNode)t=e.backgroundNode;else{const r=this.get(e);r.backgroundNode&&(t=r.backgroundNode)}return t}getFogNode(e){return this.updateFog(e),e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){Ta[0]=e,Ta[1]=t;const r=this.renderer.info.calls,s=this.callHashCache.get(Ta)||{};if(s.callId!==r){const a=this.getEnvironmentNode(e),c=this.getFogNode(e);t&&Sl.push(t.getCacheKey(!0)),a&&Sl.push(a.getCacheKey()),c&&Sl.push(c.getCacheKey()),Sl.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),Sl.push(this.renderer.shadowMap.enabled?1:0),Sl.push(this.renderer.shadowMap.type),s.callId=r,s.cacheKey=Os(Sl),this.callHashCache.set(Ta,s),Sl.length=0}return Ta.length=0,s.cacheKey}get isToneMappingState(){return!this.renderer.getRenderTarget()}updateBackground(e){const t=this.get(e),r=e.background;if(r){const s=e.backgroundBlurriness===0&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&t.backgroundBlurriness===0;if(t.background!==r||s){const a=this.getCacheNode("background",r,()=>{if(r.isCubeTexture===!0||r.mapping===d.dSO||r.mapping===d.Bf4||r.mapping===d.g8_){if(e.backgroundBlurriness>0||r.mapping===d.g8_)return Ev(r);{let c;return r.isCubeTexture===!0?c=wd(r):c=In(r),Z1(c)}}else{if(r.isTexture===!0)return In(r,mc.flipY()).setUpdateMatrix(!0);r.isColor!==!0&&(0,d.vUy)("WebGPUNodes: Unsupported background configuration.",r)}},s);t.backgroundNode=a,t.background=r,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,r,s=!1){const a=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let c=a.get(t);return(c===void 0||s)&&(c=r(),a.set(t,c)),c}updateFog(e){const t=this.get(e),r=e.fog;if(r){if(t.fog!==r){const s=this.getCacheNode("fog",r,()=>{if(r.isFogExp2){const a=xi("color","color",r).setGroup(Ft),c=xi("density","float",r).setGroup(Ft);return mm(a,Ov(c))}else if(r.isFog){const a=xi("color","color",r).setGroup(Ft),c=xi("near","float",r).setGroup(Ft),h=xi("far","float",r).setGroup(Ft);return mm(a,Bv(c,h))}else(0,d.vUy)("Renderer: Unsupported fog configuration.",r)});t.fogNode=s,t.fog=r}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),r=e.environment;if(r){if(t.environment!==r){const s=this.getCacheNode("environment",r,()=>{if(r.isCubeTexture===!0)return wd(r);if(r.isTexture===!0)return In(r);(0,d.vUy)("Nodes: Unsupported environment configuration.",r)});t.environmentNode=s,t.environment=r}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,r=null,s=null,a=null){const c=this.nodeFrame;return c.renderer=e,c.scene=t,c.object=r,c.camera=s,c.material=a,c}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+","+e.xr.isPresenting}hasOutputChange(e){return tA.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,r=this.getOutputCacheKey(),s=e.isArrayTexture?ew(e,ce(mc,pc("gl_ViewID_OVR"))).renderOutput(t.toneMapping,t.currentColorSpace):In(e,mc).renderOutput(t.toneMapping,t.currentColorSpace);return tA.set(e,r),s}updateBefore(e){const t=e.getNodeBuilderState();for(const r of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(r)}updateAfter(e){const t=e.getNodeBuilderState();for(const r of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(r)}updateForCompute(e){const t=this.getNodeFrame(),r=this.getForCompute(e);for(const s of r.updateNodes)t.updateNode(s)}updateForRender(e){const t=this.getNodeFrameForRender(e),r=e.getNodeBuilderState();for(const s of r.updateNodes)t.updateNode(s)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new Qw,this.nodeBuilderCache=new Map,this.cacheLib={}}}const rS=new d.JOQ;class $x{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new d.Vkp,this.clippingGroupContexts=new WeakMap,this.intersectionPlanes=[],this.unionPlanes=[],this.parentVersion=null,e!==null&&(this.viewNormalMatrix=e.viewNormalMatrix,this.clippingGroupContexts=e.clippingGroupContexts,this.shadowPass=e.shadowPass,this.viewMatrix=e.viewMatrix)}projectPlanes(e,t,r){const s=e.length;for(let a=0;a<s;a++){rS.copy(e[a]).applyMatrix4(this.viewMatrix,this.viewNormalMatrix);const c=t[r+a],h=rS.normal;c.x=-h.x,c.y=-h.y,c.z=-h.z,c.w=rS.constant}}updateGlobal(e,t){this.shadowPass=e.overrideMaterial!==null&&e.overrideMaterial.isShadowPassMaterial,this.viewMatrix=t.matrixWorldInverse,this.viewNormalMatrix.getNormalMatrix(this.viewMatrix)}update(e,t){let r=!1;e.version!==this.parentVersion&&(this.intersectionPlanes=Array.from(e.intersectionPlanes),this.unionPlanes=Array.from(e.unionPlanes),this.parentVersion=e.version),this.clipIntersection!==t.clipIntersection&&(this.clipIntersection=t.clipIntersection,this.clipIntersection?this.unionPlanes.length=e.unionPlanes.length:this.intersectionPlanes.length=e.intersectionPlanes.length);const s=t.clippingPlanes,a=s.length;let c,h;if(this.clipIntersection?(c=this.intersectionPlanes,h=e.intersectionPlanes.length):(c=this.unionPlanes,h=e.unionPlanes.length),c.length!==h+a){c.length=h+a;for(let f=0;f<a;f++)c[h+f]=new d.Ltg;r=!0}this.projectPlanes(s,c,h),r&&(this.version++,this.cacheKey=`${this.intersectionPlanes.length}:${this.unionPlanes.length}`)}getGroupContext(e){if(this.shadowPass&&!e.clipShadows)return this;let t=this.clippingGroupContexts.get(e);return t===void 0&&(t=new $x(this),this.clippingGroupContexts.set(e,t)),t.update(this,e),t}get unionClippingCount(){return this.unionPlanes.length}}class CD{constructor(e,t){this.bundleGroup=e,this.camera=t}}const Tm=[];class RD{constructor(){this.bundles=new Xo}get(e,t){const r=this.bundles;Tm[0]=e,Tm[1]=t;let s=r.get(Tm);return s===void 0&&(s=new CD(e,t),r.set(Tm,s)),Tm.length=0,s}dispose(){this.bundles=new Xo}}class nA{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map}fromMaterial(e){if(e.isNodeMaterial)return e;let t=null;const r=this.getMaterialNodeClass(e.type);if(r!==null){t=new r;for(const s in e)t[s]=e[s]}return t}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,this.materialNodes)}getLightNodeClass(e){return this.lightNodes.get(e)||null}addLight(e,t){this.addClass(e,t,this.lightNodes)}addType(e,t,r){if(r.has(t)){(0,d.ZK6)(`Redefinition of node ${t}`);return}if(typeof e!="function")throw new Error(`Node class ${e.name} is not a class.`);if(typeof t=="function"||typeof t=="object")throw new Error(`Base class ${t} is not a class.`);r.set(t,e)}addClass(e,t,r){if(r.has(t)){(0,d.ZK6)(`Redefinition of node ${t.name}`);return}if(typeof e!="function")throw new Error(`Node class ${e.name} is not a class.`);if(typeof t!="function")throw new Error(`Base class ${t.name} is not a class.`);r.set(t,e)}}const ND=new Hv,Mm=[];class PD extends Xo{constructor(){super()}createNode(e=[]){return new Hv().setLights(e)}getNode(e,t){if(e.isQuadMesh)return ND;Mm[0]=e,Mm[1]=t;let r=this.get(Mm);return r===void 0&&(r=this.createNode(),this.set(Mm,r)),Mm.length=0,r}}class wm extends d.ACn{constructor(e=1,t=1,r={}){super(e,t,r),this.isXRRenderTarget=!0,this._hasExternalTextures=!1,this._autoAllocateDepthBuffer=!0,this._isOpaqueFramebuffer=!1}copy(e){return super.copy(e),this._hasExternalTextures=e._hasExternalTextures,this._autoAllocateDepthBuffer=e._autoAllocateDepthBuffer,this._isOpaqueFramebuffer=e._isOpaqueFramebuffer,this}}const iA=new d.Pa4,rA=new d.Pa4;class LD extends d.pBf{constructor(e,t=!1){super(),this.enabled=!1,this.isPresenting=!1,this.cameraAutoUpdate=!0,this._renderer=e,this._cameraL=new d.cPb,this._cameraL.viewport=new d.Ltg,this._cameraR=new d.cPb,this._cameraR.viewport=new d.Ltg,this._cameras=[this._cameraL,this._cameraR],this._cameraXR=new d.HkE,this._currentDepthNear=null,this._currentDepthFar=null,this._controllers=[],this._controllerInputSources=[],this._xrRenderTarget=null,this._layers=[],this._sessionUsesLayers=!1,this._supportsGlBinding=typeof XRWebGLBinding!="undefined",this._frameBufferTargets=null,this._createXRLayer=OD.bind(this),this._gl=null,this._currentAnimationContext=null,this._currentAnimationLoop=null,this._currentPixelRatio=null,this._currentSize=new d.FM8,this._onSessionEvent=UD.bind(this),this._onSessionEnd=FD.bind(this),this._onInputSourcesChange=BD.bind(this),this._onAnimationFrame=kD.bind(this),this._referenceSpace=null,this._referenceSpaceType="local-floor",this._customReferenceSpace=null,this._framebufferScaleFactor=1,this._foveation=1,this._session=null,this._glBaseLayer=null,this._glBinding=null,this._glProjLayer=null,this._xrFrame=null,this._supportsLayers=this._supportsGlBinding&&"createProjectionLayer"in XRWebGLBinding.prototype,this._useMultiviewIfPossible=t,this._useMultiview=!1}getController(e){return this._getController(e).getTargetRaySpace()}getControllerGrip(e){return this._getController(e).getGripSpace()}getHand(e){return this._getController(e).getHandSpace()}getFoveation(){if(!(this._glProjLayer===null&&this._glBaseLayer===null))return this._foveation}setFoveation(e){this._foveation=e,this._glProjLayer!==null&&(this._glProjLayer.fixedFoveation=e),this._glBaseLayer!==null&&this._glBaseLayer.fixedFoveation!==void 0&&(this._glBaseLayer.fixedFoveation=e)}getFramebufferScaleFactor(){return this._framebufferScaleFactor}setFramebufferScaleFactor(e){this._framebufferScaleFactor=e,this.isPresenting===!0&&(0,d.ZK6)("XRManager: Cannot change framebuffer scale while presenting.")}getReferenceSpaceType(){return this._referenceSpaceType}setReferenceSpaceType(e){this._referenceSpaceType=e,this.isPresenting===!0&&(0,d.ZK6)("XRManager: Cannot change reference space type while presenting.")}getReferenceSpace(){return this._customReferenceSpace||this._referenceSpace}setReferenceSpace(e){this._customReferenceSpace=e}getCamera(){return this._cameraXR}getEnvironmentBlendMode(){if(this._session!==null)return this._session.environmentBlendMode}getBinding(){return this._glBinding===null&&this._supportsGlBinding&&(this._glBinding=new XRWebGLBinding(this._session,this._gl)),this._glBinding}getFrame(){return this._xrFrame}useMultiview(){return this._useMultiview}createQuadLayer(e,t,r,s,a,c,h,f={}){const m=new d._12(e,t),x=new wm(a,c,{format:d.wk1,type:d.ywz,depthTexture:new d.$YQ(a,c,f.stencil?d.wJv:d.JQ4,void 0,void 0,void 0,void 0,void 0,void 0,f.stencil?d.brP:d.qkB),stencilBuffer:f.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});x._autoAllocateDepthBuffer=!0;const _=new d.vBJ({color:16777215,side:d.Wl3});_.map=x.texture,_.map.offset.y=1,_.map.repeat.y=-1;const v=new d.Kj0(m,_);v.position.copy(r),v.quaternion.copy(s);const T={type:"quad",width:e,height:t,translation:r,quaternion:s,pixelwidth:a,pixelheight:c,plane:v,material:_,rendercall:h,renderTarget:x};if(this._layers.push(T),this._session!==null){T.plane.material=new d.vBJ({color:16777215,side:d.Wl3}),T.plane.material.blending=d.Xaj,T.plane.material.blendEquation=d.bGH,T.plane.material.blendSrc=d.c8b,T.plane.material.blendDst=d.c8b,T.xrlayer=this._createXRLayer(T);const w=this._session.renderState.layers;w.unshift(T.xrlayer),this._session.updateRenderState({layers:w})}else x.isXRRenderTarget=!1;return v}createCylinderLayer(e,t,r,s,a,c,h,f,m={}){const x=new d.fHI(e,e,e*t/r,64,64,!0,Math.PI-t/2,t),_=new wm(c,h,{format:d.wk1,type:d.ywz,depthTexture:new d.$YQ(c,h,m.stencil?d.wJv:d.JQ4,void 0,void 0,void 0,void 0,void 0,void 0,m.stencil?d.brP:d.qkB),stencilBuffer:m.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});_._autoAllocateDepthBuffer=!0;const v=new d.vBJ({color:16777215,side:d._Li});v.map=_.texture,v.map.offset.y=1,v.map.repeat.y=-1;const T=new d.Kj0(x,v);T.position.copy(s),T.quaternion.copy(a);const w={type:"cylinder",radius:e,centralAngle:t,aspectratio:r,translation:s,quaternion:a,pixelwidth:c,pixelheight:h,plane:T,material:v,rendercall:f,renderTarget:_};if(this._layers.push(w),this._session!==null){w.plane.material=new d.vBJ({color:16777215,side:d._Li}),w.plane.material.blending=d.Xaj,w.plane.material.blendEquation=d.bGH,w.plane.material.blendSrc=d.c8b,w.plane.material.blendDst=d.c8b,w.xrlayer=this._createXRLayer(w);const P=this._session.renderState.layers;P.unshift(w.xrlayer),this._session.updateRenderState({layers:P})}else _.isXRRenderTarget=!1;return T}renderLayers(){const e=new d.Pa4,t=new d._fP,r=this._renderer,s=this.isPresenting,a=r.getOutputRenderTarget(),c=r._frameBufferTarget;this.isPresenting=!1;const h=new d.FM8;r.getSize(h);const f=r._quad;for(const m of this._layers)if(m.renderTarget.isXRRenderTarget=this._session!==null,m.renderTarget._hasExternalTextures=m.renderTarget.isXRRenderTarget,m.renderTarget.isXRRenderTarget&&this._sessionUsesLayers){m.xrlayer.transform=new XRRigidTransform(m.plane.getWorldPosition(e),m.plane.getWorldQuaternion(t));const x=this._glBinding.getSubImage(m.xrlayer,this._xrFrame);r.backend.setXRRenderTargetTextures(m.renderTarget,x.colorTexture,void 0),r._setXRLayerSize(m.renderTarget.width,m.renderTarget.height),r.setOutputRenderTarget(m.renderTarget),r.setRenderTarget(null),r._frameBufferTarget=null,this._frameBufferTargets||(this._frameBufferTargets=new WeakMap);const{frameBufferTarget:_,quad:v}=this._frameBufferTargets.get(m.renderTarget)||{frameBufferTarget:null,quad:null};_?(r._frameBufferTarget=_,r._quad=v):(r._quad=new fm(new Gi),this._frameBufferTargets.set(m.renderTarget,{frameBufferTarget:r._getFrameBufferTarget(),quad:r._quad})),m.rendercall(),r._frameBufferTarget=null}else r.setRenderTarget(m.renderTarget),m.rendercall();r.setRenderTarget(null),r.setOutputRenderTarget(a),r._frameBufferTarget=c,r._setXRLayerSize(h.x,h.y),r._quad=f,this.isPresenting=s}getSession(){return this._session}setSession(e){return nn(this,null,function*(){const t=this._renderer,r=t.backend;this._gl=t.getContext();const s=this._gl,a=s.getContextAttributes();if(this._session=e,e!==null){if(r.isWebGPUBackend===!0)throw new Error('THREE.XRManager: XR is currently not supported with a WebGPU backend. Use WebGL by passing "{ forceWebGL: true }" to the constructor of the renderer.');if(e.addEventListener("select",this._onSessionEvent),e.addEventListener("selectstart",this._onSessionEvent),e.addEventListener("selectend",this._onSessionEvent),e.addEventListener("squeeze",this._onSessionEvent),e.addEventListener("squeezestart",this._onSessionEvent),e.addEventListener("squeezeend",this._onSessionEvent),e.addEventListener("end",this._onSessionEnd),e.addEventListener("inputsourceschange",this._onInputSourcesChange),yield r.makeXRCompatible(),this._currentPixelRatio=t.getPixelRatio(),t.getSize(this._currentSize),this._currentAnimationContext=t._animation.getContext(),this._currentAnimationLoop=t._animation.getAnimationLoop(),t._animation.stop(),this._supportsLayers===!0){let c=null,h=null,f=null;t.depth&&(f=t.stencil?s.DEPTH24_STENCIL8:s.DEPTH_COMPONENT24,c=t.stencil?d.brP:d.qkB,h=t.stencil?d.wJv:d.JQ4);const m={colorFormat:s.RGBA8,depthFormat:f,scaleFactor:this._framebufferScaleFactor,clearOnAccess:!1};this._useMultiviewIfPossible&&t.hasFeature("OVR_multiview2")&&(m.textureType="texture-array",this._useMultiview=!0),this._glBinding=this.getBinding();const x=this._glBinding.createProjectionLayer(m),_=[x];this._glProjLayer=x,t.setPixelRatio(1),t._setXRLayerSize(x.textureWidth,x.textureHeight);const v=this._useMultiview?2:1,T=new d.$YQ(x.textureWidth,x.textureHeight,h,void 0,void 0,void 0,void 0,void 0,void 0,c,v);if(this._xrRenderTarget=new wm(x.textureWidth,x.textureHeight,{format:d.wk1,type:d.ywz,colorSpace:t.outputColorSpace,depthTexture:T,stencilBuffer:t.stencil,samples:a.antialias?4:0,resolveDepthBuffer:x.ignoreDepthValues===!1,resolveStencilBuffer:x.ignoreDepthValues===!1,depth:this._useMultiview?2:1,multiview:this._useMultiview}),this._xrRenderTarget._hasExternalTextures=!0,this._xrRenderTarget.depth=this._useMultiview?2:1,this._sessionUsesLayers=e.enabledFeatures.includes("layers"),this._referenceSpace=yield e.requestReferenceSpace(this.getReferenceSpaceType()),this._sessionUsesLayers)for(const w of this._layers)w.plane.material=new d.vBJ({color:16777215,side:w.type==="cylinder"?d._Li:d.Wl3}),w.plane.material.blending=d.Xaj,w.plane.material.blendEquation=d.bGH,w.plane.material.blendSrc=d.c8b,w.plane.material.blendDst=d.c8b,w.xrlayer=this._createXRLayer(w),_.unshift(w.xrlayer);e.updateRenderState({layers:_})}else{const c={antialias:t.currentSamples>0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},h=new XRWebGLLayer(e,s,c);this._glBaseLayer=h,e.updateRenderState({baseLayer:h}),t.setPixelRatio(1),t._setXRLayerSize(h.framebufferWidth,h.framebufferHeight),this._xrRenderTarget=new wm(h.framebufferWidth,h.framebufferHeight,{format:d.wk1,type:d.ywz,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:h.ignoreDepthValues===!1,resolveStencilBuffer:h.ignoreDepthValues===!1}),this._xrRenderTarget._isOpaqueFramebuffer=!0,this._referenceSpace=yield e.requestReferenceSpace(this.getReferenceSpaceType())}this.setFoveation(this.getFoveation()),t._animation.setAnimationLoop(this._onAnimationFrame),t._animation.setContext(e),t._animation.start(),this.isPresenting=!0,this.dispatchEvent({type:"sessionstart"})}})}updateCamera(e){const t=this._session;if(t===null)return;const r=e.near,s=e.far,a=this._cameraXR,c=this._cameraL,h=this._cameraR;a.near=h.near=c.near=r,a.far=h.far=c.far=s,a.isMultiViewCamera=this._useMultiview,(this._currentDepthNear!==a.near||this._currentDepthFar!==a.far)&&(t.updateRenderState({depthNear:a.near,depthFar:a.far}),this._currentDepthNear=a.near,this._currentDepthFar=a.far),a.layers.mask=e.layers.mask|6,c.layers.mask=a.layers.mask&3,h.layers.mask=a.layers.mask&5;const f=e.parent,m=a.cameras;sA(a,f);for(let x=0;x<m.length;x++)sA(m[x],f);m.length===2?ID(a,c,h):a.projectionMatrix.copy(c.projectionMatrix),DD(e,a,f)}_getController(e){let t=this._controllers[e];return t===void 0&&(t=new d.NiX,this._controllers[e]=t),t}}function ID(i,e,t){iA.setFromMatrixPosition(e.matrixWorld),rA.setFromMatrixPosition(t.matrixWorld);const r=iA.distanceTo(rA),s=e.projectionMatrix.elements,a=t.projectionMatrix.elements,c=s[14]/(s[10]-1),h=s[14]/(s[10]+1),f=(s[9]+1)/s[5],m=(s[9]-1)/s[5],x=(s[8]-1)/s[0],_=(a[8]+1)/a[0],v=c*x,T=c*_,w=r/(-x+_),P=w*-x;if(e.matrixWorld.decompose(i.position,i.quaternion,i.scale),i.translateX(P),i.translateZ(w),i.matrixWorld.compose(i.position,i.quaternion,i.scale),i.matrixWorldInverse.copy(i.matrixWorld).invert(),s[10]===-1)i.projectionMatrix.copy(e.projectionMatrix),i.projectionMatrixInverse.copy(e.projectionMatrixInverse);else{const C=c+w,E=h+w,D=v-P,F=T+(r-P),W=f*h/E*C,K=m*h/E*C;i.projectionMatrix.makePerspective(D,F,W,K,C,E),i.projectionMatrixInverse.copy(i.projectionMatrix).invert()}}function sA(i,e){e===null?i.matrixWorld.copy(i.matrix):i.matrixWorld.multiplyMatrices(e.matrixWorld,i.matrix),i.matrixWorldInverse.copy(i.matrixWorld).invert()}function DD(i,e,t){t===null?i.matrix.copy(e.matrixWorld):(i.matrix.copy(t.matrixWorld),i.matrix.invert(),i.matrix.multiply(e.matrixWorld)),i.matrix.decompose(i.position,i.quaternion,i.scale),i.updateMatrixWorld(!0),i.projectionMatrix.copy(e.projectionMatrix),i.projectionMatrixInverse.copy(e.projectionMatrixInverse),i.isPerspectiveCamera&&(i.fov=d.I3e*2*Math.atan(1/i.projectionMatrix.elements[5]),i.zoom=1)}function UD(i){const e=this._controllerInputSources.indexOf(i.inputSource);if(e===-1)return;const t=this._controllers[e];if(t!==void 0){const r=this.getReferenceSpace();t.update(i.inputSource,i.frame,r),t.dispatchEvent({type:i.type,data:i.inputSource})}}function FD(){const i=this._session,e=this._renderer;i.removeEventListener("select",this._onSessionEvent),i.removeEventListener("selectstart",this._onSessionEvent),i.removeEventListener("selectend",this._onSessionEvent),i.removeEventListener("squeeze",this._onSessionEvent),i.removeEventListener("squeezestart",this._onSessionEvent),i.removeEventListener("squeezeend",this._onSessionEvent),i.removeEventListener("end",this._onSessionEnd),i.removeEventListener("inputsourceschange",this._onInputSourcesChange);for(let t=0;t<this._controllers.length;t++){const r=this._controllerInputSources[t];r!==null&&(this._controllerInputSources[t]=null,this._controllers[t].disconnect(r))}if(this._currentDepthNear=null,this._currentDepthFar=null,e._resetXRState(),this._session=null,this._xrRenderTarget=null,this._glBinding=null,this._glBaseLayer=null,this._glProjLayer=null,this._sessionUsesLayers===!0)for(const t of this._layers)t.renderTarget=new wm(t.pixelwidth,t.pixelheight,{format:d.wk1,type:d.ywz,depthTexture:new d.$YQ(t.pixelwidth,t.pixelheight,t.stencilBuffer?d.wJv:d.JQ4,void 0,void 0,void 0,void 0,void 0,void 0,t.stencilBuffer?d.brP:d.qkB),stencilBuffer:t.stencilBuffer,resolveDepthBuffer:!1,resolveStencilBuffer:!1}),t.renderTarget.isXRRenderTarget=!1,t.plane.material=t.material,t.material.map=t.renderTarget.texture,t.material.map.offset.y=1,t.material.map.repeat.y=-1,delete t.xrlayer;this.isPresenting=!1,this._useMultiview=!1,e._animation.stop(),e._animation.setAnimationLoop(this._currentAnimationLoop),e._animation.setContext(this._currentAnimationContext),e._animation.start(),e.setPixelRatio(this._currentPixelRatio),e.setSize(this._currentSize.width,this._currentSize.height,!1),this.dispatchEvent({type:"sessionend"})}function BD(i){const e=this._controllers,t=this._controllerInputSources;for(let r=0;r<i.removed.length;r++){const s=i.removed[r],a=t.indexOf(s);a>=0&&(t[a]=null,e[a].disconnect(s))}for(let r=0;r<i.added.length;r++){const s=i.added[r];let a=t.indexOf(s);if(a===-1){for(let h=0;h<e.length;h++)if(h>=t.length){t.push(s),a=h;break}else if(t[h]===null){t[h]=s,a=h;break}if(a===-1)break}const c=e[a];c&&c.connect(s)}}function OD(i){return i.type==="quad"?this._glBinding.createQuadLayer({transform:new XRRigidTransform(i.translation,i.quaternion),width:i.width/2,height:i.height/2,space:this._referenceSpace,viewPixelWidth:i.pixelwidth,viewPixelHeight:i.pixelheight,clearOnAccess:!1}):this._glBinding.createCylinderLayer({transform:new XRRigidTransform(i.translation,i.quaternion),radius:i.radius,centralAngle:i.centralAngle,aspectRatio:i.aspectRatio,space:this._referenceSpace,viewPixelWidth:i.pixelwidth,viewPixelHeight:i.pixelheight,clearOnAccess:!1})}function kD(i,e){if(e===void 0)return;const t=this._cameraXR,r=this._renderer,s=r.backend,a=this._glBaseLayer,c=this.getReferenceSpace(),h=e.getViewerPose(c);if(this._xrFrame=e,h!==null){const f=h.views;this._glBaseLayer!==null&&s.setXRTarget(a.framebuffer);let m=!1;f.length!==t.cameras.length&&(t.cameras.length=0,m=!0);for(let x=0;x<f.length;x++){const _=f[x];let v;if(this._supportsLayers===!0){const w=this._glBinding.getViewSubImage(this._glProjLayer,_);v=w.viewport,x===0&&s.setXRRenderTargetTextures(this._xrRenderTarget,w.colorTexture,this._glProjLayer.ignoreDepthValues&&!this._useMultiview?void 0:w.depthStencilTexture)}else v=a.getViewport(_);let T=this._cameras[x];T===void 0&&(T=new d.cPb,T.layers.enable(x),T.viewport=new d.Ltg,this._cameras[x]=T),T.matrix.fromArray(_.transform.matrix),T.matrix.decompose(T.position,T.quaternion,T.scale),T.projectionMatrix.fromArray(_.projectionMatrix),T.projectionMatrixInverse.copy(T.projectionMatrix).invert(),T.viewport.set(v.x,v.y,v.width,v.height),x===0&&(t.matrix.copy(T.matrix),t.matrix.decompose(t.position,t.quaternion,t.scale)),m===!0&&t.cameras.push(T)}r.setOutputRenderTarget(this._xrRenderTarget)}for(let f=0;f<this._controllers.length;f++){const m=this._controllerInputSources[f],x=this._controllers[f];m!==null&&x!==void 0&&x.update(m,e,c)}this._currentAnimationLoop&&this._currentAnimationLoop(i,e),e.detectedPlanes&&this.dispatchEvent({type:"planesdetected",data:e}),this._xrFrame=null}class VD extends d.pBf{constructor(e){super(),this.domElement=e,this._pixelRatio=1,this._width=this.domElement.width,this._height=this.domElement.height,this._viewport=new d.Ltg(0,0,this._width,this._height),this._scissor=new d.Ltg(0,0,this._width,this._height),this._scissorTest=!1,this.colorTexture=new d.Wzm,this.depthTexture=new d.$YQ}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._pixelRatio=e,this.setSize(this._width,this._height,!1))}setDrawingBufferSize(e,t,r){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this._pixelRatio=r,this.domElement.width=Math.floor(e*r),this.domElement.height=Math.floor(t*r),this.setViewport(0,0,e,t),this._dispatchResize())}setSize(e,t,r=!0){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this.domElement.width=Math.floor(e*this._pixelRatio),this.domElement.height=Math.floor(t*this._pixelRatio),r===!0&&(this.domElement.style.width=e+"px",this.domElement.style.height=t+"px"),this.setViewport(0,0,e,t),this._dispatchResize())}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,r,s){const a=this._scissor;e.isVector4?a.copy(e):a.set(e,t,r,s)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,r,s,a=0,c=1){const h=this._viewport;e.isVector4?h.copy(e):h.set(e,t,r,s),h.minDepth=a,h.maxDepth=c}_dispatchResize(){this.dispatchEvent({type:"resize"})}dispose(){this.dispatchEvent({type:"dispose"})}}const oA=new d.xsS,Vd=new d.FM8,sS=new d.Ltg,oS=new d.iWj,aS=new d.gJg,jx=new d.yGw,Sc=new d.Ltg;class zD{constructor(e,t={}){this.isRenderer=!0;const{logarithmicDepthBuffer:r=!1,alpha:s=!0,depth:a=!0,stencil:c=!1,antialias:h=!1,samples:f=0,getFallback:m=null,colorBufferType:x=d.cLu,multiview:_=!1}=t;this.backend=e,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.alpha=s,this.logarithmicDepthBuffer=r,this.outputColorSpace=d.KI_,this.toneMapping=d.uL9,this.toneMappingExposure=1,this.sortObjects=!0,this.depth=a,this.stencil=c,this.info=new N2,this.overrideNodes={modelViewMatrix:null,modelNormalViewMatrix:null},this.library=new nA,this.lighting=new PD,this._samples=f||h===!0?4:0,this._onCanvasTargetResize=this._onCanvasTargetResize.bind(this),this._canvasTarget=new VD(e.getDomElement()),this._canvasTarget.addEventListener("resize",this._onCanvasTargetResize),this._canvasTarget.isDefaultCanvasTarget=!0,this._inspector=new jp,this._inspector.setRenderer(this),this._getFallback=m,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 fm(new Gi),this._quad.name="Output Color Transform",this._quad.material.name="outputColorTransform",this._currentRenderContext=null,this._opaqueSort=null,this._transparentSort=null,this._frameBufferTarget=null;const v=this.alpha===!0?0:1;this._clearColor=new Rv(0,0,0,v),this._clearDepth=1,this._clearStencil=0,this._renderTarget=null,this._activeCubeFace=0,this._activeMipmapLevel=0,this._outputRenderTarget=null,this._mrt=null,this._renderObjectFunction=null,this._currentRenderObjectFunction=null,this._currentRenderBundle=null,this._handleObjectFunction=this._renderObjectDirect,this._isDeviceLost=!1,this.onDeviceLost=this._onDeviceLost,this._colorBufferType=x,this._cacheShadowNodes=new WeakMap,this._initialized=!1,this._initPromise=null,this._compilationPromises=null,this.transparent=!0,this.opaque=!0,this.shadowMap={enabled:!1,type:d._iA},this.xr=new LD(this,_),this.debug={checkShaderErrors:!0,onShaderError:null,getShaderAsync:(T,w,P)=>nn(this,null,function*(){yield this.compileAsync(T,w);const C=this._renderLists.get(T,w),E=this._renderContexts.get(T,w,this._renderTarget),D=T.overrideMaterial||P.material,F=this._objects.get(P,D,T,w,C.lightsNode,E,E.clippingContext),{fragmentShader:W,vertexShader:K}=F.getNodeBuilderState();return{fragmentShader:W,vertexShader:K}})}}init(){return nn(this,null,function*(){return this._initPromise!==null?this._initPromise:(this._initPromise=new Promise((e,t)=>nn(this,null,function*(){let r=this.backend;try{yield r.init(this)}catch(s){if(this._getFallback!==null)try{this.backend=r=this._getFallback(s),yield r.init(this)}catch(a){t(a);return}else{t(s);return}}this._nodes=new ED(this,r),this._animation=new v2(this,this._nodes,this.info),this._attributes=new C2(r),this._background=new GI(this,this._nodes),this._geometries=new R2(this._attributes,this.info),this._textures=new $2(this,r,this.info),this._pipelines=new D2(r,this._nodes),this._bindings=new U2(r,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new w2(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new O2(this.lighting),this._bundles=new RD,this._renderContexts=new W2,this._animation.start(),this._initialized=!0,this._inspector.init(),e(this)})),this._initPromise)})}get domElement(){return this._canvasTarget.domElement}get coordinateSystem(){return this.backend.coordinateSystem}compileAsync(e,t,r=null){return nn(this,null,function*(){if(this._isDeviceLost===!0)return;this._initialized===!1&&(yield this.init());const s=this._nodes.nodeFrame,a=s.renderId,c=this._currentRenderContext,h=this._currentRenderObjectFunction,f=this._compilationPromises,m=e.isScene===!0?e:oA;r===null&&(r=e);const x=this._renderTarget,_=this._renderContexts.get(r,t,x),v=this._activeMipmapLevel,T=[];this._currentRenderContext=_,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=T,s.renderId++,s.update(),_.depth=this.depth,_.stencil=this.stencil,_.clippingContext||(_.clippingContext=new $x),_.clippingContext.updateGlobal(m,t),m.onBeforeRender(this,e,t,x);const w=this._renderLists.get(e,t);if(w.begin(),this._projectObject(e,t,0,w,_.clippingContext),r!==e&&r.traverseVisible(function(F){F.isLight&&F.layers.test(t.layers)&&w.pushLight(F)}),w.finish(),x!==null){this._textures.updateRenderTarget(x,v);const F=this._textures.get(x);_.textures=F.textures,_.depthTexture=F.depthTexture}else _.textures=null,_.depthTexture=null;this._background.update(m,w,_);const P=w.opaque,C=w.transparent,E=w.transparentDoublePass,D=w.lightsNode;this.opaque===!0&&P.length>0&&this._renderObjects(P,t,m,D),this.transparent===!0&&C.length>0&&this._renderTransparents(C,E,t,m,D),s.renderId=a,this._currentRenderContext=c,this._currentRenderObjectFunction=h,this._compilationPromises=f,this._handleObjectFunction=this._renderObjectDirect,yield Promise.all(T)})}renderAsync(e,t){return nn(this,null,function*(){(0,d.O4K)('Renderer: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),yield this.init(),this.render(e,t)})}waitForGPU(){return nn(this,null,function*(){(0,d.vUy)("Renderer: waitForGPU() has been removed. Read https://github.com/mrdoob/three.js/issues/32012 for more information.")})}set inspector(e){this._inspector!==null&&this._inspector.setRenderer(null),this._inspector=e,this._inspector.setRenderer(this)}get inspector(){return this._inspector}set highPrecision(e){e===!0?(this.overrideNodes.modelViewMatrix=Fb,this.overrideNodes.modelNormalViewMatrix=Bb):this.highPrecision&&(this.overrideNodes.modelViewMatrix=null,this.overrideNodes.modelNormalViewMatrix=null)}get highPrecision(){return this.overrideNodes.modelViewMatrix===Fb&&this.overrideNodes.modelNormalViewMatrix===Bb}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getColorBufferType(){return this._colorBufferType}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:
Message: ${e.message}`;e.reason&&(t+=`
Reason: ${e.reason}`),(0,d.vUy)(t),this._isDeviceLost=!0}_renderBundle(e,t,r){const{bundleGroup:s,camera:a,renderList:c}=e,h=this._currentRenderContext,f=this._bundles.get(s,a),m=this.backend.get(f);m.renderContexts===void 0&&(m.renderContexts=new Set);const x=s.version!==m.version,_=m.renderContexts.has(h)===!1||x;if(m.renderContexts.add(h),_){this.backend.beginBundle(h),(m.renderObjects===void 0||x)&&(m.renderObjects=[]),this._currentRenderBundle=f;const{transparentDoublePass:v,transparent:T,opaque:w}=c;this.opaque===!0&&w.length>0&&this._renderObjects(w,a,t,r),this.transparent===!0&&T.length>0&&this._renderTransparents(T,v,a,t,r),this._currentRenderBundle=null,this.backend.finishBundle(h,f),m.version=s.version}else{const{renderObjects:v}=m;for(let T=0,w=v.length;T<w;T++){const P=v[T];this._nodes.needsRefresh(P)&&(this._nodes.updateBefore(P),this._nodes.updateForRender(P),this._bindings.updateForRender(P),this._nodes.updateAfter(P))}}this.backend.addBundle(h,f)}render(e,t){if(this._initialized===!1)throw new Error('Renderer: .render() called before the backend is initialized. Use "await renderer.init();" before rendering.');this._renderScene(e,t)}get initialized(){return this._initialized}_getFrameBufferTarget(){const{currentToneMapping:e,currentColorSpace:t}=this,r=e!==d.uL9,s=t!==d.epp.workingColorSpace;if(r===!1&&s===!1)return null;const{width:a,height:c}=this.getDrawingBufferSize(Vd),{depth:h,stencil:f}=this;let m=this._frameBufferTarget;m===null&&(m=new d.ACn(a,c,{depthBuffer:h,stencilBuffer:f,type:this._colorBufferType,format:d.wk1,colorSpace:d.epp.workingColorSpace,generateMipmaps:!1,minFilter:d.wem,magFilter:d.wem,samples:this.samples}),m.isPostProcessingRenderTarget=!0,this._frameBufferTarget=m);const x=this.getOutputRenderTarget();m.depthBuffer=h,m.stencilBuffer=f,x!==null?m.setSize(x.width,x.height,x.depth):m.setSize(a,c,1);const _=this._canvasTarget;return m.viewport.copy(_._viewport),m.scissor.copy(_._scissor),m.viewport.multiplyScalar(_._pixelRatio),m.scissor.multiplyScalar(_._pixelRatio),m.scissorTest=_._scissorTest,m.multiview=x!==null?x.multiview:!1,m.resolveDepthBuffer=x!==null?x.resolveDepthBuffer:!0,m._autoAllocateDepthBuffer=x!==null?x._autoAllocateDepthBuffer:!1,m}_renderScene(e,t,r=!0){if(this._isDeviceLost===!0)return;const s=r?this._getFrameBufferTarget():null,a=this._nodes.nodeFrame,c=a.renderId,h=this._currentRenderContext,f=this._currentRenderObjectFunction,m=e.isScene===!0?e:oA,x=this._renderTarget||this._outputRenderTarget,_=this._activeCubeFace,v=this._activeMipmapLevel;let T;s!==null?(T=s,this.setRenderTarget(T)):T=x;const w=this._renderContexts.get(e,t,T);this._currentRenderContext=w,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,a.renderId=this.info.calls,this.backend.updateTimeStampUID(w),this.inspector.beginRender(this.backend.getTimestampUID(w),e,t,T);const P=this.coordinateSystem,C=this.xr;if(t.coordinateSystem!==P&&C.isPresenting===!1&&(t.coordinateSystem=P,t.updateProjectionMatrix(),t.isArrayCamera))for(const Pe of t.cameras)Pe.coordinateSystem=P,Pe.updateProjectionMatrix();e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),C.enabled===!0&&C.isPresenting===!0&&(C.cameraAutoUpdate===!0&&C.updateCamera(t),t=C.getCamera());const E=this._canvasTarget;let D=E._viewport,F=E._scissor,W=E._pixelRatio;T!==null&&(D=T.viewport,F=T.scissor,W=1),this.getDrawingBufferSize(Vd),sS.set(0,0,Vd.width,Vd.height);const K=D.minDepth===void 0?0:D.minDepth,U=D.maxDepth===void 0?1:D.maxDepth;w.viewportValue.copy(D).multiplyScalar(W).floor(),w.viewportValue.width>>=v,w.viewportValue.height>>=v,w.viewportValue.minDepth=K,w.viewportValue.maxDepth=U,w.viewport=w.viewportValue.equals(sS)===!1,w.scissorValue.copy(F).multiplyScalar(W).floor(),w.scissor=E._scissorTest&&w.scissorValue.equals(sS)===!1,w.scissorValue.width>>=v,w.scissorValue.height>>=v,w.clippingContext||(w.clippingContext=new $x),w.clippingContext.updateGlobal(m,t),m.onBeforeRender(this,e,t,T);const j=t.isArrayCamera?aS:oS;t.isArrayCamera||(jx.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),j.setFromProjectionMatrix(jx,t.coordinateSystem,t.reversedDepth));const oe=this._renderLists.get(e,t);if(oe.begin(),this._projectObject(e,t,0,oe,w.clippingContext),oe.finish(),this.sortObjects===!0&&oe.sort(this._opaqueSort,this._transparentSort),T!==null){this._textures.updateRenderTarget(T,v);const Pe=this._textures.get(T);w.textures=Pe.textures,w.depthTexture=Pe.depthTexture,w.width=Pe.width,w.height=Pe.height,w.renderTarget=T,w.depth=T.depthBuffer,w.stencil=T.stencilBuffer}else w.textures=null,w.depthTexture=null,w.width=Vd.width,w.height=Vd.height,w.depth=this.depth,w.stencil=this.stencil;w.width>>=v,w.height>>=v,w.activeCubeFace=_,w.activeMipmapLevel=v,w.occlusionQueryCount=oe.occlusionQueryCount,w.scissorValue.max(Sc.set(0,0,0,0)),w.scissorValue.x+w.scissorValue.width>w.width&&(w.scissorValue.width=Math.max(w.width-w.scissorValue.x,0)),w.scissorValue.y+w.scissorValue.height>w.height&&(w.scissorValue.height=Math.max(w.height-w.scissorValue.y,0)),this._background.update(m,oe,w),w.camera=t,this.backend.beginRender(w);const{bundles:k,lightsNode:O,transparentDoublePass:le,transparent:be,opaque:Ee}=oe;return k.length>0&&this._renderBundles(k,m,O),this.opaque===!0&&Ee.length>0&&this._renderObjects(Ee,t,m,O),this.transparent===!0&&be.length>0&&this._renderTransparents(be,le,t,m,O),this.backend.finishRender(w),a.renderId=c,this._currentRenderContext=h,this._currentRenderObjectFunction=f,s!==null&&(this.setRenderTarget(x,_,v),this._renderOutput(T)),m.onAfterRender(this,e,t,T),this.inspector.finishRender(this.backend.getTimestampUID(w)),w}_setXRLayerSize(e,t){this._canvasTarget._width=e,this._canvasTarget._height=t,this.setViewport(0,0,e,t)}_renderOutput(e){const t=this._quad;this._nodes.hasOutputChange(e.texture)&&(t.material.fragmentNode=this._nodes.getOutputNode(e.texture),t.material.needsUpdate=!0);const r=this.autoClear,s=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderScene(t,t.camera,!1),this.autoClear=r,this.xr.enabled=s}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}setAnimationLoop(e){return nn(this,null,function*(){this._initialized===!1&&(yield this.init()),this._animation.setAnimationLoop(e)})}getAnimationLoop(){return this._animation.getAnimationLoop()}getArrayBufferAsync(e){return nn(this,null,function*(){return yield this.backend.getArrayBufferAsync(e)})}getContext(){return this.backend.getContext()}getPixelRatio(){return this._canvasTarget.getPixelRatio()}getDrawingBufferSize(e){return this._canvasTarget.getDrawingBufferSize(e)}getSize(e){return this._canvasTarget.getSize(e)}setPixelRatio(e=1){this._canvasTarget.setPixelRatio(e)}setDrawingBufferSize(e,t,r){this.xr&&this.xr.isPresenting||this._canvasTarget.setDrawingBufferSize(e,t,r)}setSize(e,t,r=!0){this.xr&&this.xr.isPresenting||this._canvasTarget.setSize(e,t,r)}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){return this._canvasTarget.getScissor(e)}setScissor(e,t,r,s){this._canvasTarget.setScissor(e,t,r,s)}getScissorTest(){return this._canvasTarget.getScissorTest()}setScissorTest(e){this._canvasTarget.setScissorTest(e),this.backend.setScissorTest(e)}getViewport(e){return this._canvasTarget.getViewport(e)}setViewport(e,t,r,s,a=0,c=1){this._canvasTarget.setViewport(e,t,r,s,a,c)}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,r=!0){if(this._initialized===!1)throw new Error('Renderer: .clear() called before the backend is initialized. Use "await renderer.init();" before before using this method.');const s=this._renderTarget||this._getFrameBufferTarget();let a=null;if(s!==null){this._textures.updateRenderTarget(s);const c=this._textures.get(s);a=this._renderContexts.getForClear(s),a.textures=c.textures,a.depthTexture=c.depthTexture,a.width=c.width,a.height=c.height,a.renderTarget=s,a.depth=s.depthBuffer,a.stencil=s.stencilBuffer,a.clearColorValue=this.backend.getClearColor(),a.activeCubeFace=this.getActiveCubeFace(),a.activeMipmapLevel=this.getActiveMipmapLevel()}this.backend.clear(e,t,r,a),s!==null&&this._renderTarget===null&&this._renderOutput(s)}clearColor(){this.clear(!0,!1,!1)}clearDepth(){this.clear(!1,!0,!1)}clearStencil(){this.clear(!1,!1,!0)}clearAsync(e=!0,t=!0,r=!0){return nn(this,null,function*(){(0,d.O4K)('Renderer: "clearAsync()" has been deprecated. Use "clear()" and "await renderer.init();" when creating the renderer.'),yield this.init(),this.clear(e,t,r)})}clearColorAsync(){return nn(this,null,function*(){(0,d.O4K)('Renderer: "clearColorAsync()" has been deprecated. Use "clearColor()" and "await renderer.init();" when creating the renderer.'),this.clear(!0,!1,!1)})}clearDepthAsync(){return nn(this,null,function*(){(0,d.O4K)('Renderer: "clearDepthAsync()" has been deprecated. Use "clearDepth()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!0,!1)})}clearStencilAsync(){return nn(this,null,function*(){(0,d.O4K)('Renderer: "clearStencilAsync()" has been deprecated. Use "clearStencil()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!1,!0)})}get needsFrameBufferTarget(){const e=this.currentToneMapping!==d.uL9,t=this.currentColorSpace!==d.epp.workingColorSpace;return e||t}get samples(){return this._samples}get currentSamples(){let e=this._samples;return this._renderTarget!==null?e=this._renderTarget.samples:this.needsFrameBufferTarget&&(e=0),e}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:d.uL9}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:d.epp.workingColorSpace}get isOutputTarget(){return this._renderTarget===this._outputRenderTarget||this._renderTarget===null}dispose(){this._initialized===!0&&(this.info.dispose(),this.backend.dispose(),this._animation.dispose(),this._objects.dispose(),this._geometries.dispose(),this._pipelines.dispose(),this._nodes.dispose(),this._bindings.dispose(),this._renderLists.dispose(),this._renderContexts.dispose(),this._textures.dispose(),this._frameBufferTarget!==null&&this._frameBufferTarget.dispose(),Object.values(this.backend.timestampQueryPool).forEach(e=>{e!==null&&e.dispose()})),this.setRenderTarget(null),this.setAnimationLoop(null)}setRenderTarget(e,t=0,r=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=r}getRenderTarget(){return this._renderTarget}setOutputRenderTarget(e){this._outputRenderTarget=e}getOutputRenderTarget(){return this._outputRenderTarget}setCanvasTarget(e){this._canvasTarget.removeEventListener("resize",this._onCanvasTargetResize),this._canvasTarget=e,this._canvasTarget.addEventListener("resize",this._onCanvasTargetResize)}getCanvasTarget(){return this._canvasTarget}_resetXRState(){this.backend.setXRTarget(null),this.setOutputRenderTarget(null),this.setRenderTarget(null),this._frameBufferTarget.dispose(),this._frameBufferTarget=null}setRenderObjectFunction(e){this._renderObjectFunction=e}getRenderObjectFunction(){return this._renderObjectFunction}compute(e,t=null){if(this._isDeviceLost===!0)return;if(this._initialized===!1)return(0,d.ZK6)("Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e,t);const r=this._nodes.nodeFrame,s=r.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,r.renderId=this.info.calls,this.backend.updateTimeStampUID(e),this.inspector.beginCompute(this.backend.getTimestampUID(e),e);const a=this.backend,c=this._pipelines,h=this._bindings,f=this._nodes,m=Array.isArray(e)?e:[e];if(m[0]===void 0||m[0].isComputeNode!==!0)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");a.beginCompute(e);for(const x of m){if(c.has(x)===!1){const T=()=>{x.removeEventListener("dispose",T),c.delete(x),h.deleteForCompute(x),f.delete(x)};x.addEventListener("dispose",T);const w=x.onInitFunction;w!==null&&w.call(x,{renderer:this})}f.updateForCompute(x),h.updateForCompute(x);const _=h.getForCompute(x),v=c.getForCompute(x,_);a.compute(e,x,_,v,t)}a.finishCompute(e),r.renderId=s,this.inspector.finishCompute(this.backend.getTimestampUID(e))}computeAsync(e,t=null){return nn(this,null,function*(){this._initialized===!1&&(yield this.init()),this.compute(e,t)})}hasFeatureAsync(e){return nn(this,null,function*(){return(0,d.O4K)('Renderer: "hasFeatureAsync()" has been deprecated. Use "hasFeature()" and "await renderer.init();" when creating the renderer.'),yield this.init(),this.hasFeature(e)})}resolveTimestampsAsync(e="render"){return nn(this,null,function*(){return this._initialized===!1&&(yield this.init()),this.backend.resolveTimestampsAsync(e)})}hasFeature(e){if(this._initialized===!1)throw new Error('Renderer: .hasFeature() called before the backend is initialized. Use "await renderer.init();" before before using this method.');return this.backend.hasFeature(e)}hasInitialized(){return this._initialized}initTextureAsync(e){return nn(this,null,function*(){(0,d.O4K)('Renderer: "initTextureAsync()" has been deprecated. Use "initTexture()" and "await renderer.init();" when creating the renderer.'),yield this.init(),this.initTexture(e)})}initTexture(e){if(this._initialized===!1)throw new Error('Renderer: .initTexture() called before the backend is initialized. Use "await renderer.init();" before before using this method.');this._textures.updateTexture(e)}copyFramebufferToTexture(e,t=null){if(t!==null)if(t.isVector2)t=Sc.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=Sc.copy(t).floor();else{(0,d.vUy)("Renderer.copyFramebufferToTexture: Invalid rectangle.");return}else t=Sc.set(0,0,e.image.width,e.image.height);let r=this._currentRenderContext,s;r!==null?s=r.renderTarget:(s=this._renderTarget||this._getFrameBufferTarget(),s!==null&&(this._textures.updateRenderTarget(s),r=this._textures.get(s))),this._textures.updateTexture(e,{renderTarget:s}),this.backend.copyFramebufferToTexture(e,r,t),this._inspector.copyFramebufferToTexture(e)}copyTextureToTexture(e,t,r=null,s=null,a=0,c=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,r,s,a,c),this._inspector.copyTextureToTexture(e,t)}readRenderTargetPixelsAsync(e,t,r,s,a,c=0,h=0){return nn(this,null,function*(){return this.backend.copyTextureToBuffer(e.textures[c],t,r,s,a,h)})}_projectObject(e,t,r,s,a){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)r=e.renderOrder,e.isClippingGroup&&e.enabled&&(a=a.getGroupContext(e));else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)s.pushLight(e);else if(e.isSprite){const f=t.isArrayCamera?aS:oS;if(!e.frustumCulled||f.intersectsSprite(e,t)){this.sortObjects===!0&&Sc.setFromMatrixPosition(e.matrixWorld).applyMatrix4(jx);const{geometry:m,material:x}=e;x.visible&&s.push(e,m,x,r,Sc.z,null,a)}}else if(e.isLineLoop)(0,d.vUy)("Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if(e.isMesh||e.isLine||e.isPoints){const f=t.isArrayCamera?aS:oS;if(!e.frustumCulled||f.intersectsObject(e,t)){const{geometry:m,material:x}=e;if(this.sortObjects===!0&&(m.boundingSphere===null&&m.computeBoundingSphere(),Sc.copy(m.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(jx)),Array.isArray(x)){const _=m.groups;for(let v=0,T=_.length;v<T;v++){const w=_[v],P=x[w.materialIndex];P&&P.visible&&s.push(e,m,P,r,Sc.z,w,a)}}else x.visible&&s.push(e,m,x,r,Sc.z,null,a)}}}if(e.isBundleGroup===!0&&this.backend.beginBundle!==void 0){const f=s;s=this._renderLists.get(e,t),s.begin(),f.pushBundle({bundleGroup:e,camera:t,renderList:s}),s.finish()}const h=e.children;for(let f=0,m=h.length;f<m;f++)this._projectObject(h[f],t,r,s,a)}_renderBundles(e,t,r){for(const s of e)this._renderBundle(s,t,r)}_renderTransparents(e,t,r,s,a){if(t.length>0){for(const{material:c}of t)c.side=d._Li;this._renderObjects(t,r,s,a,"backSide");for(const{material:c}of t)c.side=d.Wl3;this._renderObjects(e,r,s,a);for(const{material:c}of t)c.side=d.ehD}else this._renderObjects(e,r,s,a)}_renderObjects(e,t,r,s,a=null){for(let c=0,h=e.length;c<h;c++){const{object:f,geometry:m,material:x,group:_,clippingContext:v}=e[c];this._currentRenderObjectFunction(f,r,t,m,x,_,s,v,a)}}_getShadowNodes(e){const t=e.version;let r=this._cacheShadowNodes.get(e);if(r===void 0||r.version!==t){const s=e.map!==null,a=e.colorNode&&e.colorNode.isNode,c=e.castShadowNode&&e.castShadowNode.isNode;let h=null,f=null,m=null;if(s||a||c){let x,_;c?(x=e.castShadowNode.rgb,_=e.castShadowNode.a):(x=ce(0),_=G(1)),s&&(_=_.mul(xi("map","texture",e).a)),a&&(_=_.mul(e.colorNode.a)),f=At(x,_)}e.depthNode&&e.depthNode.isNode&&(m=e.depthNode),e.castShadowPositionNode&&e.castShadowPositionNode.isNode?h=e.castShadowPositionNode:e.positionNode&&e.positionNode.isNode&&(h=e.positionNode),r={version:t,colorNode:f,depthNode:m,positionNode:h},this._cacheShadowNodes.set(e,r)}return r}renderObject(e,t,r,s,a,c,h,f=null,m=null){let x=!1,_,v,T,w;if(e.onBeforeRender(this,t,r,s,a,c),a.allowOverride===!0&&t.overrideMaterial!==null){const P=t.overrideMaterial;if(x=!0,_=t.overrideMaterial.colorNode,v=t.overrideMaterial.depthNode,T=t.overrideMaterial.positionNode,w=t.overrideMaterial.side,a.positionNode&&a.positionNode.isNode&&(P.positionNode=a.positionNode),P.alphaTest=a.alphaTest,P.alphaMap=a.alphaMap,P.transparent=a.transparent||a.transmission>0||a.transmissionNode&&a.transmissionNode.isNode||a.backdropNode&&a.backdropNode.isNode,P.isShadowPassMaterial){const{colorNode:C,depthNode:E,positionNode:D}=this._getShadowNodes(a);P.side=a.shadowSide===null?a.side:a.shadowSide,C!==null&&(P.colorNode=C),E!==null&&(P.depthNode=E),D!==null&&(P.positionNode=D)}a=P}a.transparent===!0&&a.side===d.ehD&&a.forceSinglePass===!1?(a.side=d._Li,this._handleObjectFunction(e,a,t,r,h,c,f,"backSide"),a.side=d.Wl3,this._handleObjectFunction(e,a,t,r,h,c,f,m),a.side=d.ehD):this._handleObjectFunction(e,a,t,r,h,c,f,m),x&&(t.overrideMaterial.colorNode=_,t.overrideMaterial.depthNode=v,t.overrideMaterial.positionNode=T,t.overrideMaterial.side=w),e.onAfterRender(this,t,r,s,a,c)}_renderObjectDirect(e,t,r,s,a,c,h,f){const m=this._objects.get(e,t,r,s,a,this._currentRenderContext,h,f);m.drawRange=e.geometry.drawRange,m.group=c;const x=this._nodes.needsRefresh(m);x&&(this._nodes.updateBefore(m),this._geometries.updateForRender(m),this._nodes.updateForRender(m),this._bindings.updateForRender(m)),this._pipelines.updateForRender(m),this._currentRenderBundle!==null&&(this.backend.get(this._currentRenderBundle).renderObjects.push(m),m.bundle=this._currentRenderBundle.bundleGroup),this.backend.draw(m,this.info),x&&this._nodes.updateAfter(m)}_createObjectPipeline(e,t,r,s,a,c,h,f){const m=this._objects.get(e,t,r,s,a,this._currentRenderContext,h,f);m.drawRange=e.geometry.drawRange,m.group=c,this._nodes.updateBefore(m),this._geometries.updateForRender(m),this._nodes.updateForRender(m),this._bindings.updateForRender(m),this._pipelines.getForRender(m,this._compilationPromises),this._nodes.updateAfter(m)}_onCanvasTargetResize(){this._initialized&&this.backend.updateSize()}get compile(){return this.compileAsync}}class aA{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}}function GD(i){return i+(bl-i%bl)%bl}class cA extends aA{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){return GD(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}}class lA extends cA{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let WD=0;class uA extends lA{constructor(e,t){super("UniformBuffer_"+WD++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class HD extends lA{constructor(e){super(e),this.isUniformsGroup=!0,this._values=null,this.uniforms=[]}addUniform(e){return this.uniforms.push(e),this}removeUniform(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}get values(){return this._values===null&&(this._values=Array.from(this.buffer)),this._values}get buffer(){let e=this._buffer;if(e===null){const t=this.byteLength;e=new Float32Array(new ArrayBuffer(t)),this._buffer=e}return e}get byteLength(){const e=this.bytesPerElement;let t=0;for(let r=0,s=this.uniforms.length;r<s;r++){const a=this.uniforms[r],c=a.boundary,h=a.itemSize*e,f=t%bl,m=f%c,x=f+m;t+=m,x!==0&&bl-x<h&&(t+=bl-x),a.offset=t/e,t+=h}return Math.ceil(t/bl)*bl}update(){let e=!1;for(const t of this.uniforms)this.updateByType(t)===!0&&(e=!0);return e}updateByType(e){if(e.isNumberUniform)return this.updateNumber(e);if(e.isVector2Uniform)return this.updateVector2(e);if(e.isVector3Uniform)return this.updateVector3(e);if(e.isVector4Uniform)return this.updateVector4(e);if(e.isColorUniform)return this.updateColor(e);if(e.isMatrix3Uniform)return this.updateMatrix3(e);if(e.isMatrix4Uniform)return this.updateMatrix4(e);(0,d.vUy)("WebGPUUniformsGroup: Unsupported uniform type.",e)}updateNumber(e){let t=!1;const r=this.values,s=e.getValue(),a=e.offset,c=e.getType();if(r[a]!==s){const h=this._getBufferForType(c);h[a]=r[a]=s,t=!0}return t}updateVector2(e){let t=!1;const r=this.values,s=e.getValue(),a=e.offset,c=e.getType();if(r[a+0]!==s.x||r[a+1]!==s.y){const h=this._getBufferForType(c);h[a+0]=r[a+0]=s.x,h[a+1]=r[a+1]=s.y,t=!0}return t}updateVector3(e){let t=!1;const r=this.values,s=e.getValue(),a=e.offset,c=e.getType();if(r[a+0]!==s.x||r[a+1]!==s.y||r[a+2]!==s.z){const h=this._getBufferForType(c);h[a+0]=r[a+0]=s.x,h[a+1]=r[a+1]=s.y,h[a+2]=r[a+2]=s.z,t=!0}return t}updateVector4(e){let t=!1;const r=this.values,s=e.getValue(),a=e.offset,c=e.getType();if(r[a+0]!==s.x||r[a+1]!==s.y||r[a+2]!==s.z||r[a+4]!==s.w){const h=this._getBufferForType(c);h[a+0]=r[a+0]=s.x,h[a+1]=r[a+1]=s.y,h[a+2]=r[a+2]=s.z,h[a+3]=r[a+3]=s.w,t=!0}return t}updateColor(e){let t=!1;const r=this.values,s=e.getValue(),a=e.offset;if(r[a+0]!==s.r||r[a+1]!==s.g||r[a+2]!==s.b){const c=this.buffer;c[a+0]=r[a+0]=s.r,c[a+1]=r[a+1]=s.g,c[a+2]=r[a+2]=s.b,t=!0}return t}updateMatrix3(e){let t=!1;const r=this.values,s=e.getValue().elements,a=e.offset;if(r[a+0]!==s[0]||r[a+1]!==s[1]||r[a+2]!==s[2]||r[a+4]!==s[3]||r[a+5]!==s[4]||r[a+6]!==s[5]||r[a+8]!==s[6]||r[a+9]!==s[7]||r[a+10]!==s[8]){const c=this.buffer;c[a+0]=r[a+0]=s[0],c[a+1]=r[a+1]=s[1],c[a+2]=r[a+2]=s[2],c[a+4]=r[a+4]=s[3],c[a+5]=r[a+5]=s[4],c[a+6]=r[a+6]=s[5],c[a+8]=r[a+8]=s[6],c[a+9]=r[a+9]=s[7],c[a+10]=r[a+10]=s[8],t=!0}return t}updateMatrix4(e){let t=!1;const r=this.values,s=e.getValue().elements,a=e.offset;return jD(r,s,a)===!1&&(this.buffer.set(s,a),$D(r,s,a),t=!0),t}_getBufferForType(e){return e==="int"||e==="ivec2"||e==="ivec3"||e==="ivec4"?new Int32Array(this.buffer.buffer):e==="uint"||e==="uvec2"||e==="uvec3"||e==="uvec4"?new Uint32Array(this.buffer.buffer):this.buffer}}function $D(i,e,t){for(let r=0,s=e.length;r<s;r++)i[t+r]=e[r]}function jD(i,e,t){for(let r=0,s=e.length;r<s;r++)if(i[t+r]!==e[r])return!1;return!0}let XD=0;class hA extends HD{constructor(e,t){super(e),this.id=XD++,this.groupNode=t,this.isNodeUniformsGroup=!0}}class dA extends aA{constructor(e,t){super(e),this._texture=null,this._onTextureDispose=()=>{this.generation=null,this.version=0},this.texture=t,this.version=t?t.version:0,this.generation=null,this.samplerKey="",this.isSampler=!0}set texture(e){this._texture!==e&&(this._texture&&this._texture.removeEventListener("dispose",this._onTextureDispose),this._texture=e,this.generation=null,this.version=0,this._texture&&this._texture.addEventListener("dispose",this._onTextureDispose))}get texture(){return this._texture}update(){const{texture:e,version:t}=this;return t!==e.version?(this.version=e.version,!0):!1}clone(){const e=super.clone();return e._texture=null,e._onTextureDispose=()=>{e.generation=null,e.version=0},e.texture=this.texture,e}}let qD=0;class KD extends dA{constructor(e,t){super(e,t),this.id=qD++,this.store=!1,this.mipLevel=0,this.isSampledTexture=!0}}class Xx extends KD{constructor(e,t,r,s=null){super(e,t?t.value:null),this.textureNode=t,this.groupNode=r,this.access=s}update(){const{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update()}}class fA extends Xx{constructor(e,t,r,s=null){super(e,t,r,s),this.isSampledCubeTexture=!0}}class cS extends Xx{constructor(e,t,r,s=null){super(e,t,r,s),this.isSampledTexture3D=!0}}const pA={bitcast_int_uint:new Cr("uint tsl_bitcast_uint_to_int ( int x ) { return floatBitsToInt( uintBitsToFloat( x ) ); }"),bitcast_uint_int:new Cr("uint tsl_bitcast_int_to_uint ( int x ) { return floatBitsToUint( intBitsToFloat ( x ) ); }")},ZD={textureDimensions:"textureSize",equals:"equal",bitcast_float_int:"floatBitsToInt",bitcast_int_float:"intBitsToFloat",bitcast_uint_float:"uintBitsToFloat",bitcast_float_uint:"floatBitsToUint",bitcast_uint_int:"tsl_bitcast_uint_to_int",bitcast_int_uint:"tsl_bitcast_int_to_uint"},YD={low:"lowp",medium:"mediump",high:"highp"},mA={swizzleAssign:!0,storageBuffer:!1},gA={perspective:"smooth",linear:"noperspective"},xA={centroid:"centroid"},_A=`
precision highp float;
precision highp int;
precision highp sampler2D;
precision highp sampler3D;
precision highp samplerCube;
precision highp sampler2DArray;
precision highp usampler2D;
precision highp usampler3D;
precision highp usamplerCube;
precision highp usampler2DArray;
precision highp isampler2D;
precision highp isampler3D;
precision highp isamplerCube;
precision highp isampler2DArray;
precision lowp sampler2DShadow;
precision lowp sampler2DArrayShadow;
precision lowp samplerCubeShadow;
`;class QD extends Yw{constructor(e,t){super(e,t,new AD),this.uniformGroups={},this.transforms=[],this.extensions={},this.builtins={vertex:[],fragment:[],compute:[]}}needsToWorkingColorSpace(e){return e.isVideoTexture===!0&&e.colorSpace!==d.aCh}_include(e){const t=pA[e];return t.build(this),this.addInclude(t),t}getMethod(e){return pA[e]!==void 0&&this._include(e),ZD[e]||e}getBitcastMethod(e,t){return this.getMethod(`bitcast_${t}_${e}`)}getTernary(e,t,r){return`${e} ? ${t} : ${r}`}getOutputStructName(){return""}buildFunctionCode(e){const t=e.layout,r=this.flowShaderNode(e),s=[];for(const c of t.inputs)s.push(this.getType(c.type)+" "+c.name);return`${this.getType(t.type)} ${t.name}( ${s.join(", ")} ) {
${r.vars}
${r.code}
return ${r.result};
}`}setupPBO(e){const t=e.value;if(t.pbo===void 0){const r=t.array,s=t.count*t.itemSize,{itemSize:a}=t,c=t.array.constructor.name.toLowerCase().includes("int");let h=c?d.D9w:d.hEm;a===2?h=c?d.CtA:d.av9:a===3?h=c?d.F5G:d.UCm:a===4&&(h=c?d.E2K:d.wk1);const f={Float32Array:d.VzW,Uint8Array:d.ywz,Uint16Array:d.LsT,Uint32Array:d.JQ4,Int8Array:d.T95,Int16Array:d.iAb,Int32Array:d.Kz5,Uint8ClampedArray:d.ywz},m=Math.pow(2,Math.ceil(Math.log2(Math.sqrt(s/a))));let x=Math.ceil(s/a/m);m*x*a<s&&x++;const _=m*x*a,v=new r.constructor(_);v.set(r,0),t.array=v;const T=new d.IEO(t.array,m,x,h,f[t.array.constructor.name]||d.VzW);T.needsUpdate=!0,T.isPBOTexture=!0;const w=new _a(T,null,null);w.setPrecision("high"),t.pboNode=w,t.pbo=w.value,this.getUniformFromNode(t.pboNode,"texture",this.shaderStage,this.context.nodeName)}}getPropertyName(e,t=this.shaderStage){return e.isNodeUniform&&e.node.isTextureNode!==!0&&e.node.isBufferNode!==!0?t.charAt(0)+"_"+e.name:super.getPropertyName(e,t)}generatePBO(e){const{node:t,indexNode:r}=e,s=t.value;if(this.renderer.backend.has(s)){const x=this.renderer.backend.get(s);x.pbo=s.pbo}const a=this.getUniformFromNode(s.pboNode,"texture",this.shaderStage,this.context.nodeName),c=this.getPropertyName(a);this.increaseUsage(r);const h=r.build(this,"uint"),f=this.getDataFromNode(e);let m=f.propertyName;if(m===void 0){const x=this.getVarFromNode(e);m=this.getPropertyName(x);const _=this.getDataFromNode(t);let v=_.propertySizeName;v===void 0&&(v=m+"Size",this.getVarFromNode(t,v,"uint"),this.addLineFlowCode(`${v} = uint( textureSize( ${c}, 0 ).x )`,e),_.propertySizeName=v);const{itemSize:T}=s,w="."+Ja.join("").slice(0,T),P=`ivec2(${h} % ${v}, ${h} / ${v})`,C=this.generateTextureLoad(null,c,P,"0",null,null);let E="vec4";s.pbo.type===d.JQ4?E="uvec4":s.pbo.type===d.Kz5&&(E="ivec4"),this.addLineFlowCode(`${m} = ${E}(${C})${w}`,e),f.propertyName=m}return m}generateTextureLoad(e,t,r,s,a,c){s===null&&(s="0");let h;return a?c?h=`texelFetchOffset( ${t}, ivec3( ${r}, ${a} ), ${s}, ${c} )`:h=`texelFetch( ${t}, ivec3( ${r}, ${a} ), ${s} )`:c?h=`texelFetchOffset( ${t}, ${r}, ${s}, ${c} )`:h=`texelFetch( ${t}, ${r}, ${s} )`,e!==null&&e.isDepthTexture&&(h+=".x"),h}generateTexture(e,t,r,s,a){return s&&(r=`vec3( ${r}, ${s} )`),e.isDepthTexture?a?`textureOffset( ${t}, ${r}, ${a} ).x`:`texture( ${t}, ${r} ).x`:a?`textureOffset( ${t}, ${r}, ${a} )`:`texture( ${t}, ${r} )`}generateTextureLevel(e,t,r,s,a){return a?`textureLodOffset( ${t}, ${r}, ${s}, ${a} )`:`textureLod( ${t}, ${r}, ${s} )`}generateTextureBias(e,t,r,s,a){return a?`textureOffset( ${t}, ${r}, ${a}, ${s} )`:`texture( ${t}, ${r}, ${s} )`}generateTextureGrad(e,t,r,s,a){return a?`textureGradOffset( ${t}, ${r}, ${s[0]}, ${s[1]}, ${a} )`:`textureGrad( ${t}, ${r}, ${s[0]}, ${s[1]} )`}generateTextureCompare(e,t,r,s,a,c,h=this.shaderStage){if(h==="fragment")return a?c?`textureOffset( ${t}, vec4( ${r}, ${a}, ${s} ), ${c} )`:`texture( ${t}, vec4( ${r}, ${a}, ${s} ) )`:c?`textureOffset( ${t}, vec3( ${r}, ${s} ), ${c} )`:`texture( ${t}, vec3( ${r}, ${s} ) )`;(0,d.vUy)(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${h} shader.`)}getVars(e){const t=[],r=this.vars[e];if(r!==void 0)for(const s of r)t.push(`${this.getVar(s.type,s.name,s.count)};`);return t.join(`
`)}getUniforms(e){const t=this.uniforms[e],r=[],s={};for(const c of t){let h=null,f=!1;if(c.type==="texture"||c.type==="texture3D"){const x=c.node.value;let _="";(x.isDataTexture===!0||x.isData3DTexture===!0)&&(x.type===d.JQ4?_="u":x.type===d.Kz5&&(_="i")),c.type==="texture3D"&&x.isArrayTexture===!1?h=`${_}sampler3D ${c.name};`:x.compareFunction?x.isArrayTexture===!0?h=`sampler2DArrayShadow ${c.name};`:h=`sampler2DShadow ${c.name};`:x.isArrayTexture===!0||x.isDataArrayTexture===!0||x.isCompressedArrayTexture===!0?h=`${_}sampler2DArray ${c.name};`:h=`${_}sampler2D ${c.name};`}else if(c.type==="cubeTexture")h=`samplerCube ${c.name};`;else if(c.type==="buffer"){const x=c.node,_=this.getType(x.bufferType),v=x.bufferCount,T=v>0?v:"";h=`${x.name} {
${_} ${c.name}[${T}];
};
`}else h=`${this.getVectorType(c.type)} ${this.getPropertyName(c,e)};`,f=!0;const m=c.node.precision;if(m!==null&&(h=YD[m]+" "+h),f){h=" "+h;const x=c.groupNode.name;(s[x]||(s[x]=[])).push(h)}else h="uniform "+h,r.push(h)}let a="";for(const c in s){const h=s[c];a+=this._getGLSLUniformStruct(e+"_"+c,h.join(`
`))+`
`}return a+=r.join(`
`),a}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==d.Kz5){let r=e;e.isInterleavedBufferAttribute&&(r=e.data);const s=r.array;s instanceof Uint32Array||s instanceof Int32Array||(t=t.slice(1))}return t}getAttributes(e){let t="";if(e==="vertex"||e==="compute"){const r=this.getAttributesArray();let s=0;for(const a of r)t+=`layout( location = ${s++} ) in ${a.type} ${a.name};
`}return t}getStructMembers(e){const t=[];for(const r of e.members)t.push(` ${r.type} ${r.name};`);return t.join(`
`)}getStructs(e){const t=[],r=this.structs[e],s=[];for(const a of r)if(a.output)for(const c of a.members)s.push(`layout( location = ${c.index} ) out ${c.type} ${c.name};`);else{let c="struct "+a.name+` {
`;c+=this.getStructMembers(a),c+=`
};
`,t.push(c)}return s.length===0&&s.push("layout( location = 0 ) out vec4 fragColor;"),`
`+s.join(`
`)+`
`+t.join(`
`)}getVaryings(e){let t="";const r=this.varyings;if(e==="vertex"||e==="compute")for(const s of r){e==="compute"&&(s.needsInterpolation=!0);const a=this.getType(s.type);if(s.needsInterpolation)if(s.interpolationType){const c=gA[s.interpolationType]||s.interpolationType,h=xA[s.interpolationSampling]||"";t+=`${c} ${h} out ${a} ${s.name};
`}else{const c=a.includes("int")||a.includes("uv")||a.includes("iv")?"flat ":"";t+=`${c}out ${a} ${s.name};
`}else t+=`${a} ${s.name};
`}else if(e==="fragment"){for(const s of r)if(s.needsInterpolation){const a=this.getType(s.type);if(s.interpolationType){const c=gA[s.interpolationType]||s.interpolationType,h=xA[s.interpolationSampling]||"";t+=`${c} ${h} in ${a} ${s.name};
`}else{const c=a.includes("int")||a.includes("uv")||a.includes("iv")?"flat ":"";t+=`${c}in ${a} ${s.name};
`}}}for(const s of this.builtins[e])t+=`${s};
`;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce((r,s)=>r*s,1)}u`}getSubgroupSize(){(0,d.vUy)("GLSLNodeBuilder: WebGLBackend does not support the subgroupSize node")}getInvocationSubgroupIndex(){(0,d.vUy)("GLSLNodeBuilder: WebGLBackend does not support the invocationSubgroupIndex node")}getSubgroupIndex(){(0,d.vUy)("GLSLNodeBuilder: WebGLBackend does not support the subgroupIndex node")}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,r=this.shaderStage){const s=this.extensions[r]||(this.extensions[r]=new Map);s.has(e)===!1&&s.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if(e==="vertex"){const s=this.renderer.backend.extensions;this.object.isBatchedMesh&&s.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const r=this.extensions[e];if(r!==void 0)for(const{name:s,behavior:a}of r.values())t.push(`#extension ${s} : ${a}`);return t.join(`
`)}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=mA[e];if(t===void 0){let r;switch(t=!1,e){case"float32Filterable":r="OES_texture_float_linear";break;case"clipDistance":r="WEBGL_clip_cull_distance";break}if(r!==void 0){const s=this.renderer.backend.extensions;s.has(r)&&(s.get(r),t=!0)}mA[e]=t}return t}isFlipY(){return!0}enableHardwareClipping(e){this.enableExtension("GL_ANGLE_clip_cull_distance","require"),this.builtins.vertex.push(`out float gl_ClipDistance[ ${e} ]`)}enableMultiview(){this.enableExtension("GL_OVR_multiview2","require","fragment"),this.enableExtension("GL_OVR_multiview2","require","vertex"),this.builtins.vertex.push("layout(num_views = 2) in")}registerTransform(e,t){this.transforms.push({varyingName:e,attributeNode:t})}getTransforms(){const e=this.transforms;let t="";for(let r=0;r<e.length;r++){const s=e[r],a=this.getPropertyName(s.attributeNode);a&&(t+=`${s.varyingName} = ${a};
`)}return t}_getGLSLUniformStruct(e,t){return`
layout( std140 ) uniform ${e} {
${t}
};`}_getGLSLVertexCode(e){return`#version 300 es
${this.getSignature()}
// extensions
${e.extensions}
// precision
${_A}
// uniforms
${e.uniforms}
// varyings
${e.varyings}
// attributes
${e.attributes}
// codes
${e.codes}
void main() {
// vars
${e.vars}
// transforms
${e.transforms}
// flow
${e.flow}
gl_PointSize = 1.0;
}
`}_getGLSLFragmentCode(e){return`#version 300 es
${this.getSignature()}
// extensions
${e.extensions}
// precision
${_A}
// structs
${e.structs}
// uniforms
${e.uniforms}
// varyings
${e.varyings}
// codes
${e.codes}
void main() {
// vars
${e.vars}
// flow
${e.flow}
}
`}buildCode(){const e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){let r=`// code
`;r+=this.flowCode[t];const s=this.flowNodes[t],a=s[s.length-1];for(const h of s){const f=this.getFlowData(h),m=h.name;m&&(r.length>0&&(r+=`
`),r+=` // flow -> ${m}
`),r+=`${f.code}
`,h===a&&t!=="compute"&&(r+=`// result
`,t==="vertex"?(r+="gl_Position = ",r+=`${f.result};`):t==="fragment"&&(h.outputNode.isOutputStructNode||(r+="fragColor = ",r+=`${f.result};`)))}const c=e[t];c.extensions=this.getExtensions(t),c.uniforms=this.getUniforms(t),c.attributes=this.getAttributes(t),c.varyings=this.getVaryings(t),c.vars=this.getVars(t),c.structs=this.getStructs(t),c.codes=this.getCodes(t),c.transforms=this.getTransforms(t),c.flow=r}this.material!==null?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,r,s=null){const a=super.getUniformFromNode(e,t,r,s),c=this.getDataFromNode(e,r,this.globalCache);let h=c.uniformGPU;if(h===void 0){const f=e.groupNode,m=f.name,x=this.getBindGroupArray(m,r);if(t==="texture")h=new Xx(a.name,a.node,f),x.push(h);else if(t==="cubeTexture")h=new fA(a.name,a.node,f),x.push(h);else if(t==="texture3D")h=new cS(a.name,a.node,f),x.push(h);else if(t==="buffer"){e.name=`NodeBuffer_${e.id}`,a.name=`buffer${e.id}`;const _=new uA(e,f);_.name=e.name,x.push(_),h=_}else{const _=this.uniformGroups[r]||(this.uniformGroups[r]={});let v=_[m];v===void 0&&(v=new hA(r+"_"+m,f),_[m]=v,x.push(v)),h=this.getNodeUniform(a,t),v.addUniform(h)}c.uniformGPU=h}return a}}let lS=null,zd=null;class yA{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={[d.eS_.RENDER]:null,[d.eS_.COMPUTE]:null},this.trackTimestamp=e.trackTimestamp===!0}init(e){return nn(this,null,function*(){this.renderer=e})}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}updateSampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}copyTextureToBuffer(){return nn(this,null,function*(){})}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}updateTimeStampUID(e){const t=this.get(e),r=this.renderer.info.frame;let s;e.isComputeNode===!0?s="c:"+this.renderer.info.compute.frameCalls:s="r:"+this.renderer.info.render.frameCalls,t.timestampUID=s+":"+e.id+":f"+r}getTimestampUID(e){return this.get(e).timestampUID}getTimestampFrames(e){const t=this.timestampQueryPool[e];return t?t.getTimestampFrames():[]}_getQueryPool(e){const t=e.startsWith("c:")?d.eS_.COMPUTE:d.eS_.RENDER;return this.timestampQueryPool[t]}getTimestamp(e){return this._getQueryPool(e).getTimestamp(e)}hasTimestamp(e){return this._getQueryPool(e).hasTimestamp(e)}isOccluded(){}resolveTimestampsAsync(e="render"){return nn(this,null,function*(){if(!this.trackTimestamp){(0,d.O4K)("WebGPURenderer: Timestamp tracking is disabled.");return}const t=this.timestampQueryPool[e];if(!t)return;const r=yield t.resolveQueriesAsync();return this.renderer.info[e].timestamp=r,r})}getArrayBufferAsync(){return nn(this,null,function*(){})}hasFeatureAsync(){return nn(this,null,function*(){})}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return lS=lS||new d.FM8,this.renderer.getDrawingBufferSize(lS)}setScissorTest(){}getClearColor(){const e=this.renderer;return zd=zd||new Rv,e.getClearColor(zd),zd.getRGB(zd),zd}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas!==void 0?this.parameters.canvas:(0,d.O5A)(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${d.UZH} webgpu`),this.domElement=e),e}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}dispose(){}}let JD=0;class eU{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[this.activeBufferIndex^1]}switchBuffers(){this.activeBufferIndex^=1}}class tU{constructor(e){this.backend=e}createAttribute(e,t){const r=this.backend,{gl:s}=r,a=e.array,c=e.usage||s.STATIC_DRAW,h=e.isInterleavedBufferAttribute?e.data:e,f=r.get(h);let m=f.bufferGPU;m===void 0&&(m=this._createBuffer(s,t,a,c),f.bufferGPU=m,f.bufferType=t,f.version=h.version);let x;if(a instanceof Float32Array)x=s.FLOAT;else if(typeof Float16Array!="undefined"&&a instanceof Float16Array)x=s.HALF_FLOAT;else if(a instanceof Uint16Array)e.isFloat16BufferAttribute?x=s.HALF_FLOAT:x=s.UNSIGNED_SHORT;else if(a instanceof Int16Array)x=s.SHORT;else if(a instanceof Uint32Array)x=s.UNSIGNED_INT;else if(a instanceof Int32Array)x=s.INT;else if(a instanceof Int8Array)x=s.BYTE;else if(a instanceof Uint8Array)x=s.UNSIGNED_BYTE;else if(a instanceof Uint8ClampedArray)x=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+a);let _={bufferGPU:m,bufferType:t,type:x,byteLength:a.byteLength,bytesPerElement:a.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:x===s.INT||x===s.UNSIGNED_INT||e.gpuType===d.Kz5,id:JD++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const v=this._createBuffer(s,t,a,c);_=new eU(_,v)}r.set(e,_)}updateAttribute(e){const t=this.backend,{gl:r}=t,s=e.array,a=e.isInterleavedBufferAttribute?e.data:e,c=t.get(a),h=c.bufferType,f=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(r.bindBuffer(h,c.bufferGPU),f.length===0)r.bufferSubData(h,0,s);else{for(let m=0,x=f.length;m<x;m++){const _=f[m];r.bufferSubData(h,_.start*s.BYTES_PER_ELEMENT,s,_.start,_.count)}a.clearUpdateRanges()}r.bindBuffer(h,null),c.version=a.version}destroyAttribute(e){const t=this.backend,{gl:r}=t;e.isInterleavedBufferAttribute&&t.delete(e.data);const s=t.get(e);r.deleteBuffer(s.bufferGPU),t.delete(e)}getArrayBufferAsync(e){return nn(this,null,function*(){const t=this.backend,{gl:r}=t,s=e.isInterleavedBufferAttribute?e.data:e,{bufferGPU:a}=t.get(s),c=e.array,h=c.byteLength;r.bindBuffer(r.COPY_READ_BUFFER,a);const f=r.createBuffer();r.bindBuffer(r.COPY_WRITE_BUFFER,f),r.bufferData(r.COPY_WRITE_BUFFER,h,r.STREAM_READ),r.copyBufferSubData(r.COPY_READ_BUFFER,r.COPY_WRITE_BUFFER,0,0,h),yield t.utils._clientWaitAsync();const m=new e.array.constructor(c.length);return r.bindBuffer(r.COPY_WRITE_BUFFER,f),r.getBufferSubData(r.COPY_WRITE_BUFFER,0,m),r.deleteBuffer(f),r.bindBuffer(r.COPY_READ_BUFFER,null),r.bindBuffer(r.COPY_WRITE_BUFFER,null),m.buffer})}_createBuffer(e,t,r,s){const a=e.createBuffer();return e.bindBuffer(t,a),e.bufferData(t,r,s),e.bindBuffer(t,null),a}}let uS,Am;class nU{constructor(e){this.backend=e,this.gl=this.backend.gl,this.enabled={},this.currentFlipSided=null,this.currentCullFace=null,this.currentProgram=null,this.currentBlendingEnabled=!1,this.currentBlending=null,this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentPremultipledAlpha=null,this.currentPolygonOffsetFactor=null,this.currentPolygonOffsetUnits=null,this.currentColorMask=null,this.currentDepthFunc=null,this.currentDepthMask=null,this.currentStencilFunc=null,this.currentStencilRef=null,this.currentStencilFuncMask=null,this.currentStencilFail=null,this.currentStencilZFail=null,this.currentStencilZPass=null,this.currentStencilMask=null,this.currentLineWidth=null,this.currentClippingPlanes=0,this.currentVAO=null,this.currentIndex=null,this.currentBoundFramebuffers={},this.currentDrawbuffers=new WeakMap,this.maxTextures=this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS),this.currentTextureSlot=null,this.currentBoundTextures={},this.currentBoundBufferBases={},this._init()}_init(){const e=this.gl;uS={[d.bGH]:e.FUNC_ADD,[d.Wbm]:e.FUNC_SUBTRACT,[d.rOj]:e.FUNC_REVERSE_SUBTRACT},Am={[d.c8b]:e.ZERO,[d.ghN]:e.ONE,[d.KhW]:e.SRC_COLOR,[d.k74]:e.SRC_ALPHA,[d.RlZ]:e.SRC_ALPHA_SATURATE,[d.Vdb]:e.DST_COLOR,[d.fSK]:e.DST_ALPHA,[d.iWC]:e.ONE_MINUS_SRC_COLOR,[d.LgZ]:e.ONE_MINUS_SRC_ALPHA,[d.Wpd]:e.ONE_MINUS_DST_COLOR,[d.Hy8]:e.ONE_MINUS_DST_ALPHA};const t=e.getParameter(e.SCISSOR_BOX),r=e.getParameter(e.VIEWPORT);this.currentScissor=new d.Ltg().fromArray(t),this.currentViewport=new d.Ltg().fromArray(r),this._tempVec4=new d.Ltg}enable(e){const{enabled:t}=this;t[e]!==!0&&(this.gl.enable(e),t[e]=!0)}disable(e){const{enabled:t}=this;t[e]!==!1&&(this.gl.disable(e),t[e]=!1)}setFlipSided(e){if(this.currentFlipSided!==e){const{gl:t}=this;e?t.frontFace(t.CW):t.frontFace(t.CCW),this.currentFlipSided=e}}setCullFace(e){const{gl:t}=this;e!==d.PeU?(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===d.tm_?t.cullFace(t.BACK):e===d.S2y?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):this.disable(t.CULL_FACE),this.currentCullFace=e}setLineWidth(e){const{currentLineWidth:t,gl:r}=this;e!==t&&(r.lineWidth(e),this.currentLineWidth=e)}setBlending(e,t,r,s,a,c,h,f){const{gl:m}=this;if(e===d.jFi){this.currentBlendingEnabled===!0&&(this.disable(m.BLEND),this.currentBlendingEnabled=!1);return}if(this.currentBlendingEnabled===!1&&(this.enable(m.BLEND),this.currentBlendingEnabled=!0),e!==d.Xaj){if(e!==this.currentBlending||f!==this.currentPremultipledAlpha){if((this.currentBlendEquation!==d.bGH||this.currentBlendEquationAlpha!==d.bGH)&&(m.blendEquation(m.FUNC_ADD),this.currentBlendEquation=d.bGH,this.currentBlendEquationAlpha=d.bGH),f)switch(e){case d.bdR:m.blendFuncSeparate(m.ONE,m.ONE_MINUS_SRC_ALPHA,m.ONE,m.ONE_MINUS_SRC_ALPHA);break;case d.WMw:m.blendFunc(m.ONE,m.ONE);break;case d.N4l:m.blendFuncSeparate(m.ZERO,m.ONE_MINUS_SRC_COLOR,m.ZERO,m.ONE);break;case d.M5h:m.blendFuncSeparate(m.DST_COLOR,m.ONE_MINUS_SRC_ALPHA,m.ZERO,m.ONE);break;default:(0,d.vUy)("WebGLState: Invalid blending: ",e);break}else switch(e){case d.bdR:m.blendFuncSeparate(m.SRC_ALPHA,m.ONE_MINUS_SRC_ALPHA,m.ONE,m.ONE_MINUS_SRC_ALPHA);break;case d.WMw:m.blendFuncSeparate(m.SRC_ALPHA,m.ONE,m.ONE,m.ONE);break;case d.N4l:(0,d.vUy)("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case d.M5h:(0,d.vUy)("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:(0,d.vUy)("WebGLState: Invalid blending: ",e);break}this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentBlending=e,this.currentPremultipledAlpha=f}return}a=a||t,c=c||r,h=h||s,(t!==this.currentBlendEquation||a!==this.currentBlendEquationAlpha)&&(m.blendEquationSeparate(uS[t],uS[a]),this.currentBlendEquation=t,this.currentBlendEquationAlpha=a),(r!==this.currentBlendSrc||s!==this.currentBlendDst||c!==this.currentBlendSrcAlpha||h!==this.currentBlendDstAlpha)&&(m.blendFuncSeparate(Am[r],Am[s],Am[c],Am[h]),this.currentBlendSrc=r,this.currentBlendDst=s,this.currentBlendSrcAlpha=c,this.currentBlendDstAlpha=h),this.currentBlending=e,this.currentPremultipledAlpha=!1}setColorMask(e){this.currentColorMask!==e&&(this.gl.colorMask(e,e,e,e),this.currentColorMask=e)}setDepthTest(e){const{gl:t}=this;e?this.enable(t.DEPTH_TEST):this.disable(t.DEPTH_TEST)}setDepthMask(e){this.currentDepthMask!==e&&(this.gl.depthMask(e),this.currentDepthMask=e)}setDepthFunc(e){if(this.currentDepthFunc!==e){const{gl:t}=this;switch(e){case d.BVF:t.depthFunc(t.NEVER);break;case d.Se2:t.depthFunc(t.ALWAYS);break;case d.Zr5:t.depthFunc(t.LESS);break;case d.vCF:t.depthFunc(t.LEQUAL);break;case d.eD:t.depthFunc(t.EQUAL);break;case d.ksN:t.depthFunc(t.GEQUAL);break;case d.w$m:t.depthFunc(t.GREATER);break;case d.M6v:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}this.currentDepthFunc=e}}scissor(e,t,r,s){const a=this._tempVec4.set(e,t,r,s);if(this.currentScissor.equals(a)===!1){const{gl:c}=this;c.scissor(a.x,a.y,a.z,a.w),this.currentScissor.copy(a)}}viewport(e,t,r,s){const a=this._tempVec4.set(e,t,r,s);if(this.currentViewport.equals(a)===!1){const{gl:c}=this;c.viewport(a.x,a.y,a.z,a.w),this.currentViewport.copy(a)}}setScissorTest(e){const t=this.gl;e?t.enable(t.SCISSOR_TEST):t.disable(t.SCISSOR_TEST)}setStencilTest(e){const{gl:t}=this;e?this.enable(t.STENCIL_TEST):this.disable(t.STENCIL_TEST)}setStencilMask(e){this.currentStencilMask!==e&&(this.gl.stencilMask(e),this.currentStencilMask=e)}setStencilFunc(e,t,r){(this.currentStencilFunc!==e||this.currentStencilRef!==t||this.currentStencilFuncMask!==r)&&(this.gl.stencilFunc(e,t,r),this.currentStencilFunc=e,this.currentStencilRef=t,this.currentStencilFuncMask=r)}setStencilOp(e,t,r){(this.currentStencilFail!==e||this.currentStencilZFail!==t||this.currentStencilZPass!==r)&&(this.gl.stencilOp(e,t,r),this.currentStencilFail=e,this.currentStencilZFail=t,this.currentStencilZPass=r)}setMaterial(e,t,r){const{gl:s}=this;e.side===d.ehD?this.disable(s.CULL_FACE):this.enable(s.CULL_FACE);let a=e.side===d._Li;t&&(a=!a),this.setFlipSided(a),e.blending===d.bdR&&e.transparent===!1?this.setBlending(d.jFi):this.setBlending(e.blending,e.blendEquation,e.blendSrc,e.blendDst,e.blendEquationAlpha,e.blendSrcAlpha,e.blendDstAlpha,e.premultipliedAlpha),this.setDepthFunc(e.depthFunc),this.setDepthTest(e.depthTest),this.setDepthMask(e.depthWrite),this.setColorMask(e.colorWrite);const c=e.stencilWrite;if(this.setStencilTest(c),c&&(this.setStencilMask(e.stencilWriteMask),this.setStencilFunc(e.stencilFunc,e.stencilRef,e.stencilFuncMask),this.setStencilOp(e.stencilFail,e.stencilZFail,e.stencilZPass)),this.setPolygonOffset(e.polygonOffset,e.polygonOffsetFactor,e.polygonOffsetUnits),e.alphaToCoverage===!0&&this.backend.renderer.currentSamples>0?this.enable(s.SAMPLE_ALPHA_TO_COVERAGE):this.disable(s.SAMPLE_ALPHA_TO_COVERAGE),r>0&&this.currentClippingPlanes!==r)for(let f=0;f<8;f++)f<r?this.enable(12288+f):this.disable(12288+f)}setPolygonOffset(e,t,r){const{gl:s}=this;e?(this.enable(s.POLYGON_OFFSET_FILL),(this.currentPolygonOffsetFactor!==t||this.currentPolygonOffsetUnits!==r)&&(s.polygonOffset(t,r),this.currentPolygonOffsetFactor=t,this.currentPolygonOffsetUnits=r)):this.disable(s.POLYGON_OFFSET_FILL)}useProgram(e){return this.currentProgram!==e?(this.gl.useProgram(e),this.currentProgram=e,!0):!1}setVertexState(e,t=null){const r=this.gl;return this.currentVAO!==e||this.currentIndex!==t?(r.bindVertexArray(e),t!==null&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,t),this.currentVAO=e,this.currentIndex=t,!0):!1}resetVertexState(){const e=this.gl;e.bindVertexArray(null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),this.currentVAO=null,this.currentIndex=null}bindFramebuffer(e,t){const{gl:r,currentBoundFramebuffers:s}=this;return s[e]!==t?(r.bindFramebuffer(e,t),s[e]=t,e===r.DRAW_FRAMEBUFFER&&(s[r.FRAMEBUFFER]=t),e===r.FRAMEBUFFER&&(s[r.DRAW_FRAMEBUFFER]=t),!0):!1}drawBuffers(e,t){const{gl:r}=this;let s=[],a=!1;if(e.textures!==null){s=this.currentDrawbuffers.get(t),s===void 0&&(s=[],this.currentDrawbuffers.set(t,s));const c=e.textures;if(s.length!==c.length||s[0]!==r.COLOR_ATTACHMENT0){for(let h=0,f=c.length;h<f;h++)s[h]=r.COLOR_ATTACHMENT0+h;s.length=c.length,a=!0}}else s[0]!==r.BACK&&(s[0]=r.BACK,a=!0);a&&r.drawBuffers(s)}activeTexture(e){const{gl:t,currentTextureSlot:r,maxTextures:s}=this;e===void 0&&(e=t.TEXTURE0+s-1),r!==e&&(t.activeTexture(e),this.currentTextureSlot=e)}bindTexture(e,t,r){const{gl:s,currentTextureSlot:a,currentBoundTextures:c,maxTextures:h}=this;r===void 0&&(a===null?r=s.TEXTURE0+h-1:r=a);let f=c[r];f===void 0&&(f={type:void 0,texture:void 0},c[r]=f),(f.type!==e||f.texture!==t)&&(a!==r&&(s.activeTexture(r),this.currentTextureSlot=r),s.bindTexture(e,t),f.type=e,f.texture=t)}bindBufferBase(e,t,r){const{gl:s}=this,a=`${e}-${t}`;return this.currentBoundBufferBases[a]!==r?(s.bindBufferBase(e,t,r),this.currentBoundBufferBases[a]=r,!0):!1}unbindTexture(){const{gl:e,currentTextureSlot:t,currentBoundTextures:r}=this,s=r[t];s!==void 0&&s.type!==void 0&&(e.bindTexture(s.type,null),s.type=void 0,s.texture=void 0)}}class iU{constructor(e){this.backend=e,this.gl=this.backend.gl,this.extensions=e.extensions}convert(e,t=d.aCh){const{gl:r,extensions:s}=this;let a;const c=d.epp.getTransfer(t);if(e===d.ywz)return r.UNSIGNED_BYTE;if(e===d.k0A)return r.UNSIGNED_SHORT_4_4_4_4;if(e===d.irR)return r.UNSIGNED_SHORT_5_5_5_1;if(e===d.tQZ)return r.UNSIGNED_INT_5_9_9_9_REV;if(e===d.dVD)return r.UNSIGNED_INT_10F_11F_11F_REV;if(e===d.T95)return r.BYTE;if(e===d.iAb)return r.SHORT;if(e===d.LsT)return r.UNSIGNED_SHORT;if(e===d.Kz5)return r.INT;if(e===d.JQ4)return r.UNSIGNED_INT;if(e===d.VzW)return r.FLOAT;if(e===d.cLu)return r.HALF_FLOAT;if(e===d.OTo)return r.ALPHA;if(e===d.UCm)return r.RGB;if(e===d.wk1)return r.RGBA;if(e===d.qkB)return r.DEPTH_COMPONENT;if(e===d.brP)return r.DEPTH_STENCIL;if(e===d.hEm)return r.RED;if(e===d.D9w)return r.RED_INTEGER;if(e===d.av9)return r.RG;if(e===d.CtA)return r.RG_INTEGER;if(e===d.E2K)return r.RGBA_INTEGER;if(e===d.wuA||e===d.BFQ||e===d.v3W||e===d.ILR)if(c===d.j17)if(a=s.get("WEBGL_compressed_texture_s3tc_srgb"),a!==null){if(e===d.wuA)return a.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(e===d.BFQ)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(e===d.v3W)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(e===d.ILR)return a.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(a=s.get("WEBGL_compressed_texture_s3tc"),a!==null){if(e===d.wuA)return a.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===d.BFQ)return a.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===d.v3W)return a.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===d.ILR)return a.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(e===d._AM||e===d.vCx||e===d.eaV||e===d.CaW)if(a=s.get("WEBGL_compressed_texture_pvrtc"),a!==null){if(e===d._AM)return a.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===d.vCx)return a.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===d.eaV)return a.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===d.CaW)return a.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(e===d.fto||e===d.l0P||e===d.ekQ)if(a=s.get("WEBGL_compressed_texture_etc"),a!==null){if(e===d.fto||e===d.l0P)return c===d.j17?a.COMPRESSED_SRGB8_ETC2:a.COMPRESSED_RGB8_ETC2;if(e===d.ekQ)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:a.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(e===d.ptH||e===d.jZA||e===d.y2t||e===d.gi4||e===d.Djp||e===d.BG$||e===d.NYV||e===d.xJs||e===d.pKu||e===d.GG6||e===d.Gih||e===d.FUD||e===d.iiP||e===d.SvJ)if(a=s.get("WEBGL_compressed_texture_astc"),a!==null){if(e===d.ptH)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:a.COMPRESSED_RGBA_ASTC_4x4_KHR;if(e===d.jZA)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:a.COMPRESSED_RGBA_ASTC_5x4_KHR;if(e===d.y2t)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:a.COMPRESSED_RGBA_ASTC_5x5_KHR;if(e===d.gi4)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:a.COMPRESSED_RGBA_ASTC_6x5_KHR;if(e===d.Djp)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:a.COMPRESSED_RGBA_ASTC_6x6_KHR;if(e===d.BG$)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:a.COMPRESSED_RGBA_ASTC_8x5_KHR;if(e===d.NYV)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:a.COMPRESSED_RGBA_ASTC_8x6_KHR;if(e===d.xJs)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:a.COMPRESSED_RGBA_ASTC_8x8_KHR;if(e===d.pKu)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:a.COMPRESSED_RGBA_ASTC_10x5_KHR;if(e===d.GG6)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:a.COMPRESSED_RGBA_ASTC_10x6_KHR;if(e===d.Gih)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:a.COMPRESSED_RGBA_ASTC_10x8_KHR;if(e===d.FUD)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:a.COMPRESSED_RGBA_ASTC_10x10_KHR;if(e===d.iiP)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:a.COMPRESSED_RGBA_ASTC_12x10_KHR;if(e===d.SvJ)return c===d.j17?a.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:a.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(e===d.bsb)if(a=s.get("EXT_texture_compression_bptc"),a!==null){if(e===d.bsb)return c===d.j17?a.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:a.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(e===d.HdW||e===d.vuL||e===d.ZTh||e===d.lGU)if(a=s.get("EXT_texture_compression_rgtc"),a!==null){if(e===d.HdW)return a.COMPRESSED_RED_RGTC1_EXT;if(e===d.vuL)return a.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(e===d.ZTh)return a.COMPRESSED_RED_GREEN_RGTC2_EXT;if(e===d.lGU)return a.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return e===d.wJv?r.UNSIGNED_INT_24_8:r[e]!==void 0?r[e]:null}_clientWaitAsync(){const{gl:e}=this,t=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);return e.flush(),new Promise((r,s)=>{function a(){const c=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(c===e.WAIT_FAILED){e.deleteSync(t),s();return}if(c===e.TIMEOUT_EXPIRED){requestAnimationFrame(a);return}e.deleteSync(t),r()}a()})}}let bA=!1,qx,hS,vA;class rU{constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},this._srcFramebuffer=null,this._dstFramebuffer=null,bA===!1&&(this._init(),bA=!0)}_init(){const e=this.gl;qx={[d.rpg]:e.REPEAT,[d.uWy]:e.CLAMP_TO_EDGE,[d.OoA]:e.MIRRORED_REPEAT},hS={[d.TyD]:e.NEAREST,[d.YLQ]:e.NEAREST_MIPMAP_NEAREST,[d.aH4]:e.NEAREST_MIPMAP_LINEAR,[d.wem]:e.LINEAR,[d.qyh]:e.LINEAR_MIPMAP_NEAREST,[d.D1R]:e.LINEAR_MIPMAP_LINEAR},vA={[d.xoQ]:e.NEVER,[d.T6w]:e.ALWAYS,[d.D67]:e.LESS,[d.M$G]:e.LEQUAL,[d.F1y]:e.EQUAL,[d.Jjb]:e.GEQUAL,[d.Zen]:e.GREATER,[d.O78]:e.NOTEQUAL}}getGLTextureType(e){const{gl:t}=this;let r;return e.isCubeTexture===!0?r=t.TEXTURE_CUBE_MAP:e.isArrayTexture===!0||e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?r=t.TEXTURE_2D_ARRAY:e.isData3DTexture===!0?r=t.TEXTURE_3D:r=t.TEXTURE_2D,r}getInternalFormat(e,t,r,s,a=!1){const{gl:c,extensions:h}=this;if(e!==null){if(c[e]!==void 0)return c[e];(0,d.ZK6)("WebGLBackend: Attempt to use non-existing WebGL internal format '"+e+"'")}let f=t;if(t===c.RED&&(r===c.FLOAT&&(f=c.R32F),r===c.HALF_FLOAT&&(f=c.R16F),r===c.UNSIGNED_BYTE&&(f=c.R8),r===c.UNSIGNED_SHORT&&(f=c.R16),r===c.UNSIGNED_INT&&(f=c.R32UI),r===c.BYTE&&(f=c.R8I),r===c.SHORT&&(f=c.R16I),r===c.INT&&(f=c.R32I)),t===c.RED_INTEGER&&(r===c.UNSIGNED_BYTE&&(f=c.R8UI),r===c.UNSIGNED_SHORT&&(f=c.R16UI),r===c.UNSIGNED_INT&&(f=c.R32UI),r===c.BYTE&&(f=c.R8I),r===c.SHORT&&(f=c.R16I),r===c.INT&&(f=c.R32I)),t===c.RG&&(r===c.FLOAT&&(f=c.RG32F),r===c.HALF_FLOAT&&(f=c.RG16F),r===c.UNSIGNED_BYTE&&(f=c.RG8),r===c.UNSIGNED_SHORT&&(f=c.RG16),r===c.UNSIGNED_INT&&(f=c.RG32UI),r===c.BYTE&&(f=c.RG8I),r===c.SHORT&&(f=c.RG16I),r===c.INT&&(f=c.RG32I)),t===c.RG_INTEGER&&(r===c.UNSIGNED_BYTE&&(f=c.RG8UI),r===c.UNSIGNED_SHORT&&(f=c.RG16UI),r===c.UNSIGNED_INT&&(f=c.RG32UI),r===c.BYTE&&(f=c.RG8I),r===c.SHORT&&(f=c.RG16I),r===c.INT&&(f=c.RG32I)),t===c.RGB){const m=a?d.l6D:d.epp.getTransfer(s);r===c.FLOAT&&(f=c.RGB32F),r===c.HALF_FLOAT&&(f=c.RGB16F),r===c.UNSIGNED_BYTE&&(f=c.RGB8),r===c.UNSIGNED_SHORT&&(f=c.RGB16),r===c.UNSIGNED_INT&&(f=c.RGB32UI),r===c.BYTE&&(f=c.RGB8I),r===c.SHORT&&(f=c.RGB16I),r===c.INT&&(f=c.RGB32I),r===c.UNSIGNED_BYTE&&(f=m===d.j17?c.SRGB8:c.RGB8),r===c.UNSIGNED_SHORT_5_6_5&&(f=c.RGB565),r===c.UNSIGNED_SHORT_5_5_5_1&&(f=c.RGB5_A1),r===c.UNSIGNED_SHORT_4_4_4_4&&(f=c.RGB4),r===c.UNSIGNED_INT_5_9_9_9_REV&&(f=c.RGB9_E5),r===c.UNSIGNED_INT_10F_11F_11F_REV&&(f=c.R11F_G11F_B10F)}if(t===c.RGB_INTEGER&&(r===c.UNSIGNED_BYTE&&(f=c.RGB8UI),r===c.UNSIGNED_SHORT&&(f=c.RGB16UI),r===c.UNSIGNED_INT&&(f=c.RGB32UI),r===c.BYTE&&(f=c.RGB8I),r===c.SHORT&&(f=c.RGB16I),r===c.INT&&(f=c.RGB32I)),t===c.RGBA){const m=a?d.l6D:d.epp.getTransfer(s);r===c.FLOAT&&(f=c.RGBA32F),r===c.HALF_FLOAT&&(f=c.RGBA16F),r===c.UNSIGNED_BYTE&&(f=c.RGBA8),r===c.UNSIGNED_SHORT&&(f=c.RGBA16),r===c.UNSIGNED_INT&&(f=c.RGBA32UI),r===c.BYTE&&(f=c.RGBA8I),r===c.SHORT&&(f=c.RGBA16I),r===c.INT&&(f=c.RGBA32I),r===c.UNSIGNED_BYTE&&(f=m===d.j17?c.SRGB8_ALPHA8:c.RGBA8),r===c.UNSIGNED_SHORT_4_4_4_4&&(f=c.RGBA4),r===c.UNSIGNED_SHORT_5_5_5_1&&(f=c.RGB5_A1)}return t===c.RGBA_INTEGER&&(r===c.UNSIGNED_BYTE&&(f=c.RGBA8UI),r===c.UNSIGNED_SHORT&&(f=c.RGBA16UI),r===c.UNSIGNED_INT&&(f=c.RGBA32UI),r===c.BYTE&&(f=c.RGBA8I),r===c.SHORT&&(f=c.RGBA16I),r===c.INT&&(f=c.RGBA32I)),t===c.DEPTH_COMPONENT&&(r===c.UNSIGNED_SHORT&&(f=c.DEPTH_COMPONENT16),r===c.UNSIGNED_INT&&(f=c.DEPTH_COMPONENT24),r===c.FLOAT&&(f=c.DEPTH_COMPONENT32F)),t===c.DEPTH_STENCIL&&r===c.UNSIGNED_INT_24_8&&(f=c.DEPTH24_STENCIL8),(f===c.R16F||f===c.R32F||f===c.RG16F||f===c.RG32F||f===c.RGBA16F||f===c.RGBA32F)&&h.get("EXT_color_buffer_float"),f}setTextureParameters(e,t){const{gl:r,extensions:s,backend:a}=this,c=d.epp.getPrimaries(d.epp.workingColorSpace),h=t.colorSpace===d.aCh?null:d.epp.getPrimaries(t.colorSpace),f=t.colorSpace===d.aCh||c===h?r.NONE:r.BROWSER_DEFAULT_WEBGL;r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,t.flipY),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),r.pixelStorei(r.UNPACK_ALIGNMENT,t.unpackAlignment),r.pixelStorei(r.UNPACK_COLORSPACE_CONVERSION_WEBGL,f),r.texParameteri(e,r.TEXTURE_WRAP_S,qx[t.wrapS]),r.texParameteri(e,r.TEXTURE_WRAP_T,qx[t.wrapT]),(e===r.TEXTURE_3D||e===r.TEXTURE_2D_ARRAY)&&(t.isArrayTexture||r.texParameteri(e,r.TEXTURE_WRAP_R,qx[t.wrapR])),r.texParameteri(e,r.TEXTURE_MAG_FILTER,hS[t.magFilter]);const m=t.mipmaps!==void 0&&t.mipmaps.length>0,x=t.minFilter===d.wem&&m?d.D1R:t.minFilter;if(r.texParameteri(e,r.TEXTURE_MIN_FILTER,hS[x]),t.compareFunction&&(r.texParameteri(e,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE),r.texParameteri(e,r.TEXTURE_COMPARE_FUNC,vA[t.compareFunction])),s.has("EXT_texture_filter_anisotropic")===!0){if(t.magFilter===d.TyD||t.minFilter!==d.aH4&&t.minFilter!==d.D1R||t.type===d.VzW&&s.has("OES_texture_float_linear")===!1)return;if(t.anisotropy>1){const _=s.get("EXT_texture_filter_anisotropic");r.texParameterf(e,_.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,a.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:r,defaultTextures:s}=this,a=this.getGLTextureType(e);let c=s[a];c===void 0&&(c=t.createTexture(),r.state.bindTexture(a,c),t.texParameteri(a,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(a,t.TEXTURE_MAG_FILTER,t.NEAREST),s[a]=c),r.set(e,{textureGPU:c,glTextureType:a})}createTexture(e,t){const{gl:r,backend:s}=this,{levels:a,width:c,height:h,depth:f}=t,m=s.utils.convert(e.format,e.colorSpace),x=s.utils.convert(e.type),_=this.getInternalFormat(e.internalFormat,m,x,e.colorSpace,e.isVideoTexture),v=r.createTexture(),T=this.getGLTextureType(e);s.state.bindTexture(T,v),this.setTextureParameters(T,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?r.texStorage3D(r.TEXTURE_2D_ARRAY,a,_,c,h,f):e.isData3DTexture?r.texStorage3D(r.TEXTURE_3D,a,_,c,h,f):e.isVideoTexture||r.texStorage2D(T,a,_,c,h),s.set(e,{textureGPU:v,glTextureType:T,glFormat:m,glType:x,glInternalFormat:_})}copyBufferToTexture(e,t){const{gl:r,backend:s}=this,{textureGPU:a,glTextureType:c,glFormat:h,glType:f}=s.get(t),{width:m,height:x}=t.source.data;r.bindBuffer(r.PIXEL_UNPACK_BUFFER,e),s.state.bindTexture(c,a),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,!1),r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),r.texSubImage2D(c,0,0,0,m,x,h,f,0),r.bindBuffer(r.PIXEL_UNPACK_BUFFER,null),s.state.unbindTexture()}updateTexture(e,t){const{gl:r}=this,{width:s,height:a}=t,{textureGPU:c,glTextureType:h,glFormat:f,glType:m,glInternalFormat:x}=this.backend.get(e);if(!(e.isRenderTargetTexture||c===void 0))if(this.backend.state.bindTexture(h,c),this.setTextureParameters(h,e),e.isCompressedTexture){const _=e.mipmaps,v=t.image;for(let T=0;T<_.length;T++){const w=_[T];e.isCompressedArrayTexture?e.format!==r.RGBA?f!==null?r.compressedTexSubImage3D(r.TEXTURE_2D_ARRAY,T,0,0,0,w.width,w.height,v.depth,f,w.data):(0,d.ZK6)("WebGLBackend: Attempt to load unsupported compressed texture format in .uploadTexture()"):r.texSubImage3D(r.TEXTURE_2D_ARRAY,T,0,0,0,w.width,w.height,v.depth,f,m,w.data):f!==null?r.compressedTexSubImage2D(r.TEXTURE_2D,T,0,0,w.width,w.height,f,w.data):(0,d.ZK6)("WebGLBackend: Unsupported compressed texture format")}}else if(e.isCubeTexture){const _=t.images,v=e.mipmaps;for(let T=0;T<6;T++){const w=Kx(_[T]);r.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+T,0,0,0,s,a,f,m,w);for(let P=0;P<v.length;P++){const C=v[P],E=Kx(C.images[T]);r.texSubImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+T,P+1,0,0,E.width,E.height,f,m,E)}}}else if(e.isDataArrayTexture||e.isArrayTexture){const _=t.image;if(e.layerUpdates.size>0){const v=(0,d.EcG)(_.width,_.height,e.format,e.type);for(const T of e.layerUpdates){const w=_.data.subarray(T*v/_.data.BYTES_PER_ELEMENT,(T+1)*v/_.data.BYTES_PER_ELEMENT);r.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,T,_.width,_.height,1,f,m,w)}e.clearLayerUpdates()}else r.texSubImage3D(r.TEXTURE_2D_ARRAY,0,0,0,0,_.width,_.height,_.depth,f,m,_.data)}else if(e.isData3DTexture){const _=t.image;r.texSubImage3D(r.TEXTURE_3D,0,0,0,0,_.width,_.height,_.depth,f,m,_.data)}else if(e.isVideoTexture)e.update(),r.texImage2D(h,0,x,f,m,t.image);else{const _=e.mipmaps;if(_.length>0)for(let v=0,T=_.length;v<T;v++){const w=_[v],P=Kx(w);r.texSubImage2D(h,v,0,0,w.width,w.height,f,m,P)}else{const v=Kx(t.image);r.texSubImage2D(h,0,0,0,s,a,f,m,v)}}}generateMipmaps(e){const{gl:t,backend:r}=this,{textureGPU:s,glTextureType:a}=r.get(e);r.state.bindTexture(a,s),t.generateMipmap(a)}deallocateRenderBuffers(e){const{gl:t,backend:r}=this;if(e){const s=r.get(e);if(s.renderBufferStorageSetup=void 0,s.framebuffers){for(const a in s.framebuffers)t.deleteFramebuffer(s.framebuffers[a]);delete s.framebuffers}if(s.depthRenderbuffer&&(t.deleteRenderbuffer(s.depthRenderbuffer),delete s.depthRenderbuffer),s.stencilRenderbuffer&&(t.deleteRenderbuffer(s.stencilRenderbuffer),delete s.stencilRenderbuffer),s.msaaFrameBuffer&&(t.deleteFramebuffer(s.msaaFrameBuffer),delete s.msaaFrameBuffer),s.msaaRenderbuffers){for(let a=0;a<s.msaaRenderbuffers.length;a++)t.deleteRenderbuffer(s.msaaRenderbuffers[a]);delete s.msaaRenderbuffers}}}destroyTexture(e,t=!1){const{gl:r,backend:s}=this,{textureGPU:a,renderTarget:c}=s.get(e);this.deallocateRenderBuffers(c),t===!1&&r.deleteTexture(a),s.delete(e)}copyTextureToTexture(e,t,r=null,s=null,a=0,c=0){const{gl:h,backend:f}=this,{state:m}=this.backend,{textureGPU:x,glTextureType:_,glType:v,glFormat:T}=f.get(t);m.bindTexture(_,x);let w,P,C,E,D,F,W,K,U;const j=e.isCompressedTexture?e.mipmaps[c]:e.image;if(r!==null)w=r.max.x-r.min.x,P=r.max.y-r.min.y,C=r.isBox3?r.max.z-r.min.z:1,E=r.min.x,D=r.min.y,F=r.isBox3?r.min.z:0;else{const He=Math.pow(2,-a);w=Math.floor(j.width*He),P=Math.floor(j.height*He),e.isDataArrayTexture||e.isArrayTexture?C=j.depth:e.isData3DTexture?C=Math.floor(j.depth*He):C=1,E=0,D=0,F=0}s!==null?(W=s.x,K=s.y,U=s.z):(W=0,K=0,U=0),h.pixelStorei(h.UNPACK_FLIP_Y_WEBGL,t.flipY),h.pixelStorei(h.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),h.pixelStorei(h.UNPACK_ALIGNMENT,t.unpackAlignment);const oe=h.getParameter(h.UNPACK_ROW_LENGTH),k=h.getParameter(h.UNPACK_IMAGE_HEIGHT),O=h.getParameter(h.UNPACK_SKIP_PIXELS),le=h.getParameter(h.UNPACK_SKIP_ROWS),be=h.getParameter(h.UNPACK_SKIP_IMAGES);h.pixelStorei(h.UNPACK_ROW_LENGTH,j.width),h.pixelStorei(h.UNPACK_IMAGE_HEIGHT,j.height),h.pixelStorei(h.UNPACK_SKIP_PIXELS,E),h.pixelStorei(h.UNPACK_SKIP_ROWS,D),h.pixelStorei(h.UNPACK_SKIP_IMAGES,F);const Ee=e.isDataArrayTexture||e.isData3DTexture||t.isArrayTexture,Pe=t.isDataArrayTexture||t.isData3DTexture||t.isArrayTexture;if(e.isDepthTexture){const He=f.get(e),Be=f.get(t),ft=f.get(He.renderTarget),$e=f.get(Be.renderTarget),Tt=ft.framebuffers[He.cacheKey],Pt=$e.framebuffers[Be.cacheKey];m.bindFramebuffer(h.READ_FRAMEBUFFER,Tt),m.bindFramebuffer(h.DRAW_FRAMEBUFFER,Pt);for(let Ye=0;Ye<C;Ye++)Ee&&(h.framebufferTextureLayer(h.READ_FRAMEBUFFER,h.COLOR_ATTACHMENT0,He.textureGPU,a,F+Ye),h.framebufferTextureLayer(h.DRAW_FRAMEBUFFER,h.COLOR_ATTACHMENT0,x,c,U+Ye)),h.blitFramebuffer(E,D,w,P,W,K,w,P,h.DEPTH_BUFFER_BIT,h.NEAREST);m.bindFramebuffer(h.READ_FRAMEBUFFER,null),m.bindFramebuffer(h.DRAW_FRAMEBUFFER,null)}else if(a!==0||e.isRenderTargetTexture||f.has(e)){const He=f.get(e);this._srcFramebuffer===null&&(this._srcFramebuffer=h.createFramebuffer()),this._dstFramebuffer===null&&(this._dstFramebuffer=h.createFramebuffer()),m.bindFramebuffer(h.READ_FRAMEBUFFER,this._srcFramebuffer),m.bindFramebuffer(h.DRAW_FRAMEBUFFER,this._dstFramebuffer);for(let Be=0;Be<C;Be++)Ee?h.framebufferTextureLayer(h.READ_FRAMEBUFFER,h.COLOR_ATTACHMENT0,He.textureGPU,a,F+Be):h.framebufferTexture2D(h.READ_FRAMEBUFFER,h.COLOR_ATTACHMENT0,h.TEXTURE_2D,He.textureGPU,a),Pe?h.framebufferTextureLayer(h.DRAW_FRAMEBUFFER,h.COLOR_ATTACHMENT0,x,c,U+Be):h.framebufferTexture2D(h.DRAW_FRAMEBUFFER,h.COLOR_ATTACHMENT0,h.TEXTURE_2D,x,c),a!==0?h.blitFramebuffer(E,D,w,P,W,K,w,P,h.COLOR_BUFFER_BIT,h.NEAREST):Pe?h.copyTexSubImage3D(_,c,W,K,U+Be,E,D,w,P):h.copyTexSubImage2D(_,c,W,K,E,D,w,P);m.bindFramebuffer(h.READ_FRAMEBUFFER,null),m.bindFramebuffer(h.DRAW_FRAMEBUFFER,null)}else Pe?e.isDataTexture||e.isData3DTexture?h.texSubImage3D(_,c,W,K,U,w,P,C,T,v,j.data):t.isCompressedArrayTexture?h.compressedTexSubImage3D(_,c,W,K,U,w,P,C,T,j.data):h.texSubImage3D(_,c,W,K,U,w,P,C,T,v,j):e.isDataTexture?h.texSubImage2D(h.TEXTURE_2D,c,W,K,w,P,T,v,j.data):e.isCompressedTexture?h.compressedTexSubImage2D(h.TEXTURE_2D,c,W,K,j.width,j.height,T,j.data):h.texSubImage2D(h.TEXTURE_2D,c,W,K,w,P,T,v,j);h.pixelStorei(h.UNPACK_ROW_LENGTH,oe),h.pixelStorei(h.UNPACK_IMAGE_HEIGHT,k),h.pixelStorei(h.UNPACK_SKIP_PIXELS,O),h.pixelStorei(h.UNPACK_SKIP_ROWS,le),h.pixelStorei(h.UNPACK_SKIP_IMAGES,be),c===0&&t.generateMipmaps&&h.generateMipmap(_),m.unbindTexture()}copyFramebufferToTexture(e,t,r){const{gl:s}=this,{state:a}=this.backend,{textureGPU:c}=this.backend.get(e),{x:h,y:f,z:m,w:x}=r,_=e.isDepthTexture===!0||t.renderTarget&&t.renderTarget.samples>0,v=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(_){const T=h!==0||f!==0;let w,P;if(e.isDepthTexture===!0?(w=s.DEPTH_BUFFER_BIT,P=s.DEPTH_ATTACHMENT,t.stencil&&(w|=s.STENCIL_BUFFER_BIT)):(w=s.COLOR_BUFFER_BIT,P=s.COLOR_ATTACHMENT0),T){const C=this.backend.get(t.renderTarget),E=C.framebuffers[t.getCacheKey()],D=C.msaaFrameBuffer;a.bindFramebuffer(s.DRAW_FRAMEBUFFER,E),a.bindFramebuffer(s.READ_FRAMEBUFFER,D);const F=v-f-x;s.blitFramebuffer(h,F,h+m,F+x,h,F,h+m,F+x,w,s.NEAREST),a.bindFramebuffer(s.READ_FRAMEBUFFER,E),a.bindTexture(s.TEXTURE_2D,c),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,h,F,m,x),a.unbindTexture()}else{const C=s.createFramebuffer();a.bindFramebuffer(s.DRAW_FRAMEBUFFER,C),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,P,s.TEXTURE_2D,c,0),s.blitFramebuffer(0,0,m,x,0,0,m,x,w,s.NEAREST),s.deleteFramebuffer(C)}}else a.bindTexture(s.TEXTURE_2D,c),s.copyTexSubImage2D(s.TEXTURE_2D,0,0,0,h,v-x-f,m,x),a.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,r,s=!1){const{gl:a}=this,c=t.renderTarget,{depthTexture:h,depthBuffer:f,stencilBuffer:m,width:x,height:_}=c;if(a.bindRenderbuffer(a.RENDERBUFFER,e),f&&!m){let v=a.DEPTH_COMPONENT24;s===!0?this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(a.RENDERBUFFER,c.samples,v,x,_):r>0?(h&&h.isDepthTexture&&h.type===a.FLOAT&&(v=a.DEPTH_COMPONENT32F),a.renderbufferStorageMultisample(a.RENDERBUFFER,r,v,x,_)):a.renderbufferStorage(a.RENDERBUFFER,v,x,_),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.DEPTH_ATTACHMENT,a.RENDERBUFFER,e)}else f&&m&&(r>0?a.renderbufferStorageMultisample(a.RENDERBUFFER,r,a.DEPTH24_STENCIL8,x,_):a.renderbufferStorage(a.RENDERBUFFER,a.DEPTH_STENCIL,x,_),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.DEPTH_STENCIL_ATTACHMENT,a.RENDERBUFFER,e));a.bindRenderbuffer(a.RENDERBUFFER,null)}copyTextureToBuffer(e,t,r,s,a,c){return nn(this,null,function*(){const{backend:h,gl:f}=this,{textureGPU:m,glFormat:x,glType:_}=this.backend.get(e),v=f.createFramebuffer();f.bindFramebuffer(f.READ_FRAMEBUFFER,v);const T=e.isCubeTexture?f.TEXTURE_CUBE_MAP_POSITIVE_X+c:f.TEXTURE_2D;f.framebufferTexture2D(f.READ_FRAMEBUFFER,f.COLOR_ATTACHMENT0,T,m,0);const w=this._getTypedArrayType(_),P=this._getBytesPerTexel(_,x),E=s*a*P,D=f.createBuffer();f.bindBuffer(f.PIXEL_PACK_BUFFER,D),f.bufferData(f.PIXEL_PACK_BUFFER,E,f.STREAM_READ),f.readPixels(t,r,s,a,x,_,0),f.bindBuffer(f.PIXEL_PACK_BUFFER,null),yield h.utils._clientWaitAsync();const F=new w(E/w.BYTES_PER_ELEMENT);return f.bindBuffer(f.PIXEL_PACK_BUFFER,D),f.getBufferSubData(f.PIXEL_PACK_BUFFER,0,F),f.bindBuffer(f.PIXEL_PACK_BUFFER,null),f.deleteFramebuffer(v),F})}_getTypedArrayType(e){const{gl:t}=this;if(e===t.UNSIGNED_BYTE)return Uint8Array;if(e===t.UNSIGNED_SHORT_4_4_4_4||e===t.UNSIGNED_SHORT_5_5_5_1||e===t.UNSIGNED_SHORT_5_6_5||e===t.UNSIGNED_SHORT)return Uint16Array;if(e===t.UNSIGNED_INT)return Uint32Array;if(e===t.HALF_FLOAT)return Uint16Array;if(e===t.FLOAT)return Float32Array;throw new Error(`Unsupported WebGL type: ${e}`)}_getBytesPerTexel(e,t){const{gl:r}=this;let s=0;if(e===r.UNSIGNED_BYTE&&(s=1),(e===r.UNSIGNED_SHORT_4_4_4_4||e===r.UNSIGNED_SHORT_5_5_5_1||e===r.UNSIGNED_SHORT_5_6_5||e===r.UNSIGNED_SHORT||e===r.HALF_FLOAT)&&(s=2),(e===r.UNSIGNED_INT||e===r.FLOAT)&&(s=4),t===r.RGBA)return s*4;if(t===r.RGB)return s*3;if(t===r.ALPHA)return s}dispose(){const{gl:e}=this;this._srcFramebuffer!==null&&e.deleteFramebuffer(this._srcFramebuffer),this._dstFramebuffer!==null&&e.deleteFramebuffer(this._dstFramebuffer)}}function Kx(i){return i.isDataTexture?i.image.data:typeof HTMLImageElement!="undefined"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&i instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&i instanceof ImageBitmap||typeof OffscreenCanvas!="undefined"&&i instanceof OffscreenCanvas?i:i.data}class sU{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 t===void 0&&(t=this.gl.getExtension(e),this.extensions[e]=t),t}has(e){return this.availableExtensions.includes(e)}}class oU{constructor(e){this.backend=e,this.maxAnisotropy=null}getMaxAnisotropy(){if(this.maxAnisotropy!==null)return this.maxAnisotropy;const e=this.backend.gl,t=this.backend.extensions;if(t.has("EXT_texture_filter_anisotropic")===!0){const r=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(r.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}const SA={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",WEBGL_compressed_texture_s3tc:"texture-compression-s3tc",EXT_texture_compression_bptc:"texture-compression-bc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"};class aU{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:r,mode:s,object:a,type:c,info:h,index:f}=this;f!==0?r.drawElements(s,t,c,e):r.drawArrays(s,e,t),h.update(a,t,1)}renderInstances(e,t,r){const{gl:s,mode:a,type:c,index:h,object:f,info:m}=this;r!==0&&(h!==0?s.drawElementsInstanced(a,t,c,e,r):s.drawArraysInstanced(a,e,t,r),m.update(f,t,r))}renderMultiDraw(e,t,r){const{extensions:s,mode:a,object:c,info:h}=this;if(r===0)return;const f=s.get("WEBGL_multi_draw");if(f===null)for(let m=0;m<r;m++)this.render(e[m],t[m]);else{this.index!==0?f.multiDrawElementsWEBGL(a,t,0,this.type,e,0,r):f.multiDrawArraysWEBGL(a,e,0,t,0,r);let m=0;for(let x=0;x<r;x++)m+=t[x];h.update(c,m,1)}}renderMultiDrawInstances(e,t,r,s){const{extensions:a,mode:c,object:h,info:f}=this;if(r===0)return;const m=a.get("WEBGL_multi_draw");if(m===null)for(let x=0;x<r;x++)this.renderInstances(e[x],t[x],s[x]);else{this.index!==0?m.multiDrawElementsInstancedWEBGL(c,t,0,this.type,e,0,s,0,r):m.multiDrawArraysInstancedWEBGL(c,e,0,t,0,s,0,r);let x=0;for(let _=0;_<r;_++)x+=t[_]*s[_];f.update(h,x,1)}}}class TA{constructor(e=256){this.trackTimestamp=!0,this.maxQueries=e,this.currentQueryIndex=0,this.queryOffsets=new Map,this.isDisposed=!1,this.lastValue=0,this.frames=[],this.pendingResolve=!1,this.timestamps=new Map}getTimestampFrames(){return this.frames}getTimestamp(e){let t=this.timestamps.get(e);return t===void 0&&((0,d.ZK6)(`TimestampQueryPool: No timestamp available for uid ${e}.`),t=0),t}hasTimestamp(e){return this.timestamps.has(e)}allocateQueriesForContext(){}resolveQueriesAsync(){return nn(this,null,function*(){})}dispose(){}}class cU extends TA{constructor(e,t,r=2048){if(super(r),this.gl=e,this.type=t,this.ext=e.getExtension("EXT_disjoint_timer_query_webgl2")||e.getExtension("EXT_disjoint_timer_query"),!this.ext){(0,d.ZK6)("EXT_disjoint_timer_query not supported; timestamps will be disabled."),this.trackTimestamp=!1;return}this.queries=[];for(let s=0;s<this.maxQueries;s++)this.queries.push(e.createQuery());this.activeQuery=null,this.queryStates=new Map}allocateQueriesForContext(e){if(!this.trackTimestamp)return null;if(this.currentQueryIndex+2>this.maxQueries)return(0,d.O4K)(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryStates.set(t,"inactive"),this.queryOffsets.set(e,t),t}beginQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e);if(t==null||this.activeQuery!==null)return;const r=this.queries[t];if(r)try{this.queryStates.get(t)==="inactive"&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,r),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(s){s("Error in beginQuery:",s),this.activeQuery=null,this.queryStates.set(t,"inactive")}}endQuery(e){if(!this.trackTimestamp||this.isDisposed)return;const t=this.queryOffsets.get(e);if(t!=null&&this.activeQuery===t)try{this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.queryStates.set(t,"ended"),this.activeQuery=null}catch(r){r("Error in endQuery:",r),this.queryStates.set(t,"inactive"),this.activeQuery=null}}resolveQueriesAsync(){return nn(this,null,function*(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{const e=new Map;for(const[a,c]of this.queryOffsets)if(this.queryStates.get(c)==="ended"){const f=this.queries[c];e.set(a,this.resolveQuery(f))}if(e.size===0)return this.lastValue;const t={},r=[];for(const[a,c]of e){const h=a.match(/^(.*):f(\d+)$/),f=parseInt(h[2]);r.includes(f)===!1&&r.push(f),t[f]===void 0&&(t[f]=0);const m=yield c;this.timestamps.set(a,m),t[f]+=m}const s=t[r[r.length-1]];return this.lastValue=s,this.frames=r,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,s}catch(e){return e("Error resolving queries:",e),this.lastValue}finally{this.pendingResolve=!1}})}resolveQuery(e){return nn(this,null,function*(){return new Promise(t=>{if(this.isDisposed){t(this.lastValue);return}let r,s=!1;const a=()=>{r&&(clearTimeout(r),r=null)},c=f=>{s||(s=!0,a(),t(f))},h=()=>{if(this.isDisposed){c(this.lastValue);return}try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT)){c(this.lastValue);return}if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE)){r=setTimeout(h,1);return}const x=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(x)/1e6)}catch(f){f("Error checking query:",f),t(this.lastValue)}};h()})})}dispose(){if(!this.isDisposed&&(this.isDisposed=!0,!!this.trackTimestamp)){for(const e of this.queries)this.gl.deleteQuery(e);this.queries=[],this.queryStates.clear(),this.queryOffsets.clear(),this.lastValue=0,this.activeQuery=null}}}class MA extends yA{constructor(e={}){super(e),this.isWebGLBackend=!0,this.attributeUtils=null,this.extensions=null,this.capabilities=null,this.textureUtils=null,this.bufferRenderer=null,this.gl=null,this.state=null,this.utils=null,this.vaoCache={},this.transformFeedbackCache={},this.discard=!1,this.disjoint=null,this.parallel=null,this._currentContext=null,this._knownBindings=new WeakSet,this._supportsInvalidateFramebuffer=typeof navigator=="undefined"?!1:/OculusBrowser/g.test(navigator.userAgent),this._xrFramebuffer=null}init(e){super.init(e);const t=this.parameters,r={antialias:e.currentSamples>0,alpha:!0,depth:e.depth,stencil:e.stencil},s=t.context!==void 0?t.context:e.domElement.getContext("webgl2",r);function a(c){c.preventDefault();const h={api:"WebGL",message:c.statusMessage||"Unknown reason",reason:null,originalEvent:c};e.onDeviceLost(h)}this._onContextLost=a,e.domElement.addEventListener("webglcontextlost",a,!1),this.gl=s,this.extensions=new sU(this),this.capabilities=new oU(this),this.attributeUtils=new tU(this),this.textureUtils=new rU(this),this.bufferRenderer=new aU(this),this.state=new nU(this),this.utils=new iU(this),this.extensions.get("EXT_color_buffer_float"),this.extensions.get("WEBGL_clip_cull_distance"),this.extensions.get("OES_texture_float_linear"),this.extensions.get("EXT_color_buffer_half_float"),this.extensions.get("WEBGL_multisampled_render_to_texture"),this.extensions.get("WEBGL_render_shared_exponent"),this.extensions.get("WEBGL_multi_draw"),this.extensions.get("OVR_multiview2"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile")}get coordinateSystem(){return d._RZ}getArrayBufferAsync(e){return nn(this,null,function*(){return yield this.attributeUtils.getArrayBufferAsync(e)})}makeXRCompatible(){return nn(this,null,function*(){this.gl.getContextAttributes().xrCompatible!==!0&&(yield this.gl.makeXRCompatible())})}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,r=null){const s=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:s.RGBA8}),r!==null){const a=e.stencilBuffer?s.DEPTH24_STENCIL8:s.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:r,glInternalFormat:a}),this.extensions.has("WEBGL_multisampled_render_to_texture")===!0&&e._autoAllocateDepthBuffer===!0&&e.multiview===!1&&(0,d.ZK6)("WebGLBackend: Render-to-texture extension was disabled because an external texture was provided"),e._autoAllocateDepthBuffer=!1}}initTimestampQuery(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new cU(this.gl,e,2048));const r=this.timestampQueryPool[e];r.allocateQueriesForContext(t)!==null&&r.beginQuery(t)}prepareTimestampBuffer(e,t){if(!this.disjoint||!this.trackTimestamp)return;this.timestampQueryPool[e].endQuery(t)}getContext(){return this.gl}beginRender(e){const{state:t}=this,r=this.get(e);if(e.viewport)this.updateViewport(e);else{const{width:a,height:c}=this.getDrawingBufferSize();t.viewport(0,0,a,c)}if(e.scissor){const{x:a,y:c,width:h,height:f}=e.scissorValue;t.scissor(a,e.height-f-c,h,f)}this.initTimestampQuery(d.eS_.RENDER,this.getTimestampUID(e)),r.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);const s=e.occlusionQueryCount;s>0&&(r.currentOcclusionQueries=r.occlusionQueries,r.currentOcclusionQueryObjects=r.occlusionQueryObjects,r.lastOcclusionObject=null,r.occlusionQueries=new Array(s),r.occlusionQueryObjects=new Array(s),r.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:r}=this,s=this.get(e),a=s.previousContext;r.resetVertexState();const c=e.occlusionQueryCount;c>0&&(c>s.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const h=e.textures;if(h!==null)for(let f=0;f<h.length;f++){const m=h[f];m.generateMipmaps&&this.generateMipmaps(m)}if(this._currentContext=a,this._resolveRenderTarget(e),a!==null)if(this._setFramebuffer(a),a.viewport)this.updateViewport(a);else{const{width:f,height:m}=this.getDrawingBufferSize();r.viewport(0,0,f,m)}this.prepareTimestampBuffer(d.eS_.RENDER,this.getTimestampUID(e))}resolveOccludedAsync(e){const t=this.get(e),{currentOcclusionQueries:r,currentOcclusionQueryObjects:s}=t;if(r&&s){const a=new WeakSet,{gl:c}=this;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueries=null;const h=()=>{let f=0;for(let m=0;m<r.length;m++){const x=r[m];x!==null&&c.getQueryParameter(x,c.QUERY_RESULT_AVAILABLE)&&(c.getQueryParameter(x,c.QUERY_RESULT)===0&&a.add(s[m]),r[m]=null,c.deleteQuery(x),f++)}f<r.length?requestAnimationFrame(h):t.occluded=a};h()}}isOccluded(e,t){const r=this.get(e);return r.occluded&&r.occluded.has(t)}updateViewport(e){const{state:t}=this,{x:r,y:s,width:a,height:c}=e.viewportValue;t.viewport(r,e.height-c-s,a,c)}setScissorTest(e){this.state.setScissorTest(e)}getClearColor(){const e=super.getClearColor();return e.r*=e.a,e.g*=e.a,e.b*=e.a,e}clear(e,t,r,s=null,a=!0,c=!0){const{gl:h,renderer:f}=this;s===null&&(s={textures:null,clearColorValue:this.getClearColor()});let m=0;if(e&&(m|=h.COLOR_BUFFER_BIT),t&&(m|=h.DEPTH_BUFFER_BIT),r&&(m|=h.STENCIL_BUFFER_BIT),m!==0){let x;s.clearColorValue?x=s.clearColorValue:x=this.getClearColor();const _=f.getClearDepth(),v=f.getClearStencil();if(t&&this.state.setDepthMask(!0),s.textures===null)h.clearColor(x.r,x.g,x.b,x.a),h.clear(m);else{if(a&&this._setFramebuffer(s),e)for(let T=0;T<s.textures.length;T++)T===0?h.clearBufferfv(h.COLOR,T,[x.r,x.g,x.b,x.a]):h.clearBufferfv(h.COLOR,T,[0,0,0,1]);t&&r?h.clearBufferfi(h.DEPTH_STENCIL,0,_,v):t?h.clearBufferfv(h.DEPTH,0,[_]):r&&h.clearBufferiv(h.STENCIL,0,[v]),a&&c&&this._resolveRenderTarget(s)}}}beginCompute(e){const{state:t,gl:r}=this;t.bindFramebuffer(r.FRAMEBUFFER,null),this.initTimestampQuery(d.eS_.COMPUTE,this.getTimestampUID(e))}compute(e,t,r,s,a=null){const{state:c,gl:h}=this;this.discard===!1&&(h.enable(h.RASTERIZER_DISCARD),this.discard=!0);const{programGPU:f,transformBuffers:m,attributes:x}=this.get(s),_=this._getVaoKey(x),v=this.vaoCache[_];v===void 0?this.vaoCache[_]=this._createVao(x):c.setVertexState(v),c.useProgram(f),this._bindUniforms(r);const T=this._getTransformFeedback(m);h.bindTransformFeedback(h.TRANSFORM_FEEDBACK,T),h.beginTransformFeedback(h.POINTS),a=a!==null?a:t.count,Array.isArray(a)?((0,d.O4K)("WebGLBackend.compute(): The count parameter must be a single number, not an array."),a=a[0]):a&&typeof a=="object"&&a.isIndirectStorageBufferAttribute&&((0,d.O4K)("WebGLBackend.compute(): The count parameter must be a single number, not IndirectStorageBufferAttribute"),a=t.count),x[0].isStorageInstancedBufferAttribute?h.drawArraysInstanced(h.POINTS,0,1,a):h.drawArrays(h.POINTS,0,a),h.endTransformFeedback(),h.bindTransformFeedback(h.TRANSFORM_FEEDBACK,null);for(let w=0;w<m.length;w++){const P=m[w];P.pbo&&this.has(P.pbo)&&this.textureUtils.copyBufferToTexture(P.transformBuffer,P.pbo),P.switchBuffers()}}finishCompute(e){const t=this.gl;this.discard=!1,t.disable(t.RASTERIZER_DISCARD),this.prepareTimestampBuffer(d.eS_.COMPUTE,this.getTimestampUID(e)),this._currentContext&&this._setFramebuffer(this._currentContext)}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.isArrayTexture&&e.camera.isArrayCamera}draw(e){const{object:t,pipeline:r,material:s,context:a,hardwareClippingPlanes:c}=e,{programGPU:h}=this.get(r),{gl:f,state:m}=this,x=this.get(a),_=e.getDrawParameters();if(_===null)return;this._bindUniforms(e.getBindings());const v=t.isMesh&&t.matrixWorld.determinant()<0;m.setMaterial(s,v,c),m.useProgram(h);const T=e.getAttributes(),w=this.get(T);let P=w.vaoGPU;if(P===void 0){const oe=this._getVaoKey(T);P=this.vaoCache[oe],P===void 0&&(P=this._createVao(T),this.vaoCache[oe]=P,w.vaoGPU=P)}const C=e.getIndex(),E=C!==null?this.get(C).bufferGPU:null;m.setVertexState(P,E);const D=x.lastOcclusionObject;if(D!==t&&D!==void 0){if(D!==null&&D.occlusionTest===!0&&(f.endQuery(f.ANY_SAMPLES_PASSED),x.occlusionQueryIndex++),t.occlusionTest===!0){const oe=f.createQuery();f.beginQuery(f.ANY_SAMPLES_PASSED,oe),x.occlusionQueries[x.occlusionQueryIndex]=oe,x.occlusionQueryObjects[x.occlusionQueryIndex]=t}x.lastOcclusionObject=t}const F=this.bufferRenderer;t.isPoints?F.mode=f.POINTS:t.isLineSegments?F.mode=f.LINES:t.isLine?F.mode=f.LINE_STRIP:t.isLineLoop?F.mode=f.LINE_LOOP:s.wireframe===!0?(m.setLineWidth(s.wireframeLinewidth*this.renderer.getPixelRatio()),F.mode=f.LINES):F.mode=f.TRIANGLES;const{vertexCount:W,instanceCount:K}=_;let{firstVertex:U}=_;if(F.object=t,C!==null){U*=C.array.BYTES_PER_ELEMENT;const oe=this.get(C);F.index=C.count,F.type=oe.type}else F.index=0;const j=()=>{t.isBatchedMesh?t._multiDrawInstances!==null?((0,d.O4K)("WebGLBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),F.renderMultiDrawInstances(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount,t._multiDrawInstances)):this.hasFeature("WEBGL_multi_draw")?F.renderMultiDraw(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount):(0,d.O4K)("WebGLBackend: WEBGL_multi_draw not supported."):K>1?F.renderInstances(U,W,K):F.render(U,W)};if(e.camera.isArrayCamera===!0&&e.camera.cameras.length>0&&e.camera.isMultiViewCamera===!1){const oe=this.get(e.camera),k=e.camera.cameras,O=e.getBindingGroup("cameraIndex").bindings[0];if(oe.indexesGPU===void 0||oe.indexesGPU.length!==k.length){const Be=new Uint32Array([0,0,0,0]),ft=[];for(let $e=0,Tt=k.length;$e<Tt;$e++){const Pt=f.createBuffer();Be[0]=$e,f.bindBuffer(f.UNIFORM_BUFFER,Pt),f.bufferData(f.UNIFORM_BUFFER,Be,f.STATIC_DRAW),ft.push(Pt)}oe.indexesGPU=ft}const le=this.get(O),be=this.renderer.getPixelRatio(),Ee=this._currentContext.renderTarget,Pe=this._isRenderCameraDepthArray(this._currentContext),He=this._currentContext.activeCubeFace;if(Pe){const Be=this.get(Ee.depthTexture);if(Be.clearedRenderId!==this.renderer._nodes.nodeFrame.renderId){Be.clearedRenderId=this.renderer._nodes.nodeFrame.renderId;const{stencilBuffer:ft}=Ee;for(let $e=0,Tt=k.length;$e<Tt;$e++)this.renderer._activeCubeFace=$e,this._currentContext.activeCubeFace=$e,this._setFramebuffer(this._currentContext),this.clear(!1,!0,ft,this._currentContext,!1,!1);this.renderer._activeCubeFace=He,this._currentContext.activeCubeFace=He}}for(let Be=0,ft=k.length;Be<ft;Be++){const $e=k[Be];if(t.layers.test($e.layers)){Pe&&(this.renderer._activeCubeFace=Be,this._currentContext.activeCubeFace=Be,this._setFramebuffer(this._currentContext));const Tt=$e.viewport;if(Tt!==void 0){const Pt=Tt.x*be,Ye=Tt.y*be,yt=Tt.width*be,Ot=Tt.height*be;m.viewport(Math.floor(Pt),Math.floor(e.context.height-Ot-Ye),Math.floor(yt),Math.floor(Ot))}m.bindBufferBase(f.UNIFORM_BUFFER,le.index,oe.indexesGPU[Be]),j()}this._currentContext.activeCubeFace=He,this.renderer._activeCubeFace=He}}else j()}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,t=!1){this.textureUtils.destroyTexture(e,t)}copyTextureToBuffer(e,t,r,s,a,c){return nn(this,null,function*(){return this.textureUtils.copyTextureToBuffer(e,t,r,s,a,c)})}updateSampler(){return""}createNodeBuilder(e,t){return new QD(e,t)}createProgram(e){const t=this.gl,{stage:r,code:s}=e,a=r==="fragment"?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);t.shaderSource(a,s),t.compileShader(a),this.set(e,{shaderGPU:a})}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){const r=this.gl,s=e.pipeline,{fragmentProgram:a,vertexProgram:c}=s,h=r.createProgram(),f=this.get(a).shaderGPU,m=this.get(c).shaderGPU;if(r.attachShader(h,f),r.attachShader(h,m),r.linkProgram(h),this.set(s,{programGPU:h,fragmentShader:f,vertexShader:m}),t!==null&&this.parallel){const x=new Promise(_=>{const v=this.parallel,T=()=>{r.getProgramParameter(h,v.COMPLETION_STATUS_KHR)?(this._completeCompile(e,s),_()):requestAnimationFrame(T)};T()});t.push(x);return}this._completeCompile(e,s)}_handleSource(e,t){const r=e.split(`
`),s=[],a=Math.max(t-6,0),c=Math.min(t+6,r.length);for(let h=a;h<c;h++){const f=h+1;s.push(`${f===t?">":" "} ${f}: ${r[h]}`)}return s.join(`
`)}_getShaderErrors(e,t,r){const s=e.getShaderParameter(t,e.COMPILE_STATUS),c=(e.getShaderInfoLog(t)||"").trim();if(s&&c==="")return"";const h=/ERROR: 0:(\d+)/.exec(c);if(h){const f=parseInt(h[1]);return r.toUpperCase()+`
`+c+`
`+this._handleSource(e.getShaderSource(t),f)}else return c}_logProgramError(e,t,r){if(this.renderer.debug.checkShaderErrors){const s=this.gl,c=(s.getProgramInfoLog(e)||"").trim();if(s.getProgramParameter(e,s.LINK_STATUS)===!1)if(typeof this.renderer.debug.onShaderError=="function")this.renderer.debug.onShaderError(s,e,r,t);else{const h=this._getShaderErrors(s,r,"vertex"),f=this._getShaderErrors(s,t,"fragment");(0,d.vUy)("THREE.WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(e,s.VALIDATE_STATUS)+`
Program Info Log: `+c+`
`+h+`
`+f)}else c!==""&&(0,d.ZK6)("WebGLProgram: Program Info Log:",c)}}_completeCompile(e,t){const{state:r,gl:s}=this,a=this.get(t),{programGPU:c,fragmentShader:h,vertexShader:f}=a;s.getProgramParameter(c,s.LINK_STATUS)===!1&&this._logProgramError(c,h,f),r.useProgram(c);const m=e.getBindings();this._setupBindings(m,c),this.set(t,{programGPU:c})}createComputePipeline(e,t){const{state:r,gl:s}=this,a={stage:"fragment",code:`#version 300 es
precision highp float;
void main() {}`};this.createProgram(a);const{computeProgram:c}=e,h=s.createProgram(),f=this.get(a).shaderGPU,m=this.get(c).shaderGPU,x=c.transforms,_=[],v=[];for(let C=0;C<x.length;C++){const E=x[C];_.push(E.varyingName),v.push(E.attributeNode)}s.attachShader(h,f),s.attachShader(h,m),s.transformFeedbackVaryings(h,_,s.SEPARATE_ATTRIBS),s.linkProgram(h),s.getProgramParameter(h,s.LINK_STATUS)===!1&&this._logProgramError(h,f,m),r.useProgram(h),this._setupBindings(t,h);const T=c.attributes,w=[],P=[];for(let C=0;C<T.length;C++){const E=T[C].node.attribute;w.push(E),this.has(E)||this.attributeUtils.createAttribute(E,s.ARRAY_BUFFER)}for(let C=0;C<v.length;C++){const E=v[C].attribute;this.has(E)||this.attributeUtils.createAttribute(E,s.ARRAY_BUFFER);const D=this.get(E);P.push(D)}this.set(e,{programGPU:h,transformBuffers:P,attributes:w})}createBindings(e,t){if(this._knownBindings.has(t)===!1){this._knownBindings.add(t);let r=0,s=0;for(const a of t){this.set(a,{textures:s,uniformBuffers:r});for(const c of a.bindings)c.isUniformBuffer&&r++,c.isSampledTexture&&s++}}this.updateBindings(e,t)}updateBindings(e){const{gl:t}=this,r=this.get(e);let s=r.uniformBuffers,a=r.textures;for(const c of e.bindings){const h=this.get(c);if(c.isUniformsGroup||c.isUniformBuffer){const f=c.buffer;let{bufferGPU:m}=this.get(f);m===void 0?(m=t.createBuffer(),t.bindBuffer(t.UNIFORM_BUFFER,m),t.bufferData(t.UNIFORM_BUFFER,f,t.DYNAMIC_DRAW),this.set(f,{bufferGPU:m})):(t.bindBuffer(t.UNIFORM_BUFFER,m),t.bufferSubData(t.UNIFORM_BUFFER,0,f)),h.index=s++,h.bufferGPU=m,this.set(c,h)}else if(c.isSampledTexture){const{textureGPU:f,glTextureType:m}=this.get(c.texture);h.index=a++,h.textureGPU=f,h.glTextureType=m,this.set(c,h)}}}updateBinding(e){const t=this.gl;if(e.isUniformsGroup||e.isUniformBuffer){const s=this.get(e).bufferGPU,a=e.buffer;t.bindBuffer(t.UNIFORM_BUFFER,s),t.bufferData(t.UNIFORM_BUFFER,a,t.DYNAMIC_DRAW)}}createIndexAttribute(e){const t=this.gl;this.attributeUtils.createAttribute(e,t.ELEMENT_ARRAY_BUFFER)}createAttribute(e){if(this.has(e))return;const t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}createStorageAttribute(e){if(this.has(e))return;const t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}hasFeature(e){const t=Object.keys(SA).filter(s=>SA[s]===e),r=this.extensions;for(let s=0;s<t.length;s++)if(r.has(t[s]))return!0;return!1}getMaxAnisotropy(){return this.capabilities.getMaxAnisotropy()}copyTextureToTexture(e,t,r=null,s=null,a=0,c=0){this.textureUtils.copyTextureToTexture(e,t,r,s,a,c)}copyFramebufferToTexture(e,t,r){this.textureUtils.copyFramebufferToTexture(e,t,r)}_setFramebuffer(e){const{gl:t,state:r}=this;let s=null;if(e.textures!==null){const a=e.renderTarget,c=this.get(a),{samples:h,depthBuffer:f,stencilBuffer:m}=a,x=a.isWebGLCubeRenderTarget===!0,_=a.isRenderTarget3D===!0,v=a.depth>1,T=a.isXRRenderTarget===!0,w=T===!0&&a._hasExternalTextures===!0;let P=c.msaaFrameBuffer,C=c.depthRenderbuffer;const E=this.extensions.get("WEBGL_multisampled_render_to_texture"),D=this.extensions.get("OVR_multiview2"),F=this._useMultisampledExtension(a),W=WM(e);let K;if(x?(c.cubeFramebuffers||(c.cubeFramebuffers={}),K=c.cubeFramebuffers[W]):T&&w===!1?K=this._xrFramebuffer:(c.framebuffers||(c.framebuffers={}),K=c.framebuffers[W]),K===void 0){K=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,K);const U=e.textures,j=[];if(x){c.cubeFramebuffers[W]=K;const{textureGPU:k}=this.get(U[0]),O=this.renderer._activeCubeFace,le=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+O,k,le)}else{c.framebuffers[W]=K;for(let k=0;k<U.length;k++){const O=U[k],le=this.get(O);le.renderTarget=e.renderTarget,le.cacheKey=W;const be=t.COLOR_ATTACHMENT0+k;if(a.multiview)D.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,be,le.textureGPU,0,h,0,2);else if(_||v){const Ee=this.renderer._activeCubeFace,Pe=this.renderer._activeMipmapLevel;t.framebufferTextureLayer(t.FRAMEBUFFER,be,le.textureGPU,Pe,Ee)}else if(F)E.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,be,t.TEXTURE_2D,le.textureGPU,0,h);else{const Ee=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,be,t.TEXTURE_2D,le.textureGPU,Ee)}}}const oe=m?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(a._autoAllocateDepthBuffer===!0){const k=t.createRenderbuffer();this.textureUtils.setupRenderBufferStorage(k,e,0,F),c.xrDepthRenderbuffer=k,j.push(m?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT),t.bindRenderbuffer(t.RENDERBUFFER,k),t.framebufferRenderbuffer(t.FRAMEBUFFER,oe,t.RENDERBUFFER,k)}else if(e.depthTexture!==null){j.push(m?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT);const k=this.get(e.depthTexture);if(k.renderTarget=e.renderTarget,k.cacheKey=W,a.multiview)D.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,oe,k.textureGPU,0,h,0,2);else if(w&&F)E.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,oe,t.TEXTURE_2D,k.textureGPU,0,h);else if(e.depthTexture.isArrayTexture){const O=this.renderer._activeCubeFace;t.framebufferTextureLayer(t.FRAMEBUFFER,oe,k.textureGPU,0,O)}else t.framebufferTexture2D(t.FRAMEBUFFER,oe,t.TEXTURE_2D,k.textureGPU,0)}c.depthInvalidationArray=j}else{if(this._isRenderCameraDepthArray(e)){r.bindFramebuffer(t.FRAMEBUFFER,K);const j=this.renderer._activeCubeFace,oe=this.get(e.depthTexture),k=m?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.framebufferTextureLayer(t.FRAMEBUFFER,k,oe.textureGPU,0,j)}if((T||F||a.multiview)&&a._isOpaqueFramebuffer!==!0){r.bindFramebuffer(t.FRAMEBUFFER,K);const j=this.get(e.textures[0]);a.multiview?D.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,j.textureGPU,0,h,0,2):F?E.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,j.textureGPU,0,h):t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,j.textureGPU,0);const oe=m?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(a._autoAllocateDepthBuffer===!0){const k=c.xrDepthRenderbuffer;t.bindRenderbuffer(t.RENDERBUFFER,k),t.framebufferRenderbuffer(t.FRAMEBUFFER,oe,t.RENDERBUFFER,k)}else{const k=this.get(e.depthTexture);a.multiview?D.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,oe,k.textureGPU,0,h,0,2):F?E.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,oe,t.TEXTURE_2D,k.textureGPU,0,h):t.framebufferTexture2D(t.FRAMEBUFFER,oe,t.TEXTURE_2D,k.textureGPU,0)}}}if(h>0&&F===!1&&!a.multiview){if(P===void 0){const U=[];P=t.createFramebuffer(),r.bindFramebuffer(t.FRAMEBUFFER,P);const j=[],oe=e.textures;for(let k=0;k<oe.length;k++){j[k]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,j[k]),U.push(t.COLOR_ATTACHMENT0+k);const O=e.textures[k],le=this.get(O);t.renderbufferStorageMultisample(t.RENDERBUFFER,h,le.glInternalFormat,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+k,t.RENDERBUFFER,j[k])}if(t.bindRenderbuffer(t.RENDERBUFFER,null),c.msaaFrameBuffer=P,c.msaaRenderbuffers=j,f&&C===void 0){C=t.createRenderbuffer(),this.textureUtils.setupRenderBufferStorage(C,e,h),c.depthRenderbuffer=C;const k=m?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;U.push(k)}c.invalidationArray=U}s=c.msaaFrameBuffer}else s=K;r.drawBuffers(e,K)}r.bindFramebuffer(t.FRAMEBUFFER,s)}_getVaoKey(e){let t="";for(let r=0;r<e.length;r++){const s=this.get(e[r]);t+=":"+s.id}return t}_createVao(e){const{gl:t}=this,r=t.createVertexArray();t.bindVertexArray(r);for(let s=0;s<e.length;s++){const a=e[s],c=this.get(a);t.bindBuffer(t.ARRAY_BUFFER,c.bufferGPU),t.enableVertexAttribArray(s);let h,f;a.isInterleavedBufferAttribute===!0?(h=a.data.stride*c.bytesPerElement,f=a.offset*c.bytesPerElement):(h=0,f=0),c.isInteger?t.vertexAttribIPointer(s,a.itemSize,c.type,h,f):t.vertexAttribPointer(s,a.itemSize,c.type,a.normalized,h,f),a.isInstancedBufferAttribute&&!a.isInterleavedBufferAttribute?t.vertexAttribDivisor(s,a.meshPerAttribute):a.isInterleavedBufferAttribute&&a.data.isInstancedInterleavedBuffer&&t.vertexAttribDivisor(s,a.data.meshPerAttribute)}return t.bindBuffer(t.ARRAY_BUFFER,null),r}_getTransformFeedback(e){let t="";for(let a=0;a<e.length;a++)t+=":"+e[a].id;let r=this.transformFeedbackCache[t];if(r!==void 0)return r;const{gl:s}=this;r=s.createTransformFeedback(),s.bindTransformFeedback(s.TRANSFORM_FEEDBACK,r);for(let a=0;a<e.length;a++){const c=e[a];s.bindBufferBase(s.TRANSFORM_FEEDBACK_BUFFER,a,c.transformBuffer)}return s.bindTransformFeedback(s.TRANSFORM_FEEDBACK,null),this.transformFeedbackCache[t]=r,r}_setupBindings(e,t){const r=this.gl;for(const s of e)for(const a of s.bindings){const h=this.get(a).index;if(a.isUniformsGroup||a.isUniformBuffer){const f=r.getUniformBlockIndex(t,a.name);r.uniformBlockBinding(t,f,h)}else if(a.isSampledTexture){const f=r.getUniformLocation(t,a.name);r.uniform1i(f,h)}}}_bindUniforms(e){const{gl:t,state:r}=this;for(const s of e)for(const a of s.bindings){const c=this.get(a),h=c.index;a.isUniformsGroup||a.isUniformBuffer?r.bindBufferBase(t.UNIFORM_BUFFER,h,c.bufferGPU):a.isSampledTexture&&r.bindTexture(c.glTextureType,c.textureGPU,t.TEXTURE0+h)}}_resolveRenderTarget(e){const{gl:t,state:r}=this,s=e.renderTarget;if(e.textures!==null&&s){const a=this.get(s);if(s.samples>0&&this._useMultisampledExtension(s)===!1){const c=a.framebuffers[e.getCacheKey()];let h=t.COLOR_BUFFER_BIT;s.resolveDepthBuffer&&(s.depthBuffer&&(h|=t.DEPTH_BUFFER_BIT),s.stencilBuffer&&s.resolveStencilBuffer&&(h|=t.STENCIL_BUFFER_BIT));const f=a.msaaFrameBuffer,m=a.msaaRenderbuffers,x=e.textures,_=x.length>1;if(r.bindFramebuffer(t.READ_FRAMEBUFFER,f),r.bindFramebuffer(t.DRAW_FRAMEBUFFER,c),_)for(let v=0;v<x.length;v++)t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+v,t.RENDERBUFFER,null),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+v,t.TEXTURE_2D,null,0);for(let v=0;v<x.length;v++){if(_){const{textureGPU:T}=this.get(x[v]);t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,m[v]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,T,0)}if(e.scissor){const{x:T,y:w,width:P,height:C}=e.scissorValue,E=e.height-C-w;t.blitFramebuffer(T,E,T+P,E+C,T,E,T+P,E+C,h,t.NEAREST)}else t.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,h,t.NEAREST)}if(_)for(let v=0;v<x.length;v++){const{textureGPU:T}=this.get(x[v]);t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+v,t.RENDERBUFFER,m[v]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+v,t.TEXTURE_2D,T,0)}this._supportsInvalidateFramebuffer===!0&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,a.invalidationArray)}else if(s.resolveDepthBuffer===!1&&a.framebuffers){const c=a.framebuffers[e.getCacheKey()];r.bindFramebuffer(t.DRAW_FRAMEBUFFER,c),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,a.depthInvalidationArray)}}}_useMultisampledExtension(e){return e.multiview===!0?!0:e.samples>0&&this.extensions.has("WEBGL_multisampled_render_to_texture")===!0&&e._autoAllocateDepthBuffer!==!1}dispose(){this.textureUtils!==null&&this.textureUtils.dispose();const e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}const Gd={PointList:"point-list",LineList:"line-list",LineStrip:"line-strip",TriangleList:"triangle-list",TriangleStrip:"triangle-strip"},Wr={Never:"never",Less:"less",Equal:"equal",LessEqual:"less-equal",Greater:"greater",NotEqual:"not-equal",GreaterEqual:"greater-equal",Always:"always"},ds={Store:"store"},di={Load:"load",Clear:"clear"},wA={CCW:"ccw",CW:"cw"},AA={None:"none",Back:"back"},Wd={Uint16:"uint16",Uint32:"uint32"},pe={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:"rg11b10ufloat",RG32Uint:"rg32uint",RG32Sint:"rg32sint",RG32Float:"rg32float",RGBA16Uint:"rgba16uint",RGBA16Sint:"rgba16sint",RGBA16Float:"rgba16float",RGBA32Uint:"rgba32uint",RGBA32Sint:"rgba32sint",RGBA32Float:"rgba32float",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-unorm-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"},dS={ClampToEdge:"clamp-to-edge",Repeat:"repeat",MirrorRepeat:"mirror-repeat"},zu={Linear:"linear",Nearest:"nearest"},Zn={Zero:"zero",One:"one",Src:"src",OneMinusSrc:"one-minus-src",SrcAlpha:"src-alpha",OneMinusSrcAlpha:"one-minus-src-alpha",Dst:"dst",OneMinusDst:"one-minus-dst",DstAlpha:"dst-alpha",OneMinusDstAlpha:"one-minus-dst-alpha",SrcAlphaSaturated:"src-alpha-saturated",Constant:"constant",OneMinusConstant:"one-minus-constant"},Gu={Add:"add",Subtract:"subtract",ReverseSubtract:"reverse-subtract",Min:"min",Max:"max"},EA={None:0,All:15},Tl={Keep:"keep",Zero:"zero",Replace:"replace",Invert:"invert",IncrementClamp:"increment-clamp",DecrementClamp:"decrement-clamp",IncrementWrap:"increment-wrap",DecrementWrap:"decrement-wrap"},fS={Storage:"storage",ReadOnlyStorage:"read-only-storage"},pS={WriteOnly:"write-only",ReadOnly:"read-only",ReadWrite:"read-write"},CA={NonFiltering:"non-filtering",Comparison:"comparison"},Wu={Float:"float",UnfilterableFloat:"unfilterable-float",Depth:"depth",SInt:"sint",UInt:"uint"},RA={TwoD:"2d",ThreeD:"3d"},fr={TwoD:"2d",TwoDArray:"2d-array",Cube:"cube",ThreeD:"3d"},lU={All:"all"},Zx={Vertex:"vertex",Instance:"instance"},mS={CoreFeaturesAndLimits:"core-features-and-limits",DepthClipControl:"depth-clip-control",Depth32FloatStencil8:"depth32float-stencil8",TextureCompressionBC:"texture-compression-bc",TextureCompressionBCSliced3D:"texture-compression-bc-sliced-3d",TextureCompressionETC2:"texture-compression-etc2",TextureCompressionASTC:"texture-compression-astc",TextureCompressionASTCSliced3D:"texture-compression-astc-sliced-3d",TimestampQuery:"timestamp-query",IndirectFirstInstance:"indirect-first-instance",ShaderF16:"shader-f16",RG11B10UFloat:"rg11b10ufloat-renderable",BGRA8UNormStorage:"bgra8unorm-storage",Float32Filterable:"float32-filterable",Float32Blendable:"float32-blendable",ClipDistances:"clip-distances",DualSourceBlending:"dual-source-blending",Subgroups:"subgroups",TextureFormatsTier1:"texture-formats-tier1",TextureFormatsTier2:"texture-formats-tier2"},NA={"texture-compression-s3tc":"texture-compression-bc","texture-compression-etc1":"texture-compression-etc2"};class uU extends dA{constructor(e,t,r){super(e,t?t.value:null),this.textureNode=t,this.groupNode=r}update(){const{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update()}}class hU extends cA{constructor(e,t){super(e,t?t.array:null),this.attribute=t,this.isStorageBuffer=!0}}let dU=0;class fU extends hU{constructor(e,t){super("StorageBuffer_"+dU++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:yr.READ_WRITE,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class pU extends yl{constructor(e){super(),this.device=e;const t=`
struct VarysStruct {
@builtin( position ) Position: vec4<f32>,
@location( 0 ) vTex : vec2<f32>
};
@vertex
fn main( @builtin( vertex_index ) vertexIndex : u32 ) -> VarysStruct {
var Varys : VarysStruct;
var pos = array< vec2<f32>, 4 >(
vec2<f32>( -1.0, 1.0 ),
vec2<f32>( 1.0, 1.0 ),
vec2<f32>( -1.0, -1.0 ),
vec2<f32>( 1.0, -1.0 )
);
var tex = array< vec2<f32>, 4 >(
vec2<f32>( 0.0, 0.0 ),
vec2<f32>( 1.0, 0.0 ),
vec2<f32>( 0.0, 1.0 ),
vec2<f32>( 1.0, 1.0 )
);
Varys.vTex = tex[ vertexIndex ];
Varys.Position = vec4<f32>( pos[ vertexIndex ], 0.0, 1.0 );
return Varys;
}
`,r=`
@group( 0 ) @binding( 0 )
var imgSampler : sampler;
@group( 0 ) @binding( 1 )
var img : texture_2d<f32>;
@fragment
fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
return textureSample( img, imgSampler, vTex );
}
`,s=`
@group( 0 ) @binding( 0 )
var imgSampler : sampler;
@group( 0 ) @binding( 1 )
var img : texture_2d<f32>;
@fragment
fn main( @location( 0 ) vTex : vec2<f32> ) -> @location( 0 ) vec4<f32> {
return textureSample( img, imgSampler, vec2( vTex.x, 1.0 - vTex.y ) );
}
`;this.mipmapSampler=e.createSampler({minFilter:zu.Linear}),this.flipYSampler=e.createSampler({minFilter:zu.Nearest}),this.transferPipelines={},this.flipYPipelines={},this.mipmapVertexShaderModule=e.createShaderModule({label:"mipmapVertex",code:t}),this.mipmapFragmentShaderModule=e.createShaderModule({label:"mipmapFragment",code:r}),this.flipYFragmentShaderModule=e.createShaderModule({label:"flipYFragment",code:s})}getTransferPipeline(e){let t=this.transferPipelines[e];return t===void 0&&(t=this.device.createRenderPipeline({label:`mipmap-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.mipmapFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:Gd.TriangleStrip,stripIndexFormat:Wd.Uint32},layout:"auto"}),this.transferPipelines[e]=t),t}getFlipYPipeline(e){let t=this.flipYPipelines[e];return t===void 0&&(t=this.device.createRenderPipeline({label:`flipY-${e}`,vertex:{module:this.mipmapVertexShaderModule,entryPoint:"main"},fragment:{module:this.flipYFragmentShaderModule,entryPoint:"main",targets:[{format:e}]},primitive:{topology:Gd.TriangleStrip,stripIndexFormat:Wd.Uint32},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,r=0){const s=t.format,{width:a,height:c}=t.size,h=this.getTransferPipeline(s),f=this.getFlipYPipeline(s),m=this.device.createTexture({size:{width:a,height:c,depthOrArrayLayers:1},format:s,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),x=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:fr.TwoD,baseArrayLayer:r}),_=m.createView({baseMipLevel:0,mipLevelCount:1,dimension:fr.TwoD,baseArrayLayer:0}),v=this.device.createCommandEncoder({}),T=(w,P,C)=>{const E=w.getBindGroupLayout(0),D=this.device.createBindGroup({layout:E,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:P}]}),F=v.beginRenderPass({colorAttachments:[{view:C,loadOp:di.Clear,storeOp:ds.Store,clearValue:[0,0,0,0]}]});F.setPipeline(w),F.setBindGroup(0,D),F.draw(4,1,0,0),F.end()};T(h,x,_),T(f,_,x),this.device.queue.submit([v.finish()]),m.destroy()}generateMipmaps(e,t,r=0,s=null){const a=this.get(e);a.layers===void 0&&(a.layers=[]);const c=a.layers[r]||this._mipmapCreateBundles(e,t,r),h=s||this.device.createCommandEncoder({label:"mipmapEncoder"});this._mipmapRunBundles(h,c),s===null&&this.device.queue.submit([h.finish()]),a.layers[r]=c}_mipmapCreateBundles(e,t,r){const s=this.getTransferPipeline(t.format),a=s.getBindGroupLayout(0);let c=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:fr.TwoD,baseArrayLayer:r});const h=[];for(let f=1;f<t.mipLevelCount;f++){const m=this.device.createBindGroup({layout:a,entries:[{binding:0,resource:this.mipmapSampler},{binding:1,resource:c}]}),x=e.createView({baseMipLevel:f,mipLevelCount:1,dimension:fr.TwoD,baseArrayLayer:r}),_={colorAttachments:[{view:x,loadOp:di.Clear,storeOp:ds.Store,clearValue:[0,0,0,0]}]},v=this.device.createRenderBundleEncoder({colorFormats:[t.format]});v.setPipeline(s),v.setBindGroup(0,m),v.draw(4,1,0,0),h.push({renderBundles:[v.finish()],passDescriptor:_}),c=x}return h}_mipmapRunBundles(e,t){const r=t.length;for(let s=0;s<r;s++){const a=t[s],c=e.beginRenderPass(a.passDescriptor);c.executeBundles(a.renderBundles),c.end()}}}const mU={[d.xoQ]:"never",[d.D67]:"less",[d.F1y]:"equal",[d.M$G]:"less-equal",[d.Zen]:"greater",[d.Jjb]:"greater-equal",[d.T6w]:"always",[d.O78]:"not-equal"},gU=[0,1,3,2,4,5];class xU{constructor(e){this.backend=e,this._passUtils=null,this.defaultTexture={},this.defaultCubeTexture={},this.defaultVideoFrame=null,this._samplerCache=new Map}updateSampler(e){const t=this.backend,r=e.minFilter+"-"+e.magFilter+"-"+e.wrapS+"-"+e.wrapT+"-"+(e.wrapR||"0")+"-"+e.anisotropy+"-"+(e.compareFunction||0);let s=this._samplerCache.get(r);if(s===void 0){const c={addressModeU:this._convertAddressMode(e.wrapS),addressModeV:this._convertAddressMode(e.wrapT),addressModeW:this._convertAddressMode(e.wrapR),magFilter:this._convertFilterMode(e.magFilter),minFilter:this._convertFilterMode(e.minFilter),mipmapFilter:this._convertFilterMode(e.minFilter),maxAnisotropy:1};c.magFilter===zu.Linear&&c.minFilter===zu.Linear&&c.mipmapFilter===zu.Linear&&(c.maxAnisotropy=e.anisotropy),e.isDepthTexture&&e.compareFunction!==null&&(c.compare=mU[e.compareFunction]),s={sampler:t.device.createSampler(c),usedTimes:0},this._samplerCache.set(r,s)}const a=t.get(e);if(a.sampler!==s.sampler){if(a.sampler!==void 0){const c=this._samplerCache.get(a.samplerKey);c.usedTimes--,c.usedTimes===0&&this._samplerCache.delete(a.samplerKey)}a.samplerKey=r,a.sampler=s.sampler,s.usedTimes++}return r}createDefaultTexture(e){let t;const r=gS(e);e.isCubeTexture?t=this._getDefaultCubeTextureGPU(r):t=this._getDefaultTextureGPU(r),this.backend.get(e).texture=t}createTexture(e,t={}){const r=this.backend,s=r.get(e);if(s.initialized)throw new Error("WebGPUTextureUtils: Texture already initialized.");if(e.isExternalTexture){s.texture=e.sourceTexture,s.initialized=!0;return}t.needsMipmaps===void 0&&(t.needsMipmaps=!1),t.levels===void 0&&(t.levels=1),t.depth===void 0&&(t.depth=1);const{width:a,height:c,depth:h,levels:f}=t;e.isFramebufferTexture&&(t.renderTarget?t.format=this.backend.utils.getCurrentColorFormat(t.renderTarget):t.format=this.backend.utils.getPreferredCanvasFormat());const m=this._getDimension(e),x=e.internalFormat||t.format||gS(e,r.device);s.format=x;const{samples:_,primarySamples:v,isMSAA:T}=r.utils.getTextureSampleData(e);let w=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC;e.isStorageTexture===!0&&(w|=GPUTextureUsage.STORAGE_BINDING),e.isCompressedTexture!==!0&&e.isCompressedArrayTexture!==!0&&x!==pe.RGB9E5UFloat&&(w|=GPUTextureUsage.RENDER_ATTACHMENT);const P={label:e.name,size:{width:a,height:c,depthOrArrayLayers:h},mipLevelCount:f,sampleCount:v,dimension:m,format:x,usage:w};if(x===void 0){(0,d.ZK6)("WebGPURenderer: Texture format not supported."),this.createDefaultTexture(e);return}if(e.isCubeTexture&&(P.textureBindingViewDimension=fr.Cube),s.texture=r.device.createTexture(P),T){const C=Object.assign({},P);C.label=C.label+"-msaa",C.sampleCount=_,C.mipLevelCount=1,s.msaaTexture=r.device.createTexture(C)}s.initialized=!0,s.textureDescriptorGPU=P}destroyTexture(e,t=!1){const r=this.backend,s=r.get(e);s.texture!==void 0&&t===!1&&s.texture.destroy(),s.msaaTexture!==void 0&&s.msaaTexture.destroy(),r.delete(e)}generateMipmaps(e,t=null){const r=this.backend.get(e);if(e.isCubeTexture)for(let s=0;s<6;s++)this._generateMipmaps(r.texture,r.textureDescriptorGPU,s,t);else{const s=e.image.depth||1;for(let a=0;a<s;a++)this._generateMipmaps(r.texture,r.textureDescriptorGPU,a,t)}}getColorBuffer(){const e=this.backend,t=e.renderer.getCanvasTarget(),{width:r,height:s}=e.getDrawingBufferSize(),a=e.renderer.currentSamples,c=t.colorTexture,h=e.get(c);if(c.width===r&&c.height===s&&c.samples===a)return h.texture;let f=h.texture;return f&&f.destroy(),f=e.device.createTexture({label:"colorBuffer",size:{width:r,height:s,depthOrArrayLayers:1},sampleCount:e.utils.getSampleCount(e.renderer.currentSamples),format:e.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC}),c.source.width=r,c.source.height=s,c.samples=a,h.texture=f,f}getDepthBuffer(e=!0,t=!1){const r=this.backend,s=r.renderer.getCanvasTarget(),{width:a,height:c}=r.getDrawingBufferSize(),h=r.renderer.currentSamples,f=s.depthTexture;if(f.width===a&&f.height===c&&f.samples===h&&f.depth===e&&f.stencil===t)return r.get(f).texture;const m=r.get(f).texture;let x,_;if(t?(x=d.brP,_=d.wJv):e&&(x=d.qkB,_=d.JQ4),m!==void 0){if(f.image.width===a&&f.image.height===c&&f.format===x&&f.type===_&&f.samples===h)return m;this.destroyTexture(f)}return f.name="depthBuffer",f.format=x,f.type=_,f.image.width=a,f.image.height=c,f.samples=h,this.createTexture(f,{width:a,height:c}),r.get(f).texture}updateTexture(e,t){const r=this.backend.get(e),s=e.mipmaps,{textureDescriptorGPU:a}=r;if(!(e.isRenderTargetTexture||a===void 0)){if(e.isDataTexture)if(s.length>0)for(let c=0,h=s.length;c<h;c++){const f=s[c];this._copyBufferToTexture(f,r.texture,a,0,e.flipY,0,c)}else this._copyBufferToTexture(t.image,r.texture,a,0,e.flipY);else if(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)for(let c=0;c<t.image.depth;c++)this._copyBufferToTexture(t.image,r.texture,a,c,e.flipY,c);else if(e.isCompressedTexture||e.isCompressedArrayTexture)this._copyCompressedBufferToTexture(e.mipmaps,r.texture,a);else if(e.isCubeTexture)this._copyCubeMapToTexture(e,r.texture,a);else if(s.length>0)for(let c=0,h=s.length;c<h;c++){const f=s[c];this._copyImageToTexture(f,r.texture,a,0,e.flipY,e.premultiplyAlpha,c)}else this._copyImageToTexture(t.image,r.texture,a,0,e.flipY,e.premultiplyAlpha);r.version=e.version}}copyTextureToBuffer(e,t,r,s,a,c){return nn(this,null,function*(){const h=this.backend.device,f=this.backend.get(e),m=f.texture,x=f.textureDescriptorGPU.format,_=this._getBytesPerTexel(x);let v=s*_;v=Math.ceil(v/256)*256;const T=h.createBuffer({size:(a-1)*v+s*_,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),w=h.createCommandEncoder();w.copyTextureToBuffer({texture:m,origin:{x:t,y:r,z:c}},{buffer:T,bytesPerRow:v},{width:s,height:a});const P=this._getTypedArrayType(x);h.queue.submit([w.finish()]),yield T.mapAsync(GPUMapMode.READ);const C=T.getMappedRange();return new P(C)})}dispose(){this._samplerCache.clear()}_getDefaultTextureGPU(e){let t=this.defaultTexture[e];if(t===void 0){const r=new d.xEZ;r.minFilter=d.TyD,r.magFilter=d.TyD,this.createTexture(r,{width:1,height:1,format:e}),this.defaultTexture[e]=t=r}return this.backend.get(t).texture}_getDefaultCubeTextureGPU(e){let t=this.defaultTexture[e];if(t===void 0){const r=new d.BtG;r.minFilter=d.TyD,r.magFilter=d.TyD,this.createTexture(r,{width:1,height:1,depth:6}),this.defaultCubeTexture[e]=t=r}return this.backend.get(t).texture}_copyCubeMapToTexture(e,t,r){const s=e.images,a=e.mipmaps;for(let c=0;c<6;c++){const h=s[c],f=e.flipY===!0?gU[c]:c;h.isDataTexture?this._copyBufferToTexture(h.image,t,r,f,e.flipY):this._copyImageToTexture(h,t,r,f,e.flipY,e.premultiplyAlpha);for(let m=0;m<a.length;m++){const _=a[m].images[c];_.isDataTexture?this._copyBufferToTexture(_.image,t,r,f,e.flipY,0,m+1):this._copyImageToTexture(_,t,r,f,e.flipY,e.premultiplyAlpha,m+1)}}}_copyImageToTexture(e,t,r,s,a,c,h=0){const f=this.backend.device,m=h>0?e.width:r.size.width,x=h>0?e.height:r.size.height;f.queue.copyExternalImageToTexture({source:e,flipY:a},{texture:t,mipLevel:h,origin:{x:0,y:0,z:s},premultipliedAlpha:c},{width:m,height:x,depthOrArrayLayers:1})}_getPassUtils(){let e=this._passUtils;return e===null&&(this._passUtils=e=new pU(this.backend.device)),e}_generateMipmaps(e,t,r=0,s=null){this._getPassUtils().generateMipmaps(e,t,r,s)}_flipY(e,t,r=0){this._getPassUtils().flipY(e,t,r)}_copyBufferToTexture(e,t,r,s,a,c=0,h=0){const f=this.backend.device,m=e.data,x=this._getBytesPerTexel(r.format),_=e.width*x;f.queue.writeTexture({texture:t,mipLevel:h,origin:{x:0,y:0,z:s}},m,{offset:e.width*e.height*x*c,bytesPerRow:_},{width:e.width,height:e.height,depthOrArrayLayers:1}),a===!0&&this._flipY(t,r,s)}_copyCompressedBufferToTexture(e,t,r){const s=this.backend.device,a=this._getBlockData(r.format),c=r.size.depthOrArrayLayers>1;for(let h=0;h<e.length;h++){const f=e[h],m=f.width,x=f.height,_=c?r.size.depthOrArrayLayers:1,v=Math.ceil(m/a.width)*a.byteLength,T=v*Math.ceil(x/a.height);for(let w=0;w<_;w++)s.queue.writeTexture({texture:t,mipLevel:h,origin:{x:0,y:0,z:w}},f.data,{offset:w*T,bytesPerRow:v,rowsPerImage:Math.ceil(x/a.height)},{width:Math.ceil(m/a.width)*a.width,height:Math.ceil(x/a.height)*a.height,depthOrArrayLayers:1})}}_getBlockData(e){if(e===pe.BC1RGBAUnorm||e===pe.BC1RGBAUnormSRGB)return{byteLength:8,width:4,height:4};if(e===pe.BC2RGBAUnorm||e===pe.BC2RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===pe.BC3RGBAUnorm||e===pe.BC3RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===pe.BC4RUnorm||e===pe.BC4RSnorm)return{byteLength:8,width:4,height:4};if(e===pe.BC5RGUnorm||e===pe.BC5RGSnorm)return{byteLength:16,width:4,height:4};if(e===pe.BC6HRGBUFloat||e===pe.BC6HRGBFloat)return{byteLength:16,width:4,height:4};if(e===pe.BC7RGBAUnorm||e===pe.BC7RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===pe.ETC2RGB8Unorm||e===pe.ETC2RGB8UnormSRGB)return{byteLength:8,width:4,height:4};if(e===pe.ETC2RGB8A1Unorm||e===pe.ETC2RGB8A1UnormSRGB)return{byteLength:8,width:4,height:4};if(e===pe.ETC2RGBA8Unorm||e===pe.ETC2RGBA8UnormSRGB)return{byteLength:16,width:4,height:4};if(e===pe.EACR11Unorm)return{byteLength:8,width:4,height:4};if(e===pe.EACR11Snorm)return{byteLength:8,width:4,height:4};if(e===pe.EACRG11Unorm)return{byteLength:16,width:4,height:4};if(e===pe.EACRG11Snorm)return{byteLength:16,width:4,height:4};if(e===pe.ASTC4x4Unorm||e===pe.ASTC4x4UnormSRGB)return{byteLength:16,width:4,height:4};if(e===pe.ASTC5x4Unorm||e===pe.ASTC5x4UnormSRGB)return{byteLength:16,width:5,height:4};if(e===pe.ASTC5x5Unorm||e===pe.ASTC5x5UnormSRGB)return{byteLength:16,width:5,height:5};if(e===pe.ASTC6x5Unorm||e===pe.ASTC6x5UnormSRGB)return{byteLength:16,width:6,height:5};if(e===pe.ASTC6x6Unorm||e===pe.ASTC6x6UnormSRGB)return{byteLength:16,width:6,height:6};if(e===pe.ASTC8x5Unorm||e===pe.ASTC8x5UnormSRGB)return{byteLength:16,width:8,height:5};if(e===pe.ASTC8x6Unorm||e===pe.ASTC8x6UnormSRGB)return{byteLength:16,width:8,height:6};if(e===pe.ASTC8x8Unorm||e===pe.ASTC8x8UnormSRGB)return{byteLength:16,width:8,height:8};if(e===pe.ASTC10x5Unorm||e===pe.ASTC10x5UnormSRGB)return{byteLength:16,width:10,height:5};if(e===pe.ASTC10x6Unorm||e===pe.ASTC10x6UnormSRGB)return{byteLength:16,width:10,height:6};if(e===pe.ASTC10x8Unorm||e===pe.ASTC10x8UnormSRGB)return{byteLength:16,width:10,height:8};if(e===pe.ASTC10x10Unorm||e===pe.ASTC10x10UnormSRGB)return{byteLength:16,width:10,height:10};if(e===pe.ASTC12x10Unorm||e===pe.ASTC12x10UnormSRGB)return{byteLength:16,width:12,height:10};if(e===pe.ASTC12x12Unorm||e===pe.ASTC12x12UnormSRGB)return{byteLength:16,width:12,height:12}}_convertAddressMode(e){let t=dS.ClampToEdge;return e===d.rpg?t=dS.Repeat:e===d.OoA&&(t=dS.MirrorRepeat),t}_convertFilterMode(e){let t=zu.Linear;return(e===d.TyD||e===d.YLQ||e===d.aH4)&&(t=zu.Nearest),t}_getBytesPerTexel(e){if(e===pe.R8Unorm||e===pe.R8Snorm||e===pe.R8Uint||e===pe.R8Sint)return 1;if(e===pe.R16Uint||e===pe.R16Sint||e===pe.R16Float||e===pe.RG8Unorm||e===pe.RG8Snorm||e===pe.RG8Uint||e===pe.RG8Sint)return 2;if(e===pe.R32Uint||e===pe.R32Sint||e===pe.R32Float||e===pe.RG16Uint||e===pe.RG16Sint||e===pe.RG16Float||e===pe.RGBA8Unorm||e===pe.RGBA8UnormSRGB||e===pe.RGBA8Snorm||e===pe.RGBA8Uint||e===pe.RGBA8Sint||e===pe.BGRA8Unorm||e===pe.BGRA8UnormSRGB||e===pe.RGB9E5UFloat||e===pe.RGB10A2Unorm||e===pe.RG11B10UFloat||e===pe.Depth32Float||e===pe.Depth24Plus||e===pe.Depth24PlusStencil8||e===pe.Depth32FloatStencil8)return 4;if(e===pe.RG32Uint||e===pe.RG32Sint||e===pe.RG32Float||e===pe.RGBA16Uint||e===pe.RGBA16Sint||e===pe.RGBA16Float)return 8;if(e===pe.RGBA32Uint||e===pe.RGBA32Sint||e===pe.RGBA32Float)return 16}_getTypedArrayType(e){if(e===pe.R8Uint)return Uint8Array;if(e===pe.R8Sint)return Int8Array;if(e===pe.R8Unorm)return Uint8Array;if(e===pe.R8Snorm)return Int8Array;if(e===pe.RG8Uint)return Uint8Array;if(e===pe.RG8Sint)return Int8Array;if(e===pe.RG8Unorm)return Uint8Array;if(e===pe.RG8Snorm)return Int8Array;if(e===pe.RGBA8Uint)return Uint8Array;if(e===pe.RGBA8Sint)return Int8Array;if(e===pe.RGBA8Unorm||e===pe.RGBA8UnormSRGB)return Uint8Array;if(e===pe.RGBA8Snorm)return Int8Array;if(e===pe.R16Uint)return Uint16Array;if(e===pe.R16Sint)return Int16Array;if(e===pe.RG16Uint)return Uint16Array;if(e===pe.RG16Sint)return Int16Array;if(e===pe.RGBA16Uint)return Uint16Array;if(e===pe.RGBA16Sint)return Int16Array;if(e===pe.R16Float||e===pe.RG16Float||e===pe.RGBA16Float)return Uint16Array;if(e===pe.R32Uint)return Uint32Array;if(e===pe.R32Sint)return Int32Array;if(e===pe.R32Float)return Float32Array;if(e===pe.RG32Uint)return Uint32Array;if(e===pe.RG32Sint)return Int32Array;if(e===pe.RG32Float)return Float32Array;if(e===pe.RGBA32Uint)return Uint32Array;if(e===pe.RGBA32Sint)return Int32Array;if(e===pe.RGBA32Float)return Float32Array;if(e===pe.BGRA8Unorm||e===pe.BGRA8UnormSRGB)return Uint8Array;if(e===pe.RGB10A2Unorm||e===pe.RGB9E5UFloat||e===pe.RG11B10UFloat)return Uint32Array;if(e===pe.Depth32Float)return Float32Array;if(e===pe.Depth24Plus||e===pe.Depth24PlusStencil8)return Uint32Array;if(e===pe.Depth32FloatStencil8)return Float32Array}_getDimension(e){let t;return e.is3DTexture||e.isData3DTexture?t=RA.ThreeD:t=RA.TwoD,t}}function gS(i,e=null){const t=i.format,r=i.type,s=i.colorSpace,a=d.epp.getTransfer(s);let c;if(i.isCompressedTexture===!0||i.isCompressedArrayTexture===!0)switch(t){case d.wuA:case d.BFQ:c=a===d.j17?pe.BC1RGBAUnormSRGB:pe.BC1RGBAUnorm;break;case d.v3W:c=a===d.j17?pe.BC2RGBAUnormSRGB:pe.BC2RGBAUnorm;break;case d.ILR:c=a===d.j17?pe.BC3RGBAUnormSRGB:pe.BC3RGBAUnorm;break;case d.HdW:c=pe.BC4RUnorm;break;case d.vuL:c=pe.BC4RSnorm;break;case d.ZTh:c=pe.BC5RGUnorm;break;case d.lGU:c=pe.BC5RGSnorm;break;case d.bsb:c=a===d.j17?pe.BC7RGBAUnormSRGB:pe.BC7RGBAUnorm;break;case d.l0P:case d.fto:c=a===d.j17?pe.ETC2RGB8UnormSRGB:pe.ETC2RGB8Unorm;break;case d.ekQ:c=a===d.j17?pe.ETC2RGBA8UnormSRGB:pe.ETC2RGBA8Unorm;break;case d.ptH:c=a===d.j17?pe.ASTC4x4UnormSRGB:pe.ASTC4x4Unorm;break;case d.jZA:c=a===d.j17?pe.ASTC5x4UnormSRGB:pe.ASTC5x4Unorm;break;case d.y2t:c=a===d.j17?pe.ASTC5x5UnormSRGB:pe.ASTC5x5Unorm;break;case d.gi4:c=a===d.j17?pe.ASTC6x5UnormSRGB:pe.ASTC6x5Unorm;break;case d.Djp:c=a===d.j17?pe.ASTC6x6UnormSRGB:pe.ASTC6x6Unorm;break;case d.BG$:c=a===d.j17?pe.ASTC8x5UnormSRGB:pe.ASTC8x5Unorm;break;case d.NYV:c=a===d.j17?pe.ASTC8x6UnormSRGB:pe.ASTC8x6Unorm;break;case d.xJs:c=a===d.j17?pe.ASTC8x8UnormSRGB:pe.ASTC8x8Unorm;break;case d.pKu:c=a===d.j17?pe.ASTC10x5UnormSRGB:pe.ASTC10x5Unorm;break;case d.GG6:c=a===d.j17?pe.ASTC10x6UnormSRGB:pe.ASTC10x6Unorm;break;case d.Gih:c=a===d.j17?pe.ASTC10x8UnormSRGB:pe.ASTC10x8Unorm;break;case d.FUD:c=a===d.j17?pe.ASTC10x10UnormSRGB:pe.ASTC10x10Unorm;break;case d.iiP:c=a===d.j17?pe.ASTC12x10UnormSRGB:pe.ASTC12x10Unorm;break;case d.SvJ:c=a===d.j17?pe.ASTC12x12UnormSRGB:pe.ASTC12x12Unorm;break;case d.wk1:c=a===d.j17?pe.RGBA8UnormSRGB:pe.RGBA8Unorm;break;default:(0,d.vUy)("WebGPURenderer: Unsupported texture format.",t)}else switch(t){case d.wk1:switch(r){case d.T95:c=pe.RGBA8Snorm;break;case d.iAb:c=pe.RGBA16Sint;break;case d.LsT:c=pe.RGBA16Uint;break;case d.JQ4:c=pe.RGBA32Uint;break;case d.Kz5:c=pe.RGBA32Sint;break;case d.ywz:c=a===d.j17?pe.RGBA8UnormSRGB:pe.RGBA8Unorm;break;case d.cLu:c=pe.RGBA16Float;break;case d.VzW:c=pe.RGBA32Float;break;default:(0,d.vUy)("WebGPURenderer: Unsupported texture type with RGBAFormat.",r)}break;case d.UCm:switch(r){case d.tQZ:c=pe.RGB9E5UFloat;break;case d.dVD:c=pe.RG11B10UFloat;break;default:(0,d.vUy)("WebGPURenderer: Unsupported texture type with RGBFormat.",r)}break;case d.hEm:switch(r){case d.T95:c=pe.R8Snorm;break;case d.iAb:c=pe.R16Sint;break;case d.LsT:c=pe.R16Uint;break;case d.JQ4:c=pe.R32Uint;break;case d.Kz5:c=pe.R32Sint;break;case d.ywz:c=pe.R8Unorm;break;case d.cLu:c=pe.R16Float;break;case d.VzW:c=pe.R32Float;break;default:(0,d.vUy)("WebGPURenderer: Unsupported texture type with RedFormat.",r)}break;case d.av9:switch(r){case d.T95:c=pe.RG8Snorm;break;case d.iAb:c=pe.RG16Sint;break;case d.LsT:c=pe.RG16Uint;break;case d.JQ4:c=pe.RG32Uint;break;case d.Kz5:c=pe.RG32Sint;break;case d.ywz:c=pe.RG8Unorm;break;case d.cLu:c=pe.RG16Float;break;case d.VzW:c=pe.RG32Float;break;default:(0,d.vUy)("WebGPURenderer: Unsupported texture type with RGFormat.",r)}break;case d.qkB:switch(r){case d.LsT:c=pe.Depth16Unorm;break;case d.JQ4:c=pe.Depth24Plus;break;case d.VzW:c=pe.Depth32Float;break;default:(0,d.vUy)("WebGPURenderer: Unsupported texture type with DepthFormat.",r)}break;case d.brP:switch(r){case d.wJv:c=pe.Depth24PlusStencil8;break;case d.VzW:e&&e.features.has(mS.Depth32FloatStencil8)===!1&&(0,d.vUy)('WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.'),c=pe.Depth32FloatStencil8;break;default:(0,d.vUy)("WebGPURenderer: Unsupported texture type with DepthStencilFormat.",r)}break;case d.D9w:switch(r){case d.Kz5:c=pe.R32Sint;break;case d.JQ4:c=pe.R32Uint;break;default:(0,d.vUy)("WebGPURenderer: Unsupported texture type with RedIntegerFormat.",r)}break;case d.CtA:switch(r){case d.Kz5:c=pe.RG32Sint;break;case d.JQ4:c=pe.RG32Uint;break;default:(0,d.vUy)("WebGPURenderer: Unsupported texture type with RGIntegerFormat.",r)}break;case d.E2K:switch(r){case d.Kz5:c=pe.RGBA32Sint;break;case d.JQ4:c=pe.RGBA32Uint;break;default:(0,d.vUy)("WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.",r)}break;default:(0,d.vUy)("WebGPURenderer: Unsupported texture format.",t)}return c}const _U=/^[fn]*\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)\s*[\-\>]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,yU=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/ig,PA={f32:"float",i32:"int",u32:"uint",bool:"bool","vec2<f32>":"vec2","vec2<i32>":"ivec2","vec2<u32>":"uvec2","vec2<bool>":"bvec2",vec2f:"vec2",vec2i:"ivec2",vec2u:"uvec2",vec2b:"bvec2","vec3<f32>":"vec3","vec3<i32>":"ivec3","vec3<u32>":"uvec3","vec3<bool>":"bvec3",vec3f:"vec3",vec3i:"ivec3",vec3u:"uvec3",vec3b:"bvec3","vec4<f32>":"vec4","vec4<i32>":"ivec4","vec4<u32>":"uvec4","vec4<bool>":"bvec4",vec4f:"vec4",vec4i:"ivec4",vec4u:"uvec4",vec4b:"bvec4","mat2x2<f32>":"mat2",mat2x2f:"mat2","mat3x3<f32>":"mat3",mat3x3f:"mat3","mat4x4<f32>":"mat4",mat4x4f:"mat4",sampler:"sampler",texture_1d:"texture",texture_2d:"texture",texture_2d_array:"texture",texture_multisampled_2d:"cubeTexture",texture_depth_2d:"depthTexture",texture_depth_2d_array:"depthTexture",texture_depth_multisampled_2d:"depthTexture",texture_depth_cube:"depthTexture",texture_depth_cube_array:"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"},bU=i=>{i=i.trim();const e=i.match(_U);if(e!==null&&e.length===4){const t=e[2],r=[];let s=null;for(;(s=yU.exec(t))!==null;)r.push({name:s[1],type:s[2]});const a=[];for(let x=0;x<r.length;x++){const{name:_,type:v}=r[x];let T=v;T.startsWith("ptr")?T="pointer":(T.startsWith("texture")&&(T=v.split("<")[0]),T=PA[T]),a.push(new eS(T,_))}const c=i.substring(e[0].length),h=e[3]||"void",f=e[1]!==void 0?e[1]:"";return{type:PA[h]||h,inputs:a,name:f,inputsCode:t,blockCode:c,outputType:h}}else throw new Error("FunctionNode: Function is not a WGSL code.")};class vU extends iS{constructor(e){const{type:t,inputs:r,name:s,inputsCode:a,blockCode:c,outputType:h}=bU(e);super(t,r,s),this.inputsCode=a,this.blockCode=c,this.outputType=h}getCode(e=this.name){const t=this.outputType!=="void"?"-> "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class SU extends Jw{parseFunction(e){return new vU(e)}}const Hd=typeof self!="undefined"?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},TU={[yr.READ_ONLY]:"read",[yr.WRITE_ONLY]:"write",[yr.READ_WRITE]:"read_write"},LA={[d.rpg]:"repeat",[d.uWy]:"clamp",[d.OoA]:"mirror"},Yx={vertex:Hd?Hd.VERTEX:1,fragment:Hd?Hd.FRAGMENT:2,compute:Hd?Hd.COMPUTE:4},IA={instance:!0,swizzleAssign:!1,storageBuffer:!0},MU={"^^":"tsl_xor"},wU={float:"f32",int:"i32",uint:"u32",bool:"bool",color:"vec3<f32>",vec2:"vec2<f32>",ivec2:"vec2<i32>",uvec2:"vec2<u32>",bvec2:"vec2<bool>",vec3:"vec3<f32>",ivec3:"vec3<i32>",uvec3:"vec3<u32>",bvec3:"vec3<bool>",vec4:"vec4<f32>",ivec4:"vec4<i32>",uvec4:"vec4<u32>",bvec4:"vec4<bool>",mat2:"mat2x2<f32>",mat3:"mat3x3<f32>",mat4:"mat4x4<f32>"},DA={},Em={tsl_xor:new Cr("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new Cr("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new Cr("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new Cr("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new Cr("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new Cr("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new Cr("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new Cr("fn tsl_equals_bvec3( a : vec3f, b : vec3f ) -> vec3<bool> { return vec3<bool>( a.x == b.x, a.y == b.y, a.z == b.z ); }"),equals_bvec4:new Cr("fn tsl_equals_bvec4( a : vec4f, b : vec4f ) -> vec4<bool> { return vec4<bool>( a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w ); }"),repeatWrapping_float:new Cr("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new Cr("fn tsl_mirrorWrapping_float( coord: f32 ) -> f32 { let mirrored = fract( coord * 0.5 ) * 2.0; return 1.0 - abs( 1.0 - mirrored ); }"),clampWrapping_float:new Cr("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new Cr(`
fn tsl_biquadraticTexture( map : texture_2d<f32>, coord : vec2f, iRes : vec2u, level : u32 ) -> vec4f {
let res = vec2f( iRes );
let uvScaled = coord * res;
let uvWrapping = ( ( uvScaled % res ) + res ) % res;
// https://www.shadertoy.com/view/WtyXRy
let uv = uvWrapping - 0.5;
let iuv = floor( uv );
let f = fract( uv );
let rg1 = textureLoad( map, vec2u( iuv + vec2( 0.5, 0.5 ) ) % iRes, level );
let rg2 = textureLoad( map, vec2u( iuv + vec2( 1.5, 0.5 ) ) % iRes, level );
let rg3 = textureLoad( map, vec2u( iuv + vec2( 0.5, 1.5 ) ) % iRes, level );
let rg4 = textureLoad( map, vec2u( iuv + vec2( 1.5, 1.5 ) ) % iRes, level );
return mix( mix( rg1, rg2, f.x ), mix( rg3, rg4, f.x ), f.y );
}
`)},AU={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<f32>"};let UA="";(typeof navigator!="undefined"&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(UA+=`diagnostic( off, derivative_uniformity );
`);class EU extends Yw{constructor(e,t){super(e,t,new SU),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}_generateTextureSample(e,t,r,s,a,c=this.shaderStage){return c==="fragment"?s?a?`textureSample( ${t}, ${t}_sampler, ${r}, ${s}, ${a} )`:`textureSample( ${t}, ${t}_sampler, ${r}, ${s} )`:a?`textureSample( ${t}, ${t}_sampler, ${r}, ${a} )`:`textureSample( ${t}, ${t}_sampler, ${r} )`:this.generateTextureSampleLevel(e,t,r,"0",s)}generateTextureSampleLevel(e,t,r,s,a,c){return this.isUnfilterable(e)===!1?c?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s}, ${c} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,c,s):this.generateTextureLod(e,t,r,a,c,s)}generateWrapFunction(e){const t=`tsl_coord_${LA[e.wrapS]}S_${LA[e.wrapT]}_${e.isData3DTexture?"3d":"2d"}T`;let r=DA[t];if(r===void 0){const s=[],a=e.isData3DTexture?"vec3f":"vec2f";let c=`fn ${t}( coord : ${a} ) -> ${a} {
return ${a}(
`;const h=(f,m)=>{f===d.rpg?(s.push(Em.repeatWrapping_float),c+=` tsl_repeatWrapping_float( coord.${m} )`):f===d.uWy?(s.push(Em.clampWrapping_float),c+=` tsl_clampWrapping_float( coord.${m} )`):f===d.OoA?(s.push(Em.mirrorWrapping_float),c+=` tsl_mirrorWrapping_float( coord.${m} )`):(c+=` coord.${m}`,(0,d.ZK6)(`WebGPURenderer: Unsupported texture wrap type "${f}" for vertex shader.`))};h(e.wrapS,"x"),c+=`,
`,h(e.wrapT,"y"),e.isData3DTexture&&(c+=`,
`,h(e.wrapR,"z")),c+=`
);
}
`,DA[t]=r=new Cr(c,s)}return r.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,r){const s=this.getDataFromNode(e,this.shaderStage,this.globalCache);s.dimensionsSnippet===void 0&&(s.dimensionsSnippet={});let a=s.dimensionsSnippet[r];if(s.dimensionsSnippet[r]===void 0){let c,h;const{primarySamples:f}=this.renderer.backend.utils.getTextureSampleData(e),m=f>1;e.isData3DTexture?h="vec3<u32>":h="vec2<u32>",m||e.isStorageTexture?c=t:c=`${t}${r?`, u32( ${r} )`:""}`,a=new B(new gi(`textureDimensions( ${c} )`,h)),s.dimensionsSnippet[r]=a,(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)&&(s.arrayLayerCount=new B(new gi(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(s.cubeFaceCount=new B(new gi("6u","u32")))}return a.build(this)}generateFilteredTexture(e,t,r,s,a="0u"){this._include("biquadraticTexture");const c=this.generateWrapFunction(e),h=this.generateTextureDimension(e,t,a);return s&&(r=`${r} + vec2<f32>(${s}) / ${h}`),`tsl_biquadraticTexture( ${t}, ${c}( ${r} ), ${h}, u32( ${a} ) )`}generateTextureLod(e,t,r,s,a,c="0u"){const h=this.generateWrapFunction(e),f=this.generateTextureDimension(e,t,c),m=e.isData3DTexture?"vec3":"vec2";a&&(r=`${r} + ${m}<f32>(${a}) / ${m}<f32>( ${f} )`);const x=`${m}<u32>( ${h}( ${r} ) * ${m}<f32>( ${f} ) )`;return this.generateTextureLoad(e,t,x,c,s,null)}generateTextureLoad(e,t,r,s,a,c){s===null&&(s="0u"),c&&(r=`${r} + ${c}`);let h;return a?h=`textureLoad( ${t}, ${r}, ${a}, u32( ${s} ) )`:(h=`textureLoad( ${t}, ${r}, u32( ${s} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(h+=".x")),h}generateTextureStore(e,t,r,s,a){let c;return s?c=`textureStore( ${t}, ${r}, ${s}, ${a} )`:c=`textureStore( ${t}, ${r}, ${a} )`,c}isSampleCompare(e){return e.isDepthTexture===!0&&e.compareFunction!==null}isUnfilterable(e){return this.getComponentTypeFromTexture(e)!=="float"||!this.isAvailable("float32Filterable")&&e.isDataTexture===!0&&e.type===d.VzW||this.isSampleCompare(e)===!1&&e.minFilter===d.TyD&&e.magFilter===d.TyD||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,r,s,a,c=this.shaderStage){let h=null;return this.isUnfilterable(e)?h=this.generateTextureLod(e,t,r,s,a,"0",c):h=this._generateTextureSample(e,t,r,s,a,c),h}generateTextureGrad(e,t,r,s,a,c,h=this.shaderStage){if(h==="fragment")return c?`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${s[0]}, ${s[1]}, ${c} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${r}, ${s[0]}, ${s[1]} )`;(0,d.vUy)(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${h} shader.`)}generateTextureCompare(e,t,r,s,a,c,h=this.shaderStage){if(h==="fragment")return e.isDepthTexture===!0&&e.isArrayTexture===!0?c?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${a}, ${s}, ${c} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${a}, ${s} )`:c?`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s}, ${c} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${r}, ${s} )`;(0,d.vUy)(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${h} shader.`)}generateTextureLevel(e,t,r,s,a,c){return this.isUnfilterable(e)===!1?c?`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s}, ${c} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${r}, ${s} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,r,c,s):this.generateTextureLod(e,t,r,a,c,s)}generateTextureBias(e,t,r,s,a,c,h=this.shaderStage){if(h==="fragment")return c?`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${s}, ${c} )`:`textureSampleBias( ${t}, ${t}_sampler, ${r}, ${s} )`;(0,d.vUy)(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${h} shader.`)}getPropertyName(e,t=this.shaderStage){if(e.isNodeVarying===!0&&e.needsInterpolation===!0){if(t==="vertex")return`varyings.${e.name}`}else if(e.isNodeUniform===!0){const r=e.name,s=e.type;return s==="texture"||s==="cubeTexture"||s==="storageTexture"||s==="texture3D"?r:s==="buffer"||s==="storageBuffer"||s==="indirectStorageBuffer"?this.isCustomStruct(e)?r:r+".value":e.groupNode.name+"."+r}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){const t=MU[e];return t!==void 0?(this._include(t),t):null}getNodeAccess(e,t){return t!=="compute"?e.isAtomic===!0?((0,d.ZK6)("WebGPURenderer: Atomic operations are only supported in compute shaders."),yr.READ_WRITE):yr.READ_ONLY:e.access}getStorageAccess(e,t){return TU[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,r,s=null){const a=super.getUniformFromNode(e,t,r,s),c=this.getDataFromNode(e,r,this.globalCache);if(c.uniformGPU===void 0){let h;const f=e.groupNode,m=f.name,x=this.getBindGroupArray(m,r);if(t==="texture"||t==="cubeTexture"||t==="storageTexture"||t==="texture3D"){let _=null;const v=this.getNodeAccess(e,r);if(t==="texture"||t==="storageTexture"?e.value.is3DTexture===!0?_=new cS(a.name,a.node,f,v):_=new Xx(a.name,a.node,f,v):t==="cubeTexture"?_=new fA(a.name,a.node,f,v):t==="texture3D"&&(_=new cS(a.name,a.node,f,v)),_.store=e.isStorageTextureNode===!0,_.mipLevel=_.store?e.mipLevel:0,_.setVisibility(Yx[r]),this.isUnfilterable(e.value)===!1&&_.store===!1){const T=new uU(`${a.name}_sampler`,a.node,f);T.setVisibility(Yx[r]),x.push(T,_),h=[T,_]}else x.push(_),h=[_]}else if(t==="buffer"||t==="storageBuffer"||t==="indirectStorageBuffer"){const _=t==="buffer"?uA:fU,v=new _(e,f);v.setVisibility(Yx[r]),x.push(v),h=v,a.name=s||"NodeBuffer_"+a.id}else{const _=this.uniformGroups[r]||(this.uniformGroups[r]={});let v=_[m];v===void 0&&(v=new hA(m,f),v.setVisibility(Yx[r]),_[m]=v,x.push(v)),h=this.getNodeUniform(a,t),v.addUniform(h)}c.uniformGPU=h}return a}getBuiltin(e,t,r,s=this.shaderStage){const a=this.builtins[s]||(this.builtins[s]=new Map);return a.has(e)===!1&&a.set(e,{name:e,property:t,type:r}),t}hasBuiltin(e,t=this.shaderStage){return this.builtins[t]!==void 0&&this.builtins[t].has(e)}getVertexIndex(){return this.shaderStage==="vertex"?this.getBuiltin("vertex_index","vertexIndex","u32","attribute"):"vertexIndex"}buildFunctionCode(e){const t=e.layout,r=this.flowShaderNode(e),s=[];for(const c of t.inputs)s.push(c.name+" : "+this.getType(c.type));let a=`fn ${t.name}( ${s.join(", ")} ) -> ${this.getType(t.type)} {
${r.vars}
${r.code}
`;return r.result&&(a+=` return ${r.result};
`),a+=`
}
`,a}getInstanceIndex(){return this.shaderStage==="vertex"?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")}getInvocationSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_invocation_id","invocationSubgroupIndex","u32","attribute")}getSubgroupIndex(){return this.enableSubGroups(),this.getBuiltin("subgroup_id","subgroupIndex","u32","attribute")}getDrawIndex(){return null}getFrontFacing(){return this.getBuiltin("front_facing","isFront","bool")}getFragCoord(){return this.getBuiltin("position","fragCoord","vec4<f32>")+".xy"}getFragDepth(){return"output."+this.getBuiltin("frag_depth","depth","f32","output")}getClipDistance(){return"varyings.hw_clip_distances"}isFlipY(){return!1}enableDirective(e,t=this.shaderStage){(this.directives[t]||(this.directives[t]=new Set)).add(e)}getDirectives(e){const t=[],r=this.directives[e];if(r!==void 0)for(const s of r)t.push(`enable ${s};`);return t.join(`
`)}enableSubGroups(){this.enableDirective("subgroups")}enableSubgroupsF16(){this.enableDirective("subgroups-f16")}enableClipDistances(){this.enableDirective("clip_distances")}enableShaderF16(){this.enableDirective("f16")}enableDualSourceBlending(){this.enableDirective("dual_source_blending")}enableHardwareClipping(e){this.enableClipDistances(),this.getBuiltin("clip_distances","hw_clip_distances",`array<f32, ${e} >`,"vertex")}getBuiltins(e){const t=[],r=this.builtins[e];if(r!==void 0)for(const{name:s,property:a,type:c}of r.values())t.push(`@builtin( ${s} ) ${a} : ${c}`);return t.join(`,
`)}getScopedArray(e,t,r,s){return this.scopedArrays.has(e)===!1&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:r,bufferCount:s}),e}getScopedArrays(e){if(e!=="compute")return;const t=[];for(const{name:r,scope:s,bufferType:a,bufferCount:c}of this.scopedArrays.values()){const h=this.getType(a);t.push(`var<${s}> ${r}: array< ${h}, ${c} >;`)}return t.join(`
`)}getAttributes(e){const t=[];if(e==="compute"&&(this.getBuiltin("global_invocation_id","globalId","vec3<u32>","attribute"),this.getBuiltin("workgroup_id","workgroupId","vec3<u32>","attribute"),this.getBuiltin("local_invocation_id","localId","vec3<u32>","attribute"),this.getBuiltin("num_workgroups","numWorkgroups","vec3<u32>","attribute"),this.renderer.hasFeature("subgroups")&&(this.enableDirective("subgroups",e),this.getBuiltin("subgroup_size","subgroupSize","u32","attribute"))),e==="vertex"||e==="compute"){const r=this.getBuiltins("attribute");r&&t.push(r);const s=this.getAttributesArray();for(let a=0,c=s.length;a<c;a++){const h=s[a],f=h.name,m=this.getType(h.type);t.push(`@location( ${a} ) ${f} : ${m}`)}}return t.join(`,
`)}getStructMembers(e){const t=[];for(const r of e.members){const s=e.output?"@location( "+r.index+" ) ":"";let a=this.getType(r.type);r.atomic&&(a="atomic< "+a+" >"),t.push(` ${s+r.name} : ${a}`)}return e.output&&t.push(` ${this.getBuiltins("output")}`),t.join(`,
`)}getStructs(e){let t="";const r=this.structs[e];if(r.length>0){const s=[];for(const a of r){let c=`struct ${a.name} {
`;c+=this.getStructMembers(a),c+=`
};`,s.push(c)}t=`
`+s.join(`
`)+`
`}return t}getVar(e,t,r=null){let s=`var ${t} : `;return r!==null?s+=this.generateArrayDeclaration(e,r):s+=this.getType(e),s}getVars(e){const t=[],r=this.vars[e];if(r!==void 0)for(const s of r)t.push(` ${this.getVar(s.type,s.name,s.count)};`);return`
${t.join(`
`)}
`}getVaryings(e){const t=[];if(e==="vertex"&&this.getBuiltin("position","Vertex","vec4<f32>","vertex"),e==="vertex"||e==="fragment"){const a=this.varyings,c=this.vars[e];for(let h=0;h<a.length;h++){const f=a[h];if(f.needsInterpolation){let m=`@location( ${h} )`;if(f.interpolationType){const x=f.interpolationSampling!==null?`, ${f.interpolationSampling} )`:" )";m+=` @interpolate( ${f.interpolationType}${x}`}else/^(int|uint|ivec|uvec)/.test(f.type)&&(m+=` @interpolate( ${this.renderer.backend.compatibilityMode?"flat, either":"flat"} )`);t.push(`${m} ${f.name} : ${this.getType(f.type)}`)}else e==="vertex"&&c.includes(f)===!1&&c.push(f)}}const r=this.getBuiltins(e);r&&t.push(r);const s=t.join(`,
`);return e==="vertex"?this._getWGSLStruct("VaryingsStruct"," "+s):s}isCustomStruct(e){const t=e.value,r=e.node,s=(t.isBufferAttribute||t.isInstancedBufferAttribute)&&r.structTypeNode!==null,a=r.value&&r.value.array&&typeof r.value.itemSize=="number"&&r.value.array.length>r.value.itemSize;return s&&!a}getUniforms(e){const t=this.uniforms[e],r=[],s=[],a=[],c={};for(const f of t){const m=f.groupNode.name,x=this.bindingsIndexes[m];if(f.type==="texture"||f.type==="cubeTexture"||f.type==="storageTexture"||f.type==="texture3D"){const _=f.node.value;this.isUnfilterable(_)===!1&&f.node.isStorageTextureNode!==!0&&(this.isSampleCompare(_)?r.push(`@binding( ${x.binding++} ) @group( ${x.group} ) var ${f.name}_sampler : sampler_comparison;`):r.push(`@binding( ${x.binding++} ) @group( ${x.group} ) var ${f.name}_sampler : sampler;`));let v,T="";const{primarySamples:w}=this.renderer.backend.utils.getTextureSampleData(_);if(w>1&&(T="_multisampled"),_.isCubeTexture===!0)v="texture_cube<f32>";else if(_.isDepthTexture===!0)this.renderer.backend.compatibilityMode&&_.compareFunction===null?v=`texture${T}_2d<f32>`:v=`texture_depth${T}_2d${_.isArrayTexture===!0?"_array":""}`;else if(f.node.isStorageTextureNode===!0){const P=gS(_),C=this.getStorageAccess(f.node,e),E=f.node.value.is3DTexture,D=f.node.value.isArrayTexture;v=`texture_storage_${E?"3d":`2d${D?"_array":""}`}<${P}, ${C}>`}else if(_.isArrayTexture===!0||_.isDataArrayTexture===!0||_.isCompressedArrayTexture===!0)v="texture_2d_array<f32>";else if(_.is3DTexture===!0||_.isData3DTexture===!0)v="texture_3d<f32>";else{const P=this.getComponentTypeFromTexture(_).charAt(0);v=`texture${T}_2d<${P}32>`}r.push(`@binding( ${x.binding++} ) @group( ${x.group} ) var ${f.name} : ${v};`)}else if(f.type==="buffer"||f.type==="storageBuffer"||f.type==="indirectStorageBuffer"){const _=f.node,v=this.getType(_.getNodeType(this)),T=_.bufferCount,w=T>0&&f.type==="buffer"?", "+T:"",P=_.isStorageBufferNode?`storage, ${this.getStorageAccess(_,e)}`:"uniform";if(this.isCustomStruct(f))s.push(`@binding( ${x.binding++} ) @group( ${x.group} ) var<${P}> ${f.name} : ${v};`);else{const E=` value : array< ${_.isAtomic?`atomic<${v}>`:`${v}`}${w} >`;s.push(this._getWGSLStructBinding(f.name,E,P,x.binding++,x.group))}}else{const _=this.getType(this.getVectorType(f.type)),v=f.groupNode.name;(c[v]||(c[v]={index:x.binding++,id:x.group,snippets:[]})).snippets.push(` ${f.name} : ${_}`)}}for(const f in c){const m=c[f];a.push(this._getWGSLStructBinding(f,m.snippets.join(`,
`),"uniform",m.index,m.id))}let h=r.join(`
`);return h+=s.join(`
`),h+=a.join(`
`),h}buildCode(){const e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){this.shaderStage=t;const r=e[t];r.uniforms=this.getUniforms(t),r.attributes=this.getAttributes(t),r.varyings=this.getVaryings(t),r.structs=this.getStructs(t),r.vars=this.getVars(t),r.codes=this.getCodes(t),r.directives=this.getDirectives(t),r.scopedArrays=this.getScopedArrays(t);let s=`// code
`;s+=this.flowCode[t];const a=this.flowNodes[t],c=a[a.length-1],h=c.outputNode,f=h!==void 0&&h.isOutputStructNode===!0;for(const m of a){const x=this.getFlowData(m),_=m.name;if(_&&(s.length>0&&(s+=`
`),s+=` // flow -> ${_}
`),s+=`${x.code}
`,m===c&&t!=="compute"){if(s+=`// result
`,t==="vertex")s+=`varyings.Vertex = ${x.result};`;else if(t==="fragment")if(f)r.returnType=h.getNodeType(this),r.structs+="var<private> output : "+r.returnType+";",s+=`return ${x.result};`;else{let v=" @location(0) color: vec4<f32>";const T=this.getBuiltins("output");T&&(v+=`,
`+T),r.returnType="OutputStruct",r.structs+=this._getWGSLStruct("OutputStruct",v),r.structs+=`
var<private> output : OutputStruct;`,s+=`output.color = ${x.result};
return output;`}}}r.flow=s}if(this.shaderStage=null,this.material!==null)this.vertexShader=this._getWGSLVertexCode(e.vertex),this.fragmentShader=this._getWGSLFragmentCode(e.fragment);else{const t=this.object.workgroupSize;this.computeShader=this._getWGSLComputeCode(e.compute,t)}}getMethod(e,t=null){let r;return t!==null&&(r=this._getWGSLMethod(e+"_"+t)),r===void 0&&(r=this._getWGSLMethod(e)),r||e}getBitcastMethod(e){return`bitcast<${this.getType(e)}>`}getTernary(e,t,r){return`select( ${r}, ${t}, ${e} )`}getType(e){return wU[e]||e}isAvailable(e){let t=IA[e];return t===void 0&&(e==="float32Filterable"?t=this.renderer.hasFeature("float32-filterable"):e==="clipDistance"&&(t=this.renderer.hasFeature("clip-distances")),IA[e]=t),t}_getWGSLMethod(e){return Em[e]!==void 0&&this._include(e),AU[e]}_include(e){const t=Em[e];return t.build(this),this.addInclude(t),t}_getWGSLVertexCode(e){return`${this.getSignature()}
// directives
${e.directives}
// structs
${e.structs}
// uniforms
${e.uniforms}
// varyings
${e.varyings}
var<private> varyings : VaryingsStruct;
// codes
${e.codes}
@vertex
fn main( ${e.attributes} ) -> VaryingsStruct {
// vars
${e.vars}
// flow
${e.flow}
return varyings;
}
`}_getWGSLFragmentCode(e){return`${this.getSignature()}
// global
${UA}
// structs
${e.structs}
// uniforms
${e.uniforms}
// codes
${e.codes}
@fragment
fn main( ${e.varyings} ) -> ${e.returnType} {
// vars
${e.vars}
// flow
${e.flow}
}
`}_getWGSLComputeCode(e,t){const[r,s,a]=t;return`${this.getSignature()}
// directives
${e.directives}
// system
var<private> instanceIndex : u32;
// locals
${e.scopedArrays}
// structs
${e.structs}
// uniforms
${e.uniforms}
// codes
${e.codes}
@compute @workgroup_size( ${r}, ${s}, ${a} )
fn main( ${e.attributes} ) {
// system
instanceIndex = globalId.x
+ globalId.y * ( ${r} * numWorkgroups.x )
+ globalId.z * ( ${r} * numWorkgroups.x ) * ( ${s} * numWorkgroups.y );
// vars
${e.vars}
// flow
${e.flow}
}
`}_getWGSLStruct(e,t){return`
struct ${e} {
${t}
};`}_getWGSLStructBinding(e,t,r,s=0,a=0){const c=e+"Struct";return`${this._getWGSLStruct(c,t)}
@binding( ${s} ) @group( ${a} )
var<${r}> ${e} : ${c};`}}class CU{constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depthTexture!==null?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=pe.Depth24PlusStencil8:e.depth&&(t=pe.Depth24Plus),t}getTextureFormatGPU(e){return this.backend.get(e).format}getTextureSampleData(e){let t;if(e.isFramebufferTexture)t=1;else if(e.isDepthTexture&&!e.renderTarget){const a=this.backend.renderer,c=a.getRenderTarget();t=c?c.samples:a.currentSamples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const r=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0;return{samples:t,primarySamples:r?1:t,isMSAA:r}}getCurrentColorFormat(e){let t;return e.textures!==null?t=this.getTextureFormatGPU(e.textures[0]):t=this.getPreferredCanvasFormat(),t}getCurrentColorFormats(e){return e.textures!==null?e.textures.map(t=>this.getTextureFormatGPU(t)):[this.getPreferredCanvasFormat()]}getCurrentColorSpace(e){return e.textures!==null?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return Gd.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return Gd.LineList;if(e.isLine)return Gd.LineStrip;if(e.isMesh)return Gd.TriangleList}getSampleCount(e){return e>=4?4:1}getSampleCountRenderContext(e){return e.textures!==null?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.currentSamples)}getPreferredCanvasFormat(){const e=this.backend.parameters.outputType;if(e===void 0)return navigator.gpu.getPreferredCanvasFormat();if(e===d.ywz)return pe.BGRA8Unorm;if(e===d.cLu)return pe.RGBA16Float;throw new Error("Unsupported outputType")}}const FA=new Map([[Int8Array,["sint8","snorm8"]],[Uint8Array,["uint8","unorm8"]],[Int16Array,["sint16","snorm16"]],[Uint16Array,["uint16","unorm16"]],[Int32Array,["sint32","snorm32"]],[Uint32Array,["uint32","unorm32"]],[Float32Array,["float32"]]]);typeof Float16Array!="undefined"&&FA.set(Float16Array,["float16"]);const RU=new Map([[d.e62,["float16"]]]),NU=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class PU{constructor(e){this.backend=e}createAttribute(e,t){const r=this._getBufferAttribute(e),s=this.backend,a=s.get(r);let c=a.buffer;if(c===void 0){const h=s.device;let f=r.array;if(e.normalized===!1){if(f.constructor===Int16Array||f.constructor===Int8Array)f=new Int32Array(f);else if((f.constructor===Uint16Array||f.constructor===Uint8Array)&&(f=new Uint32Array(f),t&GPUBufferUsage.INDEX))for(let _=0;_<f.length;_++)f[_]===65535&&(f[_]=4294967295)}if(r.array=f,(r.isStorageBufferAttribute||r.isStorageInstancedBufferAttribute)&&r.itemSize===3){f=new f.constructor(r.count*4);for(let _=0;_<r.count;_++)f.set(r.array.subarray(_*3,_*3+3),_*4);r.itemSize=4,r.array=f,a._force3to4BytesAlignment=!0}const m=f.byteLength,x=m+(4-m%4)%4;c=h.createBuffer({label:r.name,size:x,usage:t,mappedAtCreation:!0}),new f.constructor(c.getMappedRange()).set(f),c.unmap(),a.buffer=c}}updateAttribute(e){const t=this._getBufferAttribute(e),r=this.backend,s=r.device,a=r.get(t),c=r.get(t).buffer;let h=t.array;if(a._force3to4BytesAlignment===!0){h=new h.constructor(t.count*4);for(let x=0;x<t.count;x++)h.set(t.array.subarray(x*3,x*3+3),x*4);t.array=h}const f=this._isTypedArray(h),m=t.updateRanges;if(m.length===0)s.queue.writeBuffer(c,0,h,0);else{const x=f?1:h.BYTES_PER_ELEMENT;for(let _=0,v=m.length;_<v;_++){const T=m[_];let w,P;if(a._force3to4BytesAlignment===!0){const E=Math.floor(T.start/3),D=Math.ceil(T.count/3);w=E*4*x,P=D*4*x}else w=T.start*x,P=T.count*x;const C=w*(f?h.BYTES_PER_ELEMENT:1);s.queue.writeBuffer(c,C,h,w,P)}t.clearUpdateRanges()}}createShaderVertexBuffers(e){const t=e.getAttributes(),r=new Map;for(let s=0;s<t.length;s++){const a=t[s],c=a.array.BYTES_PER_ELEMENT,h=this._getBufferAttribute(a);let f=r.get(h);if(f===void 0){let _,v;a.isInterleavedBufferAttribute===!0?(_=a.data.stride*c,v=a.data.isInstancedInterleavedBuffer?Zx.Instance:Zx.Vertex):(_=a.itemSize*c,v=a.isInstancedBufferAttribute?Zx.Instance:Zx.Vertex),a.normalized===!1&&(a.array.constructor===Int16Array||a.array.constructor===Uint16Array)&&(_=4),f={arrayStride:_,attributes:[],stepMode:v},r.set(h,f)}const m=this._getVertexFormat(a),x=a.isInterleavedBufferAttribute===!0?a.offset*c:0;f.attributes.push({shaderLocation:s,offset:x,format:m})}return Array.from(r.values())}destroyAttribute(e){const t=this.backend;t.get(this._getBufferAttribute(e)).buffer.destroy(),t.delete(e)}getArrayBufferAsync(e){return nn(this,null,function*(){const t=this.backend,r=t.device,a=t.get(this._getBufferAttribute(e)).buffer,c=a.size,h=r.createBuffer({label:`${e.name}_readback`,size:c,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),f=r.createCommandEncoder({label:`readback_encoder_${e.name}`});f.copyBufferToBuffer(a,0,h,0,c);const m=f.finish();r.queue.submit([m]),yield h.mapAsync(GPUMapMode.READ);const x=h.getMappedRange(),_=new e.array.constructor(x.slice(0));return h.unmap(),_.buffer})}_getVertexFormat(e){const{itemSize:t,normalized:r}=e,s=e.array.constructor,a=e.constructor;let c;if(t===1)c=NU.get(s);else{const f=(RU.get(a)||FA.get(s))[r?1:0];if(f){const m=s.BYTES_PER_ELEMENT*t,_=Math.floor((m+3)/4)*4/s.BYTES_PER_ELEMENT;if(_%1)throw new Error("THREE.WebGPUAttributeUtils: Bad vertex format item size.");c=`${f}x${_}`}}return c||(0,d.vUy)("WebGPUAttributeUtils: Vertex format not supported yet."),c}_isTypedArray(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}class LU{constructor(e){this.backend=e,this.bindGroupLayoutCache=new WeakMap}createBindingsLayout(e){const t=this.backend,r=t.device,s=[];let a=0;for(const c of e.bindings){const h={binding:a++,visibility:c.visibility};if(c.isUniformBuffer||c.isStorageBuffer){const f={};c.isStorageBuffer&&(c.visibility&4&&(c.access===yr.READ_WRITE||c.access===yr.WRITE_ONLY)?f.type=fS.Storage:f.type=fS.ReadOnlyStorage),h.buffer=f}else if(c.isSampledTexture&&c.store){const f={};f.format=this.backend.get(c.texture).texture.format;const m=c.access;m===yr.READ_WRITE?f.access=pS.ReadWrite:m===yr.WRITE_ONLY?f.access=pS.WriteOnly:f.access=pS.ReadOnly,c.texture.isArrayTexture?f.viewDimension=fr.TwoDArray:c.texture.is3DTexture&&(f.viewDimension=fr.ThreeD),h.storageTexture=f}else if(c.isSampledTexture){const f={},{primarySamples:m}=t.utils.getTextureSampleData(c.texture);if(m>1&&(f.multisampled=!0,c.texture.isDepthTexture||(f.sampleType=Wu.UnfilterableFloat)),c.texture.isDepthTexture)t.compatibilityMode&&c.texture.compareFunction===null?f.sampleType=Wu.UnfilterableFloat:f.sampleType=Wu.Depth;else if(c.texture.isDataTexture||c.texture.isDataArrayTexture||c.texture.isData3DTexture){const x=c.texture.type;x===d.Kz5?f.sampleType=Wu.SInt:x===d.JQ4?f.sampleType=Wu.UInt:x===d.VzW&&(this.backend.hasFeature("float32-filterable")?f.sampleType=Wu.Float:f.sampleType=Wu.UnfilterableFloat)}c.isSampledCubeTexture?f.viewDimension=fr.Cube:c.texture.isArrayTexture||c.texture.isDataArrayTexture||c.texture.isCompressedArrayTexture?f.viewDimension=fr.TwoDArray:c.isSampledTexture3D&&(f.viewDimension=fr.ThreeD),h.texture=f}else if(c.isSampler){const f={};c.texture.isDepthTexture&&(c.texture.compareFunction!==null?f.type=CA.Comparison:t.compatibilityMode&&(f.type=CA.NonFiltering)),h.sampler=f}else(0,d.vUy)(`WebGPUBindingUtils: Unsupported binding "${c}".`);s.push(h)}return r.createBindGroupLayout({entries:s})}createBindings(e,t,r,s=0){const{backend:a,bindGroupLayoutCache:c}=this,h=a.get(e);let f=c.get(e.bindingsReference);f===void 0&&(f=this.createBindingsLayout(e),c.set(e.bindingsReference,f));let m;r>0&&(h.groups===void 0&&(h.groups=[],h.versions=[]),h.versions[r]===s&&(m=h.groups[r])),m===void 0&&(m=this.createBindGroup(e,f),r>0&&(h.groups[r]=m,h.versions[r]=s)),h.group=m,h.layout=f}updateBinding(e){const t=this.backend,r=t.device,s=e.buffer,a=t.get(e).buffer;r.queue.writeBuffer(a,0,s,0)}createBindGroupIndex(e,t){const s=this.backend.device,a=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,c=e[0],h=s.createBuffer({label:"bindingCameraIndex_"+c,size:16,usage:a});s.queue.writeBuffer(h,0,e,0);const f=[{binding:0,resource:{buffer:h}}];return s.createBindGroup({label:"bindGroupCameraIndex_"+c,layout:t,entries:f})}createBindGroup(e,t){const r=this.backend,s=r.device;let a=0;const c=[];for(const h of e.bindings){if(h.isUniformBuffer){const f=r.get(h);if(f.buffer===void 0){const m=h.byteLength,x=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,_=s.createBuffer({label:"bindingBuffer_"+h.name,size:m,usage:x});f.buffer=_}c.push({binding:a,resource:{buffer:f.buffer}})}else if(h.isStorageBuffer){const f=r.get(h);if(f.buffer===void 0){const m=h.attribute;f.buffer=r.get(m).buffer}c.push({binding:a,resource:{buffer:f.buffer}})}else if(h.isSampledTexture){const f=r.get(h.texture);let m;if(f.externalTexture!==void 0)m=s.importExternalTexture({source:f.externalTexture});else{const x=h.store?1:f.texture.mipLevelCount,_=h.store?h.mipLevel:0;let v=`view-${f.texture.width}-${f.texture.height}`;if(f.texture.depthOrArrayLayers>1&&(v+=`-${f.texture.depthOrArrayLayers}`),v+=`-${x}-${_}`,m=f[v],m===void 0){const T=lU.All;let w;h.isSampledCubeTexture?w=fr.Cube:h.isSampledTexture3D?w=fr.ThreeD:h.texture.isArrayTexture||h.texture.isDataArrayTexture||h.texture.isCompressedArrayTexture?w=fr.TwoDArray:w=fr.TwoD,m=f[v]=f.texture.createView({aspect:T,dimension:w,mipLevelCount:x,baseMipLevel:_})}}c.push({binding:a,resource:m})}else if(h.isSampler){const f=r.get(h.texture);c.push({binding:a,resource:f.sampler})}a++}return s.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:c})}}class IU{constructor(e){this.backend=e,this._activePipelines=new WeakMap}setPipeline(e,t){this._activePipelines.get(e)!==t&&(e.setPipeline(t),this._activePipelines.set(e,t))}_getSampleCount(e){return this.backend.utils.getSampleCountRenderContext(e)}createRenderPipeline(e,t){const{object:r,material:s,geometry:a,pipeline:c}=e,{vertexProgram:h,fragmentProgram:f}=c,m=this.backend,x=m.device,_=m.utils,v=m.get(c),T=[];for(const Ee of e.getBindings()){const Pe=m.get(Ee);T.push(Pe.layout)}const w=m.attributeUtils.createShaderVertexBuffers(e);let P;s.blending!==d.jFi&&(s.blending!==d.bdR||s.transparent!==!1)&&(P=this._getBlending(s));let C={};s.stencilWrite===!0&&(C={compare:this._getStencilCompare(s),failOp:this._getStencilOperation(s.stencilFail),depthFailOp:this._getStencilOperation(s.stencilZFail),passOp:this._getStencilOperation(s.stencilZPass)});const E=this._getColorWriteMask(s),D=[];if(e.context.textures!==null){const Ee=e.context.textures;for(let Pe=0;Pe<Ee.length;Pe++){const He=_.getTextureFormatGPU(Ee[Pe]);D.push({format:He,blend:P,writeMask:E})}}else{const Ee=_.getCurrentColorFormat(e.context);D.push({format:Ee,blend:P,writeMask:E})}const F=m.get(h).module,W=m.get(f).module,K=this._getPrimitiveState(r,a,s),U=this._getDepthCompare(s),j=_.getCurrentDepthStencilFormat(e.context),oe=this._getSampleCount(e.context),k={label:`renderPipeline_${s.name||s.type}_${s.id}`,vertex:Object.assign({},F,{buffers:w}),fragment:Object.assign({},W,{targets:D}),primitive:K,multisample:{count:oe,alphaToCoverageEnabled:s.alphaToCoverage&&oe>1},layout:x.createPipelineLayout({bindGroupLayouts:T})},O={},le=e.context.depth,be=e.context.stencil;if((le===!0||be===!0)&&(le===!0&&(O.format=j,O.depthWriteEnabled=s.depthWrite,O.depthCompare=U),be===!0&&(O.stencilFront=C,O.stencilBack={},O.stencilReadMask=s.stencilFuncMask,O.stencilWriteMask=s.stencilWriteMask),s.polygonOffset===!0&&(O.depthBias=s.polygonOffsetUnits,O.depthBiasSlopeScale=s.polygonOffsetFactor,O.depthBiasClamp=0),k.depthStencil=O),x.pushErrorScope("validation"),t===null)v.pipeline=x.createRenderPipeline(k),x.popErrorScope().then(Ee=>{Ee!==null&&(v.error=!0,(0,d.vUy)(Ee.message))});else{const Ee=new Promise(Pe=>nn(this,null,function*(){try{v.pipeline=yield x.createRenderPipelineAsync(k)}catch(Be){}const He=yield x.popErrorScope();He!==null&&(v.error=!0,(0,d.vUy)(He.message)),Pe()}));t.push(Ee)}}createBundleEncoder(e,t="renderBundleEncoder"){const r=this.backend,{utils:s,device:a}=r,c=s.getCurrentDepthStencilFormat(e),h=s.getCurrentColorFormats(e),f=this._getSampleCount(e),m={label:t,colorFormats:h,depthStencilFormat:c,sampleCount:f};return a.createRenderBundleEncoder(m)}createComputePipeline(e,t){const r=this.backend,s=r.device,a=r.get(e.computeProgram).module,c=r.get(e),h=[];for(const f of t){const m=r.get(f);h.push(m.layout)}c.pipeline=s.createComputePipeline({compute:a,layout:s.createPipelineLayout({bindGroupLayouts:h})})}_getBlending(e){let t,r;const s=e.blending,a=e.blendSrc,c=e.blendDst,h=e.blendEquation;if(s===d.Xaj){const f=e.blendSrcAlpha!==null?e.blendSrcAlpha:a,m=e.blendDstAlpha!==null?e.blendDstAlpha:c,x=e.blendEquationAlpha!==null?e.blendEquationAlpha:h;t={srcFactor:this._getBlendFactor(a),dstFactor:this._getBlendFactor(c),operation:this._getBlendOperation(h)},r={srcFactor:this._getBlendFactor(f),dstFactor:this._getBlendFactor(m),operation:this._getBlendOperation(x)}}else{const f=e.premultipliedAlpha,m=(x,_,v,T)=>{t={srcFactor:x,dstFactor:_,operation:Gu.Add},r={srcFactor:v,dstFactor:T,operation:Gu.Add}};if(f)switch(s){case d.bdR:m(Zn.One,Zn.OneMinusSrcAlpha,Zn.One,Zn.OneMinusSrcAlpha);break;case d.WMw:m(Zn.One,Zn.One,Zn.One,Zn.One);break;case d.N4l:m(Zn.Zero,Zn.OneMinusSrc,Zn.Zero,Zn.One);break;case d.M5h:m(Zn.Dst,Zn.OneMinusSrcAlpha,Zn.Zero,Zn.One);break}else switch(s){case d.bdR:m(Zn.SrcAlpha,Zn.OneMinusSrcAlpha,Zn.One,Zn.OneMinusSrcAlpha);break;case d.WMw:m(Zn.SrcAlpha,Zn.One,Zn.One,Zn.One);break;case d.N4l:(0,d.vUy)("WebGPURenderer: SubtractiveBlending requires material.premultipliedAlpha = true");break;case d.M5h:(0,d.vUy)("WebGPURenderer: MultiplyBlending requires material.premultipliedAlpha = true");break}}if(t!==void 0&&r!==void 0)return{color:t,alpha:r};(0,d.vUy)("WebGPURenderer: Invalid blending: ",s)}_getBlendFactor(e){let t;switch(e){case d.c8b:t=Zn.Zero;break;case d.ghN:t=Zn.One;break;case d.KhW:t=Zn.Src;break;case d.iWC:t=Zn.OneMinusSrc;break;case d.k74:t=Zn.SrcAlpha;break;case d.LgZ:t=Zn.OneMinusSrcAlpha;break;case d.Vdb:t=Zn.Dst;break;case d.Wpd:t=Zn.OneMinusDst;break;case d.fSK:t=Zn.DstAlpha;break;case d.Hy8:t=Zn.OneMinusDstAlpha;break;case d.RlZ:t=Zn.SrcAlphaSaturated;break;case A2:t=Zn.Constant;break;case E2:t=Zn.OneMinusConstant;break;default:(0,d.vUy)("WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const r=e.stencilFunc;switch(r){case d.MyG:t=Wr.Never;break;case d.cum:t=Wr.Always;break;case d.uXU:t=Wr.Less;break;case d.yt0:t=Wr.LessEqual;break;case d.jwo:t=Wr.Equal;break;case d.j4z:t=Wr.GreaterEqual;break;case d.OAl:t=Wr.Greater;break;case d.RvT:t=Wr.NotEqual;break;default:(0,d.vUy)("WebGPURenderer: Invalid stencil function.",r)}return t}_getStencilOperation(e){let t;switch(e){case d.x5V:t=Tl.Keep;break;case d.ad5:t=Tl.Zero;break;case d.ce8:t=Tl.Replace;break;case d.eMJ:t=Tl.Invert;break;case d.ZRs:t=Tl.IncrementClamp;break;case d.jfJ:t=Tl.DecrementClamp;break;case d.oqc:t=Tl.IncrementWrap;break;case d.T_J:t=Tl.DecrementWrap;break;default:(0,d.vUy)("WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case d.bGH:t=Gu.Add;break;case d.Wbm:t=Gu.Subtract;break;case d.rOj:t=Gu.ReverseSubtract;break;case d.r_:t=Gu.Min;break;case d.Sm8:t=Gu.Max;break;default:(0,d.vUy)("WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,r){const s={},a=this.backend.utils;s.topology=a.getPrimitiveTopology(e,r),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(s.stripIndexFormat=t.index.array instanceof Uint16Array?Wd.Uint16:Wd.Uint32);let c=r.side===d._Li;return e.isMesh&&e.matrixWorld.determinant()<0&&(c=!c),s.frontFace=c===!0?wA.CW:wA.CCW,s.cullMode=r.side===d.ehD?AA.None:AA.Back,s}_getColorWriteMask(e){return e.colorWrite===!0?EA.All:EA.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=Wr.Always;else{const r=e.depthFunc;switch(r){case d.BVF:t=Wr.Never;break;case d.Se2:t=Wr.Always;break;case d.Zr5:t=Wr.Less;break;case d.vCF:t=Wr.LessEqual;break;case d.eD:t=Wr.Equal;break;case d.ksN:t=Wr.GreaterEqual;break;case d.w$m:t=Wr.Greater;break;case d.M6v:t=Wr.NotEqual;break;default:(0,d.vUy)("WebGPUPipelineUtils: Invalid depth function.",r)}}return t}}class DU extends TA{constructor(e,t,r=2048){super(r),this.device=e,this.type=t,this.querySet=this.device.createQuerySet({type:"timestamp",count:this.maxQueries,label:`queryset_global_timestamp_${t}`});const s=this.maxQueries*8;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:s,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:s,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return(0,d.O4K)(`WebGPUTimestampQueryPool [${this.type}]: Maximum number of queries exceeded, when using trackTimestamp it is necessary to resolves the queries via renderer.resolveTimestampsAsync( THREE.TimestampQuery.${this.type.toUpperCase()} ).`),null;const t=this.currentQueryIndex;return this.currentQueryIndex+=2,this.queryOffsets.set(e,t),t}resolveQueriesAsync(){return nn(this,null,function*(){if(!this.trackTimestamp||this.currentQueryIndex===0||this.isDisposed)return this.lastValue;if(this.pendingResolve)return this.pendingResolve;this.pendingResolve=this._resolveQueries();try{return yield this.pendingResolve}finally{this.pendingResolve=null}})}_resolveQueries(){return nn(this,null,function*(){if(this.isDisposed)return this.lastValue;try{if(this.resultBuffer.mapState!=="unmapped")return this.lastValue;const e=new Map(this.queryOffsets),t=this.currentQueryIndex,r=t*8;this.currentQueryIndex=0,this.queryOffsets.clear();const s=this.device.createCommandEncoder();s.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),s.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,r);const a=s.finish();if(this.device.queue.submit([a]),this.resultBuffer.mapState!=="unmapped")return this.lastValue;if(yield this.resultBuffer.mapAsync(GPUMapMode.READ,0,r),this.isDisposed)return this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue;const c=new BigUint64Array(this.resultBuffer.getMappedRange(0,r)),h={},f=[];for(const[x,_]of e){const v=x.match(/^(.*):f(\d+)$/),T=parseInt(v[2]);f.includes(T)===!1&&f.push(T),h[T]===void 0&&(h[T]=0);const w=c[_],P=c[_+1],C=Number(P-w)/1e6;this.timestamps.set(x,C),h[T]+=C}const m=h[f[f.length-1]];return this.resultBuffer.unmap(),this.lastValue=m,this.frames=f,m}catch(e){return e("Error resolving queries:",e),this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue}})}dispose(){return nn(this,null,function*(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{yield this.pendingResolve}catch(e){e("Error waiting for pending resolve:",e)}if(this.resultBuffer&&this.resultBuffer.mapState==="mapped")try{this.resultBuffer.unmap()}catch(e){e("Error unmapping buffer:",e)}this.querySet&&(this.querySet.destroy(),this.querySet=null),this.resolveBuffer&&(this.resolveBuffer.destroy(),this.resolveBuffer=null),this.resultBuffer&&(this.resultBuffer.destroy(),this.resultBuffer=null),this.queryOffsets.clear(),this.pendingResolve=null}})}}class xS extends yA{constructor(e={}){super(e),this.isWebGPUBackend=!0,this.parameters.alpha=e.alpha===void 0?!0:e.alpha,this.parameters.compatibilityMode=e.compatibilityMode===void 0?!1:e.compatibilityMode,this.parameters.requiredLimits=e.requiredLimits===void 0?{}:e.requiredLimits,this.compatibilityMode=this.parameters.compatibilityMode,this.device=null,this.defaultRenderPassdescriptor=null,this.utils=new CU(this),this.attributeUtils=new PU(this),this.bindingUtils=new LU(this),this.pipelineUtils=new IU(this),this.textureUtils=new xU(this),this.occludedResolveCache=new Map}init(e){return nn(this,null,function*(){yield u3(xS.prototype,this,"init").call(this,e);const t=this.parameters;let r;if(t.device===void 0){const s={powerPreference:t.powerPreference,featureLevel:t.compatibilityMode?"compatibility":void 0},a=typeof navigator!="undefined"?yield navigator.gpu.requestAdapter(s):null;if(a===null)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const c=Object.values(mS),h=[];for(const m of c)a.features.has(m)&&h.push(m);const f={requiredFeatures:h,requiredLimits:t.requiredLimits};r=yield a.requestDevice(f)}else r=t.device;r.lost.then(s=>{const a={api:"WebGPU",message:s.message||"Unknown reason",reason:s.reason||null,originalEvent:s};e.onDeviceLost(a)}),this.device=r,this.trackTimestamp=this.trackTimestamp&&this.hasFeature(mS.TimestampQuery),this.updateSize()})}get context(){const e=this.renderer.getCanvasTarget(),t=this.get(e);let r=t.context;if(r===void 0){const s=this.parameters;e.isDefaultCanvasTarget===!0&&s.context!==void 0?r=s.context:r=e.domElement.getContext("webgpu"),"setAttribute"in e.domElement&&e.domElement.setAttribute("data-engine",`three.js r${d.UZH} webgpu`);const a=s.alpha?"premultiplied":"opaque",c=s.outputType===d.cLu?"extended":"standard";r.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:a,toneMapping:{mode:c}}),t.context=r}return r}get coordinateSystem(){return d.JCZ}getArrayBufferAsync(e){return nn(this,null,function*(){return yield this.attributeUtils.getArrayBufferAsync(e)})}getContext(){return this.context}_getDefaultRenderPassDescriptor(){const e=this.renderer,t=e.getCanvasTarget(),r=this.get(t),s=e.currentSamples;let a=r.descriptor;if(a===void 0||r.samples!==s){a={colorAttachments:[{view:null}]},(e.depth===!0||e.stencil===!0)&&(a.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(e.depth,e.stencil).createView()});const h=a.colorAttachments[0];s>0?h.view=this.textureUtils.getColorBuffer().createView():h.resolveTarget=void 0,r.descriptor=a,r.samples=s}const c=a.colorAttachments[0];return s>0?c.resolveTarget=this.context.getCurrentTexture().createView():c.view=this.context.getCurrentTexture().createView(),a}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.image.depth>1&&e.camera.isArrayCamera}_getRenderPassDescriptor(e,t={}){const r=e.renderTarget,s=this.get(r);let a=s.descriptors;(a===void 0||s.width!==r.width||s.height!==r.height||s.samples!==r.samples)&&(a={},s.descriptors=a);const c=e.getCacheKey();let h=a[c];if(h===void 0){const m=e.textures,x=[];let _;const v=this._isRenderCameraDepthArray(e);for(let T=0;T<m.length;T++){const w=this.get(m[T]),P={label:`colorAttachment_${T}`,baseMipLevel:e.activeMipmapLevel,mipLevelCount:1,baseArrayLayer:e.activeCubeFace,arrayLayerCount:1,dimension:fr.TwoD};if(r.isRenderTarget3D)_=e.activeCubeFace,P.baseArrayLayer=0,P.dimension=fr.ThreeD,P.depthOrArrayLayers=m[T].image.depth;else if(r.isRenderTarget&&m[T].image.depth>1)if(v===!0){const C=e.camera.cameras;for(let E=0;E<C.length;E++){const D=To(rr({},P),{baseArrayLayer:E,arrayLayerCount:1,dimension:fr.TwoD}),F=w.texture.createView(D);x.push({view:F,resolveTarget:void 0,depthSlice:void 0})}}else P.dimension=fr.TwoDArray,P.depthOrArrayLayers=m[T].image.depth;if(v!==!0){const C=w.texture.createView(P);let E,D;w.msaaTexture!==void 0?(E=w.msaaTexture.createView(),D=C):(E=C,D=void 0),x.push({view:E,resolveTarget:D,depthSlice:_})}}if(h={textureViews:x},e.depth){const T=this.get(e.depthTexture),w={};e.depthTexture.isArrayTexture&&(w.dimension=fr.TwoD,w.arrayLayerCount=1,w.baseArrayLayer=e.activeCubeFace),h.depthStencilView=T.texture.createView(w)}a[c]=h,s.width=r.width,s.height=r.height,s.samples=r.samples,s.activeMipmapLevel=e.activeMipmapLevel,s.activeCubeFace=e.activeCubeFace}const f={colorAttachments:[]};for(let m=0;m<h.textureViews.length;m++){const x=h.textureViews[m];let _={r:0,g:0,b:0,a:1};m===0&&t.clearValue&&(_=t.clearValue),f.colorAttachments.push({view:x.view,depthSlice:x.depthSlice,resolveTarget:x.resolveTarget,loadOp:t.loadOp||di.Load,storeOp:t.storeOp||ds.Store,clearValue:_})}return h.depthStencilView&&(f.depthStencilAttachment={view:h.depthStencilView}),f}beginRender(e){const t=this.get(e),r=this.device,s=e.occlusionQueryCount;let a;s>0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,a=r.createQuerySet({type:"occlusion",count:s,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=a,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(s),t.lastOcclusionObject=null);let c;e.textures===null?c=this._getDefaultRenderPassDescriptor():c=this._getRenderPassDescriptor(e,{loadOp:di.Load}),this.initTimestampQuery(d.eS_.RENDER,this.getTimestampUID(e),c),c.occlusionQuerySet=a;const h=c.depthStencilAttachment;if(e.textures!==null){const m=c.colorAttachments;for(let x=0;x<m.length;x++){const _=m[x];e.clearColor?(_.clearValue=x===0?e.clearColorValue:{r:0,g:0,b:0,a:1},_.loadOp=di.Clear):_.loadOp=di.Load,_.storeOp=ds.Store}}else{const m=c.colorAttachments[0];e.clearColor?(m.clearValue=e.clearColorValue,m.loadOp=di.Clear):m.loadOp=di.Load,m.storeOp=ds.Store}e.depth&&(e.clearDepth?(h.depthClearValue=e.clearDepthValue,h.depthLoadOp=di.Clear):h.depthLoadOp=di.Load,h.depthStoreOp=ds.Store),e.stencil&&(e.clearStencil?(h.stencilClearValue=e.clearStencilValue,h.stencilLoadOp=di.Clear):h.stencilLoadOp=di.Load,h.stencilStoreOp=ds.Store);const f=r.createCommandEncoder({label:"renderContext_"+e.id});if(this._isRenderCameraDepthArray(e)===!0){const m=e.camera.cameras;!t.layerDescriptors||t.layerDescriptors.length!==m.length?this._createDepthLayerDescriptors(e,t,c,m):this._updateDepthLayerDescriptors(e,t,m),t.bundleEncoders=[],t.bundleSets=[];for(let x=0;x<m.length;x++){const _=this.pipelineUtils.createBundleEncoder(e,"renderBundleArrayCamera_"+x),v={attributes:{},bindingGroups:[],pipeline:null,index:null};t.bundleEncoders.push(_),t.bundleSets.push(v)}t.currentPass=null}else{const m=f.beginRenderPass(c);t.currentPass=m,e.viewport&&this.updateViewport(e),e.scissor&&this.updateScissor(e)}t.descriptor=c,t.encoder=f,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.renderBundles=[]}_createDepthLayerDescriptors(e,t,r,s){const a=r.depthStencilAttachment;t.layerDescriptors=[];const c=this.get(e.depthTexture);c.viewCache||(c.viewCache=[]);for(let h=0;h<s.length;h++){const f=To(rr({},r),{colorAttachments:[To(rr({},r.colorAttachments[0]),{view:r.colorAttachments[h].view})]});if(r.depthStencilAttachment){const m=h;c.viewCache[m]||(c.viewCache[m]=c.texture.createView({dimension:fr.TwoD,baseArrayLayer:h,arrayLayerCount:1})),f.depthStencilAttachment={view:c.viewCache[m],depthLoadOp:a.depthLoadOp||di.Clear,depthStoreOp:a.depthStoreOp||ds.Store,depthClearValue:a.depthClearValue||1},e.stencil&&(f.depthStencilAttachment.stencilLoadOp=a.stencilLoadOp,f.depthStencilAttachment.stencilStoreOp=a.stencilStoreOp,f.depthStencilAttachment.stencilClearValue=a.stencilClearValue)}else f.depthStencilAttachment=rr({},a);t.layerDescriptors.push(f)}}_updateDepthLayerDescriptors(e,t,r){for(let s=0;s<r.length;s++){const a=t.layerDescriptors[s];if(a.depthStencilAttachment){const c=a.depthStencilAttachment;e.depth&&(e.clearDepth?(c.depthClearValue=e.clearDepthValue,c.depthLoadOp=di.Clear):c.depthLoadOp=di.Load),e.stencil&&(e.clearStencil?(c.stencilClearValue=e.clearStencilValue,c.stencilLoadOp=di.Clear):c.stencilLoadOp=di.Load)}}}finishRender(e){const t=this.get(e),r=e.occlusionQueryCount;t.renderBundles.length>0&&t.currentPass.executeBundles(t.renderBundles),r>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();const s=t.encoder;if(this._isRenderCameraDepthArray(e)===!0){const a=[];for(let c=0;c<t.bundleEncoders.length;c++){const h=t.bundleEncoders[c];a.push(h.finish())}for(let c=0;c<t.layerDescriptors.length;c++)if(c<a.length){const h=t.layerDescriptors[c],f=s.beginRenderPass(h);if(e.viewport){const{x:m,y:x,width:_,height:v,minDepth:T,maxDepth:w}=e.viewportValue;f.setViewport(m,x,_,v,T,w)}if(e.scissor){const{x:m,y:x,width:_,height:v}=e.scissorValue;f.setScissorRect(m,x,_,v)}f.executeBundles([a[c]]),f.end()}}else t.currentPass&&t.currentPass.end();if(r>0){const a=r*8;let c=this.occludedResolveCache.get(a);c===void 0&&(c=this.device.createBuffer({size:a,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(a,c));const h=this.device.createBuffer({size:a,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,r,c,0),t.encoder.copyBufferToBuffer(c,0,h,0,a),t.occlusionQueryBuffer=h,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),e.textures!==null){const a=e.textures;for(let c=0;c<a.length;c++){const h=a[c];h.generateMipmaps===!0&&this.textureUtils.generateMipmaps(h)}}}isOccluded(e,t){const r=this.get(e);return r.occluded&&r.occluded.has(t)}resolveOccludedAsync(e){return nn(this,null,function*(){const t=this.get(e),{currentOcclusionQueryBuffer:r,currentOcclusionQueryObjects:s}=t;if(r&&s){const a=new WeakSet;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueryBuffer=null,yield r.mapAsync(GPUMapMode.READ);const c=r.getMappedRange(),h=new BigUint64Array(c);for(let f=0;f<s.length;f++)h[f]===BigInt(0)&&a.add(s[f]);r.destroy(),t.occluded=a}})}updateViewport(e){const{currentPass:t}=this.get(e),{x:r,y:s,width:a,height:c,minDepth:h,maxDepth:f}=e.viewportValue;t.setViewport(r,s,a,c,h,f)}updateScissor(e){const{currentPass:t}=this.get(e),{x:r,y:s,width:a,height:c}=e.scissorValue;t.setScissorRect(r,s,a,c)}getClearColor(){const e=super.getClearColor();return this.renderer.alpha===!0&&(e.r*=e.a,e.g*=e.a,e.b*=e.a),e}clear(e,t,r,s=null){const a=this.device,c=this.renderer;let h=[],f,m,x,_;if(e){const w=this.getClearColor();m={r:w.r,g:w.g,b:w.b,a:w.a}}if(s===null){x=c.depth,_=c.stencil;const w=this._getDefaultRenderPassDescriptor();if(e){h=w.colorAttachments;const P=h[0];P.clearValue=m,P.loadOp=di.Clear,P.storeOp=ds.Store}(x||_)&&(f=w.depthStencilAttachment)}else{x=s.depth,_=s.stencil;const w={loadOp:e?di.Clear:di.Load,clearValue:e?m:void 0};x&&(w.depthLoadOp=t?di.Clear:di.Load,w.depthClearValue=t?c.getClearDepth():void 0,w.depthStoreOp=ds.Store),_&&(w.stencilLoadOp=r?di.Clear:di.Load,w.stencilClearValue=r?c.getClearStencil():void 0,w.stencilStoreOp=ds.Store);const P=this._getRenderPassDescriptor(s,w);h=P.colorAttachments,f=P.depthStencilAttachment}x&&f&&(t?(f.depthLoadOp=di.Clear,f.depthClearValue=c.getClearDepth(),f.depthStoreOp=ds.Store):(f.depthLoadOp=di.Load,f.depthStoreOp=ds.Store)),_&&f&&(r?(f.stencilLoadOp=di.Clear,f.stencilClearValue=c.getClearStencil(),f.stencilStoreOp=ds.Store):(f.stencilLoadOp=di.Load,f.stencilStoreOp=ds.Store));const v=a.createCommandEncoder({label:"clear"});v.beginRenderPass({colorAttachments:h,depthStencilAttachment:f}).end(),a.queue.submit([v.finish()])}beginCompute(e){const t=this.get(e),r={label:"computeGroup_"+e.id};this.initTimestampQuery(d.eS_.COMPUTE,this.getTimestampUID(e),r),t.cmdEncoderGPU=this.device.createCommandEncoder({label:"computeGroup_"+e.id}),t.passEncoderGPU=t.cmdEncoderGPU.beginComputePass(r)}compute(e,t,r,s,a=null){const c=this.get(t),{passEncoderGPU:h}=this.get(e),f=this.get(s).pipeline;this.pipelineUtils.setPipeline(h,f);for(let m=0,x=r.length;m<x;m++){const _=r[m],v=this.get(_);h.setBindGroup(m,v.group)}if(a===null&&(a=t.count),a&&typeof a=="object"&&a.isIndirectStorageBufferAttribute){const m=this.get(a).buffer;h.dispatchWorkgroupsIndirect(m,0);return}if(typeof a=="number"){const m=a;if(c.dispatchSize===void 0||c.count!==m){c.dispatchSize=[0,1,1],c.count=m;const x=t.workgroupSize;let _=x[0];for(let w=1;w<x.length;w++)_*=x[w];const v=Math.ceil(m/_),T=this.device.limits.maxComputeWorkgroupsPerDimension;a=[v,1,1],v>T&&(a[0]=Math.min(v,T),a[1]=Math.ceil(v/T)),c.dispatchSize=a}a=c.dispatchSize}h.dispatchWorkgroups(a[0],a[1]||1,a[2]||1)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}draw(e,t){const{object:r,material:s,context:a,pipeline:c}=e,h=e.getBindings(),f=this.get(a),m=this.get(c),x=m.pipeline;if(m.error===!0)return;const _=e.getIndex(),v=_!==null,T=e.getDrawParameters();if(T===null)return;const w=(C,E)=>{this.pipelineUtils.setPipeline(C,x),E.pipeline=x;const D=E.bindingGroups;for(let W=0,K=h.length;W<K;W++){const U=h[W],j=this.get(U);D[U.index]!==U.id&&(C.setBindGroup(U.index,j.group),D[U.index]=U.id)}if(v===!0&&E.index!==_){const W=this.get(_).buffer,K=_.array instanceof Uint16Array?Wd.Uint16:Wd.Uint32;C.setIndexBuffer(W,K),E.index=_}const F=e.getVertexBuffers();for(let W=0,K=F.length;W<K;W++){const U=F[W];if(E.attributes[W]!==U){const j=this.get(U).buffer;C.setVertexBuffer(W,j),E.attributes[W]=U}}a.stencil===!0&&s.stencilWrite===!0&&f.currentStencilRef!==s.stencilRef&&(C.setStencilReference(s.stencilRef),f.currentStencilRef=s.stencilRef)},P=(C,E)=>{if(w(C,E),r.isBatchedMesh===!0){const D=r._multiDrawStarts,F=r._multiDrawCounts,W=r._multiDrawCount,K=r._multiDrawInstances;K!==null&&(0,d.O4K)("WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");for(let U=0;U<W;U++){const j=K?K[U]:1,oe=j>1?0:U;v===!0?C.drawIndexed(F[U],j,D[U]/_.array.BYTES_PER_ELEMENT,0,oe):C.draw(F[U],j,D[U],oe),t.update(r,F[U],j)}}else if(v===!0){const{vertexCount:D,instanceCount:F,firstVertex:W}=T,K=e.getIndirect();if(K!==null){const U=this.get(K).buffer;C.drawIndexedIndirect(U,0)}else C.drawIndexed(D,F,W,0,0);t.update(r,D,F)}else{const{vertexCount:D,instanceCount:F,firstVertex:W}=T,K=e.getIndirect();if(K!==null){const U=this.get(K).buffer;C.drawIndirect(U,0)}else C.draw(D,F,W,0);t.update(r,D,F)}};if(e.camera.isArrayCamera&&e.camera.cameras.length>0){const C=this.get(e.camera),E=e.camera.cameras,D=e.getBindingGroup("cameraIndex");if(C.indexesGPU===void 0||C.indexesGPU.length!==E.length){const W=this.get(D),K=[],U=new Uint32Array([0,0,0,0]);for(let j=0,oe=E.length;j<oe;j++){U[0]=j;const k=this.bindingUtils.createBindGroupIndex(U,W.layout);K.push(k)}C.indexesGPU=K}const F=this.renderer.getPixelRatio();for(let W=0,K=E.length;W<K;W++){const U=E[W];if(r.layers.test(U.layers)){const j=U.viewport;let oe=f.currentPass,k=f.currentSets;if(f.bundleEncoders){const O=f.bundleEncoders[W],le=f.bundleSets[W];oe=O,k=le}j&&oe.setViewport(Math.floor(j.x*F),Math.floor(j.y*F),Math.floor(j.width*F),Math.floor(j.height*F),a.viewportValue.minDepth,a.viewportValue.maxDepth),D&&C.indexesGPU&&(oe.setBindGroup(D.index,C.indexesGPU[W]),k.bindingGroups[D.index]=D.id),P(oe,k)}}}else if(f.currentPass){if(f.occlusionQuerySet!==void 0){const C=f.lastOcclusionObject;C!==r&&(C!==null&&C.occlusionTest===!0&&(f.currentPass.endOcclusionQuery(),f.occlusionQueryIndex++),r.occlusionTest===!0&&(f.currentPass.beginOcclusionQuery(f.occlusionQueryIndex),f.occlusionQueryObjects[f.occlusionQueryIndex]=r),f.lastOcclusionObject=r)}P(f.currentPass,f.currentSets)}}needsRenderUpdate(e){const t=this.get(e),{object:r,material:s}=e,a=this.utils,c=a.getSampleCountRenderContext(e.context),h=a.getCurrentColorSpace(e.context),f=a.getCurrentColorFormat(e.context),m=a.getCurrentDepthStencilFormat(e.context),x=a.getPrimitiveTopology(r,s);let _=!1;return(t.material!==s||t.materialVersion!==s.version||t.transparent!==s.transparent||t.blending!==s.blending||t.premultipliedAlpha!==s.premultipliedAlpha||t.blendSrc!==s.blendSrc||t.blendDst!==s.blendDst||t.blendEquation!==s.blendEquation||t.blendSrcAlpha!==s.blendSrcAlpha||t.blendDstAlpha!==s.blendDstAlpha||t.blendEquationAlpha!==s.blendEquationAlpha||t.colorWrite!==s.colorWrite||t.depthWrite!==s.depthWrite||t.depthTest!==s.depthTest||t.depthFunc!==s.depthFunc||t.stencilWrite!==s.stencilWrite||t.stencilFunc!==s.stencilFunc||t.stencilFail!==s.stencilFail||t.stencilZFail!==s.stencilZFail||t.stencilZPass!==s.stencilZPass||t.stencilFuncMask!==s.stencilFuncMask||t.stencilWriteMask!==s.stencilWriteMask||t.side!==s.side||t.alphaToCoverage!==s.alphaToCoverage||t.sampleCount!==c||t.colorSpace!==h||t.colorFormat!==f||t.depthStencilFormat!==m||t.primitiveTopology!==x||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.material=s,t.materialVersion=s.version,t.transparent=s.transparent,t.blending=s.blending,t.premultipliedAlpha=s.premultipliedAlpha,t.blendSrc=s.blendSrc,t.blendDst=s.blendDst,t.blendEquation=s.blendEquation,t.blendSrcAlpha=s.blendSrcAlpha,t.blendDstAlpha=s.blendDstAlpha,t.blendEquationAlpha=s.blendEquationAlpha,t.colorWrite=s.colorWrite,t.depthWrite=s.depthWrite,t.depthTest=s.depthTest,t.depthFunc=s.depthFunc,t.stencilWrite=s.stencilWrite,t.stencilFunc=s.stencilFunc,t.stencilFail=s.stencilFail,t.stencilZFail=s.stencilZFail,t.stencilZPass=s.stencilZPass,t.stencilFuncMask=s.stencilFuncMask,t.stencilWriteMask=s.stencilWriteMask,t.side=s.side,t.alphaToCoverage=s.alphaToCoverage,t.sampleCount=c,t.colorSpace=h,t.colorFormat=f,t.depthStencilFormat=m,t.primitiveTopology=x,t.clippingContextCacheKey=e.clippingContextCacheKey,_=!0),_}getRenderCacheKey(e){const{object:t,material:r}=e,s=this.utils,a=e.context,c=t.isMesh&&t.matrixWorld.determinant()<0;return[r.transparent,r.blending,r.premultipliedAlpha,r.blendSrc,r.blendDst,r.blendEquation,r.blendSrcAlpha,r.blendDstAlpha,r.blendEquationAlpha,r.colorWrite,r.depthWrite,r.depthTest,r.depthFunc,r.stencilWrite,r.stencilFunc,r.stencilFail,r.stencilZFail,r.stencilZPass,r.stencilFuncMask,r.stencilWriteMask,r.side,c,s.getSampleCountRenderContext(a),s.getCurrentColorSpace(a),s.getCurrentColorFormat(a),s.getCurrentDepthStencilFormat(a),s.getPrimitiveTopology(t,r),e.getGeometryCacheKey(),e.clippingContextCacheKey].join()}updateSampler(e){return this.textureUtils.updateSampler(e)}createDefaultTexture(e){return 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,t=!1){this.textureUtils.destroyTexture(e,t)}copyTextureToBuffer(e,t,r,s,a,c){return nn(this,null,function*(){return this.textureUtils.copyTextureToBuffer(e,t,r,s,a,c)})}initTimestampQuery(e,t,r){if(!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new DU(this.device,e,2048));const s=this.timestampQueryPool[e],a=s.allocateQueriesForContext(t);r.timestampWrites={querySet:s.querySet,beginningOfPassWriteIndex:a,endOfPassWriteIndex:a+1}}createNodeBuilder(e,t){return new EU(e,t)}createProgram(e){const t=this.get(e);t.module={module:this.device.createShaderModule({code:e.code,label:e.stage+(e.name!==""?`_${e.name}`:"")}),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:{},bindingGroups:[],pipeline:null,index:null},t.currentPass=this.pipelineUtils.createBundleEncoder(e)}finishBundle(e,t){const r=this.get(e),a=r.currentPass.finish();this.get(t).bundleGPU=a,r.currentSets=r._currentSets,r.currentPass=r._currentPass}addBundle(e,t){this.get(e).renderBundles.push(this.get(t).bundleGPU)}createBindings(e,t,r,s){this.bindingUtils.createBindings(e,t,r,s)}updateBindings(e,t,r,s){this.bindingUtils.createBindings(e,t,r,s)}updateBinding(e){this.bindingUtils.updateBinding(e)}createIndexAttribute(e){let t=GPUBufferUsage.INDEX|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST;(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(t|=GPUBufferUsage.STORAGE),this.attributeUtils.createAttribute(e,t)}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)}createIndirectStorageAttribute(e){this.attributeUtils.createAttribute(e,GPUBufferUsage.STORAGE|GPUBufferUsage.INDIRECT|GPUBufferUsage.COPY_SRC|GPUBufferUsage.COPY_DST)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}updateSize(){this.delete(this.renderer.getCanvasTarget())}getMaxAnisotropy(){return 16}hasFeature(e){return NA[e]!==void 0&&(e=NA[e]),this.device.features.has(e)}copyTextureToTexture(e,t,r=null,s=null,a=0,c=0){let h=0,f=0,m=0,x=0,_=0,v=0,T=e.image.width,w=e.image.height,P=1;r!==null&&(r.isBox3===!0?(x=r.min.x,_=r.min.y,v=r.min.z,T=r.max.x-r.min.x,w=r.max.y-r.min.y,P=r.max.z-r.min.z):(x=r.min.x,_=r.min.y,T=r.max.x-r.min.x,w=r.max.y-r.min.y,P=1)),s!==null&&(h=s.x,f=s.y,m=s.z||0);const C=this.device.createCommandEncoder({label:"copyTextureToTexture_"+e.id+"_"+t.id}),E=this.get(e).texture,D=this.get(t).texture;C.copyTextureToTexture({texture:E,mipLevel:a,origin:{x,y:_,z:v}},{texture:D,mipLevel:c,origin:{x:h,y:f,z:m}},[T,w,P]),this.device.queue.submit([C.finish()]),c===0&&t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}copyFramebufferToTexture(e,t,r){const s=this.get(t);let a=null;t.renderTarget?e.isDepthTexture?a=this.get(t.depthTexture).texture:a=this.get(t.textures[0]).texture:e.isDepthTexture?a=this.textureUtils.getDepthBuffer(t.depth,t.stencil):a=this.context.getCurrentTexture();const c=this.get(e).texture;if(a.format!==c.format){(0,d.vUy)("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",a.format,c.format);return}let h;if(s.currentPass?(s.currentPass.end(),h=s.encoder):h=this.device.createCommandEncoder({label:"copyFramebufferToTexture_"+e.id}),h.copyTextureToTexture({texture:a,origin:[r.x,r.y,0]},{texture:c},[r.z,r.w]),e.generateMipmaps&&this.textureUtils.generateMipmaps(e,h),s.currentPass){const{descriptor:f}=s;for(let m=0;m<f.colorAttachments.length;m++)f.colorAttachments[m].loadOp=di.Load;t.depth&&(f.depthStencilAttachment.depthLoadOp=di.Load),t.stencil&&(f.depthStencilAttachment.stencilLoadOp=di.Load),s.currentPass=h.beginRenderPass(f),s.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.viewport&&this.updateViewport(t),t.scissor&&this.updateScissor(t)}else this.device.queue.submit([h.finish()])}dispose(){this.textureUtils.dispose()}}class UU extends d.PMe{constructor(e,t,r,s,a,c){super(e,t,r,s,a,c),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}}class FU extends d.PMe{constructor(e,t,r,s,a,c){super(e,t,r,s,a,c),this.aspect=null}copy(e,t){return super.copy(e,t),this.aspect=e.aspect,this}}class BU extends nA{constructor(){super(),this.addMaterial(uR,"MeshPhongMaterial"),this.addMaterial(IM,"MeshStandardMaterial"),this.addMaterial(i2,"MeshPhysicalMaterial"),this.addMaterial(c2,"MeshToonMaterial"),this.addMaterial(iR,"MeshBasicMaterial"),this.addMaterial(cR,"MeshLambertMaterial"),this.addMaterial(QC,"MeshNormalMaterial"),this.addMaterial(u2,"MeshMatcapMaterial"),this.addMaterial($C,"LineBasicMaterial"),this.addMaterial(XC,"LineDashedMaterial"),this.addMaterial(m2,"PointsMaterial"),this.addMaterial(UM,"SpriteMaterial"),this.addMaterial(y2,"ShadowMaterial"),this.addLight(OL,d.cek),this.addLight(pD,d.Ox3),this.addLight(mD,d.T_f),this.addLight(nS,d.PMe),this.addLight(yD,d.Mig),this.addLight(bD,d.vmT),this.addLight(vD,d.lk7),this.addLight(gD,UU),this.addLight(_D,FU),this.addToneMapping(ow,d.EoG),this.addToneMapping(aw,d.CdI),this.addToneMapping(cw,d.YGz),this.addToneMapping(lw,d.LY2),this.addToneMapping(uw,d.Bgp),this.addToneMapping(hw,d.ORg)}}class OU extends zD{constructor(e={}){let t;e.forceWebGL?t=MA:(t=xS,e.getFallback=()=>((0,d.ZK6)("WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new MA(e)));const r=new t(e);super(r,e),this.library=new BU,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}}class j4 extends null{constructor(){super(),this.isBundleGroup=!0,this.type="BundleGroup",this.static=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}}class X4{constructor(e,t=At(0,0,1,1)){this.renderer=e,this.outputNode=t,this.outputColorTransform=!0,this.needsUpdate=!0;const r=new Gi;r.name="PostProcessing",this._quadMesh=new fm(r),this._quadMesh.name="Post-Processing",this._context=null}render(){const e=this.renderer;this._update(),this._context.onBeforePostProcessing!==null&&this._context.onBeforePostProcessing();const t=e.toneMapping,r=e.outputColorSpace;e.toneMapping=NoToneMapping,e.outputColorSpace=ColorManagement.workingColorSpace;const s=e.xr.enabled;e.xr.enabled=!1,this._quadMesh.render(e),e.xr.enabled=s,e.toneMapping=t,e.outputColorSpace=r,this._context.onAfterPostProcessing!==null&&this._context.onAfterPostProcessing()}get context(){return this._context}dispose(){this._quadMesh.material.dispose()}_update(){if(this.needsUpdate===!0){const e=this.renderer,t=e.toneMapping,r=e.outputColorSpace,s={postProcessing:this,onBeforePostProcessing:null,onAfterPostProcessing:null};let a=this.outputNode;this.outputColorTransform===!0?(a=a.context(s),a=Vr(a,t,r)):(s.toneMapping=t,s.outputColorSpace=r,a=a.context(s)),this._context=s,this._quadMesh.material.fragmentNode=a,this._quadMesh.material.needsUpdate=!0,this.needsUpdate=!1}}renderAsync(){return nn(this,null,function*(){warnOnce('PostProcessing: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),yield this.renderer.init(),this.render()})}}class q4 extends null{constructor(e=1,t=1){super(),this.image={width:e,height:t},this.magFilter=LinearFilter,this.minFilter=LinearFilter,this.isStorageTexture=!0,this.mipmapsAutoUpdate=!0}setSize(e,t){(this.image.width!==e||this.image.height!==t)&&(this.image.width=e,this.image.height=t,this.dispose())}}class K4 extends null{constructor(e=1,t=1,r=1){super(),this.isArrayTexture=!1,this.image={width:e,height:t,depth:r},this.magFilter=LinearFilter,this.minFilter=LinearFilter,this.wrapR=ClampToEdgeWrapping,this.isStorageTexture=!0,this.is3DTexture=!0}setSize(e,t,r){(this.image.width!==e||this.image.height!==t||this.image.depth!==r)&&(this.image.width=e,this.image.height=t,this.image.depth=r,this.dispose())}}class Z4 extends null{constructor(e=1,t=1,r=1){super(),this.isArrayTexture=!0,this.image={width:e,height:t,depth:r},this.magFilter=LinearFilter,this.minFilter=LinearFilter,this.isStorageTexture=!0}setSize(e,t,r){(this.image.width!==e||this.image.height!==t||this.image.depth!==r)&&(this.image.width=e,this.image.height=t,this.image.depth=r,this.dispose())}}class Y4 extends null{constructor(e,t){super(e,t,Uint32Array),this.isIndirectStorageBufferAttribute=!0}}class kU extends null{constructor(e){super(e),this.textures={},this.nodes={}}load(e,t,r,s){const a=new FileLoader(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,c=>{try{t(this.parse(JSON.parse(c)))}catch(h){s?s(h):error(h),this.manager.itemError(e)}},r,s)}parseNodes(e){const t={};if(e!==void 0){for(const s of e){const{uuid:a,type:c}=s;t[a]=this.createNodeFromType(c),t[a].uuid=a}const r={nodes:t,textures:this.textures};for(const s of e)s.meta=r,t[s.uuid].deserialize(s),delete s.meta}return t}parse(e){const t=this.createNodeFromType(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}setNodes(e){return this.nodes=e,this}createNodeFromType(e){return this.nodes[e]===void 0?(error("NodeLoader: Node type not found:",e),G()):Oe(new this.nodes[e])}}class VU extends null{constructor(e){super(e),this.nodes={},this.nodeMaterials={}}parse(e){const t=super.parse(e),r=this.nodes,s=e.inputNodes;for(const a in s){const c=s[a];t[a]=r[c]}return t}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}createMaterialFromType(e){const t=this.nodeMaterials[e];return t!==void 0?new t:super.createMaterialFromType(e)}}class Q4 extends null{constructor(e){super(e),this.nodes={},this.nodeMaterials={},this._nodesJSON=null}setNodes(e){return this.nodes=e,this}setNodeMaterials(e){return this.nodeMaterials=e,this}parse(e,t){this._nodesJSON=e.nodes;const r=super.parse(e,t);return this._nodesJSON=null,r}parseNodes(e,t){if(e!==void 0){const r=new kU;return r.setNodes(this.nodes),r.setTextures(t),r.parseNodes(e)}return{}}parseMaterials(e,t){const r={};if(e!==void 0){const s=this.parseNodes(this._nodesJSON,t),a=new VU;a.setTextures(t),a.setNodes(s),a.setNodeMaterials(this.nodeMaterials);for(let c=0,h=e.length;c<h;c++){const f=e[c];r[f.uuid]=a.parse(f)}}return r}}class J4 extends null{constructor(){super(),this.isClippingGroup=!0,this.clippingPlanes=[],this.enabled=!0,this.clipIntersection=!1,this.clipShadows=!1}}const _S={type:"change"},yS={type:"start"},bS={type:"end"},BA=1e-6,fi={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4},Qx=new d.FM8,Ml=new d.FM8,zU=new d.Pa4,Jx=new d.Pa4,vS=new d.Pa4,$d=new d._fP,OA=new d.Pa4,e_=new d.Pa4,SS=new d.Pa4,t_=new d.Pa4;class GU extends d.ZXd{constructor(e,t=null){super(e,t),this.screen={left:0,top:0,width:0,height:0},this.rotateSpeed=1,this.zoomSpeed=1.2,this.panSpeed=.3,this.noRotate=!1,this.noZoom=!1,this.noPan=!1,this.staticMoving=!1,this.dynamicDampingFactor=.2,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.keys=["KeyA","KeyS","KeyD"],this.mouseButtons={LEFT:d.RsA.ROTATE,MIDDLE:d.RsA.DOLLY,RIGHT:d.RsA.PAN},this.target=new d.Pa4,this.state=fi.NONE,this.keyState=fi.NONE,this._lastPosition=new d.Pa4,this._lastZoom=1,this._touchZoomDistanceStart=0,this._touchZoomDistanceEnd=0,this._lastAngle=0,this._eye=new d.Pa4,this._movePrev=new d.FM8,this._moveCurr=new d.FM8,this._lastAxis=new d.Pa4,this._zoomStart=new d.FM8,this._zoomEnd=new d.FM8,this._panStart=new d.FM8,this._panEnd=new d.FM8,this._pointers=[],this._pointerPositions={},this._onPointerMove=HU.bind(this),this._onPointerDown=WU.bind(this),this._onPointerUp=$U.bind(this),this._onPointerCancel=jU.bind(this),this._onContextMenu=JU.bind(this),this._onMouseWheel=QU.bind(this),this._onKeyDown=qU.bind(this),this._onKeyUp=XU.bind(this),this._onTouchStart=eF.bind(this),this._onTouchMove=tF.bind(this),this._onTouchEnd=nF.bind(this),this._onMouseDown=KU.bind(this),this._onMouseMove=ZU.bind(this),this._onMouseUp=YU.bind(this),this._target0=this.target.clone(),this._position0=this.object.position.clone(),this._up0=this.object.up.clone(),this._zoom0=this.object.zoom,t!==null&&(this.connect(t),this.handleResize()),this.update()}connect(e){super.connect(e),window.addEventListener("keydown",this._onKeyDown),window.addEventListener("keyup",this._onKeyUp),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerCancel),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="none"}disconnect(){window.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("keyup",this._onKeyUp),this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerCancel),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}handleResize(){const e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}update(){this._eye.subVectors(this.object.position,this.target),this.noRotate||this._rotateCamera(),this.noZoom||this._zoomCamera(),this.noPan||this._panCamera(),this.object.position.addVectors(this.target,this._eye),this.object.isPerspectiveCamera?(this._checkDistances(),this.object.lookAt(this.target),this._lastPosition.distanceToSquared(this.object.position)>BA&&(this.dispatchEvent(_S),this._lastPosition.copy(this.object.position))):this.object.isOrthographicCamera?(this.object.lookAt(this.target),(this._lastPosition.distanceToSquared(this.object.position)>BA||this._lastZoom!==this.object.zoom)&&(this.dispatchEvent(_S),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom)):console.warn("THREE.TrackballControls: Unsupported camera type.")}reset(){this.state=fi.NONE,this.keyState=fi.NONE,this.target.copy(this._target0),this.object.position.copy(this._position0),this.object.up.copy(this._up0),this.object.zoom=this._zoom0,this.object.updateProjectionMatrix(),this._eye.subVectors(this.object.position,this.target),this.object.lookAt(this.target),this.dispatchEvent(_S),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom}_panCamera(){if(Ml.copy(this._panEnd).sub(this._panStart),Ml.lengthSq()){if(this.object.isOrthographicCamera){const e=(this.object.right-this.object.left)/this.object.zoom/this.domElement.clientWidth,t=(this.object.top-this.object.bottom)/this.object.zoom/this.domElement.clientWidth;Ml.x*=e,Ml.y*=t}Ml.multiplyScalar(this._eye.length()*this.panSpeed),Jx.copy(this._eye).cross(this.object.up).setLength(Ml.x),Jx.add(zU.copy(this.object.up).setLength(Ml.y)),this.object.position.add(Jx),this.target.add(Jx),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(Ml.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}}_rotateCamera(){t_.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0);let e=t_.length();e?(this._eye.copy(this.object.position).sub(this.target),OA.copy(this._eye).normalize(),e_.copy(this.object.up).normalize(),SS.crossVectors(e_,OA).normalize(),e_.setLength(this._moveCurr.y-this._movePrev.y),SS.setLength(this._moveCurr.x-this._movePrev.x),t_.copy(e_.add(SS)),vS.crossVectors(t_,this._eye).normalize(),e*=this.rotateSpeed,$d.setFromAxisAngle(vS,e),this._eye.applyQuaternion($d),this.object.up.applyQuaternion($d),this._lastAxis.copy(vS),this._lastAngle=e):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),$d.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion($d),this.object.up.applyQuaternion($d)),this._movePrev.copy(this._moveCurr)}_zoomCamera(){let e;this.state===fi.TOUCH_ZOOM_PAN?(e=this._touchZoomDistanceStart/this._touchZoomDistanceEnd,this._touchZoomDistanceStart=this._touchZoomDistanceEnd,this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=d.M8C.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")):(e=1+(this._zoomEnd.y-this._zoomStart.y)*this.zoomSpeed,e!==1&&e>0&&(this.object.isPerspectiveCamera?this._eye.multiplyScalar(e):this.object.isOrthographicCamera?(this.object.zoom=d.M8C.clamp(this.object.zoom/e,this.minZoom,this.maxZoom),this._lastZoom!==this.object.zoom&&this.object.updateProjectionMatrix()):console.warn("THREE.TrackballControls: Unsupported camera type")),this.staticMoving?this._zoomStart.copy(this._zoomEnd):this._zoomStart.y+=(this._zoomEnd.y-this._zoomStart.y)*this.dynamicDampingFactor)}_getMouseOnScreen(e,t){return Qx.set((e-this.screen.left)/this.screen.width,(t-this.screen.top)/this.screen.height),Qx}_getMouseOnCircle(e,t){return Qx.set((e-this.screen.width*.5-this.screen.left)/(this.screen.width*.5),(this.screen.height+2*(this.screen.top-t))/this.screen.width),Qx}_addPointer(e){this._pointers.push(e)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t].pointerId==e.pointerId){this._pointers.splice(t,1);return}}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new d.FM8,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0].pointerId?this._pointers[1]:this._pointers[0];return this._pointerPositions[t.pointerId]}_checkDistances(){(!this.noZoom||!this.noPan)&&(this._eye.lengthSq()>this.maxDistance*this.maxDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.maxDistance)),this._zoomStart.copy(this._zoomEnd)),this._eye.lengthSq()<this.minDistance*this.minDistance&&(this.object.position.addVectors(this.target,this._eye.setLength(this.minDistance)),this._zoomStart.copy(this._zoomEnd)))}}function WU(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i))}function HU(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function $U(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchEnd(i):this._onMouseUp(),this._removePointer(i),this._pointers.length===0&&(this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp)))}function jU(i){this._removePointer(i)}function XU(){this.enabled!==!1&&(this.keyState=fi.NONE,window.addEventListener("keydown",this._onKeyDown))}function qU(i){this.enabled!==!1&&(window.removeEventListener("keydown",this._onKeyDown),this.keyState===fi.NONE&&(i.code===this.keys[fi.ROTATE]&&!this.noRotate?this.keyState=fi.ROTATE:i.code===this.keys[fi.ZOOM]&&!this.noZoom?this.keyState=fi.ZOOM:i.code===this.keys[fi.PAN]&&!this.noPan&&(this.keyState=fi.PAN)))}function KU(i){let e;switch(i.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case d.RsA.DOLLY:this.state=fi.ZOOM;break;case d.RsA.ROTATE:this.state=fi.ROTATE;break;case d.RsA.PAN:this.state=fi.PAN;break;default:this.state=fi.NONE}const t=this.keyState!==fi.NONE?this.keyState:this.state;t===fi.ROTATE&&!this.noRotate?(this._moveCurr.copy(this._getMouseOnCircle(i.pageX,i.pageY)),this._movePrev.copy(this._moveCurr)):t===fi.ZOOM&&!this.noZoom?(this._zoomStart.copy(this._getMouseOnScreen(i.pageX,i.pageY)),this._zoomEnd.copy(this._zoomStart)):t===fi.PAN&&!this.noPan&&(this._panStart.copy(this._getMouseOnScreen(i.pageX,i.pageY)),this._panEnd.copy(this._panStart)),this.dispatchEvent(yS)}function ZU(i){const e=this.keyState!==fi.NONE?this.keyState:this.state;e===fi.ROTATE&&!this.noRotate?(this._movePrev.copy(this._moveCurr),this._moveCurr.copy(this._getMouseOnCircle(i.pageX,i.pageY))):e===fi.ZOOM&&!this.noZoom?this._zoomEnd.copy(this._getMouseOnScreen(i.pageX,i.pageY)):e===fi.PAN&&!this.noPan&&this._panEnd.copy(this._getMouseOnScreen(i.pageX,i.pageY))}function YU(){this.state=fi.NONE,this.dispatchEvent(bS)}function QU(i){if(this.enabled!==!1&&this.noZoom!==!0){switch(i.preventDefault(),i.deltaMode){case 2:this._zoomStart.y-=i.deltaY*.025;break;case 1:this._zoomStart.y-=i.deltaY*.01;break;default:this._zoomStart.y-=i.deltaY*25e-5;break}this.dispatchEvent(yS),this.dispatchEvent(bS)}}function JU(i){this.enabled!==!1&&i.preventDefault()}function eF(i){switch(this._trackPointer(i),this._pointers.length){case 1:this.state=fi.TOUCH_ROTATE,this._moveCurr.copy(this._getMouseOnCircle(this._pointers[0].pageX,this._pointers[0].pageY)),this._movePrev.copy(this._moveCurr);break;default:this.state=fi.TOUCH_ZOOM_PAN;const e=this._pointers[0].pageX-this._pointers[1].pageX,t=this._pointers[0].pageY-this._pointers[1].pageY;this._touchZoomDistanceEnd=this._touchZoomDistanceStart=Math.sqrt(e*e+t*t);const r=(this._pointers[0].pageX+this._pointers[1].pageX)/2,s=(this._pointers[0].pageY+this._pointers[1].pageY)/2;this._panStart.copy(this._getMouseOnScreen(r,s)),this._panEnd.copy(this._panStart);break}this.dispatchEvent(yS)}function tF(i){switch(this._trackPointer(i),this._pointers.length){case 1:this._movePrev.copy(this._moveCurr),this._moveCurr.copy(this._getMouseOnCircle(i.pageX,i.pageY));break;default:const e=this._getSecondPointerPosition(i),t=i.pageX-e.x,r=i.pageY-e.y;this._touchZoomDistanceEnd=Math.sqrt(t*t+r*r);const s=(i.pageX+e.x)/2,a=(i.pageY+e.y)/2;this._panEnd.copy(this._getMouseOnScreen(s,a));break}}function nF(i){switch(this._pointers.length){case 0:this.state=fi.NONE;break;case 1:this.state=fi.TOUCH_ROTATE,this._moveCurr.copy(this._getMouseOnCircle(i.pageX,i.pageY)),this._movePrev.copy(this._moveCurr);break;case 2:this.state=fi.TOUCH_ZOOM_PAN;for(let e=0;e<this._pointers.length;e++)if(this._pointers[e].pointerId!==i.pointerId){const t=this._pointerPositions[this._pointers[e].pointerId];this._moveCurr.copy(this._getMouseOnCircle(t.x,t.y)),this._movePrev.copy(this._moveCurr);break}break}this.dispatchEvent(bS)}const kA={type:"change"},TS={type:"start"},VA={type:"end"},n_=new d.zHn,zA=new d.JOQ,iF=Math.cos(70*d.M8C.DEG2RAD),Tr=new d.Pa4,As=2*Math.PI,bi={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},MS=1e-6;class rF extends d.ZXd{constructor(e,t=null){super(e,t),this.state=bi.NONE,this.target=new d.Pa4,this.cursor=new d.Pa4,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:d.RsA.ROTATE,MIDDLE:d.RsA.DOLLY,RIGHT:d.RsA.PAN},this.touches={ONE:d.QmN.ROTATE,TWO:d.QmN.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new d.Pa4,this._lastQuaternion=new d._fP,this._lastTargetPosition=new d.Pa4,this._quat=new d._fP().setFromUnitVectors(e.up,new d.Pa4(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new d.$V,this._sphericalDelta=new d.$V,this._scale=1,this._panOffset=new d.Pa4,this._rotateStart=new d.FM8,this._rotateEnd=new d.FM8,this._rotateDelta=new d.FM8,this._panStart=new d.FM8,this._panEnd=new d.FM8,this._panDelta=new d.FM8,this._dollyStart=new d.FM8,this._dollyEnd=new d.FM8,this._dollyDelta=new d.FM8,this._dollyDirection=new d.Pa4,this._mouse=new d.FM8,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=oF.bind(this),this._onPointerDown=sF.bind(this),this._onPointerUp=aF.bind(this),this._onContextMenu=pF.bind(this),this._onMouseWheel=uF.bind(this),this._onKeyDown=hF.bind(this),this._onTouchStart=dF.bind(this),this._onTouchMove=fF.bind(this),this._onMouseDown=cF.bind(this),this._onMouseMove=lF.bind(this),this._interceptControlDown=mF.bind(this),this._interceptControlUp=gF.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(kA),this.update(),this.state=bi.NONE}update(e=null){const t=this.object.position;Tr.copy(t).sub(this.target),Tr.applyQuaternion(this._quat),this._spherical.setFromVector3(Tr),this.autoRotate&&this.state===bi.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let r=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(r)&&isFinite(s)&&(r<-Math.PI?r+=As:r>Math.PI&&(r-=As),s<-Math.PI?s+=As:s>Math.PI&&(s-=As),r<=s?this._spherical.theta=Math.max(r,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(r+s)/2?Math.max(r,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let a=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const c=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),a=c!=this._spherical.radius}if(Tr.setFromSpherical(this._spherical),Tr.applyQuaternion(this._quatInverse),t.copy(this.target).add(Tr),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let c=null;if(this.object.isPerspectiveCamera){const h=Tr.length();c=this._clampDistance(h*this._scale);const f=h-c;this.object.position.addScaledVector(this._dollyDirection,f),this.object.updateMatrixWorld(),a=!!f}else if(this.object.isOrthographicCamera){const h=new d.Pa4(this._mouse.x,this._mouse.y,0);h.unproject(this.object);const f=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),a=f!==this.object.zoom;const m=new d.Pa4(this._mouse.x,this._mouse.y,0);m.unproject(this.object),this.object.position.sub(m).add(h),this.object.updateMatrixWorld(),c=Tr.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;c!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(c).add(this.object.position):(n_.origin.copy(this.object.position),n_.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(n_.direction))<iF?this.object.lookAt(this.target):(zA.setFromNormalAndCoplanarPoint(this.object.up,this.target),n_.intersectPlane(zA,this.target))))}else if(this.object.isOrthographicCamera){const c=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),c!==this.object.zoom&&(this.object.updateProjectionMatrix(),a=!0)}return this._scale=1,this._performCursorZoom=!1,a||this._lastPosition.distanceToSquared(this.object.position)>MS||8*(1-this._lastQuaternion.dot(this.object.quaternion))>MS||this._lastTargetPosition.distanceToSquared(this.target)>MS?(this.dispatchEvent(kA),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?As/60*this.autoRotateSpeed*e:As/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Tr.setFromMatrixColumn(t,0),Tr.multiplyScalar(-e),this._panOffset.add(Tr)}_panUp(e,t){this.screenSpacePanning===!0?Tr.setFromMatrixColumn(t,1):(Tr.setFromMatrixColumn(t,0),Tr.crossVectors(this.object.up,Tr)),Tr.multiplyScalar(e),this._panOffset.add(Tr)}_pan(e,t){const r=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;Tr.copy(s).sub(this.target);let a=Tr.length();a*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*a/r.clientHeight,this.object.matrix),this._panUp(2*t*a/r.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/r.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/r.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const r=this.domElement.getBoundingClientRect(),s=e-r.left,a=t-r.top,c=r.width,h=r.height;this._mouse.x=s/c*2-1,this._mouse.y=-(a/h)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(As*this._rotateDelta.x/t.clientHeight),this._rotateUp(As*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(As*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-As*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(As*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-As*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),r=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(r,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),r=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(r,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),r=e.pageX-t.x,s=e.pageY-t.y,a=Math.sqrt(r*r+s*s);this._dollyStart.set(0,a)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const r=this._getSecondPointerPosition(e),s=.5*(e.pageX+r.x),a=.5*(e.pageY+r.y);this._rotateEnd.set(s,a)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(As*this._rotateDelta.x/t.clientHeight),this._rotateUp(As*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),r=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(r,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),r=e.pageX-t.x,s=e.pageY-t.y,a=Math.sqrt(r*r+s*s);this._dollyEnd.set(0,a),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const c=(e.pageX+t.x)*.5,h=(e.pageY+t.y)*.5;this._updateZoomParameters(c,h)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new d.FM8,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,r={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:r.deltaY*=16;break;case 2:r.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(r.deltaY*=10),r}}function sF(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function oF(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function aF(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(VA),this.state=bi.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function cF(i){let e;switch(i.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case d.RsA.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=bi.DOLLY;break;case d.RsA.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=bi.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=bi.ROTATE}break;case d.RsA.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=bi.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=bi.PAN}break;default:this.state=bi.NONE}this.state!==bi.NONE&&this.dispatchEvent(TS)}function lF(i){switch(this.state){case bi.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case bi.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case bi.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function uF(i){this.enabled===!1||this.enableZoom===!1||this.state!==bi.NONE||(i.preventDefault(),this.dispatchEvent(TS),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(VA))}function hF(i){this.enabled!==!1&&this._handleKeyDown(i)}function dF(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case d.QmN.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=bi.TOUCH_ROTATE;break;case d.QmN.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=bi.TOUCH_PAN;break;default:this.state=bi.NONE}break;case 2:switch(this.touches.TWO){case d.QmN.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=bi.TOUCH_DOLLY_PAN;break;case d.QmN.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=bi.TOUCH_DOLLY_ROTATE;break;default:this.state=bi.NONE}break;default:this.state=bi.NONE}this.state!==bi.NONE&&this.dispatchEvent(TS)}function fF(i){switch(this._trackPointer(i),this.state){case bi.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case bi.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case bi.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case bi.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=bi.NONE}}function pF(i){this.enabled!==!1&&i.preventDefault()}function mF(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function gF(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const xF={type:"change"},GA=1e-6,WA=new d._fP;class _F extends d.ZXd{constructor(e,t=null){super(e,t),this.movementSpeed=1,this.rollSpeed=.005,this.dragToLook=!1,this.autoForward=!1,this._moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0},this._moveVector=new d.Pa4(0,0,0),this._rotationVector=new d.Pa4(0,0,0),this._lastQuaternion=new d._fP,this._lastPosition=new d.Pa4,this._status=0,this._onKeyDown=yF.bind(this),this._onKeyUp=bF.bind(this),this._onPointerMove=SF.bind(this),this._onPointerDown=vF.bind(this),this._onPointerUp=TF.bind(this),this._onPointerCancel=MF.bind(this),this._onContextMenu=wF.bind(this),t!==null&&this.connect(t)}connect(e){super.connect(e),window.addEventListener("keydown",this._onKeyDown),window.addEventListener("keyup",this._onKeyUp),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.addEventListener("pointercancel",this._onPointerCancel),this.domElement.addEventListener("contextmenu",this._onContextMenu)}disconnect(){window.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("keyup",this._onKeyUp),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerCancel),this.domElement.removeEventListener("contextmenu",this._onContextMenu)}dispose(){this.disconnect()}update(e){if(this.enabled===!1)return;const t=this.object,r=e*this.movementSpeed,s=e*this.rollSpeed;t.translateX(this._moveVector.x*r),t.translateY(this._moveVector.y*r),t.translateZ(this._moveVector.z*r),WA.set(this._rotationVector.x*s,this._rotationVector.y*s,this._rotationVector.z*s,1).normalize(),t.quaternion.multiply(WA),(this._lastPosition.distanceToSquared(t.position)>GA||8*(1-this._lastQuaternion.dot(t.quaternion))>GA)&&(this.dispatchEvent(xF),this._lastQuaternion.copy(t.quaternion),this._lastPosition.copy(t.position))}_updateMovementVector(){const e=this._moveState.forward||this.autoForward&&!this._moveState.back?1:0;this._moveVector.x=-this._moveState.left+this._moveState.right,this._moveVector.y=-this._moveState.down+this._moveState.up,this._moveVector.z=-e+this._moveState.back}_updateRotationVector(){this._rotationVector.x=-this._moveState.pitchDown+this._moveState.pitchUp,this._rotationVector.y=-this._moveState.yawRight+this._moveState.yawLeft,this._rotationVector.z=-this._moveState.rollRight+this._moveState.rollLeft}_getContainerDimensions(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}}}function yF(i){if(!(i.altKey||this.enabled===!1)){switch(i.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=.1;break;case"KeyW":this._moveState.forward=1;break;case"KeyS":this._moveState.back=1;break;case"KeyA":this._moveState.left=1;break;case"KeyD":this._moveState.right=1;break;case"KeyR":this._moveState.up=1;break;case"KeyF":this._moveState.down=1;break;case"ArrowUp":this._moveState.pitchUp=1;break;case"ArrowDown":this._moveState.pitchDown=1;break;case"ArrowLeft":this._moveState.yawLeft=1;break;case"ArrowRight":this._moveState.yawRight=1;break;case"KeyQ":this._moveState.rollLeft=1;break;case"KeyE":this._moveState.rollRight=1;break}this._updateMovementVector(),this._updateRotationVector()}}function bF(i){if(this.enabled!==!1){switch(i.code){case"ShiftLeft":case"ShiftRight":this.movementSpeedMultiplier=1;break;case"KeyW":this._moveState.forward=0;break;case"KeyS":this._moveState.back=0;break;case"KeyA":this._moveState.left=0;break;case"KeyD":this._moveState.right=0;break;case"KeyR":this._moveState.up=0;break;case"KeyF":this._moveState.down=0;break;case"ArrowUp":this._moveState.pitchUp=0;break;case"ArrowDown":this._moveState.pitchDown=0;break;case"ArrowLeft":this._moveState.yawLeft=0;break;case"ArrowRight":this._moveState.yawRight=0;break;case"KeyQ":this._moveState.rollLeft=0;break;case"KeyE":this._moveState.rollRight=0;break}this._updateMovementVector(),this._updateRotationVector()}}function vF(i){if(this.enabled!==!1)if(this.dragToLook)this._status++;else{switch(i.button){case 0:this._moveState.forward=1;break;case 2:this._moveState.back=1;break}this._updateMovementVector()}}function SF(i){if(this.enabled!==!1&&(!this.dragToLook||this._status>0)){const e=this._getContainerDimensions(),t=e.size[0]/2,r=e.size[1]/2;this._moveState.yawLeft=-(i.pageX-e.offset[0]-t)/t,this._moveState.pitchDown=(i.pageY-e.offset[1]-r)/r,this._updateRotationVector()}}function TF(i){if(this.enabled!==!1){if(this.dragToLook)this._status--,this._moveState.yawLeft=this._moveState.pitchDown=0;else{switch(i.button){case 0:this._moveState.forward=0;break;case 2:this._moveState.back=0;break}this._updateMovementVector()}this._updateRotationVector()}}function MF(){this.enabled!==!1&&(this.dragToLook?(this._status=0,this._moveState.yawLeft=this._moveState.pitchDown=0):(this._moveState.forward=0,this._moveState.back=0,this._updateMovementVector()),this._updateRotationVector())}function wF(i){this.enabled!==!1&&i.preventDefault()}const AF={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,fragmentShader:`
uniform float opacity;
uniform sampler2D tDiffuse;
varying vec2 vUv;
void main() {
vec4 texel = texture2D( tDiffuse, vUv );
gl_FragColor = opacity * texel;
}`};class i_{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const EF=new d.iKG(-1,1,1,-1,0,1);class CF extends d.u9r{constructor(){super(),this.setAttribute("position",new d.a$l([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new d.a$l([0,2,0,0,2,0],2))}}const RF=new CF;class NF{constructor(e){this._mesh=new d.Kj0(RF,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,EF)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class PF extends i_{constructor(e,t="tDiffuse"){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof d.jyz?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=d.rDY.clone(e.uniforms),this.material=new d.jyz({name:e.name!==void 0?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this._fsQuad=new NF(this.material)}render(e,t,r){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=r.texture),this._fsQuad.material=this.material,this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}class HA extends i_{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,r){const s=e.getContext(),a=e.state;a.buffers.color.setMask(!1),a.buffers.depth.setMask(!1),a.buffers.color.setLocked(!0),a.buffers.depth.setLocked(!0);let c,h;this.inverse?(c=0,h=1):(c=1,h=0),a.buffers.stencil.setTest(!0),a.buffers.stencil.setOp(s.REPLACE,s.REPLACE,s.REPLACE),a.buffers.stencil.setFunc(s.ALWAYS,c,4294967295),a.buffers.stencil.setClear(h),a.buffers.stencil.setLocked(!0),e.setRenderTarget(r),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),a.buffers.color.setLocked(!1),a.buffers.depth.setLocked(!1),a.buffers.color.setMask(!0),a.buffers.depth.setMask(!0),a.buffers.stencil.setLocked(!1),a.buffers.stencil.setFunc(s.EQUAL,1,4294967295),a.buffers.stencil.setOp(s.KEEP,s.KEEP,s.KEEP),a.buffers.stencil.setLocked(!0)}}class LF extends i_{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class IF{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const r=e.getSize(new d.FM8);this._width=r.width,this._height=r.height,t=new d.dd2(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:d.cLu}),t.texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new PF(AF),this.copyPass.material.blending=d.jFi,this.clock=new d.SUY}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){e===void 0&&(e=this.clock.getDelta());const t=this.renderer.getRenderTarget();let r=!1;for(let s=0,a=this.passes.length;s<a;s++){const c=this.passes[s];if(c.enabled!==!1){if(c.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(s),c.render(this.renderer,this.writeBuffer,this.readBuffer,e,r),c.needsSwap){if(r){const h=this.renderer.getContext(),f=this.renderer.state.buffers.stencil;f.setFunc(h.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),f.setFunc(h.EQUAL,1,4294967295)}this.swapBuffers()}HA!==void 0&&(c instanceof HA?r=!0:c instanceof LF&&(r=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){const t=this.renderer.getSize(new d.FM8);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,e=this.renderTarget1.clone(),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){this._width=e,this._height=t;const r=this._width*this._pixelRatio,s=this._height*this._pixelRatio;this.renderTarget1.setSize(r,s),this.renderTarget2.setSize(r,s);for(let a=0;a<this.passes.length;a++)this.passes[a].setSize(r,s)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}class DF extends i_{constructor(e,t,r=null,s=null,a=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=r,this.clearColor=s,this.clearAlpha=a,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new d.Ilk}render(e,t,r){const s=e.autoClear;e.autoClear=!1;let a,c;this.overrideMaterial!==null&&(c=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(e.getClearColor(this._oldClearColor),e.setClearColor(this.clearColor,e.getClearAlpha())),this.clearAlpha!==null&&(a=e.getClearAlpha(),e.setClearAlpha(this.clearAlpha)),this.clearDepth==!0&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:r),this.clear===!0&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor!==null&&e.setClearColor(this._oldClearColor),this.clearAlpha!==null&&e.setClearAlpha(a),this.overrideMaterial!==null&&(this.scene.overrideMaterial=c),e.autoClear=s}}var vo=ne(54476),UF=ne(31226),FF=ne(69168),BF=ne(58289),$A=ne(18773);function OF(i){try{return Function.toString.call(i).indexOf("[native code]")!==-1}catch(e){return typeof i=="function"}}var kF=ne(75538);function VF(i,e,t){if((0,kF.Z)())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,e);var s=new(i.bind.apply(i,r));return t&&(0,$A.Z)(s,t.prototype),s}function wS(i){var e=typeof Map=="function"?new Map:void 0;return wS=function(r){if(r===null||!OF(r))return r;if(typeof r!="function")throw new TypeError("Super expression must either be null or a function");if(e!==void 0){if(e.has(r))return e.get(r);e.set(r,s)}function s(){return VF(r,arguments,(0,BF.Z)(this).constructor)}return s.prototype=Object.create(r.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}}),(0,$A.Z)(s,r)},wS(i)}function jA(){var i;return i=arguments.length-1,i<0||arguments.length<=i?void 0:arguments[i]}function zF(i){return-i}function GF(i,e){return i+e}function WF(i,e){return i-e}function HF(i,e){return i*e}function $F(i,e){return i/e}function jF(){return Math.max.apply(Math,arguments)}function XF(){return Math.min.apply(Math,arguments)}function qF(){return Array.of.apply(Array,arguments)}var ez={symbols:{"*":{infix:{symbol:"*",f:HF,notation:"infix",precedence:4,rightToLeft:0,argCount:2},symbol:"*",regSymbol:"\\*"},"/":{infix:{symbol:"/",f:$F,notation:"infix",precedence:4,rightToLeft:0,argCount:2},symbol:"/",regSymbol:"/"},"+":{infix:{symbol:"+",f:GF,notation:"infix",precedence:2,rightToLeft:0,argCount:2},prefix:{symbol:"+",f:jA,notation:"prefix",precedence:3,rightToLeft:0,argCount:1},symbol:"+",regSymbol:"\\+"},"-":{infix:{symbol:"-",f:WF,notation:"infix",precedence:2,rightToLeft:0,argCount:2},prefix:{symbol:"-",f:zF,notation:"prefix",precedence:3,rightToLeft:0,argCount:1},symbol:"-",regSymbol:"-"},",":{infix:{symbol:",",f:qF,notation:"infix",precedence:1,rightToLeft:0,argCount:2},symbol:",",regSymbol:","},"(":{prefix:{symbol:"(",f:jA,notation:"prefix",precedence:0,rightToLeft:0,argCount:1},symbol:"(",regSymbol:"\\("},")":{postfix:{symbol:")",f:void 0,notation:"postfix",precedence:0,rightToLeft:0,argCount:1},symbol:")",regSymbol:"\\)"},min:{func:{symbol:"min",f:XF,notation:"func",precedence:0,rightToLeft:0,argCount:1},symbol:"min",regSymbol:"min\\b"},max:{func:{symbol:"max",f:jF,notation:"func",precedence:0,rightToLeft:0,argCount:1},symbol:"max",regSymbol:"max\\b"}}},XA=null,tz={1:`Passed invalid arguments to hsl, please pass multiple numbers e.g. hsl(360, 0.75, 0.4) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75 }).
`,2:`Passed invalid arguments to hsla, please pass multiple numbers e.g. hsla(360, 0.75, 0.4, 0.7) or an object e.g. rgb({ hue: 255, saturation: 0.4, lightness: 0.75, alpha: 0.7 }).
`,3:`Passed an incorrect argument to a color function, please pass a string representation of a color.
`,4:`Couldn't generate valid rgb string from %s, it returned %s.
`,5:`Couldn't parse the color string. Please provide the color as a string in hex, rgb, rgba, hsl or hsla notation.
`,6:`Passed invalid arguments to rgb, please pass multiple numbers e.g. rgb(255, 205, 100) or an object e.g. rgb({ red: 255, green: 205, blue: 100 }).
`,7:`Passed invalid arguments to rgba, please pass multiple numbers e.g. rgb(255, 205, 100, 0.75) or an object e.g. rgb({ red: 255, green: 205, blue: 100, alpha: 0.75 }).
`,8:`Passed invalid argument to toColorString, please pass a RgbColor, RgbaColor, HslColor or HslaColor object.
`,9:`Please provide a number of steps to the modularScale helper.
`,10:`Please pass a number or one of the predefined scales to the modularScale helper as the ratio.
`,11:`Invalid value passed as base to modularScale, expected number or em string but got "%s"
`,12:`Expected a string ending in "px" or a number passed as the first argument to %s(), got "%s" instead.
`,13:`Expected a string ending in "px" or a number passed as the second argument to %s(), got "%s" instead.
`,14:`Passed invalid pixel value ("%s") to %s(), please pass a value like "12px" or 12.
`,15:`Passed invalid base value ("%s") to %s(), please pass a value like "12px" or 12.
`,16:`You must provide a template to this method.
`,17:`You passed an unsupported selector state to this method.
`,18:`minScreen and maxScreen must be provided as stringified numbers with the same units.
`,19:`fromSize and toSize must be provided as stringified numbers with the same units.
`,20:`expects either an array of objects or a single object with the properties prop, fromSize, and toSize.
`,21:"expects the objects in the first argument array to have the properties `prop`, `fromSize`, and `toSize`.\n\n",22:"expects the first argument object to have the properties `prop`, `fromSize`, and `toSize`.\n\n",23:`fontFace expects a name of a font-family.
`,24:`fontFace expects either the path to the font file(s) or a name of a local copy.
`,25:`fontFace expects localFonts to be an array.
`,26:`fontFace expects fileFormats to be an array.
`,27:`radialGradient requries at least 2 color-stops to properly render.
`,28:`Please supply a filename to retinaImage() as the first argument.
`,29:`Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.
`,30:"Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",31:`The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation
`,32:`To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])
To pass a single animation please supply them in simple values, e.g. animation('rotate', '2s')
`,33:`The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation
`,34:`borderRadius expects a radius value as a string or number as the second argument.
`,35:`borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.
`,36:`Property must be a string value.
`,37:`Syntax Error at %s.
`,38:`Formula contains a function that needs parentheses at %s.
`,39:`Formula is missing closing parenthesis at %s.
`,40:`Formula has too many closing parentheses at %s.
`,41:`All values in a formula must have the same unit or be unitless.
`,42:`Please provide a number of steps to the modularScale helper.
`,43:`Please pass a number or one of the predefined scales to the modularScale helper as the ratio.
`,44:`Invalid value passed as base to modularScale, expected number or em/rem string but got %s.
`,45:`Passed invalid argument to hslToColorString, please pass a HslColor or HslaColor object.
`,46:`Passed invalid argument to rgbToColorString, please pass a RgbColor or RgbaColor object.
`,47:`minScreen and maxScreen must be provided as stringified numbers with the same units.
`,48:`fromSize and toSize must be provided as stringified numbers with the same units.
`,49:`Expects either an array of objects or a single object with the properties prop, fromSize, and toSize.
`,50:`Expects the objects in the first argument array to have the properties prop, fromSize, and toSize.
`,51:`Expects the first argument object to have the properties prop, fromSize, and toSize.
`,52:`fontFace expects either the path to the font file(s) or a name of a local copy.
`,53:`fontFace expects localFonts to be an array.
`,54:`fontFace expects fileFormats to be an array.
`,55:`fontFace expects a name of a font-family.
`,56:`linearGradient requries at least 2 color-stops to properly render.
`,57:`radialGradient requries at least 2 color-stops to properly render.
`,58:`Please supply a filename to retinaImage() as the first argument.
`,59:`Passed invalid argument to triangle, please pass correct pointingDirection e.g. 'right'.
`,60:"Passed an invalid value to `height` or `width`. Please provide a pixel based unit.\n\n",61:`Property must be a string value.
`,62:`borderRadius expects a radius value as a string or number as the second argument.
`,63:`borderRadius expects one of "top", "bottom", "left" or "right" as the first argument.
`,64:`The animation shorthand only takes 8 arguments. See the specification for more information: http://mdn.io/animation.
`,65:`To pass multiple animations please supply them in arrays, e.g. animation(['rotate', '2s'], ['move', '1s'])\\nTo pass a single animation please supply them in simple values, e.g. animation('rotate', '2s').
`,66:`The animation shorthand arrays can only have 8 elements. See the specification for more information: http://mdn.io/animation.
`,67:`You must provide a template to this method.
`,68:`You passed an unsupported selector state to this method.
`,69:`Expected a string ending in "px" or a number passed as the first argument to %s(), got %s instead.
`,70:`Expected a string ending in "px" or a number passed as the second argument to %s(), got %s instead.
`,71:`Passed invalid pixel value %s to %s(), please pass a value like "12px" or 12.
`,72:`Passed invalid base value %s to %s(), please pass a value like "12px" or 12.
`,73:`Please provide a valid CSS variable.
`,74:`CSS variable not found and no default was provided.
`,75:`important requires a valid style object, got a %s instead.
`,76:`fromSize and toSize must be provided as stringified numbers with the same units as minScreen and maxScreen.
`,77:`remToPx expects a value in "rem" but you provided it in "%s".
`,78:`base must be set in "px" or "%" but you set it in "%s".
`};function nz(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];var r=e[0],s=[],a;for(a=1;a<e.length;a+=1)s.push(e[a]);return s.forEach(function(c){r=r.replace(/%[a-z]/,c)}),r}var _n=function(i){(0,FF.Z)(e,i);function e(t){var r;if(1)r=i.call(this,"An error occurred. See https://github.com/styled-components/polished/blob/main/src/internalHelpers/errors.md#"+t+" for more information.")||this;else var s,a,c;return(0,UF.Z)(r)}return e}(wS(Error)),qA=/((?!\w)a|na|hc|mc|dg|me[r]?|xe|ni(?![a-zA-Z])|mm|cp|tp|xp|q(?!s)|hv|xamv|nimv|wv|sm|s(?!\D|$)|ged|darg?|nrut)/g;function KF(i){var e={};return e.symbols=i?_extends({},XA.symbols,i.symbols):_extends({},XA.symbols),e}function KA(i,e){var t,r=i.pop();return e.push(r.f.apply(r,(t=[]).concat.apply(t,e.splice(-r.argCount)))),r.precedence}function ZF(i,e){var t=KF(e),r,s=[t.symbols["("].prefix],a=[],c=new RegExp("\\d+(?:\\.\\d+)?|"+Object.keys(t.symbols).map(function(C){return t.symbols[C]}).sort(function(C,E){return E.symbol.length-C.symbol.length}).map(function(C){return C.regSymbol}).join("|")+"|(\\S)","g");c.lastIndex=0;var h=!1;do{r=c.exec(i);var f=r||[")",void 0],m=f[0],x=f[1],_=t.symbols[m],v=_&&!_.prefix&&!_.func,T=!_||!_.postfix&&!_.infix;if(x||(h?T:v))throw new _n(37,r?r.index:i.length,i);if(h){var w=_.postfix||_.infix;do{var P=s[s.length-1];if((w.precedence-P.precedence||P.rightToLeft)>0)break}while(KA(s,a));h=w.notation==="postfix",w.symbol!==")"&&(s.push(w),h&&KA(s,a))}else if(_){if(s.push(_.prefix||_.func),_.func&&(r=c.exec(i),!r||r[0]!=="("))throw new _n(38,r?r.index:i.length,i)}else a.push(+m),h=!0}while(r&&s.length);if(s.length)throw new _n(39,r?r.index:i.length,i);if(r)throw new _n(40,r?r.index:i.length,i);return a.pop()}function AS(i){return i.split("").reverse().join("")}function iz(i,e){var t=AS(i),r=t.match(qA);if(r&&!r.every(function(a){return a===r[0]}))throw new _n(41);var s=AS(t.replace(qA,""));return""+ZF(s,e)+(r?AS(r[0]):"")}var YF=/--[\S]*/g;function rz(i,e){if(!i||!i.match(YF))throw new _n(73);var t;if(typeof document!="undefined"&&document.documentElement!==null&&(t=getComputedStyle(document.documentElement).getPropertyValue(i)),t)return t.trim();if(e)return e;throw new _n(74)}function Cm(i){return i.charAt(0).toUpperCase()+i.slice(1)}var QF=null;function JF(i,e){if(!i)return e.toLowerCase();var t=i.split("-");if(t.length>1)return t.splice(1,0,e),t.reduce(function(s,a){return""+s+Cm(a)});var r=i.replace(/([a-z])([A-Z])/g,"$1"+e+"$2");return i===r?""+i+e:r}function eB(i,e){for(var t={},r=0;r<e.length;r+=1)(e[r]||e[r]===0)&&(t[JF(i,QF[r])]=e[r]);return t}function Hu(i){for(var e=arguments.length,t=new Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];var s=t[0],a=t[1],c=a===void 0?s:a,h=t[2],f=h===void 0?s:h,m=t[3],x=m===void 0?c:m,_=[s,c,f,x];return eB(i,_)}function ZA(i,e){return i.substr(-e.length)===e}var tB=/^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/;function YA(i){if(typeof i!="string")return i;var e=i.match(tB);return e?parseFloat(i):i}var nB=function(e){return function(t,r){r===void 0&&(r="16px");var s=t,a=r;if(typeof t=="string"){if(!ZA(t,"px"))throw new _n(69,e,t);s=YA(t)}if(typeof r=="string"){if(!ZA(r,"px"))throw new _n(70,e,r);a=YA(r)}if(typeof s=="string")throw new _n(71,t,e);if(typeof a=="string")throw new _n(72,r,e);return""+s/a+e}},QA=nB,sz=QA("em"),oz=null,iB=/^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/;function Tc(i){if(typeof i!="string")return[i,""];var e=i.match(iB);return e?[parseFloat(i),e[2]]:[i,void 0]}function rB(i,e){if(typeof i!="object"||i===null)throw new _n(75,typeof i);var t={};return Object.keys(i).forEach(function(r){typeof i[r]=="object"&&i[r]!==null?t[r]=rB(i[r],e):!e||e&&(e===r||e.indexOf(r)>=0)?t[r]=i[r]+" !important":t[r]=i[r]}),t}var JA={minorSecond:1.067,majorSecond:1.125,minorThird:1.2,majorThird:1.25,perfectFourth:1.333,augFourth:1.414,perfectFifth:1.5,minorSixth:1.6,goldenSection:1.618,majorSixth:1.667,minorSeventh:1.778,majorSeventh:1.875,octave:2,majorTenth:2.5,majorEleventh:2.667,majorTwelfth:3,doubleOctave:4};function sB(i){return JA[i]}function az(i,e,t){if(e===void 0&&(e="1em"),t===void 0&&(t=1.333),typeof i!="number")throw new _n(42);if(typeof t=="string"&&!JA[t])throw new _n(43);var r=typeof e=="string"?Tc(e):[e,""],s=r[0],a=r[1],c=typeof t=="string"?sB(t):t;if(typeof s=="string")throw new _n(44,e);return""+s*Math.pow(c,i)+(a||"")}var cz=QA("rem"),lz=null,ES=16;function eE(i){var e=Tc(i);if(e[1]==="px")return parseFloat(i);if(e[1]==="%")return parseFloat(i)/100*ES;throw new _n(78,e[1])}function oB(){if(typeof document!="undefined"&&document.documentElement!==null){var i=getComputedStyle(document.documentElement).fontSize;return i?eE(i):ES}return ES}function uz(i,e){var t=Tc(i);if(t[1]!=="rem"&&t[1]!=="")throw new _n(77,t[1]);var r=e?eE(e):oB();return t[0]*r+"px"}var aB={back:"cubic-bezier(0.600, -0.280, 0.735, 0.045)",circ:"cubic-bezier(0.600, 0.040, 0.980, 0.335)",cubic:"cubic-bezier(0.550, 0.055, 0.675, 0.190)",expo:"cubic-bezier(0.950, 0.050, 0.795, 0.035)",quad:"cubic-bezier(0.550, 0.085, 0.680, 0.530)",quart:"cubic-bezier(0.895, 0.030, 0.685, 0.220)",quint:"cubic-bezier(0.755, 0.050, 0.855, 0.060)",sine:"cubic-bezier(0.470, 0.000, 0.745, 0.715)"};function hz(i){return aB[i.toLowerCase().trim()]}var cB={back:"cubic-bezier(0.680, -0.550, 0.265, 1.550)",circ:"cubic-bezier(0.785, 0.135, 0.150, 0.860)",cubic:"cubic-bezier(0.645, 0.045, 0.355, 1.000)",expo:"cubic-bezier(1.000, 0.000, 0.000, 1.000)",quad:"cubic-bezier(0.455, 0.030, 0.515, 0.955)",quart:"cubic-bezier(0.770, 0.000, 0.175, 1.000)",quint:"cubic-bezier(0.860, 0.000, 0.070, 1.000)",sine:"cubic-bezier(0.445, 0.050, 0.550, 0.950)"};function dz(i){return cB[i.toLowerCase().trim()]}var lB={back:"cubic-bezier(0.175, 0.885, 0.320, 1.275)",cubic:"cubic-bezier(0.215, 0.610, 0.355, 1.000)",circ:"cubic-bezier(0.075, 0.820, 0.165, 1.000)",expo:"cubic-bezier(0.190, 1.000, 0.220, 1.000)",quad:"cubic-bezier(0.250, 0.460, 0.450, 0.940)",quart:"cubic-bezier(0.165, 0.840, 0.440, 1.000)",quint:"cubic-bezier(0.230, 1.000, 0.320, 1.000)",sine:"cubic-bezier(0.390, 0.575, 0.565, 1.000)"};function fz(i){return lB[i.toLowerCase().trim()]}function tE(i,e,t,r){t===void 0&&(t="320px"),r===void 0&&(r="1200px");var s=Tc(i),a=s[0],c=s[1],h=Tc(e),f=h[0],m=h[1],x=Tc(t),_=x[0],v=x[1],T=Tc(r),w=T[0],P=T[1];if(typeof _!="number"||typeof w!="number"||!v||!P||v!==P)throw new _n(47);if(typeof a!="number"||typeof f!="number"||c!==m)throw new _n(48);if(c!==v||m!==P)throw new _n(76);var C=(a-f)/(_-w),E=f-C*w;return"calc("+E.toFixed(2)+(c||"")+" + "+(100*C).toFixed(2)+"vw)"}function pz(i){var e;i===void 0&&(i="&");var t=i+"::after";return e={},e[t]={clear:"both",content:'""',display:"table"},e}function mz(i){return i===void 0&&(i=0),{position:"absolute",top:i,right:i,bottom:i,left:i}}function gz(i,e){e===void 0&&(e=1);var t={display:"inline-block",maxWidth:i||"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",wordWrap:"normal"};return e>1?_extends({},t,{WebkitBoxOrient:"vertical",WebkitLineClamp:e,display:"-webkit-box",whiteSpace:"normal"}):t}function uB(i,e){var t=typeof Symbol!="undefined"&&i[Symbol.iterator]||i["@@iterator"];if(t)return(t=t.call(i)).next.bind(t);if(Array.isArray(i)||(t=hB(i))||e&&i&&typeof i.length=="number"){t&&(i=t);var r=0;return function(){return r>=i.length?{done:!0}:{done:!1,value:i[r++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hB(i,e){if(i){if(typeof i=="string")return nE(i,e);var t=Object.prototype.toString.call(i).slice(8,-1);if(t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set")return Array.from(i);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return nE(i,e)}}function nE(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,r=new Array(e);t<e;t++)r[t]=i[t];return r}function xz(i,e,t){if(e===void 0&&(e="320px"),t===void 0&&(t="1200px"),!Array.isArray(i)&&typeof i!="object"||i===null)throw new _n(49);if(Array.isArray(i)){for(var r={},s={},a=uB(i),c;!(c=a()).done;){var h,f,m=c.value;if(!m.prop||!m.fromSize||!m.toSize)throw new _n(50);s[m.prop]=m.fromSize,r["@media (min-width: "+e+")"]=_extends({},r["@media (min-width: "+e+")"],(h={},h[m.prop]=tE(m.fromSize,m.toSize,e,t),h)),r["@media (min-width: "+t+")"]=_extends({},r["@media (min-width: "+t+")"],(f={},f[m.prop]=m.toSize,f))}return _extends({},s,r)}else{var x,_,v;if(!i.prop||!i.fromSize||!i.toSize)throw new _n(51);return v={},v[i.prop]=i.fromSize,v["@media (min-width: "+e+")"]=(x={},x[i.prop]=tE(i.fromSize,i.toSize,e,t),x),v["@media (min-width: "+t+")"]=(_={},_[i.prop]=i.toSize,_),v}}var dB=/^\s*data:([a-z]+\/[a-z-]+(;[a-z-]+=[a-z-]+)?)?(;charset=[a-z0-9-]+)?(;base64)?,[a-z0-9!$&',()*+,;=\-._~:@/?%\s]*\s*$/i,fB={woff:"woff",woff2:"woff2",ttf:"truetype",otf:"opentype",eot:"embedded-opentype",svg:"svg",svgz:"svg"};function iE(i,e){return e?' format("'+fB[i]+'")':""}function pB(i){return!!i.replace(/\s+/g," ").match(dB)}function mB(i,e,t){if(pB(i))return'url("'+i+'")'+iE(e[0],t);var r=e.map(function(s){return'url("'+i+"."+s+'")'+iE(s,t)});return r.join(", ")}function gB(i){var e=i.map(function(t){return'local("'+t+'")'});return e.join(", ")}function xB(i,e,t,r){var s=[];return e&&s.push(gB(e)),i&&s.push(mB(i,t,r)),s.join(", ")}function _z(i){var e=i.fontFamily,t=i.fontFilePath,r=i.fontStretch,s=i.fontStyle,a=i.fontVariant,c=i.fontWeight,h=i.fileFormats,f=h===void 0?["eot","woff2","woff","ttf","svg"]:h,m=i.formatHint,x=m===void 0?!1:m,_=i.localFonts,v=_===void 0?[e]:_,T=i.unicodeRange,w=i.fontDisplay,P=i.fontVariationSettings,C=i.fontFeatureSettings;if(!e)throw new _n(55);if(!t&&!v)throw new _n(52);if(v&&!Array.isArray(v))throw new _n(53);if(!Array.isArray(f))throw new _n(54);var E={"@font-face":{fontFamily:e,src:xB(t,v,f,x),unicodeRange:T,fontStretch:r,fontStyle:s,fontVariant:a,fontWeight:c,fontDisplay:w,fontVariationSettings:P,fontFeatureSettings:C}};return JSON.parse(JSON.stringify(E))}function yz(){return{textIndent:"101%",overflow:"hidden",whiteSpace:"nowrap"}}function bz(){return{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",whiteSpace:"nowrap",width:"1px"}}function _B(i){return i===void 0&&(i=1.3),`
@media only screen and (-webkit-min-device-pixel-ratio: `+i+`),
only screen and (min--moz-device-pixel-ratio: `+i+`),
only screen and (-o-min-device-pixel-ratio: `+i+`/1),
only screen and (min-resolution: `+Math.round(i*96)+`dpi),
only screen and (min-resolution: `+i+`dppx)
`}function rE(i){for(var e="",t=arguments.length,r=new Array(t>1?t-1:0),s=1;s<t;s++)r[s-1]=arguments[s];for(var a=0;a<i.length;a+=1)if(e+=i[a],a===r.length-1&&r[a]){var c=r.filter(function(h){return!!h});c.length>1?(e=e.slice(0,-1),e+=", "+r[a]):c.length===1&&(e+=""+r[a])}else r[a]&&(e+=r[a]+" ");return e.trim()}var sE;function vz(i){var e=i.colorStops,t=i.fallback,r=i.toDirection,s=r===void 0?"":r;if(!e||e.length<2)throw new _n(56);return{backgroundColor:t||e[0].replace(/,\s+/g,",").split(" ")[0].replace(/,(?=\S)/g,", "),backgroundImage:rE(sE||(sE=_taggedTemplateLiteralLoose(["linear-gradient(","",")"])),s,e.join(", ").replace(/,(?=\S)/g,", "))}}function Sz(){var i;return[(i={html:{lineHeight:"1.15",textSizeAdjust:"100%"},body:{margin:"0"},main:{display:"block"},h1:{fontSize:"2em",margin:"0.67em 0"},hr:{boxSizing:"content-box",height:"0",overflow:"visible"},pre:{fontFamily:"monospace, monospace",fontSize:"1em"},a:{backgroundColor:"transparent"},"abbr[title]":{borderBottom:"none",textDecoration:"underline"}},i[`b,
strong`]={fontWeight:"bolder"},i[`code,
kbd,
samp`]={fontFamily:"monospace, monospace",fontSize:"1em"},i.small={fontSize:"80%"},i[`sub,
sup`]={fontSize:"75%",lineHeight:"0",position:"relative",verticalAlign:"baseline"},i.sub={bottom:"-0.25em"},i.sup={top:"-0.5em"},i.img={borderStyle:"none"},i[`button,
input,
optgroup,
select,
textarea`]={fontFamily:"inherit",fontSize:"100%",lineHeight:"1.15",margin:"0"},i[`button,
input`]={overflow:"visible"},i[`button,
select`]={textTransform:"none"},i[`button,
html [type="button"],
[type="reset"],
[type="submit"]`]={WebkitAppearance:"button"},i[`button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner`]={borderStyle:"none",padding:"0"},i[`button:-moz-focusring,
[type="button"]:-moz-focusring,
[type="reset"]:-moz-focusring,
[type="submit"]:-moz-focusring`]={outline:"1px dotted ButtonText"},i.fieldset={padding:"0.35em 0.625em 0.75em"},i.legend={boxSizing:"border-box",color:"inherit",display:"table",maxWidth:"100%",padding:"0",whiteSpace:"normal"},i.progress={verticalAlign:"baseline"},i.textarea={overflow:"auto"},i[`[type="checkbox"],
[type="radio"]`]={boxSizing:"border-box",padding:"0"},i[`[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button`]={height:"auto"},i['[type="search"]']={WebkitAppearance:"textfield",outlineOffset:"-2px"},i['[type="search"]::-webkit-search-decoration']={WebkitAppearance:"none"},i["::-webkit-file-upload-button"]={WebkitAppearance:"button",font:"inherit"},i.details={display:"block"},i.summary={display:"list-item"},i.template={display:"none"},i["[hidden]"]={display:"none"},i),{"abbr[title]":{textDecoration:"underline dotted"}}]}var oE;function Tz(i){var e=i.colorStops,t=i.extent,r=t===void 0?"":t,s=i.fallback,a=i.position,c=a===void 0?"":a,h=i.shape,f=h===void 0?"":h;if(!e||e.length<2)throw new _n(57);return{backgroundColor:s||e[0].split(" ")[0],backgroundImage:rE(oE||(oE=_taggedTemplateLiteralLoose(["radial-gradient(","","","",")"])),c,f,r,e.join(", "))}}function Mz(i,e,t,r,s){var a;if(t===void 0&&(t="png"),s===void 0&&(s="_2x"),!i)throw new _n(58);var c=t.replace(/^\./,""),h=r?r+"."+c:""+i+s+"."+c;return a={backgroundImage:"url("+i+"."+c+")"},a[_B()]=_extends({backgroundImage:"url("+h+")"},e?{backgroundSize:e}:{}),a}var yB={easeInBack:"cubic-bezier(0.600, -0.280, 0.735, 0.045)",easeInCirc:"cubic-bezier(0.600, 0.040, 0.980, 0.335)",easeInCubic:"cubic-bezier(0.550, 0.055, 0.675, 0.190)",easeInExpo:"cubic-bezier(0.950, 0.050, 0.795, 0.035)",easeInQuad:"cubic-bezier(0.550, 0.085, 0.680, 0.530)",easeInQuart:"cubic-bezier(0.895, 0.030, 0.685, 0.220)",easeInQuint:"cubic-bezier(0.755, 0.050, 0.855, 0.060)",easeInSine:"cubic-bezier(0.470, 0.000, 0.745, 0.715)",easeOutBack:"cubic-bezier(0.175, 0.885, 0.320, 1.275)",easeOutCubic:"cubic-bezier(0.215, 0.610, 0.355, 1.000)",easeOutCirc:"cubic-bezier(0.075, 0.820, 0.165, 1.000)",easeOutExpo:"cubic-bezier(0.190, 1.000, 0.220, 1.000)",easeOutQuad:"cubic-bezier(0.250, 0.460, 0.450, 0.940)",easeOutQuart:"cubic-bezier(0.165, 0.840, 0.440, 1.000)",easeOutQuint:"cubic-bezier(0.230, 1.000, 0.320, 1.000)",easeOutSine:"cubic-bezier(0.390, 0.575, 0.565, 1.000)",easeInOutBack:"cubic-bezier(0.680, -0.550, 0.265, 1.550)",easeInOutCirc:"cubic-bezier(0.785, 0.135, 0.150, 0.860)",easeInOutCubic:"cubic-bezier(0.645, 0.045, 0.355, 1.000)",easeInOutExpo:"cubic-bezier(1.000, 0.000, 0.000, 1.000)",easeInOutQuad:"cubic-bezier(0.455, 0.030, 0.515, 0.955)",easeInOutQuart:"cubic-bezier(0.770, 0.000, 0.175, 1.000)",easeInOutQuint:"cubic-bezier(0.860, 0.000, 0.070, 1.000)",easeInOutSine:"cubic-bezier(0.445, 0.050, 0.550, 0.950)"};function bB(i){return yB[i]}function wz(i){return bB(i)}var vB=function(e,t,r){var s=""+r[0]+(r[1]||""),a=""+r[0]/2+(r[1]||""),c=""+t[0]+(t[1]||""),h=""+t[0]/2+(t[1]||"");switch(e){case"top":return"0 "+a+" "+c+" "+a;case"topLeft":return s+" "+c+" 0 0";case"left":return h+" "+s+" "+h+" 0";case"bottomLeft":return s+" 0 0 "+c;case"bottom":return c+" "+a+" 0 "+a;case"bottomRight":return"0 0 "+s+" "+c;case"right":return h+" 0 "+h+" "+s;case"topRight":default:return"0 "+s+" "+c+" 0"}},SB=function(e,t){switch(e){case"top":case"bottomRight":return{borderBottomColor:t};case"right":case"bottomLeft":return{borderLeftColor:t};case"bottom":case"topLeft":return{borderTopColor:t};case"left":case"topRight":return{borderRightColor:t};default:throw new _n(59)}};function Az(i){var e=i.pointingDirection,t=i.height,r=i.width,s=i.foregroundColor,a=i.backgroundColor,c=a===void 0?"transparent":a,h=Tc(r),f=Tc(t);if(isNaN(f[0])||isNaN(h[0]))throw new _n(60);return _extends({width:"0",height:"0",borderColor:c},SB(e,s),{borderStyle:"solid",borderWidth:vB(e,f,h)})}function Ez(i){i===void 0&&(i="break-word");var e=i==="break-word"?"break-all":i;return{overflowWrap:i,wordWrap:i,wordBreak:e}}function CS(i){return Math.round(i*255)}function TB(i,e,t){return CS(i)+","+CS(e)+","+CS(t)}function Rm(i,e,t,r){if(r===void 0&&(r=TB),e===0)return r(t,t,t);var s=(i%360+360)%360/60,a=(1-Math.abs(2*t-1))*e,c=a*(1-Math.abs(s%2-1)),h=0,f=0,m=0;s>=0&&s<1?(h=a,f=c):s>=1&&s<2?(h=c,f=a):s>=2&&s<3?(f=a,m=c):s>=3&&s<4?(f=c,m=a):s>=4&&s<5?(h=c,m=a):s>=5&&s<6&&(h=a,m=c);var x=t-a/2,_=h+x,v=f+x,T=m+x;return r(_,v,T)}var aE={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"639",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"};function MB(i){if(typeof i!="string")return i;var e=i.toLowerCase();return aE[e]?"#"+aE[e]:i}var wB=/^#[a-fA-F0-9]{6}$/,AB=/^#[a-fA-F0-9]{8}$/,EB=/^#[a-fA-F0-9]{3}$/,CB=/^#[a-fA-F0-9]{4}$/,RS=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,RB=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,NB=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,PB=/^hsl(?:a)?\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i;function Mc(i){if(typeof i!="string")throw new _n(3);var e=MB(i);if(e.match(wB))return{red:parseInt(""+e[1]+e[2],16),green:parseInt(""+e[3]+e[4],16),blue:parseInt(""+e[5]+e[6],16)};if(e.match(AB)){var t=parseFloat((parseInt(""+e[7]+e[8],16)/255).toFixed(2));return{red:parseInt(""+e[1]+e[2],16),green:parseInt(""+e[3]+e[4],16),blue:parseInt(""+e[5]+e[6],16),alpha:t}}if(e.match(EB))return{red:parseInt(""+e[1]+e[1],16),green:parseInt(""+e[2]+e[2],16),blue:parseInt(""+e[3]+e[3],16)};if(e.match(CB)){var r=parseFloat((parseInt(""+e[4]+e[4],16)/255).toFixed(2));return{red:parseInt(""+e[1]+e[1],16),green:parseInt(""+e[2]+e[2],16),blue:parseInt(""+e[3]+e[3],16),alpha:r}}var s=RS.exec(e);if(s)return{red:parseInt(""+s[1],10),green:parseInt(""+s[2],10),blue:parseInt(""+s[3],10)};var a=RB.exec(e.substring(0,50));if(a)return{red:parseInt(""+a[1],10),green:parseInt(""+a[2],10),blue:parseInt(""+a[3],10),alpha:parseFloat(""+a[4])>1?parseFloat(""+a[4])/100:parseFloat(""+a[4])};var c=NB.exec(e);if(c){var h=parseInt(""+c[1],10),f=parseInt(""+c[2],10)/100,m=parseInt(""+c[3],10)/100,x="rgb("+Rm(h,f,m)+")",_=RS.exec(x);if(!_)throw new _n(4,e,x);return{red:parseInt(""+_[1],10),green:parseInt(""+_[2],10),blue:parseInt(""+_[3],10)}}var v=PB.exec(e.substring(0,50));if(v){var T=parseInt(""+v[1],10),w=parseInt(""+v[2],10)/100,P=parseInt(""+v[3],10)/100,C="rgb("+Rm(T,w,P)+")",E=RS.exec(C);if(!E)throw new _n(4,e,C);return{red:parseInt(""+E[1],10),green:parseInt(""+E[2],10),blue:parseInt(""+E[3],10),alpha:parseFloat(""+v[4])>1?parseFloat(""+v[4])/100:parseFloat(""+v[4])}}throw new _n(5)}function LB(i){var e=i.red/255,t=i.green/255,r=i.blue/255,s=Math.max(e,t,r),a=Math.min(e,t,r),c=(s+a)/2;if(s===a)return i.alpha!==void 0?{hue:0,saturation:0,lightness:c,alpha:i.alpha}:{hue:0,saturation:0,lightness:c};var h,f=s-a,m=c>.5?f/(2-s-a):f/(s+a);switch(s){case e:h=(t-r)/f+(t<r?6:0);break;case t:h=(r-e)/f+2;break;default:h=(e-t)/f+4;break}return h*=60,i.alpha!==void 0?{hue:h,saturation:m,lightness:c,alpha:i.alpha}:{hue:h,saturation:m,lightness:c}}function Ma(i){return LB(Mc(i))}var IB=function(e){return e.length===7&&e[1]===e[2]&&e[3]===e[4]&&e[5]===e[6]?"#"+e[1]+e[3]+e[5]:e},NS=IB;function $u(i){var e=i.toString(16);return e.length===1?"0"+e:e}function PS(i){return $u(Math.round(i*255))}function DB(i,e,t){return NS("#"+PS(i)+PS(e)+PS(t))}function r_(i,e,t){return Rm(i,e,t,DB)}function cE(i,e,t){if(typeof i=="number"&&typeof e=="number"&&typeof t=="number")return r_(i,e,t);if(typeof i=="object"&&e===void 0&&t===void 0)return r_(i.hue,i.saturation,i.lightness);throw new _n(1)}function lE(i,e,t,r){if(typeof i=="number"&&typeof e=="number"&&typeof t=="number"&&typeof r=="number")return r>=1?r_(i,e,t):"rgba("+Rm(i,e,t)+","+r+")";if(typeof i=="object"&&e===void 0&&t===void 0&&r===void 0)return i.alpha>=1?r_(i.hue,i.saturation,i.lightness):"rgba("+Rm(i.hue,i.saturation,i.lightness)+","+i.alpha+")";throw new _n(2)}function s_(i,e,t){if(typeof i=="number"&&typeof e=="number"&&typeof t=="number")return NS("#"+$u(i)+$u(e)+$u(t));if(typeof i=="object"&&e===void 0&&t===void 0)return NS("#"+$u(i.red)+$u(i.green)+$u(i.blue));throw new _n(6)}function Nm(i,e,t,r){if(typeof i=="string"&&typeof e=="number"){var s=Mc(i);return"rgba("+s.red+","+s.green+","+s.blue+","+e+")"}else{if(typeof i=="number"&&typeof e=="number"&&typeof t=="number"&&typeof r=="number")return r>=1?s_(i,e,t):"rgba("+i+","+e+","+t+","+r+")";if(typeof i=="object"&&e===void 0&&t===void 0&&r===void 0)return i.alpha>=1?s_(i.red,i.green,i.blue):"rgba("+i.red+","+i.green+","+i.blue+","+i.alpha+")"}throw new _n(7)}var UB=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&(typeof e.alpha!="number"||typeof e.alpha=="undefined")},FB=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&typeof e.alpha=="number"},BB=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&(typeof e.alpha!="number"||typeof e.alpha=="undefined")},OB=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&typeof e.alpha=="number"};function Zo(i){if(typeof i!="object")throw new _n(8);if(FB(i))return Nm(i);if(UB(i))return s_(i);if(OB(i))return lE(i);if(BB(i))return cE(i);throw new _n(8)}function uE(i,e,t){return function(){var s=t.concat(Array.prototype.slice.call(arguments));return s.length>=e?i.apply(this,s):uE(i,e,s)}}function Qs(i){return uE(i,i.length,[])}function kB(i,e){if(e==="transparent")return e;var t=Ma(e);return Zo((0,vo.Z)({},t,{hue:t.hue+parseFloat(i)}))}var Cz=Qs(kB),Rz=null;function Nz(i){if(i==="transparent")return i;var e=Ma(i);return Zo(_extends({},e,{hue:(e.hue+180)%360}))}function jd(i,e,t){return Math.max(i,Math.min(e,t))}function VB(i,e){if(e==="transparent")return e;var t=Ma(e);return Zo((0,vo.Z)({},t,{lightness:jd(0,1,t.lightness-parseFloat(i))}))}var Pz=Qs(VB),Lz=null;function zB(i,e){if(e==="transparent")return e;var t=Ma(e);return Zo((0,vo.Z)({},t,{saturation:jd(0,1,t.saturation-parseFloat(i))}))}var Iz=Qs(zB),Dz=null;function LS(i){if(i==="transparent")return 0;var e=Mc(i),t=Object.keys(e).map(function(c){var h=e[c]/255;return h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4)}),r=t[0],s=t[1],a=t[2];return parseFloat((.2126*r+.7152*s+.0722*a).toFixed(3))}function hE(i,e){var t=LS(i),r=LS(e);return parseFloat((t>r?(t+.05)/(r+.05):(r+.05)/(t+.05)).toFixed(2))}function Uz(i){return i==="transparent"?i:Zo(_extends({},Ma(i),{saturation:0}))}function Fz(i){if(typeof i=="object"&&typeof i.hue=="number"&&typeof i.saturation=="number"&&typeof i.lightness=="number")return i.alpha&&typeof i.alpha=="number"?lE({hue:i.hue,saturation:i.saturation,lightness:i.lightness,alpha:i.alpha}):cE({hue:i.hue,saturation:i.saturation,lightness:i.lightness});throw new _n(45)}function Bz(i){if(i==="transparent")return i;var e=Mc(i);return Zo(_extends({},e,{red:255-e.red,green:255-e.green,blue:255-e.blue}))}function GB(i,e){if(e==="transparent")return e;var t=Ma(e);return Zo((0,vo.Z)({},t,{lightness:jd(0,1,t.lightness+parseFloat(i))}))}var Oz=Qs(GB),kz=null;function Vz(i,e){var t=hE(i,e);return{AA:t>=4.5,AALarge:t>=3,AAA:t>=7,AAALarge:t>=4.5}}function WB(i,e,t){if(e==="transparent")return t;if(t==="transparent")return e;if(i===0)return t;var r=Mc(e),s=(0,vo.Z)({},r,{alpha:typeof r.alpha=="number"?r.alpha:1}),a=Mc(t),c=(0,vo.Z)({},a,{alpha:typeof a.alpha=="number"?a.alpha:1}),h=s.alpha-c.alpha,f=parseFloat(i)*2-1,m=f*h===-1?f:f+h,x=1+f*h,_=(m/x+1)/2,v=1-_,T={red:Math.floor(s.red*_+c.red*v),green:Math.floor(s.green*_+c.green*v),blue:Math.floor(s.blue*_+c.blue*v),alpha:s.alpha*parseFloat(i)+c.alpha*(1-parseFloat(i))};return Nm(T)}var HB=Qs(WB),dE=HB;function $B(i,e){if(e==="transparent")return e;var t=Mc(e),r=typeof t.alpha=="number"?t.alpha:1,s=(0,vo.Z)({},t,{alpha:jd(0,1,(r*100+parseFloat(i)*100)/100)});return Nm(s)}var jB=Qs($B),XB=jB,fE="#000",pE="#fff";function zz(i,e,t,r){e===void 0&&(e=fE),t===void 0&&(t=pE),r===void 0&&(r=!0);var s=LS(i)>.179,a=s?e:t;return!r||hE(i,a)>=4.5?a:s?fE:pE}function Gz(i){if(typeof i=="object"&&typeof i.red=="number"&&typeof i.green=="number"&&typeof i.blue=="number")return typeof i.alpha=="number"?Nm({red:i.red,green:i.green,blue:i.blue,alpha:i.alpha}):s_({red:i.red,green:i.green,blue:i.blue});throw new _n(46)}function qB(i,e){if(e==="transparent")return e;var t=Ma(e);return Zo((0,vo.Z)({},t,{saturation:jd(0,1,t.saturation+parseFloat(i))}))}var Wz=Qs(qB),Hz=null;function KB(i,e){return e==="transparent"?e:Zo((0,vo.Z)({},Ma(e),{hue:parseFloat(i)}))}var $z=Qs(KB),jz=null;function ZB(i,e){return e==="transparent"?e:Zo((0,vo.Z)({},Ma(e),{lightness:parseFloat(i)}))}var Xz=Qs(ZB),qz=null;function YB(i,e){return e==="transparent"?e:Zo((0,vo.Z)({},Ma(e),{saturation:parseFloat(i)}))}var Kz=Qs(YB),Zz=null;function QB(i,e){return e==="transparent"?e:dE(parseFloat(i),"rgb(0, 0, 0)",e)}var Yz=Qs(QB),Qz=null;function JB(i,e){return e==="transparent"?e:dE(parseFloat(i),"rgb(255, 255, 255)",e)}var Jz=Qs(JB),e5=null;function eO(i,e){if(e==="transparent")return e;var t=Mc(e),r=typeof t.alpha=="number"?t.alpha:1,s=(0,vo.Z)({},t,{alpha:jd(0,1,+(r*100-parseFloat(i)*100).toFixed(2)/100)});return Nm(s)}var t5=Qs(eO),n5=null;function i5(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];var r=Array.isArray(e[0]);if(!r&&e.length>8)throw new _n(64);var s=e.map(function(a){if(r&&!Array.isArray(a)||!r&&Array.isArray(a))throw new _n(65);if(Array.isArray(a)&&a.length>8)throw new _n(66);return Array.isArray(a)?a.join(" "):a}).join(", ");return{animation:s}}function r5(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return{backgroundImage:e.join(", ")}}function s5(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return{background:e.join(", ")}}var tO=null;function o5(i){for(var e=arguments.length,t=new Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];if(typeof i=="string"&&tO.indexOf(i)>=0){var s;return s={},s["border"+Cm(i)+"Width"]=t[0],s["border"+Cm(i)+"Style"]=t[1],s["border"+Cm(i)+"Color"]=t[2],s}else return t.unshift(i),{borderWidth:t[0],borderStyle:t[1],borderColor:t[2]}}function a5(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return Hu.apply(void 0,["borderColor"].concat(e))}function c5(i,e){var t=Cm(i);if(!e&&e!==0)throw new _n(62);if(t==="Top"||t==="Bottom"){var r;return r={},r["border"+t+"RightRadius"]=e,r["border"+t+"LeftRadius"]=e,r}if(t==="Left"||t==="Right"){var s;return s={},s["borderTop"+t+"Radius"]=e,s["borderBottom"+t+"Radius"]=e,s}throw new _n(63)}function l5(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return Hu.apply(void 0,["borderStyle"].concat(e))}function u5(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return Hu.apply(void 0,["borderWidth"].concat(e))}function mE(i,e){var t=e?":"+e:"";return i(t)}function gE(i,e,t){if(!e)throw new _n(67);if(i.length===0)return mE(e,null);for(var r=[],s=0;s<i.length;s+=1){if(t&&t.indexOf(i[s])<0)throw new _n(68);r.push(mE(e,i[s]))}return r=r.join(","),r}var nO=null;function iO(i){return"button"+i+`,
input[type="button"]`+i+`,
input[type="reset"]`+i+`,
input[type="submit"]`+i}function h5(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return gE(e,iO,nO)}function d5(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return Hu.apply(void 0,["margin"].concat(e))}function f5(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return Hu.apply(void 0,["padding"].concat(e))}var rO=null;function p5(i){for(var e=arguments.length,t=new Array(e>1?e-1:0),r=1;r<e;r++)t[r-1]=arguments[r];return rO.indexOf(i)>=0&&i?_extends({},Hu.apply(void 0,[""].concat(t)),{position:i}):Hu.apply(void 0,["",i].concat(t))}function m5(i,e){return e===void 0&&(e=i),{height:i,width:e}}var sO=null;function oO(i){return'input[type="color"]'+i+`,
input[type="date"]`+i+`,
input[type="datetime"]`+i+`,
input[type="datetime-local"]`+i+`,
input[type="email"]`+i+`,
input[type="month"]`+i+`,
input[type="number"]`+i+`,
input[type="password"]`+i+`,
input[type="search"]`+i+`,
input[type="tel"]`+i+`,
input[type="text"]`+i+`,
input[type="time"]`+i+`,
input[type="url"]`+i+`,
input[type="week"]`+i+`,
input:not([type])`+i+`,
textarea`+i}function g5(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return gE(e,oO,sO)}function x5(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];if(Array.isArray(e[0])&&e.length===2){var r=e[1];if(typeof r!="string")throw new _n(61);var s=e[0].map(function(a){return a+" "+r}).join(", ");return{transition:s}}else return{transition:e.join(", ")}}var wl=Object.freeze({Linear:Object.freeze({None:function(i){return i},In:function(i){return i},Out:function(i){return i},InOut:function(i){return i}}),Quadratic:Object.freeze({In:function(i){return i*i},Out:function(i){return i*(2-i)},InOut:function(i){return(i*=2)<1?.5*i*i:-.5*(--i*(i-2)-1)}}),Cubic:Object.freeze({In:function(i){return i*i*i},Out:function(i){return--i*i*i+1},InOut:function(i){return(i*=2)<1?.5*i*i*i:.5*((i-=2)*i*i+2)}}),Quartic:Object.freeze({In:function(i){return i*i*i*i},Out:function(i){return 1- --i*i*i*i},InOut:function(i){return(i*=2)<1?.5*i*i*i*i:-.5*((i-=2)*i*i*i-2)}}),Quintic:Object.freeze({In:function(i){return i*i*i*i*i},Out:function(i){return--i*i*i*i*i+1},InOut:function(i){return(i*=2)<1?.5*i*i*i*i*i:.5*((i-=2)*i*i*i*i+2)}}),Sinusoidal:Object.freeze({In:function(i){return 1-Math.sin((1-i)*Math.PI/2)},Out:function(i){return Math.sin(i*Math.PI/2)},InOut:function(i){return .5*(1-Math.sin(Math.PI*(.5-i)))}}),Exponential:Object.freeze({In:function(i){return i===0?0:Math.pow(1024,i-1)},Out:function(i){return i===1?1:1-Math.pow(2,-10*i)},InOut:function(i){return i===0?0:i===1?1:(i*=2)<1?.5*Math.pow(1024,i-1):.5*(-Math.pow(2,-10*(i-1))+2)}}),Circular:Object.freeze({In:function(i){return 1-Math.sqrt(1-i*i)},Out:function(i){return Math.sqrt(1- --i*i)},InOut:function(i){return(i*=2)<1?-.5*(Math.sqrt(1-i*i)-1):.5*(Math.sqrt(1-(i-=2)*i)+1)}}),Elastic:Object.freeze({In:function(i){return i===0?0:i===1?1:-Math.pow(2,10*(i-1))*Math.sin((i-1.1)*5*Math.PI)},Out:function(i){return i===0?0:i===1?1:Math.pow(2,-10*i)*Math.sin((i-.1)*5*Math.PI)+1},InOut:function(i){return i===0?0:i===1?1:(i*=2,i<1?-.5*Math.pow(2,10*(i-1))*Math.sin((i-1.1)*5*Math.PI):.5*Math.pow(2,-10*(i-1))*Math.sin((i-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(i){var e=1.70158;return i===1?1:i*i*((e+1)*i-e)},Out:function(i){var e=1.70158;return i===0?0:--i*i*((e+1)*i+e)+1},InOut:function(i){var e=2.5949095;return(i*=2)<1?.5*(i*i*((e+1)*i-e)):.5*((i-=2)*i*((e+1)*i+e)+2)}}),Bounce:Object.freeze({In:function(i){return 1-wl.Bounce.Out(1-i)},Out:function(i){return i<1/2.75?7.5625*i*i:i<2/2.75?7.5625*(i-=1.5/2.75)*i+.75:i<2.5/2.75?7.5625*(i-=2.25/2.75)*i+.9375:7.5625*(i-=2.625/2.75)*i+.984375},InOut:function(i){return i<.5?wl.Bounce.In(i*2)*.5:wl.Bounce.Out(i*2-1)*.5+.5}}),generatePow:function(i){return i===void 0&&(i=4),i=i<Number.EPSILON?Number.EPSILON:i,i=i>1e4?1e4:i,{In:function(e){return Math.pow(e,i)},Out:function(e){return 1-Math.pow(1-e,i)},InOut:function(e){return e<.5?Math.pow(e*2,i)/2:(1-Math.pow(2-e*2,i))/2+.5}}}}),Xd=function(){return performance.now()},IS=function(){function i(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._tweens={},this._tweensAddedDuringUpdate={},this.add.apply(this,e)}return i.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},i.prototype.removeAll=function(){this._tweens={}},i.prototype.add=function(){for(var e,t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];for(var s=0,a=t;s<a.length;s++){var c=a[s];(e=c._group)===null||e===void 0||e.remove(c),c._group=this,this._tweens[c.getId()]=c,this._tweensAddedDuringUpdate[c.getId()]=c}},i.prototype.remove=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var r=0,s=e;r<s.length;r++){var a=s[r];a._group=void 0,delete this._tweens[a.getId()],delete this._tweensAddedDuringUpdate[a.getId()]}},i.prototype.allStopped=function(){return this.getAll().every(function(e){return!e.isPlaying()})},i.prototype.update=function(e,t){e===void 0&&(e=Xd()),t===void 0&&(t=!0);var r=Object.keys(this._tweens);if(r.length!==0)for(;r.length>0;){this._tweensAddedDuringUpdate={};for(var s=0;s<r.length;s++){var a=this._tweens[r[s]],c=!t;a&&a.update(e,c)===!1&&!t&&this.remove(a)}r=Object.keys(this._tweensAddedDuringUpdate)}},i}(),ju={Linear:function(i,e){var t=i.length-1,r=t*e,s=Math.floor(r),a=ju.Utils.Linear;return e<0?a(i[0],i[1],r):e>1?a(i[t],i[t-1],t-r):a(i[s],i[s+1>t?t:s+1],r-s)},Bezier:function(i,e){for(var t=0,r=i.length-1,s=Math.pow,a=ju.Utils.Bernstein,c=0;c<=r;c++)t+=s(1-e,r-c)*s(e,c)*i[c]*a(r,c);return t},CatmullRom:function(i,e){var t=i.length-1,r=t*e,s=Math.floor(r),a=ju.Utils.CatmullRom;return i[0]===i[t]?(e<0&&(s=Math.floor(r=t*(1+e))),a(i[(s-1+t)%t],i[s],i[(s+1)%t],i[(s+2)%t],r-s)):e<0?i[0]-(a(i[0],i[0],i[1],i[1],-r)-i[0]):e>1?i[t]-(a(i[t],i[t],i[t-1],i[t-1],r-t)-i[t]):a(i[s?s-1:0],i[s],i[t<s+1?t:s+1],i[t<s+2?t:s+2],r-s)},Utils:{Linear:function(i,e,t){return(e-i)*t+i},Bernstein:function(i,e){var t=ju.Utils.Factorial;return t(i)/t(e)/t(i-e)},Factorial:function(){var i=[1];return function(e){var t=1;if(i[e])return i[e];for(var r=e;r>1;r--)t*=r;return i[e]=t,t}}(),CatmullRom:function(i,e,t,r,s){var a=(t-i)*.5,c=(r-e)*.5,h=s*s,f=s*h;return(2*e-2*t+a+c)*f+(-3*e+3*t-2*a-c)*h+a*s+e}}},DS=function(){function i(){}return i.nextId=function(){return i._nextId++},i._nextId=0,i}(),US=new IS,FS=function(){function i(e,t){this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=wl.Linear.None,this._interpolationFunction=ju.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=DS.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1,this._object=e,typeof t=="object"?(this._group=t,t.add(this)):t===!0&&(this._group=US,US.add(this))}return i.prototype.getId=function(){return this._id},i.prototype.isPlaying=function(){return this._isPlaying},i.prototype.isPaused=function(){return this._isPaused},i.prototype.getDuration=function(){return this._duration},i.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},i.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},i.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},i.prototype.start=function(e,t){if(e===void 0&&(e=Xd()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var r in this._valuesStartRepeat)this._swapEndStartRepeatValues(r),this._valuesStart[r]=this._valuesStartRepeat[r]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var s={};for(var a in this._valuesEnd)s[a]=this._valuesEnd[a];this._valuesEnd=s}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},i.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},i.prototype._setupProperties=function(e,t,r,s,a){for(var c in r){var h=e[c],f=Array.isArray(h),m=f?"array":typeof h,x=!f&&Array.isArray(r[c]);if(!(m==="undefined"||m==="function")){if(x){var _=r[c];if(_.length===0)continue;for(var v=[h],T=0,w=_.length;T<w;T+=1){var P=this._handleRelativeValue(h,_[T]);if(isNaN(P)){x=!1,console.warn("Found invalid interpolation list. Skipping.");break}v.push(P)}x&&(r[c]=v)}if((m==="object"||f)&&h&&!x){t[c]=f?[]:{};var C=h;for(var E in C)t[c][E]=C[E];s[c]=f?[]:{};var _=r[c];if(!this._isDynamic){var D={};for(var E in _)D[E]=_[E];r[c]=_=D}this._setupProperties(C,t[c],_,s[c],a)}else(typeof t[c]=="undefined"||a)&&(t[c]=h),f||(t[c]*=1),x?s[c]=r[c].slice().reverse():s[c]=t[c]||0}}},i.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},i.prototype.end=function(){return this._goToEnd=!0,this.update(this._startTime+this._duration),this},i.prototype.pause=function(e){return e===void 0&&(e=Xd()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this)},i.prototype.resume=function(e){return e===void 0&&(e=Xd()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this)},i.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},i.prototype.group=function(e){return e?(e.add(this),this):(console.warn("tween.group() without args has been removed, use group.add(tween) instead."),this)},i.prototype.remove=function(){var e;return(e=this._group)===null||e===void 0||e.remove(this),this},i.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},i.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},i.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},i.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},i.prototype.easing=function(e){return e===void 0&&(e=wl.Linear.None),this._easingFunction=e,this},i.prototype.interpolation=function(e){return e===void 0&&(e=ju.Linear),this._interpolationFunction=e,this},i.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},i.prototype.onStart=function(e){return this._onStartCallback=e,this},i.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},i.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},i.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},i.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},i.prototype.onStop=function(e){return this._onStopCallback=e,this},i.prototype.update=function(e,t){var r=this,s;if(e===void 0&&(e=Xd()),t===void 0&&(t=i.autoStartOnUpdate),this._isPaused)return!0;var a;if(!this._goToEnd&&!this._isPlaying)if(t)this.start(e,!0);else return!1;if(this._goToEnd=!1,e<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var c=e-this._startTime,h=this._duration+((s=this._repeatDelayTime)!==null&&s!==void 0?s:this._delayTime),f=this._duration+this._repeat*h,m=function(){if(r._duration===0||c>f)return 1;var P=Math.trunc(c/h),C=c-P*h,E=Math.min(C/r._duration,1);return E===0&&c===r._duration?1:E},x=m(),_=this._easingFunction(x);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,_),this._onUpdateCallback&&this._onUpdateCallback(this._object,x),this._duration===0||c>=this._duration)if(this._repeat>0){var v=Math.min(Math.trunc((c-this._duration)/h)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=v);for(a in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[a]=="string"&&(this._valuesStartRepeat[a]=this._valuesStartRepeat[a]+parseFloat(this._valuesEnd[a])),this._yoyo&&this._swapEndStartRepeatValues(a),this._valuesStart[a]=this._valuesStartRepeat[a];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=h*v,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var T=0,w=this._chainedTweens.length;T<w;T++)this._chainedTweens[T].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},i.prototype._updateProperties=function(e,t,r,s){for(var a in r)if(t[a]!==void 0){var c=t[a]||0,h=r[a],f=Array.isArray(e[a]),m=Array.isArray(h),x=!f&&m;x?e[a]=this._interpolationFunction(h,s):typeof h=="object"&&h?this._updateProperties(e[a],c,h,s):(h=this._handleRelativeValue(c,h),typeof h=="number"&&(e[a]=c+(h-c)*s))}},i.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},i.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],r=this._valuesEnd[e];typeof r=="string"?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(r):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},i.autoStartOnUpdate=!1,i}(),aO="25.0.0",cO=DS.nextId,wa=US,lO=wa.getAll.bind(wa),uO=wa.removeAll.bind(wa),hO=wa.add.bind(wa),dO=wa.remove.bind(wa),fO=wa.update.bind(wa),_5={Easing:wl,Group:IS,Interpolation:ju,now:Xd,Sequence:DS,nextId:cO,Tween:FS,VERSION:aO,getAll:lO,removeAll:uO,add:hO,remove:dO,update:fO};function pO(){}function xE(i){return i==null?pO:function(){return this.querySelector(i)}}function mO(i){typeof i!="function"&&(i=xE(i));for(var e=this._groups,t=e.length,r=new Array(t),s=0;s<t;++s)for(var a=e[s],c=a.length,h=r[s]=new Array(c),f,m,x=0;x<c;++x)(f=a[x])&&(m=i.call(f,f.__data__,x,a))&&("__data__"in f&&(m.__data__=f.__data__),h[x]=m);return new Js(r,this._parents)}function gO(i){return i==null?[]:Array.isArray(i)?i:Array.from(i)}function xO(){return[]}function _O(i){return i==null?xO:function(){return this.querySelectorAll(i)}}function yO(i){return function(){return gO(i.apply(this,arguments))}}function bO(i){typeof i=="function"?i=yO(i):i=_O(i);for(var e=this._groups,t=e.length,r=[],s=[],a=0;a<t;++a)for(var c=e[a],h=c.length,f,m=0;m<h;++m)(f=c[m])&&(r.push(i.call(f,f.__data__,m,c)),s.push(f));return new Js(r,s)}function vO(i){return function(){return this.matches(i)}}function _E(i){return function(e){return e.matches(i)}}var SO=Array.prototype.find;function TO(i){return function(){return SO.call(this.children,i)}}function MO(){return this.firstElementChild}function wO(i){return this.select(i==null?MO:TO(typeof i=="function"?i:_E(i)))}var AO=Array.prototype.filter;function EO(){return Array.from(this.children)}function CO(i){return function(){return AO.call(this.children,i)}}function RO(i){return this.selectAll(i==null?EO:CO(typeof i=="function"?i:_E(i)))}function NO(i){typeof i!="function"&&(i=vO(i));for(var e=this._groups,t=e.length,r=new Array(t),s=0;s<t;++s)for(var a=e[s],c=a.length,h=r[s]=[],f,m=0;m<c;++m)(f=a[m])&&i.call(f,f.__data__,m,a)&&h.push(f);return new Js(r,this._parents)}function yE(i){return new Array(i.length)}function PO(){return new Js(this._enter||this._groups.map(yE),this._parents)}function o_(i,e){this.ownerDocument=i.ownerDocument,this.namespaceURI=i.namespaceURI,this._next=null,this._parent=i,this.__data__=e}o_.prototype={constructor:o_,appendChild:function(i){return this._parent.insertBefore(i,this._next)},insertBefore:function(i,e){return this._parent.insertBefore(i,e)},querySelector:function(i){return this._parent.querySelector(i)},querySelectorAll:function(i){return this._parent.querySelectorAll(i)}};function LO(i){return function(){return i}}function IO(i,e,t,r,s,a){for(var c=0,h,f=e.length,m=a.length;c<m;++c)(h=e[c])?(h.__data__=a[c],r[c]=h):t[c]=new o_(i,a[c]);for(;c<f;++c)(h=e[c])&&(s[c]=h)}function DO(i,e,t,r,s,a,c){var h,f,m=new Map,x=e.length,_=a.length,v=new Array(x),T;for(h=0;h<x;++h)(f=e[h])&&(v[h]=T=c.call(f,f.__data__,h,e)+"",m.has(T)?s[h]=f:m.set(T,f));for(h=0;h<_;++h)T=c.call(i,a[h],h,a)+"",(f=m.get(T))?(r[h]=f,f.__data__=a[h],m.delete(T)):t[h]=new o_(i,a[h]);for(h=0;h<x;++h)(f=e[h])&&m.get(v[h])===f&&(s[h]=f)}function UO(i){return i.__data__}function FO(i,e){if(!arguments.length)return Array.from(this,UO);var t=e?DO:IO,r=this._parents,s=this._groups;typeof i!="function"&&(i=LO(i));for(var a=s.length,c=new Array(a),h=new Array(a),f=new Array(a),m=0;m<a;++m){var x=r[m],_=s[m],v=_.length,T=BO(i.call(x,x&&x.__data__,m,r)),w=T.length,P=h[m]=new Array(w),C=c[m]=new Array(w),E=f[m]=new Array(v);t(x,_,P,C,E,T,e);for(var D=0,F=0,W,K;D<w;++D)if(W=P[D]){for(D>=F&&(F=D+1);!(K=C[F])&&++F<w;);W._next=K||null}}return c=new Js(c,r),c._enter=h,c._exit=f,c}function BO(i){return typeof i=="object"&&"length"in i?i:Array.from(i)}function OO(){return new Js(this._exit||this._groups.map(yE),this._parents)}function kO(i,e,t){var r=this.enter(),s=this,a=this.exit();return typeof i=="function"?(r=i(r),r&&(r=r.selection())):r=r.append(i+""),e!=null&&(s=e(s),s&&(s=s.selection())),t==null?a.remove():t(a),r&&s?r.merge(s).order():s}function VO(i){for(var e=i.selection?i.selection():i,t=this._groups,r=e._groups,s=t.length,a=r.length,c=Math.min(s,a),h=new Array(s),f=0;f<c;++f)for(var m=t[f],x=r[f],_=m.length,v=h[f]=new Array(_),T,w=0;w<_;++w)(T=m[w]||x[w])&&(v[w]=T);for(;f<s;++f)h[f]=t[f];return new Js(h,this._parents)}function zO(){for(var i=this._groups,e=-1,t=i.length;++e<t;)for(var r=i[e],s=r.length-1,a=r[s],c;--s>=0;)(c=r[s])&&(a&&c.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(c,a),a=c);return this}function GO(i){i||(i=WO);function e(_,v){return _&&v?i(_.__data__,v.__data__):!_-!v}for(var t=this._groups,r=t.length,s=new Array(r),a=0;a<r;++a){for(var c=t[a],h=c.length,f=s[a]=new Array(h),m,x=0;x<h;++x)(m=c[x])&&(f[x]=m);f.sort(e)}return new Js(s,this._parents).order()}function WO(i,e){return i<e?-1:i>e?1:i>=e?0:NaN}function HO(){var i=arguments[0];return arguments[0]=this,i.apply(null,arguments),this}function $O(){return Array.from(this)}function jO(){for(var i=this._groups,e=0,t=i.length;e<t;++e)for(var r=i[e],s=0,a=r.length;s<a;++s){var c=r[s];if(c)return c}return null}function XO(){let i=0;for(const e of this)++i;return i}function qO(){return!this.node()}function KO(i){for(var e=this._groups,t=0,r=e.length;t<r;++t)for(var s=e[t],a=0,c=s.length,h;a<c;++a)(h=s[a])&&i.call(h,h.__data__,a,s);return this}var BS="http://www.w3.org/1999/xhtml",bE={svg:"http://www.w3.org/2000/svg",xhtml:BS,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function vE(i){var e=i+="",t=e.indexOf(":");return t>=0&&(e=i.slice(0,t))!=="xmlns"&&(i=i.slice(t+1)),bE.hasOwnProperty(e)?{space:bE[e],local:i}:i}function ZO(i){return function(){this.removeAttribute(i)}}function YO(i){return function(){this.removeAttributeNS(i.space,i.local)}}function QO(i,e){return function(){this.setAttribute(i,e)}}function JO(i,e){return function(){this.setAttributeNS(i.space,i.local,e)}}function ek(i,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(i):this.setAttribute(i,t)}}function tk(i,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttributeNS(i.space,i.local):this.setAttributeNS(i.space,i.local,t)}}function nk(i,e){var t=vE(i);if(arguments.length<2){var r=this.node();return t.local?r.getAttributeNS(t.space,t.local):r.getAttribute(t)}return this.each((e==null?t.local?YO:ZO:typeof e=="function"?t.local?tk:ek:t.local?JO:QO)(t,e))}function SE(i){return i.ownerDocument&&i.ownerDocument.defaultView||i.document&&i||i.defaultView}function ik(i){return function(){this.style.removeProperty(i)}}function rk(i,e,t){return function(){this.style.setProperty(i,e,t)}}function sk(i,e,t){return function(){var r=e.apply(this,arguments);r==null?this.style.removeProperty(i):this.style.setProperty(i,r,t)}}function ok(i,e,t){return arguments.length>1?this.each((e==null?ik:typeof e=="function"?sk:rk)(i,e,t==null?"":t)):ak(this.node(),i)}function ak(i,e){return i.style.getPropertyValue(e)||SE(i).getComputedStyle(i,null).getPropertyValue(e)}function ck(i){return function(){delete this[i]}}function lk(i,e){return function(){this[i]=e}}function uk(i,e){return function(){var t=e.apply(this,arguments);t==null?delete this[i]:this[i]=t}}function hk(i,e){return arguments.length>1?this.each((e==null?ck:typeof e=="function"?uk:lk)(i,e)):this.node()[i]}function TE(i){return i.trim().split(/^|\s+/)}function OS(i){return i.classList||new ME(i)}function ME(i){this._node=i,this._names=TE(i.getAttribute("class")||"")}ME.prototype={add:function(i){var e=this._names.indexOf(i);e<0&&(this._names.push(i),this._node.setAttribute("class",this._names.join(" ")))},remove:function(i){var e=this._names.indexOf(i);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(i){return this._names.indexOf(i)>=0}};function wE(i,e){for(var t=OS(i),r=-1,s=e.length;++r<s;)t.add(e[r])}function AE(i,e){for(var t=OS(i),r=-1,s=e.length;++r<s;)t.remove(e[r])}function dk(i){return function(){wE(this,i)}}function fk(i){return function(){AE(this,i)}}function pk(i,e){return function(){(e.apply(this,arguments)?wE:AE)(this,i)}}function mk(i,e){var t=TE(i+"");if(arguments.length<2){for(var r=OS(this.node()),s=-1,a=t.length;++s<a;)if(!r.contains(t[s]))return!1;return!0}return this.each((typeof e=="function"?pk:e?dk:fk)(t,e))}function gk(){this.textContent=""}function xk(i){return function(){this.textContent=i}}function _k(i){return function(){var e=i.apply(this,arguments);this.textContent=e==null?"":e}}function yk(i){return arguments.length?this.each(i==null?gk:(typeof i=="function"?_k:xk)(i)):this.node().textContent}function bk(){this.innerHTML=""}function vk(i){return function(){this.innerHTML=i}}function Sk(i){return function(){var e=i.apply(this,arguments);this.innerHTML=e==null?"":e}}function Tk(i){return arguments.length?this.each(i==null?bk:(typeof i=="function"?Sk:vk)(i)):this.node().innerHTML}function Mk(){this.nextSibling&&this.parentNode.appendChild(this)}function wk(){return this.each(Mk)}function Ak(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ek(){return this.each(Ak)}function Ck(i){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===BS&&e.documentElement.namespaceURI===BS?e.createElement(i):e.createElementNS(t,i)}}function Rk(i){return function(){return this.ownerDocument.createElementNS(i.space,i.local)}}function EE(i){var e=vE(i);return(e.local?Rk:Ck)(e)}function Nk(i){var e=typeof i=="function"?i:EE(i);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function Pk(){return null}function Lk(i,e){var t=typeof i=="function"?i:EE(i),r=e==null?Pk:typeof e=="function"?e:xE(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),r.apply(this,arguments)||null)})}function Ik(){var i=this.parentNode;i&&i.removeChild(this)}function Dk(){return this.each(Ik)}function Uk(){var i=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(i,this.nextSibling):i}function Fk(){var i=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(i,this.nextSibling):i}function Bk(i){return this.select(i?Fk:Uk)}function Ok(i){return arguments.length?this.property("__data__",i):this.node().__data__}function kk(i){return function(e){i.call(this,e,this.__data__)}}function Vk(i){return i.trim().split(/^|\s+/).map(function(e){var t="",r=e.indexOf(".");return r>=0&&(t=e.slice(r+1),e=e.slice(0,r)),{type:e,name:t}})}function zk(i){return function(){var e=this.__on;if(e){for(var t=0,r=-1,s=e.length,a;t<s;++t)a=e[t],(!i.type||a.type===i.type)&&a.name===i.name?this.removeEventListener(a.type,a.listener,a.options):e[++r]=a;++r?e.length=r:delete this.__on}}}function Gk(i,e,t){return function(){var r=this.__on,s,a=kk(e);if(r){for(var c=0,h=r.length;c<h;++c)if((s=r[c]).type===i.type&&s.name===i.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=a,s.options=t),s.value=e;return}}this.addEventListener(i.type,a,t),s={type:i.type,name:i.name,value:e,listener:a,options:t},r?r.push(s):this.__on=[s]}}function Wk(i,e,t){var r=Vk(i+""),s,a=r.length,c;if(arguments.length<2){var h=this.node().__on;if(h){for(var f=0,m=h.length,x;f<m;++f)for(s=0,x=h[f];s<a;++s)if((c=r[s]).type===x.type&&c.name===x.name)return x.value}return}for(h=e?Gk:zk,s=0;s<a;++s)this.each(h(r[s],e,t));return this}function CE(i,e,t){var r=SE(i),s=r.CustomEvent;typeof s=="function"?s=new s(e,t):(s=r.document.createEvent("Event"),t?(s.initEvent(e,t.bubbles,t.cancelable),s.detail=t.detail):s.initEvent(e,!1,!1)),i.dispatchEvent(s)}function Hk(i,e){return function(){return CE(this,i,e)}}function $k(i,e){return function(){return CE(this,i,e.apply(this,arguments))}}function jk(i,e){return this.each((typeof e=="function"?$k:Hk)(i,e))}function*Xk(){for(var i=this._groups,e=0,t=i.length;e<t;++e)for(var r=i[e],s=0,a=r.length,c;s<a;++s)(c=r[s])&&(yield c)}var RE=[null];function Js(i,e){this._groups=i,this._parents=e}function qk(){return new Js([[document.documentElement]],RE)}function Kk(){return this}Js.prototype=qk.prototype={constructor:Js,select:mO,selectAll:bO,selectChild:wO,selectChildren:RO,filter:NO,data:FO,enter:PO,exit:OO,join:kO,merge:VO,selection:Kk,order:zO,sort:GO,call:HO,nodes:$O,node:jO,size:XO,empty:qO,each:KO,attr:nk,style:ok,property:hk,classed:mk,text:yk,html:Tk,raise:wk,lower:Ek,append:Nk,insert:Lk,remove:Dk,clone:Bk,datum:Ok,on:Wk,dispatch:jk,[Symbol.iterator]:Xk};var y5=null;function Zk(i){return typeof i=="string"?new Js([[document.querySelector(i)]],[document.documentElement]):new Js([[i]],RE)}function Yk(i){let e;for(;e=i.sourceEvent;)i=e;return i}function Qk(i,e){if(i=Yk(i),e===void 0&&(e=i.currentTarget),e){var t=e.ownerSVGElement||e;if(t.createSVGPoint){var r=t.createSVGPoint();return r.x=i.clientX,r.y=i.clientY,r=r.matrixTransform(e.getScreenCTM().inverse()),[r.x,r.y]}if(e.getBoundingClientRect){var s=e.getBoundingClientRect();return[i.clientX-s.left-e.clientLeft,i.clientY-s.top-e.clientTop]}}return[i.pageX,i.pageY]}var Pm,Wi,NE,PE,Xu,LE,IE,DE,UE,kS,VS,zS,FE,Lm={},BE=[],Jk=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Im=Array.isArray;function Aa(i,e){for(var t in e)i[t]=e[t];return i}function GS(i){i&&i.parentNode&&i.parentNode.removeChild(i)}function eV(i,e,t){var r,s,a,c={};for(a in e)a=="key"?r=e[a]:a=="ref"?s=e[a]:c[a]=e[a];if(arguments.length>2&&(c.children=arguments.length>3?Pm.call(arguments,2):t),typeof i=="function"&&i.defaultProps!=null)for(a in i.defaultProps)c[a]===void 0&&(c[a]=i.defaultProps[a]);return Dm(i,c,r,s,null)}function Dm(i,e,t,r,s){var a={type:i,props:e,key:t,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:s==null?++NE:s,__i:-1,__u:0};return s==null&&Wi.vnode!=null&&Wi.vnode(a),a}function b5(){return{current:null}}function a_(i){return i.children}function c_(i,e){this.props=i,this.context=e}function qd(i,e){if(e==null)return i.__?qd(i.__,i.__i+1):null;for(var t;e<i.__k.length;e++)if((t=i.__k[e])!=null&&t.__e!=null)return t.__e;return typeof i.type=="function"?qd(i):null}function OE(i){var e,t;if((i=i.__)!=null&&i.__c!=null){for(i.__e=i.__c.base=null,e=0;e<i.__k.length;e++)if((t=i.__k[e])!=null&&t.__e!=null){i.__e=i.__c.base=t.__e;break}return OE(i)}}function WS(i){(!i.__d&&(i.__d=!0)&&Xu.push(i)&&!l_.__r++||LE!=Wi.debounceRendering)&&((LE=Wi.debounceRendering)||IE)(l_)}function l_(){for(var i,e,t,r,s,a,c,h=1;Xu.length;)Xu.length>h&&Xu.sort(DE),i=Xu.shift(),h=Xu.length,i.__d&&(t=void 0,r=void 0,s=(r=(e=i).__v).__e,a=[],c=[],e.__P&&((t=Aa({},r)).__v=r.__v+1,Wi.vnode&&Wi.vnode(t),HS(e.__P,t,r,e.__n,e.__P.namespaceURI,32&r.__u?[s]:null,a,s==null?qd(r):s,!!(32&r.__u),c),t.__v=r.__v,t.__.__k[t.__i]=t,WE(a,t,c),r.__e=r.__=null,t.__e!=s&&OE(t)));l_.__r=0}function kE(i,e,t,r,s,a,c,h,f,m,x){var _,v,T,w,P,C,E,D=r&&r.__k||BE,F=e.length;for(f=tV(t,e,D,f,F),_=0;_<F;_++)(T=t.__k[_])!=null&&(v=T.__i==-1?Lm:D[T.__i]||Lm,T.__i=_,C=HS(i,T,v,s,a,c,h,f,m,x),w=T.__e,T.ref&&v.ref!=T.ref&&(v.ref&&jS(v.ref,null,T),x.push(T.ref,T.__c||w,T)),P==null&&w!=null&&(P=w),(E=!!(4&T.__u))||v.__k===T.__k?f=VE(T,f,i,E):typeof T.type=="function"&&C!==void 0?f=C:w&&(f=w.nextSibling),T.__u&=-7);return t.__e=P,f}function tV(i,e,t,r,s){var a,c,h,f,m,x=t.length,_=x,v=0;for(i.__k=new Array(s),a=0;a<s;a++)(c=e[a])!=null&&typeof c!="boolean"&&typeof c!="function"?(typeof c=="string"||typeof c=="number"||typeof c=="bigint"||c.constructor==String?c=i.__k[a]=Dm(null,c,null,null,null):Im(c)?c=i.__k[a]=Dm(a_,{children:c},null,null,null):c.constructor==null&&c.__b>0?c=i.__k[a]=Dm(c.type,c.props,c.key,c.ref?c.ref:null,c.__v):i.__k[a]=c,f=a+v,c.__=i,c.__b=i.__b+1,(m=c.__i=iV(c,t,f,_))!=-1&&(_--,(h=t[m])&&(h.__u|=2)),h==null||h.__v==null?(m==-1&&(s>x?v--:s<x&&v++),typeof c.type!="function"&&(c.__u|=4)):m!=f&&(m==f-1?v--:m==f+1?v++:(m>f?v--:v++,c.__u|=4))):i.__k[a]=null;if(_)for(a=0;a<x;a++)(h=t[a])!=null&&!(2&h.__u)&&(h.__e==r&&(r=qd(h)),$E(h,h));return r}function VE(i,e,t,r){var s,a;if(typeof i.type=="function"){for(s=i.__k,a=0;s&&a<s.length;a++)s[a]&&(s[a].__=i,e=VE(s[a],e,t,r));return e}i.__e!=e&&(r&&(e&&i.type&&!e.parentNode&&(e=qd(i)),t.insertBefore(i.__e,e||null)),e=i.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function nV(i,e){return e=e||[],i==null||typeof i=="boolean"||(Im(i)?i.some(function(t){nV(t,e)}):e.push(i)),e}function iV(i,e,t,r){var s,a,c,h=i.key,f=i.type,m=e[t],x=m!=null&&(2&m.__u)==0;if(m===null&&h==null||x&&h==m.key&&f==m.type)return t;if(r>(x?1:0)){for(s=t-1,a=t+1;s>=0||a<e.length;)if((m=e[c=s>=0?s--:a++])!=null&&!(2&m.__u)&&h==m.key&&f==m.type)return c}return-1}function zE(i,e,t){e[0]=="-"?i.setProperty(e,t==null?"":t):i[e]=t==null?"":typeof t!="number"||Jk.test(e)?t:t+"px"}function u_(i,e,t,r,s){var a,c;e:if(e=="style")if(typeof t=="string")i.style.cssText=t;else{if(typeof r=="string"&&(i.style.cssText=r=""),r)for(e in r)t&&e in t||zE(i.style,e,"");if(t)for(e in t)r&&t[e]==r[e]||zE(i.style,e,t[e])}else if(e[0]=="o"&&e[1]=="n")a=e!=(e=e.replace(UE,"$1")),c=e.toLowerCase(),e=c in i||e=="onFocusOut"||e=="onFocusIn"?c.slice(2):e.slice(2),i.l||(i.l={}),i.l[e+a]=t,t?r?t.u=r.u:(t.u=kS,i.addEventListener(e,a?zS:VS,a)):i.removeEventListener(e,a?zS:VS,a);else{if(s=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in i)try{i[e]=t==null?"":t;break e}catch(h){}typeof t=="function"||(t==null||t===!1&&e[4]!="-"?i.removeAttribute(e):i.setAttribute(e,e=="popover"&&t==1?"":t))}}function GE(i){return function(e){if(this.l){var t=this.l[e.type+i];if(e.t==null)e.t=kS++;else if(e.t<t.u)return;return t(Wi.event?Wi.event(e):e)}}}function HS(i,e,t,r,s,a,c,h,f,m){var x,_,v,T,w,P,C,E,D,F,W,K,U,j,oe,k,O,le=e.type;if(e.constructor!=null)return null;128&t.__u&&(f=!!(32&t.__u),a=[h=e.__e=t.__e]),(x=Wi.__b)&&x(e);e:if(typeof le=="function")try{if(E=e.props,D="prototype"in le&&le.prototype.render,F=(x=le.contextType)&&r[x.__c],W=x?F?F.props.value:x.__:r,t.__c?C=(_=e.__c=t.__c).__=_.__E:(D?e.__c=_=new le(E,W):(e.__c=_=new c_(E,W),_.constructor=le,_.render=sV),F&&F.sub(_),_.state||(_.state={}),_.__n=r,v=_.__d=!0,_.__h=[],_._sb=[]),D&&_.__s==null&&(_.__s=_.state),D&&le.getDerivedStateFromProps!=null&&(_.__s==_.state&&(_.__s=Aa({},_.__s)),Aa(_.__s,le.getDerivedStateFromProps(E,_.__s))),T=_.props,w=_.state,_.__v=e,v)D&&le.getDerivedStateFromProps==null&&_.componentWillMount!=null&&_.componentWillMount(),D&&_.componentDidMount!=null&&_.__h.push(_.componentDidMount);else{if(D&&le.getDerivedStateFromProps==null&&E!==T&&_.componentWillReceiveProps!=null&&_.componentWillReceiveProps(E,W),e.__v==t.__v||!_.__e&&_.shouldComponentUpdate!=null&&_.shouldComponentUpdate(E,_.__s,W)===!1){for(e.__v!=t.__v&&(_.props=E,_.state=_.__s,_.__d=!1),e.__e=t.__e,e.__k=t.__k,e.__k.some(function(be){be&&(be.__=e)}),K=0;K<_._sb.length;K++)_.__h.push(_._sb[K]);_._sb=[],_.__h.length&&c.push(_);break e}_.componentWillUpdate!=null&&_.componentWillUpdate(E,_.__s,W),D&&_.componentDidUpdate!=null&&_.__h.push(function(){_.componentDidUpdate(T,w,P)})}if(_.context=W,_.props=E,_.__P=i,_.__e=!1,U=Wi.__r,j=0,D){for(_.state=_.__s,_.__d=!1,U&&U(e),x=_.render(_.props,_.state,_.context),oe=0;oe<_._sb.length;oe++)_.__h.push(_._sb[oe]);_._sb=[]}else do _.__d=!1,U&&U(e),x=_.render(_.props,_.state,_.context),_.state=_.__s;while(_.__d&&++j<25);_.state=_.__s,_.getChildContext!=null&&(r=Aa(Aa({},r),_.getChildContext())),D&&!v&&_.getSnapshotBeforeUpdate!=null&&(P=_.getSnapshotBeforeUpdate(T,w)),k=x,x!=null&&x.type===a_&&x.key==null&&(k=HE(x.props.children)),h=kE(i,Im(k)?k:[k],e,t,r,s,a,c,h,f,m),_.base=e.__e,e.__u&=-161,_.__h.length&&c.push(_),C&&(_.__E=_.__=null)}catch(be){if(e.__v=null,f||a!=null)if(be.then){for(e.__u|=f?160:128;h&&h.nodeType==8&&h.nextSibling;)h=h.nextSibling;a[a.indexOf(h)]=null,e.__e=h}else{for(O=a.length;O--;)GS(a[O]);$S(e)}else e.__e=t.__e,e.__k=t.__k,be.then||$S(e);Wi.__e(be,e,t)}else a==null&&e.__v==t.__v?(e.__k=t.__k,e.__e=t.__e):h=e.__e=rV(t.__e,e,t,r,s,a,c,f,m);return(x=Wi.diffed)&&x(e),128&e.__u?void 0:h}function $S(i){i&&i.__c&&(i.__c.__e=!0),i&&i.__k&&i.__k.forEach($S)}function WE(i,e,t){for(var r=0;r<t.length;r++)jS(t[r],t[++r],t[++r]);Wi.__c&&Wi.__c(e,i),i.some(function(s){try{i=s.__h,s.__h=[],i.some(function(a){a.call(s)})}catch(a){Wi.__e(a,s.__v)}})}function HE(i){return typeof i!="object"||i==null||i.__b&&i.__b>0?i:Im(i)?i.map(HE):Aa({},i)}function rV(i,e,t,r,s,a,c,h,f){var m,x,_,v,T,w,P,C=t.props||Lm,E=e.props,D=e.type;if(D=="svg"?s="http://www.w3.org/2000/svg":D=="math"?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),a!=null){for(m=0;m<a.length;m++)if((T=a[m])&&"setAttribute"in T==!!D&&(D?T.localName==D:T.nodeType==3)){i=T,a[m]=null;break}}if(i==null){if(D==null)return document.createTextNode(E);i=document.createElementNS(s,D,E.is&&E),h&&(Wi.__m&&Wi.__m(e,a),h=!1),a=null}if(D==null)C===E||h&&i.data==E||(i.data=E);else{if(a=a&&Pm.call(i.childNodes),!h&&a!=null)for(C={},m=0;m<i.attributes.length;m++)C[(T=i.attributes[m]).name]=T.value;for(m in C)if(T=C[m],m!="children"){if(m=="dangerouslySetInnerHTML")_=T;else if(!(m in E)){if(m=="value"&&"defaultValue"in E||m=="checked"&&"defaultChecked"in E)continue;u_(i,m,null,T,s)}}for(m in E)T=E[m],m=="children"?v=T:m=="dangerouslySetInnerHTML"?x=T:m=="value"?w=T:m=="checked"?P=T:h&&typeof T!="function"||C[m]===T||u_(i,m,T,C[m],s);if(x)h||_&&(x.__html==_.__html||x.__html==i.innerHTML)||(i.innerHTML=x.__html),e.__k=[];else if(_&&(i.innerHTML=""),kE(e.type=="template"?i.content:i,Im(v)?v:[v],e,t,r,D=="foreignObject"?"http://www.w3.org/1999/xhtml":s,a,c,a?a[0]:t.__k&&qd(t,0),h,f),a!=null)for(m=a.length;m--;)GS(a[m]);h||(m="value",D=="progress"&&w==null?i.removeAttribute("value"):w!=null&&(w!==i[m]||D=="progress"&&!w||D=="option"&&w!=C[m])&&u_(i,m,w,C[m],s),m="checked",P!=null&&P!=i[m]&&u_(i,m,P,C[m],s))}return i}function jS(i,e,t){try{if(typeof i=="function"){var r=typeof i.__u=="function";r&&i.__u(),r&&e==null||(i.__u=i(e))}else i.current=e}catch(s){Wi.__e(s,t)}}function $E(i,e,t){var r,s;if(Wi.unmount&&Wi.unmount(i),(r=i.ref)&&(r.current&&r.current!=i.__e||jS(r,null,e)),(r=i.__c)!=null){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(a){Wi.__e(a,e)}r.base=r.__P=null}if(r=i.__k)for(s=0;s<r.length;s++)r[s]&&$E(r[s],e,t||typeof i.type!="function");t||GS(i.__e),i.__c=i.__=i.__e=void 0}function sV(i,e,t){return this.constructor(i,t)}function jE(i,e,t){var r,s,a,c;e==document&&(e=document.documentElement),Wi.__&&Wi.__(i,e),s=(r=typeof t=="function")?null:t&&t.__k||e.__k,a=[],c=[],HS(e,i=(!r&&t||e).__k=eV(a_,null,[i]),s||Lm,Lm,e.namespaceURI,!r&&t?[t]:s?null:e.firstChild?Pm.call(e.childNodes):null,a,!r&&t?t:s?s.__e:e.firstChild,r,c),WE(a,i,c)}function oV(i,e){jE(i,e,oV)}function XE(i,e,t){var r,s,a,c,h=Aa({},i.props);for(a in i.type&&i.type.defaultProps&&(c=i.type.defaultProps),e)a=="key"?r=e[a]:a=="ref"?s=e[a]:h[a]=e[a]===void 0&&c!=null?c[a]:e[a];return arguments.length>2&&(h.children=arguments.length>3?Pm.call(arguments,2):t),Dm(i.type,h,r||i.key,s||i.ref,null)}function v5(i){function e(t){var r,s;return this.getChildContext||(r=new Set,(s={})[e.__c]=this,this.getChildContext=function(){return s},this.componentWillUnmount=function(){r=null},this.shouldComponentUpdate=function(a){this.props.value!=a.value&&r.forEach(function(c){c.__e=!0,WS(c)})},this.sub=function(a){r.add(a);var c=a.componentWillUnmount;a.componentWillUnmount=function(){r&&r.delete(a),c&&c.call(a)}}),t.children}return e.__c="__cC"+FE++,e.__=i,e.Provider=e.__l=(e.Consumer=function(t,r){return t.children(r)}).contextType=e,e}Pm=BE.slice,Wi={__e:function(i,e,t,r){for(var s,a,c;e=e.__;)if((s=e.__c)&&!s.__)try{if((a=s.constructor)&&a.getDerivedStateFromError!=null&&(s.setState(a.getDerivedStateFromError(i)),c=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(i,r||{}),c=s.__d),c)return s.__E=s}catch(h){i=h}throw i}},NE=0,PE=function(i){return i!=null&&i.constructor==null},c_.prototype.setState=function(i,e){var t;t=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Aa({},this.state),typeof i=="function"&&(i=i(Aa({},t),this.props)),i&&Aa(t,i),i!=null&&this.__v&&(e&&this._sb.push(e),WS(this))},c_.prototype.forceUpdate=function(i){this.__v&&(this.__e=!0,i&&this.__h.push(i),WS(this))},c_.prototype.render=a_,Xu=[],IE=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,DE=function(i,e){return i.__v.__b-e.__v.__b},l_.__r=0,UE=/(PointerCapture)$|Capture$/i,kS=0,VS=GE(!1),zS=GE(!0),FE=0;function qE(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,r=Array(e);t<e;t++)r[t]=i[t];return r}function aV(i){if(Array.isArray(i))return i}function cV(i,e,t){return(e=pV(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function lV(i,e){var t=i==null?null:typeof Symbol!="undefined"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var r,s,a,c,h=[],f=!0,m=!1;try{if(a=(t=t.call(i)).next,e!==0)for(;!(f=(r=a.call(t)).done)&&(h.push(r.value),h.length!==e);f=!0);}catch(x){m=!0,s=x}finally{try{if(!f&&t.return!=null&&(c=t.return(),Object(c)!==c))return}finally{if(m)throw s}}return h}}function uV(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function KE(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,r)}return t}function hV(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?KE(Object(t),!0).forEach(function(r){cV(i,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):KE(Object(t)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(t,r))})}return i}function dV(i,e){return aV(i)||lV(i,e)||mV(i,e)||uV()}function fV(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var r=t.call(i,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function pV(i){var e=fV(i,"string");return typeof e=="symbol"?e:e+""}function h_(i){"@babel/helpers - typeof";return h_=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},h_(i)}function mV(i,e){if(i){if(typeof i=="string")return qE(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?qE(i,e):void 0}}var XS=function(e){if(h_(e)!=="object")return e;var t=XE(e);if(t.props){var r;t.props=hV({},t.props),t!=null&&(r=t.props)!==null&&r!==void 0&&r.children&&(t.props.children=Array.isArray(t.props.children)?t.props.children.map(XS):XS(t.props.children))}return t},gV=function(e){return PE(XE(e))},xV=function(e,t){delete t.__k,jE(XS(e),t)};function _V(i,e){e===void 0&&(e={});var t=e.insertAt;if(typeof document!="undefined"){var r=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css",t==="top"&&r.firstChild?r.insertBefore(s,r.firstChild):r.appendChild(s),s.styleSheet?s.styleSheet.cssText=i:s.appendChild(document.createTextNode(i))}}var yV=`.float-tooltip-kap {
position: absolute;
width: max-content; /* prevent shrinking near right edge */
max-width: max(50%, 150px);
padding: 3px 5px;
border-radius: 3px;
font: 12px sans-serif;
color: #eee;
background: rgba(0,0,0,0.6);
pointer-events: none;
}
`;_V(yV);var bV=wo({props:{content:{default:!1},offsetX:{triggerUpdate:!1},offsetY:{triggerUpdate:!1}},init:function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=r.style,a=s===void 0?{}:s,c=!!e&&h_(e)==="object"&&!!e.node&&typeof e.node=="function",h=Zk(c?e.node():e);h.style("position")==="static"&&h.style("position","relative"),t.tooltipEl=h.append("div").attr("class","float-tooltip-kap"),Object.entries(a).forEach(function(m){var x=dV(m,2),_=x[0],v=x[1];return t.tooltipEl.style(_,v)}),t.tooltipEl.style("left","-10000px").style("display","none");var f="tooltip-".concat(Math.round(Math.random()*1e12));t.mouseInside=!1,h.on("mousemove.".concat(f),function(m){t.mouseInside=!0;var x=Qk(m),_=h.node(),v=_.offsetWidth,T=_.offsetHeight,w=[t.offsetX===null||t.offsetX===void 0?"-".concat(x[0]/v*100,"%"):typeof t.offsetX=="number"?"calc(-50% + ".concat(t.offsetX,"px)"):t.offsetX,t.offsetY===null||t.offsetY===void 0?T>130&&T-x[1]<100?"calc(-100% - 6px)":"21px":typeof t.offsetY=="number"?t.offsetY<0?"calc(-100% - ".concat(Math.abs(t.offsetY),"px)"):"".concat(t.offsetY,"px"):t.offsetY];t.tooltipEl.style("left",x[0]+"px").style("top",x[1]+"px").style("transform","translate(".concat(w.join(","),")")),t.content&&t.tooltipEl.style("display","inline")}),h.on("mouseover.".concat(f),function(){t.mouseInside=!0,t.content&&t.tooltipEl.style("display","inline")}),h.on("mouseout.".concat(f),function(){t.mouseInside=!1,t.tooltipEl.style("display","none")})},update:function(e){e.tooltipEl.style("display",e.content&&e.mouseInside?"inline":"none"),e.content?e.content instanceof HTMLElement?(e.tooltipEl.text(""),e.tooltipEl.append(function(){return e.content})):typeof e.content=="string"?e.tooltipEl.html(e.content):gV(e.content)?(e.tooltipEl.text(""),xV(e.content,e.tooltipEl.node())):(e.tooltipEl.style("display","none"),console.warn("Tooltip content is invalid, skipping.",e.content,e.content.toString())):e.tooltipEl.text("")}});function vV(i,e){e===void 0&&(e={});var t=e.insertAt;if(typeof document!="undefined"){var r=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css",t==="top"&&r.firstChild?r.insertBefore(s,r.firstChild):r.appendChild(s),s.styleSheet?s.styleSheet.cssText=i:s.appendChild(document.createTextNode(i))}}var SV=`.scene-nav-info {
position: absolute;
bottom: 5px;
width: 100%;
text-align: center;
color: slategrey;
opacity: 0.7;
font-size: 10px;
font-family: sans-serif;
pointer-events: none;
user-select: none;
}
.scene-container canvas:focus {
outline: none;
}`;vV(SV);function qS(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,r=Array(e);t<e;t++)r[t]=i[t];return r}function TV(i){if(Array.isArray(i))return i}function MV(i){if(Array.isArray(i))return qS(i)}function wV(i,e,t){return(e=LV(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function AV(i){if(typeof Symbol!="undefined"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function EV(i,e){var t=i==null?null:typeof Symbol!="undefined"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var r,s,a,c,h=[],f=!0,m=!1;try{if(a=(t=t.call(i)).next,e!==0)for(;!(f=(r=a.call(t)).done)&&(h.push(r.value),h.length!==e);f=!0);}catch(x){m=!0,s=x}finally{try{if(!f&&t.return!=null&&(c=t.return(),Object(c)!==c))return}finally{if(m)throw s}}return h}}function CV(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function RV(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function NV(i,e){return TV(i)||EV(i,e)||ZE(i,e)||CV()}function qu(i){return MV(i)||AV(i)||ZE(i)||RV()}function PV(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var r=t.call(i,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function LV(i){var e=PV(i,"string");return typeof e=="symbol"?e:e+""}function ZE(i,e){if(i){if(typeof i=="string")return qS(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?qS(i,e):void 0}}var Hi=window.THREE?window.THREE:{WebGLRenderer:tb,Scene:d.xsS,PerspectiveCamera:d.cPb,Raycaster:d.iMs,SRGBColorSpace:d.KI_,TextureLoader:d.dpR,Vector2:d.FM8,Vector3:d.Pa4,Box3:d.ZzF,Color:d.Ilk,Mesh:d.Kj0,SphereGeometry:d.xo$,MeshBasicMaterial:d.vBJ,BackSide:d._Li,Clock:d.SUY},YE=wo({props:{width:{default:window.innerWidth,onChange:function(e,t,r){isNaN(e)&&(t.width=r)}},height:{default:window.innerHeight,onChange:function(e,t,r){isNaN(e)&&(t.height=r)}},viewOffset:{default:[0,0]},backgroundColor:{default:"#000011"},backgroundImageUrl:{},onBackgroundImageLoaded:{},showNavInfo:{default:!0},skyRadius:{default:5e4},objects:{default:[]},lights:{default:[]},enablePointerInteraction:{default:!0,onChange:function(e,t){t.hoverObj=null,t.tooltip&&t.tooltip.content(null)},triggerUpdate:!1},pointerRaycasterThrottleMs:{default:50,triggerUpdate:!1},lineHoverPrecision:{default:1,triggerUpdate:!1},pointsHoverPrecision:{default:1,triggerUpdate:!1},hoverOrderComparator:{triggerUpdate:!1},hoverFilter:{default:function(){return!0},triggerUpdate:!1},tooltipContent:{triggerUpdate:!1},hoverDuringDrag:{default:!1,triggerUpdate:!1},clickAfterDrag:{default:!1,triggerUpdate:!1},onHover:{default:function(){},triggerUpdate:!1},onClick:{default:function(){},triggerUpdate:!1},onRightClick:{triggerUpdate:!1}},methods:{tick:function(e){if(e.initialised){e.controls.enabled&&e.controls.update&&e.controls.update(Math.min(1,e.clock.getDelta())),e.postProcessingComposer?e.postProcessingComposer.render():e.renderer.render(e.scene,e.camera),e.extraRenderers.forEach(function(c){return c.render(e.scene,e.camera)});var t=+new Date;if(e.enablePointerInteraction&&t-e.lastRaycasterCheck>=e.pointerRaycasterThrottleMs){e.lastRaycasterCheck=t;var r=null;if(e.hoverDuringDrag||!e.isPointerDragging){var s=this.intersectingObjects(e.pointerPos.x,e.pointerPos.y);e.hoverOrderComparator&&s.sort(function(c,h){return e.hoverOrderComparator(c.object,h.object)});var a=s.find(function(c){return e.hoverFilter(c.object)})||null;r=a?a.object:null,e.intersection=a||null}r!==e.hoverObj&&(e.onHover(r,e.hoverObj,e.intersection),e.tooltip.content(r&&Wn(e.tooltipContent)(r,e.intersection)||null),e.hoverObj=r)}e.tweenGroup.update()}return this},getPointerPos:function(e){var t=e.pointerPos,r=t.x,s=t.y;return{x:r,y:s}},cameraPosition:function(e,t,r,s){var a=e.camera;if(t&&e.initialised){var c=t,h=r||{x:0,y:0,z:0};if(!s)x(c),_(h);else{var f=Object.assign({},a.position),m=v();e.tweenGroup.add(new FS(f).to(c,s).easing(wl.Quadratic.Out).onUpdate(x).start()),e.tweenGroup.add(new FS(m).to(h,s/3).easing(wl.Quadratic.Out).onUpdate(_).start())}return this}return Object.assign({},a.position,{lookAt:v()});function x(T){var w=T.x,P=T.y,C=T.z;w!==void 0&&(a.position.x=w),P!==void 0&&(a.position.y=P),C!==void 0&&(a.position.z=C)}function _(T){var w=new Hi.Vector3(T.x,T.y,T.z);e.controls.enabled&&e.controls.target?e.controls.target=w:a.lookAt(w)}function v(){return Object.assign(new Hi.Vector3(0,0,-1e3).applyQuaternion(a.quaternion).add(a.position))}},zoomToFit:function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:10,s=arguments.length,a=new Array(s>3?s-3:0),c=3;c<s;c++)a[c-3]=arguments[c];return this.fitToBbox(this.getBbox.apply(this,a),t,r)},fitToBbox:function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:10,a=e.camera;if(t){var c=new Hi.Vector3(0,0,0),h=Math.max.apply(Math,qu(Object.entries(t).map(function(T){var w=NV(T,2),P=w[0],C=w[1];return Math.max.apply(Math,qu(C.map(function(E){return Math.abs(c[P]-E)})))})))*2,f=(1-s*2/e.height)*a.fov,m=h/Math.atan(f*Math.PI/180),x=m/a.aspect,_=Math.max(m,x);if(_>0){var v=c.clone().sub(a.position).normalize().multiplyScalar(-_);this.cameraPosition(v,c,r)}}return this},getBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0},r=new Hi.Box3(new Hi.Vector3(0,0,0),new Hi.Vector3(0,0,0)),s=e.objects.filter(t);return s.length?(s.forEach(function(a){return r.expandByObject(a)}),Object.assign.apply(Object,qu(["x","y","z"].map(function(a){return wV({},a,[r.min[a],r.max[a]])})))):null},getScreenCoords:function(e,t,r,s){var a=new Hi.Vector3(t,r,s);return a.project(this.camera()),{x:(a.x+1)*e.width/2,y:-(a.y-1)*e.height/2}},getSceneCoords:function(e,t,r){var s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,a=new Hi.Vector2(t/e.width*2-1,-(r/e.height)*2+1),c=new Hi.Raycaster;return c.setFromCamera(a,e.camera),Object.assign({},c.ray.at(s,new Hi.Vector3))},intersectingObjects:function(e,t,r){var s=new Hi.Vector2(t/e.width*2-1,-(r/e.height)*2+1),a=new Hi.Raycaster;return a.params.Line.threshold=e.lineHoverPrecision,a.params.Points.threshold=e.pointsHoverPrecision,a.setFromCamera(s,e.camera),a.intersectObjects(e.objects,!0)},renderer:function(e){return e.renderer},scene:function(e){return e.scene},camera:function(e){return e.camera},postProcessingComposer:function(e){return e.postProcessingComposer},controls:function(e){return e.controls},tbControls:function(e){return e.controls}},stateInit:function(){return{scene:new Hi.Scene,camera:new Hi.PerspectiveCamera,clock:new Hi.Clock,tweenGroup:new IS,lastRaycasterCheck:0}},init:function(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=r.controlType,a=s===void 0?"trackball":s,c=r.useWebGPU,h=c===void 0?!1:c,f=r.rendererConfig,m=f===void 0?{}:f,x=r.extraRenderers,_=x===void 0?[]:x,v=r.waitForLoadComplete,T=v===void 0?!0:v;e.innerHTML="",e.appendChild(t.container=document.createElement("div")),t.container.className="scene-container",t.container.style.position="relative",t.container.appendChild(t.navInfo=document.createElement("div")),t.navInfo.className="scene-nav-info",t.navInfo.textContent={orbit:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",trackball:"Left-click: rotate, Mouse-wheel/middle-click: zoom, Right-click: pan",fly:"WASD: move, R|F: up | down, Q|E: roll, up|down: pitch, left|right: yaw"}[a]||"",t.navInfo.style.display=t.showNavInfo?null:"none",t.tooltip=new bV(t.container),t.pointerPos=new Hi.Vector2,t.pointerPos.x=-2,t.pointerPos.y=-2,["pointermove","pointerdown"].forEach(function(w){return t.container.addEventListener(w,function(P){if(w==="pointerdown"&&(t.isPointerPressed=!0),!t.isPointerDragging&&P.type==="pointermove"&&(P.pressure>0||t.isPointerPressed)&&(P.pointerType==="mouse"||P.movementX===void 0||[P.movementX,P.movementY].some(function(D){return Math.abs(D)>1}))&&(t.isPointerDragging=!0),t.enablePointerInteraction){var C=E(t.container);t.pointerPos.x=P.pageX-C.left,t.pointerPos.y=P.pageY-C.top}function E(D){var F=D.getBoundingClientRect(),W=window.pageXOffset||document.documentElement.scrollLeft,K=window.pageYOffset||document.documentElement.scrollTop;return{top:F.top+K,left:F.left+W}}},{passive:!0})}),t.container.addEventListener("pointerup",function(w){t.isPointerPressed&&(t.isPointerPressed=!1,!(t.isPointerDragging&&(t.isPointerDragging=!1,!t.clickAfterDrag))&&requestAnimationFrame(function(){w.button===0&&t.onClick(t.hoverObj||null,w,t.intersection),w.button===2&&t.onRightClick&&t.onRightClick(t.hoverObj||null,w,t.intersection)}))},{passive:!0,capture:!0}),t.container.addEventListener("contextmenu",function(w){t.onRightClick&&w.preventDefault()}),t.renderer=new(h?OU:Hi.WebGLRenderer)(Object.assign({antialias:!0,alpha:!0},m)),t.renderer.setPixelRatio(Math.min(2,window.devicePixelRatio)),t.container.appendChild(t.renderer.domElement),t.extraRenderers=_,t.extraRenderers.forEach(function(w){w.domElement.style.position="absolute",w.domElement.style.top="0px",w.domElement.style.pointerEvents="none",t.container.appendChild(w.domElement)}),t.postProcessingComposer=new IF(t.renderer),t.postProcessingComposer.addPass(new DF(t.scene,t.camera)),t.controls=new{trackball:GU,orbit:rF,fly:_F}[a](t.camera,t.renderer.domElement),a==="fly"&&(t.controls.movementSpeed=300,t.controls.rollSpeed=Math.PI/6,t.controls.dragToLook=!0),(a==="trackball"||a==="orbit")&&(t.controls.minDistance=.1,t.controls.maxDistance=t.skyRadius,t.controls.addEventListener("start",function(){t.controlsEngaged=!0}),t.controls.addEventListener("change",function(){t.controlsEngaged&&(t.controlsDragging=!0)}),t.controls.addEventListener("end",function(){t.controlsEngaged=!1,t.controlsDragging=!1})),[t.renderer,t.postProcessingComposer].concat(qu(t.extraRenderers)).forEach(function(w){return w.setSize(t.width,t.height)}),t.camera.aspect=t.width/t.height,t.camera.updateProjectionMatrix(),t.camera.position.z=1e3,t.scene.add(t.skysphere=new Hi.Mesh),t.skysphere.visible=!1,t.loadComplete=t.scene.visible=!T,window.scene=t.scene},update:function(e,t){if(e.width&&e.height&&(t.hasOwnProperty("width")||t.hasOwnProperty("height"))){var r,s=e.width,a=e.height;e.container.style.width="".concat(s,"px"),e.container.style.height="".concat(a,"px"),[e.renderer,e.postProcessingComposer].concat(qu(e.extraRenderers)).forEach(function(T){return T.setSize(s,a)}),e.camera.aspect=s/a;var c=e.viewOffset.slice(0,2);c.some(function(T){return T})&&(r=e.camera).setViewOffset.apply(r,[s,a].concat(qu(c),[s,a])),e.camera.updateProjectionMatrix()}if(t.hasOwnProperty("viewOffset")){var h,f=e.width,m=e.height,x=e.viewOffset.slice(0,2);x.some(function(T){return T})?(h=e.camera).setViewOffset.apply(h,[f,m].concat(qu(x),[f,m])):e.camera.clearViewOffset()}if(t.hasOwnProperty("skyRadius")&&e.skyRadius&&(e.controls.hasOwnProperty("maxDistance")&&t.skyRadius&&(e.controls.maxDistance=Math.min(e.controls.maxDistance,e.skyRadius)),e.camera.far=e.skyRadius*2.5,e.camera.updateProjectionMatrix(),e.skysphere.geometry=new Hi.SphereGeometry(e.skyRadius)),t.hasOwnProperty("backgroundColor")){var _=Mc(e.backgroundColor).alpha;_===void 0&&(_=1),e.renderer.setClearColor(new Hi.Color(XB(1,e.backgroundColor)),_)}t.hasOwnProperty("backgroundImageUrl")&&(e.backgroundImageUrl?new Hi.TextureLoader().load(e.backgroundImageUrl,function(T){T.colorSpace=Hi.SRGBColorSpace,e.skysphere.material=new Hi.MeshBasicMaterial({map:T,side:Hi.BackSide}),e.skysphere.visible=!0,e.onBackgroundImageLoaded&&setTimeout(e.onBackgroundImageLoaded),!e.loadComplete&&v()}):(e.skysphere.visible=!1,e.skysphere.material.map=null,!e.loadComplete&&v())),t.hasOwnProperty("showNavInfo")&&(e.navInfo.style.display=e.showNavInfo?null:"none"),t.hasOwnProperty("lights")&&((t.lights||[]).forEach(function(T){return e.scene.remove(T)}),e.lights.forEach(function(T){return e.scene.add(T)})),t.hasOwnProperty("objects")&&((t.objects||[]).forEach(function(T){return e.scene.remove(T)}),e.objects.forEach(function(T){return e.scene.add(T)}));function v(){e.loadComplete=e.scene.visible=!0}}});function IV(i,e){e===void 0&&(e={});var t=e.insertAt;if(typeof document!="undefined"){var r=document.head||document.getElementsByTagName("head")[0],s=document.createElement("style");s.type="text/css",t==="top"&&r.firstChild?r.insertBefore(s,r.firstChild):r.appendChild(s),s.styleSheet?s.styleSheet.cssText=i:s.appendChild(document.createTextNode(i))}}var DV=`.graph-info-msg {
top: 50%;
width: 100%;
text-align: center;
color: lavender;
opacity: 0.7;
font-size: 22px;
position: absolute;
font-family: Sans-serif;
}
.scene-container .clickable {
cursor: pointer;
}
.scene-container .grabbable {
cursor: move;
cursor: grab;
cursor: -moz-grab;
cursor: -webkit-grab;
}
.scene-container .grabbable:active {
cursor: grabbing;
cursor: -moz-grabbing;
cursor: -webkit-grabbing;
}`;IV(DV);function KS(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,r=Array(e);t<e;t++)r[t]=i[t];return r}function UV(i){if(Array.isArray(i))return KS(i)}function Um(i,e,t){return(e=kV(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function FV(i){if(typeof Symbol!="undefined"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function BV(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function QE(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(i);e&&(r=r.filter(function(s){return Object.getOwnPropertyDescriptor(i,s).enumerable})),t.push.apply(t,r)}return t}function d_(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?QE(Object(t),!0).forEach(function(r){Um(i,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):QE(Object(t)).forEach(function(r){Object.defineProperty(i,r,Object.getOwnPropertyDescriptor(t,r))})}return i}function f_(i){return UV(i)||FV(i)||VV(i)||BV()}function OV(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var r=t.call(i,e);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function kV(i){var e=OV(i,"string");return typeof e=="symbol"?e:e+""}function VV(i,e){if(i){if(typeof i=="string")return KS(i,e);var t={}.toString.call(i).slice(8,-1);return t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set"?Array.from(i):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?KS(i,e):void 0}}function JE(i,e){var t=new e;return t._destructor&&t._destructor(),{linkProp:function(s){return{default:t[s](),onChange:function(c,h){h[i][s](c)},triggerUpdate:!1}},linkMethod:function(s){return function(a){for(var c=a[i],h=arguments.length,f=new Array(h>1?h-1:0),m=1;m<h;m++)f[m-1]=arguments[m];var x=c[s].apply(c,f);return x===c?this:x}}}}var ZS=window.THREE?window.THREE:{AmbientLight:d.Mig,DirectionalLight:d.Ox3,REVISION:d.UZH},zV=170,e3=JE("forceGraph",Pg),GV=Object.assign.apply(Object,f_(["jsonUrl","graphData","numDimensions","dagMode","dagLevelDistance","dagNodeFilter","onDagError","nodeRelSize","nodeId","nodeVal","nodeResolution","nodeColor","nodeAutoColorBy","nodeOpacity","nodeVisibility","nodeThreeObject","nodeThreeObjectExtend","nodePositionUpdate","linkSource","linkTarget","linkVisibility","linkColor","linkAutoColorBy","linkOpacity","linkWidth","linkResolution","linkCurvature","linkCurveRotation","linkMaterial","linkThreeObject","linkThreeObjectExtend","linkPositionUpdate","linkDirectionalArrowLength","linkDirectionalArrowColor","linkDirectionalArrowRelPos","linkDirectionalArrowResolution","linkDirectionalParticles","linkDirectionalParticleSpeed","linkDirectionalParticleOffset","linkDirectionalParticleWidth","linkDirectionalParticleColor","linkDirectionalParticleResolution","linkDirectionalParticleThreeObject","forceEngine","d3AlphaDecay","d3VelocityDecay","d3AlphaMin","ngraphPhysics","warmupTicks","cooldownTicks","cooldownTime","onEngineTick","onEngineStop"].map(function(i){return Um({},i,e3.linkProp(i))}))),WV=Object.assign.apply(Object,f_(["refresh","getGraphBbox","d3Force","d3ReheatSimulation","emitParticle"].map(function(i){return Um({},i,e3.linkMethod(i))}))),p_=JE("renderObjs",YE),HV=Object.assign.apply(Object,f_(["width","height","backgroundColor","showNavInfo","enablePointerInteraction"].map(function(i){return Um({},i,p_.linkProp(i))}))),$V=Object.assign.apply(Object,f_(["lights","cameraPosition","postProcessingComposer"].map(function(i){return Um({},i,p_.linkMethod(i))})).concat([{graph2ScreenCoords:p_.linkMethod("getScreenCoords"),screen2GraphCoords:p_.linkMethod("getSceneCoords")}])),jV=wo({props:d_(d_({nodeLabel:{default:"name",triggerUpdate:!1},linkLabel:{default:"name",triggerUpdate:!1},linkHoverPrecision:{default:1,onChange:function(e,t){return t.renderObjs.lineHoverPrecision(e)},triggerUpdate:!1},enableNavigationControls:{default:!0,onChange:function(e,t){var r=t.renderObjs.controls();r&&(r.enabled=e,e&&r.domElement&&r.domElement.dispatchEvent(new PointerEvent("pointerup")))},triggerUpdate:!1},enableNodeDrag:{default:!0,triggerUpdate:!1},onNodeDrag:{default:function(){},triggerUpdate:!1},onNodeDragEnd:{default:function(){},triggerUpdate:!1},onNodeClick:{triggerUpdate:!1},onNodeRightClick:{triggerUpdate:!1},onNodeHover:{triggerUpdate:!1},onLinkClick:{triggerUpdate:!1},onLinkRightClick:{triggerUpdate:!1},onLinkHover:{triggerUpdate:!1},onBackgroundClick:{triggerUpdate:!1},onBackgroundRightClick:{triggerUpdate:!1},showPointerCursor:{default:!0,triggerUpdate:!1}},GV),HV),methods:d_(d_({zoomToFit:function(e,t,r){for(var s,a=arguments.length,c=new Array(a>3?a-3:0),h=3;h<a;h++)c[h-3]=arguments[h];return e.renderObjs.fitToBbox((s=e.forceGraph).getGraphBbox.apply(s,c),t,r),this},pauseAnimation:function(e){return e.animationFrameRequestId!==null&&(cancelAnimationFrame(e.animationFrameRequestId),e.animationFrameRequestId=null),this},resumeAnimation:function(e){return e.animationFrameRequestId===null&&this._animationCycle(),this},_animationCycle:function(e){e.enablePointerInteraction&&(this.renderer().domElement.style.cursor=null),e.forceGraph.tickFrame(),e.renderObjs.tick(),e.animationFrameRequestId=requestAnimationFrame(this._animationCycle)},scene:function(e){return e.renderObjs.scene()},camera:function(e){return e.renderObjs.camera()},renderer:function(e){return e.renderObjs.renderer()},controls:function(e){return e.renderObjs.controls()},tbControls:function(e){return e.renderObjs.tbControls()},_destructor:function(){this.pauseAnimation(),this.graphData({nodes:[],links:[]})}},WV),$V),stateInit:function(e){var t=e.controlType,r=e.rendererConfig,s=e.extraRenderers,a=new Pg;return{forceGraph:a,renderObjs:YE({controlType:t,rendererConfig:r,extraRenderers:s}).objects([a]).lights([new ZS.AmbientLight(13421772,Math.PI),new ZS.DirectionalLight(16777215,.6*Math.PI)])}},init:function(e,t){e.innerHTML="",e.appendChild(t.container=document.createElement("div")),t.container.style.position="relative";var r=document.createElement("div");t.container.appendChild(r),t.renderObjs(r);var s=t.renderObjs.camera(),a=t.renderObjs.renderer(),c=t.renderObjs.controls();c.enabled=!!t.enableNavigationControls,t.lastSetCameraZ=s.position.z;var h;t.container.appendChild(h=document.createElement("div")),h.className="graph-info-msg",h.textContent="",t.forceGraph.onLoading(function(){h.textContent="Loading..."}).onFinishLoading(function(){h.textContent=""}).onUpdate(function(){t.graphData=t.forceGraph.graphData(),s.position.x===0&&s.position.y===0&&s.position.z===t.lastSetCameraZ&&t.graphData.nodes.length&&(s.lookAt(t.forceGraph.position),t.lastSetCameraZ=s.position.z=Math.cbrt(t.graphData.nodes.length)*zV)}).onFinishUpdate(function(){if(t._dragControls){var f=t.graphData.nodes.find(function(x){return x.__initialFixedPos&&!x.__disposeControlsAfterDrag});f?f.__disposeControlsAfterDrag=!0:t._dragControls.dispose(),t._dragControls=void 0}if(t.enableNodeDrag&&t.enablePointerInteraction&&t.forceEngine==="d3"){var m=t._dragControls=new Ie(t.graphData.nodes.map(function(x){return x.__threeObj}).filter(function(x){return x}),s,a.domElement);m.addEventListener("dragstart",function(x){var _=wc(x.object);if(_){c.enabled=!1,x.object.__initialPos=x.object.position.clone(),x.object.__prevPos=x.object.position.clone();var v=_.__data;!v.__initialFixedPos&&(v.__initialFixedPos={fx:v.fx,fy:v.fy,fz:v.fz}),!v.__initialPos&&(v.__initialPos={x:v.x,y:v.y,z:v.z}),["x","y","z"].forEach(function(T){return v["f".concat(T)]=v[T]}),a.domElement.classList.add("grabbable")}}),m.addEventListener("drag",function(x){var _=wc(x.object);if(_){if(!x.object.hasOwnProperty("__graphObjType")){var v=x.object.__initialPos,T=x.object.__prevPos,w=x.object.position;_.position.add(w.clone().sub(T)),T.copy(w),w.copy(v)}var P=_.__data,C=_.position,E={x:C.x-P.x,y:C.y-P.y,z:C.z-P.z};["x","y","z"].forEach(function(D){return P["f".concat(D)]=P[D]=C[D]}),t.forceGraph.d3AlphaTarget(.3).resetCountdown(),P.__dragged=!0,t.onNodeDrag(P,E)}}),m.addEventListener("dragend",function(x){var _=wc(x.object);if(_){delete x.object.__initialPos,delete x.object.__prevPos;var v=_.__data;v.__disposeControlsAfterDrag&&(m.dispose(),delete v.__disposeControlsAfterDrag);var T=v.__initialFixedPos,w=v.__initialPos,P={x:w.x-v.x,y:w.y-v.y,z:w.z-v.z};if(T&&(["x","y","z"].forEach(function(E){var D="f".concat(E);T[D]===void 0&&delete v[D]}),delete v.__initialFixedPos,delete v.__initialPos,v.__dragged&&(delete v.__dragged,t.onNodeDragEnd(v,P))),t.forceGraph.d3AlphaTarget(0).resetCountdown(),t.enableNavigationControls){var C;c.enabled=!0,c._status&&((C=c._onPointerCancel)===null||C===void 0||C.call(c)),c.domElement&&c.domElement.ownerDocument&&c.domElement.ownerDocument.dispatchEvent(new PointerEvent("pointerup",{pointerType:"touch"}))}a.domElement.classList.remove("grabbable")}})}}),ZS.REVISION<155&&(t.renderObjs.renderer().useLegacyLights=!1),t.renderObjs.hoverOrderComparator(function(f,m){var x=wc(f);if(!x)return 1;var _=wc(m);if(!_)return-1;var v=function(w){return w.__graphObjType==="node"};return v(_)-v(x)}).tooltipContent(function(f){var m=wc(f);return m&&Wn(t["".concat(m.__graphObjType,"Label")])(m.__data)||""}).hoverDuringDrag(!1).onHover(function(f){var m=wc(f);if(m!==t.hoverObj){var x=t.hoverObj?t.hoverObj.__graphObjType:null,_=t.hoverObj?t.hoverObj.__data:null,v=m?m.__graphObjType:null,T=m?m.__data:null;if(x&&x!==v){var w=t["on".concat(x==="node"?"Node":"Link","Hover")];w&&w(null,_)}if(v){var P=t["on".concat(v==="node"?"Node":"Link","Hover")];P&&P(T,x===v?_:null)}a.domElement.classList[(m&&t["on".concat(v==="node"?"Node":"Link","Click")]||!m&&t.onBackgroundClick)&&Wn(t.showPointerCursor)(T)?"add":"remove"]("clickable"),t.hoverObj=m}}).clickAfterDrag(!1).onClick(function(f,m){var x=wc(f);if(x){var _=t["on".concat(x.__graphObjType==="node"?"Node":"Link","Click")];_&&_(x.__data,m)}else t.onBackgroundClick&&t.onBackgroundClick(m)}).onRightClick(function(f,m){var x=wc(f);if(x){var _=t["on".concat(x.__graphObjType==="node"?"Node":"Link","RightClick")];_&&_(x.__data,m)}else t.onBackgroundRightClick&&t.onBackgroundRightClick(m)}),this._animationCycle()}});function wc(i){for(var e=i;e&&!e.hasOwnProperty("__graphObjType");)e=e.parent;return e}},69168:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return ge}});var d=ne(18773);function ge(ae,z){ae.prototype=Object.create(z.prototype),ae.prototype.constructor=ae,(0,d.Z)(ae,z)}},42602:function(Qe,Le){"use strict";var ne={value:()=>{}};function d(){for(var $=0,X=arguments.length,Q={},ue;$<X;++$){if(!(ue=arguments[$]+"")||ue in Q||/[\s.]/.test(ue))throw new Error("illegal type: "+ue);Q[ue]=[]}return new ge(Q)}function ge($){this._=$}function ae($,X){return $.trim().split(/^|\s+/).map(function(Q){var ue="",de=Q.indexOf(".");if(de>=0&&(ue=Q.slice(de+1),Q=Q.slice(0,de)),Q&&!X.hasOwnProperty(Q))throw new Error("unknown type: "+Q);return{type:Q,name:ue}})}ge.prototype=d.prototype={constructor:ge,on:function($,X){var Q=this._,ue=ae($+"",Q),de,se=-1,_e=ue.length;if(arguments.length<2){for(;++se<_e;)if((de=($=ue[se]).type)&&(de=z(Q[de],$.name)))return de;return}if(X!=null&&typeof X!="function")throw new Error("invalid callback: "+X);for(;++se<_e;)if(de=($=ue[se]).type)Q[de]=Y(Q[de],$.name,X);else if(X==null)for(de in Q)Q[de]=Y(Q[de],$.name,null);return this},copy:function(){var $={},X=this._;for(var Q in X)$[Q]=X[Q].slice();return new ge($)},call:function($,X){if((de=arguments.length-2)>0)for(var Q=new Array(de),ue=0,de,se;ue<de;++ue)Q[ue]=arguments[ue+2];if(!this._.hasOwnProperty($))throw new Error("unknown type: "+$);for(se=this._[$],ue=0,de=se.length;ue<de;++ue)se[ue].value.apply(X,Q)},apply:function($,X,Q){if(!this._.hasOwnProperty($))throw new Error("unknown type: "+$);for(var ue=this._[$],de=0,se=ue.length;de<se;++de)ue[de].value.apply(X,Q)}};function z($,X){for(var Q=0,ue=$.length,de;Q<ue;++Q)if((de=$[Q]).name===X)return de.value}function Y($,X,Q){for(var ue=0,de=$.length;ue<de;++ue)if($[ue].name===X){$[ue]=ne,$=$.slice(0,ue).concat($.slice(ue+1));break}return Q!=null&&$.push({name:X,value:Q}),$}Le.Z=d},14310:function(Qe,Le,ne){"use strict";ne.d(Le,{H:function(){return ae},Z:function(){return d}});function d(z){const Y=+this._x.call(null,z);return ge(this.cover(Y),Y,z)}function ge(z,Y,$){if(isNaN(Y))return z;var X,Q=z._root,ue={data:$},de=z._x0,se=z._x1,_e,Ae,Te,ye,Ie;if(!Q)return z._root=ue,z;for(;Q.length;)if((Te=Y>=(_e=(de+se)/2))?de=_e:se=_e,X=Q,!(Q=Q[ye=+Te]))return X[ye]=ue,z;if(Ae=+z._x.call(null,Q.data),Y===Ae)return ue.next=Q,X?X[ye]=ue:z._root=ue,z;do X=X?X[ye]=new Array(2):z._root=new Array(2),(Te=Y>=(_e=(de+se)/2))?de=_e:se=_e;while((ye=+Te)==(Ie=+(Ae>=_e)));return X[Ie]=Q,X[ye]=ue,z}function ae(z){Array.isArray(z)||(z=Array.from(z));const Y=z.length,$=new Float64Array(Y);let X=1/0,Q=-1/0;for(let ue=0,de;ue<Y;++ue)isNaN(de=+this._x.call(null,z[ue]))||($[ue]=de,de<X&&(X=de),de>Q&&(Q=de));if(X>Q)return this;this.cover(X).cover(Q);for(let ue=0;ue<Y;++ue)ge(this,$[ue],z[ue]);return this}},33662:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return _e}});var d=ne(14310),ge=ne(63945),ae=ne(27002),z=ne(44508),Y=ne(79150),$=ne(45632),X=ne(30108),Q=ne(90820),ue=ne(11706),de=ne(78017),se=ne(79387);function _e(Ie,Ze){var Xe=new Ae(Ze==null?se.P:Ze,NaN,NaN);return Ie==null?Xe:Xe.addAll(Ie)}function Ae(Ie,Ze,Xe){this._x=Ie,this._x0=Ze,this._x1=Xe,this._root=void 0}function Te(Ie){for(var Ze={data:Ie.data},Xe=Ze;Ie=Ie.next;)Xe=Xe.next={data:Ie.data};return Ze}var ye=_e.prototype=Ae.prototype;ye.copy=function(){var Ie=new Ae(this._x,this._x0,this._x1),Ze=this._root,Xe,qe;if(!Ze)return Ie;if(!Ze.length)return Ie._root=Te(Ze),Ie;for(Xe=[{source:Ze,target:Ie._root=new Array(2)}];Ze=Xe.pop();)for(var st=0;st<2;++st)(qe=Ze.source[st])&&(qe.length?Xe.push({source:qe,target:Ze.target[st]=new Array(2)}):Ze.target[st]=Te(qe));return Ie},ye.add=d.Z,ye.addAll=d.H,ye.cover=ge.Z,ye.data=ae.Z,ye.extent=z.Z,ye.find=Y.Z,ye.remove=$.Z,ye.removeAll=$.x,ye.root=X.Z,ye.size=Q.Z,ye.visit=ue.Z,ye.visitAfter=de.Z,ye.x=se.Z},63945:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return d}});function d(ge){if(isNaN(ge=+ge))return this;var ae=this._x0,z=this._x1;if(isNaN(ae))z=(ae=Math.floor(ge))+1;else{for(var Y=z-ae||1,$=this._root,X,Q;ae>ge||ge>=z;)switch(Q=+(ge<ae),X=new Array(2),X[Q]=$,$=X,Y*=2,Q){case 0:z=ae+Y;break;case 1:ae=z-Y;break}this._root&&this._root.length&&(this._root=$)}return this._x0=ae,this._x1=z,this}},27002:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return d}});function d(){var ge=[];return this.visit(function(ae){if(!ae.length)do ge.push(ae.data);while(ae=ae.next)}),ge}},44508:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return d}});function d(ge){return arguments.length?this.cover(+ge[0][0]).cover(+ge[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]}},79150:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return ge}});var d=ne(10253);function ge(ae,z){var Y,$=this._x0,X,Q,ue=this._x1,de=[],se=this._root,_e,Ae;for(se&&de.push(new d.Z(se,$,ue)),z==null?z=1/0:($=ae-z,ue=ae+z);_e=de.pop();)if(!(!(se=_e.node)||(X=_e.x0)>ue||(Q=_e.x1)<$))if(se.length){var Te=(X+Q)/2;de.push(new d.Z(se[1],Te,Q),new d.Z(se[0],X,Te)),(Ae=+(ae>=Te))&&(_e=de[de.length-1],de[de.length-1]=de[de.length-1-Ae],de[de.length-1-Ae]=_e)}else{var ye=Math.abs(ae-+this._x.call(null,se.data));ye<z&&(z=ye,$=ae-ye,ue=ae+ye,Y=se.data)}return Y}},10253:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return d}});function d(ge,ae,z){this.node=ge,this.x0=ae,this.x1=z}},45632:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return d},x:function(){return ge}});function d(ae){if(isNaN(se=+this._x.call(null,ae)))return this;var z,Y=this._root,$,X,Q,ue=this._x0,de=this._x1,se,_e,Ae,Te,ye;if(!Y)return this;if(Y.length)for(;;){if((Ae=se>=(_e=(ue+de)/2))?ue=_e:de=_e,z=Y,!(Y=Y[Te=+Ae]))return this;if(!Y.length)break;z[Te+1&1]&&($=z,ye=Te)}for(;Y.data!==ae;)if(X=Y,!(Y=Y.next))return this;return(Q=Y.next)&&delete Y.next,X?(Q?X.next=Q:delete X.next,this):z?(Q?z[Te]=Q:delete z[Te],(Y=z[0]||z[1])&&Y===(z[1]||z[0])&&!Y.length&&($?$[ye]=Y:this._root=Y),this):(this._root=Q,this)}function ge(ae){for(var z=0,Y=ae.length;z<Y;++z)this.remove(ae[z]);return this}},30108:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return d}});function d(){return this._root}},90820:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return d}});function d(){var ge=0;return this.visit(function(ae){if(!ae.length)do++ge;while(ae=ae.next)}),ge}},11706:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return ge}});var d=ne(10253);function ge(ae){var z=[],Y,$=this._root,X,Q,ue;for($&&z.push(new d.Z($,this._x0,this._x1));Y=z.pop();)if(!ae($=Y.node,Q=Y.x0,ue=Y.x1)&&$.length){var de=(Q+ue)/2;(X=$[1])&&z.push(new d.Z(X,de,ue)),(X=$[0])&&z.push(new d.Z(X,Q,de))}return this}},78017:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return ge}});var d=ne(10253);function ge(ae){var z=[],Y=[],$;for(this._root&&z.push(new d.Z(this._root,this._x0,this._x1));$=z.pop();){var X=$.node;if(X.length){var Q,ue=$.x0,de=$.x1,se=(ue+de)/2;(Q=X[0])&&z.push(new d.Z(Q,ue,se)),(Q=X[1])&&z.push(new d.Z(Q,se,de))}Y.push($)}for(;$=Y.pop();)ae($.node,$.x0,$.x1);return this}},79387:function(Qe,Le,ne){"use strict";ne.d(Le,{P:function(){return d},Z:function(){return ge}});function d(ae){return ae[0]}function ge(ae){return arguments.length?(this._x=ae,this):this._x}},38192:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return d}});function d(ge,ae,z){var Y,$=1;ge==null&&(ge=0),ae==null&&(ae=0),z==null&&(z=0);function X(){var Q,ue=Y.length,de,se=0,_e=0,Ae=0;for(Q=0;Q<ue;++Q)de=Y[Q],se+=de.x||0,_e+=de.y||0,Ae+=de.z||0;for(se=(se/ue-ge)*$,_e=(_e/ue-ae)*$,Ae=(Ae/ue-z)*$,Q=0;Q<ue;++Q)de=Y[Q],se&&(de.x-=se),_e&&(de.y-=_e),Ae&&(de.z-=Ae)}return X.initialize=function(Q){Y=Q},X.x=function(Q){return arguments.length?(ge=+Q,X):ge},X.y=function(Q){return arguments.length?(ae=+Q,X):ae},X.z=function(Q){return arguments.length?(z=+Q,X):z},X.strength=function(Q){return arguments.length?($=+Q,X):$},X}},85320:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return d}});function d(ge){return function(){return ge}}},50277:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return d}});function d(ge){return(ge()-.5)*1e-6}},1076:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return z}});const d=1664525,ge=1013904223,ae=4294967296;function z(){let Y=1;return()=>(Y=(d*Y+ge)%ae)/ae}},76633:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return Y}});var d=ne(85320),ge=ne(50277);function ae($){return $.index}function z($,X){var Q=$.get(X);if(!Q)throw new Error("node not found: "+X);return Q}function Y($){var X=ae,Q=Xe,ue,de=(0,d.Z)(30),se,_e,Ae,Te,ye,Ie,Ze=1;$==null&&($=[]);function Xe(nt){return 1/Math.min(Te[nt.source.index],Te[nt.target.index])}function qe(nt){for(var ut=0,jt=$.length;ut<Ze;++ut)for(var un=0,hn,pn,_t,bn=0,kt=0,Gt=0,ti,ot;un<jt;++un)hn=$[un],pn=hn.source,_t=hn.target,bn=_t.x+_t.vx-pn.x-pn.vx||(0,ge.Z)(Ie),Ae>1&&(kt=_t.y+_t.vy-pn.y-pn.vy||(0,ge.Z)(Ie)),Ae>2&&(Gt=_t.z+_t.vz-pn.z-pn.vz||(0,ge.Z)(Ie)),ti=Math.sqrt(bn*bn+kt*kt+Gt*Gt),ti=(ti-se[un])/ti*nt*ue[un],bn*=ti,kt*=ti,Gt*=ti,_t.vx-=bn*(ot=ye[un]),Ae>1&&(_t.vy-=kt*ot),Ae>2&&(_t.vz-=Gt*ot),pn.vx+=bn*(ot=1-ot),Ae>1&&(pn.vy+=kt*ot),Ae>2&&(pn.vz+=Gt*ot)}function st(){if(_e){var nt,ut=_e.length,jt=$.length,un=new Map(_e.map((pn,_t)=>[X(pn,_t,_e),pn])),hn;for(nt=0,Te=new Array(ut);nt<jt;++nt)hn=$[nt],hn.index=nt,typeof hn.source!="object"&&(hn.source=z(un,hn.source)),typeof hn.target!="object"&&(hn.target=z(un,hn.target)),Te[hn.source.index]=(Te[hn.source.index]||0)+1,Te[hn.target.index]=(Te[hn.target.index]||0)+1;for(nt=0,ye=new Array(jt);nt<jt;++nt)hn=$[nt],ye[nt]=Te[hn.source.index]/(Te[hn.source.index]+Te[hn.target.index]);ue=new Array(jt),rt(),se=new Array(jt),Ke()}}function rt(){if(_e)for(var nt=0,ut=$.length;nt<ut;++nt)ue[nt]=+Q($[nt],nt,$)}function Ke(){if(_e)for(var nt=0,ut=$.length;nt<ut;++nt)se[nt]=+de($[nt],nt,$)}return qe.initialize=function(nt,...ut){_e=nt,Ie=ut.find(jt=>typeof jt=="function")||Math.random,Ae=ut.find(jt=>[1,2,3].includes(jt))||2,st()},qe.links=function(nt){return arguments.length?($=nt,st(),qe):$},qe.id=function(nt){return arguments.length?(X=nt,qe):X},qe.iterations=function(nt){return arguments.length?(Ze=+nt,qe):Ze},qe.strength=function(nt){return arguments.length?(Q=typeof nt=="function"?nt:(0,d.Z)(+nt),rt(),qe):Q},qe.distance=function(nt){return arguments.length?(de=typeof nt=="function"?nt:(0,d.Z)(+nt),Ke(),qe):de},qe}},61147:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return X}});var d=ne(33662),ge=ne(14301),ae=ne(7695),z=ne(85320),Y=ne(50277),$=ne(21668);function X(){var Q,ue,de,se,_e,Ae=(0,z.Z)(-30),Te,ye=1,Ie=1/0,Ze=.81;function Xe(Ke){var nt,ut=Q.length,jt=(ue===1?(0,d.Z)(Q,$.x):ue===2?(0,ge.Z)(Q,$.x,$.y):ue===3?(0,ae.Z)(Q,$.x,$.y,$.z):null).visitAfter(st);for(_e=Ke,nt=0;nt<ut;++nt)de=Q[nt],jt.visit(rt)}function qe(){if(Q){var Ke,nt=Q.length,ut;for(Te=new Array(nt),Ke=0;Ke<nt;++Ke)ut=Q[Ke],Te[ut.index]=+Ae(ut,Ke,Q)}}function st(Ke){var nt=0,ut,jt,un=0,hn,pn,_t,bn,kt=Ke.length;if(kt){for(hn=pn=_t=bn=0;bn<kt;++bn)(ut=Ke[bn])&&(jt=Math.abs(ut.value))&&(nt+=ut.value,un+=jt,hn+=jt*(ut.x||0),pn+=jt*(ut.y||0),_t+=jt*(ut.z||0));nt*=Math.sqrt(4/kt),Ke.x=hn/un,ue>1&&(Ke.y=pn/un),ue>2&&(Ke.z=_t/un)}else{ut=Ke,ut.x=ut.data.x,ue>1&&(ut.y=ut.data.y),ue>2&&(ut.z=ut.data.z);do nt+=Te[ut.data.index];while(ut=ut.next)}Ke.value=nt}function rt(Ke,nt,ut,jt,un){if(!Ke.value)return!0;var hn=[ut,jt,un][ue-1],pn=Ke.x-de.x,_t=ue>1?Ke.y-de.y:0,bn=ue>2?Ke.z-de.z:0,kt=hn-nt,Gt=pn*pn+_t*_t+bn*bn;if(kt*kt/Ze<Gt)return Gt<Ie&&(pn===0&&(pn=(0,Y.Z)(se),Gt+=pn*pn),ue>1&&_t===0&&(_t=(0,Y.Z)(se),Gt+=_t*_t),ue>2&&bn===0&&(bn=(0,Y.Z)(se),Gt+=bn*bn),Gt<ye&&(Gt=Math.sqrt(ye*Gt)),de.vx+=pn*Ke.value*_e/Gt,ue>1&&(de.vy+=_t*Ke.value*_e/Gt),ue>2&&(de.vz+=bn*Ke.value*_e/Gt)),!0;if(Ke.length||Gt>=Ie)return;(Ke.data!==de||Ke.next)&&(pn===0&&(pn=(0,Y.Z)(se),Gt+=pn*pn),ue>1&&_t===0&&(_t=(0,Y.Z)(se),Gt+=_t*_t),ue>2&&bn===0&&(bn=(0,Y.Z)(se),Gt+=bn*bn),Gt<ye&&(Gt=Math.sqrt(ye*Gt)));do Ke.data!==de&&(kt=Te[Ke.data.index]*_e/Gt,de.vx+=pn*kt,ue>1&&(de.vy+=_t*kt),ue>2&&(de.vz+=bn*kt));while(Ke=Ke.next)}return Xe.initialize=function(Ke,...nt){Q=Ke,se=nt.find(ut=>typeof ut=="function")||Math.random,ue=nt.find(ut=>[1,2,3].includes(ut))||2,qe()},Xe.strength=function(Ke){return arguments.length?(Ae=typeof Ke=="function"?Ke:(0,z.Z)(+Ke),qe(),Xe):Ae},Xe.distanceMin=function(Ke){return arguments.length?(ye=Ke*Ke,Xe):Math.sqrt(ye)},Xe.distanceMax=function(Ke){return arguments.length?(Ie=Ke*Ke,Xe):Math.sqrt(Ie)},Xe.theta=function(Ke){return arguments.length?(Ze=Ke*Ke,Xe):Math.sqrt(Ze)},Xe}},21668:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return se},x:function(){return Y},y:function(){return $},z:function(){return X}});var d=ne(42602),ge=ne(83833),ae=ne(1076),z=3;function Y(_e){return _e.x}function $(_e){return _e.y}function X(_e){return _e.z}var Q=10,ue=Math.PI*(3-Math.sqrt(5)),de=Math.PI*20/(9+Math.sqrt(221));function se(_e,Ae){Ae=Ae||2;var Te=Math.min(z,Math.max(1,Math.round(Ae))),ye,Ie=1,Ze=.001,Xe=1-Math.pow(Ze,1/300),qe=0,st=.6,rt=new Map,Ke=(0,ge.HT)(jt),nt=(0,d.Z)("tick","end"),ut=(0,ae.Z)();_e==null&&(_e=[]);function jt(){un(),nt.call("tick",ye),Ie<Ze&&(Ke.stop(),nt.call("end",ye))}function un(_t){var bn,kt=_e.length,Gt;_t===void 0&&(_t=1);for(var ti=0;ti<_t;++ti)for(Ie+=(qe-Ie)*Xe,rt.forEach(function(ot){ot(Ie)}),bn=0;bn<kt;++bn)Gt=_e[bn],Gt.fx==null?Gt.x+=Gt.vx*=st:(Gt.x=Gt.fx,Gt.vx=0),Te>1&&(Gt.fy==null?Gt.y+=Gt.vy*=st:(Gt.y=Gt.fy,Gt.vy=0)),Te>2&&(Gt.fz==null?Gt.z+=Gt.vz*=st:(Gt.z=Gt.fz,Gt.vz=0));return ye}function hn(){for(var _t=0,bn=_e.length,kt;_t<bn;++_t){if(kt=_e[_t],kt.index=_t,kt.fx!=null&&(kt.x=kt.fx),kt.fy!=null&&(kt.y=kt.fy),kt.fz!=null&&(kt.z=kt.fz),isNaN(kt.x)||Te>1&&isNaN(kt.y)||Te>2&&isNaN(kt.z)){var Gt=Q*(Te>2?Math.cbrt(.5+_t):Te>1?Math.sqrt(.5+_t):_t),ti=_t*ue,ot=_t*de;Te===1?kt.x=Gt:Te===2?(kt.x=Gt*Math.cos(ti),kt.y=Gt*Math.sin(ti)):(kt.x=Gt*Math.sin(ti)*Math.cos(ot),kt.y=Gt*Math.cos(ti),kt.z=Gt*Math.sin(ti)*Math.sin(ot))}(isNaN(kt.vx)||Te>1&&isNaN(kt.vy)||Te>2&&isNaN(kt.vz))&&(kt.vx=0,Te>1&&(kt.vy=0),Te>2&&(kt.vz=0))}}function pn(_t){return _t.initialize&&_t.initialize(_e,ut,Te),_t}return hn(),ye={tick:un,restart:function(){return Ke.restart(jt),ye},stop:function(){return Ke.stop(),ye},numDimensions:function(_t){return arguments.length?(Te=Math.min(z,Math.max(1,Math.round(_t))),rt.forEach(pn),ye):Te},nodes:function(_t){return arguments.length?(_e=_t,hn(),rt.forEach(pn),ye):_e},alpha:function(_t){return arguments.length?(Ie=+_t,ye):Ie},alphaMin:function(_t){return arguments.length?(Ze=+_t,ye):Ze},alphaDecay:function(_t){return arguments.length?(Xe=+_t,ye):+Xe},alphaTarget:function(_t){return arguments.length?(qe=+_t,ye):qe},velocityDecay:function(_t){return arguments.length?(st=1-_t,ye):1-st},randomSource:function(_t){return arguments.length?(ut=_t,rt.forEach(pn),ye):ut},force:function(_t,bn){return arguments.length>1?(bn==null?rt.delete(_t):rt.set(_t,pn(bn)),ye):rt.get(_t)},find:function(){var _t=Array.prototype.slice.call(arguments),bn=_t.shift()||0,kt=(Te>1?_t.shift():null)||0,Gt=(Te>2?_t.shift():null)||0,ti=_t.shift()||1/0,ot=0,Xt=_e.length,mn,_i,Kr,Zr,Mo,Ac;for(ti*=ti,ot=0;ot<Xt;++ot)Mo=_e[ot],mn=bn-Mo.x,_i=kt-(Mo.y||0),Kr=Gt-(Mo.z||0),Zr=mn*mn+_i*_i+Kr*Kr,Zr<ti&&(Ac=Mo,ti=Zr);return Ac},on:function(_t,bn){return arguments.length>1?(nt.on(_t,bn),ye):nt.on(_t)}}}},12713:function(Qe,Le,ne){"use strict";ne.d(Le,{H:function(){return ae},Z:function(){return d}});function d(z){const Y=+this._x.call(null,z),$=+this._y.call(null,z),X=+this._z.call(null,z);return ge(this.cover(Y,$,X),Y,$,X,z)}function ge(z,Y,$,X,Q){if(isNaN(Y)||isNaN($)||isNaN(X))return z;var ue,de=z._root,se={data:Q},_e=z._x0,Ae=z._y0,Te=z._z0,ye=z._x1,Ie=z._y1,Ze=z._z1,Xe,qe,st,rt,Ke,nt,ut,jt,un,hn,pn;if(!de)return z._root=se,z;for(;de.length;)if((ut=Y>=(Xe=(_e+ye)/2))?_e=Xe:ye=Xe,(jt=$>=(qe=(Ae+Ie)/2))?Ae=qe:Ie=qe,(un=X>=(st=(Te+Ze)/2))?Te=st:Ze=st,ue=de,!(de=de[hn=un<<2|jt<<1|ut]))return ue[hn]=se,z;if(rt=+z._x.call(null,de.data),Ke=+z._y.call(null,de.data),nt=+z._z.call(null,de.data),Y===rt&&$===Ke&&X===nt)return se.next=de,ue?ue[hn]=se:z._root=se,z;do ue=ue?ue[hn]=new Array(8):z._root=new Array(8),(ut=Y>=(Xe=(_e+ye)/2))?_e=Xe:ye=Xe,(jt=$>=(qe=(Ae+Ie)/2))?Ae=qe:Ie=qe,(un=X>=(st=(Te+Ze)/2))?Te=st:Ze=st;while((hn=un<<2|jt<<1|ut)===(pn=(nt>=st)<<2|(Ke>=qe)<<1|rt>=Xe));return ue[pn]=de,ue[hn]=se,z}function ae(z){Array.isArray(z)||(z=Array.from(z));const Y=z.length,$=new Float64Array(Y),X=new Float64Array(Y),Q=new Float64Array(Y);let ue=1/0,de=1/0,se=1/0,_e=-1/0,Ae=-1/0,Te=-1/0;for(let ye=0,Ie,Ze,Xe,qe;ye<Y;++ye)isNaN(Ze=+this._x.call(null,Ie=z[ye]))||isNaN(Xe=+this._y.call(null,Ie))||isNaN(qe=+this._z.call(null,Ie))||($[ye]=Ze,X[ye]=Xe,Q[ye]=qe,Ze<ue&&(ue=Ze),Ze>_e&&(_e=Ze),Xe<de&&(de=Xe),Xe>Ae&&(Ae=Xe),qe<se&&(se=qe),qe>Te&&(Te=qe));if(ue>_e||de>Ae||se>Te)return this;this.cover(ue,de,se).cover(_e,Ae,Te);for(let ye=0;ye<Y;++ye)ge(this,$[ye],X[ye],Q[ye],z[ye]);return this}},17646:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return d}});function d(ge,ae,z){if(isNaN(ge=+ge)||isNaN(ae=+ae)||isNaN(z=+z))return this;var Y=this._x0,$=this._y0,X=this._z0,Q=this._x1,ue=this._y1,de=this._z1;if(isNaN(Y))Q=(Y=Math.floor(ge))+1,ue=($=Math.floor(ae))+1,de=(X=Math.floor(z))+1;else{for(var se=Q-Y||1,_e=this._root,Ae,Te;Y>ge||ge>=Q||$>ae||ae>=ue||X>z||z>=de;)switch(Te=(z<X)<<2|(ae<$)<<1|ge<Y,Ae=new Array(8),Ae[Te]=_e,_e=Ae,se*=2,Te){case 0:Q=Y+se,ue=$+se,de=X+se;break;case 1:Y=Q-se,ue=$+se,de=X+se;break;case 2:Q=Y+se,$=ue-se,de=X+se;break;case 3:Y=Q-se,$=ue-se,de=X+se;break;case 4:Q=Y+se,ue=$+se,X=de-se;break;case 5:Y=Q-se,ue=$+se,X=de-se;break;case 6:Q=Y+se,$=ue-se,X=de-se;break;case 7:Y=Q-se,$=ue-se,X=de-se;break}this._root&&this._root.length&&(this._root=_e)}return this._x0=Y,this._y0=$,this._z0=X,this._x1=Q,this._y1=ue,this._z1=de,this}},39894:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return d}});function d(){var ge=[];return this.visit(function(ae){if(!ae.length)do ge.push(ae.data);while(ae=ae.next)}),ge}},56033:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return d}});function d(ge){return arguments.length?this.cover(+ge[0][0],+ge[0][1],+ge[0][2]).cover(+ge[1][0],+ge[1][1],+ge[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]}},77480:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return ge}});var d=ne(26805);function ge(ae,z,Y,$){var X,Q=this._x0,ue=this._y0,de=this._z0,se,_e,Ae,Te,ye,Ie,Ze=this._x1,Xe=this._y1,qe=this._z1,st=[],rt=this._root,Ke,nt;for(rt&&st.push(new d.Z(rt,Q,ue,de,Ze,Xe,qe)),$==null?$=1/0:(Q=ae-$,ue=z-$,de=Y-$,Ze=ae+$,Xe=z+$,qe=Y+$,$*=$);Ke=st.pop();)if(!(!(rt=Ke.node)||(se=Ke.x0)>Ze||(_e=Ke.y0)>Xe||(Ae=Ke.z0)>qe||(Te=Ke.x1)<Q||(ye=Ke.y1)<ue||(Ie=Ke.z1)<de))if(rt.length){var ut=(se+Te)/2,jt=(_e+ye)/2,un=(Ae+Ie)/2;st.push(new d.Z(rt[7],ut,jt,un,Te,ye,Ie),new d.Z(rt[6],se,jt,un,ut,ye,Ie),new d.Z(rt[5],ut,_e,un,Te,jt,Ie),new d.Z(rt[4],se,_e,un,ut,jt,Ie),new d.Z(rt[3],ut,jt,Ae,Te,ye,un),new d.Z(rt[2],se,jt,Ae,ut,ye,un),new d.Z(rt[1],ut,_e,Ae,Te,jt,un),new d.Z(rt[0],se,_e,Ae,ut,jt,un)),(nt=(Y>=un)<<2|(z>=jt)<<1|ae>=ut)&&(Ke=st[st.length-1],st[st.length-1]=st[st.length-1-nt],st[st.length-1-nt]=Ke)}else{var hn=ae-+this._x.call(null,rt.data),pn=z-+this._y.call(null,rt.data),_t=Y-+this._z.call(null,rt.data),bn=hn*hn+pn*pn+_t*_t;if(bn<$){var kt=Math.sqrt($=bn);Q=ae-kt,ue=z-kt,de=Y-kt,Ze=ae+kt,Xe=z+kt,qe=Y+kt,X=rt.data}}return X}},72096:function(Qe,Le,ne){"use strict";ne.d(Le,{r:function(){return ge}});const d=(ae,z,Y,$,X,Q)=>Math.sqrt(Zd(ae-$,2)+Zd(z-X,2)+Zd(Y-Q,2));function ge(ae,z,Y,$){const X=[],Q=ae-$,ue=z-$,de=Y-$,se=ae+$,_e=z+$,Ae=Y+$;return this.visit((Te,ye,Ie,Ze,Xe,qe,st)=>{if(!Te.length)do{const rt=Te.data;d(ae,z,Y,this._x(rt),this._y(rt),this._z(rt))<=$&&X.push(rt)}while(Te=Te.next);return ye>se||Ie>_e||Ze>Ae||Xe<Q||qe<ue||st<de}),X}},26805:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return d}});function d(ge,ae,z,Y,$,X,Q){this.node=ge,this.x0=ae,this.y0=z,this.z0=Y,this.x1=$,this.y1=X,this.z1=Q}},7695:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return ye}});var d=ne(12713),ge=ne(17646),ae=ne(39894),z=ne(56033),Y=ne(77480),$=ne(72096),X=ne(36989),Q=ne(10325),ue=ne(15902),de=ne(12027),se=ne(66612),_e=ne(14763),Ae=ne(94009),Te=ne(68889);function ye(qe,st,rt,Ke){var nt=new Ie(st==null?_e.P:st,rt==null?Ae.q:rt,Ke==null?Te.i:Ke,NaN,NaN,NaN,NaN,NaN,NaN);return qe==null?nt:nt.addAll(qe)}function Ie(qe,st,rt,Ke,nt,ut,jt,un,hn){this._x=qe,this._y=st,this._z=rt,this._x0=Ke,this._y0=nt,this._z0=ut,this._x1=jt,this._y1=un,this._z1=hn,this._root=void 0}function Ze(qe){for(var st={data:qe.data},rt=st;qe=qe.next;)rt=rt.next={data:qe.data};return st}var Xe=ye.prototype=Ie.prototype;Xe.copy=function(){var qe=new Ie(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),st=this._root,rt,Ke;if(!st)return qe;if(!st.length)return qe._root=Ze(st),qe;for(rt=[{source:st,target:qe._root=new Array(8)}];st=rt.pop();)for(var nt=0;nt<8;++nt)(Ke=st.source[nt])&&(Ke.length?rt.push({source:Ke,target:st.target[nt]=new Array(8)}):st.target[nt]=Ze(Ke));return qe},Xe.add=d.Z,Xe.addAll=d.H,Xe.cover=ge.Z,Xe.data=ae.Z,Xe.extent=z.Z,Xe.find=Y.Z,Xe.findAllWithinRadius=$.r,Xe.remove=X.Z,Xe.removeAll=X.x,Xe.root=Q.Z,Xe.size=ue.Z,Xe.visit=de.Z,Xe.visitAfter=se.Z,Xe.x=_e.Z,Xe.y=Ae.Z,Xe.z=Te.Z},36989:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return d},x:function(){return ge}});function d(ae){if(isNaN(ye=+this._x.call(null,ae))||isNaN(Ie=+this._y.call(null,ae))||isNaN(Ze=+this._z.call(null,ae)))return this;var z,Y=this._root,$,X,Q,ue=this._x0,de=this._y0,se=this._z0,_e=this._x1,Ae=this._y1,Te=this._z1,ye,Ie,Ze,Xe,qe,st,rt,Ke,nt,ut,jt;if(!Y)return this;if(Y.length)for(;;){if((rt=ye>=(Xe=(ue+_e)/2))?ue=Xe:_e=Xe,(Ke=Ie>=(qe=(de+Ae)/2))?de=qe:Ae=qe,(nt=Ze>=(st=(se+Te)/2))?se=st:Te=st,z=Y,!(Y=Y[ut=nt<<2|Ke<<1|rt]))return this;if(!Y.length)break;(z[ut+1&7]||z[ut+2&7]||z[ut+3&7]||z[ut+4&7]||z[ut+5&7]||z[ut+6&7]||z[ut+7&7])&&($=z,jt=ut)}for(;Y.data!==ae;)if(X=Y,!(Y=Y.next))return this;return(Q=Y.next)&&delete Y.next,X?(Q?X.next=Q:delete X.next,this):z?(Q?z[ut]=Q:delete z[ut],(Y=z[0]||z[1]||z[2]||z[3]||z[4]||z[5]||z[6]||z[7])&&Y===(z[7]||z[6]||z[5]||z[4]||z[3]||z[2]||z[1]||z[0])&&!Y.length&&($?$[jt]=Y:this._root=Y),this):(this._root=Q,this)}function ge(ae){for(var z=0,Y=ae.length;z<Y;++z)this.remove(ae[z]);return this}},10325:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return d}});function d(){return this._root}},15902:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return d}});function d(){var ge=0;return this.visit(function(ae){if(!ae.length)do++ge;while(ae=ae.next)}),ge}},12027:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return ge}});var d=ne(26805);function ge(ae){var z=[],Y,$=this._root,X,Q,ue,de,se,_e,Ae;for($&&z.push(new d.Z($,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));Y=z.pop();)if(!ae($=Y.node,Q=Y.x0,ue=Y.y0,de=Y.z0,se=Y.x1,_e=Y.y1,Ae=Y.z1)&&$.length){var Te=(Q+se)/2,ye=(ue+_e)/2,Ie=(de+Ae)/2;(X=$[7])&&z.push(new d.Z(X,Te,ye,Ie,se,_e,Ae)),(X=$[6])&&z.push(new d.Z(X,Q,ye,Ie,Te,_e,Ae)),(X=$[5])&&z.push(new d.Z(X,Te,ue,Ie,se,ye,Ae)),(X=$[4])&&z.push(new d.Z(X,Q,ue,Ie,Te,ye,Ae)),(X=$[3])&&z.push(new d.Z(X,Te,ye,de,se,_e,Ie)),(X=$[2])&&z.push(new d.Z(X,Q,ye,de,Te,_e,Ie)),(X=$[1])&&z.push(new d.Z(X,Te,ue,de,se,ye,Ie)),(X=$[0])&&z.push(new d.Z(X,Q,ue,de,Te,ye,Ie))}return this}},66612:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return ge}});var d=ne(26805);function ge(ae){var z=[],Y=[],$;for(this._root&&z.push(new d.Z(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));$=z.pop();){var X=$.node;if(X.length){var Q,ue=$.x0,de=$.y0,se=$.z0,_e=$.x1,Ae=$.y1,Te=$.z1,ye=(ue+_e)/2,Ie=(de+Ae)/2,Ze=(se+Te)/2;(Q=X[0])&&z.push(new d.Z(Q,ue,de,se,ye,Ie,Ze)),(Q=X[1])&&z.push(new d.Z(Q,ye,de,se,_e,Ie,Ze)),(Q=X[2])&&z.push(new d.Z(Q,ue,Ie,se,ye,Ae,Ze)),(Q=X[3])&&z.push(new d.Z(Q,ye,Ie,se,_e,Ae,Ze)),(Q=X[4])&&z.push(new d.Z(Q,ue,de,Ze,ye,Ie,Te)),(Q=X[5])&&z.push(new d.Z(Q,ye,de,Ze,_e,Ie,Te)),(Q=X[6])&&z.push(new d.Z(Q,ue,Ie,Ze,ye,Ae,Te)),(Q=X[7])&&z.push(new d.Z(Q,ye,Ie,Ze,_e,Ae,Te))}Y.push($)}for(;$=Y.pop();)ae($.node,$.x0,$.y0,$.z0,$.x1,$.y1,$.z1);return this}},14763:function(Qe,Le,ne){"use strict";ne.d(Le,{P:function(){return d},Z:function(){return ge}});function d(ae){return ae[0]}function ge(ae){return arguments.length?(this._x=ae,this):this._x}},94009:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return ge},q:function(){return d}});function d(ae){return ae[1]}function ge(ae){return arguments.length?(this._y=ae,this):this._y}},68889:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return ge},i:function(){return d}});function d(ae){return ae[2]}function ge(ae){return arguments.length?(this._z=ae,this):this._z}},60272:function(Qe,Le,ne){"use strict";ne.d(Le,{H:function(){return ae},Z:function(){return d}});function d(z){const Y=+this._x.call(null,z),$=+this._y.call(null,z);return ge(this.cover(Y,$),Y,$,z)}function ge(z,Y,$,X){if(isNaN(Y)||isNaN($))return z;var Q,ue=z._root,de={data:X},se=z._x0,_e=z._y0,Ae=z._x1,Te=z._y1,ye,Ie,Ze,Xe,qe,st,rt,Ke;if(!ue)return z._root=de,z;for(;ue.length;)if((qe=Y>=(ye=(se+Ae)/2))?se=ye:Ae=ye,(st=$>=(Ie=(_e+Te)/2))?_e=Ie:Te=Ie,Q=ue,!(ue=ue[rt=st<<1|qe]))return Q[rt]=de,z;if(Ze=+z._x.call(null,ue.data),Xe=+z._y.call(null,ue.data),Y===Ze&&$===Xe)return de.next=ue,Q?Q[rt]=de:z._root=de,z;do Q=Q?Q[rt]=new Array(4):z._root=new Array(4),(qe=Y>=(ye=(se+Ae)/2))?se=ye:Ae=ye,(st=$>=(Ie=(_e+Te)/2))?_e=Ie:Te=Ie;while((rt=st<<1|qe)===(Ke=(Xe>=Ie)<<1|Ze>=ye));return Q[Ke]=ue,Q[rt]=de,z}function ae(z){var Y,$,X=z.length,Q,ue,de=new Array(X),se=new Array(X),_e=1/0,Ae=1/0,Te=-1/0,ye=-1/0;for($=0;$<X;++$)isNaN(Q=+this._x.call(null,Y=z[$]))||isNaN(ue=+this._y.call(null,Y))||(de[$]=Q,se[$]=ue,Q<_e&&(_e=Q),Q>Te&&(Te=Q),ue<Ae&&(Ae=ue),ue>ye&&(ye=ue));if(_e>Te||Ae>ye)return this;for(this.cover(_e,Ae).cover(Te,ye),$=0;$<X;++$)ge(this,de[$],se[$],z[$]);return this}},51097:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return d}});function d(ge,ae){if(isNaN(ge=+ge)||isNaN(ae=+ae))return this;var z=this._x0,Y=this._y0,$=this._x1,X=this._y1;if(isNaN(z))$=(z=Math.floor(ge))+1,X=(Y=Math.floor(ae))+1;else{for(var Q=$-z||1,ue=this._root,de,se;z>ge||ge>=$||Y>ae||ae>=X;)switch(se=(ae<Y)<<1|ge<z,de=new Array(4),de[se]=ue,ue=de,Q*=2,se){case 0:$=z+Q,X=Y+Q;break;case 1:z=$-Q,X=Y+Q;break;case 2:$=z+Q,Y=X-Q;break;case 3:z=$-Q,Y=X-Q;break}this._root&&this._root.length&&(this._root=ue)}return this._x0=z,this._y0=Y,this._x1=$,this._y1=X,this}},58007:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return d}});function d(){var ge=[];return this.visit(function(ae){if(!ae.length)do ge.push(ae.data);while(ae=ae.next)}),ge}},12070:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return d}});function d(ge){return arguments.length?this.cover(+ge[0][0],+ge[0][1]).cover(+ge[1][0],+ge[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}},47064:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return ge}});var d=ne(44213);function ge(ae,z,Y){var $,X=this._x0,Q=this._y0,ue,de,se,_e,Ae=this._x1,Te=this._y1,ye=[],Ie=this._root,Ze,Xe;for(Ie&&ye.push(new d.Z(Ie,X,Q,Ae,Te)),Y==null?Y=1/0:(X=ae-Y,Q=z-Y,Ae=ae+Y,Te=z+Y,Y*=Y);Ze=ye.pop();)if(!(!(Ie=Ze.node)||(ue=Ze.x0)>Ae||(de=Ze.y0)>Te||(se=Ze.x1)<X||(_e=Ze.y1)<Q))if(Ie.length){var qe=(ue+se)/2,st=(de+_e)/2;ye.push(new d.Z(Ie[3],qe,st,se,_e),new d.Z(Ie[2],ue,st,qe,_e),new d.Z(Ie[1],qe,de,se,st),new d.Z(Ie[0],ue,de,qe,st)),(Xe=(z>=st)<<1|ae>=qe)&&(Ze=ye[ye.length-1],ye[ye.length-1]=ye[ye.length-1-Xe],ye[ye.length-1-Xe]=Ze)}else{var rt=ae-+this._x.call(null,Ie.data),Ke=z-+this._y.call(null,Ie.data),nt=rt*rt+Ke*Ke;if(nt<Y){var ut=Math.sqrt(Y=nt);X=ae-ut,Q=z-ut,Ae=ae+ut,Te=z+ut,$=Ie.data}}return $}},44213:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return d}});function d(ge,ae,z,Y,$){this.node=ge,this.x0=ae,this.y0=z,this.x1=Y,this.y1=$}},14301:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return Ae}});var d=ne(60272),ge=ne(51097),ae=ne(58007),z=ne(12070),Y=ne(47064),$=ne(88866),X=ne(10864),Q=ne(68984),ue=ne(3715),de=ne(73607),se=ne(56570),_e=ne(30992);function Ae(Ze,Xe,qe){var st=new Te(Xe==null?se.P:Xe,qe==null?_e.q:qe,NaN,NaN,NaN,NaN);return Ze==null?st:st.addAll(Ze)}function Te(Ze,Xe,qe,st,rt,Ke){this._x=Ze,this._y=Xe,this._x0=qe,this._y0=st,this._x1=rt,this._y1=Ke,this._root=void 0}function ye(Ze){for(var Xe={data:Ze.data},qe=Xe;Ze=Ze.next;)qe=qe.next={data:Ze.data};return Xe}var Ie=Ae.prototype=Te.prototype;Ie.copy=function(){var Ze=new Te(this._x,this._y,this._x0,this._y0,this._x1,this._y1),Xe=this._root,qe,st;if(!Xe)return Ze;if(!Xe.length)return Ze._root=ye(Xe),Ze;for(qe=[{source:Xe,target:Ze._root=new Array(4)}];Xe=qe.pop();)for(var rt=0;rt<4;++rt)(st=Xe.source[rt])&&(st.length?qe.push({source:st,target:Xe.target[rt]=new Array(4)}):Xe.target[rt]=ye(st));return Ze},Ie.add=d.Z,Ie.addAll=d.H,Ie.cover=ge.Z,Ie.data=ae.Z,Ie.extent=z.Z,Ie.find=Y.Z,Ie.remove=$.Z,Ie.removeAll=$.x,Ie.root=X.Z,Ie.size=Q.Z,Ie.visit=ue.Z,Ie.visitAfter=de.Z,Ie.x=se.Z,Ie.y=_e.Z},88866:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return d},x:function(){return ge}});function d(ae){if(isNaN(Ae=+this._x.call(null,ae))||isNaN(Te=+this._y.call(null,ae)))return this;var z,Y=this._root,$,X,Q,ue=this._x0,de=this._y0,se=this._x1,_e=this._y1,Ae,Te,ye,Ie,Ze,Xe,qe,st;if(!Y)return this;if(Y.length)for(;;){if((Ze=Ae>=(ye=(ue+se)/2))?ue=ye:se=ye,(Xe=Te>=(Ie=(de+_e)/2))?de=Ie:_e=Ie,z=Y,!(Y=Y[qe=Xe<<1|Ze]))return this;if(!Y.length)break;(z[qe+1&3]||z[qe+2&3]||z[qe+3&3])&&($=z,st=qe)}for(;Y.data!==ae;)if(X=Y,!(Y=Y.next))return this;return(Q=Y.next)&&delete Y.next,X?(Q?X.next=Q:delete X.next,this):z?(Q?z[qe]=Q:delete z[qe],(Y=z[0]||z[1]||z[2]||z[3])&&Y===(z[3]||z[2]||z[1]||z[0])&&!Y.length&&($?$[st]=Y:this._root=Y),this):(this._root=Q,this)}function ge(ae){for(var z=0,Y=ae.length;z<Y;++z)this.remove(ae[z]);return this}},10864:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return d}});function d(){return this._root}},68984:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return d}});function d(){var ge=0;return this.visit(function(ae){if(!ae.length)do++ge;while(ae=ae.next)}),ge}},3715:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return ge}});var d=ne(44213);function ge(ae){var z=[],Y,$=this._root,X,Q,ue,de,se;for($&&z.push(new d.Z($,this._x0,this._y0,this._x1,this._y1));Y=z.pop();)if(!ae($=Y.node,Q=Y.x0,ue=Y.y0,de=Y.x1,se=Y.y1)&&$.length){var _e=(Q+de)/2,Ae=(ue+se)/2;(X=$[3])&&z.push(new d.Z(X,_e,Ae,de,se)),(X=$[2])&&z.push(new d.Z(X,Q,Ae,_e,se)),(X=$[1])&&z.push(new d.Z(X,_e,ue,de,Ae)),(X=$[0])&&z.push(new d.Z(X,Q,ue,_e,Ae))}return this}},73607:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return ge}});var d=ne(44213);function ge(ae){var z=[],Y=[],$;for(this._root&&z.push(new d.Z(this._root,this._x0,this._y0,this._x1,this._y1));$=z.pop();){var X=$.node;if(X.length){var Q,ue=$.x0,de=$.y0,se=$.x1,_e=$.y1,Ae=(ue+se)/2,Te=(de+_e)/2;(Q=X[0])&&z.push(new d.Z(Q,ue,de,Ae,Te)),(Q=X[1])&&z.push(new d.Z(Q,Ae,de,se,Te)),(Q=X[2])&&z.push(new d.Z(Q,ue,Te,Ae,_e)),(Q=X[3])&&z.push(new d.Z(Q,Ae,Te,se,_e))}Y.push($)}for(;$=Y.pop();)ae($.node,$.x0,$.y0,$.x1,$.y1);return this}},56570:function(Qe,Le,ne){"use strict";ne.d(Le,{P:function(){return d},Z:function(){return ge}});function d(ae){return ae[0]}function ge(ae){return arguments.length?(this._x=ae,this):this._x}},30992:function(Qe,Le,ne){"use strict";ne.d(Le,{Z:function(){return ge},q:function(){return d}});function d(ae){return ae[1]}function ge(ae){return arguments.length?(this._y=ae,this):this._y}},83833:function(Qe,Le,ne){"use strict";ne.d(Le,{HT:function(){return ye}});var d=0,ge=0,ae=0,z=1e3,Y,$,X=0,Q=0,ue=0,de=typeof performance=="object"&&performance.now?performance:Date,se=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(rt){setTimeout(rt,17)};function _e(){return Q||(se(Ae),Q=de.now()+ue)}function Ae(){Q=0}function Te(){this._call=this._time=this._next=null}Te.prototype=ye.prototype={constructor:Te,restart:function(rt,Ke,nt){if(typeof rt!="function")throw new TypeError("callback is not a function");nt=(nt==null?_e():+nt)+(Ke==null?0:+Ke),!this._next&&$!==this&&($?$._next=this:Y=this,$=this),this._call=rt,this._time=nt,st()},stop:function(){this._call&&(this._call=null,this._time=1/0,st())}};function ye(rt,Ke,nt){var ut=new Te;return ut.restart(rt,Ke,nt),ut}function Ie(){_e(),++d;for(var rt=Y,Ke;rt;)(Ke=Q-rt._time)>=0&&rt._call.call(void 0,Ke),rt=rt._next;--d}function Ze(){Q=(X=de.now())+ue,d=ge=0;try{Ie()}finally{d=0,qe(),Q=0}}function Xe(){var rt=de.now(),Ke=rt-X;Ke>z&&(ue-=Ke,X=rt)}function qe(){for(var rt,Ke=Y,nt,ut=1/0;Ke;)Ke._call?(ut>Ke._time&&(ut=Ke._time),rt=Ke,Ke=Ke._next):(nt=Ke._next,Ke._next=null,Ke=rt?rt._next=nt:Y=nt);$=rt,st(ut)}function st(rt){if(!d){ge&&(ge=clearTimeout(ge));var Ke=rt-Q;Ke>24?(rt<1/0&&(ge=setTimeout(Ze,rt-de.now()-ue)),ae&&(ae=clearInterval(ae))):(ae||(X=de.now(),ae=setInterval(Xe,z)),d=1,se(Ze))}}},51910:function(Qe,Le,ne){"use strict";ne.d(Le,{$TI:function(){return yb},$V:function(){return j0},$YQ:function(){return Ky},ACn:function(){return Fg},BFQ:function(){return pr},BG$:function(){return Cc},BVF:function(){return Ac},Bf4:function(){return zm},Bgp:function(){return Al},BtG:function(){return Nh},CaW:function(){return hg},CdI:function(){return Ju},CtA:function(){return rg},Cy:function(){return Kr},D1R:function(){return El},D67:function(){return G_},D9w:function(){return Rl},Djp:function(){return Ra},DvJ:function(){return zl},E2K:function(){return og},EJi:function(){return ol},EcG:function(){return bd},EoG:function(){return S_},F1y:function(){return W_},F5G:function(){return sg},F5T:function(){return Lr},FDw:function(){return C_},FM8:function(){return dt},FT0:function(){return pt},FUD:function(){return ef},GG6:function(){return ah},GUF:function(){return hf},Gih:function(){return _g},H7L:function(){return Ag},HdW:function(){return yg},HkE:function(){return C0},Hy8:function(){return ti},I3e:function(){return Co},IEO:function(){return io},IKL:function(){return nc},ILR:function(){return Nl},IOt:function(){return Pa},Ilk:function(){return Nn},JCZ:function(){return Ia},JOQ:function(){return Xa},JQ4:function(){return rh},JUT:function(){return Sf},Jjb:function(){return Mg},KI_:function(){return Qr},KhW:function(){return pn},Kj0:function(){return aa},Kz5:function(){return qm},LSk:function(){return mf},LY2:function(){return T_},LgZ:function(){return kt},LsT:function(){return Xm},Ltg:function(){return or},Lun:function(){return ua},M$G:function(){return ff},M5h:function(){return qe},M6v:function(){return __},M8C:function(){return uy},Mig:function(){return as},MyG:function(){return Jr},N4l:function(){return Xe},NDo:function(){return b_},NKc:function(){return Mo},NYV:function(){return Na},NiX:function(){return Ey},Ns1:function(){return Qu},O4K:function(){return Dl},O5A:function(){return ey},O78:function(){return $_},OAl:function(){return Ll},ORg:function(){return w_},OTo:function(){return eg},OoA:function(){return ih},Ox3:function(){return pa},PA7:function(){return F_},PMe:function(){return da},Pa4:function(){return ie},PeU:function(){return z},QO2:function(){return rf},Qey:function(){return Cg},QmN:function(){return ae},ROQ:function(){return qy},RSm:function(){return Oe},Rhp:function(){return Vf},RlZ:function(){return mn},RsA:function(){return ge},RvT:function(){return Sg},S2y:function(){return $},S9g:function(){return Cf},SUY:function(){return Bp},Se2:function(){return An},Sm8:function(){return jt},SvJ:function(){return ch},T6w:function(){return j_},T95:function(){return $m},T_J:function(){return Ci},T_f:function(){return hl},TlE:function(){return dr},Tme:function(){return Ri},Tn7:function(){return Cp},TyD:function(){return ps},UCm:function(){return tg},USm:function(){return Ds},UY4:function(){return np},UZH:function(){return d},UcC:function(){return ga},V1s:function(){return $c},Vdb:function(){return ot},Vkp:function(){return Ps},VzW:function(){return Jo},W2J:function(){return Pc},WMw:function(){return Ze},WXh:function(){return sl},Wbm:function(){return Ke},Wid:function(){return ki},Wl3:function(){return _e},Wpd:function(){return Xt},Wzm:function(){return Hy},Xaj:function(){return st},YBo:function(){return al},YGz:function(){return Bm},YLQ:function(){return Gm},ZAu:function(){return za},ZK6:function(){return dn},ZRs:function(){return O_},ZTh:function(){return sf},ZXd:function(){return Y0},Zen:function(){return H_},Zr5:function(){return yi},ZzF:function(){return wr},_12:function(){return od},_AM:function(){return cg},_Li:function(){return Ae},_MY:function(){return Q},_RZ:function(){return Mr},_am:function(){return Qg},_fP:function(){return Hr},_iA:function(){return ue},_wr:function(){return _i},a$l:function(){return Ht},aCh:function(){return uf},aH4:function(){return Wm},aLr:function(){return xr},ad5:function(){return B_},av9:function(){return ig},bGH:function(){return rt},b_z:function(){return Qc},bdR:function(){return Ie},brP:function(){return ng},bsb:function(){return tf},c8b:function(){return un},cLu:function(){return Km},cM7:function(){return ts},cPb:function(){return os},cac:function(){return Il},ce8:function(){return df},cek:function(){return mu},cum:function(){return es},dSO:function(){return Vm},dVD:function(){return Jm},dZ3:function(){return M_},dd2:function(){return Bg},dj0:function(){return X_},dpR:function(){return Vs},dwf:function(){return xs},dwk:function(){return se},e62:function(){return pT},eD:function(){return Yu},eMJ:function(){return fh},eS_:function(){return gf},eaV:function(){return ug},ehD:function(){return Te},ekQ:function(){return pg},epp:function(){return $r},f2y:function(){return nf},fHI:function(){return Ql},fSK:function(){return Gt},fY$:function(){return th},fto:function(){return dg},g8_:function(){return Yd},gJg:function(){return Vh},ghN:function(){return hn},gi4:function(){return Jd},hEm:function(){return Qd},iAb:function(){return jm},iKG:function(){return lo},iMs:function(){return bb},iWC:function(){return _t},iWj:function(){return kh},iiP:function(){return N_},irR:function(){return Ym},j17:function(){return dh},j4z:function(){return Tg},jFi:function(){return ye},jZA:function(){return gg},jes:function(){return Zr},jfJ:function(){return k_},jwo:function(){return z_},jyi:function(){return t0},jyz:function(){return Wl},k0A:function(){return Zm},k74:function(){return bn},kB5:function(){return Ga},kaV:function(){return sn},ksN:function(){return Ec},l0P:function(){return fg},l6D:function(){return hh},lCJ:function(){return Ty},lGU:function(){return of},lRF:function(){return cu},lb7:function(){return Kc},lk7:function(){return ac},mSO:function(){return U_},mXe:function(){return eu},nls:function(){return Ur},ntZ:function(){return de},oAp:function(){return Jg},oDz:function(){return Ay},oqc:function(){return vg},p3g:function(){return Og},pBf:function(){return ea},pKu:function(){return oh},ptH:function(){return mg},qhX:function(){return y_},qkB:function(){return Wn},qlB:function(){return Sy},qyh:function(){return Hm},rDY:function(){return Gl},rOj:function(){return nt},r_:function(){return ut},rpg:function(){return nh},tQZ:function(){return Qm},tm_:function(){return Y},u9r:function(){return $n},uL9:function(){return v_},uWy:function(){return Rs},uXU:function(){return V_},v3W:function(){return Ca},vBJ:function(){return Wc},vCF:function(){return Qo},vCx:function(){return lg},vUy:function(){return Yn},vmT:function(){return jn},vpT:function(){return Lh},vuL:function(){return P_},vxC:function(){return km},w$m:function(){return x_},wJv:function(){return R_},wem:function(){return Yr},wk1:function(){return wo},wuA:function(){return ag},x12:function(){return Yl},x5V:function(){return La},xEZ:function(){return sr},xJs:function(){return sh},xeV:function(){return Ih},xfE:function(){return eh},xnb:function(){return Zy},xo$:function(){return ru},xoQ:function(){return Ao},xoR:function(){return Np},xsS:function(){return e0},y2t:function(){return xg},yGw:function(){return Ln},yj7:function(){return _0},yt0:function(){return Ns},ywz:function(){return Cl},zHn:function(){return Bc}});const d="181",ge={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},ae={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},z=0,Y=1,$=2,X=3,Q=0,ue=1,de=2,se=3,_e=0,Ae=1,Te=2,ye=0,Ie=1,Ze=2,Xe=3,qe=4,st=5,rt=100,Ke=101,nt=102,ut=103,jt=104,un=200,hn=201,pn=202,_t=203,bn=204,kt=205,Gt=206,ti=207,ot=208,Xt=209,mn=210,_i=211,Kr=212,Zr=213,Mo=214,Ac=0,An=1,yi=2,Qo=3,Yu=4,Ec=5,x_=6,__=7,Qu=0,y_=1,b_=2,v_=0,S_=1,Ju=2,Bm=3,T_=4,M_=5,Al=6,w_=7,Om="attached",A_="detached",eh=300,th=301,km=302,Vm=303,zm=304,Yd=306,nh=1e3,Rs=1001,ih=1002,ps=1003,Gm=1004,JS=1004,Wm=1005,E_=1005,Yr=1006,Hm=1007,eT=1007,El=1008,C_=1008,Cl=1009,$m=1010,jm=1011,Xm=1012,qm=1013,rh=1014,Jo=1015,Km=1016,Zm=1017,Ym=1018,R_=1020,Qm=35902,Jm=35899,eg=1021,tg=1022,wo=1023,Wn=1026,ng=1027,Qd=1028,Rl=1029,ig=1030,rg=1031,sg=1032,og=1033,ag=33776,pr=33777,Ca=33778,Nl=33779,cg=35840,lg=35841,ug=35842,hg=35843,dg=36196,fg=37492,pg=37496,mg=37808,gg=37809,xg=37810,Jd=37811,Ra=37812,Cc=37813,Na=37814,sh=37815,oh=37816,ah=37817,_g=37818,ef=37819,N_=37820,ch=37821,tf=36492,nf=36494,rf=36495,yg=36283,P_=36284,sf=36285,of=36286,L_=2200,I_=2201,lh=2202,uh=2300,af=2301,Kt=2302,Rc=2400,Nc=2401,Pl=2402,cf=2500,lf=2501,tT=0,D_=1,nT=2,bg=3200,U_=3201,iT=3202,rT=3203,Pa=0,F_=1,uf="",Qr="srgb",hf="srgb-linear",hh="linear",dh="srgb",B_=0,La=7680,df=7681,O_=7682,k_=7683,vg=34055,Ci=34056,fh=5386,Jr=512,V_=513,z_=514,Ns=515,Ll=516,Sg=517,Tg=518,es=519,Ao=512,G_=513,W_=514,ff=515,H_=516,$_=517,Mg=518,j_=519,Pc=35044,X_=35048,q_=35040,wg=35045,K_=35049,Z_=35041,Y_=35046,sT=35050,Q_=35042,pf="100",mf="300 es",Mr=2e3,Ia=2001,gf={COMPUTE:"compute",RENDER:"render"},oT={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},aT={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"};function Ag(M){for(let n=M.length-1;n>=0;--n)if(M[n]>=65535)return!0;return!1}const J_={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function Da(M,n){return new J_[M](n)}function Il(M){return document.createElementNS("http://www.w3.org/1999/xhtml",M)}function ey(){const M=Il("canvas");return M.style.display="block",M}const ph={};let ms=null;function cT(M){ms=M}function Eg(){return ms}function ts(...M){const n="THREE."+M.shift();ms?ms("log",n,...M):console.log(n,...M)}function dn(...M){const n="THREE."+M.shift();ms?ms("warn",n,...M):console.warn(n,...M)}function Yn(...M){const n="THREE."+M.shift();ms?ms("error",n,...M):console.error(n,...M)}function Dl(...M){const n=M.join(" ");n in ph||(ph[n]=!0,dn(...M))}function Cg(M,n,o){return new Promise(function(l,u){function p(){switch(M.clientWaitSync(n,M.SYNC_FLUSH_COMMANDS_BIT,0)){case M.WAIT_FAILED:u();break;case M.TIMEOUT_EXPIRED:setTimeout(p,o);break;default:l()}}setTimeout(p,o)})}class ea{addEventListener(n,o){this._listeners===void 0&&(this._listeners={});const l=this._listeners;l[n]===void 0&&(l[n]=[]),l[n].indexOf(o)===-1&&l[n].push(o)}hasEventListener(n,o){const l=this._listeners;return l===void 0?!1:l[n]!==void 0&&l[n].indexOf(o)!==-1}removeEventListener(n,o){const l=this._listeners;if(l===void 0)return;const u=l[n];if(u!==void 0){const p=u.indexOf(o);p!==-1&&u.splice(p,1)}}dispatchEvent(n){const o=this._listeners;if(o===void 0)return;const l=o[n.type];if(l!==void 0){n.target=this;const u=l.slice(0);for(let p=0,g=u.length;p<g;p++)u[p].call(this,n);n.target=null}}}const mr=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let mh=1234567;const Eo=Math.PI/180,Co=180/Math.PI;function gr(){const M=Math.random()*4294967295|0,n=Math.random()*4294967295|0,o=Math.random()*4294967295|0,l=Math.random()*4294967295|0;return(mr[M&255]+mr[M>>8&255]+mr[M>>16&255]+mr[M>>24&255]+"-"+mr[n&255]+mr[n>>8&255]+"-"+mr[n>>16&15|64]+mr[n>>24&255]+"-"+mr[o&63|128]+mr[o>>8&255]+"-"+mr[o>>16&255]+mr[o>>24&255]+mr[l&255]+mr[l>>8&255]+mr[l>>16&255]+mr[l>>24&255]).toLowerCase()}function an(M,n,o){return Math.max(n,Math.min(o,M))}function Ul(M,n){return(M%n+n)%n}function ty(M,n,o,l,u){return l+(M-n)*(u-l)/(o-n)}function Rg(M,n,o){return M!==n?(o-M)/(n-M):0}function Fl(M,n,o){return(1-o)*M+o*n}function gn(M,n,o,l){return Fl(M,n,1-Math.exp(-o*l))}function Ng(M,n=1){return n-Math.abs(Ul(M,n*2)-n)}function ny(M,n,o){return M<=n?0:M>=o?1:(M=(M-n)/(o-n),M*M*(3-2*M))}function xf(M,n,o){return M<=n?0:M>=o?1:(M=(M-n)/(o-n),M*M*M*(M*(M*6-15)+10))}function gh(M,n){return M+Math.floor(Math.random()*(n-M+1))}function iy(M,n){return M+Math.random()*(n-M)}function ry(M){return M*(.5-Math.random())}function sy(M){M!==void 0&&(mh=M);let n=mh+=1831565813;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}function Pg(M){return M*Eo}function Lg(M){return M*Co}function oy(M){return(M&M-1)===0&&M!==0}function ay(M){return Math.pow(2,Math.ceil(Math.log(M)/Math.LN2))}function cy(M){return Math.pow(2,Math.floor(Math.log(M)/Math.LN2))}function ly(M,n,o,l,u){const p=Math.cos,g=Math.sin,y=p(o/2),b=g(o/2),S=p((n+l)/2),A=g((n+l)/2),R=p((n-l)/2),N=g((n-l)/2),L=p((l-n)/2),I=g((l-n)/2);switch(u){case"XYX":M.set(y*A,b*R,b*N,y*S);break;case"YZY":M.set(b*N,y*A,b*R,y*S);break;case"ZXZ":M.set(b*R,b*N,y*A,y*S);break;case"XZX":M.set(y*A,b*I,b*L,y*S);break;case"YXY":M.set(b*L,y*A,b*I,y*S);break;case"ZYZ":M.set(b*I,b*L,y*A,y*S);break;default:dn("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+u)}}function Nr(M,n){switch(n.constructor){case Float32Array:return M;case Uint32Array:return M/4294967295;case Uint16Array:return M/65535;case Uint8Array:return M/255;case Int32Array:return Math.max(M/2147483647,-1);case Int16Array:return Math.max(M/32767,-1);case Int8Array:return Math.max(M/127,-1);default:throw new Error("Invalid component type.")}}function Fn(M,n){switch(n.constructor){case Float32Array:return M;case Uint32Array:return Math.round(M*4294967295);case Uint16Array:return Math.round(M*65535);case Uint8Array:return Math.round(M*255);case Int32Array:return Math.round(M*2147483647);case Int16Array:return Math.round(M*32767);case Int8Array:return Math.round(M*127);default:throw new Error("Invalid component type.")}}const uy={DEG2RAD:Eo,RAD2DEG:Co,generateUUID:gr,clamp:an,euclideanModulo:Ul,mapLinear:ty,inverseLerp:Rg,lerp:Fl,damp:gn,pingpong:Ng,smoothstep:ny,smootherstep:xf,randInt:gh,randFloat:iy,randFloatSpread:ry,seededRandom:sy,degToRad:Pg,radToDeg:Lg,isPowerOfTwo:oy,ceilPowerOfTwo:ay,floorPowerOfTwo:cy,setQuaternionFromProperEuler:ly,normalize:Fn,denormalize:Nr};class dt{constructor(n=0,o=0){dt.prototype.isVector2=!0,this.x=n,this.y=o}get width(){return this.x}set width(n){this.x=n}get height(){return this.y}set height(n){this.y=n}set(n,o){return this.x=n,this.y=o,this}setScalar(n){return this.x=n,this.y=n,this}setX(n){return this.x=n,this}setY(n){return this.y=n,this}setComponent(n,o){switch(n){case 0:this.x=o;break;case 1:this.y=o;break;default:throw new Error("index is out of range: "+n)}return this}getComponent(n){switch(n){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+n)}}clone(){return new this.constructor(this.x,this.y)}copy(n){return this.x=n.x,this.y=n.y,this}add(n){return this.x+=n.x,this.y+=n.y,this}addScalar(n){return this.x+=n,this.y+=n,this}addVectors(n,o){return this.x=n.x+o.x,this.y=n.y+o.y,this}addScaledVector(n,o){return this.x+=n.x*o,this.y+=n.y*o,this}sub(n){return this.x-=n.x,this.y-=n.y,this}subScalar(n){return this.x-=n,this.y-=n,this}subVectors(n,o){return this.x=n.x-o.x,this.y=n.y-o.y,this}multiply(n){return this.x*=n.x,this.y*=n.y,this}multiplyScalar(n){return this.x*=n,this.y*=n,this}divide(n){return this.x/=n.x,this.y/=n.y,this}divideScalar(n){return this.multiplyScalar(1/n)}applyMatrix3(n){const o=this.x,l=this.y,u=n.elements;return this.x=u[0]*o+u[3]*l+u[6],this.y=u[1]*o+u[4]*l+u[7],this}min(n){return this.x=Math.min(this.x,n.x),this.y=Math.min(this.y,n.y),this}max(n){return this.x=Math.max(this.x,n.x),this.y=Math.max(this.y,n.y),this}clamp(n,o){return this.x=an(this.x,n.x,o.x),this.y=an(this.y,n.y,o.y),this}clampScalar(n,o){return this.x=an(this.x,n,o),this.y=an(this.y,n,o),this}clampLength(n,o){const l=this.length();return this.divideScalar(l||1).multiplyScalar(an(l,n,o))}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(n){return this.x*n.x+this.y*n.y}cross(n){return this.x*n.y-this.y*n.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(n){const o=Math.sqrt(this.lengthSq()*n.lengthSq());if(o===0)return Math.PI/2;const l=this.dot(n)/o;return Math.acos(an(l,-1,1))}distanceTo(n){return Math.sqrt(this.distanceToSquared(n))}distanceToSquared(n){const o=this.x-n.x,l=this.y-n.y;return o*o+l*l}manhattanDistanceTo(n){return Math.abs(this.x-n.x)+Math.abs(this.y-n.y)}setLength(n){return this.normalize().multiplyScalar(n)}lerp(n,o){return this.x+=(n.x-this.x)*o,this.y+=(n.y-this.y)*o,this}lerpVectors(n,o,l){return this.x=n.x+(o.x-n.x)*l,this.y=n.y+(o.y-n.y)*l,this}equals(n){return n.x===this.x&&n.y===this.y}fromArray(n,o=0){return this.x=n[o],this.y=n[o+1],this}toArray(n=[],o=0){return n[o]=this.x,n[o+1]=this.y,n}fromBufferAttribute(n,o){return this.x=n.getX(o),this.y=n.getY(o),this}rotateAround(n,o){const l=Math.cos(o),u=Math.sin(o),p=this.x-n.x,g=this.y-n.y;return this.x=p*l-g*u+n.x,this.y=p*u+g*l+n.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Hr{constructor(n=0,o=0,l=0,u=1){this.isQuaternion=!0,this._x=n,this._y=o,this._z=l,this._w=u}static slerpFlat(n,o,l,u,p,g,y){let b=l[u+0],S=l[u+1],A=l[u+2],R=l[u+3],N=p[g+0],L=p[g+1],I=p[g+2],B=p[g+3];if(y<=0){n[o+0]=b,n[o+1]=S,n[o+2]=A,n[o+3]=R;return}if(y>=1){n[o+0]=N,n[o+1]=L,n[o+2]=I,n[o+3]=B;return}if(R!==B||b!==N||S!==L||A!==I){let Z=b*N+S*L+A*I+R*B;Z<0&&(N=-N,L=-L,I=-I,B=-B,Z=-Z);let q=1-y;if(Z<.9995){const ee=Math.acos(Z),te=Math.sin(ee);q=Math.sin(q*ee)/te,y=Math.sin(y*ee)/te,b=b*q+N*y,S=S*q+L*y,A=A*q+I*y,R=R*q+B*y}else{b=b*q+N*y,S=S*q+L*y,A=A*q+I*y,R=R*q+B*y;const ee=1/Math.sqrt(b*b+S*S+A*A+R*R);b*=ee,S*=ee,A*=ee,R*=ee}}n[o]=b,n[o+1]=S,n[o+2]=A,n[o+3]=R}static multiplyQuaternionsFlat(n,o,l,u,p,g){const y=l[u],b=l[u+1],S=l[u+2],A=l[u+3],R=p[g],N=p[g+1],L=p[g+2],I=p[g+3];return n[o]=y*I+A*R+b*L-S*N,n[o+1]=b*I+A*N+S*R-y*L,n[o+2]=S*I+A*L+y*N-b*R,n[o+3]=A*I-y*R-b*N-S*L,n}get x(){return this._x}set x(n){this._x=n,this._onChangeCallback()}get y(){return this._y}set y(n){this._y=n,this._onChangeCallback()}get z(){return this._z}set z(n){this._z=n,this._onChangeCallback()}get w(){return this._w}set w(n){this._w=n,this._onChangeCallback()}set(n,o,l,u){return this._x=n,this._y=o,this._z=l,this._w=u,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(n){return this._x=n.x,this._y=n.y,this._z=n.z,this._w=n.w,this._onChangeCallback(),this}setFromEuler(n,o=!0){const l=n._x,u=n._y,p=n._z,g=n._order,y=Math.cos,b=Math.sin,S=y(l/2),A=y(u/2),R=y(p/2),N=b(l/2),L=b(u/2),I=b(p/2);switch(g){case"XYZ":this._x=N*A*R+S*L*I,this._y=S*L*R-N*A*I,this._z=S*A*I+N*L*R,this._w=S*A*R-N*L*I;break;case"YXZ":this._x=N*A*R+S*L*I,this._y=S*L*R-N*A*I,this._z=S*A*I-N*L*R,this._w=S*A*R+N*L*I;break;case"ZXY":this._x=N*A*R-S*L*I,this._y=S*L*R+N*A*I,this._z=S*A*I+N*L*R,this._w=S*A*R-N*L*I;break;case"ZYX":this._x=N*A*R-S*L*I,this._y=S*L*R+N*A*I,this._z=S*A*I-N*L*R,this._w=S*A*R+N*L*I;break;case"YZX":this._x=N*A*R+S*L*I,this._y=S*L*R+N*A*I,this._z=S*A*I-N*L*R,this._w=S*A*R-N*L*I;break;case"XZY":this._x=N*A*R-S*L*I,this._y=S*L*R-N*A*I,this._z=S*A*I+N*L*R,this._w=S*A*R+N*L*I;break;default:dn("Quaternion: .setFromEuler() encountered an unknown order: "+g)}return o===!0&&this._onChangeCallback(),this}setFromAxisAngle(n,o){const l=o/2,u=Math.sin(l);return this._x=n.x*u,this._y=n.y*u,this._z=n.z*u,this._w=Math.cos(l),this._onChangeCallback(),this}setFromRotationMatrix(n){const o=n.elements,l=o[0],u=o[4],p=o[8],g=o[1],y=o[5],b=o[9],S=o[2],A=o[6],R=o[10],N=l+y+R;if(N>0){const L=.5/Math.sqrt(N+1);this._w=.25/L,this._x=(A-b)*L,this._y=(p-S)*L,this._z=(g-u)*L}else if(l>y&&l>R){const L=2*Math.sqrt(1+l-y-R);this._w=(A-b)/L,this._x=.25*L,this._y=(u+g)/L,this._z=(p+S)/L}else if(y>R){const L=2*Math.sqrt(1+y-l-R);this._w=(p-S)/L,this._x=(u+g)/L,this._y=.25*L,this._z=(b+A)/L}else{const L=2*Math.sqrt(1+R-l-y);this._w=(g-u)/L,this._x=(p+S)/L,this._y=(b+A)/L,this._z=.25*L}return this._onChangeCallback(),this}setFromUnitVectors(n,o){let l=n.dot(o)+1;return l<1e-8?(l=0,Math.abs(n.x)>Math.abs(n.z)?(this._x=-n.y,this._y=n.x,this._z=0,this._w=l):(this._x=0,this._y=-n.z,this._z=n.y,this._w=l)):(this._x=n.y*o.z-n.z*o.y,this._y=n.z*o.x-n.x*o.z,this._z=n.x*o.y-n.y*o.x,this._w=l),this.normalize()}angleTo(n){return 2*Math.acos(Math.abs(an(this.dot(n),-1,1)))}rotateTowards(n,o){const l=this.angleTo(n);if(l===0)return this;const u=Math.min(1,o/l);return this.slerp(n,u),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(n){return this._x*n._x+this._y*n._y+this._z*n._z+this._w*n._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 n=this.length();return n===0?(this._x=0,this._y=0,this._z=0,this._w=1):(n=1/n,this._x=this._x*n,this._y=this._y*n,this._z=this._z*n,this._w=this._w*n),this._onChangeCallback(),this}multiply(n){return this.multiplyQuaternions(this,n)}premultiply(n){return this.multiplyQuaternions(n,this)}multiplyQuaternions(n,o){const l=n._x,u=n._y,p=n._z,g=n._w,y=o._x,b=o._y,S=o._z,A=o._w;return this._x=l*A+g*y+u*S-p*b,this._y=u*A+g*b+p*y-l*S,this._z=p*A+g*S+l*b-u*y,this._w=g*A-l*y-u*b-p*S,this._onChangeCallback(),this}slerp(n,o){if(o<=0)return this;if(o>=1)return this.copy(n);let l=n._x,u=n._y,p=n._z,g=n._w,y=this.dot(n);y<0&&(l=-l,u=-u,p=-p,g=-g,y=-y);let b=1-o;if(y<.9995){const S=Math.acos(y),A=Math.sin(S);b=Math.sin(b*S)/A,o=Math.sin(o*S)/A,this._x=this._x*b+l*o,this._y=this._y*b+u*o,this._z=this._z*b+p*o,this._w=this._w*b+g*o,this._onChangeCallback()}else this._x=this._x*b+l*o,this._y=this._y*b+u*o,this._z=this._z*b+p*o,this._w=this._w*b+g*o,this.normalize();return this}slerpQuaternions(n,o,l){return this.copy(n).slerp(o,l)}random(){const n=2*Math.PI*Math.random(),o=2*Math.PI*Math.random(),l=Math.random(),u=Math.sqrt(1-l),p=Math.sqrt(l);return this.set(u*Math.sin(n),u*Math.cos(n),p*Math.sin(o),p*Math.cos(o))}equals(n){return n._x===this._x&&n._y===this._y&&n._z===this._z&&n._w===this._w}fromArray(n,o=0){return this._x=n[o],this._y=n[o+1],this._z=n[o+2],this._w=n[o+3],this._onChangeCallback(),this}toArray(n=[],o=0){return n[o]=this._x,n[o+1]=this._y,n[o+2]=this._z,n[o+3]=this._w,n}fromBufferAttribute(n,o){return this._x=n.getX(o),this._y=n.getY(o),this._z=n.getZ(o),this._w=n.getW(o),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(n){return this._onChangeCallback=n,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class ie{constructor(n=0,o=0,l=0){ie.prototype.isVector3=!0,this.x=n,this.y=o,this.z=l}set(n,o,l){return l===void 0&&(l=this.z),this.x=n,this.y=o,this.z=l,this}setScalar(n){return this.x=n,this.y=n,this.z=n,this}setX(n){return this.x=n,this}setY(n){return this.y=n,this}setZ(n){return this.z=n,this}setComponent(n,o){switch(n){case 0:this.x=o;break;case 1:this.y=o;break;case 2:this.z=o;break;default:throw new Error("index is out of range: "+n)}return this}getComponent(n){switch(n){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+n)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(n){return this.x=n.x,this.y=n.y,this.z=n.z,this}add(n){return this.x+=n.x,this.y+=n.y,this.z+=n.z,this}addScalar(n){return this.x+=n,this.y+=n,this.z+=n,this}addVectors(n,o){return this.x=n.x+o.x,this.y=n.y+o.y,this.z=n.z+o.z,this}addScaledVector(n,o){return this.x+=n.x*o,this.y+=n.y*o,this.z+=n.z*o,this}sub(n){return this.x-=n.x,this.y-=n.y,this.z-=n.z,this}subScalar(n){return this.x-=n,this.y-=n,this.z-=n,this}subVectors(n,o){return this.x=n.x-o.x,this.y=n.y-o.y,this.z=n.z-o.z,this}multiply(n){return this.x*=n.x,this.y*=n.y,this.z*=n.z,this}multiplyScalar(n){return this.x*=n,this.y*=n,this.z*=n,this}multiplyVectors(n,o){return this.x=n.x*o.x,this.y=n.y*o.y,this.z=n.z*o.z,this}applyEuler(n){return this.applyQuaternion(Ig.setFromEuler(n))}applyAxisAngle(n,o){return this.applyQuaternion(Ig.setFromAxisAngle(n,o))}applyMatrix3(n){const o=this.x,l=this.y,u=this.z,p=n.elements;return this.x=p[0]*o+p[3]*l+p[6]*u,this.y=p[1]*o+p[4]*l+p[7]*u,this.z=p[2]*o+p[5]*l+p[8]*u,this}applyNormalMatrix(n){return this.applyMatrix3(n).normalize()}applyMatrix4(n){const o=this.x,l=this.y,u=this.z,p=n.elements,g=1/(p[3]*o+p[7]*l+p[11]*u+p[15]);return this.x=(p[0]*o+p[4]*l+p[8]*u+p[12])*g,this.y=(p[1]*o+p[5]*l+p[9]*u+p[13])*g,this.z=(p[2]*o+p[6]*l+p[10]*u+p[14])*g,this}applyQuaternion(n){const o=this.x,l=this.y,u=this.z,p=n.x,g=n.y,y=n.z,b=n.w,S=2*(g*u-y*l),A=2*(y*o-p*u),R=2*(p*l-g*o);return this.x=o+b*S+g*R-y*A,this.y=l+b*A+y*S-p*R,this.z=u+b*R+p*A-g*S,this}project(n){return this.applyMatrix4(n.matrixWorldInverse).applyMatrix4(n.projectionMatrix)}unproject(n){return this.applyMatrix4(n.projectionMatrixInverse).applyMatrix4(n.matrixWorld)}transformDirection(n){const o=this.x,l=this.y,u=this.z,p=n.elements;return this.x=p[0]*o+p[4]*l+p[8]*u,this.y=p[1]*o+p[5]*l+p[9]*u,this.z=p[2]*o+p[6]*l+p[10]*u,this.normalize()}divide(n){return this.x/=n.x,this.y/=n.y,this.z/=n.z,this}divideScalar(n){return this.multiplyScalar(1/n)}min(n){return this.x=Math.min(this.x,n.x),this.y=Math.min(this.y,n.y),this.z=Math.min(this.z,n.z),this}max(n){return this.x=Math.max(this.x,n.x),this.y=Math.max(this.y,n.y),this.z=Math.max(this.z,n.z),this}clamp(n,o){return this.x=an(this.x,n.x,o.x),this.y=an(this.y,n.y,o.y),this.z=an(this.z,n.z,o.z),this}clampScalar(n,o){return this.x=an(this.x,n,o),this.y=an(this.y,n,o),this.z=an(this.z,n,o),this}clampLength(n,o){const l=this.length();return this.divideScalar(l||1).multiplyScalar(an(l,n,o))}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(n){return this.x*n.x+this.y*n.y+this.z*n.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(n){return this.normalize().multiplyScalar(n)}lerp(n,o){return this.x+=(n.x-this.x)*o,this.y+=(n.y-this.y)*o,this.z+=(n.z-this.z)*o,this}lerpVectors(n,o,l){return this.x=n.x+(o.x-n.x)*l,this.y=n.y+(o.y-n.y)*l,this.z=n.z+(o.z-n.z)*l,this}cross(n){return this.crossVectors(this,n)}crossVectors(n,o){const l=n.x,u=n.y,p=n.z,g=o.x,y=o.y,b=o.z;return this.x=u*b-p*y,this.y=p*g-l*b,this.z=l*y-u*g,this}projectOnVector(n){const o=n.lengthSq();if(o===0)return this.set(0,0,0);const l=n.dot(this)/o;return this.copy(n).multiplyScalar(l)}projectOnPlane(n){return _f.copy(this).projectOnVector(n),this.sub(_f)}reflect(n){return this.sub(_f.copy(n).multiplyScalar(2*this.dot(n)))}angleTo(n){const o=Math.sqrt(this.lengthSq()*n.lengthSq());if(o===0)return Math.PI/2;const l=this.dot(n)/o;return Math.acos(an(l,-1,1))}distanceTo(n){return Math.sqrt(this.distanceToSquared(n))}distanceToSquared(n){const o=this.x-n.x,l=this.y-n.y,u=this.z-n.z;return o*o+l*l+u*u}manhattanDistanceTo(n){return Math.abs(this.x-n.x)+Math.abs(this.y-n.y)+Math.abs(this.z-n.z)}setFromSpherical(n){return this.setFromSphericalCoords(n.radius,n.phi,n.theta)}setFromSphericalCoords(n,o,l){const u=Math.sin(o)*n;return this.x=u*Math.sin(l),this.y=Math.cos(o)*n,this.z=u*Math.cos(l),this}setFromCylindrical(n){return this.setFromCylindricalCoords(n.radius,n.theta,n.y)}setFromCylindricalCoords(n,o,l){return this.x=n*Math.sin(o),this.y=l,this.z=n*Math.cos(o),this}setFromMatrixPosition(n){const o=n.elements;return this.x=o[12],this.y=o[13],this.z=o[14],this}setFromMatrixScale(n){const o=this.setFromMatrixColumn(n,0).length(),l=this.setFromMatrixColumn(n,1).length(),u=this.setFromMatrixColumn(n,2).length();return this.x=o,this.y=l,this.z=u,this}setFromMatrixColumn(n,o){return this.fromArray(n.elements,o*4)}setFromMatrix3Column(n,o){return this.fromArray(n.elements,o*3)}setFromEuler(n){return this.x=n._x,this.y=n._y,this.z=n._z,this}setFromColor(n){return this.x=n.r,this.y=n.g,this.z=n.b,this}equals(n){return n.x===this.x&&n.y===this.y&&n.z===this.z}fromArray(n,o=0){return this.x=n[o],this.y=n[o+1],this.z=n[o+2],this}toArray(n=[],o=0){return n[o]=this.x,n[o+1]=this.y,n[o+2]=this.z,n}fromBufferAttribute(n,o){return this.x=n.getX(o),this.y=n.getY(o),this.z=n.getZ(o),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const n=Math.random()*Math.PI*2,o=Math.random()*2-1,l=Math.sqrt(1-o*o);return this.x=l*Math.cos(n),this.y=o,this.z=l*Math.sin(n),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const _f=new ie,Ig=new Hr;class Ps{constructor(n,o,l,u,p,g,y,b,S){Ps.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],n!==void 0&&this.set(n,o,l,u,p,g,y,b,S)}set(n,o,l,u,p,g,y,b,S){const A=this.elements;return A[0]=n,A[1]=u,A[2]=y,A[3]=o,A[4]=p,A[5]=b,A[6]=l,A[7]=g,A[8]=S,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(n){const o=this.elements,l=n.elements;return o[0]=l[0],o[1]=l[1],o[2]=l[2],o[3]=l[3],o[4]=l[4],o[5]=l[5],o[6]=l[6],o[7]=l[7],o[8]=l[8],this}extractBasis(n,o,l){return n.setFromMatrix3Column(this,0),o.setFromMatrix3Column(this,1),l.setFromMatrix3Column(this,2),this}setFromMatrix4(n){const o=n.elements;return this.set(o[0],o[4],o[8],o[1],o[5],o[9],o[2],o[6],o[10]),this}multiply(n){return this.multiplyMatrices(this,n)}premultiply(n){return this.multiplyMatrices(n,this)}multiplyMatrices(n,o){const l=n.elements,u=o.elements,p=this.elements,g=l[0],y=l[3],b=l[6],S=l[1],A=l[4],R=l[7],N=l[2],L=l[5],I=l[8],B=u[0],Z=u[3],q=u[6],ee=u[1],te=u[4],he=u[7],Re=u[2],ke=u[5],We=u[8];return p[0]=g*B+y*ee+b*Re,p[3]=g*Z+y*te+b*ke,p[6]=g*q+y*he+b*We,p[1]=S*B+A*ee+R*Re,p[4]=S*Z+A*te+R*ke,p[7]=S*q+A*he+R*We,p[2]=N*B+L*ee+I*Re,p[5]=N*Z+L*te+I*ke,p[8]=N*q+L*he+I*We,this}multiplyScalar(n){const o=this.elements;return o[0]*=n,o[3]*=n,o[6]*=n,o[1]*=n,o[4]*=n,o[7]*=n,o[2]*=n,o[5]*=n,o[8]*=n,this}determinant(){const n=this.elements,o=n[0],l=n[1],u=n[2],p=n[3],g=n[4],y=n[5],b=n[6],S=n[7],A=n[8];return o*g*A-o*y*S-l*p*A+l*y*b+u*p*S-u*g*b}invert(){const n=this.elements,o=n[0],l=n[1],u=n[2],p=n[3],g=n[4],y=n[5],b=n[6],S=n[7],A=n[8],R=A*g-y*S,N=y*b-A*p,L=S*p-g*b,I=o*R+l*N+u*L;if(I===0)return this.set(0,0,0,0,0,0,0,0,0);const B=1/I;return n[0]=R*B,n[1]=(u*S-A*l)*B,n[2]=(y*l-u*g)*B,n[3]=N*B,n[4]=(A*o-u*b)*B,n[5]=(u*p-y*o)*B,n[6]=L*B,n[7]=(l*b-S*o)*B,n[8]=(g*o-l*p)*B,this}transpose(){let n;const o=this.elements;return n=o[1],o[1]=o[3],o[3]=n,n=o[2],o[2]=o[6],o[6]=n,n=o[5],o[5]=o[7],o[7]=n,this}getNormalMatrix(n){return this.setFromMatrix4(n).invert().transpose()}transposeIntoArray(n){const o=this.elements;return n[0]=o[0],n[1]=o[3],n[2]=o[6],n[3]=o[1],n[4]=o[4],n[5]=o[7],n[6]=o[2],n[7]=o[5],n[8]=o[8],this}setUvTransform(n,o,l,u,p,g,y){const b=Math.cos(p),S=Math.sin(p);return this.set(l*b,l*S,-l*(b*g+S*y)+g+n,-u*S,u*b,-u*(-S*g+b*y)+y+o,0,0,1),this}scale(n,o){return this.premultiply(yf.makeScale(n,o)),this}rotate(n){return this.premultiply(yf.makeRotation(-n)),this}translate(n,o){return this.premultiply(yf.makeTranslation(n,o)),this}makeTranslation(n,o){return n.isVector2?this.set(1,0,n.x,0,1,n.y,0,0,1):this.set(1,0,n,0,1,o,0,0,1),this}makeRotation(n){const o=Math.cos(n),l=Math.sin(n);return this.set(o,-l,0,l,o,0,0,0,1),this}makeScale(n,o){return this.set(n,0,0,0,o,0,0,0,1),this}equals(n){const o=this.elements,l=n.elements;for(let u=0;u<9;u++)if(o[u]!==l[u])return!1;return!0}fromArray(n,o=0){for(let l=0;l<9;l++)this.elements[l]=n[l+o];return this}toArray(n=[],o=0){const l=this.elements;return n[o]=l[0],n[o+1]=l[1],n[o+2]=l[2],n[o+3]=l[3],n[o+4]=l[4],n[o+5]=l[5],n[o+6]=l[6],n[o+7]=l[7],n[o+8]=l[8],n}clone(){return new this.constructor().fromArray(this.elements)}}const yf=new Ps,Dg=new Ps().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Ug=new Ps().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function hy(){const M={enabled:!0,workingColorSpace:hf,spaces:{},convert:function(u,p,g){return this.enabled===!1||p===g||!p||!g||(this.spaces[p].transfer===dh&&(u.r=Ro(u.r),u.g=Ro(u.g),u.b=Ro(u.b)),this.spaces[p].primaries!==this.spaces[g].primaries&&(u.applyMatrix3(this.spaces[p].toXYZ),u.applyMatrix3(this.spaces[g].fromXYZ)),this.spaces[g].transfer===dh&&(u.r=Lc(u.r),u.g=Lc(u.g),u.b=Lc(u.b))),u},workingToColorSpace:function(u,p){return this.convert(u,this.workingColorSpace,p)},colorSpaceToWorking:function(u,p){return this.convert(u,p,this.workingColorSpace)},getPrimaries:function(u){return this.spaces[u].primaries},getTransfer:function(u){return u===uf?hh:this.spaces[u].transfer},getToneMappingMode:function(u){return this.spaces[u].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(u,p=this.workingColorSpace){return u.fromArray(this.spaces[p].luminanceCoefficients)},define:function(u){Object.assign(this.spaces,u)},_getMatrix:function(u,p,g){return u.copy(this.spaces[p].toXYZ).multiply(this.spaces[g].fromXYZ)},_getDrawingBufferColorSpace:function(u){return this.spaces[u].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(u=this.workingColorSpace){return this.spaces[u].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(u,p){return Dl("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),M.workingToColorSpace(u,p)},toWorkingColorSpace:function(u,p){return Dl("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),M.colorSpaceToWorking(u,p)}},n=[.64,.33,.3,.6,.15,.06],o=[.2126,.7152,.0722],l=[.3127,.329];return M.define({[hf]:{primaries:n,whitePoint:l,transfer:hh,toXYZ:Dg,fromXYZ:Ug,luminanceCoefficients:o,workingColorSpaceConfig:{unpackColorSpace:Qr},outputColorSpaceConfig:{drawingBufferColorSpace:Qr}},[Qr]:{primaries:n,whitePoint:l,transfer:dh,toXYZ:Dg,fromXYZ:Ug,luminanceCoefficients:o,outputColorSpaceConfig:{drawingBufferColorSpace:Qr}}}),M}const $r=hy();function Ro(M){return M<.04045?M*.0773993808:Math.pow(M*.9478672986+.0521327014,2.4)}function Lc(M){return M<.0031308?M*12.92:1.055*Math.pow(M,.41666)-.055}let Ic;class dy{static getDataURL(n,o="image/png"){if(/^data:/i.test(n.src)||typeof HTMLCanvasElement=="undefined")return n.src;let l;if(n instanceof HTMLCanvasElement)l=n;else{Ic===void 0&&(Ic=Il("canvas")),Ic.width=n.width,Ic.height=n.height;const u=Ic.getContext("2d");n instanceof ImageData?u.putImageData(n,0,0):u.drawImage(n,0,0,n.width,n.height),l=Ic}return l.toDataURL(o)}static sRGBToLinear(n){if(typeof HTMLImageElement!="undefined"&&n instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&n instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&n instanceof ImageBitmap){const o=Il("canvas");o.width=n.width,o.height=n.height;const l=o.getContext("2d");l.drawImage(n,0,0,n.width,n.height);const u=l.getImageData(0,0,n.width,n.height),p=u.data;for(let g=0;g<p.length;g++)p[g]=Ro(p[g]/255)*255;return l.putImageData(u,0,0),o}else if(n.data){const o=n.data.slice(0);for(let l=0;l<o.length;l++)o instanceof Uint8Array||o instanceof Uint8ClampedArray?o[l]=Math.floor(Ro(o[l]/255)*255):o[l]=Ro(o[l]);return{data:o,width:n.width,height:n.height}}else return dn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),n}}let fy=0;class Ua{constructor(n=null){this.isSource=!0,Object.defineProperty(this,"id",{value:fy++}),this.uuid=gr(),this.data=n,this.dataReady=!0,this.version=0}getSize(n){const o=this.data;return typeof HTMLVideoElement!="undefined"&&o instanceof HTMLVideoElement?n.set(o.videoWidth,o.videoHeight,0):o instanceof VideoFrame?n.set(o.displayHeight,o.displayWidth,0):o!==null?n.set(o.width,o.height,o.depth||0):n.set(0,0,0),n}set needsUpdate(n){n===!0&&this.version++}toJSON(n){const o=n===void 0||typeof n=="string";if(!o&&n.images[this.uuid]!==void 0)return n.images[this.uuid];const l={uuid:this.uuid,url:""},u=this.data;if(u!==null){let p;if(Array.isArray(u)){p=[];for(let g=0,y=u.length;g<y;g++)u[g].isDataTexture?p.push(bf(u[g].image)):p.push(bf(u[g]))}else p=bf(u);l.url=p}return o||(n.images[this.uuid]=l),l}}function bf(M){return typeof HTMLImageElement!="undefined"&&M instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&M instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&M instanceof ImageBitmap?dy.getDataURL(M):M.data?{data:Array.from(M.data),width:M.width,height:M.height,type:M.data.constructor.name}:(dn("Texture: Unable to serialize Texture."),{})}let py=0;const vf=new ie;class sr extends ea{constructor(n=sr.DEFAULT_IMAGE,o=sr.DEFAULT_MAPPING,l=Rs,u=Rs,p=Yr,g=El,y=wo,b=Cl,S=sr.DEFAULT_ANISOTROPY,A=uf){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:py++}),this.uuid=gr(),this.name="",this.source=new Ua(n),this.mipmaps=[],this.mapping=o,this.channel=0,this.wrapS=l,this.wrapT=u,this.magFilter=p,this.minFilter=g,this.anisotropy=S,this.format=y,this.internalFormat=null,this.type=b,this.offset=new dt(0,0),this.repeat=new dt(1,1),this.center=new dt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Ps,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=A,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(n&&n.depth&&n.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(vf).x}get height(){return this.source.getSize(vf).y}get depth(){return this.source.getSize(vf).z}get image(){return this.source.data}set image(n=null){this.source.data=n}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(n,o){this.updateRanges.push({start:n,count:o})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(n){return this.name=n.name,this.source=n.source,this.mipmaps=n.mipmaps.slice(0),this.mapping=n.mapping,this.channel=n.channel,this.wrapS=n.wrapS,this.wrapT=n.wrapT,this.magFilter=n.magFilter,this.minFilter=n.minFilter,this.anisotropy=n.anisotropy,this.format=n.format,this.internalFormat=n.internalFormat,this.type=n.type,this.offset.copy(n.offset),this.repeat.copy(n.repeat),this.center.copy(n.center),this.rotation=n.rotation,this.matrixAutoUpdate=n.matrixAutoUpdate,this.matrix.copy(n.matrix),this.generateMipmaps=n.generateMipmaps,this.premultiplyAlpha=n.premultiplyAlpha,this.flipY=n.flipY,this.unpackAlignment=n.unpackAlignment,this.colorSpace=n.colorSpace,this.renderTarget=n.renderTarget,this.isRenderTargetTexture=n.isRenderTargetTexture,this.isArrayTexture=n.isArrayTexture,this.userData=JSON.parse(JSON.stringify(n.userData)),this.needsUpdate=!0,this}setValues(n){for(const o in n){const l=n[o];if(l===void 0){dn(`Texture.setValues(): parameter '${o}' has value of undefined.`);continue}const u=this[o];if(u===void 0){dn(`Texture.setValues(): property '${o}' does not exist.`);continue}u&&l&&u.isVector2&&l.isVector2||u&&l&&u.isVector3&&l.isVector3||u&&l&&u.isMatrix3&&l.isMatrix3?u.copy(l):this[o]=l}}toJSON(n){const o=n===void 0||typeof n=="string";if(!o&&n.textures[this.uuid]!==void 0)return n.textures[this.uuid];const l={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(n).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(l.userData=this.userData),o||(n.textures[this.uuid]=l),l}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(n){if(this.mapping!==eh)return n;if(n.applyMatrix3(this.matrix),n.x<0||n.x>1)switch(this.wrapS){case nh:n.x=n.x-Math.floor(n.x);break;case Rs:n.x=n.x<0?0:1;break;case ih:Math.abs(Math.floor(n.x)%2)===1?n.x=Math.ceil(n.x)-n.x:n.x=n.x-Math.floor(n.x);break}if(n.y<0||n.y>1)switch(this.wrapT){case nh:n.y=n.y-Math.floor(n.y);break;case Rs:n.y=n.y<0?0:1;break;case ih:Math.abs(Math.floor(n.y)%2)===1?n.y=Math.ceil(n.y)-n.y:n.y=n.y-Math.floor(n.y);break}return this.flipY&&(n.y=1-n.y),n}set needsUpdate(n){n===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(n){n===!0&&this.pmremVersion++}}sr.DEFAULT_IMAGE=null,sr.DEFAULT_MAPPING=eh,sr.DEFAULT_ANISOTROPY=1;class or{constructor(n=0,o=0,l=0,u=1){or.prototype.isVector4=!0,this.x=n,this.y=o,this.z=l,this.w=u}get width(){return this.z}set width(n){this.z=n}get height(){return this.w}set height(n){this.w=n}set(n,o,l,u){return this.x=n,this.y=o,this.z=l,this.w=u,this}setScalar(n){return this.x=n,this.y=n,this.z=n,this.w=n,this}setX(n){return this.x=n,this}setY(n){return this.y=n,this}setZ(n){return this.z=n,this}setW(n){return this.w=n,this}setComponent(n,o){switch(n){case 0:this.x=o;break;case 1:this.y=o;break;case 2:this.z=o;break;case 3:this.w=o;break;default:throw new Error("index is out of range: "+n)}return this}getComponent(n){switch(n){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: "+n)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(n){return this.x=n.x,this.y=n.y,this.z=n.z,this.w=n.w!==void 0?n.w:1,this}add(n){return this.x+=n.x,this.y+=n.y,this.z+=n.z,this.w+=n.w,this}addScalar(n){return this.x+=n,this.y+=n,this.z+=n,this.w+=n,this}addVectors(n,o){return this.x=n.x+o.x,this.y=n.y+o.y,this.z=n.z+o.z,this.w=n.w+o.w,this}addScaledVector(n,o){return this.x+=n.x*o,this.y+=n.y*o,this.z+=n.z*o,this.w+=n.w*o,this}sub(n){return this.x-=n.x,this.y-=n.y,this.z-=n.z,this.w-=n.w,this}subScalar(n){return this.x-=n,this.y-=n,this.z-=n,this.w-=n,this}subVectors(n,o){return this.x=n.x-o.x,this.y=n.y-o.y,this.z=n.z-o.z,this.w=n.w-o.w,this}multiply(n){return this.x*=n.x,this.y*=n.y,this.z*=n.z,this.w*=n.w,this}multiplyScalar(n){return this.x*=n,this.y*=n,this.z*=n,this.w*=n,this}applyMatrix4(n){const o=this.x,l=this.y,u=this.z,p=this.w,g=n.elements;return this.x=g[0]*o+g[4]*l+g[8]*u+g[12]*p,this.y=g[1]*o+g[5]*l+g[9]*u+g[13]*p,this.z=g[2]*o+g[6]*l+g[10]*u+g[14]*p,this.w=g[3]*o+g[7]*l+g[11]*u+g[15]*p,this}divide(n){return this.x/=n.x,this.y/=n.y,this.z/=n.z,this.w/=n.w,this}divideScalar(n){return this.multiplyScalar(1/n)}setAxisAngleFromQuaternion(n){this.w=2*Math.acos(n.w);const o=Math.sqrt(1-n.w*n.w);return o<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=n.x/o,this.y=n.y/o,this.z=n.z/o),this}setAxisAngleFromRotationMatrix(n){let o,l,u,p;const b=n.elements,S=b[0],A=b[4],R=b[8],N=b[1],L=b[5],I=b[9],B=b[2],Z=b[6],q=b[10];if(Math.abs(A-N)<.01&&Math.abs(R-B)<.01&&Math.abs(I-Z)<.01){if(Math.abs(A+N)<.1&&Math.abs(R+B)<.1&&Math.abs(I+Z)<.1&&Math.abs(S+L+q-3)<.1)return this.set(1,0,0,0),this;o=Math.PI;const te=(S+1)/2,he=(L+1)/2,Re=(q+1)/2,ke=(A+N)/4,We=(R+B)/4,ze=(I+Z)/4;return te>he&&te>Re?te<.01?(l=0,u=.707106781,p=.707106781):(l=Math.sqrt(te),u=ke/l,p=We/l):he>Re?he<.01?(l=.707106781,u=0,p=.707106781):(u=Math.sqrt(he),l=ke/u,p=ze/u):Re<.01?(l=.707106781,u=.707106781,p=0):(p=Math.sqrt(Re),l=We/p,u=ze/p),this.set(l,u,p,o),this}let ee=Math.sqrt((Z-I)*(Z-I)+(R-B)*(R-B)+(N-A)*(N-A));return Math.abs(ee)<.001&&(ee=1),this.x=(Z-I)/ee,this.y=(R-B)/ee,this.z=(N-A)/ee,this.w=Math.acos((S+L+q-1)/2),this}setFromMatrixPosition(n){const o=n.elements;return this.x=o[12],this.y=o[13],this.z=o[14],this.w=o[15],this}min(n){return this.x=Math.min(this.x,n.x),this.y=Math.min(this.y,n.y),this.z=Math.min(this.z,n.z),this.w=Math.min(this.w,n.w),this}max(n){return this.x=Math.max(this.x,n.x),this.y=Math.max(this.y,n.y),this.z=Math.max(this.z,n.z),this.w=Math.max(this.w,n.w),this}clamp(n,o){return this.x=an(this.x,n.x,o.x),this.y=an(this.y,n.y,o.y),this.z=an(this.z,n.z,o.z),this.w=an(this.w,n.w,o.w),this}clampScalar(n,o){return this.x=an(this.x,n,o),this.y=an(this.y,n,o),this.z=an(this.z,n,o),this.w=an(this.w,n,o),this}clampLength(n,o){const l=this.length();return this.divideScalar(l||1).multiplyScalar(an(l,n,o))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(n){return this.x*n.x+this.y*n.y+this.z*n.z+this.w*n.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)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(n){return this.normalize().multiplyScalar(n)}lerp(n,o){return this.x+=(n.x-this.x)*o,this.y+=(n.y-this.y)*o,this.z+=(n.z-this.z)*o,this.w+=(n.w-this.w)*o,this}lerpVectors(n,o,l){return this.x=n.x+(o.x-n.x)*l,this.y=n.y+(o.y-n.y)*l,this.z=n.z+(o.z-n.z)*l,this.w=n.w+(o.w-n.w)*l,this}equals(n){return n.x===this.x&&n.y===this.y&&n.z===this.z&&n.w===this.w}fromArray(n,o=0){return this.x=n[o],this.y=n[o+1],this.z=n[o+2],this.w=n[o+3],this}toArray(n=[],o=0){return n[o]=this.x,n[o+1]=this.y,n[o+2]=this.z,n[o+3]=this.w,n}fromBufferAttribute(n,o){return this.x=n.getX(o),this.y=n.getY(o),this.z=n.getZ(o),this.w=n.getW(o),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Fg extends ea{constructor(n=1,o=1,l={}){super(),l=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Yr,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},l),this.isRenderTarget=!0,this.width=n,this.height=o,this.depth=l.depth,this.scissor=new or(0,0,n,o),this.scissorTest=!1,this.viewport=new or(0,0,n,o);const u={width:n,height:o,depth:l.depth},p=new sr(u);this.textures=[];const g=l.count;for(let y=0;y<g;y++)this.textures[y]=p.clone(),this.textures[y].isRenderTargetTexture=!0,this.textures[y].renderTarget=this;this._setTextureOptions(l),this.depthBuffer=l.depthBuffer,this.stencilBuffer=l.stencilBuffer,this.resolveDepthBuffer=l.resolveDepthBuffer,this.resolveStencilBuffer=l.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=l.depthTexture,this.samples=l.samples,this.multiview=l.multiview}_setTextureOptions(n={}){const o={minFilter:Yr,generateMipmaps:!1,flipY:!1,internalFormat:null};n.mapping!==void 0&&(o.mapping=n.mapping),n.wrapS!==void 0&&(o.wrapS=n.wrapS),n.wrapT!==void 0&&(o.wrapT=n.wrapT),n.wrapR!==void 0&&(o.wrapR=n.wrapR),n.magFilter!==void 0&&(o.magFilter=n.magFilter),n.minFilter!==void 0&&(o.minFilter=n.minFilter),n.format!==void 0&&(o.format=n.format),n.type!==void 0&&(o.type=n.type),n.anisotropy!==void 0&&(o.anisotropy=n.anisotropy),n.colorSpace!==void 0&&(o.colorSpace=n.colorSpace),n.flipY!==void 0&&(o.flipY=n.flipY),n.generateMipmaps!==void 0&&(o.generateMipmaps=n.generateMipmaps),n.internalFormat!==void 0&&(o.internalFormat=n.internalFormat);for(let l=0;l<this.textures.length;l++)this.textures[l].setValues(o)}get texture(){return this.textures[0]}set texture(n){this.textures[0]=n}set depthTexture(n){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),n!==null&&(n.renderTarget=this),this._depthTexture=n}get depthTexture(){return this._depthTexture}setSize(n,o,l=1){if(this.width!==n||this.height!==o||this.depth!==l){this.width=n,this.height=o,this.depth=l;for(let u=0,p=this.textures.length;u<p;u++)this.textures[u].image.width=n,this.textures[u].image.height=o,this.textures[u].image.depth=l,this.textures[u].isData3DTexture!==!0&&(this.textures[u].isArrayTexture=this.textures[u].image.depth>1);this.dispose()}this.viewport.set(0,0,n,o),this.scissor.set(0,0,n,o)}clone(){return new this.constructor().copy(this)}copy(n){this.width=n.width,this.height=n.height,this.depth=n.depth,this.scissor.copy(n.scissor),this.scissorTest=n.scissorTest,this.viewport.copy(n.viewport),this.textures.length=0;for(let o=0,l=n.textures.length;o<l;o++){this.textures[o]=n.textures[o].clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;const u=Object.assign({},n.textures[o].image);this.textures[o].source=new Ua(u)}return this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,n.depthTexture!==null&&(this.depthTexture=n.depthTexture.clone()),this.samples=n.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Bg extends Fg{constructor(n=1,o=1,l={}){super(n,o,l),this.isWebGLRenderTarget=!0}}class Og extends sr{constructor(n=null,o=1,l=1,u=1){super(null),this.isDataArrayTexture=!0,this.image={data:n,width:o,height:l,depth:u},this.magFilter=ps,this.minFilter=ps,this.wrapR=Rs,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(n){this.layerUpdates.add(n)}clearLayerUpdates(){this.layerUpdates.clear()}}class lT extends null{constructor(n=1,o=1,l=1,u={}){super(n,o,u),this.isWebGLArrayRenderTarget=!0,this.depth=l,this.texture=new Og(null,n,o,l),this._setTextureOptions(u),this.texture.isRenderTargetTexture=!0}}class Sf extends sr{constructor(n=null,o=1,l=1,u=1){super(null),this.isData3DTexture=!0,this.image={data:n,width:o,height:l,depth:u},this.magFilter=ps,this.minFilter=ps,this.wrapR=Rs,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class uT extends null{constructor(n=1,o=1,l=1,u={}){super(n,o,u),this.isWebGL3DRenderTarget=!0,this.depth=l,this.texture=new Sf(null,n,o,l),this._setTextureOptions(u),this.texture.isRenderTargetTexture=!0}}class wr{constructor(n=new ie(1/0,1/0,1/0),o=new ie(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=n,this.max=o}set(n,o){return this.min.copy(n),this.max.copy(o),this}setFromArray(n){this.makeEmpty();for(let o=0,l=n.length;o<l;o+=3)this.expandByPoint(Ls.fromArray(n,o));return this}setFromBufferAttribute(n){this.makeEmpty();for(let o=0,l=n.count;o<l;o++)this.expandByPoint(Ls.fromBufferAttribute(n,o));return this}setFromPoints(n){this.makeEmpty();for(let o=0,l=n.length;o<l;o++)this.expandByPoint(n[o]);return this}setFromCenterAndSize(n,o){const l=Ls.copy(o).multiplyScalar(.5);return this.min.copy(n).sub(l),this.max.copy(n).add(l),this}setFromObject(n,o=!1){return this.makeEmpty(),this.expandByObject(n,o)}clone(){return new this.constructor().copy(this)}copy(n){return this.min.copy(n.min),this.max.copy(n.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(n){return this.isEmpty()?n.set(0,0,0):n.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(n){return this.isEmpty()?n.set(0,0,0):n.subVectors(this.max,this.min)}expandByPoint(n){return this.min.min(n),this.max.max(n),this}expandByVector(n){return this.min.sub(n),this.max.add(n),this}expandByScalar(n){return this.min.addScalar(-n),this.max.addScalar(n),this}expandByObject(n,o=!1){n.updateWorldMatrix(!1,!1);const l=n.geometry;if(l!==void 0){const p=l.getAttribute("position");if(o===!0&&p!==void 0&&n.isInstancedMesh!==!0)for(let g=0,y=p.count;g<y;g++)n.isMesh===!0?n.getVertexPosition(g,Ls):Ls.fromBufferAttribute(p,g),Ls.applyMatrix4(n.matrixWorld),this.expandByPoint(Ls);else n.boundingBox!==void 0?(n.boundingBox===null&&n.computeBoundingBox(),xh.copy(n.boundingBox)):(l.boundingBox===null&&l.computeBoundingBox(),xh.copy(l.boundingBox)),xh.applyMatrix4(n.matrixWorld),this.union(xh)}const u=n.children;for(let p=0,g=u.length;p<g;p++)this.expandByObject(u[p],o);return this}containsPoint(n){return n.x>=this.min.x&&n.x<=this.max.x&&n.y>=this.min.y&&n.y<=this.max.y&&n.z>=this.min.z&&n.z<=this.max.z}containsBox(n){return this.min.x<=n.min.x&&n.max.x<=this.max.x&&this.min.y<=n.min.y&&n.max.y<=this.max.y&&this.min.z<=n.min.z&&n.max.z<=this.max.z}getParameter(n,o){return o.set((n.x-this.min.x)/(this.max.x-this.min.x),(n.y-this.min.y)/(this.max.y-this.min.y),(n.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(n){return n.max.x>=this.min.x&&n.min.x<=this.max.x&&n.max.y>=this.min.y&&n.min.y<=this.max.y&&n.max.z>=this.min.z&&n.min.z<=this.max.z}intersectsSphere(n){return this.clampPoint(n.center,Ls),Ls.distanceToSquared(n.center)<=n.radius*n.radius}intersectsPlane(n){let o,l;return n.normal.x>0?(o=n.normal.x*this.min.x,l=n.normal.x*this.max.x):(o=n.normal.x*this.max.x,l=n.normal.x*this.min.x),n.normal.y>0?(o+=n.normal.y*this.min.y,l+=n.normal.y*this.max.y):(o+=n.normal.y*this.max.y,l+=n.normal.y*this.min.y),n.normal.z>0?(o+=n.normal.z*this.min.z,l+=n.normal.z*this.max.z):(o+=n.normal.z*this.max.z,l+=n.normal.z*this.min.z),o<=-n.constant&&l>=-n.constant}intersectsTriangle(n){if(this.isEmpty())return!1;this.getCenter(Bl),_h.subVectors(this.max,Bl),Dc.subVectors(n.a,Bl),Uc.subVectors(n.b,Bl),Fc.subVectors(n.c,Bl),ta.subVectors(Uc,Dc),na.subVectors(Fc,Uc),Fa.subVectors(Dc,Fc);let o=[0,-ta.z,ta.y,0,-na.z,na.y,0,-Fa.z,Fa.y,ta.z,0,-ta.x,na.z,0,-na.x,Fa.z,0,-Fa.x,-ta.y,ta.x,0,-na.y,na.x,0,-Fa.y,Fa.x,0];return!Tf(o,Dc,Uc,Fc,_h)||(o=[1,0,0,0,1,0,0,0,1],!Tf(o,Dc,Uc,Fc,_h))?!1:(yh.crossVectors(ta,na),o=[yh.x,yh.y,yh.z],Tf(o,Dc,Uc,Fc,_h))}clampPoint(n,o){return o.copy(n).clamp(this.min,this.max)}distanceToPoint(n){return this.clampPoint(n,Ls).distanceTo(n)}getBoundingSphere(n){return this.isEmpty()?n.makeEmpty():(this.getCenter(n.center),n.radius=this.getSize(Ls).length()*.5),n}intersect(n){return this.min.max(n.min),this.max.min(n.max),this.isEmpty()&&this.makeEmpty(),this}union(n){return this.min.min(n.min),this.max.max(n.max),this}applyMatrix4(n){return this.isEmpty()?this:(No[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(n),No[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(n),No[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(n),No[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(n),No[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(n),No[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(n),No[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(n),No[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(n),this.setFromPoints(No),this)}translate(n){return this.min.add(n),this.max.add(n),this}equals(n){return n.min.equals(this.min)&&n.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(n){return this.min.fromArray(n.min),this.max.fromArray(n.max),this}}const No=[new ie,new ie,new ie,new ie,new ie,new ie,new ie,new ie],Ls=new ie,xh=new wr,Dc=new ie,Uc=new ie,Fc=new ie,ta=new ie,na=new ie,Fa=new ie,Bl=new ie,_h=new ie,yh=new ie,Ba=new ie;function Tf(M,n,o,l,u){for(let p=0,g=M.length-3;p<=g;p+=3){Ba.fromArray(M,p);const y=u.x*Math.abs(Ba.x)+u.y*Math.abs(Ba.y)+u.z*Math.abs(Ba.z),b=n.dot(Ba),S=o.dot(Ba),A=l.dot(Ba);if(Math.max(-Math.max(b,S,A),Math.min(b,S,A))>y)return!1}return!0}const my=new wr,Ol=new ie,Mf=new ie;class xr{constructor(n=new ie,o=-1){this.isSphere=!0,this.center=n,this.radius=o}set(n,o){return this.center.copy(n),this.radius=o,this}setFromPoints(n,o){const l=this.center;o!==void 0?l.copy(o):my.setFromPoints(n).getCenter(l);let u=0;for(let p=0,g=n.length;p<g;p++)u=Math.max(u,l.distanceToSquared(n[p]));return this.radius=Math.sqrt(u),this}copy(n){return this.center.copy(n.center),this.radius=n.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(n){return n.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(n){return n.distanceTo(this.center)-this.radius}intersectsSphere(n){const o=this.radius+n.radius;return n.center.distanceToSquared(this.center)<=o*o}intersectsBox(n){return n.intersectsSphere(this)}intersectsPlane(n){return Math.abs(n.distanceToPoint(this.center))<=this.radius}clampPoint(n,o){const l=this.center.distanceToSquared(n);return o.copy(n),l>this.radius*this.radius&&(o.sub(this.center).normalize(),o.multiplyScalar(this.radius).add(this.center)),o}getBoundingBox(n){return this.isEmpty()?(n.makeEmpty(),n):(n.set(this.center,this.center),n.expandByScalar(this.radius),n)}applyMatrix4(n){return this.center.applyMatrix4(n),this.radius=this.radius*n.getMaxScaleOnAxis(),this}translate(n){return this.center.add(n),this}expandByPoint(n){if(this.isEmpty())return this.center.copy(n),this.radius=0,this;Ol.subVectors(n,this.center);const o=Ol.lengthSq();if(o>this.radius*this.radius){const l=Math.sqrt(o),u=(l-this.radius)*.5;this.center.addScaledVector(Ol,u/l),this.radius+=u}return this}union(n){return n.isEmpty()?this:this.isEmpty()?(this.copy(n),this):(this.center.equals(n.center)===!0?this.radius=Math.max(this.radius,n.radius):(Mf.subVectors(n.center,this.center).setLength(n.radius),this.expandByPoint(Ol.copy(n.center).add(Mf)),this.expandByPoint(Ol.copy(n.center).sub(Mf))),this)}equals(n){return n.center.equals(this.center)&&n.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(n){return this.radius=n.radius,this.center.fromArray(n.center),this}}const Po=new ie,wf=new ie,bh=new ie,ia=new ie,Af=new ie,vh=new ie,Ef=new ie;class Bc{constructor(n=new ie,o=new ie(0,0,-1)){this.origin=n,this.direction=o}set(n,o){return this.origin.copy(n),this.direction.copy(o),this}copy(n){return this.origin.copy(n.origin),this.direction.copy(n.direction),this}at(n,o){return o.copy(this.origin).addScaledVector(this.direction,n)}lookAt(n){return this.direction.copy(n).sub(this.origin).normalize(),this}recast(n){return this.origin.copy(this.at(n,Po)),this}closestPointToPoint(n,o){o.subVectors(n,this.origin);const l=o.dot(this.direction);return l<0?o.copy(this.origin):o.copy(this.origin).addScaledVector(this.direction,l)}distanceToPoint(n){return Math.sqrt(this.distanceSqToPoint(n))}distanceSqToPoint(n){const o=Po.subVectors(n,this.origin).dot(this.direction);return o<0?this.origin.distanceToSquared(n):(Po.copy(this.origin).addScaledVector(this.direction,o),Po.distanceToSquared(n))}distanceSqToSegment(n,o,l,u){wf.copy(n).add(o).multiplyScalar(.5),bh.copy(o).sub(n).normalize(),ia.copy(this.origin).sub(wf);const p=n.distanceTo(o)*.5,g=-this.direction.dot(bh),y=ia.dot(this.direction),b=-ia.dot(bh),S=ia.lengthSq(),A=Math.abs(1-g*g);let R,N,L,I;if(A>0)if(R=g*b-y,N=g*y-b,I=p*A,R>=0)if(N>=-I)if(N<=I){const B=1/A;R*=B,N*=B,L=R*(R+g*N+2*y)+N*(g*R+N+2*b)+S}else N=p,R=Math.max(0,-(g*N+y)),L=-R*R+N*(N+2*b)+S;else N=-p,R=Math.max(0,-(g*N+y)),L=-R*R+N*(N+2*b)+S;else N<=-I?(R=Math.max(0,-(-g*p+y)),N=R>0?-p:Math.min(Math.max(-p,-b),p),L=-R*R+N*(N+2*b)+S):N<=I?(R=0,N=Math.min(Math.max(-p,-b),p),L=N*(N+2*b)+S):(R=Math.max(0,-(g*p+y)),N=R>0?p:Math.min(Math.max(-p,-b),p),L=-R*R+N*(N+2*b)+S);else N=g>0?-p:p,R=Math.max(0,-(g*N+y)),L=-R*R+N*(N+2*b)+S;return l&&l.copy(this.origin).addScaledVector(this.direction,R),u&&u.copy(wf).addScaledVector(bh,N),L}intersectSphere(n,o){Po.subVectors(n.center,this.origin);const l=Po.dot(this.direction),u=Po.dot(Po)-l*l,p=n.radius*n.radius;if(u>p)return null;const g=Math.sqrt(p-u),y=l-g,b=l+g;return b<0?null:y<0?this.at(b,o):this.at(y,o)}intersectsSphere(n){return n.radius<0?!1:this.distanceSqToPoint(n.center)<=n.radius*n.radius}distanceToPlane(n){const o=n.normal.dot(this.direction);if(o===0)return n.distanceToPoint(this.origin)===0?0:null;const l=-(this.origin.dot(n.normal)+n.constant)/o;return l>=0?l:null}intersectPlane(n,o){const l=this.distanceToPlane(n);return l===null?null:this.at(l,o)}intersectsPlane(n){const o=n.distanceToPoint(this.origin);return o===0||n.normal.dot(this.direction)*o<0}intersectBox(n,o){let l,u,p,g,y,b;const S=1/this.direction.x,A=1/this.direction.y,R=1/this.direction.z,N=this.origin;return S>=0?(l=(n.min.x-N.x)*S,u=(n.max.x-N.x)*S):(l=(n.max.x-N.x)*S,u=(n.min.x-N.x)*S),A>=0?(p=(n.min.y-N.y)*A,g=(n.max.y-N.y)*A):(p=(n.max.y-N.y)*A,g=(n.min.y-N.y)*A),l>g||p>u||((p>l||isNaN(l))&&(l=p),(g<u||isNaN(u))&&(u=g),R>=0?(y=(n.min.z-N.z)*R,b=(n.max.z-N.z)*R):(y=(n.max.z-N.z)*R,b=(n.min.z-N.z)*R),l>b||y>u)||((y>l||l!==l)&&(l=y),(b<u||u!==u)&&(u=b),u<0)?null:this.at(l>=0?l:u,o)}intersectsBox(n){return this.intersectBox(n,Po)!==null}intersectTriangle(n,o,l,u,p){Af.subVectors(o,n),vh.subVectors(l,n),Ef.crossVectors(Af,vh);let g=this.direction.dot(Ef),y;if(g>0){if(u)return null;y=1}else if(g<0)y=-1,g=-g;else return null;ia.subVectors(this.origin,n);const b=y*this.direction.dot(vh.crossVectors(ia,vh));if(b<0)return null;const S=y*this.direction.dot(Af.cross(ia));if(S<0||b+S>g)return null;const A=-y*ia.dot(Ef);return A<0?null:this.at(A/g,p)}applyMatrix4(n){return this.origin.applyMatrix4(n),this.direction.transformDirection(n),this}equals(n){return n.origin.equals(this.origin)&&n.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Ln{constructor(n,o,l,u,p,g,y,b,S,A,R,N,L,I,B,Z){Ln.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],n!==void 0&&this.set(n,o,l,u,p,g,y,b,S,A,R,N,L,I,B,Z)}set(n,o,l,u,p,g,y,b,S,A,R,N,L,I,B,Z){const q=this.elements;return q[0]=n,q[4]=o,q[8]=l,q[12]=u,q[1]=p,q[5]=g,q[9]=y,q[13]=b,q[2]=S,q[6]=A,q[10]=R,q[14]=N,q[3]=L,q[7]=I,q[11]=B,q[15]=Z,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 Ln().fromArray(this.elements)}copy(n){const o=this.elements,l=n.elements;return o[0]=l[0],o[1]=l[1],o[2]=l[2],o[3]=l[3],o[4]=l[4],o[5]=l[5],o[6]=l[6],o[7]=l[7],o[8]=l[8],o[9]=l[9],o[10]=l[10],o[11]=l[11],o[12]=l[12],o[13]=l[13],o[14]=l[14],o[15]=l[15],this}copyPosition(n){const o=this.elements,l=n.elements;return o[12]=l[12],o[13]=l[13],o[14]=l[14],this}setFromMatrix3(n){const o=n.elements;return this.set(o[0],o[3],o[6],0,o[1],o[4],o[7],0,o[2],o[5],o[8],0,0,0,0,1),this}extractBasis(n,o,l){return n.setFromMatrixColumn(this,0),o.setFromMatrixColumn(this,1),l.setFromMatrixColumn(this,2),this}makeBasis(n,o,l){return this.set(n.x,o.x,l.x,0,n.y,o.y,l.y,0,n.z,o.z,l.z,0,0,0,0,1),this}extractRotation(n){const o=this.elements,l=n.elements,u=1/Oc.setFromMatrixColumn(n,0).length(),p=1/Oc.setFromMatrixColumn(n,1).length(),g=1/Oc.setFromMatrixColumn(n,2).length();return o[0]=l[0]*u,o[1]=l[1]*u,o[2]=l[2]*u,o[3]=0,o[4]=l[4]*p,o[5]=l[5]*p,o[6]=l[6]*p,o[7]=0,o[8]=l[8]*g,o[9]=l[9]*g,o[10]=l[10]*g,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,this}makeRotationFromEuler(n){const o=this.elements,l=n.x,u=n.y,p=n.z,g=Math.cos(l),y=Math.sin(l),b=Math.cos(u),S=Math.sin(u),A=Math.cos(p),R=Math.sin(p);if(n.order==="XYZ"){const N=g*A,L=g*R,I=y*A,B=y*R;o[0]=b*A,o[4]=-b*R,o[8]=S,o[1]=L+I*S,o[5]=N-B*S,o[9]=-y*b,o[2]=B-N*S,o[6]=I+L*S,o[10]=g*b}else if(n.order==="YXZ"){const N=b*A,L=b*R,I=S*A,B=S*R;o[0]=N+B*y,o[4]=I*y-L,o[8]=g*S,o[1]=g*R,o[5]=g*A,o[9]=-y,o[2]=L*y-I,o[6]=B+N*y,o[10]=g*b}else if(n.order==="ZXY"){const N=b*A,L=b*R,I=S*A,B=S*R;o[0]=N-B*y,o[4]=-g*R,o[8]=I+L*y,o[1]=L+I*y,o[5]=g*A,o[9]=B-N*y,o[2]=-g*S,o[6]=y,o[10]=g*b}else if(n.order==="ZYX"){const N=g*A,L=g*R,I=y*A,B=y*R;o[0]=b*A,o[4]=I*S-L,o[8]=N*S+B,o[1]=b*R,o[5]=B*S+N,o[9]=L*S-I,o[2]=-S,o[6]=y*b,o[10]=g*b}else if(n.order==="YZX"){const N=g*b,L=g*S,I=y*b,B=y*S;o[0]=b*A,o[4]=B-N*R,o[8]=I*R+L,o[1]=R,o[5]=g*A,o[9]=-y*A,o[2]=-S*A,o[6]=L*R+I,o[10]=N-B*R}else if(n.order==="XZY"){const N=g*b,L=g*S,I=y*b,B=y*S;o[0]=b*A,o[4]=-R,o[8]=S*A,o[1]=N*R+B,o[5]=g*A,o[9]=L*R-I,o[2]=I*R-L,o[6]=y*A,o[10]=B*R+N}return o[3]=0,o[7]=0,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,this}makeRotationFromQuaternion(n){return this.compose(gy,n,xy)}lookAt(n,o,l){const u=this.elements;return ns.subVectors(n,o),ns.lengthSq()===0&&(ns.z=1),ns.normalize(),ra.crossVectors(l,ns),ra.lengthSq()===0&&(Math.abs(l.z)===1?ns.x+=1e-4:ns.z+=1e-4,ns.normalize(),ra.crossVectors(l,ns)),ra.normalize(),Sh.crossVectors(ns,ra),u[0]=ra.x,u[4]=Sh.x,u[8]=ns.x,u[1]=ra.y,u[5]=Sh.y,u[9]=ns.y,u[2]=ra.z,u[6]=Sh.z,u[10]=ns.z,this}multiply(n){return this.multiplyMatrices(this,n)}premultiply(n){return this.multiplyMatrices(n,this)}multiplyMatrices(n,o){const l=n.elements,u=o.elements,p=this.elements,g=l[0],y=l[4],b=l[8],S=l[12],A=l[1],R=l[5],N=l[9],L=l[13],I=l[2],B=l[6],Z=l[10],q=l[14],ee=l[3],te=l[7],he=l[11],Re=l[15],ke=u[0],We=u[4],ze=u[8],lt=u[12],mt=u[1],Zt=u[5],Bn=u[9],Hn=u[13],pi=u[2],ni=u[6],ur=u[10],vr=u[14],vs=u[3],zi=u[7],Qi=u[11],Di=u[15];return p[0]=g*ke+y*mt+b*pi+S*vs,p[4]=g*We+y*Zt+b*ni+S*zi,p[8]=g*ze+y*Bn+b*ur+S*Qi,p[12]=g*lt+y*Hn+b*vr+S*Di,p[1]=A*ke+R*mt+N*pi+L*vs,p[5]=A*We+R*Zt+N*ni+L*zi,p[9]=A*ze+R*Bn+N*ur+L*Qi,p[13]=A*lt+R*Hn+N*vr+L*Di,p[2]=I*ke+B*mt+Z*pi+q*vs,p[6]=I*We+B*Zt+Z*ni+q*zi,p[10]=I*ze+B*Bn+Z*ur+q*Qi,p[14]=I*lt+B*Hn+Z*vr+q*Di,p[3]=ee*ke+te*mt+he*pi+Re*vs,p[7]=ee*We+te*Zt+he*ni+Re*zi,p[11]=ee*ze+te*Bn+he*ur+Re*Qi,p[15]=ee*lt+te*Hn+he*vr+Re*Di,this}multiplyScalar(n){const o=this.elements;return o[0]*=n,o[4]*=n,o[8]*=n,o[12]*=n,o[1]*=n,o[5]*=n,o[9]*=n,o[13]*=n,o[2]*=n,o[6]*=n,o[10]*=n,o[14]*=n,o[3]*=n,o[7]*=n,o[11]*=n,o[15]*=n,this}determinant(){const n=this.elements,o=n[0],l=n[4],u=n[8],p=n[12],g=n[1],y=n[5],b=n[9],S=n[13],A=n[2],R=n[6],N=n[10],L=n[14],I=n[3],B=n[7],Z=n[11],q=n[15];return I*(+p*b*R-u*S*R-p*y*N+l*S*N+u*y*L-l*b*L)+B*(+o*b*L-o*S*N+p*g*N-u*g*L+u*S*A-p*b*A)+Z*(+o*S*R-o*y*L-p*g*R+l*g*L+p*y*A-l*S*A)+q*(-u*y*A-o*b*R+o*y*N+u*g*R-l*g*N+l*b*A)}transpose(){const n=this.elements;let o;return o=n[1],n[1]=n[4],n[4]=o,o=n[2],n[2]=n[8],n[8]=o,o=n[6],n[6]=n[9],n[9]=o,o=n[3],n[3]=n[12],n[12]=o,o=n[7],n[7]=n[13],n[13]=o,o=n[11],n[11]=n[14],n[14]=o,this}setPosition(n,o,l){const u=this.elements;return n.isVector3?(u[12]=n.x,u[13]=n.y,u[14]=n.z):(u[12]=n,u[13]=o,u[14]=l),this}invert(){const n=this.elements,o=n[0],l=n[1],u=n[2],p=n[3],g=n[4],y=n[5],b=n[6],S=n[7],A=n[8],R=n[9],N=n[10],L=n[11],I=n[12],B=n[13],Z=n[14],q=n[15],ee=R*Z*S-B*N*S+B*b*L-y*Z*L-R*b*q+y*N*q,te=I*N*S-A*Z*S-I*b*L+g*Z*L+A*b*q-g*N*q,he=A*B*S-I*R*S+I*y*L-g*B*L-A*y*q+g*R*q,Re=I*R*b-A*B*b-I*y*N+g*B*N+A*y*Z-g*R*Z,ke=o*ee+l*te+u*he+p*Re;if(ke===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const We=1/ke;return n[0]=ee*We,n[1]=(B*N*p-R*Z*p-B*u*L+l*Z*L+R*u*q-l*N*q)*We,n[2]=(y*Z*p-B*b*p+B*u*S-l*Z*S-y*u*q+l*b*q)*We,n[3]=(R*b*p-y*N*p-R*u*S+l*N*S+y*u*L-l*b*L)*We,n[4]=te*We,n[5]=(A*Z*p-I*N*p+I*u*L-o*Z*L-A*u*q+o*N*q)*We,n[6]=(I*b*p-g*Z*p-I*u*S+o*Z*S+g*u*q-o*b*q)*We,n[7]=(g*N*p-A*b*p+A*u*S-o*N*S-g*u*L+o*b*L)*We,n[8]=he*We,n[9]=(I*R*p-A*B*p-I*l*L+o*B*L+A*l*q-o*R*q)*We,n[10]=(g*B*p-I*y*p+I*l*S-o*B*S-g*l*q+o*y*q)*We,n[11]=(A*y*p-g*R*p-A*l*S+o*R*S+g*l*L-o*y*L)*We,n[12]=Re*We,n[13]=(A*B*u-I*R*u+I*l*N-o*B*N-A*l*Z+o*R*Z)*We,n[14]=(I*y*u-g*B*u-I*l*b+o*B*b+g*l*Z-o*y*Z)*We,n[15]=(g*R*u-A*y*u+A*l*b-o*R*b-g*l*N+o*y*N)*We,this}scale(n){const o=this.elements,l=n.x,u=n.y,p=n.z;return o[0]*=l,o[4]*=u,o[8]*=p,o[1]*=l,o[5]*=u,o[9]*=p,o[2]*=l,o[6]*=u,o[10]*=p,o[3]*=l,o[7]*=u,o[11]*=p,this}getMaxScaleOnAxis(){const n=this.elements,o=n[0]*n[0]+n[1]*n[1]+n[2]*n[2],l=n[4]*n[4]+n[5]*n[5]+n[6]*n[6],u=n[8]*n[8]+n[9]*n[9]+n[10]*n[10];return Math.sqrt(Math.max(o,l,u))}makeTranslation(n,o,l){return n.isVector3?this.set(1,0,0,n.x,0,1,0,n.y,0,0,1,n.z,0,0,0,1):this.set(1,0,0,n,0,1,0,o,0,0,1,l,0,0,0,1),this}makeRotationX(n){const o=Math.cos(n),l=Math.sin(n);return this.set(1,0,0,0,0,o,-l,0,0,l,o,0,0,0,0,1),this}makeRotationY(n){const o=Math.cos(n),l=Math.sin(n);return this.set(o,0,l,0,0,1,0,0,-l,0,o,0,0,0,0,1),this}makeRotationZ(n){const o=Math.cos(n),l=Math.sin(n);return this.set(o,-l,0,0,l,o,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(n,o){const l=Math.cos(o),u=Math.sin(o),p=1-l,g=n.x,y=n.y,b=n.z,S=p*g,A=p*y;return this.set(S*g+l,S*y-u*b,S*b+u*y,0,S*y+u*b,A*y+l,A*b-u*g,0,S*b-u*y,A*b+u*g,p*b*b+l,0,0,0,0,1),this}makeScale(n,o,l){return this.set(n,0,0,0,0,o,0,0,0,0,l,0,0,0,0,1),this}makeShear(n,o,l,u,p,g){return this.set(1,l,p,0,n,1,g,0,o,u,1,0,0,0,0,1),this}compose(n,o,l){const u=this.elements,p=o._x,g=o._y,y=o._z,b=o._w,S=p+p,A=g+g,R=y+y,N=p*S,L=p*A,I=p*R,B=g*A,Z=g*R,q=y*R,ee=b*S,te=b*A,he=b*R,Re=l.x,ke=l.y,We=l.z;return u[0]=(1-(B+q))*Re,u[1]=(L+he)*Re,u[2]=(I-te)*Re,u[3]=0,u[4]=(L-he)*ke,u[5]=(1-(N+q))*ke,u[6]=(Z+ee)*ke,u[7]=0,u[8]=(I+te)*We,u[9]=(Z-ee)*We,u[10]=(1-(N+B))*We,u[11]=0,u[12]=n.x,u[13]=n.y,u[14]=n.z,u[15]=1,this}decompose(n,o,l){const u=this.elements;let p=Oc.set(u[0],u[1],u[2]).length();const g=Oc.set(u[4],u[5],u[6]).length(),y=Oc.set(u[8],u[9],u[10]).length();this.determinant()<0&&(p=-p),n.x=u[12],n.y=u[13],n.z=u[14],Is.copy(this);const S=1/p,A=1/g,R=1/y;return Is.elements[0]*=S,Is.elements[1]*=S,Is.elements[2]*=S,Is.elements[4]*=A,Is.elements[5]*=A,Is.elements[6]*=A,Is.elements[8]*=R,Is.elements[9]*=R,Is.elements[10]*=R,o.setFromRotationMatrix(Is),l.x=p,l.y=g,l.z=y,this}makePerspective(n,o,l,u,p,g,y=Mr,b=!1){const S=this.elements,A=2*p/(o-n),R=2*p/(l-u),N=(o+n)/(o-n),L=(l+u)/(l-u);let I,B;if(b)I=p/(g-p),B=g*p/(g-p);else if(y===Mr)I=-(g+p)/(g-p),B=-2*g*p/(g-p);else if(y===Ia)I=-g/(g-p),B=-g*p/(g-p);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+y);return S[0]=A,S[4]=0,S[8]=N,S[12]=0,S[1]=0,S[5]=R,S[9]=L,S[13]=0,S[2]=0,S[6]=0,S[10]=I,S[14]=B,S[3]=0,S[7]=0,S[11]=-1,S[15]=0,this}makeOrthographic(n,o,l,u,p,g,y=Mr,b=!1){const S=this.elements,A=2/(o-n),R=2/(l-u),N=-(o+n)/(o-n),L=-(l+u)/(l-u);let I,B;if(b)I=1/(g-p),B=g/(g-p);else if(y===Mr)I=-2/(g-p),B=-(g+p)/(g-p);else if(y===Ia)I=-1/(g-p),B=-p/(g-p);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+y);return S[0]=A,S[4]=0,S[8]=0,S[12]=N,S[1]=0,S[5]=R,S[9]=0,S[13]=L,S[2]=0,S[6]=0,S[10]=I,S[14]=B,S[3]=0,S[7]=0,S[11]=0,S[15]=1,this}equals(n){const o=this.elements,l=n.elements;for(let u=0;u<16;u++)if(o[u]!==l[u])return!1;return!0}fromArray(n,o=0){for(let l=0;l<16;l++)this.elements[l]=n[l+o];return this}toArray(n=[],o=0){const l=this.elements;return n[o]=l[0],n[o+1]=l[1],n[o+2]=l[2],n[o+3]=l[3],n[o+4]=l[4],n[o+5]=l[5],n[o+6]=l[6],n[o+7]=l[7],n[o+8]=l[8],n[o+9]=l[9],n[o+10]=l[10],n[o+11]=l[11],n[o+12]=l[12],n[o+13]=l[13],n[o+14]=l[14],n[o+15]=l[15],n}}const Oc=new ie,Is=new Ln,gy=new ie(0,0,0),xy=new ie(1,1,1),ra=new ie,Sh=new ie,ns=new ie,kg=new Ln,Vg=new Hr;class Ds{constructor(n=0,o=0,l=0,u=Ds.DEFAULT_ORDER){this.isEuler=!0,this._x=n,this._y=o,this._z=l,this._order=u}get x(){return this._x}set x(n){this._x=n,this._onChangeCallback()}get y(){return this._y}set y(n){this._y=n,this._onChangeCallback()}get z(){return this._z}set z(n){this._z=n,this._onChangeCallback()}get order(){return this._order}set order(n){this._order=n,this._onChangeCallback()}set(n,o,l,u=this._order){return this._x=n,this._y=o,this._z=l,this._order=u,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(n){return this._x=n._x,this._y=n._y,this._z=n._z,this._order=n._order,this._onChangeCallback(),this}setFromRotationMatrix(n,o=this._order,l=!0){const u=n.elements,p=u[0],g=u[4],y=u[8],b=u[1],S=u[5],A=u[9],R=u[2],N=u[6],L=u[10];switch(o){case"XYZ":this._y=Math.asin(an(y,-1,1)),Math.abs(y)<.9999999?(this._x=Math.atan2(-A,L),this._z=Math.atan2(-g,p)):(this._x=Math.atan2(N,S),this._z=0);break;case"YXZ":this._x=Math.asin(-an(A,-1,1)),Math.abs(A)<.9999999?(this._y=Math.atan2(y,L),this._z=Math.atan2(b,S)):(this._y=Math.atan2(-R,p),this._z=0);break;case"ZXY":this._x=Math.asin(an(N,-1,1)),Math.abs(N)<.9999999?(this._y=Math.atan2(-R,L),this._z=Math.atan2(-g,S)):(this._y=0,this._z=Math.atan2(b,p));break;case"ZYX":this._y=Math.asin(-an(R,-1,1)),Math.abs(R)<.9999999?(this._x=Math.atan2(N,L),this._z=Math.atan2(b,p)):(this._x=0,this._z=Math.atan2(-g,S));break;case"YZX":this._z=Math.asin(an(b,-1,1)),Math.abs(b)<.9999999?(this._x=Math.atan2(-A,S),this._y=Math.atan2(-R,p)):(this._x=0,this._y=Math.atan2(y,L));break;case"XZY":this._z=Math.asin(-an(g,-1,1)),Math.abs(g)<.9999999?(this._x=Math.atan2(N,S),this._y=Math.atan2(y,p)):(this._x=Math.atan2(-A,L),this._y=0);break;default:dn("Euler: .setFromRotationMatrix() encountered an unknown order: "+o)}return this._order=o,l===!0&&this._onChangeCallback(),this}setFromQuaternion(n,o,l){return kg.makeRotationFromQuaternion(n),this.setFromRotationMatrix(kg,o,l)}setFromVector3(n,o=this._order){return this.set(n.x,n.y,n.z,o)}reorder(n){return Vg.setFromEuler(this),this.setFromQuaternion(Vg,n)}equals(n){return n._x===this._x&&n._y===this._y&&n._z===this._z&&n._order===this._order}fromArray(n){return this._x=n[0],this._y=n[1],this._z=n[2],n[3]!==void 0&&(this._order=n[3]),this._onChangeCallback(),this}toArray(n=[],o=0){return n[o]=this._x,n[o+1]=this._y,n[o+2]=this._z,n[o+3]=this._order,n}_onChange(n){return this._onChangeCallback=n,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Ds.DEFAULT_ORDER="XYZ";class Cf{constructor(){this.mask=1}set(n){this.mask=(1<<n|0)>>>0}enable(n){this.mask|=1<<n|0}enableAll(){this.mask=-1}toggle(n){this.mask^=1<<n|0}disable(n){this.mask&=~(1<<n|0)}disableAll(){this.mask=0}test(n){return(this.mask&n.mask)!==0}isEnabled(n){return(this.mask&(1<<n|0))!==0}}let _y=0;const zg=new ie,kc=new Hr,Lo=new Ln,Th=new ie,kl=new ie,yy=new ie,by=new Hr,Gg=new ie(1,0,0),Wg=new ie(0,1,0),Hg=new ie(0,0,1),$g={type:"added"},vy={type:"removed"},Vc={type:"childadded",child:null},Rf={type:"childremoved",child:null};class Ri extends ea{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:_y++}),this.uuid=gr(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Ri.DEFAULT_UP.clone();const n=new ie,o=new Ds,l=new Hr,u=new ie(1,1,1);function p(){l.setFromEuler(o,!1)}function g(){o.setFromQuaternion(l,void 0,!1)}o._onChange(p),l._onChange(g),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:n},rotation:{configurable:!0,enumerable:!0,value:o},quaternion:{configurable:!0,enumerable:!0,value:l},scale:{configurable:!0,enumerable:!0,value:u},modelViewMatrix:{value:new Ln},normalMatrix:{value:new Ps}}),this.matrix=new Ln,this.matrixWorld=new Ln,this.matrixAutoUpdate=Ri.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Ri.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Cf,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(n){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(n),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(n){return this.quaternion.premultiply(n),this}setRotationFromAxisAngle(n,o){this.quaternion.setFromAxisAngle(n,o)}setRotationFromEuler(n){this.quaternion.setFromEuler(n,!0)}setRotationFromMatrix(n){this.quaternion.setFromRotationMatrix(n)}setRotationFromQuaternion(n){this.quaternion.copy(n)}rotateOnAxis(n,o){return kc.setFromAxisAngle(n,o),this.quaternion.multiply(kc),this}rotateOnWorldAxis(n,o){return kc.setFromAxisAngle(n,o),this.quaternion.premultiply(kc),this}rotateX(n){return this.rotateOnAxis(Gg,n)}rotateY(n){return this.rotateOnAxis(Wg,n)}rotateZ(n){return this.rotateOnAxis(Hg,n)}translateOnAxis(n,o){return zg.copy(n).applyQuaternion(this.quaternion),this.position.add(zg.multiplyScalar(o)),this}translateX(n){return this.translateOnAxis(Gg,n)}translateY(n){return this.translateOnAxis(Wg,n)}translateZ(n){return this.translateOnAxis(Hg,n)}localToWorld(n){return this.updateWorldMatrix(!0,!1),n.applyMatrix4(this.matrixWorld)}worldToLocal(n){return this.updateWorldMatrix(!0,!1),n.applyMatrix4(Lo.copy(this.matrixWorld).invert())}lookAt(n,o,l){n.isVector3?Th.copy(n):Th.set(n,o,l);const u=this.parent;this.updateWorldMatrix(!0,!1),kl.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Lo.lookAt(kl,Th,this.up):Lo.lookAt(Th,kl,this.up),this.quaternion.setFromRotationMatrix(Lo),u&&(Lo.extractRotation(u.matrixWorld),kc.setFromRotationMatrix(Lo),this.quaternion.premultiply(kc.invert()))}add(n){if(arguments.length>1){for(let o=0;o<arguments.length;o++)this.add(arguments[o]);return this}return n===this?(Yn("Object3D.add: object can't be added as a child of itself.",n),this):(n&&n.isObject3D?(n.removeFromParent(),n.parent=this,this.children.push(n),n.dispatchEvent($g),Vc.child=n,this.dispatchEvent(Vc),Vc.child=null):Yn("Object3D.add: object not an instance of THREE.Object3D.",n),this)}remove(n){if(arguments.length>1){for(let l=0;l<arguments.length;l++)this.remove(arguments[l]);return this}const o=this.children.indexOf(n);return o!==-1&&(n.parent=null,this.children.splice(o,1),n.dispatchEvent(vy),Rf.child=n,this.dispatchEvent(Rf),Rf.child=null),this}removeFromParent(){const n=this.parent;return n!==null&&n.remove(this),this}clear(){return this.remove(...this.children)}attach(n){return this.updateWorldMatrix(!0,!1),Lo.copy(this.matrixWorld).invert(),n.parent!==null&&(n.parent.updateWorldMatrix(!0,!1),Lo.multiply(n.parent.matrixWorld)),n.applyMatrix4(Lo),n.removeFromParent(),n.parent=this,this.children.push(n),n.updateWorldMatrix(!1,!0),n.dispatchEvent($g),Vc.child=n,this.dispatchEvent(Vc),Vc.child=null,this}getObjectById(n){return this.getObjectByProperty("id",n)}getObjectByName(n){return this.getObjectByProperty("name",n)}getObjectByProperty(n,o){if(this[n]===o)return this;for(let l=0,u=this.children.length;l<u;l++){const g=this.children[l].getObjectByProperty(n,o);if(g!==void 0)return g}}getObjectsByProperty(n,o,l=[]){this[n]===o&&l.push(this);const u=this.children;for(let p=0,g=u.length;p<g;p++)u[p].getObjectsByProperty(n,o,l);return l}getWorldPosition(n){return this.updateWorldMatrix(!0,!1),n.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(n){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(kl,n,yy),n}getWorldScale(n){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(kl,by,n),n}getWorldDirection(n){this.updateWorldMatrix(!0,!1);const o=this.matrixWorld.elements;return n.set(o[8],o[9],o[10]).normalize()}raycast(){}traverse(n){n(this);const o=this.children;for(let l=0,u=o.length;l<u;l++)o[l].traverse(n)}traverseVisible(n){if(this.visible===!1)return;n(this);const o=this.children;for(let l=0,u=o.length;l<u;l++)o[l].traverseVisible(n)}traverseAncestors(n){const o=this.parent;o!==null&&(n(o),o.traverseAncestors(n))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(n){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0);const o=this.children;for(let l=0,u=o.length;l<u;l++)o[l].updateMatrixWorld(n)}updateWorldMatrix(n,o){const l=this.parent;if(n===!0&&l!==null&&l.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),o===!0){const u=this.children;for(let p=0,g=u.length;p<g;p++)u[p].updateWorldMatrix(!1,!0)}}toJSON(n){const o=n===void 0||typeof n=="string",l={};o&&(n={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},l.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const u={};u.uuid=this.uuid,u.type=this.type,this.name!==""&&(u.name=this.name),this.castShadow===!0&&(u.castShadow=!0),this.receiveShadow===!0&&(u.receiveShadow=!0),this.visible===!1&&(u.visible=!1),this.frustumCulled===!1&&(u.frustumCulled=!1),this.renderOrder!==0&&(u.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(u.userData=this.userData),u.layers=this.layers.mask,u.matrix=this.matrix.toArray(),u.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(u.matrixAutoUpdate=!1),this.isInstancedMesh&&(u.type="InstancedMesh",u.count=this.count,u.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(u.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(u.type="BatchedMesh",u.perObjectFrustumCulled=this.perObjectFrustumCulled,u.sortObjects=this.sortObjects,u.drawRanges=this._drawRanges,u.reservedRanges=this._reservedRanges,u.geometryInfo=this._geometryInfo.map(y=>To(rr({},y),{boundingBox:y.boundingBox?y.boundingBox.toJSON():void 0,boundingSphere:y.boundingSphere?y.boundingSphere.toJSON():void 0})),u.instanceInfo=this._instanceInfo.map(y=>rr({},y)),u.availableInstanceIds=this._availableInstanceIds.slice(),u.availableGeometryIds=this._availableGeometryIds.slice(),u.nextIndexStart=this._nextIndexStart,u.nextVertexStart=this._nextVertexStart,u.geometryCount=this._geometryCount,u.maxInstanceCount=this._maxInstanceCount,u.maxVertexCount=this._maxVertexCount,u.maxIndexCount=this._maxIndexCount,u.geometryInitialized=this._geometryInitialized,u.matricesTexture=this._matricesTexture.toJSON(n),u.indirectTexture=this._indirectTexture.toJSON(n),this._colorsTexture!==null&&(u.colorsTexture=this._colorsTexture.toJSON(n)),this.boundingSphere!==null&&(u.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(u.boundingBox=this.boundingBox.toJSON()));function p(y,b){return y[b.uuid]===void 0&&(y[b.uuid]=b.toJSON(n)),b.uuid}if(this.isScene)this.background&&(this.background.isColor?u.background=this.background.toJSON():this.background.isTexture&&(u.background=this.background.toJSON(n).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(u.environment=this.environment.toJSON(n).uuid);else if(this.isMesh||this.isLine||this.isPoints){u.geometry=p(n.geometries,this.geometry);const y=this.geometry.parameters;if(y!==void 0&&y.shapes!==void 0){const b=y.shapes;if(Array.isArray(b))for(let S=0,A=b.length;S<A;S++){const R=b[S];p(n.shapes,R)}else p(n.shapes,b)}}if(this.isSkinnedMesh&&(u.bindMode=this.bindMode,u.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(p(n.skeletons,this.skeleton),u.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const y=[];for(let b=0,S=this.material.length;b<S;b++)y.push(p(n.materials,this.material[b]));u.material=y}else u.material=p(n.materials,this.material);if(this.children.length>0){u.children=[];for(let y=0;y<this.children.length;y++)u.children.push(this.children[y].toJSON(n).object)}if(this.animations.length>0){u.animations=[];for(let y=0;y<this.animations.length;y++){const b=this.animations[y];u.animations.push(p(n.animations,b))}}if(o){const y=g(n.geometries),b=g(n.materials),S=g(n.textures),A=g(n.images),R=g(n.shapes),N=g(n.skeletons),L=g(n.animations),I=g(n.nodes);y.length>0&&(l.geometries=y),b.length>0&&(l.materials=b),S.length>0&&(l.textures=S),A.length>0&&(l.images=A),R.length>0&&(l.shapes=R),N.length>0&&(l.skeletons=N),L.length>0&&(l.animations=L),I.length>0&&(l.nodes=I)}return l.object=u,l;function g(y){const b=[];for(const S in y){const A=y[S];delete A.metadata,b.push(A)}return b}}clone(n){return new this.constructor().copy(this,n)}copy(n,o=!0){if(this.name=n.name,this.up.copy(n.up),this.position.copy(n.position),this.rotation.order=n.rotation.order,this.quaternion.copy(n.quaternion),this.scale.copy(n.scale),this.matrix.copy(n.matrix),this.matrixWorld.copy(n.matrixWorld),this.matrixAutoUpdate=n.matrixAutoUpdate,this.matrixWorldAutoUpdate=n.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=n.matrixWorldNeedsUpdate,this.layers.mask=n.layers.mask,this.visible=n.visible,this.castShadow=n.castShadow,this.receiveShadow=n.receiveShadow,this.frustumCulled=n.frustumCulled,this.renderOrder=n.renderOrder,this.animations=n.animations.slice(),this.userData=JSON.parse(JSON.stringify(n.userData)),o===!0)for(let l=0;l<n.children.length;l++){const u=n.children[l];this.add(u.clone())}return this}}Ri.DEFAULT_UP=new ie(0,1,0),Ri.DEFAULT_MATRIX_AUTO_UPDATE=!0,Ri.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const Us=new ie,Io=new ie,Nf=new ie,Do=new ie,zc=new ie,Gc=new ie,jg=new ie,Pf=new ie,Lf=new ie,If=new ie,Df=new or,Uf=new or,Ff=new or;class is{constructor(n=new ie,o=new ie,l=new ie){this.a=n,this.b=o,this.c=l}static getNormal(n,o,l,u){u.subVectors(l,o),Us.subVectors(n,o),u.cross(Us);const p=u.lengthSq();return p>0?u.multiplyScalar(1/Math.sqrt(p)):u.set(0,0,0)}static getBarycoord(n,o,l,u,p){Us.subVectors(u,o),Io.subVectors(l,o),Nf.subVectors(n,o);const g=Us.dot(Us),y=Us.dot(Io),b=Us.dot(Nf),S=Io.dot(Io),A=Io.dot(Nf),R=g*S-y*y;if(R===0)return p.set(0,0,0),null;const N=1/R,L=(S*b-y*A)*N,I=(g*A-y*b)*N;return p.set(1-L-I,I,L)}static containsPoint(n,o,l,u){return this.getBarycoord(n,o,l,u,Do)===null?!1:Do.x>=0&&Do.y>=0&&Do.x+Do.y<=1}static getInterpolation(n,o,l,u,p,g,y,b){return this.getBarycoord(n,o,l,u,Do)===null?(b.x=0,b.y=0,"z"in b&&(b.z=0),"w"in b&&(b.w=0),null):(b.setScalar(0),b.addScaledVector(p,Do.x),b.addScaledVector(g,Do.y),b.addScaledVector(y,Do.z),b)}static getInterpolatedAttribute(n,o,l,u,p,g){return Df.setScalar(0),Uf.setScalar(0),Ff.setScalar(0),Df.fromBufferAttribute(n,o),Uf.fromBufferAttribute(n,l),Ff.fromBufferAttribute(n,u),g.setScalar(0),g.addScaledVector(Df,p.x),g.addScaledVector(Uf,p.y),g.addScaledVector(Ff,p.z),g}static isFrontFacing(n,o,l,u){return Us.subVectors(l,o),Io.subVectors(n,o),Us.cross(Io).dot(u)<0}set(n,o,l){return this.a.copy(n),this.b.copy(o),this.c.copy(l),this}setFromPointsAndIndices(n,o,l,u){return this.a.copy(n[o]),this.b.copy(n[l]),this.c.copy(n[u]),this}setFromAttributeAndIndices(n,o,l,u){return this.a.fromBufferAttribute(n,o),this.b.fromBufferAttribute(n,l),this.c.fromBufferAttribute(n,u),this}clone(){return new this.constructor().copy(this)}copy(n){return this.a.copy(n.a),this.b.copy(n.b),this.c.copy(n.c),this}getArea(){return Us.subVectors(this.c,this.b),Io.subVectors(this.a,this.b),Us.cross(Io).length()*.5}getMidpoint(n){return n.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(n){return is.getNormal(this.a,this.b,this.c,n)}getPlane(n){return n.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(n,o){return is.getBarycoord(n,this.a,this.b,this.c,o)}getInterpolation(n,o,l,u,p){return is.getInterpolation(n,this.a,this.b,this.c,o,l,u,p)}containsPoint(n){return is.containsPoint(n,this.a,this.b,this.c)}isFrontFacing(n){return is.isFrontFacing(this.a,this.b,this.c,n)}intersectsBox(n){return n.intersectsTriangle(this)}closestPointToPoint(n,o){const l=this.a,u=this.b,p=this.c;let g,y;zc.subVectors(u,l),Gc.subVectors(p,l),Pf.subVectors(n,l);const b=zc.dot(Pf),S=Gc.dot(Pf);if(b<=0&&S<=0)return o.copy(l);Lf.subVectors(n,u);const A=zc.dot(Lf),R=Gc.dot(Lf);if(A>=0&&R<=A)return o.copy(u);const N=b*R-A*S;if(N<=0&&b>=0&&A<=0)return g=b/(b-A),o.copy(l).addScaledVector(zc,g);If.subVectors(n,p);const L=zc.dot(If),I=Gc.dot(If);if(I>=0&&L<=I)return o.copy(p);const B=L*S-b*I;if(B<=0&&S>=0&&I<=0)return y=S/(S-I),o.copy(l).addScaledVector(Gc,y);const Z=A*I-L*R;if(Z<=0&&R-A>=0&&L-I>=0)return jg.subVectors(p,u),y=(R-A)/(R-A+(L-I)),o.copy(u).addScaledVector(jg,y);const q=1/(Z+B+N);return g=B*q,y=N*q,o.copy(l).addScaledVector(zc,g).addScaledVector(Gc,y)}equals(n){return n.a.equals(this.a)&&n.b.equals(this.b)&&n.c.equals(this.c)}}const Xg={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},sa={h:0,s:0,l:0},Mh={h:0,s:0,l:0};function Bf(M,n,o){return o<0&&(o+=1),o>1&&(o-=1),o<1/6?M+(n-M)*6*o:o<1/2?n:o<2/3?M+(n-M)*6*(2/3-o):M}class Nn{constructor(n,o,l){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(n,o,l)}set(n,o,l){if(o===void 0&&l===void 0){const u=n;u&&u.isColor?this.copy(u):typeof u=="number"?this.setHex(u):typeof u=="string"&&this.setStyle(u)}else this.setRGB(n,o,l);return this}setScalar(n){return this.r=n,this.g=n,this.b=n,this}setHex(n,o=Qr){return n=Math.floor(n),this.r=(n>>16&255)/255,this.g=(n>>8&255)/255,this.b=(n&255)/255,$r.colorSpaceToWorking(this,o),this}setRGB(n,o,l,u=$r.workingColorSpace){return this.r=n,this.g=o,this.b=l,$r.colorSpaceToWorking(this,u),this}setHSL(n,o,l,u=$r.workingColorSpace){if(n=Ul(n,1),o=an(o,0,1),l=an(l,0,1),o===0)this.r=this.g=this.b=l;else{const p=l<=.5?l*(1+o):l+o-l*o,g=2*l-p;this.r=Bf(g,p,n+1/3),this.g=Bf(g,p,n),this.b=Bf(g,p,n-1/3)}return $r.colorSpaceToWorking(this,u),this}setStyle(n,o=Qr){function l(p){p!==void 0&&parseFloat(p)<1&&dn("Color: Alpha component of "+n+" will be ignored.")}let u;if(u=/^(\w+)\(([^\)]*)\)/.exec(n)){let p;const g=u[1],y=u[2];switch(g){case"rgb":case"rgba":if(p=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(y))return l(p[4]),this.setRGB(Math.min(255,parseInt(p[1],10))/255,Math.min(255,parseInt(p[2],10))/255,Math.min(255,parseInt(p[3],10))/255,o);if(p=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(y))return l(p[4]),this.setRGB(Math.min(100,parseInt(p[1],10))/100,Math.min(100,parseInt(p[2],10))/100,Math.min(100,parseInt(p[3],10))/100,o);break;case"hsl":case"hsla":if(p=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(y))return l(p[4]),this.setHSL(parseFloat(p[1])/360,parseFloat(p[2])/100,parseFloat(p[3])/100,o);break;default:dn("Color: Unknown color model "+n)}}else if(u=/^\#([A-Fa-f\d]+)$/.exec(n)){const p=u[1],g=p.length;if(g===3)return this.setRGB(parseInt(p.charAt(0),16)/15,parseInt(p.charAt(1),16)/15,parseInt(p.charAt(2),16)/15,o);if(g===6)return this.setHex(parseInt(p,16),o);dn("Color: Invalid hex color "+n)}else if(n&&n.length>0)return this.setColorName(n,o);return this}setColorName(n,o=Qr){const l=Xg[n.toLowerCase()];return l!==void 0?this.setHex(l,o):dn("Color: Unknown color "+n),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(n){return this.r=n.r,this.g=n.g,this.b=n.b,this}copySRGBToLinear(n){return this.r=Ro(n.r),this.g=Ro(n.g),this.b=Ro(n.b),this}copyLinearToSRGB(n){return this.r=Lc(n.r),this.g=Lc(n.g),this.b=Lc(n.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(n=Qr){return $r.workingToColorSpace(Pr.copy(this),n),Math.round(an(Pr.r*255,0,255))*65536+Math.round(an(Pr.g*255,0,255))*256+Math.round(an(Pr.b*255,0,255))}getHexString(n=Qr){return("000000"+this.getHex(n).toString(16)).slice(-6)}getHSL(n,o=$r.workingColorSpace){$r.workingToColorSpace(Pr.copy(this),o);const l=Pr.r,u=Pr.g,p=Pr.b,g=Math.max(l,u,p),y=Math.min(l,u,p);let b,S;const A=(y+g)/2;if(y===g)b=0,S=0;else{const R=g-y;switch(S=A<=.5?R/(g+y):R/(2-g-y),g){case l:b=(u-p)/R+(u<p?6:0);break;case u:b=(p-l)/R+2;break;case p:b=(l-u)/R+4;break}b/=6}return n.h=b,n.s=S,n.l=A,n}getRGB(n,o=$r.workingColorSpace){return $r.workingToColorSpace(Pr.copy(this),o),n.r=Pr.r,n.g=Pr.g,n.b=Pr.b,n}getStyle(n=Qr){$r.workingToColorSpace(Pr.copy(this),n);const o=Pr.r,l=Pr.g,u=Pr.b;return n!==Qr?`color(${n} ${o.toFixed(3)} ${l.toFixed(3)} ${u.toFixed(3)})`:`rgb(${Math.round(o*255)},${Math.round(l*255)},${Math.round(u*255)})`}offsetHSL(n,o,l){return this.getHSL(sa),this.setHSL(sa.h+n,sa.s+o,sa.l+l)}add(n){return this.r+=n.r,this.g+=n.g,this.b+=n.b,this}addColors(n,o){return this.r=n.r+o.r,this.g=n.g+o.g,this.b=n.b+o.b,this}addScalar(n){return this.r+=n,this.g+=n,this.b+=n,this}sub(n){return this.r=Math.max(0,this.r-n.r),this.g=Math.max(0,this.g-n.g),this.b=Math.max(0,this.b-n.b),this}multiply(n){return this.r*=n.r,this.g*=n.g,this.b*=n.b,this}multiplyScalar(n){return this.r*=n,this.g*=n,this.b*=n,this}lerp(n,o){return this.r+=(n.r-this.r)*o,this.g+=(n.g-this.g)*o,this.b+=(n.b-this.b)*o,this}lerpColors(n,o,l){return this.r=n.r+(o.r-n.r)*l,this.g=n.g+(o.g-n.g)*l,this.b=n.b+(o.b-n.b)*l,this}lerpHSL(n,o){this.getHSL(sa),n.getHSL(Mh);const l=Fl(sa.h,Mh.h,o),u=Fl(sa.s,Mh.s,o),p=Fl(sa.l,Mh.l,o);return this.setHSL(l,u,p),this}setFromVector3(n){return this.r=n.x,this.g=n.y,this.b=n.z,this}applyMatrix3(n){const o=this.r,l=this.g,u=this.b,p=n.elements;return this.r=p[0]*o+p[3]*l+p[6]*u,this.g=p[1]*o+p[4]*l+p[7]*u,this.b=p[2]*o+p[5]*l+p[8]*u,this}equals(n){return n.r===this.r&&n.g===this.g&&n.b===this.b}fromArray(n,o=0){return this.r=n[o],this.g=n[o+1],this.b=n[o+2],this}toArray(n=[],o=0){return n[o]=this.r,n[o+1]=this.g,n[o+2]=this.b,n}fromBufferAttribute(n,o){return this.r=n.getX(o),this.g=n.getY(o),this.b=n.getZ(o),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Pr=new Nn;Nn.NAMES=Xg;let hT=0;class Lr extends ea{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:hT++}),this.uuid=gr(),this.name="",this.type="Material",this.blending=Ie,this.side=_e,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=bn,this.blendDst=kt,this.blendEquation=rt,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Nn(0,0,0),this.blendAlpha=0,this.depthFunc=Qo,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=es,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=La,this.stencilZFail=La,this.stencilZPass=La,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(n){this._alphaTest>0!=n>0&&this.version++,this._alphaTest=n}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(n){if(n!==void 0)for(const o in n){const l=n[o];if(l===void 0){dn(`Material: parameter '${o}' has value of undefined.`);continue}const u=this[o];if(u===void 0){dn(`Material: '${o}' is not a property of THREE.${this.type}.`);continue}u&&u.isColor?u.set(l):u&&u.isVector3&&l&&l.isVector3?u.copy(l):this[o]=l}}toJSON(n){const o=n===void 0||typeof n=="string";o&&(n={textures:{},images:{}});const l={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};l.uuid=this.uuid,l.type=this.type,this.name!==""&&(l.name=this.name),this.color&&this.color.isColor&&(l.color=this.color.getHex()),this.roughness!==void 0&&(l.roughness=this.roughness),this.metalness!==void 0&&(l.metalness=this.metalness),this.sheen!==void 0&&(l.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(l.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(l.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(l.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(l.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(l.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(l.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(l.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(l.shininess=this.shininess),this.clearcoat!==void 0&&(l.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(l.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(l.clearcoatMap=this.clearcoatMap.toJSON(n).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(l.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(n).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(l.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(n).uuid,l.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(l.sheenColorMap=this.sheenColorMap.toJSON(n).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(l.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(n).uuid),this.dispersion!==void 0&&(l.dispersion=this.dispersion),this.iridescence!==void 0&&(l.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(l.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(l.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(l.iridescenceMap=this.iridescenceMap.toJSON(n).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(l.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(n).uuid),this.anisotropy!==void 0&&(l.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(l.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(l.anisotropyMap=this.anisotropyMap.toJSON(n).uuid),this.map&&this.map.isTexture&&(l.map=this.map.toJSON(n).uuid),this.matcap&&this.matcap.isTexture&&(l.matcap=this.matcap.toJSON(n).uuid),this.alphaMap&&this.alphaMap.isTexture&&(l.alphaMap=this.alphaMap.toJSON(n).uuid),this.lightMap&&this.lightMap.isTexture&&(l.lightMap=this.lightMap.toJSON(n).uuid,l.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(l.aoMap=this.aoMap.toJSON(n).uuid,l.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(l.bumpMap=this.bumpMap.toJSON(n).uuid,l.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(l.normalMap=this.normalMap.toJSON(n).uuid,l.normalMapType=this.normalMapType,l.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(l.displacementMap=this.displacementMap.toJSON(n).uuid,l.displacementScale=this.displacementScale,l.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(l.roughnessMap=this.roughnessMap.toJSON(n).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(l.metalnessMap=this.metalnessMap.toJSON(n).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(l.emissiveMap=this.emissiveMap.toJSON(n).uuid),this.specularMap&&this.specularMap.isTexture&&(l.specularMap=this.specularMap.toJSON(n).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(l.specularIntensityMap=this.specularIntensityMap.toJSON(n).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(l.specularColorMap=this.specularColorMap.toJSON(n).uuid),this.envMap&&this.envMap.isTexture&&(l.envMap=this.envMap.toJSON(n).uuid,this.combine!==void 0&&(l.combine=this.combine)),this.envMapRotation!==void 0&&(l.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(l.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(l.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(l.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(l.gradientMap=this.gradientMap.toJSON(n).uuid),this.transmission!==void 0&&(l.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(l.transmissionMap=this.transmissionMap.toJSON(n).uuid),this.thickness!==void 0&&(l.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(l.thicknessMap=this.thicknessMap.toJSON(n).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(l.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(l.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(l.size=this.size),this.shadowSide!==null&&(l.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(l.sizeAttenuation=this.sizeAttenuation),this.blending!==Ie&&(l.blending=this.blending),this.side!==_e&&(l.side=this.side),this.vertexColors===!0&&(l.vertexColors=!0),this.opacity<1&&(l.opacity=this.opacity),this.transparent===!0&&(l.transparent=!0),this.blendSrc!==bn&&(l.blendSrc=this.blendSrc),this.blendDst!==kt&&(l.blendDst=this.blendDst),this.blendEquation!==rt&&(l.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(l.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(l.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(l.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(l.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(l.blendAlpha=this.blendAlpha),this.depthFunc!==Qo&&(l.depthFunc=this.depthFunc),this.depthTest===!1&&(l.depthTest=this.depthTest),this.depthWrite===!1&&(l.depthWrite=this.depthWrite),this.colorWrite===!1&&(l.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(l.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==es&&(l.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(l.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(l.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==La&&(l.stencilFail=this.stencilFail),this.stencilZFail!==La&&(l.stencilZFail=this.stencilZFail),this.stencilZPass!==La&&(l.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(l.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(l.rotation=this.rotation),this.polygonOffset===!0&&(l.polygonOffset=!0),this.polygonOffsetFactor!==0&&(l.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(l.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(l.linewidth=this.linewidth),this.dashSize!==void 0&&(l.dashSize=this.dashSize),this.gapSize!==void 0&&(l.gapSize=this.gapSize),this.scale!==void 0&&(l.scale=this.scale),this.dithering===!0&&(l.dithering=!0),this.alphaTest>0&&(l.alphaTest=this.alphaTest),this.alphaHash===!0&&(l.alphaHash=!0),this.alphaToCoverage===!0&&(l.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(l.premultipliedAlpha=!0),this.forceSinglePass===!0&&(l.forceSinglePass=!0),this.wireframe===!0&&(l.wireframe=!0),this.wireframeLinewidth>1&&(l.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(l.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(l.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(l.flatShading=!0),this.visible===!1&&(l.visible=!1),this.toneMapped===!1&&(l.toneMapped=!1),this.fog===!1&&(l.fog=!1),Object.keys(this.userData).length>0&&(l.userData=this.userData);function u(p){const g=[];for(const y in p){const b=p[y];delete b.metadata,g.push(b)}return g}if(o){const p=u(n.textures),g=u(n.images);p.length>0&&(l.textures=p),g.length>0&&(l.images=g)}return l}clone(){return new this.constructor().copy(this)}copy(n){this.name=n.name,this.blending=n.blending,this.side=n.side,this.vertexColors=n.vertexColors,this.opacity=n.opacity,this.transparent=n.transparent,this.blendSrc=n.blendSrc,this.blendDst=n.blendDst,this.blendEquation=n.blendEquation,this.blendSrcAlpha=n.blendSrcAlpha,this.blendDstAlpha=n.blendDstAlpha,this.blendEquationAlpha=n.blendEquationAlpha,this.blendColor.copy(n.blendColor),this.blendAlpha=n.blendAlpha,this.depthFunc=n.depthFunc,this.depthTest=n.depthTest,this.depthWrite=n.depthWrite,this.stencilWriteMask=n.stencilWriteMask,this.stencilFunc=n.stencilFunc,this.stencilRef=n.stencilRef,this.stencilFuncMask=n.stencilFuncMask,this.stencilFail=n.stencilFail,this.stencilZFail=n.stencilZFail,this.stencilZPass=n.stencilZPass,this.stencilWrite=n.stencilWrite;const o=n.clippingPlanes;let l=null;if(o!==null){const u=o.length;l=new Array(u);for(let p=0;p!==u;++p)l[p]=o[p].clone()}return this.clippingPlanes=l,this.clipIntersection=n.clipIntersection,this.clipShadows=n.clipShadows,this.shadowSide=n.shadowSide,this.colorWrite=n.colorWrite,this.precision=n.precision,this.polygonOffset=n.polygonOffset,this.polygonOffsetFactor=n.polygonOffsetFactor,this.polygonOffsetUnits=n.polygonOffsetUnits,this.dithering=n.dithering,this.alphaTest=n.alphaTest,this.alphaHash=n.alphaHash,this.alphaToCoverage=n.alphaToCoverage,this.premultipliedAlpha=n.premultipliedAlpha,this.forceSinglePass=n.forceSinglePass,this.visible=n.visible,this.toneMapped=n.toneMapped,this.userData=JSON.parse(JSON.stringify(n.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(n){n===!0&&this.version++}}class Wc extends Lr{constructor(n){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Nn(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 Ds,this.combine=Qu,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(n)}copy(n){return super.copy(n),this.color.copy(n.color),this.map=n.map,this.lightMap=n.lightMap,this.lightMapIntensity=n.lightMapIntensity,this.aoMap=n.aoMap,this.aoMapIntensity=n.aoMapIntensity,this.specularMap=n.specularMap,this.alphaMap=n.alphaMap,this.envMap=n.envMap,this.envMapRotation.copy(n.envMapRotation),this.combine=n.combine,this.reflectivity=n.reflectivity,this.refractionRatio=n.refractionRatio,this.wireframe=n.wireframe,this.wireframeLinewidth=n.wireframeLinewidth,this.wireframeLinecap=n.wireframeLinecap,this.wireframeLinejoin=n.wireframeLinejoin,this.fog=n.fog,this}}const oa=dT();function dT(){const M=new ArrayBuffer(4),n=new Float32Array(M),o=new Uint32Array(M),l=new Uint32Array(512),u=new Uint32Array(512);for(let b=0;b<256;++b){const S=b-127;S<-27?(l[b]=0,l[b|256]=32768,u[b]=24,u[b|256]=24):S<-14?(l[b]=1024>>-S-14,l[b|256]=1024>>-S-14|32768,u[b]=-S-1,u[b|256]=-S-1):S<=15?(l[b]=S+15<<10,l[b|256]=S+15<<10|32768,u[b]=13,u[b|256]=13):S<128?(l[b]=31744,l[b|256]=64512,u[b]=24,u[b|256]=24):(l[b]=31744,l[b|256]=64512,u[b]=13,u[b|256]=13)}const p=new Uint32Array(2048),g=new Uint32Array(64),y=new Uint32Array(64);for(let b=1;b<1024;++b){let S=b<<13,A=0;for(;!(S&8388608);)S<<=1,A-=8388608;S&=-8388609,A+=947912704,p[b]=S|A}for(let b=1024;b<2048;++b)p[b]=939524096+(b-1024<<13);for(let b=1;b<31;++b)g[b]=b<<23;g[31]=1199570944,g[32]=2147483648;for(let b=33;b<63;++b)g[b]=2147483648+(b-32<<23);g[63]=3347054592;for(let b=1;b<64;++b)b!==32&&(y[b]=1024);return{floatView:n,uint32View:o,baseTable:l,shiftTable:u,mantissaTable:p,exponentTable:g,offsetTable:y}}function rs(M){Math.abs(M)>65504&&dn("DataUtils.toHalfFloat(): Value out of range."),M=an(M,-65504,65504),oa.floatView[0]=M;const n=oa.uint32View[0],o=n>>23&511;return oa.baseTable[o]+((n&8388607)>>oa.shiftTable[o])}function wh(M){const n=M>>10;return oa.uint32View[0]=oa.mantissaTable[oa.offsetTable[n]+(M&1023)]+oa.exponentTable[n],oa.floatView[0]}class h3{static toHalfFloat(n){return rs(n)}static fromHalfFloat(n){return wh(n)}}const ar=new ie,Of=new dt;let fT=0;class dr{constructor(n,o,l=!1){if(Array.isArray(n))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:fT++}),this.name="",this.array=n,this.itemSize=o,this.count=n!==void 0?n.length/o:0,this.normalized=l,this.usage=Pc,this.updateRanges=[],this.gpuType=Jo,this.version=0}onUploadCallback(){}set needsUpdate(n){n===!0&&this.version++}setUsage(n){return this.usage=n,this}addUpdateRange(n,o){this.updateRanges.push({start:n,count:o})}clearUpdateRanges(){this.updateRanges.length=0}copy(n){return this.name=n.name,this.array=new n.array.constructor(n.array),this.itemSize=n.itemSize,this.count=n.count,this.normalized=n.normalized,this.usage=n.usage,this.gpuType=n.gpuType,this}copyAt(n,o,l){n*=this.itemSize,l*=o.itemSize;for(let u=0,p=this.itemSize;u<p;u++)this.array[n+u]=o.array[l+u];return this}copyArray(n){return this.array.set(n),this}applyMatrix3(n){if(this.itemSize===2)for(let o=0,l=this.count;o<l;o++)Of.fromBufferAttribute(this,o),Of.applyMatrix3(n),this.setXY(o,Of.x,Of.y);else if(this.itemSize===3)for(let o=0,l=this.count;o<l;o++)ar.fromBufferAttribute(this,o),ar.applyMatrix3(n),this.setXYZ(o,ar.x,ar.y,ar.z);return this}applyMatrix4(n){for(let o=0,l=this.count;o<l;o++)ar.fromBufferAttribute(this,o),ar.applyMatrix4(n),this.setXYZ(o,ar.x,ar.y,ar.z);return this}applyNormalMatrix(n){for(let o=0,l=this.count;o<l;o++)ar.fromBufferAttribute(this,o),ar.applyNormalMatrix(n),this.setXYZ(o,ar.x,ar.y,ar.z);return this}transformDirection(n){for(let o=0,l=this.count;o<l;o++)ar.fromBufferAttribute(this,o),ar.transformDirection(n),this.setXYZ(o,ar.x,ar.y,ar.z);return this}set(n,o=0){return this.array.set(n,o),this}getComponent(n,o){let l=this.array[n*this.itemSize+o];return this.normalized&&(l=Nr(l,this.array)),l}setComponent(n,o,l){return this.normalized&&(l=Fn(l,this.array)),this.array[n*this.itemSize+o]=l,this}getX(n){let o=this.array[n*this.itemSize];return this.normalized&&(o=Nr(o,this.array)),o}setX(n,o){return this.normalized&&(o=Fn(o,this.array)),this.array[n*this.itemSize]=o,this}getY(n){let o=this.array[n*this.itemSize+1];return this.normalized&&(o=Nr(o,this.array)),o}setY(n,o){return this.normalized&&(o=Fn(o,this.array)),this.array[n*this.itemSize+1]=o,this}getZ(n){let o=this.array[n*this.itemSize+2];return this.normalized&&(o=Nr(o,this.array)),o}setZ(n,o){return this.normalized&&(o=Fn(o,this.array)),this.array[n*this.itemSize+2]=o,this}getW(n){let o=this.array[n*this.itemSize+3];return this.normalized&&(o=Nr(o,this.array)),o}setW(n,o){return this.normalized&&(o=Fn(o,this.array)),this.array[n*this.itemSize+3]=o,this}setXY(n,o,l){return n*=this.itemSize,this.normalized&&(o=Fn(o,this.array),l=Fn(l,this.array)),this.array[n+0]=o,this.array[n+1]=l,this}setXYZ(n,o,l,u){return n*=this.itemSize,this.normalized&&(o=Fn(o,this.array),l=Fn(l,this.array),u=Fn(u,this.array)),this.array[n+0]=o,this.array[n+1]=l,this.array[n+2]=u,this}setXYZW(n,o,l,u,p){return n*=this.itemSize,this.normalized&&(o=Fn(o,this.array),l=Fn(l,this.array),u=Fn(u,this.array),p=Fn(p,this.array)),this.array[n+0]=o,this.array[n+1]=l,this.array[n+2]=u,this.array[n+3]=p,this}onUpload(n){return this.onUploadCallback=n,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const n={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(n.name=this.name),this.usage!==Pc&&(n.usage=this.usage),n}}class d3 extends null{constructor(n,o,l){super(new Int8Array(n),o,l)}}class f3 extends null{constructor(n,o,l){super(new Uint8Array(n),o,l)}}class p3 extends null{constructor(n,o,l){super(new Uint8ClampedArray(n),o,l)}}class m3 extends null{constructor(n,o,l){super(new Int16Array(n),o,l)}}class Sy extends dr{constructor(n,o,l){super(new Uint16Array(n),o,l)}}class g3 extends null{constructor(n,o,l){super(new Int32Array(n),o,l)}}class Ty extends dr{constructor(n,o,l){super(new Uint32Array(n),o,l)}}class pT extends dr{constructor(n,o,l){super(new Uint16Array(n),o,l),this.isFloat16BufferAttribute=!0}getX(n){let o=wh(this.array[n*this.itemSize]);return this.normalized&&(o=Nr(o,this.array)),o}setX(n,o){return this.normalized&&(o=Fn(o,this.array)),this.array[n*this.itemSize]=rs(o),this}getY(n){let o=wh(this.array[n*this.itemSize+1]);return this.normalized&&(o=Nr(o,this.array)),o}setY(n,o){return this.normalized&&(o=Fn(o,this.array)),this.array[n*this.itemSize+1]=rs(o),this}getZ(n){let o=wh(this.array[n*this.itemSize+2]);return this.normalized&&(o=Nr(o,this.array)),o}setZ(n,o){return this.normalized&&(o=Fn(o,this.array)),this.array[n*this.itemSize+2]=rs(o),this}getW(n){let o=wh(this.array[n*this.itemSize+3]);return this.normalized&&(o=Nr(o,this.array)),o}setW(n,o){return this.normalized&&(o=Fn(o,this.array)),this.array[n*this.itemSize+3]=rs(o),this}setXY(n,o,l){return n*=this.itemSize,this.normalized&&(o=Fn(o,this.array),l=Fn(l,this.array)),this.array[n+0]=rs(o),this.array[n+1]=rs(l),this}setXYZ(n,o,l,u){return n*=this.itemSize,this.normalized&&(o=Fn(o,this.array),l=Fn(l,this.array),u=Fn(u,this.array)),this.array[n+0]=rs(o),this.array[n+1]=rs(l),this.array[n+2]=rs(u),this}setXYZW(n,o,l,u,p){return n*=this.itemSize,this.normalized&&(o=Fn(o,this.array),l=Fn(l,this.array),u=Fn(u,this.array),p=Fn(p,this.array)),this.array[n+0]=rs(o),this.array[n+1]=rs(l),this.array[n+2]=rs(u),this.array[n+3]=rs(p),this}}class Ht extends dr{constructor(n,o,l){super(new Float32Array(n),o,l)}}let mT=0;const Fs=new Ln,qg=new Ri,Vl=new ie,gs=new wr,Ah=new wr,_r=new ie;class $n extends ea{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:mT++}),this.uuid=gr(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(n){return Array.isArray(n)?this.index=new(Ag(n)?Ty:Sy)(n,1):this.index=n,this}setIndirect(n){return this.indirect=n,this}getIndirect(){return this.indirect}getAttribute(n){return this.attributes[n]}setAttribute(n,o){return this.attributes[n]=o,this}deleteAttribute(n){return delete this.attributes[n],this}hasAttribute(n){return this.attributes[n]!==void 0}addGroup(n,o,l=0){this.groups.push({start:n,count:o,materialIndex:l})}clearGroups(){this.groups=[]}setDrawRange(n,o){this.drawRange.start=n,this.drawRange.count=o}applyMatrix4(n){const o=this.attributes.position;o!==void 0&&(o.applyMatrix4(n),o.needsUpdate=!0);const l=this.attributes.normal;if(l!==void 0){const p=new Ps().getNormalMatrix(n);l.applyNormalMatrix(p),l.needsUpdate=!0}const u=this.attributes.tangent;return u!==void 0&&(u.transformDirection(n),u.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(n){return Fs.makeRotationFromQuaternion(n),this.applyMatrix4(Fs),this}rotateX(n){return Fs.makeRotationX(n),this.applyMatrix4(Fs),this}rotateY(n){return Fs.makeRotationY(n),this.applyMatrix4(Fs),this}rotateZ(n){return Fs.makeRotationZ(n),this.applyMatrix4(Fs),this}translate(n,o,l){return Fs.makeTranslation(n,o,l),this.applyMatrix4(Fs),this}scale(n,o,l){return Fs.makeScale(n,o,l),this.applyMatrix4(Fs),this}lookAt(n){return qg.lookAt(n),qg.updateMatrix(),this.applyMatrix4(qg.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Vl).negate(),this.translate(Vl.x,Vl.y,Vl.z),this}setFromPoints(n){const o=this.getAttribute("position");if(o===void 0){const l=[];for(let u=0,p=n.length;u<p;u++){const g=n[u];l.push(g.x,g.y,g.z||0)}this.setAttribute("position",new Ht(l,3))}else{const l=Math.min(n.length,o.count);for(let u=0;u<l;u++){const p=n[u];o.setXYZ(u,p.x,p.y,p.z||0)}n.length>o.count&&dn("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),o.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new wr);const n=this.attributes.position,o=this.morphAttributes.position;if(n&&n.isGLBufferAttribute){Yn("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new ie(-1/0,-1/0,-1/0),new ie(1/0,1/0,1/0));return}if(n!==void 0){if(this.boundingBox.setFromBufferAttribute(n),o)for(let l=0,u=o.length;l<u;l++){const p=o[l];gs.setFromBufferAttribute(p),this.morphTargetsRelative?(_r.addVectors(this.boundingBox.min,gs.min),this.boundingBox.expandByPoint(_r),_r.addVectors(this.boundingBox.max,gs.max),this.boundingBox.expandByPoint(_r)):(this.boundingBox.expandByPoint(gs.min),this.boundingBox.expandByPoint(gs.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Yn('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new xr);const n=this.attributes.position,o=this.morphAttributes.position;if(n&&n.isGLBufferAttribute){Yn("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new ie,1/0);return}if(n){const l=this.boundingSphere.center;if(gs.setFromBufferAttribute(n),o)for(let p=0,g=o.length;p<g;p++){const y=o[p];Ah.setFromBufferAttribute(y),this.morphTargetsRelative?(_r.addVectors(gs.min,Ah.min),gs.expandByPoint(_r),_r.addVectors(gs.max,Ah.max),gs.expandByPoint(_r)):(gs.expandByPoint(Ah.min),gs.expandByPoint(Ah.max))}gs.getCenter(l);let u=0;for(let p=0,g=n.count;p<g;p++)_r.fromBufferAttribute(n,p),u=Math.max(u,l.distanceToSquared(_r));if(o)for(let p=0,g=o.length;p<g;p++){const y=o[p],b=this.morphTargetsRelative;for(let S=0,A=y.count;S<A;S++)_r.fromBufferAttribute(y,S),b&&(Vl.fromBufferAttribute(n,S),_r.add(Vl)),u=Math.max(u,l.distanceToSquared(_r))}this.boundingSphere.radius=Math.sqrt(u),isNaN(this.boundingSphere.radius)&&Yn('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const n=this.index,o=this.attributes;if(n===null||o.position===void 0||o.normal===void 0||o.uv===void 0){Yn("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const l=o.position,u=o.normal,p=o.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new dr(new Float32Array(4*l.count),4));const g=this.getAttribute("tangent"),y=[],b=[];for(let ze=0;ze<l.count;ze++)y[ze]=new ie,b[ze]=new ie;const S=new ie,A=new ie,R=new ie,N=new dt,L=new dt,I=new dt,B=new ie,Z=new ie;function q(ze,lt,mt){S.fromBufferAttribute(l,ze),A.fromBufferAttribute(l,lt),R.fromBufferAttribute(l,mt),N.fromBufferAttribute(p,ze),L.fromBufferAttribute(p,lt),I.fromBufferAttribute(p,mt),A.sub(S),R.sub(S),L.sub(N),I.sub(N);const Zt=1/(L.x*I.y-I.x*L.y);isFinite(Zt)&&(B.copy(A).multiplyScalar(I.y).addScaledVector(R,-L.y).multiplyScalar(Zt),Z.copy(R).multiplyScalar(L.x).addScaledVector(A,-I.x).multiplyScalar(Zt),y[ze].add(B),y[lt].add(B),y[mt].add(B),b[ze].add(Z),b[lt].add(Z),b[mt].add(Z))}let ee=this.groups;ee.length===0&&(ee=[{start:0,count:n.count}]);for(let ze=0,lt=ee.length;ze<lt;++ze){const mt=ee[ze],Zt=mt.start,Bn=mt.count;for(let Hn=Zt,pi=Zt+Bn;Hn<pi;Hn+=3)q(n.getX(Hn+0),n.getX(Hn+1),n.getX(Hn+2))}const te=new ie,he=new ie,Re=new ie,ke=new ie;function We(ze){Re.fromBufferAttribute(u,ze),ke.copy(Re);const lt=y[ze];te.copy(lt),te.sub(Re.multiplyScalar(Re.dot(lt))).normalize(),he.crossVectors(ke,lt);const Zt=he.dot(b[ze])<0?-1:1;g.setXYZW(ze,te.x,te.y,te.z,Zt)}for(let ze=0,lt=ee.length;ze<lt;++ze){const mt=ee[ze],Zt=mt.start,Bn=mt.count;for(let Hn=Zt,pi=Zt+Bn;Hn<pi;Hn+=3)We(n.getX(Hn+0)),We(n.getX(Hn+1)),We(n.getX(Hn+2))}}computeVertexNormals(){const n=this.index,o=this.getAttribute("position");if(o!==void 0){let l=this.getAttribute("normal");if(l===void 0)l=new dr(new Float32Array(o.count*3),3),this.setAttribute("normal",l);else for(let N=0,L=l.count;N<L;N++)l.setXYZ(N,0,0,0);const u=new ie,p=new ie,g=new ie,y=new ie,b=new ie,S=new ie,A=new ie,R=new ie;if(n)for(let N=0,L=n.count;N<L;N+=3){const I=n.getX(N+0),B=n.getX(N+1),Z=n.getX(N+2);u.fromBufferAttribute(o,I),p.fromBufferAttribute(o,B),g.fromBufferAttribute(o,Z),A.subVectors(g,p),R.subVectors(u,p),A.cross(R),y.fromBufferAttribute(l,I),b.fromBufferAttribute(l,B),S.fromBufferAttribute(l,Z),y.add(A),b.add(A),S.add(A),l.setXYZ(I,y.x,y.y,y.z),l.setXYZ(B,b.x,b.y,b.z),l.setXYZ(Z,S.x,S.y,S.z)}else for(let N=0,L=o.count;N<L;N+=3)u.fromBufferAttribute(o,N+0),p.fromBufferAttribute(o,N+1),g.fromBufferAttribute(o,N+2),A.subVectors(g,p),R.subVectors(u,p),A.cross(R),l.setXYZ(N+0,A.x,A.y,A.z),l.setXYZ(N+1,A.x,A.y,A.z),l.setXYZ(N+2,A.x,A.y,A.z);this.normalizeNormals(),l.needsUpdate=!0}}normalizeNormals(){const n=this.attributes.normal;for(let o=0,l=n.count;o<l;o++)_r.fromBufferAttribute(n,o),_r.normalize(),n.setXYZ(o,_r.x,_r.y,_r.z)}toNonIndexed(){function n(y,b){const S=y.array,A=y.itemSize,R=y.normalized,N=new S.constructor(b.length*A);let L=0,I=0;for(let B=0,Z=b.length;B<Z;B++){y.isInterleavedBufferAttribute?L=b[B]*y.data.stride+y.offset:L=b[B]*A;for(let q=0;q<A;q++)N[I++]=S[L++]}return new dr(N,A,R)}if(this.index===null)return dn("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const o=new $n,l=this.index.array,u=this.attributes;for(const y in u){const b=u[y],S=n(b,l);o.setAttribute(y,S)}const p=this.morphAttributes;for(const y in p){const b=[],S=p[y];for(let A=0,R=S.length;A<R;A++){const N=S[A],L=n(N,l);b.push(L)}o.morphAttributes[y]=b}o.morphTargetsRelative=this.morphTargetsRelative;const g=this.groups;for(let y=0,b=g.length;y<b;y++){const S=g[y];o.addGroup(S.start,S.count,S.materialIndex)}return o}toJSON(){const n={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),Object.keys(this.userData).length>0&&(n.userData=this.userData),this.parameters!==void 0){const b=this.parameters;for(const S in b)b[S]!==void 0&&(n[S]=b[S]);return n}n.data={attributes:{}};const o=this.index;o!==null&&(n.data.index={type:o.array.constructor.name,array:Array.prototype.slice.call(o.array)});const l=this.attributes;for(const b in l){const S=l[b];n.data.attributes[b]=S.toJSON(n.data)}const u={};let p=!1;for(const b in this.morphAttributes){const S=this.morphAttributes[b],A=[];for(let R=0,N=S.length;R<N;R++){const L=S[R];A.push(L.toJSON(n.data))}A.length>0&&(u[b]=A,p=!0)}p&&(n.data.morphAttributes=u,n.data.morphTargetsRelative=this.morphTargetsRelative);const g=this.groups;g.length>0&&(n.data.groups=JSON.parse(JSON.stringify(g)));const y=this.boundingSphere;return y!==null&&(n.data.boundingSphere=y.toJSON()),n}clone(){return new this.constructor().copy(this)}copy(n){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const o={};this.name=n.name;const l=n.index;l!==null&&this.setIndex(l.clone());const u=n.attributes;for(const S in u){const A=u[S];this.setAttribute(S,A.clone(o))}const p=n.morphAttributes;for(const S in p){const A=[],R=p[S];for(let N=0,L=R.length;N<L;N++)A.push(R[N].clone(o));this.morphAttributes[S]=A}this.morphTargetsRelative=n.morphTargetsRelative;const g=n.groups;for(let S=0,A=g.length;S<A;S++){const R=g[S];this.addGroup(R.start,R.count,R.materialIndex)}const y=n.boundingBox;y!==null&&(this.boundingBox=y.clone());const b=n.boundingSphere;return b!==null&&(this.boundingSphere=b.clone()),this.drawRange.start=n.drawRange.start,this.drawRange.count=n.drawRange.count,this.userData=n.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const My=new Ln,Hc=new Bc,kf=new xr,kn=new ie,wt=new ie,ss=new ie,Oa=new ie,Uo=new ie,Eh=new ie,Kg=new ie,Ch=new ie;class aa extends Ri{constructor(n=new $n,o=new Wc){super(),this.isMesh=!0,this.type="Mesh",this.geometry=n,this.material=o,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(n,o){return super.copy(n,o),n.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=n.morphTargetInfluences.slice()),n.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},n.morphTargetDictionary)),this.material=Array.isArray(n.material)?n.material.slice():n.material,this.geometry=n.geometry,this}updateMorphTargets(){const o=this.geometry.morphAttributes,l=Object.keys(o);if(l.length>0){const u=o[l[0]];if(u!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let p=0,g=u.length;p<g;p++){const y=u[p].name||String(p);this.morphTargetInfluences.push(0),this.morphTargetDictionary[y]=p}}}}getVertexPosition(n,o){const l=this.geometry,u=l.attributes.position,p=l.morphAttributes.position,g=l.morphTargetsRelative;o.fromBufferAttribute(u,n);const y=this.morphTargetInfluences;if(p&&y){Eh.set(0,0,0);for(let b=0,S=p.length;b<S;b++){const A=y[b],R=p[b];A!==0&&(Uo.fromBufferAttribute(R,n),g?Eh.addScaledVector(Uo,A):Eh.addScaledVector(Uo.sub(o),A))}o.add(Eh)}return o}raycast(n,o){const l=this.geometry,u=this.material,p=this.matrixWorld;u!==void 0&&(l.boundingSphere===null&&l.computeBoundingSphere(),kf.copy(l.boundingSphere),kf.applyMatrix4(p),Hc.copy(n.ray).recast(n.near),!(kf.containsPoint(Hc.origin)===!1&&(Hc.intersectSphere(kf,kn)===null||Hc.origin.distanceToSquared(kn)>Zd(n.far-n.near,2)))&&(My.copy(p).invert(),Hc.copy(n.ray).applyMatrix4(My),!(l.boundingBox!==null&&Hc.intersectsBox(l.boundingBox)===!1)&&this._computeIntersections(n,o,Hc)))}_computeIntersections(n,o,l){let u;const p=this.geometry,g=this.material,y=p.index,b=p.attributes.position,S=p.attributes.uv,A=p.attributes.uv1,R=p.attributes.normal,N=p.groups,L=p.drawRange;if(y!==null)if(Array.isArray(g))for(let I=0,B=N.length;I<B;I++){const Z=N[I],q=g[Z.materialIndex],ee=Math.max(Z.start,L.start),te=Math.min(y.count,Math.min(Z.start+Z.count,L.start+L.count));for(let he=ee,Re=te;he<Re;he+=3){const ke=y.getX(he),We=y.getX(he+1),ze=y.getX(he+2);u=Rh(this,q,n,l,S,A,R,ke,We,ze),u&&(u.faceIndex=Math.floor(he/3),u.face.materialIndex=Z.materialIndex,o.push(u))}}else{const I=Math.max(0,L.start),B=Math.min(y.count,L.start+L.count);for(let Z=I,q=B;Z<q;Z+=3){const ee=y.getX(Z),te=y.getX(Z+1),he=y.getX(Z+2);u=Rh(this,g,n,l,S,A,R,ee,te,he),u&&(u.faceIndex=Math.floor(Z/3),o.push(u))}}else if(b!==void 0)if(Array.isArray(g))for(let I=0,B=N.length;I<B;I++){const Z=N[I],q=g[Z.materialIndex],ee=Math.max(Z.start,L.start),te=Math.min(b.count,Math.min(Z.start+Z.count,L.start+L.count));for(let he=ee,Re=te;he<Re;he+=3){const ke=he,We=he+1,ze=he+2;u=Rh(this,q,n,l,S,A,R,ke,We,ze),u&&(u.faceIndex=Math.floor(he/3),u.face.materialIndex=Z.materialIndex,o.push(u))}}else{const I=Math.max(0,L.start),B=Math.min(b.count,L.start+L.count);for(let Z=I,q=B;Z<q;Z+=3){const ee=Z,te=Z+1,he=Z+2;u=Rh(this,g,n,l,S,A,R,ee,te,he),u&&(u.faceIndex=Math.floor(Z/3),o.push(u))}}}}function wy(M,n,o,l,u,p,g,y){let b;if(n.side===Ae?b=l.intersectTriangle(g,p,u,!0,y):b=l.intersectTriangle(u,p,g,n.side===_e,y),b===null)return null;Ch.copy(y),Ch.applyMatrix4(M.matrixWorld);const S=o.ray.origin.distanceTo(Ch);return S<o.near||S>o.far?null:{distance:S,point:Ch.clone(),object:M}}function Rh(M,n,o,l,u,p,g,y,b,S){M.getVertexPosition(y,wt),M.getVertexPosition(b,ss),M.getVertexPosition(S,Oa);const A=wy(M,n,o,l,wt,ss,Oa,Kg);if(A){const R=new ie;is.getBarycoord(Kg,wt,ss,Oa,R),u&&(A.uv=is.getInterpolatedAttribute(u,y,b,S,R,new dt)),p&&(A.uv1=is.getInterpolatedAttribute(p,y,b,S,R,new dt)),g&&(A.normal=is.getInterpolatedAttribute(g,y,b,S,R,new ie),A.normal.dot(l.direction)>0&&A.normal.multiplyScalar(-1));const N={a:y,b,c:S,normal:new ie,materialIndex:0};is.getNormal(wt,ss,Oa,N.normal),A.face=N,A.barycoord=R}return A}class zl extends $n{constructor(n=1,o=1,l=1,u=1,p=1,g=1){super(),this.type="BoxGeometry",this.parameters={width:n,height:o,depth:l,widthSegments:u,heightSegments:p,depthSegments:g};const y=this;u=Math.floor(u),p=Math.floor(p),g=Math.floor(g);const b=[],S=[],A=[],R=[];let N=0,L=0;I("z","y","x",-1,-1,l,o,n,g,p,0),I("z","y","x",1,-1,l,o,-n,g,p,1),I("x","z","y",1,1,n,l,o,u,g,2),I("x","z","y",1,-1,n,l,-o,u,g,3),I("x","y","z",1,-1,n,o,l,u,p,4),I("x","y","z",-1,-1,n,o,-l,u,p,5),this.setIndex(b),this.setAttribute("position",new Ht(S,3)),this.setAttribute("normal",new Ht(A,3)),this.setAttribute("uv",new Ht(R,2));function I(B,Z,q,ee,te,he,Re,ke,We,ze,lt){const mt=he/We,Zt=Re/ze,Bn=he/2,Hn=Re/2,pi=ke/2,ni=We+1,ur=ze+1;let vr=0,vs=0;const zi=new ie;for(let Qi=0;Qi<ur;Qi++){const Di=Qi*Zt-Hn;for(let js=0;js<ni;js++){const ls=js*mt-Bn;zi[B]=ls*ee,zi[Z]=Di*te,zi[q]=pi,S.push(zi.x,zi.y,zi.z),zi[B]=0,zi[Z]=0,zi[q]=ke>0?1:-1,A.push(zi.x,zi.y,zi.z),R.push(js/We),R.push(1-Qi/ze),vr+=1}}for(let Qi=0;Qi<ze;Qi++)for(let Di=0;Di<We;Di++){const js=N+Di+ni*Qi,ls=N+Di+ni*(Qi+1),hc=N+(Di+1)+ni*(Qi+1),Eu=N+(Di+1)+ni*Qi;b.push(js,ls,Eu),b.push(ls,hc,Eu),vs+=6}y.addGroup(L,vs,lt),L+=vs,N+=vr}}copy(n){return super.copy(n),this.parameters=Object.assign({},n.parameters),this}static fromJSON(n){return new zl(n.width,n.height,n.depth,n.widthSegments,n.heightSegments,n.depthSegments)}}function xs(M){const n={};for(const o in M){n[o]={};for(const l in M[o]){const u=M[o][l];u&&(u.isColor||u.isMatrix3||u.isMatrix4||u.isVector2||u.isVector3||u.isVector4||u.isTexture||u.isQuaternion)?u.isRenderTargetTexture?(dn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),n[o][l]=null):n[o][l]=u.clone():Array.isArray(u)?n[o][l]=u.slice():n[o][l]=u}}return n}function Vf(M){const n={};for(let o=0;o<M.length;o++){const l=xs(M[o]);for(const u in l)n[u]=l[u]}return n}function ka(M){const n=[];for(let o=0;o<M.length;o++)n.push(M[o].clone());return n}function Ay(M){const n=M.getRenderTarget();return n===null?M.outputColorSpace:n.isXRRenderTarget===!0?n.texture.colorSpace:$r.workingColorSpace}const Gl={clone:xs,merge:Vf};var Zg=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,zf=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`;class Wl extends Lr{constructor(n){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Zg,this.fragmentShader=zf,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,n!==void 0&&this.setValues(n)}copy(n){return super.copy(n),this.fragmentShader=n.fragmentShader,this.vertexShader=n.vertexShader,this.uniforms=xs(n.uniforms),this.uniformsGroups=ka(n.uniformsGroups),this.defines=Object.assign({},n.defines),this.wireframe=n.wireframe,this.wireframeLinewidth=n.wireframeLinewidth,this.fog=n.fog,this.lights=n.lights,this.clipping=n.clipping,this.extensions=Object.assign({},n.extensions),this.glslVersion=n.glslVersion,this}toJSON(n){const o=super.toJSON(n);o.glslVersion=this.glslVersion,o.uniforms={};for(const u in this.uniforms){const g=this.uniforms[u].value;g&&g.isTexture?o.uniforms[u]={type:"t",value:g.toJSON(n).uuid}:g&&g.isColor?o.uniforms[u]={type:"c",value:g.getHex()}:g&&g.isVector2?o.uniforms[u]={type:"v2",value:g.toArray()}:g&&g.isVector3?o.uniforms[u]={type:"v3",value:g.toArray()}:g&&g.isVector4?o.uniforms[u]={type:"v4",value:g.toArray()}:g&&g.isMatrix3?o.uniforms[u]={type:"m3",value:g.toArray()}:g&&g.isMatrix4?o.uniforms[u]={type:"m4",value:g.toArray()}:o.uniforms[u]={value:g}}Object.keys(this.defines).length>0&&(o.defines=this.defines),o.vertexShader=this.vertexShader,o.fragmentShader=this.fragmentShader,o.lights=this.lights,o.clipping=this.clipping;const l={};for(const u in this.extensions)this.extensions[u]===!0&&(l[u]=!0);return Object.keys(l).length>0&&(o.extensions=l),o}}class $c extends Ri{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Ln,this.projectionMatrix=new Ln,this.projectionMatrixInverse=new Ln,this.coordinateSystem=Mr,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(n,o){return super.copy(n,o),this.matrixWorldInverse.copy(n.matrixWorldInverse),this.projectionMatrix.copy(n.projectionMatrix),this.projectionMatrixInverse.copy(n.projectionMatrixInverse),this.coordinateSystem=n.coordinateSystem,this}getWorldDirection(n){return super.getWorldDirection(n).negate()}updateMatrixWorld(n){super.updateMatrixWorld(n),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(n,o){super.updateWorldMatrix(n,o),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const no=new ie,Yg=new dt,Gf=new dt;class os extends $c{constructor(n=50,o=1,l=.1,u=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=n,this.zoom=1,this.near=l,this.far=u,this.focus=10,this.aspect=o,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(n,o){return super.copy(n,o),this.fov=n.fov,this.zoom=n.zoom,this.near=n.near,this.far=n.far,this.focus=n.focus,this.aspect=n.aspect,this.view=n.view===null?null:Object.assign({},n.view),this.filmGauge=n.filmGauge,this.filmOffset=n.filmOffset,this}setFocalLength(n){const o=.5*this.getFilmHeight()/n;this.fov=Co*2*Math.atan(o),this.updateProjectionMatrix()}getFocalLength(){const n=Math.tan(Eo*.5*this.fov);return .5*this.getFilmHeight()/n}getEffectiveFOV(){return Co*2*Math.atan(Math.tan(Eo*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(n,o,l){no.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),o.set(no.x,no.y).multiplyScalar(-n/no.z),no.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),l.set(no.x,no.y).multiplyScalar(-n/no.z)}getViewSize(n,o){return this.getViewBounds(n,Yg,Gf),o.subVectors(Gf,Yg)}setViewOffset(n,o,l,u,p,g){this.aspect=n/o,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=n,this.view.fullHeight=o,this.view.offsetX=l,this.view.offsetY=u,this.view.width=p,this.view.height=g,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const n=this.near;let o=n*Math.tan(Eo*.5*this.fov)/this.zoom,l=2*o,u=this.aspect*l,p=-.5*u;const g=this.view;if(this.view!==null&&this.view.enabled){const b=g.fullWidth,S=g.fullHeight;p+=g.offsetX*u/b,o-=g.offsetY*l/S,u*=g.width/b,l*=g.height/S}const y=this.filmOffset;y!==0&&(p+=n*y/this.getFilmWidth()),this.projectionMatrix.makePerspective(p,p+u,o,o-l,n,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(n){const o=super.toJSON(n);return o.object.fov=this.fov,o.object.zoom=this.zoom,o.object.near=this.near,o.object.far=this.far,o.object.focus=this.focus,o.object.aspect=this.aspect,this.view!==null&&(o.object.view=Object.assign({},this.view)),o.object.filmGauge=this.filmGauge,o.object.filmOffset=this.filmOffset,o}}const Va=-90,Bs=1;class Qg extends Ri{constructor(n,o,l){super(),this.type="CubeCamera",this.renderTarget=l,this.coordinateSystem=null,this.activeMipmapLevel=0;const u=new os(Va,Bs,n,o);u.layers=this.layers,this.add(u);const p=new os(Va,Bs,n,o);p.layers=this.layers,this.add(p);const g=new os(Va,Bs,n,o);g.layers=this.layers,this.add(g);const y=new os(Va,Bs,n,o);y.layers=this.layers,this.add(y);const b=new os(Va,Bs,n,o);b.layers=this.layers,this.add(b);const S=new os(Va,Bs,n,o);S.layers=this.layers,this.add(S)}updateCoordinateSystem(){const n=this.coordinateSystem,o=this.children.concat(),[l,u,p,g,y,b]=o;for(const S of o)this.remove(S);if(n===Mr)l.up.set(0,1,0),l.lookAt(1,0,0),u.up.set(0,1,0),u.lookAt(-1,0,0),p.up.set(0,0,-1),p.lookAt(0,1,0),g.up.set(0,0,1),g.lookAt(0,-1,0),y.up.set(0,1,0),y.lookAt(0,0,1),b.up.set(0,1,0),b.lookAt(0,0,-1);else if(n===Ia)l.up.set(0,-1,0),l.lookAt(-1,0,0),u.up.set(0,-1,0),u.lookAt(1,0,0),p.up.set(0,0,1),p.lookAt(0,1,0),g.up.set(0,0,-1),g.lookAt(0,-1,0),y.up.set(0,-1,0),y.lookAt(0,0,1),b.up.set(0,-1,0),b.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+n);for(const S of o)this.add(S),S.updateMatrixWorld()}update(n,o){this.parent===null&&this.updateMatrixWorld();const{renderTarget:l,activeMipmapLevel:u}=this;this.coordinateSystem!==n.coordinateSystem&&(this.coordinateSystem=n.coordinateSystem,this.updateCoordinateSystem());const[p,g,y,b,S,A]=this.children,R=n.getRenderTarget(),N=n.getActiveCubeFace(),L=n.getActiveMipmapLevel(),I=n.xr.enabled;n.xr.enabled=!1;const B=l.texture.generateMipmaps;l.texture.generateMipmaps=!1,n.setRenderTarget(l,0,u),n.render(o,p),n.setRenderTarget(l,1,u),n.render(o,g),n.setRenderTarget(l,2,u),n.render(o,y),n.setRenderTarget(l,3,u),n.render(o,b),n.setRenderTarget(l,4,u),n.render(o,S),l.texture.generateMipmaps=B,n.setRenderTarget(l,5,u),n.render(o,A),n.setRenderTarget(R,N,L),n.xr.enabled=I,l.texture.needsPMREMUpdate=!0}}class Nh extends sr{constructor(n=[],o=th,l,u,p,g,y,b,S,A){super(n,o,l,u,p,g,y,b,S,A),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(n){this.image=n}}class Jg extends Bg{constructor(n=1,o={}){super(n,n,o),this.isWebGLCubeRenderTarget=!0;const l={width:n,height:n,depth:1},u=[l,l,l,l,l,l];this.texture=new Nh(u),this._setTextureOptions(o),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(n,o){this.texture.type=o.type,this.texture.colorSpace=o.colorSpace,this.texture.generateMipmaps=o.generateMipmaps,this.texture.minFilter=o.minFilter,this.texture.magFilter=o.magFilter;const l={uniforms:{tEquirect:{value:null}},vertexShader:`
varying vec3 vWorldDirection;
vec3 transformDirection( in vec3 dir, in mat4 matrix ) {
return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );
}
void main() {
vWorldDirection = transformDirection( position, modelMatrix );
#include <begin_vertex>
#include <project_vertex>
}
`,fragmentShader:`
uniform sampler2D tEquirect;
varying vec3 vWorldDirection;
#include <common>
void main() {
vec3 direction = normalize( vWorldDirection );
vec2 sampleUV = equirectUv( direction );
gl_FragColor = texture2D( tEquirect, sampleUV );
}
`},u=new zl(5,5,5),p=new Wl({name:"CubemapFromEquirect",uniforms:xs(l.uniforms),vertexShader:l.vertexShader,fragmentShader:l.fragmentShader,side:Ae,blending:ye});p.uniforms.tEquirect.value=o;const g=new aa(u,p),y=o.minFilter;return o.minFilter===El&&(o.minFilter=Yr),new Qg(1,10,this).update(n,g),o.minFilter=y,g.geometry.dispose(),g.material.dispose(),this}clear(n,o=!0,l=!0,u=!0){const p=n.getRenderTarget();for(let g=0;g<6;g++)n.setRenderTarget(this,g),n.clear(o,l,u);n.setRenderTarget(p)}}class za extends Ri{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Ph={type:"move"};class Ey{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new za,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand}getTargetRaySpace(){return this._targetRay===null&&(this._targetRay=new za,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new ie,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new ie),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new za,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new ie,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new ie),this._grip}dispatchEvent(n){return this._targetRay!==null&&this._targetRay.dispatchEvent(n),this._grip!==null&&this._grip.dispatchEvent(n),this._hand!==null&&this._hand.dispatchEvent(n),this}connect(n){if(n&&n.hand){const o=this._hand;if(o)for(const l of n.hand.values())this._getHandJoint(o,l)}return this.dispatchEvent({type:"connected",data:n}),this}disconnect(n){return this.dispatchEvent({type:"disconnected",data:n}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(n,o,l){let u=null,p=null,g=null;const y=this._targetRay,b=this._grip,S=this._hand;if(n&&o.session.visibilityState!=="visible-blurred"){if(S&&n.hand){g=!0;for(const B of n.hand.values()){const Z=o.getJointPose(B,l),q=this._getHandJoint(S,B);Z!==null&&(q.matrix.fromArray(Z.transform.matrix),q.matrix.decompose(q.position,q.rotation,q.scale),q.matrixWorldNeedsUpdate=!0,q.jointRadius=Z.radius),q.visible=Z!==null}const A=S.joints["index-finger-tip"],R=S.joints["thumb-tip"],N=A.position.distanceTo(R.position),L=.02,I=.005;S.inputState.pinching&&N>L+I?(S.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:n.handedness,target:this})):!S.inputState.pinching&&N<=L-I&&(S.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:n.handedness,target:this}))}else b!==null&&n.gripSpace&&(p=o.getPose(n.gripSpace,l),p!==null&&(b.matrix.fromArray(p.transform.matrix),b.matrix.decompose(b.position,b.rotation,b.scale),b.matrixWorldNeedsUpdate=!0,p.linearVelocity?(b.hasLinearVelocity=!0,b.linearVelocity.copy(p.linearVelocity)):b.hasLinearVelocity=!1,p.angularVelocity?(b.hasAngularVelocity=!0,b.angularVelocity.copy(p.angularVelocity)):b.hasAngularVelocity=!1));y!==null&&(u=o.getPose(n.targetRaySpace,l),u===null&&p!==null&&(u=p),u!==null&&(y.matrix.fromArray(u.transform.matrix),y.matrix.decompose(y.position,y.rotation,y.scale),y.matrixWorldNeedsUpdate=!0,u.linearVelocity?(y.hasLinearVelocity=!0,y.linearVelocity.copy(u.linearVelocity)):y.hasLinearVelocity=!1,u.angularVelocity?(y.hasAngularVelocity=!0,y.angularVelocity.copy(u.angularVelocity)):y.hasAngularVelocity=!1,this.dispatchEvent(Ph)))}return y!==null&&(y.visible=u!==null),b!==null&&(b.visible=p!==null),S!==null&&(S.visible=g!==null),this}_getHandJoint(n,o){if(n.joints[o.jointName]===void 0){const l=new za;l.matrixAutoUpdate=!1,l.visible=!1,n.joints[o.jointName]=l,n.add(l)}return n.joints[o.jointName]}}class Wf{constructor(n,o=25e-5){this.isFogExp2=!0,this.name="",this.color=new Nn(n),this.density=o}clone(){return new Wf(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Hf{constructor(n,o=1,l=1e3){this.isFog=!0,this.name="",this.color=new Nn(n),this.near=o,this.far=l}clone(){return new Hf(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class e0 extends Ri{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 Ds,this.environmentIntensity=1,this.environmentRotation=new Ds,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(n,o){return super.copy(n,o),n.background!==null&&(this.background=n.background.clone()),n.environment!==null&&(this.environment=n.environment.clone()),n.fog!==null&&(this.fog=n.fog.clone()),this.backgroundBlurriness=n.backgroundBlurriness,this.backgroundIntensity=n.backgroundIntensity,this.backgroundRotation.copy(n.backgroundRotation),this.environmentIntensity=n.environmentIntensity,this.environmentRotation.copy(n.environmentRotation),n.overrideMaterial!==null&&(this.overrideMaterial=n.overrideMaterial.clone()),this.matrixAutoUpdate=n.matrixAutoUpdate,this}toJSON(n){const o=super.toJSON(n);return this.fog!==null&&(o.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(o.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(o.object.backgroundIntensity=this.backgroundIntensity),o.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(o.object.environmentIntensity=this.environmentIntensity),o.object.environmentRotation=this.environmentRotation.toArray(),o}}class Lh{constructor(n,o){this.isInterleavedBuffer=!0,this.array=n,this.stride=o,this.count=n!==void 0?n.length/o:0,this.usage=Pc,this.updateRanges=[],this.version=0,this.uuid=gr()}onUploadCallback(){}set needsUpdate(n){n===!0&&this.version++}setUsage(n){return this.usage=n,this}addUpdateRange(n,o){this.updateRanges.push({start:n,count:o})}clearUpdateRanges(){this.updateRanges.length=0}copy(n){return this.array=new n.array.constructor(n.array),this.count=n.count,this.stride=n.stride,this.usage=n.usage,this}copyAt(n,o,l){n*=this.stride,l*=o.stride;for(let u=0,p=this.stride;u<p;u++)this.array[n+u]=o.array[l+u];return this}set(n,o=0){return this.array.set(n,o),this}clone(n){n.arrayBuffers===void 0&&(n.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=gr()),n.arrayBuffers[this.array.buffer._uuid]===void 0&&(n.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const o=new this.array.constructor(n.arrayBuffers[this.array.buffer._uuid]),l=new this.constructor(o,this.stride);return l.setUsage(this.usage),l}onUpload(n){return this.onUploadCallback=n,this}toJSON(n){return n.arrayBuffers===void 0&&(n.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=gr()),n.arrayBuffers[this.array.buffer._uuid]===void 0&&(n.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Ir=new ie;class Ga{constructor(n,o,l,u=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=n,this.itemSize=o,this.offset=l,this.normalized=u}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(n){this.data.needsUpdate=n}applyMatrix4(n){for(let o=0,l=this.data.count;o<l;o++)Ir.fromBufferAttribute(this,o),Ir.applyMatrix4(n),this.setXYZ(o,Ir.x,Ir.y,Ir.z);return this}applyNormalMatrix(n){for(let o=0,l=this.count;o<l;o++)Ir.fromBufferAttribute(this,o),Ir.applyNormalMatrix(n),this.setXYZ(o,Ir.x,Ir.y,Ir.z);return this}transformDirection(n){for(let o=0,l=this.count;o<l;o++)Ir.fromBufferAttribute(this,o),Ir.transformDirection(n),this.setXYZ(o,Ir.x,Ir.y,Ir.z);return this}getComponent(n,o){let l=this.array[n*this.data.stride+this.offset+o];return this.normalized&&(l=Nr(l,this.array)),l}setComponent(n,o,l){return this.normalized&&(l=Fn(l,this.array)),this.data.array[n*this.data.stride+this.offset+o]=l,this}setX(n,o){return this.normalized&&(o=Fn(o,this.array)),this.data.array[n*this.data.stride+this.offset]=o,this}setY(n,o){return this.normalized&&(o=Fn(o,this.array)),this.data.array[n*this.data.stride+this.offset+1]=o,this}setZ(n,o){return this.normalized&&(o=Fn(o,this.array)),this.data.array[n*this.data.stride+this.offset+2]=o,this}setW(n,o){return this.normalized&&(o=Fn(o,this.array)),this.data.array[n*this.data.stride+this.offset+3]=o,this}getX(n){let o=this.data.array[n*this.data.stride+this.offset];return this.normalized&&(o=Nr(o,this.array)),o}getY(n){let o=this.data.array[n*this.data.stride+this.offset+1];return this.normalized&&(o=Nr(o,this.array)),o}getZ(n){let o=this.data.array[n*this.data.stride+this.offset+2];return this.normalized&&(o=Nr(o,this.array)),o}getW(n){let o=this.data.array[n*this.data.stride+this.offset+3];return this.normalized&&(o=Nr(o,this.array)),o}setXY(n,o,l){return n=n*this.data.stride+this.offset,this.normalized&&(o=Fn(o,this.array),l=Fn(l,this.array)),this.data.array[n+0]=o,this.data.array[n+1]=l,this}setXYZ(n,o,l,u){return n=n*this.data.stride+this.offset,this.normalized&&(o=Fn(o,this.array),l=Fn(l,this.array),u=Fn(u,this.array)),this.data.array[n+0]=o,this.data.array[n+1]=l,this.data.array[n+2]=u,this}setXYZW(n,o,l,u,p){return n=n*this.data.stride+this.offset,this.normalized&&(o=Fn(o,this.array),l=Fn(l,this.array),u=Fn(u,this.array),p=Fn(p,this.array)),this.data.array[n+0]=o,this.data.array[n+1]=l,this.data.array[n+2]=u,this.data.array[n+3]=p,this}clone(n){if(n===void 0){ts("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const o=[];for(let l=0;l<this.count;l++){const u=l*this.data.stride+this.offset;for(let p=0;p<this.itemSize;p++)o.push(this.data.array[u+p])}return new dr(new this.array.constructor(o),this.itemSize,this.normalized)}else return n.interleavedBuffers===void 0&&(n.interleavedBuffers={}),n.interleavedBuffers[this.data.uuid]===void 0&&(n.interleavedBuffers[this.data.uuid]=this.data.clone(n)),new Ga(n.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(n){if(n===void 0){ts("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const o=[];for(let l=0;l<this.count;l++){const u=l*this.data.stride+this.offset;for(let p=0;p<this.itemSize;p++)o.push(this.data.array[u+p])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:o,normalized:this.normalized}}else return n.interleavedBuffers===void 0&&(n.interleavedBuffers={}),n.interleavedBuffers[this.data.uuid]===void 0&&(n.interleavedBuffers[this.data.uuid]=this.data.toJSON(n)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Ih extends Lr{constructor(n){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Nn(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(n)}copy(n){return super.copy(n),this.color.copy(n.color),this.map=n.map,this.alphaMap=n.alphaMap,this.rotation=n.rotation,this.sizeAttenuation=n.sizeAttenuation,this.fog=n.fog,this}}let Wa;const jc=new ie,Ha=new ie,$a=new ie,ja=new dt,Xc=new dt,$f=new Ln,Hl=new ie,qc=new ie,Fo=new ie,Zi=new dt,$i=new dt,$l=new dt;class t0 extends Ri{constructor(n=new Ih){if(super(),this.isSprite=!0,this.type="Sprite",Wa===void 0){Wa=new $n;const o=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),l=new Lh(o,5);Wa.setIndex([0,1,2,0,2,3]),Wa.setAttribute("position",new Ga(l,3,0,!1)),Wa.setAttribute("uv",new Ga(l,2,3,!1))}this.geometry=Wa,this.material=n,this.center=new dt(.5,.5),this.count=1}raycast(n,o){n.camera===null&&Yn('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Ha.setFromMatrixScale(this.matrixWorld),$f.copy(n.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(n.camera.matrixWorldInverse,this.matrixWorld),$a.setFromMatrixPosition(this.modelViewMatrix),n.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Ha.multiplyScalar(-$a.z);const l=this.material.rotation;let u,p;l!==0&&(p=Math.cos(l),u=Math.sin(l));const g=this.center;Dh(Hl.set(-.5,-.5,0),$a,g,Ha,u,p),Dh(qc.set(.5,-.5,0),$a,g,Ha,u,p),Dh(Fo.set(.5,.5,0),$a,g,Ha,u,p),Zi.set(0,0),$i.set(1,0),$l.set(1,1);let y=n.ray.intersectTriangle(Hl,qc,Fo,!1,jc);if(y===null&&(Dh(qc.set(-.5,.5,0),$a,g,Ha,u,p),$i.set(0,1),y=n.ray.intersectTriangle(Hl,Fo,qc,!1,jc),y===null))return;const b=n.ray.origin.distanceTo(jc);b<n.near||b>n.far||o.push({distance:b,point:jc.clone(),uv:is.getInterpolation(jc,Hl,qc,Fo,Zi,$i,$l,new dt),face:null,object:this})}copy(n,o){return super.copy(n,o),n.center!==void 0&&this.center.copy(n.center),this.material=n.material,this}}function Dh(M,n,o,l,u,p){ja.subVectors(M,o).addScalar(.5).multiply(l),u!==void 0?(Xc.x=p*ja.x-u*ja.y,Xc.y=u*ja.x+p*ja.y):Xc.copy(ja),M.copy(n),M.x+=Xc.x,M.y+=Xc.y,M.applyMatrix4($f)}const Uh=new ie,n0=new ie;class Cy extends null{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(n){super.copy(n,!1);const o=n.levels;for(let l=0,u=o.length;l<u;l++){const p=o[l];this.addLevel(p.object.clone(),p.distance,p.hysteresis)}return this.autoUpdate=n.autoUpdate,this}addLevel(n,o=0,l=0){o=Math.abs(o);const u=this.levels;let p;for(p=0;p<u.length&&!(o<u[p].distance);p++);return u.splice(p,0,{distance:o,hysteresis:l,object:n}),this.add(n),this}removeLevel(n){const o=this.levels;for(let l=0;l<o.length;l++)if(o[l].distance===n){const u=o.splice(l,1);return this.remove(u[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(n){const o=this.levels;if(o.length>0){let l,u;for(l=1,u=o.length;l<u;l++){let p=o[l].distance;if(o[l].object.visible&&(p-=p*o[l].hysteresis),n<p)break}return o[l-1].object}return null}raycast(n,o){if(this.levels.length>0){Uh.setFromMatrixPosition(this.matrixWorld);const u=n.ray.origin.distanceTo(Uh);this.getObjectForDistance(u).raycast(n,o)}}update(n){const o=this.levels;if(o.length>1){Uh.setFromMatrixPosition(n.matrixWorld),n0.setFromMatrixPosition(this.matrixWorld);const l=Uh.distanceTo(n0)/n.zoom;o[0].object.visible=!0;let u,p;for(u=1,p=o.length;u<p;u++){let g=o[u].distance;if(o[u].object.visible&&(g-=g*o[u].hysteresis),l>=g)o[u-1].object.visible=!1,o[u].object.visible=!0;else break}for(this._currentLevel=u-1;u<p;u++)o[u].object.visible=!1}}toJSON(n){const o=super.toJSON(n);this.autoUpdate===!1&&(o.object.autoUpdate=!1),o.object.levels=[];const l=this.levels;for(let u=0,p=l.length;u<p;u++){const g=l[u];o.object.levels.push({object:g.object.uuid,distance:g.distance,hysteresis:g.hysteresis})}return o}}const i0=new ie,r0=new or,s0=new or,Ry=new ie,o0=new Ln,Fh=new ie,jf=new xr,a0=new Ln,Xf=new Bc;class Ny extends null{constructor(n,o){super(n,o),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Om,this.bindMatrix=new Ln,this.bindMatrixInverse=new Ln,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const n=this.geometry;this.boundingBox===null&&(this.boundingBox=new wr),this.boundingBox.makeEmpty();const o=n.getAttribute("position");for(let l=0;l<o.count;l++)this.getVertexPosition(l,Fh),this.boundingBox.expandByPoint(Fh)}computeBoundingSphere(){const n=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new xr),this.boundingSphere.makeEmpty();const o=n.getAttribute("position");for(let l=0;l<o.count;l++)this.getVertexPosition(l,Fh),this.boundingSphere.expandByPoint(Fh)}copy(n,o){return super.copy(n,o),this.bindMode=n.bindMode,this.bindMatrix.copy(n.bindMatrix),this.bindMatrixInverse.copy(n.bindMatrixInverse),this.skeleton=n.skeleton,n.boundingBox!==null&&(this.boundingBox=n.boundingBox.clone()),n.boundingSphere!==null&&(this.boundingSphere=n.boundingSphere.clone()),this}raycast(n,o){const l=this.material,u=this.matrixWorld;l!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),jf.copy(this.boundingSphere),jf.applyMatrix4(u),n.ray.intersectsSphere(jf)!==!1&&(a0.copy(u).invert(),Xf.copy(n.ray).applyMatrix4(a0),!(this.boundingBox!==null&&Xf.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(n,o,Xf)))}getVertexPosition(n,o){return super.getVertexPosition(n,o),this.applyBoneTransform(n,o),o}bind(n,o){this.skeleton=n,o===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),o=this.matrixWorld),this.bindMatrix.copy(o),this.bindMatrixInverse.copy(o).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const n=new or,o=this.geometry.attributes.skinWeight;for(let l=0,u=o.count;l<u;l++){n.fromBufferAttribute(o,l);const p=1/n.manhattanLength();p!==1/0?n.multiplyScalar(p):n.set(1,0,0,0),o.setXYZW(l,n.x,n.y,n.z,n.w)}}updateMatrixWorld(n){super.updateMatrixWorld(n),this.bindMode===Om?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===A_?this.bindMatrixInverse.copy(this.bindMatrix).invert():dn("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(n,o){const l=this.skeleton,u=this.geometry;r0.fromBufferAttribute(u.attributes.skinIndex,n),s0.fromBufferAttribute(u.attributes.skinWeight,n),i0.copy(o).applyMatrix4(this.bindMatrix),o.set(0,0,0);for(let p=0;p<4;p++){const g=s0.getComponent(p);if(g!==0){const y=r0.getComponent(p);o0.multiplyMatrices(l.bones[y].matrixWorld,l.boneInverses[y]),o.addScaledVector(Ry.copy(i0).applyMatrix4(o0),g)}}return o.applyMatrix4(this.bindMatrixInverse)}}class c0 extends null{constructor(){super(),this.isBone=!0,this.type="Bone"}}class io extends sr{constructor(n=null,o=1,l=1,u,p,g,y,b,S=ps,A=ps,R,N){super(null,g,y,b,S,A,u,p,R,N),this.isDataTexture=!0,this.image={data:n,width:o,height:l},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const l0=new Ln,Py=new Ln;class qf{constructor(n=[],o=[]){this.uuid=gr(),this.bones=n.slice(0),this.boneInverses=o,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const n=this.bones,o=this.boneInverses;if(this.boneMatrices=new Float32Array(n.length*16),o.length===0)this.calculateInverses();else if(n.length!==o.length){dn("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let l=0,u=this.bones.length;l<u;l++)this.boneInverses.push(new Ln)}}calculateInverses(){this.boneInverses.length=0;for(let n=0,o=this.bones.length;n<o;n++){const l=new Ln;this.bones[n]&&l.copy(this.bones[n].matrixWorld).invert(),this.boneInverses.push(l)}}pose(){for(let n=0,o=this.bones.length;n<o;n++){const l=this.bones[n];l&&l.matrixWorld.copy(this.boneInverses[n]).invert()}for(let n=0,o=this.bones.length;n<o;n++){const l=this.bones[n];l&&(l.parent&&l.parent.isBone?(l.matrix.copy(l.parent.matrixWorld).invert(),l.matrix.multiply(l.matrixWorld)):l.matrix.copy(l.matrixWorld),l.matrix.decompose(l.position,l.quaternion,l.scale))}}update(){const n=this.bones,o=this.boneInverses,l=this.boneMatrices,u=this.boneTexture;for(let p=0,g=n.length;p<g;p++){const y=n[p]?n[p].matrixWorld:Py;l0.multiplyMatrices(y,o[p]),l0.toArray(l,p*16)}u!==null&&(u.needsUpdate=!0)}clone(){return new qf(this.bones,this.boneInverses)}computeBoneTexture(){let n=Math.sqrt(this.bones.length*4);n=Math.ceil(n/4)*4,n=Math.max(n,4);const o=new Float32Array(n*n*4);o.set(this.boneMatrices);const l=new io(o,n,n,wo,Jo);return l.needsUpdate=!0,this.boneMatrices=o,this.boneTexture=l,this}getBoneByName(n){for(let o=0,l=this.bones.length;o<l;o++){const u=this.bones[o];if(u.name===n)return u}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(n,o){this.uuid=n.uuid;for(let l=0,u=n.bones.length;l<u;l++){const p=n.bones[l];let g=o[p];g===void 0&&(dn("Skeleton: No bone found with UUID:",p),g=new c0),this.bones.push(g),this.boneInverses.push(new Ln().fromArray(n.boneInverses[l]))}return this.init(),this}toJSON(){const n={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};n.uuid=this.uuid;const o=this.bones,l=this.boneInverses;for(let u=0,p=o.length;u<p;u++){const g=o[u];n.bones.push(g.uuid);const y=l[u];n.boneInverses.push(y.toArray())}return n}}class Kc extends dr{constructor(n,o,l,u=1){super(n,o,l),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=u}copy(n){return super.copy(n),this.meshPerAttribute=n.meshPerAttribute,this}toJSON(){const n=super.toJSON();return n.meshPerAttribute=this.meshPerAttribute,n.isInstancedBufferAttribute=!0,n}}const Zc=new Ln,u0=new Ln,Bh=null,h0=new wr,Ly=new Ln,jl=new aa,Xl=new xr;class Iy extends null{constructor(n,o,l){super(n,o),this.isInstancedMesh=!0,this.instanceMatrix=new Kc(new Float32Array(l*16),16),this.instanceColor=null,this.morphTexture=null,this.count=l,this.boundingBox=null,this.boundingSphere=null;for(let u=0;u<l;u++)this.setMatrixAt(u,Ly)}computeBoundingBox(){const n=this.geometry,o=this.count;this.boundingBox===null&&(this.boundingBox=new wr),n.boundingBox===null&&n.computeBoundingBox(),this.boundingBox.makeEmpty();for(let l=0;l<o;l++)this.getMatrixAt(l,Zc),h0.copy(n.boundingBox).applyMatrix4(Zc),this.boundingBox.union(h0)}computeBoundingSphere(){const n=this.geometry,o=this.count;this.boundingSphere===null&&(this.boundingSphere=new xr),n.boundingSphere===null&&n.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let l=0;l<o;l++)this.getMatrixAt(l,Zc),Xl.copy(n.boundingSphere).applyMatrix4(Zc),this.boundingSphere.union(Xl)}copy(n,o){return super.copy(n,o),this.instanceMatrix.copy(n.instanceMatrix),n.morphTexture!==null&&(this.morphTexture=n.morphTexture.clone()),n.instanceColor!==null&&(this.instanceColor=n.instanceColor.clone()),this.count=n.count,n.boundingBox!==null&&(this.boundingBox=n.boundingBox.clone()),n.boundingSphere!==null&&(this.boundingSphere=n.boundingSphere.clone()),this}getColorAt(n,o){o.fromArray(this.instanceColor.array,n*3)}getMatrixAt(n,o){o.fromArray(this.instanceMatrix.array,n*16)}getMorphAt(n,o){const l=o.morphTargetInfluences,u=this.morphTexture.source.data.data,p=l.length+1,g=n*p+1;for(let y=0;y<l.length;y++)l[y]=u[g+y]}raycast(n,o){const l=this.matrixWorld,u=this.count;if(jl.geometry=this.geometry,jl.material=this.material,jl.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Xl.copy(this.boundingSphere),Xl.applyMatrix4(l),n.ray.intersectsSphere(Xl)!==!1))for(let p=0;p<u;p++){this.getMatrixAt(p,Zc),u0.multiplyMatrices(l,Zc),jl.matrixWorld=u0,jl.raycast(n,Bh);for(let g=0,y=Bh.length;g<y;g++){const b=Bh[g];b.instanceId=p,b.object=this,o.push(b)}Bh.length=0}}setColorAt(n,o){this.instanceColor===null&&(this.instanceColor=new Kc(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),o.toArray(this.instanceColor.array,n*3)}setMatrixAt(n,o){o.toArray(this.instanceMatrix.array,n*16)}setMorphAt(n,o){const l=o.morphTargetInfluences,u=l.length+1;this.morphTexture===null&&(this.morphTexture=new io(new Float32Array(u*this.count),u,this.count,Qd,Jo));const p=this.morphTexture.source.data.data;let g=0;for(let S=0;S<l.length;S++)g+=l[S];const y=this.geometry.morphTargetsRelative?1:1-g,b=u*n;p[b]=y,p.set(l,b+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Kf=new ie,Dy=new ie,Uy=new Ps;class Xa{constructor(n=new ie(1,0,0),o=0){this.isPlane=!0,this.normal=n,this.constant=o}set(n,o){return this.normal.copy(n),this.constant=o,this}setComponents(n,o,l,u){return this.normal.set(n,o,l),this.constant=u,this}setFromNormalAndCoplanarPoint(n,o){return this.normal.copy(n),this.constant=-o.dot(this.normal),this}setFromCoplanarPoints(n,o,l){const u=Kf.subVectors(l,o).cross(Dy.subVectors(n,o)).normalize();return this.setFromNormalAndCoplanarPoint(u,n),this}copy(n){return this.normal.copy(n.normal),this.constant=n.constant,this}normalize(){const n=1/this.normal.length();return this.normal.multiplyScalar(n),this.constant*=n,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(n){return this.normal.dot(n)+this.constant}distanceToSphere(n){return this.distanceToPoint(n.center)-n.radius}projectPoint(n,o){return o.copy(n).addScaledVector(this.normal,-this.distanceToPoint(n))}intersectLine(n,o){const l=n.delta(Kf),u=this.normal.dot(l);if(u===0)return this.distanceToPoint(n.start)===0?o.copy(n.start):null;const p=-(n.start.dot(this.normal)+this.constant)/u;return p<0||p>1?null:o.copy(n.start).addScaledVector(l,p)}intersectsLine(n){const o=this.distanceToPoint(n.start),l=this.distanceToPoint(n.end);return o<0&&l>0||l<0&&o>0}intersectsBox(n){return n.intersectsPlane(this)}intersectsSphere(n){return n.intersectsPlane(this)}coplanarPoint(n){return n.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(n,o){const l=o||Uy.getNormalMatrix(n),u=this.coplanarPoint(Kf).applyMatrix4(n),p=this.normal.applyMatrix3(l).normalize();return this.constant=-u.dot(p),this}translate(n){return this.constant-=n.dot(this.normal),this}equals(n){return n.normal.equals(this.normal)&&n.constant===this.constant}clone(){return new this.constructor().copy(this)}}const qa=new xr,Fy=new dt(.5,.5),Oh=new ie;class kh{constructor(n=new Xa,o=new Xa,l=new Xa,u=new Xa,p=new Xa,g=new Xa){this.planes=[n,o,l,u,p,g]}set(n,o,l,u,p,g){const y=this.planes;return y[0].copy(n),y[1].copy(o),y[2].copy(l),y[3].copy(u),y[4].copy(p),y[5].copy(g),this}copy(n){const o=this.planes;for(let l=0;l<6;l++)o[l].copy(n.planes[l]);return this}setFromProjectionMatrix(n,o=Mr,l=!1){const u=this.planes,p=n.elements,g=p[0],y=p[1],b=p[2],S=p[3],A=p[4],R=p[5],N=p[6],L=p[7],I=p[8],B=p[9],Z=p[10],q=p[11],ee=p[12],te=p[13],he=p[14],Re=p[15];if(u[0].setComponents(S-g,L-A,q-I,Re-ee).normalize(),u[1].setComponents(S+g,L+A,q+I,Re+ee).normalize(),u[2].setComponents(S+y,L+R,q+B,Re+te).normalize(),u[3].setComponents(S-y,L-R,q-B,Re-te).normalize(),l)u[4].setComponents(b,N,Z,he).normalize(),u[5].setComponents(S-b,L-N,q-Z,Re-he).normalize();else if(u[4].setComponents(S-b,L-N,q-Z,Re-he).normalize(),o===Mr)u[5].setComponents(S+b,L+N,q+Z,Re+he).normalize();else if(o===Ia)u[5].setComponents(b,N,Z,he).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+o);return this}intersectsObject(n){if(n.boundingSphere!==void 0)n.boundingSphere===null&&n.computeBoundingSphere(),qa.copy(n.boundingSphere).applyMatrix4(n.matrixWorld);else{const o=n.geometry;o.boundingSphere===null&&o.computeBoundingSphere(),qa.copy(o.boundingSphere).applyMatrix4(n.matrixWorld)}return this.intersectsSphere(qa)}intersectsSprite(n){qa.center.set(0,0,0);const o=Fy.distanceTo(n.center);return qa.radius=.7071067811865476+o,qa.applyMatrix4(n.matrixWorld),this.intersectsSphere(qa)}intersectsSphere(n){const o=this.planes,l=n.center,u=-n.radius;for(let p=0;p<6;p++)if(o[p].distanceToPoint(l)<u)return!1;return!0}intersectsBox(n){const o=this.planes;for(let l=0;l<6;l++){const u=o[l];if(Oh.x=u.normal.x>0?n.max.x:n.min.x,Oh.y=u.normal.y>0?n.max.y:n.min.y,Oh.z=u.normal.z>0?n.max.z:n.min.z,u.distanceToPoint(Oh)<0)return!1}return!0}containsPoint(n){const o=this.planes;for(let l=0;l<6;l++)if(o[l].distanceToPoint(n)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}const ro=new Ln,so=new kh;class Vh{constructor(){this.coordinateSystem=Mr}intersectsObject(n,o){if(!o.isArrayCamera||o.cameras.length===0)return!1;for(let l=0;l<o.cameras.length;l++){const u=o.cameras[l];if(ro.multiplyMatrices(u.projectionMatrix,u.matrixWorldInverse),so.setFromProjectionMatrix(ro,u.coordinateSystem,u.reversedDepth),so.intersectsObject(n))return!0}return!1}intersectsSprite(n,o){if(!o||!o.cameras||o.cameras.length===0)return!1;for(let l=0;l<o.cameras.length;l++){const u=o.cameras[l];if(ro.multiplyMatrices(u.projectionMatrix,u.matrixWorldInverse),so.setFromProjectionMatrix(ro,u.coordinateSystem,u.reversedDepth),so.intersectsSprite(n))return!0}return!1}intersectsSphere(n,o){if(!o||!o.cameras||o.cameras.length===0)return!1;for(let l=0;l<o.cameras.length;l++){const u=o.cameras[l];if(ro.multiplyMatrices(u.projectionMatrix,u.matrixWorldInverse),so.setFromProjectionMatrix(ro,u.coordinateSystem,u.reversedDepth),so.intersectsSphere(n))return!0}return!1}intersectsBox(n,o){if(!o||!o.cameras||o.cameras.length===0)return!1;for(let l=0;l<o.cameras.length;l++){const u=o.cameras[l];if(ro.multiplyMatrices(u.projectionMatrix,u.matrixWorldInverse),so.setFromProjectionMatrix(ro,u.coordinateSystem,u.reversedDepth),so.intersectsBox(n))return!0}return!1}containsPoint(n,o){if(!o||!o.cameras||o.cameras.length===0)return!1;for(let l=0;l<o.cameras.length;l++){const u=o.cameras[l];if(ro.multiplyMatrices(u.projectionMatrix,u.matrixWorldInverse),so.setFromProjectionMatrix(ro,u.coordinateSystem,u.reversedDepth),so.containsPoint(n))return!0}return!1}clone(){return new Vh}}function Zf(M,n){return M-n}function By(M,n){return M.z-n.z}function Oy(M,n){return n.z-M.z}class Yf{constructor(){this.index=0,this.pool=[],this.list=[]}push(n,o,l,u){const p=this.pool,g=this.list;this.index>=p.length&&p.push({start:-1,count:-1,z:-1,index:-1});const y=p[this.index];g.push(y),this.index++,y.start=n,y.count=o,y.z=l,y.index=u}reset(){this.list.length=0,this.index=0}}const Dr=new Ln,ky=new Nn(1,1,1),ql=new kh,d0=new Vh,zh=new wr,Ka=new xr,Kl=new ie,Qf=new ie,Vy=new ie,Gh=new Yf,Ar=new aa,Wh=null;function Hh(M,n,o=0){const l=n.itemSize;if(M.isInterleavedBufferAttribute||M.array.constructor!==n.array.constructor){const u=M.count;for(let p=0;p<u;p++)for(let g=0;g<l;g++)n.setComponent(p+o,g,M.getComponent(p,g))}else n.array.set(M.array,o*l);n.needsUpdate=!0}function Za(M,n){if(M.constructor!==n.constructor){const o=Math.min(M.length,n.length);for(let l=0;l<o;l++)n[l]=M[l]}else{const o=Math.min(M.length,n.length);n.set(new M.constructor(M.buffer,0,o))}}class zy extends null{constructor(n,o,l=o*2,u){super(new $n,u),this.isBatchedMesh=!0,this.perObjectFrustumCulled=!0,this.sortObjects=!0,this.boundingBox=null,this.boundingSphere=null,this.customSort=null,this._instanceInfo=[],this._geometryInfo=[],this._availableInstanceIds=[],this._availableGeometryIds=[],this._nextIndexStart=0,this._nextVertexStart=0,this._geometryCount=0,this._visibilityChanged=!0,this._geometryInitialized=!1,this._maxInstanceCount=n,this._maxVertexCount=o,this._maxIndexCount=l,this._multiDrawCounts=new Int32Array(n),this._multiDrawStarts=new Int32Array(n),this._multiDrawCount=0,this._multiDrawInstances=null,this._matricesTexture=null,this._indirectTexture=null,this._colorsTexture=null,this._initMatricesTexture(),this._initIndirectTexture()}get maxInstanceCount(){return this._maxInstanceCount}get instanceCount(){return this._instanceInfo.length-this._availableInstanceIds.length}get unusedVertexCount(){return this._maxVertexCount-this._nextVertexStart}get unusedIndexCount(){return this._maxIndexCount-this._nextIndexStart}_initMatricesTexture(){let n=Math.sqrt(this._maxInstanceCount*4);n=Math.ceil(n/4)*4,n=Math.max(n,4);const o=new Float32Array(n*n*4),l=new io(o,n,n,wo,Jo);this._matricesTexture=l}_initIndirectTexture(){let n=Math.sqrt(this._maxInstanceCount);n=Math.ceil(n);const o=new Uint32Array(n*n),l=new io(o,n,n,Rl,rh);this._indirectTexture=l}_initColorsTexture(){let n=Math.sqrt(this._maxInstanceCount);n=Math.ceil(n);const o=new Float32Array(n*n*4).fill(1),l=new io(o,n,n,wo,Jo);l.colorSpace=$r.workingColorSpace,this._colorsTexture=l}_initializeGeometry(n){const o=this.geometry,l=this._maxVertexCount,u=this._maxIndexCount;if(this._geometryInitialized===!1){for(const p in n.attributes){const g=n.getAttribute(p),{array:y,itemSize:b,normalized:S}=g,A=new y.constructor(l*b),R=new dr(A,b,S);o.setAttribute(p,R)}if(n.getIndex()!==null){const p=l>65535?new Uint32Array(u):new Uint16Array(u);o.setIndex(new dr(p,1))}this._geometryInitialized=!0}}_validateGeometry(n){const o=this.geometry;if(!!n.getIndex()!=!!o.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const l in o.attributes){if(!n.hasAttribute(l))throw new Error(`THREE.BatchedMesh: Added geometry missing "${l}". All geometries must have consistent attributes.`);const u=n.getAttribute(l),p=o.getAttribute(l);if(u.itemSize!==p.itemSize||u.normalized!==p.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(n){const o=this._instanceInfo;if(n<0||n>=o.length||o[n].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${n}. Instance is either out of range or has been deleted.`)}validateGeometryId(n){const o=this._geometryInfo;if(n<0||n>=o.length||o[n].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${n}. Geometry is either out of range or has been deleted.`)}setCustomSort(n){return this.customSort=n,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new wr);const n=this.boundingBox,o=this._instanceInfo;n.makeEmpty();for(let l=0,u=o.length;l<u;l++){if(o[l].active===!1)continue;const p=o[l].geometryIndex;this.getMatrixAt(l,Dr),this.getBoundingBoxAt(p,zh).applyMatrix4(Dr),n.union(zh)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new xr);const n=this.boundingSphere,o=this._instanceInfo;n.makeEmpty();for(let l=0,u=o.length;l<u;l++){if(o[l].active===!1)continue;const p=o[l].geometryIndex;this.getMatrixAt(l,Dr),this.getBoundingSphereAt(p,Ka).applyMatrix4(Dr),n.union(Ka)}}addInstance(n){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const l={visible:!0,active:!0,geometryIndex:n};let u=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(Zf),u=this._availableInstanceIds.shift(),this._instanceInfo[u]=l):(u=this._instanceInfo.length,this._instanceInfo.push(l));const p=this._matricesTexture;Dr.identity().toArray(p.image.data,u*16),p.needsUpdate=!0;const g=this._colorsTexture;return g&&(ky.toArray(g.image.data,u*4),g.needsUpdate=!0),this._visibilityChanged=!0,u}addGeometry(n,o=-1,l=-1){this._initializeGeometry(n),this._validateGeometry(n);const u={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},p=this._geometryInfo;u.vertexStart=this._nextVertexStart,u.reservedVertexCount=o===-1?n.getAttribute("position").count:o;const g=n.getIndex();if(g!==null&&(u.indexStart=this._nextIndexStart,u.reservedIndexCount=l===-1?g.count:l),u.indexStart!==-1&&u.indexStart+u.reservedIndexCount>this._maxIndexCount||u.vertexStart+u.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let b;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(Zf),b=this._availableGeometryIds.shift(),p[b]=u):(b=this._geometryCount,this._geometryCount++,p.push(u)),this.setGeometryAt(b,n),this._nextIndexStart=u.indexStart+u.reservedIndexCount,this._nextVertexStart=u.vertexStart+u.reservedVertexCount,b}setGeometryAt(n,o){if(n>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(o);const l=this.geometry,u=l.getIndex()!==null,p=l.getIndex(),g=o.getIndex(),y=this._geometryInfo[n];if(u&&g.count>y.reservedIndexCount||o.attributes.position.count>y.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const b=y.vertexStart,S=y.reservedVertexCount;y.vertexCount=o.getAttribute("position").count;for(const A in l.attributes){const R=o.getAttribute(A),N=l.getAttribute(A);Hh(R,N,b);const L=R.itemSize;for(let I=R.count,B=S;I<B;I++){const Z=b+I;for(let q=0;q<L;q++)N.setComponent(Z,q,0)}N.needsUpdate=!0,N.addUpdateRange(b*L,S*L)}if(u){const A=y.indexStart,R=y.reservedIndexCount;y.indexCount=o.getIndex().count;for(let N=0;N<g.count;N++)p.setX(A+N,b+g.getX(N));for(let N=g.count,L=R;N<L;N++)p.setX(A+N,b);p.needsUpdate=!0,p.addUpdateRange(A,y.reservedIndexCount)}return y.start=u?y.indexStart:y.vertexStart,y.count=u?y.indexCount:y.vertexCount,y.boundingBox=null,o.boundingBox!==null&&(y.boundingBox=o.boundingBox.clone()),y.boundingSphere=null,o.boundingSphere!==null&&(y.boundingSphere=o.boundingSphere.clone()),this._visibilityChanged=!0,n}deleteGeometry(n){const o=this._geometryInfo;if(n>=o.length||o[n].active===!1)return this;const l=this._instanceInfo;for(let u=0,p=l.length;u<p;u++)l[u].active&&l[u].geometryIndex===n&&this.deleteInstance(u);return o[n].active=!1,this._availableGeometryIds.push(n),this._visibilityChanged=!0,this}deleteInstance(n){return this.validateInstanceId(n),this._instanceInfo[n].active=!1,this._availableInstanceIds.push(n),this._visibilityChanged=!0,this}optimize(){let n=0,o=0;const l=this._geometryInfo,u=l.map((g,y)=>y).sort((g,y)=>l[g].vertexStart-l[y].vertexStart),p=this.geometry;for(let g=0,y=l.length;g<y;g++){const b=u[g],S=l[b];if(S.active!==!1){if(p.index!==null){if(S.indexStart!==o){const{indexStart:A,vertexStart:R,reservedIndexCount:N}=S,L=p.index,I=L.array,B=n-R;for(let Z=A;Z<A+N;Z++)I[Z]=I[Z]+B;L.array.copyWithin(o,A,A+N),L.addUpdateRange(o,N),S.indexStart=o}o+=S.reservedIndexCount}if(S.vertexStart!==n){const{vertexStart:A,reservedVertexCount:R}=S,N=p.attributes;for(const L in N){const I=N[L],{array:B,itemSize:Z}=I;B.copyWithin(n*Z,A*Z,(A+R)*Z),I.addUpdateRange(n*Z,R*Z)}S.vertexStart=n}n+=S.reservedVertexCount,S.start=p.index?S.indexStart:S.vertexStart,this._nextIndexStart=p.index?S.indexStart+S.reservedIndexCount:0,this._nextVertexStart=S.vertexStart+S.reservedVertexCount}}return this}getBoundingBoxAt(n,o){if(n>=this._geometryCount)return null;const l=this.geometry,u=this._geometryInfo[n];if(u.boundingBox===null){const p=new wr,g=l.index,y=l.attributes.position;for(let b=u.start,S=u.start+u.count;b<S;b++){let A=b;g&&(A=g.getX(A)),p.expandByPoint(Kl.fromBufferAttribute(y,A))}u.boundingBox=p}return o.copy(u.boundingBox),o}getBoundingSphereAt(n,o){if(n>=this._geometryCount)return null;const l=this.geometry,u=this._geometryInfo[n];if(u.boundingSphere===null){const p=new xr;this.getBoundingBoxAt(n,zh),zh.getCenter(p.center);const g=l.index,y=l.attributes.position;let b=0;for(let S=u.start,A=u.start+u.count;S<A;S++){let R=S;g&&(R=g.getX(R)),Kl.fromBufferAttribute(y,R),b=Math.max(b,p.center.distanceToSquared(Kl))}p.radius=Math.sqrt(b),u.boundingSphere=p}return o.copy(u.boundingSphere),o}setMatrixAt(n,o){this.validateInstanceId(n);const l=this._matricesTexture,u=this._matricesTexture.image.data;return o.toArray(u,n*16),l.needsUpdate=!0,this}getMatrixAt(n,o){return this.validateInstanceId(n),o.fromArray(this._matricesTexture.image.data,n*16)}setColorAt(n,o){return this.validateInstanceId(n),this._colorsTexture===null&&this._initColorsTexture(),o.toArray(this._colorsTexture.image.data,n*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(n,o){return this.validateInstanceId(n),o.fromArray(this._colorsTexture.image.data,n*4)}setVisibleAt(n,o){return this.validateInstanceId(n),this._instanceInfo[n].visible===o?this:(this._instanceInfo[n].visible=o,this._visibilityChanged=!0,this)}getVisibleAt(n){return this.validateInstanceId(n),this._instanceInfo[n].visible}setGeometryIdAt(n,o){return this.validateInstanceId(n),this.validateGeometryId(o),this._instanceInfo[n].geometryIndex=o,this}getGeometryIdAt(n){return this.validateInstanceId(n),this._instanceInfo[n].geometryIndex}getGeometryRangeAt(n,o={}){this.validateGeometryId(n);const l=this._geometryInfo[n];return o.vertexStart=l.vertexStart,o.vertexCount=l.vertexCount,o.reservedVertexCount=l.reservedVertexCount,o.indexStart=l.indexStart,o.indexCount=l.indexCount,o.reservedIndexCount=l.reservedIndexCount,o.start=l.start,o.count=l.count,o}setInstanceCount(n){const o=this._availableInstanceIds,l=this._instanceInfo;for(o.sort(Zf);o[o.length-1]===l.length-1;)l.pop(),o.pop();if(n<l.length)throw new Error(`BatchedMesh: Instance ids outside the range ${n} are being used. Cannot shrink instance count.`);const u=new Int32Array(n),p=new Int32Array(n);Za(this._multiDrawCounts,u),Za(this._multiDrawStarts,p),this._multiDrawCounts=u,this._multiDrawStarts=p,this._maxInstanceCount=n;const g=this._indirectTexture,y=this._matricesTexture,b=this._colorsTexture;g.dispose(),this._initIndirectTexture(),Za(g.image.data,this._indirectTexture.image.data),y.dispose(),this._initMatricesTexture(),Za(y.image.data,this._matricesTexture.image.data),b&&(b.dispose(),this._initColorsTexture(),Za(b.image.data,this._colorsTexture.image.data))}setGeometrySize(n,o){const l=[...this._geometryInfo].filter(y=>y.active);if(Math.max(...l.map(y=>y.vertexStart+y.reservedVertexCount))>n)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${o}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...l.map(b=>b.indexStart+b.reservedIndexCount))>o)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${o}. Cannot shrink further.`);const p=this.geometry;p.dispose(),this._maxVertexCount=n,this._maxIndexCount=o,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new $n,this._initializeGeometry(p));const g=this.geometry;p.index&&Za(p.index.array,g.index.array);for(const y in p.attributes)Za(p.attributes[y].array,g.attributes[y].array)}raycast(n,o){const l=this._instanceInfo,u=this._geometryInfo,p=this.matrixWorld,g=this.geometry;Ar.material=this.material,Ar.geometry.index=g.index,Ar.geometry.attributes=g.attributes,Ar.geometry.boundingBox===null&&(Ar.geometry.boundingBox=new wr),Ar.geometry.boundingSphere===null&&(Ar.geometry.boundingSphere=new xr);for(let y=0,b=l.length;y<b;y++){if(!l[y].visible||!l[y].active)continue;const S=l[y].geometryIndex,A=u[S];Ar.geometry.setDrawRange(A.start,A.count),this.getMatrixAt(y,Ar.matrixWorld).premultiply(p),this.getBoundingBoxAt(S,Ar.geometry.boundingBox),this.getBoundingSphereAt(S,Ar.geometry.boundingSphere),Ar.raycast(n,Wh);for(let R=0,N=Wh.length;R<N;R++){const L=Wh[R];L.object=this,L.batchId=y,o.push(L)}Wh.length=0}Ar.material=null,Ar.geometry.index=null,Ar.geometry.attributes={},Ar.geometry.setDrawRange(0,1/0)}copy(n){return super.copy(n),this.geometry=n.geometry.clone(),this.perObjectFrustumCulled=n.perObjectFrustumCulled,this.sortObjects=n.sortObjects,this.boundingBox=n.boundingBox!==null?n.boundingBox.clone():null,this.boundingSphere=n.boundingSphere!==null?n.boundingSphere.clone():null,this._geometryInfo=n._geometryInfo.map(o=>To(rr({},o),{boundingBox:o.boundingBox!==null?o.boundingBox.clone():null,boundingSphere:o.boundingSphere!==null?o.boundingSphere.clone():null})),this._instanceInfo=n._instanceInfo.map(o=>rr({},o)),this._availableInstanceIds=n._availableInstanceIds.slice(),this._availableGeometryIds=n._availableGeometryIds.slice(),this._nextIndexStart=n._nextIndexStart,this._nextVertexStart=n._nextVertexStart,this._geometryCount=n._geometryCount,this._maxInstanceCount=n._maxInstanceCount,this._maxVertexCount=n._maxVertexCount,this._maxIndexCount=n._maxIndexCount,this._geometryInitialized=n._geometryInitialized,this._multiDrawCounts=n._multiDrawCounts.slice(),this._multiDrawStarts=n._multiDrawStarts.slice(),this._indirectTexture=n._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=n._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=n._colorsTexture.clone(),this._colorsTexture.image.data=this._colorsTexture.image.data.slice()),this}dispose(){this.geometry.dispose(),this._matricesTexture.dispose(),this._matricesTexture=null,this._indirectTexture.dispose(),this._indirectTexture=null,this._colorsTexture!==null&&(this._colorsTexture.dispose(),this._colorsTexture=null)}onBeforeRender(n,o,l,u,p){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const g=u.getIndex(),y=g===null?1:g.array.BYTES_PER_ELEMENT,b=this._instanceInfo,S=this._multiDrawStarts,A=this._multiDrawCounts,R=this._geometryInfo,N=this.perObjectFrustumCulled,L=this._indirectTexture,I=L.image.data,B=l.isArrayCamera?d0:ql;N&&!l.isArrayCamera&&(Dr.multiplyMatrices(l.projectionMatrix,l.matrixWorldInverse).multiply(this.matrixWorld),ql.setFromProjectionMatrix(Dr,l.coordinateSystem,l.reversedDepth));let Z=0;if(this.sortObjects){Dr.copy(this.matrixWorld).invert(),Kl.setFromMatrixPosition(l.matrixWorld).applyMatrix4(Dr),Qf.set(0,0,-1).transformDirection(l.matrixWorld).transformDirection(Dr);for(let te=0,he=b.length;te<he;te++)if(b[te].visible&&b[te].active){const Re=b[te].geometryIndex;this.getMatrixAt(te,Dr),this.getBoundingSphereAt(Re,Ka).applyMatrix4(Dr);let ke=!1;if(N&&(ke=!B.intersectsSphere(Ka,l)),!ke){const We=R[Re],ze=Vy.subVectors(Ka.center,Kl).dot(Qf);Gh.push(We.start,We.count,ze,te)}}const q=Gh.list,ee=this.customSort;ee===null?q.sort(p.transparent?Oy:By):ee.call(this,q,l);for(let te=0,he=q.length;te<he;te++){const Re=q[te];S[Z]=Re.start*y,A[Z]=Re.count,I[Z]=Re.index,Z++}Gh.reset()}else for(let q=0,ee=b.length;q<ee;q++)if(b[q].visible&&b[q].active){const te=b[q].geometryIndex;let he=!1;if(N&&(this.getMatrixAt(q,Dr),this.getBoundingSphereAt(te,Ka).applyMatrix4(Dr),he=!B.intersectsSphere(Ka,l)),!he){const Re=R[te];S[Z]=Re.start*y,A[Z]=Re.count,I[Z]=q,Z++}}L.needsUpdate=!0,this._multiDrawCount=Z,this._visibilityChanged=!1}onBeforeShadow(n,o,l,u,p,g){this.onBeforeRender(n,null,u,p,g)}}class Ur extends Lr{constructor(n){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Nn(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(n)}copy(n){return super.copy(n),this.color.copy(n.color),this.map=n.map,this.linewidth=n.linewidth,this.linecap=n.linecap,this.linejoin=n.linejoin,this.fog=n.fog,this}}const $h=new ie,ca=new ie,Jf=new Ln,Yc=new Bc,jh=new xr,Zl=new ie,f0=new ie;class Yl extends Ri{constructor(n=new $n,o=new Ur){super(),this.isLine=!0,this.type="Line",this.geometry=n,this.material=o,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(n,o){return super.copy(n,o),this.material=Array.isArray(n.material)?n.material.slice():n.material,this.geometry=n.geometry,this}computeLineDistances(){const n=this.geometry;if(n.index===null){const o=n.attributes.position,l=[0];for(let u=1,p=o.count;u<p;u++)$h.fromBufferAttribute(o,u-1),ca.fromBufferAttribute(o,u),l[u]=l[u-1],l[u]+=$h.distanceTo(ca);n.setAttribute("lineDistance",new Ht(l,1))}else dn("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(n,o){const l=this.geometry,u=this.matrixWorld,p=n.params.Line.threshold,g=l.drawRange;if(l.boundingSphere===null&&l.computeBoundingSphere(),jh.copy(l.boundingSphere),jh.applyMatrix4(u),jh.radius+=p,n.ray.intersectsSphere(jh)===!1)return;Jf.copy(u).invert(),Yc.copy(n.ray).applyMatrix4(Jf);const y=p/((this.scale.x+this.scale.y+this.scale.z)/3),b=y*y,S=this.isLineSegments?2:1,A=l.index,N=l.attributes.position;if(A!==null){const L=Math.max(0,g.start),I=Math.min(A.count,g.start+g.count);for(let B=L,Z=I-1;B<Z;B+=S){const q=A.getX(B),ee=A.getX(B+1),te=Xh(this,n,Yc,b,q,ee,B);te&&o.push(te)}if(this.isLineLoop){const B=A.getX(I-1),Z=A.getX(L),q=Xh(this,n,Yc,b,B,Z,I-1);q&&o.push(q)}}else{const L=Math.max(0,g.start),I=Math.min(N.count,g.start+g.count);for(let B=L,Z=I-1;B<Z;B+=S){const q=Xh(this,n,Yc,b,B,B+1,B);q&&o.push(q)}if(this.isLineLoop){const B=Xh(this,n,Yc,b,I-1,L,I-1);B&&o.push(B)}}}updateMorphTargets(){const o=this.geometry.morphAttributes,l=Object.keys(o);if(l.length>0){const u=o[l[0]];if(u!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let p=0,g=u.length;p<g;p++){const y=u[p].name||String(p);this.morphTargetInfluences.push(0),this.morphTargetDictionary[y]=p}}}}}function Xh(M,n,o,l,u,p,g){const y=M.geometry.attributes.position;if($h.fromBufferAttribute(y,u),ca.fromBufferAttribute(y,p),o.distanceSqToSegment($h,ca,Zl,f0)>l)return;Zl.applyMatrix4(M.matrixWorld);const S=n.ray.origin.distanceTo(Zl);if(!(S<n.near||S>n.far))return{distance:S,point:f0.clone().applyMatrix4(M.matrixWorld),index:g,face:null,faceIndex:null,barycoord:null,object:M}}const ep=new ie,p0=new ie;class tp extends null{constructor(n,o){super(n,o),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const n=this.geometry;if(n.index===null){const o=n.attributes.position,l=[];for(let u=0,p=o.count;u<p;u+=2)ep.fromBufferAttribute(o,u),p0.fromBufferAttribute(o,u+1),l[u]=u===0?0:l[u-1],l[u+1]=l[u]+ep.distanceTo(p0);n.setAttribute("lineDistance",new Ht(l,1))}else dn("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Gy extends null{constructor(n,o){super(n,o),this.isLineLoop=!0,this.type="LineLoop"}}class np extends Lr{constructor(n){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Nn(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(n)}copy(n){return super.copy(n),this.color.copy(n.color),this.map=n.map,this.alphaMap=n.alphaMap,this.size=n.size,this.sizeAttenuation=n.sizeAttenuation,this.fog=n.fog,this}}const m0=new Ln,ip=new Bc,qh=new xr,Kh=new ie;class Wy extends null{constructor(n=new $n,o=new np){super(),this.isPoints=!0,this.type="Points",this.geometry=n,this.material=o,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(n,o){return super.copy(n,o),this.material=Array.isArray(n.material)?n.material.slice():n.material,this.geometry=n.geometry,this}raycast(n,o){const l=this.geometry,u=this.matrixWorld,p=n.params.Points.threshold,g=l.drawRange;if(l.boundingSphere===null&&l.computeBoundingSphere(),qh.copy(l.boundingSphere),qh.applyMatrix4(u),qh.radius+=p,n.ray.intersectsSphere(qh)===!1)return;m0.copy(u).invert(),ip.copy(n.ray).applyMatrix4(m0);const y=p/((this.scale.x+this.scale.y+this.scale.z)/3),b=y*y,S=l.index,R=l.attributes.position;if(S!==null){const N=Math.max(0,g.start),L=Math.min(S.count,g.start+g.count);for(let I=N,B=L;I<B;I++){const Z=S.getX(I);Kh.fromBufferAttribute(R,Z),g0(Kh,Z,b,u,n,o,this)}}else{const N=Math.max(0,g.start),L=Math.min(R.count,g.start+g.count);for(let I=N,B=L;I<B;I++)Kh.fromBufferAttribute(R,I),g0(Kh,I,b,u,n,o,this)}}updateMorphTargets(){const o=this.geometry.morphAttributes,l=Object.keys(o);if(l.length>0){const u=o[l[0]];if(u!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let p=0,g=u.length;p<g;p++){const y=u[p].name||String(p);this.morphTargetInfluences.push(0),this.morphTargetDictionary[y]=p}}}}}function g0(M,n,o,l,u,p,g){const y=ip.distanceSqToPoint(M);if(y<o){const b=new ie;ip.closestPointToPoint(M,b),b.applyMatrix4(l);const S=u.ray.origin.distanceTo(b);if(S<u.near||S>u.far)return;p.push({distance:S,distanceToRay:Math.sqrt(y),point:b,index:n,face:null,faceIndex:null,barycoord:null,object:g})}}class gT extends null{constructor(n,o,l,u,p=Yr,g=Yr,y,b,S){super(n,o,l,u,p,g,y,b,S),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const A=this;function R(){A.needsUpdate=!0,A._requestVideoFrameCallbackId=n.requestVideoFrameCallback(R)}"requestVideoFrameCallback"in n&&(this._requestVideoFrameCallbackId=n.requestVideoFrameCallback(R))}clone(){return new this.constructor(this.image).copy(this)}update(){const n=this.image;"requestVideoFrameCallback"in n===!1&&n.readyState>=n.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class xT extends null{constructor(n,o,l,u,p,g,y,b){super({},n,o,l,u,p,g,y,b),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(n){this.image=n,this.needsUpdate=!0}}class Hy extends sr{constructor(n,o){super({width:n,height:o}),this.isFramebufferTexture=!0,this.magFilter=ps,this.minFilter=ps,this.generateMipmaps=!1,this.needsUpdate=!0}}class $y extends null{constructor(n,o,l,u,p,g,y,b,S,A,R,N){super(null,g,y,b,S,A,u,p,R,N),this.isCompressedTexture=!0,this.image={width:o,height:l},this.mipmaps=n,this.flipY=!1,this.generateMipmaps=!1}}class jy extends null{constructor(n,o,l,u,p,g){super(n,o,l,p,g),this.isCompressedArrayTexture=!0,this.image.depth=u,this.wrapR=Rs,this.layerUpdates=new Set}addLayerUpdate(n){this.layerUpdates.add(n)}clearLayerUpdates(){this.layerUpdates.clear()}}class Xy extends null{constructor(n,o,l){super(void 0,n[0].width,n[0].height,o,l,th),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=n}}class qy extends sr{constructor(n,o,l,u,p,g,y,b,S){super(n,o,l,u,p,g,y,b,S),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Ky extends sr{constructor(n,o,l=rh,u,p,g,y=ps,b=ps,S,A=Wn,R=1){if(A!==Wn&&A!==ng)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const N={width:n,height:o,depth:R};super(N,u,p,g,y,b,A,l,S),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(n){return super.copy(n),this.source=new Ua(Object.assign({},n.image)),this.compareFunction=n.compareFunction,this}toJSON(n){const o=super.toJSON(n);return this.compareFunction!==null&&(o.compareFunction=this.compareFunction),o}}class Zy extends sr{constructor(n=null){super(),this.sourceTexture=n,this.isExternalTexture=!0}copy(n){return super.copy(n),this.sourceTexture=n.sourceTexture,this}}class rp extends $n{constructor(n=1,o=1,l=4,u=8,p=1){super(),this.type="CapsuleGeometry",this.parameters={radius:n,height:o,capSegments:l,radialSegments:u,heightSegments:p},o=Math.max(0,o),l=Math.max(1,Math.floor(l)),u=Math.max(3,Math.floor(u)),p=Math.max(1,Math.floor(p));const g=[],y=[],b=[],S=[],A=o/2,R=Math.PI/2*n,N=o,L=2*R+N,I=l*2+p,B=u+1,Z=new ie,q=new ie;for(let ee=0;ee<=I;ee++){let te=0,he=0,Re=0,ke=0;if(ee<=l){const lt=ee/l,mt=lt*Math.PI/2;he=-A-n*Math.cos(mt),Re=n*Math.sin(mt),ke=-n*Math.cos(mt),te=lt*R}else if(ee<=l+p){const lt=(ee-l)/p;he=-A+lt*o,Re=n,ke=0,te=R+lt*N}else{const lt=(ee-l-p)/l,mt=lt*Math.PI/2;he=A+n*Math.sin(mt),Re=n*Math.cos(mt),ke=n*Math.sin(mt),te=R+N+lt*R}const We=Math.max(0,Math.min(1,te/L));let ze=0;ee===0?ze=.5/u:ee===I&&(ze=-.5/u);for(let lt=0;lt<=u;lt++){const mt=lt/u,Zt=mt*Math.PI*2,Bn=Math.sin(Zt),Hn=Math.cos(Zt);q.x=-Re*Hn,q.y=he,q.z=Re*Bn,y.push(q.x,q.y,q.z),Z.set(-Re*Hn,ke,Re*Bn),Z.normalize(),b.push(Z.x,Z.y,Z.z),S.push(mt+ze,We)}if(ee>0){const lt=(ee-1)*B;for(let mt=0;mt<u;mt++){const Zt=lt+mt,Bn=lt+mt+1,Hn=ee*B+mt,pi=ee*B+mt+1;g.push(Zt,Bn,Hn),g.push(Bn,pi,Hn)}}}this.setIndex(g),this.setAttribute("position",new Ht(y,3)),this.setAttribute("normal",new Ht(b,3)),this.setAttribute("uv",new Ht(S,2))}copy(n){return super.copy(n),this.parameters=Object.assign({},n.parameters),this}static fromJSON(n){return new rp(n.radius,n.height,n.capSegments,n.radialSegments,n.heightSegments)}}class sp extends $n{constructor(n=1,o=32,l=0,u=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:n,segments:o,thetaStart:l,thetaLength:u},o=Math.max(3,o);const p=[],g=[],y=[],b=[],S=new ie,A=new dt;g.push(0,0,0),y.push(0,0,1),b.push(.5,.5);for(let R=0,N=3;R<=o;R++,N+=3){const L=l+R/o*u;S.x=n*Math.cos(L),S.y=n*Math.sin(L),g.push(S.x,S.y,S.z),y.push(0,0,1),A.x=(g[N]/n+1)/2,A.y=(g[N+1]/n+1)/2,b.push(A.x,A.y)}for(let R=1;R<=o;R++)p.push(R,R+1,0);this.setIndex(p),this.setAttribute("position",new Ht(g,3)),this.setAttribute("normal",new Ht(y,3)),this.setAttribute("uv",new Ht(b,2))}copy(n){return super.copy(n),this.parameters=Object.assign({},n.parameters),this}static fromJSON(n){return new sp(n.radius,n.segments,n.thetaStart,n.thetaLength)}}class Ql extends $n{constructor(n=1,o=1,l=1,u=32,p=1,g=!1,y=0,b=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:n,radiusBottom:o,height:l,radialSegments:u,heightSegments:p,openEnded:g,thetaStart:y,thetaLength:b};const S=this;u=Math.floor(u),p=Math.floor(p);const A=[],R=[],N=[],L=[];let I=0;const B=[],Z=l/2;let q=0;ee(),g===!1&&(n>0&&te(!0),o>0&&te(!1)),this.setIndex(A),this.setAttribute("position",new Ht(R,3)),this.setAttribute("normal",new Ht(N,3)),this.setAttribute("uv",new Ht(L,2));function ee(){const he=new ie,Re=new ie;let ke=0;const We=(o-n)/l;for(let ze=0;ze<=p;ze++){const lt=[],mt=ze/p,Zt=mt*(o-n)+n;for(let Bn=0;Bn<=u;Bn++){const Hn=Bn/u,pi=Hn*b+y,ni=Math.sin(pi),ur=Math.cos(pi);Re.x=Zt*ni,Re.y=-mt*l+Z,Re.z=Zt*ur,R.push(Re.x,Re.y,Re.z),he.set(ni,We,ur).normalize(),N.push(he.x,he.y,he.z),L.push(Hn,1-mt),lt.push(I++)}B.push(lt)}for(let ze=0;ze<u;ze++)for(let lt=0;lt<p;lt++){const mt=B[lt][ze],Zt=B[lt+1][ze],Bn=B[lt+1][ze+1],Hn=B[lt][ze+1];(n>0||lt!==0)&&(A.push(mt,Zt,Hn),ke+=3),(o>0||lt!==p-1)&&(A.push(Zt,Bn,Hn),ke+=3)}S.addGroup(q,ke,0),q+=ke}function te(he){const Re=I,ke=new dt,We=new ie;let ze=0;const lt=he===!0?n:o,mt=he===!0?1:-1;for(let Bn=1;Bn<=u;Bn++)R.push(0,Z*mt,0),N.push(0,mt,0),L.push(.5,.5),I++;const Zt=I;for(let Bn=0;Bn<=u;Bn++){const pi=Bn/u*b+y,ni=Math.cos(pi),ur=Math.sin(pi);We.x=lt*ur,We.y=Z*mt,We.z=lt*ni,R.push(We.x,We.y,We.z),N.push(0,mt,0),ke.x=ni*.5+.5,ke.y=ur*.5*mt+.5,L.push(ke.x,ke.y),I++}for(let Bn=0;Bn<u;Bn++){const Hn=Re+Bn,pi=Zt+Bn;he===!0?A.push(pi,pi+1,Hn):A.push(pi+1,pi,Hn),ze+=3}S.addGroup(q,ze,he===!0?1:2),q+=ze}}copy(n){return super.copy(n),this.parameters=Object.assign({},n.parameters),this}static fromJSON(n){return new Ql(n.radiusTop,n.radiusBottom,n.height,n.radialSegments,n.heightSegments,n.openEnded,n.thetaStart,n.thetaLength)}}class Qc extends Ql{constructor(n=1,o=1,l=32,u=1,p=!1,g=0,y=Math.PI*2){super(0,n,o,l,u,p,g,y),this.type="ConeGeometry",this.parameters={radius:n,height:o,radialSegments:l,heightSegments:u,openEnded:p,thetaStart:g,thetaLength:y}}static fromJSON(n){return new Qc(n.radius,n.height,n.radialSegments,n.heightSegments,n.openEnded,n.thetaStart,n.thetaLength)}}class Ya extends $n{constructor(n=[],o=[],l=1,u=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:n,indices:o,radius:l,detail:u};const p=[],g=[];y(u),S(l),A(),this.setAttribute("position",new Ht(p,3)),this.setAttribute("normal",new Ht(p.slice(),3)),this.setAttribute("uv",new Ht(g,2)),u===0?this.computeVertexNormals():this.normalizeNormals();function y(ee){const te=new ie,he=new ie,Re=new ie;for(let ke=0;ke<o.length;ke+=3)L(o[ke+0],te),L(o[ke+1],he),L(o[ke+2],Re),b(te,he,Re,ee)}function b(ee,te,he,Re){const ke=Re+1,We=[];for(let ze=0;ze<=ke;ze++){We[ze]=[];const lt=ee.clone().lerp(he,ze/ke),mt=te.clone().lerp(he,ze/ke),Zt=ke-ze;for(let Bn=0;Bn<=Zt;Bn++)Bn===0&&ze===ke?We[ze][Bn]=lt:We[ze][Bn]=lt.clone().lerp(mt,Bn/Zt)}for(let ze=0;ze<ke;ze++)for(let lt=0;lt<2*(ke-ze)-1;lt++){const mt=Math.floor(lt/2);lt%2===0?(N(We[ze][mt+1]),N(We[ze+1][mt]),N(We[ze][mt])):(N(We[ze][mt+1]),N(We[ze+1][mt+1]),N(We[ze+1][mt]))}}function S(ee){const te=new ie;for(let he=0;he<p.length;he+=3)te.x=p[he+0],te.y=p[he+1],te.z=p[he+2],te.normalize().multiplyScalar(ee),p[he+0]=te.x,p[he+1]=te.y,p[he+2]=te.z}function A(){const ee=new ie;for(let te=0;te<p.length;te+=3){ee.x=p[te+0],ee.y=p[te+1],ee.z=p[te+2];const he=Z(ee)/2/Math.PI+.5,Re=q(ee)/Math.PI+.5;g.push(he,1-Re)}I(),R()}function R(){for(let ee=0;ee<g.length;ee+=6){const te=g[ee+0],he=g[ee+2],Re=g[ee+4],ke=Math.max(te,he,Re),We=Math.min(te,he,Re);ke>.9&&We<.1&&(te<.2&&(g[ee+0]+=1),he<.2&&(g[ee+2]+=1),Re<.2&&(g[ee+4]+=1))}}function N(ee){p.push(ee.x,ee.y,ee.z)}function L(ee,te){const he=ee*3;te.x=n[he+0],te.y=n[he+1],te.z=n[he+2]}function I(){const ee=new ie,te=new ie,he=new ie,Re=new ie,ke=new dt,We=new dt,ze=new dt;for(let lt=0,mt=0;lt<p.length;lt+=9,mt+=6){ee.set(p[lt+0],p[lt+1],p[lt+2]),te.set(p[lt+3],p[lt+4],p[lt+5]),he.set(p[lt+6],p[lt+7],p[lt+8]),ke.set(g[mt+0],g[mt+1]),We.set(g[mt+2],g[mt+3]),ze.set(g[mt+4],g[mt+5]),Re.copy(ee).add(te).add(he).divideScalar(3);const Zt=Z(Re);B(ke,mt+0,ee,Zt),B(We,mt+2,te,Zt),B(ze,mt+4,he,Zt)}}function B(ee,te,he,Re){Re<0&&ee.x===1&&(g[te]=ee.x-1),he.x===0&&he.z===0&&(g[te]=Re/2/Math.PI+.5)}function Z(ee){return Math.atan2(ee.z,-ee.x)}function q(ee){return Math.atan2(-ee.y,Math.sqrt(ee.x*ee.x+ee.z*ee.z))}}copy(n){return super.copy(n),this.parameters=Object.assign({},n.parameters),this}static fromJSON(n){return new Ya(n.vertices,n.indices,n.radius,n.details)}}class op extends Ya{constructor(n=1,o=0){const l=(1+Math.sqrt(5))/2,u=1/l,p=[-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,-u,-l,0,-u,l,0,u,-l,0,u,l,-u,-l,0,-u,l,0,u,-l,0,u,l,0,-l,0,-u,l,0,-u,-l,0,u,l,0,u],g=[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];super(p,g,n,o),this.type="DodecahedronGeometry",this.parameters={radius:n,detail:o}}static fromJSON(n){return new op(n.radius,n.detail)}}const Zh=new ie,Yh=new ie,ap=new ie,Qh=new is;class Yy extends $n{constructor(n=null,o=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:n,thresholdAngle:o},n!==null){const u=Math.pow(10,4),p=Math.cos(Eo*o),g=n.getIndex(),y=n.getAttribute("position"),b=g?g.count:y.count,S=[0,0,0],A=["a","b","c"],R=new Array(3),N={},L=[];for(let I=0;I<b;I+=3){g?(S[0]=g.getX(I),S[1]=g.getX(I+1),S[2]=g.getX(I+2)):(S[0]=I,S[1]=I+1,S[2]=I+2);const{a:B,b:Z,c:q}=Qh;if(B.fromBufferAttribute(y,S[0]),Z.fromBufferAttribute(y,S[1]),q.fromBufferAttribute(y,S[2]),Qh.getNormal(ap),R[0]=`${Math.round(B.x*u)},${Math.round(B.y*u)},${Math.round(B.z*u)}`,R[1]=`${Math.round(Z.x*u)},${Math.round(Z.y*u)},${Math.round(Z.z*u)}`,R[2]=`${Math.round(q.x*u)},${Math.round(q.y*u)},${Math.round(q.z*u)}`,!(R[0]===R[1]||R[1]===R[2]||R[2]===R[0]))for(let ee=0;ee<3;ee++){const te=(ee+1)%3,he=R[ee],Re=R[te],ke=Qh[A[ee]],We=Qh[A[te]],ze=`${he}_${Re}`,lt=`${Re}_${he}`;lt in N&&N[lt]?(ap.dot(N[lt].normal)<=p&&(L.push(ke.x,ke.y,ke.z),L.push(We.x,We.y,We.z)),N[lt]=null):ze in N||(N[ze]={index0:S[ee],index1:S[te],normal:ap.clone()})}}for(const I in N)if(N[I]){const{index0:B,index1:Z}=N[I];Zh.fromBufferAttribute(y,B),Yh.fromBufferAttribute(y,Z),L.push(Zh.x,Zh.y,Zh.z),L.push(Yh.x,Yh.y,Yh.z)}this.setAttribute("position",new Ht(L,3))}}copy(n){return super.copy(n),this.parameters=Object.assign({},n.parameters),this}}class oo{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){dn("Curve: .getPoint() not implemented.")}getPointAt(n,o){const l=this.getUtoTmapping(n);return this.getPoint(l,o)}getPoints(n=5){const o=[];for(let l=0;l<=n;l++)o.push(this.getPoint(l/n));return o}getSpacedPoints(n=5){const o=[];for(let l=0;l<=n;l++)o.push(this.getPointAt(l/n));return o}getLength(){const n=this.getLengths();return n[n.length-1]}getLengths(n=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===n+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const o=[];let l,u=this.getPoint(0),p=0;o.push(0);for(let g=1;g<=n;g++)l=this.getPoint(g/n),p+=l.distanceTo(u),o.push(p),u=l;return this.cacheArcLengths=o,o}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(n,o=null){const l=this.getLengths();let u=0;const p=l.length;let g;o?g=o:g=n*l[p-1];let y=0,b=p-1,S;for(;y<=b;)if(u=Math.floor(y+(b-y)/2),S=l[u]-g,S<0)y=u+1;else if(S>0)b=u-1;else{b=u;break}if(u=b,l[u]===g)return u/(p-1);const A=l[u],N=l[u+1]-A,L=(g-A)/N;return(u+L)/(p-1)}getTangent(n,o){let u=n-1e-4,p=n+1e-4;u<0&&(u=0),p>1&&(p=1);const g=this.getPoint(u),y=this.getPoint(p),b=o||(g.isVector2?new dt:new ie);return b.copy(y).sub(g).normalize(),b}getTangentAt(n,o){const l=this.getUtoTmapping(n);return this.getTangent(l,o)}computeFrenetFrames(n,o=!1){const l=new ie,u=[],p=[],g=[],y=new ie,b=new Ln;for(let L=0;L<=n;L++){const I=L/n;u[L]=this.getTangentAt(I,new ie)}p[0]=new ie,g[0]=new ie;let S=Number.MAX_VALUE;const A=Math.abs(u[0].x),R=Math.abs(u[0].y),N=Math.abs(u[0].z);A<=S&&(S=A,l.set(1,0,0)),R<=S&&(S=R,l.set(0,1,0)),N<=S&&l.set(0,0,1),y.crossVectors(u[0],l).normalize(),p[0].crossVectors(u[0],y),g[0].crossVectors(u[0],p[0]);for(let L=1;L<=n;L++){if(p[L]=p[L-1].clone(),g[L]=g[L-1].clone(),y.crossVectors(u[L-1],u[L]),y.length()>Number.EPSILON){y.normalize();const I=Math.acos(an(u[L-1].dot(u[L]),-1,1));p[L].applyMatrix4(b.makeRotationAxis(y,I))}g[L].crossVectors(u[L],p[L])}if(o===!0){let L=Math.acos(an(p[0].dot(p[n]),-1,1));L/=n,u[0].dot(y.crossVectors(p[0],p[n]))>0&&(L=-L);for(let I=1;I<=n;I++)p[I].applyMatrix4(b.makeRotationAxis(u[I],L*I)),g[I].crossVectors(u[I],p[I])}return{tangents:u,normals:p,binormals:g}}clone(){return new this.constructor().copy(this)}copy(n){return this.arcLengthDivisions=n.arcLengthDivisions,this}toJSON(){const n={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return n.arcLengthDivisions=this.arcLengthDivisions,n.type=this.type,n}fromJSON(n){return this.arcLengthDivisions=n.arcLengthDivisions,this}}class cp extends oo{constructor(n=0,o=0,l=1,u=1,p=0,g=Math.PI*2,y=!1,b=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=n,this.aY=o,this.xRadius=l,this.yRadius=u,this.aStartAngle=p,this.aEndAngle=g,this.aClockwise=y,this.aRotation=b}getPoint(n,o=new dt){const l=o,u=Math.PI*2;let p=this.aEndAngle-this.aStartAngle;const g=Math.abs(p)<Number.EPSILON;for(;p<0;)p+=u;for(;p>u;)p-=u;p<Number.EPSILON&&(g?p=0:p=u),this.aClockwise===!0&&!g&&(p===u?p=-u:p=p-u);const y=this.aStartAngle+n*p;let b=this.aX+this.xRadius*Math.cos(y),S=this.aY+this.yRadius*Math.sin(y);if(this.aRotation!==0){const A=Math.cos(this.aRotation),R=Math.sin(this.aRotation),N=b-this.aX,L=S-this.aY;b=N*A-L*R+this.aX,S=N*R+L*A+this.aY}return l.set(b,S)}copy(n){return super.copy(n),this.aX=n.aX,this.aY=n.aY,this.xRadius=n.xRadius,this.yRadius=n.yRadius,this.aStartAngle=n.aStartAngle,this.aEndAngle=n.aEndAngle,this.aClockwise=n.aClockwise,this.aRotation=n.aRotation,this}toJSON(){const n=super.toJSON();return n.aX=this.aX,n.aY=this.aY,n.xRadius=this.xRadius,n.yRadius=this.yRadius,n.aStartAngle=this.aStartAngle,n.aEndAngle=this.aEndAngle,n.aClockwise=this.aClockwise,n.aRotation=this.aRotation,n}fromJSON(n){return super.fromJSON(n),this.aX=n.aX,this.aY=n.aY,this.xRadius=n.xRadius,this.yRadius=n.yRadius,this.aStartAngle=n.aStartAngle,this.aEndAngle=n.aEndAngle,this.aClockwise=n.aClockwise,this.aRotation=n.aRotation,this}}class Qy extends cp{constructor(n,o,l,u,p,g){super(n,o,l,l,u,p,g),this.isArcCurve=!0,this.type="ArcCurve"}}function lp(){let M=0,n=0,o=0,l=0;function u(p,g,y,b){M=p,n=y,o=-3*p+3*g-2*y-b,l=2*p-2*g+y+b}return{initCatmullRom:function(p,g,y,b,S){u(g,y,S*(y-p),S*(b-g))},initNonuniformCatmullRom:function(p,g,y,b,S,A,R){let N=(g-p)/S-(y-p)/(S+A)+(y-g)/A,L=(y-g)/A-(b-g)/(A+R)+(b-y)/R;N*=A,L*=A,u(g,y,N,L)},calc:function(p){const g=p*p,y=g*p;return M+n*p+o*g+l*y}}}const Jh=new ie,Bo=new lp,up=new lp,hp=new lp;class Jy extends oo{constructor(n=[],o=!1,l="centripetal",u=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=n,this.closed=o,this.curveType=l,this.tension=u}getPoint(n,o=new ie){const l=o,u=this.points,p=u.length,g=(p-(this.closed?0:1))*n;let y=Math.floor(g),b=g-y;this.closed?y+=y>0?0:(Math.floor(Math.abs(y)/p)+1)*p:b===0&&y===p-1&&(y=p-2,b=1);let S,A;this.closed||y>0?S=u[(y-1)%p]:(Jh.subVectors(u[0],u[1]).add(u[0]),S=Jh);const R=u[y%p],N=u[(y+1)%p];if(this.closed||y+2<p?A=u[(y+2)%p]:(Jh.subVectors(u[p-1],u[p-2]).add(u[p-1]),A=Jh),this.curveType==="centripetal"||this.curveType==="chordal"){const L=this.curveType==="chordal"?.5:.25;let I=Math.pow(S.distanceToSquared(R),L),B=Math.pow(R.distanceToSquared(N),L),Z=Math.pow(N.distanceToSquared(A),L);B<1e-4&&(B=1),I<1e-4&&(I=B),Z<1e-4&&(Z=B),Bo.initNonuniformCatmullRom(S.x,R.x,N.x,A.x,I,B,Z),up.initNonuniformCatmullRom(S.y,R.y,N.y,A.y,I,B,Z),hp.initNonuniformCatmullRom(S.z,R.z,N.z,A.z,I,B,Z)}else this.curveType==="catmullrom"&&(Bo.initCatmullRom(S.x,R.x,N.x,A.x,this.tension),up.initCatmullRom(S.y,R.y,N.y,A.y,this.tension),hp.initCatmullRom(S.z,R.z,N.z,A.z,this.tension));return l.set(Bo.calc(b),up.calc(b),hp.calc(b)),l}copy(n){super.copy(n),this.points=[];for(let o=0,l=n.points.length;o<l;o++){const u=n.points[o];this.points.push(u.clone())}return this.closed=n.closed,this.curveType=n.curveType,this.tension=n.tension,this}toJSON(){const n=super.toJSON();n.points=[];for(let o=0,l=this.points.length;o<l;o++){const u=this.points[o];n.points.push(u.toArray())}return n.closed=this.closed,n.curveType=this.curveType,n.tension=this.tension,n}fromJSON(n){super.fromJSON(n),this.points=[];for(let o=0,l=n.points.length;o<l;o++){const u=n.points[o];this.points.push(new ie().fromArray(u))}return this.closed=n.closed,this.curveType=n.curveType,this.tension=n.tension,this}}function x0(M,n,o,l,u){const p=(l-n)*.5,g=(u-o)*.5,y=M*M,b=M*y;return(2*o-2*l+p+g)*b+(-3*o+3*l-2*p-g)*y+p*M+o}function Oo(M,n){const o=1-M;return o*o*n}function eb(M,n){return 2*(1-M)*M*n}function tb(M,n){return M*M*n}function Jl(M,n,o,l){return Oo(M,n)+eb(M,o)+tb(M,l)}function dp(M,n){const o=1-M;return o*o*o*n}function nb(M,n){const o=1-M;return 3*o*o*M*n}function fp(M,n){return 3*(1-M)*M*M*n}function Jc(M,n){return M*M*M*n}function Os(M,n,o,l,u){return dp(M,n)+nb(M,o)+fp(M,l)+Jc(M,u)}class Qa extends oo{constructor(n=new dt,o=new dt,l=new dt,u=new dt){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=n,this.v1=o,this.v2=l,this.v3=u}getPoint(n,o=new dt){const l=o,u=this.v0,p=this.v1,g=this.v2,y=this.v3;return l.set(Os(n,u.x,p.x,g.x,y.x),Os(n,u.y,p.y,g.y,y.y)),l}copy(n){return super.copy(n),this.v0.copy(n.v0),this.v1.copy(n.v1),this.v2.copy(n.v2),this.v3.copy(n.v3),this}toJSON(){const n=super.toJSON();return n.v0=this.v0.toArray(),n.v1=this.v1.toArray(),n.v2=this.v2.toArray(),n.v3=this.v3.toArray(),n}fromJSON(n){return super.fromJSON(n),this.v0.fromArray(n.v0),this.v1.fromArray(n.v1),this.v2.fromArray(n.v2),this.v3.fromArray(n.v3),this}}class _0 extends oo{constructor(n=new ie,o=new ie,l=new ie,u=new ie){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=n,this.v1=o,this.v2=l,this.v3=u}getPoint(n,o=new ie){const l=o,u=this.v0,p=this.v1,g=this.v2,y=this.v3;return l.set(Os(n,u.x,p.x,g.x,y.x),Os(n,u.y,p.y,g.y,y.y),Os(n,u.z,p.z,g.z,y.z)),l}copy(n){return super.copy(n),this.v0.copy(n.v0),this.v1.copy(n.v1),this.v2.copy(n.v2),this.v3.copy(n.v3),this}toJSON(){const n=super.toJSON();return n.v0=this.v0.toArray(),n.v1=this.v1.toArray(),n.v2=this.v2.toArray(),n.v3=this.v3.toArray(),n}fromJSON(n){return super.fromJSON(n),this.v0.fromArray(n.v0),this.v1.fromArray(n.v1),this.v2.fromArray(n.v2),this.v3.fromArray(n.v3),this}}class pp extends oo{constructor(n=new dt,o=new dt){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=n,this.v2=o}getPoint(n,o=new dt){const l=o;return n===1?l.copy(this.v2):(l.copy(this.v2).sub(this.v1),l.multiplyScalar(n).add(this.v1)),l}getPointAt(n,o){return this.getPoint(n,o)}getTangent(n,o=new dt){return o.subVectors(this.v2,this.v1).normalize()}getTangentAt(n,o){return this.getTangent(n,o)}copy(n){return super.copy(n),this.v1.copy(n.v1),this.v2.copy(n.v2),this}toJSON(){const n=super.toJSON();return n.v1=this.v1.toArray(),n.v2=this.v2.toArray(),n}fromJSON(n){return super.fromJSON(n),this.v1.fromArray(n.v1),this.v2.fromArray(n.v2),this}}class mp extends oo{constructor(n=new ie,o=new ie){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=n,this.v2=o}getPoint(n,o=new ie){const l=o;return n===1?l.copy(this.v2):(l.copy(this.v2).sub(this.v1),l.multiplyScalar(n).add(this.v1)),l}getPointAt(n,o){return this.getPoint(n,o)}getTangent(n,o=new ie){return o.subVectors(this.v2,this.v1).normalize()}getTangentAt(n,o){return this.getTangent(n,o)}copy(n){return super.copy(n),this.v1.copy(n.v1),this.v2.copy(n.v2),this}toJSON(){const n=super.toJSON();return n.v1=this.v1.toArray(),n.v2=this.v2.toArray(),n}fromJSON(n){return super.fromJSON(n),this.v1.fromArray(n.v1),this.v2.fromArray(n.v2),this}}class el extends oo{constructor(n=new dt,o=new dt,l=new dt){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=n,this.v1=o,this.v2=l}getPoint(n,o=new dt){const l=o,u=this.v0,p=this.v1,g=this.v2;return l.set(Jl(n,u.x,p.x,g.x),Jl(n,u.y,p.y,g.y)),l}copy(n){return super.copy(n),this.v0.copy(n.v0),this.v1.copy(n.v1),this.v2.copy(n.v2),this}toJSON(){const n=super.toJSON();return n.v0=this.v0.toArray(),n.v1=this.v1.toArray(),n.v2=this.v2.toArray(),n}fromJSON(n){return super.fromJSON(n),this.v0.fromArray(n.v0),this.v1.fromArray(n.v1),this.v2.fromArray(n.v2),this}}class eu extends oo{constructor(n=new ie,o=new ie,l=new ie){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=n,this.v1=o,this.v2=l}getPoint(n,o=new ie){const l=o,u=this.v0,p=this.v1,g=this.v2;return l.set(Jl(n,u.x,p.x,g.x),Jl(n,u.y,p.y,g.y),Jl(n,u.z,p.z,g.z)),l}copy(n){return super.copy(n),this.v0.copy(n.v0),this.v1.copy(n.v1),this.v2.copy(n.v2),this}toJSON(){const n=super.toJSON();return n.v0=this.v0.toArray(),n.v1=this.v1.toArray(),n.v2=this.v2.toArray(),n}fromJSON(n){return super.fromJSON(n),this.v0.fromArray(n.v0),this.v1.fromArray(n.v1),this.v2.fromArray(n.v2),this}}class gp extends oo{constructor(n=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=n}getPoint(n,o=new dt){const l=o,u=this.points,p=(u.length-1)*n,g=Math.floor(p),y=p-g,b=u[g===0?g:g-1],S=u[g],A=u[g>u.length-2?u.length-1:g+1],R=u[g>u.length-3?u.length-1:g+2];return l.set(x0(y,b.x,S.x,A.x,R.x),x0(y,b.y,S.y,A.y,R.y)),l}copy(n){super.copy(n),this.points=[];for(let o=0,l=n.points.length;o<l;o++){const u=n.points[o];this.points.push(u.clone())}return this}toJSON(){const n=super.toJSON();n.points=[];for(let o=0,l=this.points.length;o<l;o++){const u=this.points[o];n.points.push(u.toArray())}return n}fromJSON(n){super.fromJSON(n),this.points=[];for(let o=0,l=n.points.length;o<l;o++){const u=n.points[o];this.points.push(new dt().fromArray(u))}return this}}var tu=Object.freeze({__proto__:null,ArcCurve:Qy,CatmullRomCurve3:Jy,CubicBezierCurve:Qa,CubicBezierCurve3:_0,EllipseCurve:cp,LineCurve:pp,LineCurve3:mp,QuadraticBezierCurve:el,QuadraticBezierCurve3:eu,SplineCurve:gp});class ko extends oo{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(n){this.curves.push(n)}closePath(){const n=this.curves[0].getPoint(0),o=this.curves[this.curves.length-1].getPoint(1);if(!n.equals(o)){const l=n.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new tu[l](o,n))}return this}getPoint(n,o){const l=n*this.getLength(),u=this.getCurveLengths();let p=0;for(;p<u.length;){if(u[p]>=l){const g=u[p]-l,y=this.curves[p],b=y.getLength(),S=b===0?0:1-g/b;return y.getPointAt(S,o)}p++}return null}getLength(){const n=this.getCurveLengths();return n[n.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 n=[];let o=0;for(let l=0,u=this.curves.length;l<u;l++)o+=this.curves[l].getLength(),n.push(o);return this.cacheLengths=n,n}getSpacedPoints(n=40){const o=[];for(let l=0;l<=n;l++)o.push(this.getPoint(l/n));return this.autoClose&&o.push(o[0]),o}getPoints(n=12){const o=[];let l;for(let u=0,p=this.curves;u<p.length;u++){const g=p[u],y=g.isEllipseCurve?n*2:g.isLineCurve||g.isLineCurve3?1:g.isSplineCurve?n*g.points.length:n,b=g.getPoints(y);for(let S=0;S<b.length;S++){const A=b[S];l&&l.equals(A)||(o.push(A),l=A)}}return this.autoClose&&o.length>1&&!o[o.length-1].equals(o[0])&&o.push(o[0]),o}copy(n){super.copy(n),this.curves=[];for(let o=0,l=n.curves.length;o<l;o++){const u=n.curves[o];this.curves.push(u.clone())}return this.autoClose=n.autoClose,this}toJSON(){const n=super.toJSON();n.autoClose=this.autoClose,n.curves=[];for(let o=0,l=this.curves.length;o<l;o++){const u=this.curves[o];n.curves.push(u.toJSON())}return n}fromJSON(n){super.fromJSON(n),this.autoClose=n.autoClose,this.curves=[];for(let o=0,l=n.curves.length;o<l;o++){const u=n.curves[o];this.curves.push(new tu[u.type]().fromJSON(u))}return this}}class tl extends ko{constructor(n){super(),this.type="Path",this.currentPoint=new dt,n&&this.setFromPoints(n)}setFromPoints(n){this.moveTo(n[0].x,n[0].y);for(let o=1,l=n.length;o<l;o++)this.lineTo(n[o].x,n[o].y);return this}moveTo(n,o){return this.currentPoint.set(n,o),this}lineTo(n,o){const l=new pp(this.currentPoint.clone(),new dt(n,o));return this.curves.push(l),this.currentPoint.set(n,o),this}quadraticCurveTo(n,o,l,u){const p=new el(this.currentPoint.clone(),new dt(n,o),new dt(l,u));return this.curves.push(p),this.currentPoint.set(l,u),this}bezierCurveTo(n,o,l,u,p,g){const y=new Qa(this.currentPoint.clone(),new dt(n,o),new dt(l,u),new dt(p,g));return this.curves.push(y),this.currentPoint.set(p,g),this}splineThru(n){const o=[this.currentPoint.clone()].concat(n),l=new gp(o);return this.curves.push(l),this.currentPoint.copy(n[n.length-1]),this}arc(n,o,l,u,p,g){const y=this.currentPoint.x,b=this.currentPoint.y;return this.absarc(n+y,o+b,l,u,p,g),this}absarc(n,o,l,u,p,g){return this.absellipse(n,o,l,l,u,p,g),this}ellipse(n,o,l,u,p,g,y,b){const S=this.currentPoint.x,A=this.currentPoint.y;return this.absellipse(n+S,o+A,l,u,p,g,y,b),this}absellipse(n,o,l,u,p,g,y,b){const S=new cp(n,o,l,u,p,g,y,b);if(this.curves.length>0){const R=S.getPoint(0);R.equals(this.currentPoint)||this.lineTo(R.x,R.y)}this.curves.push(S);const A=S.getPoint(1);return this.currentPoint.copy(A),this}copy(n){return super.copy(n),this.currentPoint.copy(n.currentPoint),this}toJSON(){const n=super.toJSON();return n.currentPoint=this.currentPoint.toArray(),n}fromJSON(n){return super.fromJSON(n),this.currentPoint.fromArray(n.currentPoint),this}}class la extends tl{constructor(n){super(n),this.uuid=gr(),this.type="Shape",this.holes=[]}getPointsHoles(n){const o=[];for(let l=0,u=this.holes.length;l<u;l++)o[l]=this.holes[l].getPoints(n);return o}extractPoints(n){return{shape:this.getPoints(n),holes:this.getPointsHoles(n)}}copy(n){super.copy(n),this.holes=[];for(let o=0,l=n.holes.length;o<l;o++){const u=n.holes[o];this.holes.push(u.clone())}return this}toJSON(){const n=super.toJSON();n.uuid=this.uuid,n.holes=[];for(let o=0,l=this.holes.length;o<l;o++){const u=this.holes[o];n.holes.push(u.toJSON())}return n}fromJSON(n){super.fromJSON(n),this.uuid=n.uuid,this.holes=[];for(let o=0,l=n.holes.length;o<l;o++){const u=n.holes[o];this.holes.push(new tl().fromJSON(u))}return this}}function xp(M,n,o=2){const l=n&&n.length,u=l?n[0]*o:M.length;let p=ed(M,0,u,o,!0);const g=[];if(!p||p.next===p.prev)return g;let y,b,S;if(l&&(p=_p(M,n,p,o)),M.length>80*o){y=M[0],b=M[1];let A=y,R=b;for(let N=o;N<u;N+=o){const L=M[N],I=M[N+1];L<y&&(y=L),I<b&&(b=I),L>A&&(A=L),I>R&&(R=I)}S=Math.max(A-y,R-b),S=S!==0?32767/S:0}return Vo(p,g,o,y,b,S,0),g}function ed(M,n,o,l,u){let p;if(u===id(M,n,o,l)>0)for(let g=n;g<o;g+=l)p=S0(g/l|0,M[g],M[g+1],p);else for(let g=o-l;g>=n;g-=l)p=S0(g/l|0,M[g],M[g+1],p);return p&&il(p,p.next)&&(rl(p),p=p.next),p}function nl(M,n){if(!M)return M;n||(n=M);let o=M,l;do if(l=!1,!o.steiner&&(il(o,o.next)||Li(o.prev,o,o.next)===0)){if(rl(o),o=n=o.prev,o===o.next)break;l=!0}else o=o.next;while(l||o!==n);return n}function Vo(M,n,o,l,u,p,g){if(!M)return;!g&&p&&Rt(M,l,u,p);let y=M;for(;M.prev!==M.next;){const b=M.prev,S=M.next;if(p?ib(M,l,u,p):xn(M)){n.push(b.i,M.i,S.i),rl(M),M=S.next,y=S.next;continue}if(M=S,M===y){g?g===1?(M=yr(nl(M),n),Vo(M,n,o,l,u,p,2)):g===2&&y0(M,n,o,l,u,p):Vo(nl(M),n,o,l,u,p,1);break}}}function xn(M){const n=M.prev,o=M,l=M.next;if(Li(n,o,l)>=0)return!1;const u=n.x,p=o.x,g=l.x,y=n.y,b=o.y,S=l.y,A=Math.min(u,p,g),R=Math.min(y,b,S),N=Math.max(u,p,g),L=Math.max(y,b,S);let I=l.next;for(;I!==n;){if(I.x>=A&&I.x<=N&&I.y>=R&&I.y<=L&&nu(u,y,p,b,g,S,I.x,I.y)&&Li(I.prev,I,I.next)>=0)return!1;I=I.next}return!0}function ib(M,n,o,l){const u=M.prev,p=M,g=M.next;if(Li(u,p,g)>=0)return!1;const y=u.x,b=p.x,S=g.x,A=u.y,R=p.y,N=g.y,L=Math.min(y,b,S),I=Math.min(A,R,N),B=Math.max(y,b,S),Z=Math.max(A,R,N),q=td(L,I,n,o,l),ee=td(B,Z,n,o,l);let te=M.prevZ,he=M.nextZ;for(;te&&te.z>=q&&he&&he.z<=ee;){if(te.x>=L&&te.x<=B&&te.y>=I&&te.y<=Z&&te!==u&&te!==g&&nu(y,A,b,R,S,N,te.x,te.y)&&Li(te.prev,te,te.next)>=0||(te=te.prevZ,he.x>=L&&he.x<=B&&he.y>=I&&he.y<=Z&&he!==u&&he!==g&&nu(y,A,b,R,S,N,he.x,he.y)&&Li(he.prev,he,he.next)>=0))return!1;he=he.nextZ}for(;te&&te.z>=q;){if(te.x>=L&&te.x<=B&&te.y>=I&&te.y<=Z&&te!==u&&te!==g&&nu(y,A,b,R,S,N,te.x,te.y)&&Li(te.prev,te,te.next)>=0)return!1;te=te.prevZ}for(;he&&he.z<=ee;){if(he.x>=L&&he.x<=B&&he.y>=I&&he.y<=Z&&he!==u&&he!==g&&nu(y,A,b,R,S,N,he.x,he.y)&&Li(he.prev,he,he.next)>=0)return!1;he=he.nextZ}return!0}function yr(M,n){let o=M;do{const l=o.prev,u=o.next.next;!il(l,u)&&nd(l,o,o.next,u)&&_s(l,u)&&_s(u,l)&&(n.push(l.i,o.i,u.i),rl(o),rl(o.next),o=M=u),o=o.next}while(o!==M);return nl(o)}function y0(M,n,o,l,u,p){let g=M;do{let y=g.next.next;for(;y!==g.prev;){if(g.i!==y.i&&v0(g,y)){let b=De(g,y);g=nl(g,g.next),b=nl(b,b.next),Vo(g,n,o,l,u,p,0),Vo(b,n,o,l,u,p,0);return}y=y.next}g=g.next}while(g!==M)}function _p(M,n,o,l){const u=[];for(let p=0,g=n.length;p<g;p++){const y=n[p]*l,b=p<g-1?n[p+1]*l:M.length,S=ed(M,y,b,l,!1);S===S.next&&(S.steiner=!0),u.push(Oi(S))}u.sort(yp);for(let p=0;p<u.length;p++)o=Ja(u[p],o);return o}function yp(M,n){let o=M.x-n.x;if(o===0&&(o=M.y-n.y,o===0)){const l=(M.next.y-M.y)/(M.next.x-M.x),u=(n.next.y-n.y)/(n.next.x-n.x);o=l-u}return o}function Ja(M,n){const o=rb(M,n);if(!o)return n;const l=De(o,M);return nl(l,l.next),nl(o,o.next)}function rb(M,n){let o=n;const l=M.x,u=M.y;let p=-1/0,g;if(il(M,o))return o;do{if(il(M,o.next))return o.next;if(u<=o.y&&u>=o.next.y&&o.next.y!==o.y){const R=o.x+(u-o.y)*(o.next.x-o.x)/(o.next.y-o.y);if(R<=l&&R>p&&(p=R,g=o.x<o.next.x?o:o.next,R===l))return g}o=o.next}while(o!==n);if(!g)return null;const y=g,b=g.x,S=g.y;let A=1/0;o=g;do{if(l>=o.x&&o.x>=b&&l!==o.x&&b0(u<S?l:p,u,b,S,u<S?p:l,u,o.x,o.y)){const R=Math.abs(u-o.y)/(l-o.x);_s(o,M)&&(R<A||R===A&&(o.x>g.x||o.x===g.x&&sb(g,o)))&&(g=o,A=R)}o=o.next}while(o!==y);return g}function sb(M,n){return Li(M.prev,M,n.prev)<0&&Li(n.next,M,M.next)<0}function Rt(M,n,o,l){let u=M;do u.z===0&&(u.z=td(u.x,u.y,n,o,l)),u.prevZ=u.prev,u.nextZ=u.next,u=u.next;while(u!==M);u.prevZ.nextZ=null,u.prevZ=null,ec(u)}function ec(M){let n,o=1;do{let l=M,u;M=null;let p=null;for(n=0;l;){n++;let g=l,y=0;for(let S=0;S<o&&(y++,g=g.nextZ,!!g);S++);let b=o;for(;y>0||b>0&&g;)y!==0&&(b===0||!g||l.z<=g.z)?(u=l,l=l.nextZ,y--):(u=g,g=g.nextZ,b--),p?p.nextZ=u:M=u,u.prevZ=p,p=u;l=g}p.nextZ=null,o*=2}while(n>1);return M}function td(M,n,o,l,u){return M=(M-o)*u|0,n=(n-l)*u|0,M=(M|M<<8)&16711935,M=(M|M<<4)&252645135,M=(M|M<<2)&858993459,M=(M|M<<1)&1431655765,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,M|n<<1}function Oi(M){let n=M,o=M;do(n.x<o.x||n.x===o.x&&n.y<o.y)&&(o=n),n=n.next;while(n!==M);return o}function b0(M,n,o,l,u,p,g,y){return(u-g)*(n-y)>=(M-g)*(p-y)&&(M-g)*(l-y)>=(o-g)*(n-y)&&(o-g)*(p-y)>=(u-g)*(l-y)}function nu(M,n,o,l,u,p,g,y){return!(M===g&&n===y)&&b0(M,n,o,l,u,p,g,y)}function v0(M,n){return M.next.i!==n.i&&M.prev.i!==n.i&&!ob(M,n)&&(_s(M,n)&&_s(n,M)&&bp(M,n)&&(Li(M.prev,M,n.prev)||Li(M,n.prev,n))||il(M,n)&&Li(M.prev,M,M.next)>0&&Li(n.prev,n,n.next)>0)}function Li(M,n,o){return(n.y-M.y)*(o.x-n.x)-(n.x-M.x)*(o.y-n.y)}function il(M,n){return M.x===n.x&&M.y===n.y}function nd(M,n,o,l){const u=Fr(Li(M,n,o)),p=Fr(Li(M,n,l)),g=Fr(Li(o,l,M)),y=Fr(Li(o,l,n));return!!(u!==p&&g!==y||u===0&&iu(M,o,n)||p===0&&iu(M,l,n)||g===0&&iu(o,M,l)||y===0&&iu(o,n,l))}function iu(M,n,o){return n.x<=Math.max(M.x,o.x)&&n.x>=Math.min(M.x,o.x)&&n.y<=Math.max(M.y,o.y)&&n.y>=Math.min(M.y,o.y)}function Fr(M){return M>0?1:M<0?-1:0}function ob(M,n){let o=M;do{if(o.i!==M.i&&o.next.i!==M.i&&o.i!==n.i&&o.next.i!==n.i&&nd(o,o.next,M,n))return!0;o=o.next}while(o!==M);return!1}function _s(M,n){return Li(M.prev,M,M.next)<0?Li(M,n,M.next)>=0&&Li(M,M.prev,n)>=0:Li(M,n,M.prev)<0||Li(M,M.next,n)<0}function bp(M,n){let o=M,l=!1;const u=(M.x+n.x)/2,p=(M.y+n.y)/2;do o.y>p!=o.next.y>p&&o.next.y!==o.y&&u<(o.next.x-o.x)*(p-o.y)/(o.next.y-o.y)+o.x&&(l=!l),o=o.next;while(o!==M);return l}function De(M,n){const o=tc(M.i,M.x,M.y),l=tc(n.i,n.x,n.y),u=M.next,p=n.prev;return M.next=n,n.prev=M,o.next=u,u.prev=o,l.next=o,o.prev=l,p.next=l,l.prev=p,l}function S0(M,n,o,l){const u=tc(M,n,o);return l?(u.next=l.next,u.prev=l,l.next.prev=u,l.next=u):(u.prev=u,u.next=u),u}function rl(M){M.next.prev=M.prev,M.prev.next=M.next,M.prevZ&&(M.prevZ.nextZ=M.nextZ),M.nextZ&&(M.nextZ.prevZ=M.prevZ)}function tc(M,n,o){return{i:M,x:n,y:o,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function id(M,n,o,l){let u=0;for(let p=n,g=o-l;p<o;p+=l)u+=(M[g]-M[p])*(M[p+1]+M[g+1]),g=p;return u}class ao{static triangulate(n,o,l=2){return xp(n,o,l)}}class cr{static area(n){const o=n.length;let l=0;for(let u=o-1,p=0;p<o;u=p++)l+=n[u].x*n[p].y-n[p].x*n[u].y;return l*.5}static isClockWise(n){return cr.area(n)<0}static triangulateShape(n,o){const l=[],u=[],p=[];ks(n),vp(l,n);let g=n.length;o.forEach(ks);for(let b=0;b<o.length;b++)u.push(g),g+=o[b].length,vp(l,o[b]);const y=ao.triangulate(l,u);for(let b=0;b<y.length;b+=3)p.push(y.slice(b,b+3));return p}}function ks(M){const n=M.length;n>2&&M[n-1].equals(M[0])&&M.pop()}function vp(M,n){for(let o=0;o<n.length;o++)M.push(n[o].x),M.push(n[o].y)}class Sp extends $n{constructor(n=new la([new dt(.5,.5),new dt(-.5,.5),new dt(-.5,-.5),new dt(.5,-.5)]),o={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:n,options:o},n=Array.isArray(n)?n:[n];const l=this,u=[],p=[];for(let y=0,b=n.length;y<b;y++){const S=n[y];g(S)}this.setAttribute("position",new Ht(u,3)),this.setAttribute("uv",new Ht(p,2)),this.computeVertexNormals();function g(y){const b=[],S=o.curveSegments!==void 0?o.curveSegments:12,A=o.steps!==void 0?o.steps:1,R=o.depth!==void 0?o.depth:1;let N=o.bevelEnabled!==void 0?o.bevelEnabled:!0,L=o.bevelThickness!==void 0?o.bevelThickness:.2,I=o.bevelSize!==void 0?o.bevelSize:L-.1,B=o.bevelOffset!==void 0?o.bevelOffset:0,Z=o.bevelSegments!==void 0?o.bevelSegments:3;const q=o.extrudePath,ee=o.UVGenerator!==void 0?o.UVGenerator:ab;let te,he=!1,Re,ke,We,ze;q&&(te=q.getSpacedPoints(A),he=!0,N=!1,Re=q.computeFrenetFrames(A,!1),ke=new ie,We=new ie,ze=new ie),N||(Z=0,L=0,I=0,B=0);const lt=y.extractPoints(S);let mt=lt.shape;const Zt=lt.holes;if(!cr.isClockWise(mt)){mt=mt.reverse();for(let St=0,Vt=Zt.length;St<Vt;St++){const Wt=Zt[St];cr.isClockWise(Wt)&&(Zt[St]=Wt.reverse())}}function Hn(St){const Wt=10000000000000001e-36;let on=St[0];for(let tn=1;tn<=St.length;tn++){const ei=tn%St.length,Gn=St[ei],gi=Gn.x-on.x,ii=Gn.y-on.y,Ji=gi*gi+ii*ii,us=Math.max(Math.abs(Gn.x),Math.abs(Gn.y),Math.abs(on.x),Math.abs(on.y)),dc=Wt*us*us;if(Ji<=dc){St.splice(ei,1),tn--;continue}on=Gn}}Hn(mt),Zt.forEach(Hn);const pi=Zt.length,ni=mt;for(let St=0;St<pi;St++){const Vt=Zt[St];mt=mt.concat(Vt)}function ur(St,Vt,Wt){return Vt||Yn("ExtrudeGeometry: vec does not exist"),St.clone().addScaledVector(Vt,Wt)}const vr=mt.length;function vs(St,Vt,Wt){let on,tn,ei;const Gn=St.x-Vt.x,gi=St.y-Vt.y,ii=Wt.x-St.x,Ji=Wt.y-St.y,us=Gn*Gn+gi*gi,dc=Gn*Ji-gi*ii;if(Math.abs(dc)>Number.EPSILON){const Vr=Math.sqrt(us),J0=Math.sqrt(ii*ii+Ji*Ji),$p=Vt.x-gi/Vr,jp=Vt.y+Gn/Vr,Pb=Wt.x-Ji/J0,ex=Wt.y+ii/J0,tx=((Pb-$p)*Ji-(ex-jp)*ii)/(Gn*Ji-gi*ii);on=$p+Gn*tx-St.x,tn=jp+gi*tx-St.y;const Xp=on*on+tn*tn;if(Xp<=2)return new dt(on,tn);ei=Math.sqrt(Xp/2)}else{let Vr=!1;Gn>Number.EPSILON?ii>Number.EPSILON&&(Vr=!0):Gn<-Number.EPSILON?ii<-Number.EPSILON&&(Vr=!0):Math.sign(gi)===Math.sign(Ji)&&(Vr=!0),Vr?(on=-gi,tn=Gn,ei=Math.sqrt(us)):(on=Gn,tn=gi,ei=Math.sqrt(us/2))}return new dt(on/ei,tn/ei)}const zi=[];for(let St=0,Vt=ni.length,Wt=Vt-1,on=St+1;St<Vt;St++,Wt++,on++)Wt===Vt&&(Wt=0),on===Vt&&(on=0),zi[St]=vs(ni[St],ni[Wt],ni[on]);const Qi=[];let Di,js=zi.concat();for(let St=0,Vt=pi;St<Vt;St++){const Wt=Zt[St];Di=[];for(let on=0,tn=Wt.length,ei=tn-1,Gn=on+1;on<tn;on++,ei++,Gn++)ei===tn&&(ei=0),Gn===tn&&(Gn=0),Di[on]=vs(Wt[on],Wt[ei],Wt[Gn]);Qi.push(Di),js=js.concat(Di)}let ls;if(Z===0)ls=cr.triangulateShape(ni,Zt);else{const St=[],Vt=[];for(let Wt=0;Wt<Z;Wt++){const on=Wt/Z,tn=L*Math.cos(on*Math.PI/2),ei=I*Math.sin(on*Math.PI/2)+B;for(let Gn=0,gi=ni.length;Gn<gi;Gn++){const ii=ur(ni[Gn],zi[Gn],ei);Xs(ii.x,ii.y,-tn),on===0&&St.push(ii)}for(let Gn=0,gi=pi;Gn<gi;Gn++){const ii=Zt[Gn];Di=Qi[Gn];const Ji=[];for(let us=0,dc=ii.length;us<dc;us++){const Vr=ur(ii[us],Di[us],ei);Xs(Vr.x,Vr.y,-tn),on===0&&Ji.push(Vr)}on===0&&Vt.push(Ji)}}ls=cr.triangulateShape(St,Vt)}const hc=ls.length,Eu=I+B;for(let St=0;St<vr;St++){const Vt=N?ur(mt[St],js[St],Eu):mt[St];he?(We.copy(Re.normals[0]).multiplyScalar(Vt.x),ke.copy(Re.binormals[0]).multiplyScalar(Vt.y),ze.copy(te[0]).add(We).add(ke),Xs(ze.x,ze.y,ze.z)):Xs(Vt.x,Vt.y,0)}for(let St=1;St<=A;St++)for(let Vt=0;Vt<vr;Vt++){const Wt=N?ur(mt[Vt],js[Vt],Eu):mt[Vt];he?(We.copy(Re.normals[St]).multiplyScalar(Wt.x),ke.copy(Re.binormals[St]).multiplyScalar(Wt.y),ze.copy(te[St]).add(We).add(ke),Xs(ze.x,ze.y,ze.z)):Xs(Wt.x,Wt.y,R/A*St)}for(let St=Z-1;St>=0;St--){const Vt=St/Z,Wt=L*Math.cos(Vt*Math.PI/2),on=I*Math.sin(Vt*Math.PI/2)+B;for(let tn=0,ei=ni.length;tn<ei;tn++){const Gn=ur(ni[tn],zi[tn],on);Xs(Gn.x,Gn.y,R+Wt)}for(let tn=0,ei=Zt.length;tn<ei;tn++){const Gn=Zt[tn];Di=Qi[tn];for(let gi=0,ii=Gn.length;gi<ii;gi++){const Ji=ur(Gn[gi],Di[gi],on);he?Xs(Ji.x,Ji.y+te[A-1].y,te[A-1].x+Wt):Xs(Ji.x,Ji.y,R+Wt)}}}Cu(),Q0();function Cu(){const St=u.length/3;if(N){let Vt=0,Wt=vr*Vt;for(let on=0;on<hc;on++){const tn=ls[on];vd(tn[2]+Wt,tn[1]+Wt,tn[0]+Wt)}Vt=A+Z*2,Wt=vr*Vt;for(let on=0;on<hc;on++){const tn=ls[on];vd(tn[0]+Wt,tn[1]+Wt,tn[2]+Wt)}}else{for(let Vt=0;Vt<hc;Vt++){const Wt=ls[Vt];vd(Wt[2],Wt[1],Wt[0])}for(let Vt=0;Vt<hc;Vt++){const Wt=ls[Vt];vd(Wt[0]+vr*A,Wt[1]+vr*A,Wt[2]+vr*A)}}l.addGroup(St,u.length/3-St,0)}function Q0(){const St=u.length/3;let Vt=0;Ru(ni,Vt),Vt+=ni.length;for(let Wt=0,on=Zt.length;Wt<on;Wt++){const tn=Zt[Wt];Ru(tn,Vt),Vt+=tn.length}l.addGroup(St,u.length/3-St,1)}function Ru(St,Vt){let Wt=St.length;for(;--Wt>=0;){const on=Wt;let tn=Wt-1;tn<0&&(tn=St.length-1);for(let ei=0,Gn=A+Z*2;ei<Gn;ei++){const gi=vr*ei,ii=vr*(ei+1),Ji=Vt+on+gi,us=Vt+tn+gi,dc=Vt+tn+ii,Vr=Vt+on+ii;Hp(Ji,us,dc,Vr)}}}function Xs(St,Vt,Wt){b.push(St),b.push(Vt),b.push(Wt)}function vd(St,Vt,Wt){fo(St),fo(Vt),fo(Wt);const on=u.length/3,tn=ee.generateTopUV(l,u,on-3,on-2,on-1);jo(tn[0]),jo(tn[1]),jo(tn[2])}function Hp(St,Vt,Wt,on){fo(St),fo(Vt),fo(on),fo(Vt),fo(Wt),fo(on);const tn=u.length/3,ei=ee.generateSideWallUV(l,u,tn-6,tn-3,tn-2,tn-1);jo(ei[0]),jo(ei[1]),jo(ei[3]),jo(ei[1]),jo(ei[2]),jo(ei[3])}function fo(St){u.push(b[St*3+0]),u.push(b[St*3+1]),u.push(b[St*3+2])}function jo(St){p.push(St.x),p.push(St.y)}}}copy(n){return super.copy(n),this.parameters=Object.assign({},n.parameters),this}toJSON(){const n=super.toJSON(),o=this.parameters.shapes,l=this.parameters.options;return cb(o,l,n)}static fromJSON(n,o){const l=[];for(let p=0,g=n.shapes.length;p<g;p++){const y=o[n.shapes[p]];l.push(y)}const u=n.options.extrudePath;return u!==void 0&&(n.options.extrudePath=new tu[u.type]().fromJSON(u)),new Sp(l,n.options)}}const ab={generateTopUV:function(M,n,o,l,u){const p=n[o*3],g=n[o*3+1],y=n[l*3],b=n[l*3+1],S=n[u*3],A=n[u*3+1];return[new dt(p,g),new dt(y,b),new dt(S,A)]},generateSideWallUV:function(M,n,o,l,u,p){const g=n[o*3],y=n[o*3+1],b=n[o*3+2],S=n[l*3],A=n[l*3+1],R=n[l*3+2],N=n[u*3],L=n[u*3+1],I=n[u*3+2],B=n[p*3],Z=n[p*3+1],q=n[p*3+2];return Math.abs(y-A)<Math.abs(g-S)?[new dt(g,1-b),new dt(S,1-R),new dt(N,1-I),new dt(B,1-q)]:[new dt(y,1-b),new dt(A,1-R),new dt(L,1-I),new dt(Z,1-q)]}};function cb(M,n,o){if(o.shapes=[],Array.isArray(M))for(let l=0,u=M.length;l<u;l++){const p=M[l];o.shapes.push(p.uuid)}else o.shapes.push(M.uuid);return o.options=Object.assign({},n),n.extrudePath!==void 0&&(o.options.extrudePath=n.extrudePath.toJSON()),o}class rd extends Ya{constructor(n=1,o=0){const l=(1+Math.sqrt(5))/2,u=[-1,l,0,1,l,0,-1,-l,0,1,-l,0,0,-1,l,0,1,l,0,-1,-l,0,1,-l,l,0,-1,l,0,1,-l,0,-1,-l,0,1],p=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1];super(u,p,n,o),this.type="IcosahedronGeometry",this.parameters={radius:n,detail:o}}static fromJSON(n){return new rd(n.radius,n.detail)}}class Tp extends $n{constructor(n=[new dt(0,-.5),new dt(.5,0),new dt(0,.5)],o=12,l=0,u=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:n,segments:o,phiStart:l,phiLength:u},o=Math.floor(o),u=an(u,0,Math.PI*2);const p=[],g=[],y=[],b=[],S=[],A=1/o,R=new ie,N=new dt,L=new ie,I=new ie,B=new ie;let Z=0,q=0;for(let ee=0;ee<=n.length-1;ee++)switch(ee){case 0:Z=n[ee+1].x-n[ee].x,q=n[ee+1].y-n[ee].y,L.x=q*1,L.y=-Z,L.z=q*0,B.copy(L),L.normalize(),b.push(L.x,L.y,L.z);break;case n.length-1:b.push(B.x,B.y,B.z);break;default:Z=n[ee+1].x-n[ee].x,q=n[ee+1].y-n[ee].y,L.x=q*1,L.y=-Z,L.z=q*0,I.copy(L),L.x+=B.x,L.y+=B.y,L.z+=B.z,L.normalize(),b.push(L.x,L.y,L.z),B.copy(I)}for(let ee=0;ee<=o;ee++){const te=l+ee*A*u,he=Math.sin(te),Re=Math.cos(te);for(let ke=0;ke<=n.length-1;ke++){R.x=n[ke].x*he,R.y=n[ke].y,R.z=n[ke].x*Re,g.push(R.x,R.y,R.z),N.x=ee/o,N.y=ke/(n.length-1),y.push(N.x,N.y);const We=b[3*ke+0]*he,ze=b[3*ke+1],lt=b[3*ke+0]*Re;S.push(We,ze,lt)}}for(let ee=0;ee<o;ee++)for(let te=0;te<n.length-1;te++){const he=te+ee*n.length,Re=he,ke=he+n.length,We=he+n.length+1,ze=he+1;p.push(Re,ke,ze),p.push(We,ze,ke)}this.setIndex(p),this.setAttribute("position",new Ht(g,3)),this.setAttribute("uv",new Ht(y,2)),this.setAttribute("normal",new Ht(S,3))}copy(n){return super.copy(n),this.parameters=Object.assign({},n.parameters),this}static fromJSON(n){return new Tp(n.points,n.segments,n.phiStart,n.phiLength)}}class sd extends Ya{constructor(n=1,o=0){const l=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],u=[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2];super(l,u,n,o),this.type="OctahedronGeometry",this.parameters={radius:n,detail:o}}static fromJSON(n){return new sd(n.radius,n.detail)}}class od extends $n{constructor(n=1,o=1,l=1,u=1){super(),this.type="PlaneGeometry",this.parameters={width:n,height:o,widthSegments:l,heightSegments:u};const p=n/2,g=o/2,y=Math.floor(l),b=Math.floor(u),S=y+1,A=b+1,R=n/y,N=o/b,L=[],I=[],B=[],Z=[];for(let q=0;q<A;q++){const ee=q*N-g;for(let te=0;te<S;te++){const he=te*R-p;I.push(he,-ee,0),B.push(0,0,1),Z.push(te/y),Z.push(1-q/b)}}for(let q=0;q<b;q++)for(let ee=0;ee<y;ee++){const te=ee+S*q,he=ee+S*(q+1),Re=ee+1+S*(q+1),ke=ee+1+S*q;L.push(te,he,ke),L.push(he,Re,ke)}this.setIndex(L),this.setAttribute("position",new Ht(I,3)),this.setAttribute("normal",new Ht(B,3)),this.setAttribute("uv",new Ht(Z,2))}copy(n){return super.copy(n),this.parameters=Object.assign({},n.parameters),this}static fromJSON(n){return new od(n.width,n.height,n.widthSegments,n.heightSegments)}}class Mp extends $n{constructor(n=.5,o=1,l=32,u=1,p=0,g=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:n,outerRadius:o,thetaSegments:l,phiSegments:u,thetaStart:p,thetaLength:g},l=Math.max(3,l),u=Math.max(1,u);const y=[],b=[],S=[],A=[];let R=n;const N=(o-n)/u,L=new ie,I=new dt;for(let B=0;B<=u;B++){for(let Z=0;Z<=l;Z++){const q=p+Z/l*g;L.x=R*Math.cos(q),L.y=R*Math.sin(q),b.push(L.x,L.y,L.z),S.push(0,0,1),I.x=(L.x/o+1)/2,I.y=(L.y/o+1)/2,A.push(I.x,I.y)}R+=N}for(let B=0;B<u;B++){const Z=B*(l+1);for(let q=0;q<l;q++){const ee=q+Z,te=ee,he=ee+l+1,Re=ee+l+2,ke=ee+1;y.push(te,he,ke),y.push(he,Re,ke)}}this.setIndex(y),this.setAttribute("position",new Ht(b,3)),this.setAttribute("normal",new Ht(S,3)),this.setAttribute("uv",new Ht(A,2))}copy(n){return super.copy(n),this.parameters=Object.assign({},n.parameters),this}static fromJSON(n){return new Mp(n.innerRadius,n.outerRadius,n.thetaSegments,n.phiSegments,n.thetaStart,n.thetaLength)}}class wp extends $n{constructor(n=new la([new dt(0,.5),new dt(-.5,-.5),new dt(.5,-.5)]),o=12){super(),this.type="ShapeGeometry",this.parameters={shapes:n,curveSegments:o};const l=[],u=[],p=[],g=[];let y=0,b=0;if(Array.isArray(n)===!1)S(n);else for(let A=0;A<n.length;A++)S(n[A]),this.addGroup(y,b,A),y+=b,b=0;this.setIndex(l),this.setAttribute("position",new Ht(u,3)),this.setAttribute("normal",new Ht(p,3)),this.setAttribute("uv",new Ht(g,2));function S(A){const R=u.length/3,N=A.extractPoints(o);let L=N.shape;const I=N.holes;cr.isClockWise(L)===!1&&(L=L.reverse());for(let Z=0,q=I.length;Z<q;Z++){const ee=I[Z];cr.isClockWise(ee)===!0&&(I[Z]=ee.reverse())}const B=cr.triangulateShape(L,I);for(let Z=0,q=I.length;Z<q;Z++){const ee=I[Z];L=L.concat(ee)}for(let Z=0,q=L.length;Z<q;Z++){const ee=L[Z];u.push(ee.x,ee.y,0),p.push(0,0,1),g.push(ee.x,ee.y)}for(let Z=0,q=B.length;Z<q;Z++){const ee=B[Z],te=ee[0]+R,he=ee[1]+R,Re=ee[2]+R;l.push(te,he,Re),b+=3}}}copy(n){return super.copy(n),this.parameters=Object.assign({},n.parameters),this}toJSON(){const n=super.toJSON(),o=this.parameters.shapes;return lb(o,n)}static fromJSON(n,o){const l=[];for(let u=0,p=n.shapes.length;u<p;u++){const g=o[n.shapes[u]];l.push(g)}return new wp(l,n.curveSegments)}}function lb(M,n){if(n.shapes=[],Array.isArray(M))for(let o=0,l=M.length;o<l;o++){const u=M[o];n.shapes.push(u.uuid)}else n.shapes.push(M.uuid);return n}class ru extends $n{constructor(n=1,o=32,l=16,u=0,p=Math.PI*2,g=0,y=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:n,widthSegments:o,heightSegments:l,phiStart:u,phiLength:p,thetaStart:g,thetaLength:y},o=Math.max(3,Math.floor(o)),l=Math.max(2,Math.floor(l));const b=Math.min(g+y,Math.PI);let S=0;const A=[],R=new ie,N=new ie,L=[],I=[],B=[],Z=[];for(let q=0;q<=l;q++){const ee=[],te=q/l;let he=0;q===0&&g===0?he=.5/o:q===l&&b===Math.PI&&(he=-.5/o);for(let Re=0;Re<=o;Re++){const ke=Re/o;R.x=-n*Math.cos(u+ke*p)*Math.sin(g+te*y),R.y=n*Math.cos(g+te*y),R.z=n*Math.sin(u+ke*p)*Math.sin(g+te*y),I.push(R.x,R.y,R.z),N.copy(R).normalize(),B.push(N.x,N.y,N.z),Z.push(ke+he,1-te),ee.push(S++)}A.push(ee)}for(let q=0;q<l;q++)for(let ee=0;ee<o;ee++){const te=A[q][ee+1],he=A[q][ee],Re=A[q+1][ee],ke=A[q+1][ee+1];(q!==0||g>0)&&L.push(te,he,ke),(q!==l-1||b<Math.PI)&&L.push(he,Re,ke)}this.setIndex(L),this.setAttribute("position",new Ht(I,3)),this.setAttribute("normal",new Ht(B,3)),this.setAttribute("uv",new Ht(Z,2))}copy(n){return super.copy(n),this.parameters=Object.assign({},n.parameters),this}static fromJSON(n){return new ru(n.radius,n.widthSegments,n.heightSegments,n.phiStart,n.phiLength,n.thetaStart,n.thetaLength)}}class Ap extends Ya{constructor(n=1,o=0){const l=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],u=[2,1,0,0,3,2,1,3,0,2,3,1];super(l,u,n,o),this.type="TetrahedronGeometry",this.parameters={radius:n,detail:o}}static fromJSON(n){return new Ap(n.radius,n.detail)}}class ad extends $n{constructor(n=1,o=.4,l=12,u=48,p=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:n,tube:o,radialSegments:l,tubularSegments:u,arc:p},l=Math.floor(l),u=Math.floor(u);const g=[],y=[],b=[],S=[],A=new ie,R=new ie,N=new ie;for(let L=0;L<=l;L++)for(let I=0;I<=u;I++){const B=I/u*p,Z=L/l*Math.PI*2;R.x=(n+o*Math.cos(Z))*Math.cos(B),R.y=(n+o*Math.cos(Z))*Math.sin(B),R.z=o*Math.sin(Z),y.push(R.x,R.y,R.z),A.x=n*Math.cos(B),A.y=n*Math.sin(B),N.subVectors(R,A).normalize(),b.push(N.x,N.y,N.z),S.push(I/u),S.push(L/l)}for(let L=1;L<=l;L++)for(let I=1;I<=u;I++){const B=(u+1)*L+I-1,Z=(u+1)*(L-1)+I-1,q=(u+1)*(L-1)+I,ee=(u+1)*L+I;g.push(B,Z,ee),g.push(Z,q,ee)}this.setIndex(g),this.setAttribute("position",new Ht(y,3)),this.setAttribute("normal",new Ht(b,3)),this.setAttribute("uv",new Ht(S,2))}copy(n){return super.copy(n),this.parameters=Object.assign({},n.parameters),this}static fromJSON(n){return new ad(n.radius,n.tube,n.radialSegments,n.tubularSegments,n.arc)}}class su extends $n{constructor(n=1,o=.4,l=64,u=8,p=2,g=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:n,tube:o,tubularSegments:l,radialSegments:u,p,q:g},l=Math.floor(l),u=Math.floor(u);const y=[],b=[],S=[],A=[],R=new ie,N=new ie,L=new ie,I=new ie,B=new ie,Z=new ie,q=new ie;for(let te=0;te<=l;++te){const he=te/l*p*Math.PI*2;ee(he,p,g,n,L),ee(he+.01,p,g,n,I),Z.subVectors(I,L),q.addVectors(I,L),B.crossVectors(Z,q),q.crossVectors(B,Z),B.normalize(),q.normalize();for(let Re=0;Re<=u;++Re){const ke=Re/u*Math.PI*2,We=-o*Math.cos(ke),ze=o*Math.sin(ke);R.x=L.x+(We*q.x+ze*B.x),R.y=L.y+(We*q.y+ze*B.y),R.z=L.z+(We*q.z+ze*B.z),b.push(R.x,R.y,R.z),N.subVectors(R,L).normalize(),S.push(N.x,N.y,N.z),A.push(te/l),A.push(Re/u)}}for(let te=1;te<=l;te++)for(let he=1;he<=u;he++){const Re=(u+1)*(te-1)+(he-1),ke=(u+1)*te+(he-1),We=(u+1)*te+he,ze=(u+1)*(te-1)+he;y.push(Re,ke,ze),y.push(ke,We,ze)}this.setIndex(y),this.setAttribute("position",new Ht(b,3)),this.setAttribute("normal",new Ht(S,3)),this.setAttribute("uv",new Ht(A,2));function ee(te,he,Re,ke,We){const ze=Math.cos(te),lt=Math.sin(te),mt=Re/he*te,Zt=Math.cos(mt);We.x=ke*(2+Zt)*.5*ze,We.y=ke*(2+Zt)*lt*.5,We.z=ke*Math.sin(mt)*.5}}copy(n){return super.copy(n),this.parameters=Object.assign({},n.parameters),this}static fromJSON(n){return new su(n.radius,n.tube,n.tubularSegments,n.radialSegments,n.p,n.q)}}class sl extends $n{constructor(n=new eu(new ie(-1,-1,0),new ie(-1,1,0),new ie(1,1,0)),o=64,l=1,u=8,p=!1){super(),this.type="TubeGeometry",this.parameters={path:n,tubularSegments:o,radius:l,radialSegments:u,closed:p};const g=n.computeFrenetFrames(o,p);this.tangents=g.tangents,this.normals=g.normals,this.binormals=g.binormals;const y=new ie,b=new ie,S=new dt;let A=new ie;const R=[],N=[],L=[],I=[];B(),this.setIndex(I),this.setAttribute("position",new Ht(R,3)),this.setAttribute("normal",new Ht(N,3)),this.setAttribute("uv",new Ht(L,2));function B(){for(let te=0;te<o;te++)Z(te);Z(p===!1?o:0),ee(),q()}function Z(te){A=n.getPointAt(te/o,A);const he=g.normals[te],Re=g.binormals[te];for(let ke=0;ke<=u;ke++){const We=ke/u*Math.PI*2,ze=Math.sin(We),lt=-Math.cos(We);b.x=lt*he.x+ze*Re.x,b.y=lt*he.y+ze*Re.y,b.z=lt*he.z+ze*Re.z,b.normalize(),N.push(b.x,b.y,b.z),y.x=A.x+l*b.x,y.y=A.y+l*b.y,y.z=A.z+l*b.z,R.push(y.x,y.y,y.z)}}function q(){for(let te=1;te<=o;te++)for(let he=1;he<=u;he++){const Re=(u+1)*(te-1)+(he-1),ke=(u+1)*te+(he-1),We=(u+1)*te+he,ze=(u+1)*(te-1)+he;I.push(Re,ke,ze),I.push(ke,We,ze)}}function ee(){for(let te=0;te<=o;te++)for(let he=0;he<=u;he++)S.x=te/o,S.y=he/u,L.push(S.x,S.y)}}copy(n){return super.copy(n),this.parameters=Object.assign({},n.parameters),this}toJSON(){const n=super.toJSON();return n.path=this.parameters.path.toJSON(),n}static fromJSON(n){return new sl(new tu[n.path.type]().fromJSON(n.path),n.tubularSegments,n.radius,n.radialSegments,n.closed)}}class Ep extends $n{constructor(n=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:n},n!==null){const o=[],l=new Set,u=new ie,p=new ie;if(n.index!==null){const g=n.attributes.position,y=n.index;let b=n.groups;b.length===0&&(b=[{start:0,count:y.count,materialIndex:0}]);for(let S=0,A=b.length;S<A;++S){const R=b[S],N=R.start,L=R.count;for(let I=N,B=N+L;I<B;I+=3)for(let Z=0;Z<3;Z++){const q=y.getX(I+Z),ee=y.getX(I+(Z+1)%3);u.fromBufferAttribute(g,q),p.fromBufferAttribute(g,ee),ou(u,p,l)===!0&&(o.push(u.x,u.y,u.z),o.push(p.x,p.y,p.z))}}}else{const g=n.attributes.position;for(let y=0,b=g.count/3;y<b;y++)for(let S=0;S<3;S++){const A=3*y+S,R=3*y+(S+1)%3;u.fromBufferAttribute(g,A),p.fromBufferAttribute(g,R),ou(u,p,l)===!0&&(o.push(u.x,u.y,u.z),o.push(p.x,p.y,p.z))}}this.setAttribute("position",new Ht(o,3))}}copy(n){return super.copy(n),this.parameters=Object.assign({},n.parameters),this}}function ou(M,n,o){const l=`${M.x},${M.y},${M.z}-${n.x},${n.y},${n.z}`,u=`${n.x},${n.y},${n.z}-${M.x},${M.y},${M.z}`;return o.has(l)===!0||o.has(u)===!0?!1:(o.add(l),o.add(u),!0)}var au=Object.freeze({__proto__:null,BoxGeometry:zl,CapsuleGeometry:rp,CircleGeometry:sp,ConeGeometry:Qc,CylinderGeometry:Ql,DodecahedronGeometry:op,EdgesGeometry:Yy,ExtrudeGeometry:Sp,IcosahedronGeometry:rd,LatheGeometry:Tp,OctahedronGeometry:sd,PlaneGeometry:od,PolyhedronGeometry:Ya,RingGeometry:Mp,ShapeGeometry:wp,SphereGeometry:ru,TetrahedronGeometry:Ap,TorusGeometry:ad,TorusKnotGeometry:su,TubeGeometry:sl,WireframeGeometry:Ep});class Cp extends Lr{constructor(n){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Nn(0),this.transparent=!0,this.fog=!0,this.setValues(n)}copy(n){return super.copy(n),this.color.copy(n.color),this.fog=n.fog,this}}class Rp extends null{constructor(n){super(n),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class ki extends Lr{constructor(n){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Nn(16777215),this.roughness=1,this.metalness=0,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Nn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Pa,this.normalScale=new dt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ds,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(n)}copy(n){return super.copy(n),this.defines={STANDARD:""},this.color.copy(n.color),this.roughness=n.roughness,this.metalness=n.metalness,this.map=n.map,this.lightMap=n.lightMap,this.lightMapIntensity=n.lightMapIntensity,this.aoMap=n.aoMap,this.aoMapIntensity=n.aoMapIntensity,this.emissive.copy(n.emissive),this.emissiveMap=n.emissiveMap,this.emissiveIntensity=n.emissiveIntensity,this.bumpMap=n.bumpMap,this.bumpScale=n.bumpScale,this.normalMap=n.normalMap,this.normalMapType=n.normalMapType,this.normalScale.copy(n.normalScale),this.displacementMap=n.displacementMap,this.displacementScale=n.displacementScale,this.displacementBias=n.displacementBias,this.roughnessMap=n.roughnessMap,this.metalnessMap=n.metalnessMap,this.alphaMap=n.alphaMap,this.envMap=n.envMap,this.envMapRotation.copy(n.envMapRotation),this.envMapIntensity=n.envMapIntensity,this.wireframe=n.wireframe,this.wireframeLinewidth=n.wireframeLinewidth,this.wireframeLinecap=n.wireframeLinecap,this.wireframeLinejoin=n.wireframeLinejoin,this.flatShading=n.flatShading,this.fog=n.fog,this}}class ol extends ki{constructor(n){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new dt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return an(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(o){this.ior=(1+.4*o)/(1-.4*o)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Nn(0),this.sheenColorMap=null,this.sheenRoughness=1,this.sheenRoughnessMap=null,this.transmissionMap=null,this.thickness=0,this.thicknessMap=null,this.attenuationDistance=1/0,this.attenuationColor=new Nn(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Nn(1,1,1),this.specularColorMap=null,this._anisotropy=0,this._clearcoat=0,this._dispersion=0,this._iridescence=0,this._sheen=0,this._transmission=0,this.setValues(n)}get anisotropy(){return this._anisotropy}set anisotropy(n){this._anisotropy>0!=n>0&&this.version++,this._anisotropy=n}get clearcoat(){return this._clearcoat}set clearcoat(n){this._clearcoat>0!=n>0&&this.version++,this._clearcoat=n}get iridescence(){return this._iridescence}set iridescence(n){this._iridescence>0!=n>0&&this.version++,this._iridescence=n}get dispersion(){return this._dispersion}set dispersion(n){this._dispersion>0!=n>0&&this.version++,this._dispersion=n}get sheen(){return this._sheen}set sheen(n){this._sheen>0!=n>0&&this.version++,this._sheen=n}get transmission(){return this._transmission}set transmission(n){this._transmission>0!=n>0&&this.version++,this._transmission=n}copy(n){return super.copy(n),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=n.anisotropy,this.anisotropyRotation=n.anisotropyRotation,this.anisotropyMap=n.anisotropyMap,this.clearcoat=n.clearcoat,this.clearcoatMap=n.clearcoatMap,this.clearcoatRoughness=n.clearcoatRoughness,this.clearcoatRoughnessMap=n.clearcoatRoughnessMap,this.clearcoatNormalMap=n.clearcoatNormalMap,this.clearcoatNormalScale.copy(n.clearcoatNormalScale),this.dispersion=n.dispersion,this.ior=n.ior,this.iridescence=n.iridescence,this.iridescenceMap=n.iridescenceMap,this.iridescenceIOR=n.iridescenceIOR,this.iridescenceThicknessRange=[...n.iridescenceThicknessRange],this.iridescenceThicknessMap=n.iridescenceThicknessMap,this.sheen=n.sheen,this.sheenColor.copy(n.sheenColor),this.sheenColorMap=n.sheenColorMap,this.sheenRoughness=n.sheenRoughness,this.sheenRoughnessMap=n.sheenRoughnessMap,this.transmission=n.transmission,this.transmissionMap=n.transmissionMap,this.thickness=n.thickness,this.thicknessMap=n.thicknessMap,this.attenuationDistance=n.attenuationDistance,this.attenuationColor.copy(n.attenuationColor),this.specularIntensity=n.specularIntensity,this.specularIntensityMap=n.specularIntensityMap,this.specularColor.copy(n.specularColor),this.specularColorMap=n.specularColorMap,this}}class Np extends Lr{constructor(n){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Nn(16777215),this.specular=new Nn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Nn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Pa,this.normalScale=new dt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ds,this.combine=Qu,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(n)}copy(n){return super.copy(n),this.color.copy(n.color),this.specular.copy(n.specular),this.shininess=n.shininess,this.map=n.map,this.lightMap=n.lightMap,this.lightMapIntensity=n.lightMapIntensity,this.aoMap=n.aoMap,this.aoMapIntensity=n.aoMapIntensity,this.emissive.copy(n.emissive),this.emissiveMap=n.emissiveMap,this.emissiveIntensity=n.emissiveIntensity,this.bumpMap=n.bumpMap,this.bumpScale=n.bumpScale,this.normalMap=n.normalMap,this.normalMapType=n.normalMapType,this.normalScale.copy(n.normalScale),this.displacementMap=n.displacementMap,this.displacementScale=n.displacementScale,this.displacementBias=n.displacementBias,this.specularMap=n.specularMap,this.alphaMap=n.alphaMap,this.envMap=n.envMap,this.envMapRotation.copy(n.envMapRotation),this.combine=n.combine,this.reflectivity=n.reflectivity,this.refractionRatio=n.refractionRatio,this.wireframe=n.wireframe,this.wireframeLinewidth=n.wireframeLinewidth,this.wireframeLinecap=n.wireframeLinecap,this.wireframeLinejoin=n.wireframeLinejoin,this.flatShading=n.flatShading,this.fog=n.fog,this}}class nc extends Lr{constructor(n){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Nn(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Nn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Pa,this.normalScale=new dt(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(n)}copy(n){return super.copy(n),this.color.copy(n.color),this.map=n.map,this.gradientMap=n.gradientMap,this.lightMap=n.lightMap,this.lightMapIntensity=n.lightMapIntensity,this.aoMap=n.aoMap,this.aoMapIntensity=n.aoMapIntensity,this.emissive.copy(n.emissive),this.emissiveMap=n.emissiveMap,this.emissiveIntensity=n.emissiveIntensity,this.bumpMap=n.bumpMap,this.bumpScale=n.bumpScale,this.normalMap=n.normalMap,this.normalMapType=n.normalMapType,this.normalScale.copy(n.normalScale),this.displacementMap=n.displacementMap,this.displacementScale=n.displacementScale,this.displacementBias=n.displacementBias,this.alphaMap=n.alphaMap,this.wireframe=n.wireframe,this.wireframeLinewidth=n.wireframeLinewidth,this.wireframeLinecap=n.wireframeLinecap,this.wireframeLinejoin=n.wireframeLinejoin,this.fog=n.fog,this}}class Oe extends Lr{constructor(n){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Pa,this.normalScale=new dt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(n)}copy(n){return super.copy(n),this.bumpMap=n.bumpMap,this.bumpScale=n.bumpScale,this.normalMap=n.normalMap,this.normalMapType=n.normalMapType,this.normalScale.copy(n.normalScale),this.displacementMap=n.displacementMap,this.displacementScale=n.displacementScale,this.displacementBias=n.displacementBias,this.wireframe=n.wireframe,this.wireframeLinewidth=n.wireframeLinewidth,this.flatShading=n.flatShading,this}}class al extends Lr{constructor(n){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Nn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Nn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Pa,this.normalScale=new dt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ds,this.combine=Qu,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(n)}copy(n){return super.copy(n),this.color.copy(n.color),this.map=n.map,this.lightMap=n.lightMap,this.lightMapIntensity=n.lightMapIntensity,this.aoMap=n.aoMap,this.aoMapIntensity=n.aoMapIntensity,this.emissive.copy(n.emissive),this.emissiveMap=n.emissiveMap,this.emissiveIntensity=n.emissiveIntensity,this.bumpMap=n.bumpMap,this.bumpScale=n.bumpScale,this.normalMap=n.normalMap,this.normalMapType=n.normalMapType,this.normalScale.copy(n.normalScale),this.displacementMap=n.displacementMap,this.displacementScale=n.displacementScale,this.displacementBias=n.displacementBias,this.specularMap=n.specularMap,this.alphaMap=n.alphaMap,this.envMap=n.envMap,this.envMapRotation.copy(n.envMapRotation),this.combine=n.combine,this.reflectivity=n.reflectivity,this.refractionRatio=n.refractionRatio,this.wireframe=n.wireframe,this.wireframeLinewidth=n.wireframeLinewidth,this.wireframeLinecap=n.wireframeLinecap,this.wireframeLinejoin=n.wireframeLinejoin,this.flatShading=n.flatShading,this.fog=n.fog,this}}class cu extends Lr{constructor(n){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=bg,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(n)}copy(n){return super.copy(n),this.depthPacking=n.depthPacking,this.map=n.map,this.alphaMap=n.alphaMap,this.displacementMap=n.displacementMap,this.displacementScale=n.displacementScale,this.displacementBias=n.displacementBias,this.wireframe=n.wireframe,this.wireframeLinewidth=n.wireframeLinewidth,this}}class ua extends Lr{constructor(n){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(n)}copy(n){return super.copy(n),this.map=n.map,this.alphaMap=n.alphaMap,this.displacementMap=n.displacementMap,this.displacementScale=n.displacementScale,this.displacementBias=n.displacementBias,this}}class sn extends Lr{constructor(n){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Nn(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Pa,this.normalScale=new dt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.fog=!0,this.setValues(n)}copy(n){return super.copy(n),this.defines={MATCAP:""},this.color.copy(n.color),this.matcap=n.matcap,this.map=n.map,this.bumpMap=n.bumpMap,this.bumpScale=n.bumpScale,this.normalMap=n.normalMap,this.normalMapType=n.normalMapType,this.normalScale.copy(n.normalScale),this.displacementMap=n.displacementMap,this.displacementScale=n.displacementScale,this.displacementBias=n.displacementBias,this.alphaMap=n.alphaMap,this.wireframe=n.wireframe,this.wireframeLinewidth=n.wireframeLinewidth,this.flatShading=n.flatShading,this.fog=n.fog,this}}class pt extends Ur{constructor(n){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(n)}copy(n){return super.copy(n),this.scale=n.scale,this.dashSize=n.dashSize,this.gapSize=n.gapSize,this}}function at(M,n){return!M||M.constructor===n?M:typeof n.BYTES_PER_ELEMENT=="number"?new n(M):Array.prototype.slice.call(M)}function T0(M){return ArrayBuffer.isView(M)&&!(M instanceof DataView)}function M0(M){function n(u,p){return M[u]-M[p]}const o=M.length,l=new Array(o);for(let u=0;u!==o;++u)l[u]=u;return l.sort(n),l}function fe(M,n,o){const l=M.length,u=new M.constructor(l);for(let p=0,g=0;g!==l;++p){const y=o[p]*n;for(let b=0;b!==n;++b)u[g++]=M[y+b]}return u}function ic(M,n,o,l){let u=1,p=M[0];for(;p!==void 0&&p[l]===void 0;)p=M[u++];if(p===void 0)return;let g=p[l];if(g!==void 0)if(Array.isArray(g))do g=p[l],g!==void 0&&(n.push(p.time),o.push(...g)),p=M[u++];while(p!==void 0);else if(g.toArray!==void 0)do g=p[l],g!==void 0&&(n.push(p.time),g.toArray(o,o.length)),p=M[u++];while(p!==void 0);else do g=p[l],g!==void 0&&(n.push(p.time),o.push(g)),p=M[u++];while(p!==void 0)}function Pp(M,n,o,l,u=30){const p=M.clone();p.name=n;const g=[];for(let b=0;b<p.tracks.length;++b){const S=p.tracks[b],A=S.getValueSize(),R=[],N=[];for(let L=0;L<S.times.length;++L){const I=S.times[L]*u;if(!(I<o||I>=l)){R.push(S.times[L]);for(let B=0;B<A;++B)N.push(S.values[L*A+B])}}R.length!==0&&(S.times=at(R,S.times.constructor),S.values=at(N,S.values.constructor),g.push(S))}p.tracks=g;let y=1/0;for(let b=0;b<p.tracks.length;++b)y>p.tracks[b].times[0]&&(y=p.tracks[b].times[0]);for(let b=0;b<p.tracks.length;++b)p.tracks[b].shift(-1*y);return p.resetDuration(),p}function Dt(M,n=0,o=M,l=30){l<=0&&(l=30);const u=o.tracks.length,p=n/l;for(let g=0;g<u;++g){const y=o.tracks[g],b=y.ValueTypeName;if(b==="bool"||b==="string")continue;const S=M.tracks.find(function(q){return q.name===y.name&&q.ValueTypeName===b});if(S===void 0)continue;let A=0;const R=y.getValueSize();y.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(A=R/3);let N=0;const L=S.getValueSize();S.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(N=L/3);const I=y.times.length-1;let B;if(p<=y.times[0]){const q=A,ee=R-A;B=y.values.slice(q,ee)}else if(p>=y.times[I]){const q=I*R+A,ee=q+R-A;B=y.values.slice(q,ee)}else{const q=y.createInterpolant(),ee=A,te=R-A;q.evaluate(p),B=q.resultBuffer.slice(ee,te)}b==="quaternion"&&new Hr().fromArray(B).normalize().conjugate().toArray(B);const Z=S.times.length;for(let q=0;q<Z;++q){const ee=q*L+N;if(b==="quaternion")Hr.multiplyQuaternionsFlat(S.values,ee,B,0,S.values,ee);else{const te=L-N*2;for(let he=0;he<te;++he)S.values[ee+he]-=B[he]}}}return M.blendMode=lf,M}class _T{static convertArray(n,o){return at(n,o)}static isTypedArray(n){return T0(n)}static getKeyframeOrder(n){return M0(n)}static sortedArray(n,o,l){return fe(n,o,l)}static flattenJSON(n,o,l,u){ic(n,o,l,u)}static subclip(n,o,l,u,p=30){return Pp(n,o,l,u,p)}static makeClipAdditive(n,o=0,l=n,u=30){return Dt(n,o,l,u)}}class rc{constructor(n,o,l,u){this.parameterPositions=n,this._cachedIndex=0,this.resultBuffer=u!==void 0?u:new o.constructor(l),this.sampleValues=o,this.valueSize=l,this.settings=null,this.DefaultSettings_={}}evaluate(n){const o=this.parameterPositions;let l=this._cachedIndex,u=o[l],p=o[l-1];e:{t:{let g;n:{i:if(!(n<u)){for(let y=l+2;;){if(u===void 0){if(n<p)break i;return l=o.length,this._cachedIndex=l,this.copySampleValue_(l-1)}if(l===y)break;if(p=u,u=o[++l],n<u)break t}g=o.length;break n}if(!(n>=p)){const y=o[1];n<y&&(l=2,p=y);for(let b=l-2;;){if(p===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(l===b)break;if(u=p,p=o[--l-1],n>=p)break t}g=l,l=0;break n}break e}for(;l<g;){const y=l+g>>>1;n<o[y]?g=y:l=y+1}if(u=o[l],p=o[l-1],p===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(u===void 0)return l=o.length,this._cachedIndex=l,this.copySampleValue_(l-1)}this._cachedIndex=l,this.intervalChanged_(l,p,u)}return this.interpolate_(l,p,n,u)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(n){const o=this.resultBuffer,l=this.sampleValues,u=this.valueSize,p=n*u;for(let g=0;g!==u;++g)o[g]=l[p+g];return o}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class w0 extends rc{constructor(n,o,l,u){super(n,o,l,u),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Rc,endingEnd:Rc}}intervalChanged_(n,o,l){const u=this.parameterPositions;let p=n-2,g=n+1,y=u[p],b=u[g];if(y===void 0)switch(this.getSettings_().endingStart){case Nc:p=n,y=2*o-l;break;case Pl:p=u.length-2,y=o+u[p]-u[p+1];break;default:p=n,y=l}if(b===void 0)switch(this.getSettings_().endingEnd){case Nc:g=n,b=2*l-o;break;case Pl:g=1,b=l+u[1]-u[0];break;default:g=n-1,b=o}const S=(l-o)*.5,A=this.valueSize;this._weightPrev=S/(o-y),this._weightNext=S/(b-l),this._offsetPrev=p*A,this._offsetNext=g*A}interpolate_(n,o,l,u){const p=this.resultBuffer,g=this.sampleValues,y=this.valueSize,b=n*y,S=b-y,A=this._offsetPrev,R=this._offsetNext,N=this._weightPrev,L=this._weightNext,I=(l-o)/(u-o),B=I*I,Z=B*I,q=-N*Z+2*N*B-N*I,ee=(1+N)*Z+(-1.5-2*N)*B+(-.5+N)*I+1,te=(-1-L)*Z+(1.5+L)*B+.5*I,he=L*Z-L*B;for(let Re=0;Re!==y;++Re)p[Re]=q*g[A+Re]+ee*g[S+Re]+te*g[b+Re]+he*g[R+Re];return p}}class G extends rc{constructor(n,o,l,u){super(n,o,l,u)}interpolate_(n,o,l,u){const p=this.resultBuffer,g=this.sampleValues,y=this.valueSize,b=n*y,S=b-y,A=(l-o)/(u-o),R=1-A;for(let N=0;N!==y;++N)p[N]=g[S+N]*R+g[b+N]*A;return p}}class re extends rc{constructor(n,o,l,u){super(n,o,l,u)}interpolate_(n){return this.copySampleValue_(n-1)}}class Je{constructor(n,o,l,u){if(n===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(o===void 0||o.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+n);this.name=n,this.times=at(o,this.TimeBufferType),this.values=at(l,this.ValueBufferType),this.setInterpolation(u||this.DefaultInterpolation)}static toJSON(n){const o=n.constructor;let l;if(o.toJSON!==this.toJSON)l=o.toJSON(n);else{l={name:n.name,times:at(n.times,Array),values:at(n.values,Array)};const u=n.getInterpolation();u!==n.DefaultInterpolation&&(l.interpolation=u)}return l.type=n.ValueTypeName,l}InterpolantFactoryMethodDiscrete(n){return new re(this.times,this.values,this.getValueSize(),n)}InterpolantFactoryMethodLinear(n){return new G(this.times,this.values,this.getValueSize(),n)}InterpolantFactoryMethodSmooth(n){return new w0(this.times,this.values,this.getValueSize(),n)}setInterpolation(n){let o;switch(n){case uh:o=this.InterpolantFactoryMethodDiscrete;break;case af:o=this.InterpolantFactoryMethodLinear;break;case Kt:o=this.InterpolantFactoryMethodSmooth;break}if(o===void 0){const l="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(n!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(l);return dn("KeyframeTrack:",l),this}return this.createInterpolant=o,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return uh;case this.InterpolantFactoryMethodLinear:return af;case this.InterpolantFactoryMethodSmooth:return Kt}}getValueSize(){return this.values.length/this.times.length}shift(n){if(n!==0){const o=this.times;for(let l=0,u=o.length;l!==u;++l)o[l]+=n}return this}scale(n){if(n!==1){const o=this.times;for(let l=0,u=o.length;l!==u;++l)o[l]*=n}return this}trim(n,o){const l=this.times,u=l.length;let p=0,g=u-1;for(;p!==u&&l[p]<n;)++p;for(;g!==-1&&l[g]>o;)--g;if(++g,p!==0||g!==u){p>=g&&(g=Math.max(g,1),p=g-1);const y=this.getValueSize();this.times=l.slice(p,g),this.values=this.values.slice(p*y,g*y)}return this}validate(){let n=!0;const o=this.getValueSize();o-Math.floor(o)!==0&&(Yn("KeyframeTrack: Invalid value size in track.",this),n=!1);const l=this.times,u=this.values,p=l.length;p===0&&(Yn("KeyframeTrack: Track is empty.",this),n=!1);let g=null;for(let y=0;y!==p;y++){const b=l[y];if(typeof b=="number"&&isNaN(b)){Yn("KeyframeTrack: Time is not a valid number.",this,y,b),n=!1;break}if(g!==null&&g>b){Yn("KeyframeTrack: Out of order keys.",this,y,b,g),n=!1;break}g=b}if(u!==void 0&&T0(u))for(let y=0,b=u.length;y!==b;++y){const S=u[y];if(isNaN(S)){Yn("KeyframeTrack: Value is not a valid number.",this,y,S),n=!1;break}}return n}optimize(){const n=this.times.slice(),o=this.values.slice(),l=this.getValueSize(),u=this.getInterpolation()===Kt,p=n.length-1;let g=1;for(let y=1;y<p;++y){let b=!1;const S=n[y],A=n[y+1];if(S!==A&&(y!==1||S!==n[0]))if(u)b=!0;else{const R=y*l,N=R-l,L=R+l;for(let I=0;I!==l;++I){const B=o[R+I];if(B!==o[N+I]||B!==o[L+I]){b=!0;break}}}if(b){if(y!==g){n[g]=n[y];const R=y*l,N=g*l;for(let L=0;L!==l;++L)o[N+L]=o[R+L]}++g}}if(p>0){n[g]=n[p];for(let y=p*l,b=g*l,S=0;S!==l;++S)o[b+S]=o[y+S];++g}return g!==n.length?(this.times=n.slice(0,g),this.values=o.slice(0,g*l)):(this.times=n,this.values=o),this}clone(){const n=this.times.slice(),o=this.values.slice(),l=this.constructor,u=new l(this.name,n,o);return u.createInterpolant=this.createInterpolant,u}}Je.prototype.ValueTypeName="",Je.prototype.TimeBufferType=Float32Array,Je.prototype.ValueBufferType=Float32Array,Je.prototype.DefaultInterpolation=af;class br extends Je{constructor(n,o,l){super(n,o,l)}}br.prototype.ValueTypeName="bool",br.prototype.ValueBufferType=Array,br.prototype.DefaultInterpolation=uh,br.prototype.InterpolantFactoryMethodLinear=void 0,br.prototype.InterpolantFactoryMethodSmooth=void 0;class Ve extends Je{constructor(n,o,l,u){super(n,o,l,u)}}Ve.prototype.ValueTypeName="color";class Vi extends Je{constructor(n,o,l,u){super(n,o,l,u)}}Vi.prototype.ValueTypeName="number";class A0 extends rc{constructor(n,o,l,u){super(n,o,l,u)}interpolate_(n,o,l,u){const p=this.resultBuffer,g=this.sampleValues,y=this.valueSize,b=(l-o)/(u-o);let S=n*y;for(let A=S+y;S!==A;S+=4)Hr.slerpFlat(p,0,g,S-y,g,S,b);return p}}class lu extends Je{constructor(n,o,l,u){super(n,o,l,u)}InterpolantFactoryMethodLinear(n){return new A0(this.times,this.values,this.getValueSize(),n)}}lu.prototype.ValueTypeName="quaternion",lu.prototype.InterpolantFactoryMethodSmooth=void 0;class ce extends Je{constructor(n,o,l){super(n,o,l)}}ce.prototype.ValueTypeName="string",ce.prototype.ValueBufferType=Array,ce.prototype.DefaultInterpolation=uh,ce.prototype.InterpolantFactoryMethodLinear=void 0,ce.prototype.InterpolantFactoryMethodSmooth=void 0;class uu extends Je{constructor(n,o,l,u){super(n,o,l,u)}}uu.prototype.ValueTypeName="vector";class zo{constructor(n="",o=-1,l=[],u=cf){this.name=n,this.tracks=l,this.duration=o,this.blendMode=u,this.uuid=gr(),this.userData={},this.duration<0&&this.resetDuration()}static parse(n){const o=[],l=n.tracks,u=1/(n.fps||1);for(let g=0,y=l.length;g!==y;++g)o.push(At(l[g]).scale(u));const p=new this(n.name,n.duration,o,n.blendMode);return p.uuid=n.uuid,p.userData=JSON.parse(n.userData||"{}"),p}static toJSON(n){const o=[],l=n.tracks,u={name:n.name,duration:n.duration,tracks:o,uuid:n.uuid,blendMode:n.blendMode,userData:JSON.stringify(n.userData)};for(let p=0,g=l.length;p!==g;++p)o.push(Je.toJSON(l[p]));return u}static CreateFromMorphTargetSequence(n,o,l,u){const p=o.length,g=[];for(let y=0;y<p;y++){let b=[],S=[];b.push((y+p-1)%p,y,(y+1)%p),S.push(0,1,0);const A=M0(b);b=fe(b,1,A),S=fe(S,1,A),!u&&b[0]===0&&(b.push(p),S.push(S[0])),g.push(new Vi(".morphTargetInfluences["+o[y].name+"]",b,S).scale(1/l))}return new this(n,-1,g)}static findByName(n,o){let l=n;if(!Array.isArray(n)){const u=n;l=u.geometry&&u.geometry.animations||u.animations}for(let u=0;u<l.length;u++)if(l[u].name===o)return l[u];return null}static CreateClipsFromMorphTargetSequences(n,o,l){const u={},p=/^([\w-]*?)([\d]+)$/;for(let y=0,b=n.length;y<b;y++){const S=n[y],A=S.name.match(p);if(A&&A.length>1){const R=A[1];let N=u[R];N||(u[R]=N=[]),N.push(S)}}const g=[];for(const y in u)g.push(this.CreateFromMorphTargetSequence(y,u[y],o,l));return g}static parseAnimation(n,o){if(dn("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!n)return Yn("AnimationClip: No animation in JSONLoader data."),null;const l=function(R,N,L,I,B){if(L.length!==0){const Z=[],q=[];ic(L,Z,q,I),Z.length!==0&&B.push(new R(N,Z,q))}},u=[],p=n.name||"default",g=n.fps||30,y=n.blendMode;let b=n.length||-1;const S=n.hierarchy||[];for(let R=0;R<S.length;R++){const N=S[R].keys;if(!(!N||N.length===0))if(N[0].morphTargets){const L={};let I;for(I=0;I<N.length;I++)if(N[I].morphTargets)for(let B=0;B<N[I].morphTargets.length;B++)L[N[I].morphTargets[B]]=-1;for(const B in L){const Z=[],q=[];for(let ee=0;ee!==N[I].morphTargets.length;++ee){const te=N[I];Z.push(te.time),q.push(te.morphTarget===B?1:0)}u.push(new Vi(".morphTargetInfluence["+B+"]",Z,q))}b=L.length*g}else{const L=".bones["+o[R].name+"]";l(uu,L+".position",N,"pos",u),l(lu,L+".quaternion",N,"rot",u),l(uu,L+".scale",N,"scl",u)}}return u.length===0?null:new this(p,b,u,y)}resetDuration(){const n=this.tracks;let o=0;for(let l=0,u=n.length;l!==u;++l){const p=this.tracks[l];o=Math.max(o,p.times[p.times.length-1])}return this.duration=o,this}trim(){for(let n=0;n<this.tracks.length;n++)this.tracks[n].trim(0,this.duration);return this}validate(){let n=!0;for(let o=0;o<this.tracks.length;o++)n=n&&this.tracks[o].validate();return n}optimize(){for(let n=0;n<this.tracks.length;n++)this.tracks[n].optimize();return this}clone(){const n=[];for(let l=0;l<this.tracks.length;l++)n.push(this.tracks[l].clone());const o=new this.constructor(this.name,this.duration,n,this.blendMode);return o.userData=JSON.parse(JSON.stringify(this.userData)),o}toJSON(){return this.constructor.toJSON(this)}}function Lp(M){switch(M.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Vi;case"vector":case"vector2":case"vector3":case"vector4":return uu;case"color":return Ve;case"quaternion":return lu;case"bool":case"boolean":return br;case"string":return ce}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+M)}function At(M){if(M.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const n=Lp(M.type);if(M.times===void 0){const o=[],l=[];ic(M.keys,o,l,"value"),M.times=o,M.values=l}return n.parse!==void 0?n.parse(M):new n(M.name,M.times,M.values,M.interpolation)}const co={enabled:!1,files:{},add:function(M,n){this.enabled!==!1&&(this.files[M]=n)},get:function(M){if(this.enabled!==!1)return this.files[M]},remove:function(M){delete this.files[M]},clear:function(){this.files={}}};class Ip{constructor(n,o,l){const u=this;let p=!1,g=0,y=0,b;const S=[];this.onStart=void 0,this.onLoad=n,this.onProgress=o,this.onError=l,this._abortController=null,this.itemStart=function(A){y++,p===!1&&u.onStart!==void 0&&u.onStart(A,g,y),p=!0},this.itemEnd=function(A){g++,u.onProgress!==void 0&&u.onProgress(A,g,y),g===y&&(p=!1,u.onLoad!==void 0&&u.onLoad())},this.itemError=function(A){u.onError!==void 0&&u.onError(A)},this.resolveURL=function(A){return b?b(A):A},this.setURLModifier=function(A){return b=A,this},this.addHandler=function(A,R){return S.push(A,R),this},this.removeHandler=function(A){const R=S.indexOf(A);return R!==-1&&S.splice(R,2),this},this.getHandler=function(A){for(let R=0,N=S.length;R<N;R+=2){const L=S[R],I=S[R+1];if(L.global&&(L.lastIndex=0),L.test(A))return I}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const E0=new Ip;class cl{constructor(n){this.manager=n!==void 0?n:E0,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(n,o){const l=this;return new Promise(function(u,p){l.load(n,u,o,p)})}parse(){}setCrossOrigin(n){return this.crossOrigin=n,this}setWithCredentials(n){return this.withCredentials=n,this}setPath(n){return this.path=n,this}setResourcePath(n){return this.resourcePath=n,this}setRequestHeader(n){return this.requestHeader=n,this}abort(){return this}}cl.DEFAULT_MATERIAL_NAME="__DEFAULT";const Ni={};class sc extends null{constructor(n,o){super(n),this.response=o}}class ha extends null{constructor(n){super(n),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(n,o,l,u){n===void 0&&(n=""),this.path!==void 0&&(n=this.path+n),n=this.manager.resolveURL(n);const p=co.get(`file:${n}`);if(p!==void 0)return this.manager.itemStart(n),setTimeout(()=>{o&&o(p),this.manager.itemEnd(n)},0),p;if(Ni[n]!==void 0){Ni[n].push({onLoad:o,onProgress:l,onError:u});return}Ni[n]=[],Ni[n].push({onLoad:o,onProgress:l,onError:u});const g=new Request(n,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),y=this.mimeType,b=this.responseType;fetch(g).then(S=>{if(S.status===200||S.status===0){if(S.status===0&&dn("FileLoader: HTTP Status 0 received."),typeof ReadableStream=="undefined"||S.body===void 0||S.body.getReader===void 0)return S;const A=Ni[n],R=S.body.getReader(),N=S.headers.get("X-File-Size")||S.headers.get("Content-Length"),L=N?parseInt(N):0,I=L!==0;let B=0;const Z=new ReadableStream({start(q){ee();function ee(){R.read().then(({done:te,value:he})=>{if(te)q.close();else{B+=he.byteLength;const Re=new ProgressEvent("progress",{lengthComputable:I,loaded:B,total:L});for(let ke=0,We=A.length;ke<We;ke++){const ze=A[ke];ze.onProgress&&ze.onProgress(Re)}q.enqueue(he),ee()}},te=>{q.error(te)})}}});return new Response(Z)}else throw new sc(`fetch for "${S.url}" responded with ${S.status}: ${S.statusText}`,S)}).then(S=>{switch(b){case"arraybuffer":return S.arrayBuffer();case"blob":return S.blob();case"document":return S.text().then(A=>new DOMParser().parseFromString(A,y));case"json":return S.json();default:if(y==="")return S.text();{const R=/charset="?([^;"\s]*)"?/i.exec(y),N=R&&R[1]?R[1].toLowerCase():void 0,L=new TextDecoder(N);return S.arrayBuffer().then(I=>L.decode(I))}}}).then(S=>{co.add(`file:${n}`,S);const A=Ni[n];delete Ni[n];for(let R=0,N=A.length;R<N;R++){const L=A[R];L.onLoad&&L.onLoad(S)}}).catch(S=>{const A=Ni[n];if(A===void 0)throw this.manager.itemError(n),S;delete Ni[n];for(let R=0,N=A.length;R<N;R++){const L=A[R];L.onError&&L.onError(S)}this.manager.itemError(n)}).finally(()=>{this.manager.itemEnd(n)}),this.manager.itemStart(n)}setResponseType(n){return this.responseType=n,this}setMimeType(n){return this.mimeType=n,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class yT extends null{constructor(n){super(n)}load(n,o,l,u){const p=this,g=new ha(this.manager);g.setPath(this.path),g.setRequestHeader(this.requestHeader),g.setWithCredentials(this.withCredentials),g.load(n,function(y){try{o(p.parse(JSON.parse(y)))}catch(b){u?u(b):Yn(b),p.manager.itemError(n)}},l,u)}parse(n){const o=[];for(let l=0;l<n.length;l++){const u=zo.parse(n[l]);o.push(u)}return o}}class ub extends null{constructor(n){super(n)}load(n,o,l,u){const p=this,g=[],y=new $y,b=new ha(this.manager);b.setPath(this.path),b.setResponseType("arraybuffer"),b.setRequestHeader(this.requestHeader),b.setWithCredentials(p.withCredentials);let S=0;function A(R){b.load(n[R],function(N){const L=p.parse(N,!0);g[R]={width:L.width,height:L.height,format:L.format,mipmaps:L.mipmaps},S+=1,S===6&&(L.mipmapCount===1&&(y.minFilter=Yr),y.image=g,y.format=L.format,y.needsUpdate=!0,o&&o(y))},l,u)}if(Array.isArray(n))for(let R=0,N=n.length;R<N;++R)A(R);else b.load(n,function(R){const N=p.parse(R,!0);if(N.isCubemap){const L=N.mipmaps.length/N.mipmapCount;for(let I=0;I<L;I++){g[I]={mipmaps:[]};for(let B=0;B<N.mipmapCount;B++)g[I].mipmaps.push(N.mipmaps[I*N.mipmapCount+B]),g[I].format=N.format,g[I].width=N.width,g[I].height=N.height}y.image=g}else y.image.width=N.width,y.image.height=N.height,y.mipmaps=N.mipmaps;N.mipmapCount===1&&(y.minFilter=Yr),y.format=N.format,y.needsUpdate=!0,o&&o(y)},l,u);return y}}const oc=new WeakMap;class cd extends cl{constructor(n){super(n)}load(n,o,l,u){this.path!==void 0&&(n=this.path+n),n=this.manager.resolveURL(n);const p=this,g=co.get(`image:${n}`);if(g!==void 0){if(g.complete===!0)p.manager.itemStart(n),setTimeout(function(){o&&o(g),p.manager.itemEnd(n)},0);else{let R=oc.get(g);R===void 0&&(R=[],oc.set(g,R)),R.push({onLoad:o,onError:u})}return g}const y=Il("img");function b(){A(),o&&o(this);const R=oc.get(this)||[];for(let N=0;N<R.length;N++){const L=R[N];L.onLoad&&L.onLoad(this)}oc.delete(this),p.manager.itemEnd(n)}function S(R){A(),u&&u(R),co.remove(`image:${n}`);const N=oc.get(this)||[];for(let L=0;L<N.length;L++){const I=N[L];I.onError&&I.onError(R)}oc.delete(this),p.manager.itemError(n),p.manager.itemEnd(n)}function A(){y.removeEventListener("load",b,!1),y.removeEventListener("error",S,!1)}return y.addEventListener("load",b,!1),y.addEventListener("error",S,!1),n.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(y.crossOrigin=this.crossOrigin),co.add(`image:${n}`,y),p.manager.itemStart(n),y.src=n,y}}class bT extends null{constructor(n){super(n)}load(n,o,l,u){const p=new Nh;p.colorSpace=Qr;const g=new cd(this.manager);g.setCrossOrigin(this.crossOrigin),g.setPath(this.path);let y=0;function b(S){g.load(n[S],function(A){p.images[S]=A,y++,y===6&&(p.needsUpdate=!0,o&&o(p))},void 0,u)}for(let S=0;S<n.length;++S)b(S);return p}}class oi extends null{constructor(n){super(n)}load(n,o,l,u){const p=this,g=new io,y=new ha(this.manager);return y.setResponseType("arraybuffer"),y.setRequestHeader(this.requestHeader),y.setPath(this.path),y.setWithCredentials(p.withCredentials),y.load(n,function(b){let S;try{S=p.parse(b)}catch(A){if(u!==void 0)u(A);else{A(A);return}}S.image!==void 0?g.image=S.image:S.data!==void 0&&(g.image.width=S.width,g.image.height=S.height,g.image.data=S.data),g.wrapS=S.wrapS!==void 0?S.wrapS:Rs,g.wrapT=S.wrapT!==void 0?S.wrapT:Rs,g.magFilter=S.magFilter!==void 0?S.magFilter:Yr,g.minFilter=S.minFilter!==void 0?S.minFilter:Yr,g.anisotropy=S.anisotropy!==void 0?S.anisotropy:1,S.colorSpace!==void 0&&(g.colorSpace=S.colorSpace),S.flipY!==void 0&&(g.flipY=S.flipY),S.format!==void 0&&(g.format=S.format),S.type!==void 0&&(g.type=S.type),S.mipmaps!==void 0&&(g.mipmaps=S.mipmaps,g.minFilter=El),S.mipmapCount===1&&(g.minFilter=Yr),S.generateMipmaps!==void 0&&(g.generateMipmaps=S.generateMipmaps),g.needsUpdate=!0,o&&o(g,S)},l,u),g}}class Vs extends cl{constructor(n){super(n)}load(n,o,l,u){const p=new sr,g=new cd(this.manager);return g.setCrossOrigin(this.crossOrigin),g.setPath(this.path),g.load(n,function(y){p.image=y,p.needsUpdate=!0,o!==void 0&&o(p)},l,u),p}}class lr extends Ri{constructor(n,o=1){super(),this.isLight=!0,this.type="Light",this.color=new Nn(n),this.intensity=o}dispose(){}copy(n,o){return super.copy(n,o),this.color.copy(n.color),this.intensity=n.intensity,this}toJSON(n){const o=super.toJSON(n);return o.object.color=this.color.getHex(),o.object.intensity=this.intensity,this.groundColor!==void 0&&(o.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(o.object.distance=this.distance),this.angle!==void 0&&(o.object.angle=this.angle),this.decay!==void 0&&(o.object.decay=this.decay),this.penumbra!==void 0&&(o.object.penumbra=this.penumbra),this.shadow!==void 0&&(o.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(o.object.target=this.target.uuid),o}}class jn extends lr{constructor(n,o,l){super(n,l),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Ri.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Nn(o)}copy(n,o){return super.copy(n,o),this.groundColor.copy(n.groundColor),this}}const hu=new Ln,zs=new ie,ll=new ie;class ul{constructor(n){this.camera=n,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new dt(512,512),this.mapType=Cl,this.map=null,this.mapPass=null,this.matrix=new Ln,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new kh,this._frameExtents=new dt(1,1),this._viewportCount=1,this._viewports=[new or(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(n){const o=this.camera,l=this.matrix;zs.setFromMatrixPosition(n.matrixWorld),o.position.copy(zs),ll.setFromMatrixPosition(n.target.matrixWorld),o.lookAt(ll),o.updateMatrixWorld(),hu.multiplyMatrices(o.projectionMatrix,o.matrixWorldInverse),this._frustum.setFromProjectionMatrix(hu,o.coordinateSystem,o.reversedDepth),o.reversedDepth?l.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):l.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),l.multiply(hu)}getViewport(n){return this._viewports[n]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(n){return this.camera=n.camera.clone(),this.intensity=n.intensity,this.bias=n.bias,this.radius=n.radius,this.autoUpdate=n.autoUpdate,this.needsUpdate=n.needsUpdate,this.normalBias=n.normalBias,this.blurSamples=n.blurSamples,this.mapSize.copy(n.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const n={};return this.intensity!==1&&(n.intensity=this.intensity),this.bias!==0&&(n.bias=this.bias),this.normalBias!==0&&(n.normalBias=this.normalBias),this.radius!==1&&(n.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(n.mapSize=this.mapSize.toArray()),n.camera=this.camera.toJSON(!1).object,delete n.camera.matrix,n}}class du extends ul{constructor(){super(new os(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(n){const o=this.camera,l=Co*2*n.angle*this.focus,u=this.mapSize.width/this.mapSize.height*this.aspect,p=n.distance||o.far;(l!==o.fov||u!==o.aspect||p!==o.far)&&(o.fov=l,o.aspect=u,o.far=p,o.updateProjectionMatrix()),super.updateMatrices(n)}copy(n){return super.copy(n),this.focus=n.focus,this}}class da extends lr{constructor(n,o,l=0,u=Math.PI/3,p=0,g=2){super(n,o),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Ri.DEFAULT_UP),this.updateMatrix(),this.target=new Ri,this.distance=l,this.angle=u,this.penumbra=p,this.decay=g,this.map=null,this.shadow=new du}get power(){return this.intensity*Math.PI}set power(n){this.intensity=n/Math.PI}dispose(){this.shadow.dispose()}copy(n,o){return super.copy(n,o),this.distance=n.distance,this.angle=n.angle,this.penumbra=n.penumbra,this.decay=n.decay,this.target=n.target.clone(),this.shadow=n.shadow.clone(),this}}const fu=new Ln,fa=new ie,pu=new ie;class Dp extends ul{constructor(){super(new os(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new dt(4,2),this._viewportCount=6,this._viewports=[new or(2,1,1,1),new or(0,1,1,1),new or(3,1,1,1),new or(1,1,1,1),new or(3,0,1,1),new or(1,0,1,1)],this._cubeDirections=[new ie(1,0,0),new ie(-1,0,0),new ie(0,0,1),new ie(0,0,-1),new ie(0,1,0),new ie(0,-1,0)],this._cubeUps=[new ie(0,1,0),new ie(0,1,0),new ie(0,1,0),new ie(0,1,0),new ie(0,0,1),new ie(0,0,-1)]}updateMatrices(n,o=0){const l=this.camera,u=this.matrix,p=n.distance||l.far;p!==l.far&&(l.far=p,l.updateProjectionMatrix()),fa.setFromMatrixPosition(n.matrixWorld),l.position.copy(fa),pu.copy(l.position),pu.add(this._cubeDirections[o]),l.up.copy(this._cubeUps[o]),l.lookAt(pu),l.updateMatrixWorld(),u.makeTranslation(-fa.x,-fa.y,-fa.z),fu.multiplyMatrices(l.projectionMatrix,l.matrixWorldInverse),this._frustum.setFromProjectionMatrix(fu,l.coordinateSystem,l.reversedDepth)}}class mu extends lr{constructor(n,o,l=0,u=2){super(n,o),this.isPointLight=!0,this.type="PointLight",this.distance=l,this.decay=u,this.shadow=new Dp}get power(){return this.intensity*4*Math.PI}set power(n){this.intensity=n/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(n,o){return super.copy(n,o),this.distance=n.distance,this.decay=n.decay,this.shadow=n.shadow.clone(),this}}class lo extends $c{constructor(n=-1,o=1,l=1,u=-1,p=.1,g=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=n,this.right=o,this.top=l,this.bottom=u,this.near=p,this.far=g,this.updateProjectionMatrix()}copy(n,o){return super.copy(n,o),this.left=n.left,this.right=n.right,this.top=n.top,this.bottom=n.bottom,this.near=n.near,this.far=n.far,this.zoom=n.zoom,this.view=n.view===null?null:Object.assign({},n.view),this}setViewOffset(n,o,l,u,p,g){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=n,this.view.fullHeight=o,this.view.offsetX=l,this.view.offsetY=u,this.view.width=p,this.view.height=g,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const n=(this.right-this.left)/(2*this.zoom),o=(this.top-this.bottom)/(2*this.zoom),l=(this.right+this.left)/2,u=(this.top+this.bottom)/2;let p=l-n,g=l+n,y=u+o,b=u-o;if(this.view!==null&&this.view.enabled){const S=(this.right-this.left)/this.view.fullWidth/this.zoom,A=(this.top-this.bottom)/this.view.fullHeight/this.zoom;p+=S*this.view.offsetX,g=p+S*this.view.width,y-=A*this.view.offsetY,b=y-A*this.view.height}this.projectionMatrix.makeOrthographic(p,g,y,b,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(n){const o=super.toJSON(n);return o.object.zoom=this.zoom,o.object.left=this.left,o.object.right=this.right,o.object.top=this.top,o.object.bottom=this.bottom,o.object.near=this.near,o.object.far=this.far,this.view!==null&&(o.object.view=Object.assign({},this.view)),o}}class gu extends ul{constructor(){super(new lo(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class pa extends lr{constructor(n,o){super(n,o),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Ri.DEFAULT_UP),this.updateMatrix(),this.target=new Ri,this.shadow=new gu}dispose(){this.shadow.dispose()}copy(n){return super.copy(n),this.target=n.target.clone(),this.shadow=n.shadow.clone(),this}}class as extends lr{constructor(n,o){super(n,o),this.isAmbientLight=!0,this.type="AmbientLight"}}class hl extends lr{constructor(n,o,l=10,u=10){super(n,o),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=l,this.height=u}get power(){return this.intensity*this.width*this.height*Math.PI}set power(n){this.intensity=n/(this.width*this.height*Math.PI)}copy(n){return super.copy(n),this.width=n.width,this.height=n.height,this}toJSON(n){const o=super.toJSON(n);return o.object.width=this.width,o.object.height=this.height,o}}class ld{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let n=0;n<9;n++)this.coefficients.push(new ie)}set(n){for(let o=0;o<9;o++)this.coefficients[o].copy(n[o]);return this}zero(){for(let n=0;n<9;n++)this.coefficients[n].set(0,0,0);return this}getAt(n,o){const l=n.x,u=n.y,p=n.z,g=this.coefficients;return o.copy(g[0]).multiplyScalar(.282095),o.addScaledVector(g[1],.488603*u),o.addScaledVector(g[2],.488603*p),o.addScaledVector(g[3],.488603*l),o.addScaledVector(g[4],1.092548*(l*u)),o.addScaledVector(g[5],1.092548*(u*p)),o.addScaledVector(g[6],.315392*(3*p*p-1)),o.addScaledVector(g[7],1.092548*(l*p)),o.addScaledVector(g[8],.546274*(l*l-u*u)),o}getIrradianceAt(n,o){const l=n.x,u=n.y,p=n.z,g=this.coefficients;return o.copy(g[0]).multiplyScalar(.886227),o.addScaledVector(g[1],2*.511664*u),o.addScaledVector(g[2],2*.511664*p),o.addScaledVector(g[3],2*.511664*l),o.addScaledVector(g[4],2*.429043*l*u),o.addScaledVector(g[5],2*.429043*u*p),o.addScaledVector(g[6],.743125*p*p-.247708),o.addScaledVector(g[7],2*.429043*l*p),o.addScaledVector(g[8],.429043*(l*l-u*u)),o}add(n){for(let o=0;o<9;o++)this.coefficients[o].add(n.coefficients[o]);return this}addScaledSH(n,o){for(let l=0;l<9;l++)this.coefficients[l].addScaledVector(n.coefficients[l],o);return this}scale(n){for(let o=0;o<9;o++)this.coefficients[o].multiplyScalar(n);return this}lerp(n,o){for(let l=0;l<9;l++)this.coefficients[l].lerp(n.coefficients[l],o);return this}equals(n){for(let o=0;o<9;o++)if(!this.coefficients[o].equals(n.coefficients[o]))return!1;return!0}copy(n){return this.set(n.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(n,o=0){const l=this.coefficients;for(let u=0;u<9;u++)l[u].fromArray(n,o+u*3);return this}toArray(n=[],o=0){const l=this.coefficients;for(let u=0;u<9;u++)l[u].toArray(n,o+u*3);return n}static getBasisAt(n,o){const l=n.x,u=n.y,p=n.z;o[0]=.282095,o[1]=.488603*u,o[2]=.488603*p,o[3]=.488603*l,o[4]=1.092548*l*u,o[5]=1.092548*u*p,o[6]=.315392*(3*p*p-1),o[7]=1.092548*l*p,o[8]=.546274*(l*l-u*u)}}class ac extends lr{constructor(n=new ld,o=1){super(void 0,o),this.isLightProbe=!0,this.sh=n}copy(n){return super.copy(n),this.sh.copy(n.sh),this}fromJSON(n){return this.intensity=n.intensity,this.sh.fromArray(n.sh),this}toJSON(n){const o=super.toJSON(n);return o.object.sh=this.sh.toArray(),o}}class Go extends null{constructor(n){super(n),this.textures={}}load(n,o,l,u){const p=this,g=new ha(p.manager);g.setPath(p.path),g.setRequestHeader(p.requestHeader),g.setWithCredentials(p.withCredentials),g.load(n,function(y){try{o(p.parse(JSON.parse(y)))}catch(b){u?u(b):Yn(b),p.manager.itemError(n)}},l,u)}parse(n){const o=this.textures;function l(p){return o[p]===void 0&&dn("MaterialLoader: Undefined texture",p),o[p]}const u=this.createMaterialFromType(n.type);if(n.uuid!==void 0&&(u.uuid=n.uuid),n.name!==void 0&&(u.name=n.name),n.color!==void 0&&u.color!==void 0&&u.color.setHex(n.color),n.roughness!==void 0&&(u.roughness=n.roughness),n.metalness!==void 0&&(u.metalness=n.metalness),n.sheen!==void 0&&(u.sheen=n.sheen),n.sheenColor!==void 0&&(u.sheenColor=new Nn().setHex(n.sheenColor)),n.sheenRoughness!==void 0&&(u.sheenRoughness=n.sheenRoughness),n.emissive!==void 0&&u.emissive!==void 0&&u.emissive.setHex(n.emissive),n.specular!==void 0&&u.specular!==void 0&&u.specular.setHex(n.specular),n.specularIntensity!==void 0&&(u.specularIntensity=n.specularIntensity),n.specularColor!==void 0&&u.specularColor!==void 0&&u.specularColor.setHex(n.specularColor),n.shininess!==void 0&&(u.shininess=n.shininess),n.clearcoat!==void 0&&(u.clearcoat=n.clearcoat),n.clearcoatRoughness!==void 0&&(u.clearcoatRoughness=n.clearcoatRoughness),n.dispersion!==void 0&&(u.dispersion=n.dispersion),n.iridescence!==void 0&&(u.iridescence=n.iridescence),n.iridescenceIOR!==void 0&&(u.iridescenceIOR=n.iridescenceIOR),n.iridescenceThicknessRange!==void 0&&(u.iridescenceThicknessRange=n.iridescenceThicknessRange),n.transmission!==void 0&&(u.transmission=n.transmission),n.thickness!==void 0&&(u.thickness=n.thickness),n.attenuationDistance!==void 0&&(u.attenuationDistance=n.attenuationDistance),n.attenuationColor!==void 0&&u.attenuationColor!==void 0&&u.attenuationColor.setHex(n.attenuationColor),n.anisotropy!==void 0&&(u.anisotropy=n.anisotropy),n.anisotropyRotation!==void 0&&(u.anisotropyRotation=n.anisotropyRotation),n.fog!==void 0&&(u.fog=n.fog),n.flatShading!==void 0&&(u.flatShading=n.flatShading),n.blending!==void 0&&(u.blending=n.blending),n.combine!==void 0&&(u.combine=n.combine),n.side!==void 0&&(u.side=n.side),n.shadowSide!==void 0&&(u.shadowSide=n.shadowSide),n.opacity!==void 0&&(u.opacity=n.opacity),n.transparent!==void 0&&(u.transparent=n.transparent),n.alphaTest!==void 0&&(u.alphaTest=n.alphaTest),n.alphaHash!==void 0&&(u.alphaHash=n.alphaHash),n.depthFunc!==void 0&&(u.depthFunc=n.depthFunc),n.depthTest!==void 0&&(u.depthTest=n.depthTest),n.depthWrite!==void 0&&(u.depthWrite=n.depthWrite),n.colorWrite!==void 0&&(u.colorWrite=n.colorWrite),n.blendSrc!==void 0&&(u.blendSrc=n.blendSrc),n.blendDst!==void 0&&(u.blendDst=n.blendDst),n.blendEquation!==void 0&&(u.blendEquation=n.blendEquation),n.blendSrcAlpha!==void 0&&(u.blendSrcAlpha=n.blendSrcAlpha),n.blendDstAlpha!==void 0&&(u.blendDstAlpha=n.blendDstAlpha),n.blendEquationAlpha!==void 0&&(u.blendEquationAlpha=n.blendEquationAlpha),n.blendColor!==void 0&&u.blendColor!==void 0&&u.blendColor.setHex(n.blendColor),n.blendAlpha!==void 0&&(u.blendAlpha=n.blendAlpha),n.stencilWriteMask!==void 0&&(u.stencilWriteMask=n.stencilWriteMask),n.stencilFunc!==void 0&&(u.stencilFunc=n.stencilFunc),n.stencilRef!==void 0&&(u.stencilRef=n.stencilRef),n.stencilFuncMask!==void 0&&(u.stencilFuncMask=n.stencilFuncMask),n.stencilFail!==void 0&&(u.stencilFail=n.stencilFail),n.stencilZFail!==void 0&&(u.stencilZFail=n.stencilZFail),n.stencilZPass!==void 0&&(u.stencilZPass=n.stencilZPass),n.stencilWrite!==void 0&&(u.stencilWrite=n.stencilWrite),n.wireframe!==void 0&&(u.wireframe=n.wireframe),n.wireframeLinewidth!==void 0&&(u.wireframeLinewidth=n.wireframeLinewidth),n.wireframeLinecap!==void 0&&(u.wireframeLinecap=n.wireframeLinecap),n.wireframeLinejoin!==void 0&&(u.wireframeLinejoin=n.wireframeLinejoin),n.rotation!==void 0&&(u.rotation=n.rotation),n.linewidth!==void 0&&(u.linewidth=n.linewidth),n.dashSize!==void 0&&(u.dashSize=n.dashSize),n.gapSize!==void 0&&(u.gapSize=n.gapSize),n.scale!==void 0&&(u.scale=n.scale),n.polygonOffset!==void 0&&(u.polygonOffset=n.polygonOffset),n.polygonOffsetFactor!==void 0&&(u.polygonOffsetFactor=n.polygonOffsetFactor),n.polygonOffsetUnits!==void 0&&(u.polygonOffsetUnits=n.polygonOffsetUnits),n.dithering!==void 0&&(u.dithering=n.dithering),n.alphaToCoverage!==void 0&&(u.alphaToCoverage=n.alphaToCoverage),n.premultipliedAlpha!==void 0&&(u.premultipliedAlpha=n.premultipliedAlpha),n.forceSinglePass!==void 0&&(u.forceSinglePass=n.forceSinglePass),n.visible!==void 0&&(u.visible=n.visible),n.toneMapped!==void 0&&(u.toneMapped=n.toneMapped),n.userData!==void 0&&(u.userData=n.userData),n.vertexColors!==void 0&&(typeof n.vertexColors=="number"?u.vertexColors=n.vertexColors>0:u.vertexColors=n.vertexColors),n.uniforms!==void 0)for(const p in n.uniforms){const g=n.uniforms[p];switch(u.uniforms[p]={},g.type){case"t":u.uniforms[p].value=l(g.value);break;case"c":u.uniforms[p].value=new Nn().setHex(g.value);break;case"v2":u.uniforms[p].value=new dt().fromArray(g.value);break;case"v3":u.uniforms[p].value=new ie().fromArray(g.value);break;case"v4":u.uniforms[p].value=new or().fromArray(g.value);break;case"m3":u.uniforms[p].value=new Ps().fromArray(g.value);break;case"m4":u.uniforms[p].value=new Ln().fromArray(g.value);break;default:u.uniforms[p].value=g.value}}if(n.defines!==void 0&&(u.defines=n.defines),n.vertexShader!==void 0&&(u.vertexShader=n.vertexShader),n.fragmentShader!==void 0&&(u.fragmentShader=n.fragmentShader),n.glslVersion!==void 0&&(u.glslVersion=n.glslVersion),n.extensions!==void 0)for(const p in n.extensions)u.extensions[p]=n.extensions[p];if(n.lights!==void 0&&(u.lights=n.lights),n.clipping!==void 0&&(u.clipping=n.clipping),n.size!==void 0&&(u.size=n.size),n.sizeAttenuation!==void 0&&(u.sizeAttenuation=n.sizeAttenuation),n.map!==void 0&&(u.map=l(n.map)),n.matcap!==void 0&&(u.matcap=l(n.matcap)),n.alphaMap!==void 0&&(u.alphaMap=l(n.alphaMap)),n.bumpMap!==void 0&&(u.bumpMap=l(n.bumpMap)),n.bumpScale!==void 0&&(u.bumpScale=n.bumpScale),n.normalMap!==void 0&&(u.normalMap=l(n.normalMap)),n.normalMapType!==void 0&&(u.normalMapType=n.normalMapType),n.normalScale!==void 0){let p=n.normalScale;Array.isArray(p)===!1&&(p=[p,p]),u.normalScale=new dt().fromArray(p)}return n.displacementMap!==void 0&&(u.displacementMap=l(n.displacementMap)),n.displacementScale!==void 0&&(u.displacementScale=n.displacementScale),n.displacementBias!==void 0&&(u.displacementBias=n.displacementBias),n.roughnessMap!==void 0&&(u.roughnessMap=l(n.roughnessMap)),n.metalnessMap!==void 0&&(u.metalnessMap=l(n.metalnessMap)),n.emissiveMap!==void 0&&(u.emissiveMap=l(n.emissiveMap)),n.emissiveIntensity!==void 0&&(u.emissiveIntensity=n.emissiveIntensity),n.specularMap!==void 0&&(u.specularMap=l(n.specularMap)),n.specularIntensityMap!==void 0&&(u.specularIntensityMap=l(n.specularIntensityMap)),n.specularColorMap!==void 0&&(u.specularColorMap=l(n.specularColorMap)),n.envMap!==void 0&&(u.envMap=l(n.envMap)),n.envMapRotation!==void 0&&u.envMapRotation.fromArray(n.envMapRotation),n.envMapIntensity!==void 0&&(u.envMapIntensity=n.envMapIntensity),n.reflectivity!==void 0&&(u.reflectivity=n.reflectivity),n.refractionRatio!==void 0&&(u.refractionRatio=n.refractionRatio),n.lightMap!==void 0&&(u.lightMap=l(n.lightMap)),n.lightMapIntensity!==void 0&&(u.lightMapIntensity=n.lightMapIntensity),n.aoMap!==void 0&&(u.aoMap=l(n.aoMap)),n.aoMapIntensity!==void 0&&(u.aoMapIntensity=n.aoMapIntensity),n.gradientMap!==void 0&&(u.gradientMap=l(n.gradientMap)),n.clearcoatMap!==void 0&&(u.clearcoatMap=l(n.clearcoatMap)),n.clearcoatRoughnessMap!==void 0&&(u.clearcoatRoughnessMap=l(n.clearcoatRoughnessMap)),n.clearcoatNormalMap!==void 0&&(u.clearcoatNormalMap=l(n.clearcoatNormalMap)),n.clearcoatNormalScale!==void 0&&(u.clearcoatNormalScale=new dt().fromArray(n.clearcoatNormalScale)),n.iridescenceMap!==void 0&&(u.iridescenceMap=l(n.iridescenceMap)),n.iridescenceThicknessMap!==void 0&&(u.iridescenceThicknessMap=l(n.iridescenceThicknessMap)),n.transmissionMap!==void 0&&(u.transmissionMap=l(n.transmissionMap)),n.thicknessMap!==void 0&&(u.thicknessMap=l(n.thicknessMap)),n.anisotropyMap!==void 0&&(u.anisotropyMap=l(n.anisotropyMap)),n.sheenColorMap!==void 0&&(u.sheenColorMap=l(n.sheenColorMap)),n.sheenRoughnessMap!==void 0&&(u.sheenRoughnessMap=l(n.sheenRoughnessMap)),u}setTextures(n){return this.textures=n,this}createMaterialFromType(n){return Go.createMaterialFromType(n)}static createMaterialFromType(n){const o={ShadowMaterial:Cp,SpriteMaterial:Ih,RawShaderMaterial:Rp,ShaderMaterial:Wl,PointsMaterial:np,MeshPhysicalMaterial:ol,MeshStandardMaterial:ki,MeshPhongMaterial:Np,MeshToonMaterial:nc,MeshNormalMaterial:Oe,MeshLambertMaterial:al,MeshDepthMaterial:cu,MeshDistanceMaterial:ua,MeshBasicMaterial:Wc,MeshMatcapMaterial:sn,LineDashedMaterial:pt,LineBasicMaterial:Ur,Material:Lr};return new o[n]}}class dl{static extractUrlBase(n){const o=n.lastIndexOf("/");return o===-1?"./":n.slice(0,o+1)}static resolveURL(n,o){return typeof n!="string"||n===""?"":(/^https?:\/\//i.test(o)&&/^\//.test(n)&&(o=o.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(n)||/^data:.*,.*$/i.test(n)||/^blob:.*$/i.test(n)?n:o+n)}}class hb extends null{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(n){return super.copy(n),this.instanceCount=n.instanceCount,this}toJSON(){const n=super.toJSON();return n.instanceCount=this.instanceCount,n.isInstancedBufferGeometry=!0,n}}class xu extends null{constructor(n){super(n)}load(n,o,l,u){const p=this,g=new ha(p.manager);g.setPath(p.path),g.setRequestHeader(p.requestHeader),g.setWithCredentials(p.withCredentials),g.load(n,function(y){try{o(p.parse(JSON.parse(y)))}catch(b){u?u(b):Yn(b),p.manager.itemError(n)}},l,u)}parse(n){const o={},l={};function u(L,I){if(o[I]!==void 0)return o[I];const Z=L.interleavedBuffers[I],q=p(L,Z.buffer),ee=Da(Z.type,q),te=new Lh(ee,Z.stride);return te.uuid=Z.uuid,o[I]=te,te}function p(L,I){if(l[I]!==void 0)return l[I];const Z=L.arrayBuffers[I],q=new Uint32Array(Z).buffer;return l[I]=q,q}const g=n.isInstancedBufferGeometry?new hb:new $n,y=n.data.index;if(y!==void 0){const L=Da(y.type,y.array);g.setIndex(new dr(L,1))}const b=n.data.attributes;for(const L in b){const I=b[L];let B;if(I.isInterleavedBufferAttribute){const Z=u(n.data,I.data);B=new Ga(Z,I.itemSize,I.offset,I.normalized)}else{const Z=Da(I.type,I.array),q=I.isInstancedBufferAttribute?Kc:dr;B=new q(Z,I.itemSize,I.normalized)}I.name!==void 0&&(B.name=I.name),I.usage!==void 0&&B.setUsage(I.usage),g.setAttribute(L,B)}const S=n.data.morphAttributes;if(S)for(const L in S){const I=S[L],B=[];for(let Z=0,q=I.length;Z<q;Z++){const ee=I[Z];let te;if(ee.isInterleavedBufferAttribute){const he=u(n.data,ee.data);te=new Ga(he,ee.itemSize,ee.offset,ee.normalized)}else{const he=Da(ee.type,ee.array);te=new dr(he,ee.itemSize,ee.normalized)}ee.name!==void 0&&(te.name=ee.name),B.push(te)}g.morphAttributes[L]=B}n.data.morphTargetsRelative&&(g.morphTargetsRelative=!0);const R=n.data.groups||n.data.drawcalls||n.data.offsets;if(R!==void 0)for(let L=0,I=R.length;L!==I;++L){const B=R[L];g.addGroup(B.start,B.count,B.materialIndex)}const N=n.data.boundingSphere;return N!==void 0&&(g.boundingSphere=new xr().fromJSON(N)),n.name&&(g.name=n.name),n.userData&&(g.userData=n.userData),g}}class Up extends null{constructor(n){super(n)}load(n,o,l,u){const p=this,g=this.path===""?dl.extractUrlBase(n):this.path;this.resourcePath=this.resourcePath||g;const y=new ha(this.manager);y.setPath(this.path),y.setRequestHeader(this.requestHeader),y.setWithCredentials(this.withCredentials),y.load(n,function(b){let S=null;try{S=JSON.parse(b)}catch(R){u!==void 0&&u(R),R("ObjectLoader: Can't parse "+n+".",R.message);return}const A=S.metadata;if(A===void 0||A.type===void 0||A.type.toLowerCase()==="geometry"){u!==void 0&&u(new Error("THREE.ObjectLoader: Can't load "+n)),Yn("ObjectLoader: Can't load "+n);return}p.parse(S,o)},l,u)}loadAsync(n,o){return nn(this,null,function*(){const l=this,u=this.path===""?dl.extractUrlBase(n):this.path;this.resourcePath=this.resourcePath||u;const p=new ha(this.manager);p.setPath(this.path),p.setRequestHeader(this.requestHeader),p.setWithCredentials(this.withCredentials);const g=yield p.loadAsync(n,o),y=JSON.parse(g),b=y.metadata;if(b===void 0||b.type===void 0||b.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+n);return yield l.parseAsync(y)})}parse(n,o){const l=this.parseAnimations(n.animations),u=this.parseShapes(n.shapes),p=this.parseGeometries(n.geometries,u),g=this.parseImages(n.images,function(){o!==void 0&&o(S)}),y=this.parseTextures(n.textures,g),b=this.parseMaterials(n.materials,y),S=this.parseObject(n.object,p,b,y,l),A=this.parseSkeletons(n.skeletons,S);if(this.bindSkeletons(S,A),this.bindLightTargets(S),o!==void 0){let R=!1;for(const N in g)if(g[N].data instanceof HTMLImageElement){R=!0;break}R===!1&&o(S)}return S}parseAsync(n){return nn(this,null,function*(){const o=this.parseAnimations(n.animations),l=this.parseShapes(n.shapes),u=this.parseGeometries(n.geometries,l),p=yield this.parseImagesAsync(n.images),g=this.parseTextures(n.textures,p),y=this.parseMaterials(n.materials,g),b=this.parseObject(n.object,u,y,g,o),S=this.parseSkeletons(n.skeletons,b);return this.bindSkeletons(b,S),this.bindLightTargets(b),b})}parseShapes(n){const o={};if(n!==void 0)for(let l=0,u=n.length;l<u;l++){const p=new la().fromJSON(n[l]);o[p.uuid]=p}return o}parseSkeletons(n,o){const l={},u={};if(o.traverse(function(p){p.isBone&&(u[p.uuid]=p)}),n!==void 0)for(let p=0,g=n.length;p<g;p++){const y=new qf().fromJSON(n[p],u);l[y.uuid]=y}return l}parseGeometries(n,o){const l={};if(n!==void 0){const u=new xu;for(let p=0,g=n.length;p<g;p++){let y;const b=n[p];switch(b.type){case"BufferGeometry":case"InstancedBufferGeometry":y=u.parse(b);break;default:b.type in au?y=au[b.type].fromJSON(b,o):dn(`ObjectLoader: Unsupported geometry type "${b.type}"`)}y.uuid=b.uuid,b.name!==void 0&&(y.name=b.name),b.userData!==void 0&&(y.userData=b.userData),l[b.uuid]=y}}return l}parseMaterials(n,o){const l={},u={};if(n!==void 0){const p=new Go;p.setTextures(o);for(let g=0,y=n.length;g<y;g++){const b=n[g];l[b.uuid]===void 0&&(l[b.uuid]=p.parse(b)),u[b.uuid]=l[b.uuid]}}return u}parseAnimations(n){const o={};if(n!==void 0)for(let l=0;l<n.length;l++){const u=n[l],p=zo.parse(u);o[p.uuid]=p}return o}parseImages(n,o){const l=this,u={};let p;function g(b){return l.manager.itemStart(b),p.load(b,function(){l.manager.itemEnd(b)},void 0,function(){l.manager.itemError(b),l.manager.itemEnd(b)})}function y(b){if(typeof b=="string"){const S=b,A=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(S)?S:l.resourcePath+S;return g(A)}else return b.data?{data:Da(b.type,b.data),width:b.width,height:b.height}:null}if(n!==void 0&&n.length>0){const b=new Ip(o);p=new cd(b),p.setCrossOrigin(this.crossOrigin);for(let S=0,A=n.length;S<A;S++){const R=n[S],N=R.url;if(Array.isArray(N)){const L=[];for(let I=0,B=N.length;I<B;I++){const Z=N[I],q=y(Z);q!==null&&(q instanceof HTMLImageElement?L.push(q):L.push(new io(q.data,q.width,q.height)))}u[R.uuid]=new Ua(L)}else{const L=y(R.url);u[R.uuid]=new Ua(L)}}}return u}parseImagesAsync(n){return nn(this,null,function*(){const o=this,l={};let u;function p(g){return nn(this,null,function*(){if(typeof g=="string"){const y=g,b=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(y)?y:o.resourcePath+y;return yield u.loadAsync(b)}else return g.data?{data:Da(g.type,g.data),width:g.width,height:g.height}:null})}if(n!==void 0&&n.length>0){u=new cd(this.manager),u.setCrossOrigin(this.crossOrigin);for(let g=0,y=n.length;g<y;g++){const b=n[g],S=b.url;if(Array.isArray(S)){const A=[];for(let R=0,N=S.length;R<N;R++){const L=S[R],I=yield p(L);I!==null&&(I instanceof HTMLImageElement?A.push(I):A.push(new io(I.data,I.width,I.height)))}l[b.uuid]=new Ua(A)}else{const A=yield p(b.url);l[b.uuid]=new Ua(A)}}}return l})}parseTextures(n,o){function l(p,g){return typeof p=="number"?p:(dn("ObjectLoader.parseTexture: Constant should be in numeric form.",p),g[p])}const u={};if(n!==void 0)for(let p=0,g=n.length;p<g;p++){const y=n[p];y.image===void 0&&dn('ObjectLoader: No "image" specified for',y.uuid),o[y.image]===void 0&&dn("ObjectLoader: Undefined image",y.image);const b=o[y.image],S=b.data;let A;Array.isArray(S)?(A=new Nh,S.length===6&&(A.needsUpdate=!0)):(S&&S.data?A=new io:A=new sr,S&&(A.needsUpdate=!0)),A.source=b,A.uuid=y.uuid,y.name!==void 0&&(A.name=y.name),y.mapping!==void 0&&(A.mapping=l(y.mapping,Fp)),y.channel!==void 0&&(A.channel=y.channel),y.offset!==void 0&&A.offset.fromArray(y.offset),y.repeat!==void 0&&A.repeat.fromArray(y.repeat),y.center!==void 0&&A.center.fromArray(y.center),y.rotation!==void 0&&(A.rotation=y.rotation),y.wrap!==void 0&&(A.wrapS=l(y.wrap[0],ud),A.wrapT=l(y.wrap[1],ud)),y.format!==void 0&&(A.format=y.format),y.internalFormat!==void 0&&(A.internalFormat=y.internalFormat),y.type!==void 0&&(A.type=y.type),y.colorSpace!==void 0&&(A.colorSpace=y.colorSpace),y.minFilter!==void 0&&(A.minFilter=l(y.minFilter,hd)),y.magFilter!==void 0&&(A.magFilter=l(y.magFilter,hd)),y.anisotropy!==void 0&&(A.anisotropy=y.anisotropy),y.flipY!==void 0&&(A.flipY=y.flipY),y.generateMipmaps!==void 0&&(A.generateMipmaps=y.generateMipmaps),y.premultiplyAlpha!==void 0&&(A.premultiplyAlpha=y.premultiplyAlpha),y.unpackAlignment!==void 0&&(A.unpackAlignment=y.unpackAlignment),y.compareFunction!==void 0&&(A.compareFunction=y.compareFunction),y.userData!==void 0&&(A.userData=y.userData),u[y.uuid]=A}return u}parseObject(n,o,l,u,p){let g;function y(N){return o[N]===void 0&&dn("ObjectLoader: Undefined geometry",N),o[N]}function b(N){if(N!==void 0){if(Array.isArray(N)){const L=[];for(let I=0,B=N.length;I<B;I++){const Z=N[I];l[Z]===void 0&&dn("ObjectLoader: Undefined material",Z),L.push(l[Z])}return L}return l[N]===void 0&&dn("ObjectLoader: Undefined material",N),l[N]}}function S(N){return u[N]===void 0&&dn("ObjectLoader: Undefined texture",N),u[N]}let A,R;switch(n.type){case"Scene":g=new e0,n.background!==void 0&&(Number.isInteger(n.background)?g.background=new Nn(n.background):g.background=S(n.background)),n.environment!==void 0&&(g.environment=S(n.environment)),n.fog!==void 0&&(n.fog.type==="Fog"?g.fog=new Hf(n.fog.color,n.fog.near,n.fog.far):n.fog.type==="FogExp2"&&(g.fog=new Wf(n.fog.color,n.fog.density)),n.fog.name!==""&&(g.fog.name=n.fog.name)),n.backgroundBlurriness!==void 0&&(g.backgroundBlurriness=n.backgroundBlurriness),n.backgroundIntensity!==void 0&&(g.backgroundIntensity=n.backgroundIntensity),n.backgroundRotation!==void 0&&g.backgroundRotation.fromArray(n.backgroundRotation),n.environmentIntensity!==void 0&&(g.environmentIntensity=n.environmentIntensity),n.environmentRotation!==void 0&&g.environmentRotation.fromArray(n.environmentRotation);break;case"PerspectiveCamera":g=new os(n.fov,n.aspect,n.near,n.far),n.focus!==void 0&&(g.focus=n.focus),n.zoom!==void 0&&(g.zoom=n.zoom),n.filmGauge!==void 0&&(g.filmGauge=n.filmGauge),n.filmOffset!==void 0&&(g.filmOffset=n.filmOffset),n.view!==void 0&&(g.view=Object.assign({},n.view));break;case"OrthographicCamera":g=new lo(n.left,n.right,n.top,n.bottom,n.near,n.far),n.zoom!==void 0&&(g.zoom=n.zoom),n.view!==void 0&&(g.view=Object.assign({},n.view));break;case"AmbientLight":g=new as(n.color,n.intensity);break;case"DirectionalLight":g=new pa(n.color,n.intensity),g.target=n.target||"";break;case"PointLight":g=new mu(n.color,n.intensity,n.distance,n.decay);break;case"RectAreaLight":g=new hl(n.color,n.intensity,n.width,n.height);break;case"SpotLight":g=new da(n.color,n.intensity,n.distance,n.angle,n.penumbra,n.decay),g.target=n.target||"";break;case"HemisphereLight":g=new jn(n.color,n.groundColor,n.intensity);break;case"LightProbe":g=new ac().fromJSON(n);break;case"SkinnedMesh":A=y(n.geometry),R=b(n.material),g=new Ny(A,R),n.bindMode!==void 0&&(g.bindMode=n.bindMode),n.bindMatrix!==void 0&&g.bindMatrix.fromArray(n.bindMatrix),n.skeleton!==void 0&&(g.skeleton=n.skeleton);break;case"Mesh":A=y(n.geometry),R=b(n.material),g=new aa(A,R);break;case"InstancedMesh":A=y(n.geometry),R=b(n.material);const N=n.count,L=n.instanceMatrix,I=n.instanceColor;g=new Iy(A,R,N),g.instanceMatrix=new Kc(new Float32Array(L.array),16),I!==void 0&&(g.instanceColor=new Kc(new Float32Array(I.array),I.itemSize));break;case"BatchedMesh":A=y(n.geometry),R=b(n.material),g=new zy(n.maxInstanceCount,n.maxVertexCount,n.maxIndexCount,R),g.geometry=A,g.perObjectFrustumCulled=n.perObjectFrustumCulled,g.sortObjects=n.sortObjects,g._drawRanges=n.drawRanges,g._reservedRanges=n.reservedRanges,g._geometryInfo=n.geometryInfo.map(B=>{let Z=null,q=null;return B.boundingBox!==void 0&&(Z=new wr().fromJSON(B.boundingBox)),B.boundingSphere!==void 0&&(q=new xr().fromJSON(B.boundingSphere)),To(rr({},B),{boundingBox:Z,boundingSphere:q})}),g._instanceInfo=n.instanceInfo,g._availableInstanceIds=n._availableInstanceIds,g._availableGeometryIds=n._availableGeometryIds,g._nextIndexStart=n.nextIndexStart,g._nextVertexStart=n.nextVertexStart,g._geometryCount=n.geometryCount,g._maxInstanceCount=n.maxInstanceCount,g._maxVertexCount=n.maxVertexCount,g._maxIndexCount=n.maxIndexCount,g._geometryInitialized=n.geometryInitialized,g._matricesTexture=S(n.matricesTexture.uuid),g._indirectTexture=S(n.indirectTexture.uuid),n.colorsTexture!==void 0&&(g._colorsTexture=S(n.colorsTexture.uuid)),n.boundingSphere!==void 0&&(g.boundingSphere=new xr().fromJSON(n.boundingSphere)),n.boundingBox!==void 0&&(g.boundingBox=new wr().fromJSON(n.boundingBox));break;case"LOD":g=new Cy;break;case"Line":g=new Yl(y(n.geometry),b(n.material));break;case"LineLoop":g=new Gy(y(n.geometry),b(n.material));break;case"LineSegments":g=new tp(y(n.geometry),b(n.material));break;case"PointCloud":case"Points":g=new Wy(y(n.geometry),b(n.material));break;case"Sprite":g=new t0(b(n.material));break;case"Group":g=new za;break;case"Bone":g=new c0;break;default:g=new Ri}if(g.uuid=n.uuid,n.name!==void 0&&(g.name=n.name),n.matrix!==void 0?(g.matrix.fromArray(n.matrix),n.matrixAutoUpdate!==void 0&&(g.matrixAutoUpdate=n.matrixAutoUpdate),g.matrixAutoUpdate&&g.matrix.decompose(g.position,g.quaternion,g.scale)):(n.position!==void 0&&g.position.fromArray(n.position),n.rotation!==void 0&&g.rotation.fromArray(n.rotation),n.quaternion!==void 0&&g.quaternion.fromArray(n.quaternion),n.scale!==void 0&&g.scale.fromArray(n.scale)),n.up!==void 0&&g.up.fromArray(n.up),n.castShadow!==void 0&&(g.castShadow=n.castShadow),n.receiveShadow!==void 0&&(g.receiveShadow=n.receiveShadow),n.shadow&&(n.shadow.intensity!==void 0&&(g.shadow.intensity=n.shadow.intensity),n.shadow.bias!==void 0&&(g.shadow.bias=n.shadow.bias),n.shadow.normalBias!==void 0&&(g.shadow.normalBias=n.shadow.normalBias),n.shadow.radius!==void 0&&(g.shadow.radius=n.shadow.radius),n.shadow.mapSize!==void 0&&g.shadow.mapSize.fromArray(n.shadow.mapSize),n.shadow.camera!==void 0&&(g.shadow.camera=this.parseObject(n.shadow.camera))),n.visible!==void 0&&(g.visible=n.visible),n.frustumCulled!==void 0&&(g.frustumCulled=n.frustumCulled),n.renderOrder!==void 0&&(g.renderOrder=n.renderOrder),n.userData!==void 0&&(g.userData=n.userData),n.layers!==void 0&&(g.layers.mask=n.layers),n.children!==void 0){const N=n.children;for(let L=0;L<N.length;L++)g.add(this.parseObject(N[L],o,l,u,p))}if(n.animations!==void 0){const N=n.animations;for(let L=0;L<N.length;L++){const I=N[L];g.animations.push(p[I])}}if(n.type==="LOD"){n.autoUpdate!==void 0&&(g.autoUpdate=n.autoUpdate);const N=n.levels;for(let L=0;L<N.length;L++){const I=N[L],B=g.getObjectByProperty("uuid",I.object);B!==void 0&&g.addLevel(B,I.distance,I.hysteresis)}}return g}bindSkeletons(n,o){Object.keys(o).length!==0&&n.traverse(function(l){if(l.isSkinnedMesh===!0&&l.skeleton!==void 0){const u=o[l.skeleton];u===void 0?dn("ObjectLoader: No skeleton found with UUID:",l.skeleton):l.bind(u,l.bindMatrix)}})}bindLightTargets(n){n.traverse(function(o){if(o.isDirectionalLight||o.isSpotLight){const l=o.target,u=n.getObjectByProperty("uuid",l);u!==void 0?o.target=u:o.target=new Ri}})}}const Fp={UVMapping:eh,CubeReflectionMapping:th,CubeRefractionMapping:km,EquirectangularReflectionMapping:Vm,EquirectangularRefractionMapping:zm,CubeUVReflectionMapping:Yd},ud={RepeatWrapping:nh,ClampToEdgeWrapping:Rs,MirroredRepeatWrapping:ih},hd={NearestFilter:ps,NearestMipmapNearestFilter:Gm,NearestMipmapLinearFilter:Wm,LinearFilter:Yr,LinearMipmapNearestFilter:Hm,LinearMipmapLinearFilter:El},_u=new WeakMap;class db extends null{constructor(n){super(n),this.isImageBitmapLoader=!0,typeof createImageBitmap=="undefined"&&dn("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch=="undefined"&&dn("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(n){return this.options=n,this}load(n,o,l,u){n===void 0&&(n=""),this.path!==void 0&&(n=this.path+n),n=this.manager.resolveURL(n);const p=this,g=co.get(`image-bitmap:${n}`);if(g!==void 0){if(p.manager.itemStart(n),g.then){g.then(S=>{if(_u.has(g)===!0)u&&u(_u.get(g)),p.manager.itemError(n),p.manager.itemEnd(n);else return o&&o(S),p.manager.itemEnd(n),S});return}return setTimeout(function(){o&&o(g),p.manager.itemEnd(n)},0),g}const y={};y.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",y.headers=this.requestHeader,y.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const b=fetch(n,y).then(function(S){return S.blob()}).then(function(S){return createImageBitmap(S,Object.assign(p.options,{colorSpaceConversion:"none"}))}).then(function(S){return co.add(`image-bitmap:${n}`,S),o&&o(S),p.manager.itemEnd(n),S}).catch(function(S){u&&u(S),_u.set(b,S),co.remove(`image-bitmap:${n}`),p.manager.itemError(n),p.manager.itemEnd(n)});co.add(`image-bitmap:${n}`,b),p.manager.itemStart(n)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let yu;class bu{static getContext(){return yu===void 0&&(yu=new(window.AudioContext||window.webkitAudioContext)),yu}static setContext(n){yu=n}}class fb extends null{constructor(n){super(n)}load(n,o,l,u){const p=this,g=new ha(this.manager);g.setResponseType("arraybuffer"),g.setPath(this.path),g.setRequestHeader(this.requestHeader),g.setWithCredentials(this.withCredentials),g.load(n,function(b){try{const S=b.slice(0);bu.getContext().decodeAudioData(S,function(R){o(R)}).catch(y)}catch(S){y(S)}},l,u);function y(b){u?u(b):Yn(b),p.manager.itemError(n)}}}const Ft=new Ln,dd=new Ln,Gs=new Ln;class Bt{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new os,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new os,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(n){const o=this._cache;if(o.focus!==n.focus||o.fov!==n.fov||o.aspect!==n.aspect*this.aspect||o.near!==n.near||o.far!==n.far||o.zoom!==n.zoom||o.eyeSep!==this.eyeSep){o.focus=n.focus,o.fov=n.fov,o.aspect=n.aspect*this.aspect,o.near=n.near,o.far=n.far,o.zoom=n.zoom,o.eyeSep=this.eyeSep,Gs.copy(n.projectionMatrix);const u=o.eyeSep/2,p=u*o.near/o.focus,g=o.near*Math.tan(Eo*o.fov*.5)/o.zoom;let y,b;dd.elements[12]=-u,Ft.elements[12]=u,y=-g*o.aspect+p,b=g*o.aspect+p,Gs.elements[0]=2*o.near/(b-y),Gs.elements[8]=(b+y)/(b-y),this.cameraL.projectionMatrix.copy(Gs),y=-g*o.aspect-p,b=g*o.aspect-p,Gs.elements[0]=2*o.near/(b-y),Gs.elements[8]=(b+y)/(b-y),this.cameraR.projectionMatrix.copy(Gs)}this.cameraL.matrixWorld.copy(n.matrixWorld).multiply(dd),this.cameraR.matrixWorld.copy(n.matrixWorld).multiply(Ft)}}class C0 extends os{constructor(n=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=n}}class Bp{constructor(n=!0){this.autoStart=n,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=performance.now(),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 n=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const o=performance.now();n=(o-this.oldTime)/1e3,this.oldTime=o,this.elapsedTime+=n}return n}}const cc=new ie,fd=new Hr,pb=new ie,ma=new ie,lc=new ie;class Ii extends null{constructor(){super(),this.type="AudioListener",this.context=bu.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new Bp}getInput(){return this.gain}removeFilter(){return this.filter!==null&&(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(n){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=n,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(n){return this.gain.gain.setTargetAtTime(n,this.context.currentTime,.01),this}updateMatrixWorld(n){super.updateMatrixWorld(n);const o=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(cc,fd,pb),ma.set(0,0,-1).applyQuaternion(fd),lc.set(0,1,0).applyQuaternion(fd),o.positionX){const l=this.context.currentTime+this.timeDelta;o.positionX.linearRampToValueAtTime(cc.x,l),o.positionY.linearRampToValueAtTime(cc.y,l),o.positionZ.linearRampToValueAtTime(cc.z,l),o.forwardX.linearRampToValueAtTime(ma.x,l),o.forwardY.linearRampToValueAtTime(ma.y,l),o.forwardZ.linearRampToValueAtTime(ma.z,l),o.upX.linearRampToValueAtTime(lc.x,l),o.upY.linearRampToValueAtTime(lc.y,l),o.upZ.linearRampToValueAtTime(lc.z,l)}else o.setPosition(cc.x,cc.y,cc.z),o.setOrientation(ma.x,ma.y,ma.z,lc.x,lc.y,lc.z)}}class Yi extends null{constructor(n){super(),this.type="Audio",this.listener=n,this.context=n.context,this.gain=this.context.createGain(),this.gain.connect(n.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(n){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=n,this.connect(),this}setMediaElementSource(n){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(n),this.connect(),this}setMediaStreamSource(n){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(n),this.connect(),this}setBuffer(n){return this.buffer=n,this.sourceType="buffer",this.autoplay&&this.play(),this}play(n=0){if(this.isPlaying===!0){dn("Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){dn("Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+n;const o=this.context.createBufferSource();return o.buffer=this.buffer,o.loop=this.loop,o.loopStart=this.loopStart,o.loopEnd=this.loopEnd,o.onended=this.onEnded.bind(this),o.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=o,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){dn("Audio: this Audio has no playback control.");return}return this.isPlaying===!0&&(this._progress+=Math.max(this.context.currentTime-this._startedAt,0)*this.playbackRate,this.loop===!0&&(this._progress=this._progress%(this.duration||this.buffer.duration)),this.source.stop(),this.source.onended=null,this.isPlaying=!1),this}stop(n=0){if(this.hasPlaybackControl===!1){dn("Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+n),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let n=1,o=this.filters.length;n<o;n++)this.filters[n-1].connect(this.filters[n]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this._connected=!0,this}disconnect(){if(this._connected!==!1){if(this.filters.length>0){this.source.disconnect(this.filters[0]);for(let n=1,o=this.filters.length;n<o;n++)this.filters[n-1].disconnect(this.filters[n]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this._connected=!1,this}}getFilters(){return this.filters}setFilters(n){return n||(n=[]),this._connected===!0?(this.disconnect(),this.filters=n.slice(),this.connect()):this.filters=n.slice(),this}setDetune(n){return this.detune=n,this.isPlaying===!0&&this.source.detune!==void 0&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,.01),this}getDetune(){return this.detune}getFilter(){return this.getFilters()[0]}setFilter(n){return this.setFilters(n?[n]:[])}setPlaybackRate(n){if(this.hasPlaybackControl===!1){dn("Audio: this Audio has no playback control.");return}return this.playbackRate=n,this.isPlaying===!0&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this}getPlaybackRate(){return this.playbackRate}onEnded(){this.isPlaying=!1,this._progress=0}getLoop(){return this.hasPlaybackControl===!1?(dn("Audio: this Audio has no playback control."),!1):this.loop}setLoop(n){if(this.hasPlaybackControl===!1){dn("Audio: this Audio has no playback control.");return}return this.loop=n,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(n){return this.loopStart=n,this}setLoopEnd(n){return this.loopEnd=n,this}getVolume(){return this.gain.gain.value}setVolume(n){return this.gain.gain.setTargetAtTime(n,this.context.currentTime,.01),this}copy(n,o){return super.copy(n,o),n.sourceType!=="buffer"?(dn("Audio: Audio source type cannot be copied."),this):(this.autoplay=n.autoplay,this.buffer=n.buffer,this.detune=n.detune,this.loop=n.loop,this.loopStart=n.loopStart,this.loopEnd=n.loopEnd,this.offset=n.offset,this.duration=n.duration,this.playbackRate=n.playbackRate,this.hasPlaybackControl=n.hasPlaybackControl,this.sourceType=n.sourceType,this.filters=n.filters.slice(),this)}clone(n){return new this.constructor(this.listener).copy(this,n)}}const Cn=new ie,cn=new Hr,cs=new ie,Ws=new ie;class R0 extends null{constructor(n){super(n),this.panner=this.context.createPanner(),this.panner.panningModel="HRTF",this.panner.connect(this.gain)}connect(){return super.connect(),this.panner.connect(this.gain),this}disconnect(){return super.disconnect(),this.panner.disconnect(this.gain),this}getOutput(){return this.panner}getRefDistance(){return this.panner.refDistance}setRefDistance(n){return this.panner.refDistance=n,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(n){return this.panner.rolloffFactor=n,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(n){return this.panner.distanceModel=n,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(n){return this.panner.maxDistance=n,this}setDirectionalCone(n,o,l){return this.panner.coneInnerAngle=n,this.panner.coneOuterAngle=o,this.panner.coneOuterGain=l,this}updateMatrixWorld(n){if(super.updateMatrixWorld(n),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(Cn,cn,cs),Ws.set(0,0,1).applyQuaternion(cn);const o=this.panner;if(o.positionX){const l=this.context.currentTime+this.listener.timeDelta;o.positionX.linearRampToValueAtTime(Cn.x,l),o.positionY.linearRampToValueAtTime(Cn.y,l),o.positionZ.linearRampToValueAtTime(Cn.z,l),o.orientationX.linearRampToValueAtTime(Ws.x,l),o.orientationY.linearRampToValueAtTime(Ws.y,l),o.orientationZ.linearRampToValueAtTime(Ws.z,l)}else o.setPosition(Cn.x,Cn.y,Cn.z),o.setOrientation(Ws.x,Ws.y,Ws.z)}}class mb{constructor(n,o=2048){this.analyser=n.context.createAnalyser(),this.analyser.fftSize=o,this.data=new Uint8Array(this.analyser.frequencyBinCount),n.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let n=0;const o=this.getFrequencyData();for(let l=0;l<o.length;l++)n+=o[l];return n/o.length}}class N0{constructor(n,o,l){this.binding=n,this.valueSize=l;let u,p,g;switch(o){case"quaternion":u=this._slerp,p=this._slerpAdditive,g=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(l*6),this._workIndex=5;break;case"string":case"bool":u=this._select,p=this._select,g=this._setAdditiveIdentityOther,this.buffer=new Array(l*5);break;default:u=this._lerp,p=this._lerpAdditive,g=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(l*5)}this._mixBufferRegion=u,this._mixBufferRegionAdditive=p,this._setIdentity=g,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(n,o){const l=this.buffer,u=this.valueSize,p=n*u+u;let g=this.cumulativeWeight;if(g===0){for(let y=0;y!==u;++y)l[p+y]=l[y];g=o}else{g+=o;const y=o/g;this._mixBufferRegion(l,p,0,y,u)}this.cumulativeWeight=g}accumulateAdditive(n){const o=this.buffer,l=this.valueSize,u=l*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(o,u,0,n,l),this.cumulativeWeightAdditive+=n}apply(n){const o=this.valueSize,l=this.buffer,u=n*o+o,p=this.cumulativeWeight,g=this.cumulativeWeightAdditive,y=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,p<1){const b=o*this._origIndex;this._mixBufferRegion(l,u,b,1-p,o)}g>0&&this._mixBufferRegionAdditive(l,u,this._addIndex*o,1,o);for(let b=o,S=o+o;b!==S;++b)if(l[b]!==l[b+o]){y.setValue(l,u);break}}saveOriginalState(){const n=this.binding,o=this.buffer,l=this.valueSize,u=l*this._origIndex;n.getValue(o,u);for(let p=l,g=u;p!==g;++p)o[p]=o[u+p%l];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const n=this.valueSize*3;this.binding.setValue(this.buffer,n)}_setAdditiveIdentityNumeric(){const n=this._addIndex*this.valueSize,o=n+this.valueSize;for(let l=n;l<o;l++)this.buffer[l]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const n=this._origIndex*this.valueSize,o=this._addIndex*this.valueSize;for(let l=0;l<this.valueSize;l++)this.buffer[o+l]=this.buffer[n+l]}_select(n,o,l,u,p){if(u>=.5)for(let g=0;g!==p;++g)n[o+g]=n[l+g]}_slerp(n,o,l,u){Hr.slerpFlat(n,o,n,o,n,l,u)}_slerpAdditive(n,o,l,u,p){const g=this._workIndex*p;Hr.multiplyQuaternionsFlat(n,g,n,o,n,l),Hr.slerpFlat(n,o,n,o,n,g,u)}_lerp(n,o,l,u,p){const g=1-u;for(let y=0;y!==p;++y){const b=o+y;n[b]=n[b]*g+n[l+y]*u}}_lerpAdditive(n,o,l,u,p){for(let g=0;g!==p;++g){const y=o+g;n[y]=n[y]+n[l+g]*u}}}const vu="\\[\\]\\.:\\/",P0=new RegExp("["+vu+"]","g"),pd="[^"+vu+"]",L0="[^"+vu.replace("\\.","")+"]",I0=/((?:WC+[\/:])*)/.source.replace("WC",pd),D0=/(WCOD+)?/.source.replace("WCOD",L0),U0=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",pd),F0=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",pd),B0=new RegExp("^"+I0+D0+U0+F0+"$"),O0=["material","materials","bones","map"];class k0{constructor(n,o,l){const u=l||Jn.parseTrackName(o);this._targetGroup=n,this._bindings=n.subscribe_(o,u)}getValue(n,o){this.bind();const l=this._targetGroup.nCachedObjects_,u=this._bindings[l];u!==void 0&&u.getValue(n,o)}setValue(n,o){const l=this._bindings;for(let u=this._targetGroup.nCachedObjects_,p=l.length;u!==p;++u)l[u].setValue(n,o)}bind(){const n=this._bindings;for(let o=this._targetGroup.nCachedObjects_,l=n.length;o!==l;++o)n[o].bind()}unbind(){const n=this._bindings;for(let o=this._targetGroup.nCachedObjects_,l=n.length;o!==l;++o)n[o].unbind()}}class Jn{constructor(n,o,l){this.path=o,this.parsedPath=l||Jn.parseTrackName(o),this.node=Jn.findNode(n,this.parsedPath.nodeName),this.rootNode=n,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(n,o,l){return n&&n.isAnimationObjectGroup?new Jn.Composite(n,o,l):new Jn(n,o,l)}static sanitizeNodeName(n){return n.replace(/\s/g,"_").replace(P0,"")}static parseTrackName(n){const o=B0.exec(n);if(o===null)throw new Error("PropertyBinding: Cannot parse trackName: "+n);const l={nodeName:o[2],objectName:o[3],objectIndex:o[4],propertyName:o[5],propertyIndex:o[6]},u=l.nodeName&&l.nodeName.lastIndexOf(".");if(u!==void 0&&u!==-1){const p=l.nodeName.substring(u+1);O0.indexOf(p)!==-1&&(l.nodeName=l.nodeName.substring(0,u),l.objectName=p)}if(l.propertyName===null||l.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+n);return l}static findNode(n,o){if(o===void 0||o===""||o==="."||o===-1||o===n.name||o===n.uuid)return n;if(n.skeleton){const l=n.skeleton.getBoneByName(o);if(l!==void 0)return l}if(n.children){const l=function(p){for(let g=0;g<p.length;g++){const y=p[g];if(y.name===o||y.uuid===o)return y;const b=l(y.children);if(b)return b}return null},u=l(n.children);if(u)return u}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(n,o){n[o]=this.targetObject[this.propertyName]}_getValue_array(n,o){const l=this.resolvedProperty;for(let u=0,p=l.length;u!==p;++u)n[o++]=l[u]}_getValue_arrayElement(n,o){n[o]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(n,o){this.resolvedProperty.toArray(n,o)}_setValue_direct(n,o){this.targetObject[this.propertyName]=n[o]}_setValue_direct_setNeedsUpdate(n,o){this.targetObject[this.propertyName]=n[o],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(n,o){this.targetObject[this.propertyName]=n[o],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(n,o){const l=this.resolvedProperty;for(let u=0,p=l.length;u!==p;++u)l[u]=n[o++]}_setValue_array_setNeedsUpdate(n,o){const l=this.resolvedProperty;for(let u=0,p=l.length;u!==p;++u)l[u]=n[o++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(n,o){const l=this.resolvedProperty;for(let u=0,p=l.length;u!==p;++u)l[u]=n[o++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(n,o){this.resolvedProperty[this.propertyIndex]=n[o]}_setValue_arrayElement_setNeedsUpdate(n,o){this.resolvedProperty[this.propertyIndex]=n[o],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(n,o){this.resolvedProperty[this.propertyIndex]=n[o],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(n,o){this.resolvedProperty.fromArray(n,o)}_setValue_fromArray_setNeedsUpdate(n,o){this.resolvedProperty.fromArray(n,o),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(n,o){this.resolvedProperty.fromArray(n,o),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(n,o){this.bind(),this.getValue(n,o)}_setValue_unbound(n,o){this.bind(),this.setValue(n,o)}bind(){let n=this.node;const o=this.parsedPath,l=o.objectName,u=o.propertyName;let p=o.propertyIndex;if(n||(n=Jn.findNode(this.rootNode,o.nodeName),this.node=n),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!n){dn("PropertyBinding: No target node found for track: "+this.path+".");return}if(l){let S=o.objectIndex;switch(l){case"materials":if(!n.material){Yn("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!n.material.materials){Yn("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}n=n.material.materials;break;case"bones":if(!n.skeleton){Yn("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}n=n.skeleton.bones;for(let A=0;A<n.length;A++)if(n[A].name===S){S=A;break}break;case"map":if("map"in n){n=n.map;break}if(!n.material){Yn("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!n.material.map){Yn("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}n=n.material.map;break;default:if(n[l]===void 0){Yn("PropertyBinding: Can not bind to objectName of node undefined.",this);return}n=n[l]}if(S!==void 0){if(n[S]===void 0){Yn("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,n);return}n=n[S]}}const g=n[u];if(g===void 0){const S=o.nodeName;Yn("PropertyBinding: Trying to update property for track: "+S+"."+u+" but it wasn't found.",n);return}let y=this.Versioning.None;this.targetObject=n,n.isMaterial===!0?y=this.Versioning.NeedsUpdate:n.isObject3D===!0&&(y=this.Versioning.MatrixWorldNeedsUpdate);let b=this.BindingType.Direct;if(p!==void 0){if(u==="morphTargetInfluences"){if(!n.geometry){Yn("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!n.geometry.morphAttributes){Yn("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}n.morphTargetDictionary[p]!==void 0&&(p=n.morphTargetDictionary[p])}b=this.BindingType.ArrayElement,this.resolvedProperty=g,this.propertyIndex=p}else g.fromArray!==void 0&&g.toArray!==void 0?(b=this.BindingType.HasFromToArray,this.resolvedProperty=g):Array.isArray(g)?(b=this.BindingType.EntireArray,this.resolvedProperty=g):this.propertyName=u;this.getValue=this.GetterByBindingType[b],this.setValue=this.SetterByBindingTypeAndVersioning[b][y]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Jn.Composite=k0,Jn.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Jn.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Jn.prototype.GetterByBindingType=[Jn.prototype._getValue_direct,Jn.prototype._getValue_array,Jn.prototype._getValue_arrayElement,Jn.prototype._getValue_toArray],Jn.prototype.SetterByBindingTypeAndVersioning=[[Jn.prototype._setValue_direct,Jn.prototype._setValue_direct_setNeedsUpdate,Jn.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Jn.prototype._setValue_array,Jn.prototype._setValue_array_setNeedsUpdate,Jn.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Jn.prototype._setValue_arrayElement,Jn.prototype._setValue_arrayElement_setNeedsUpdate,Jn.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Jn.prototype._setValue_fromArray,Jn.prototype._setValue_fromArray_setNeedsUpdate,Jn.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class gb{constructor(){this.isAnimationObjectGroup=!0,this.uuid=gr(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const n={};this._indicesByUUID=n;for(let l=0,u=arguments.length;l!==u;++l)n[arguments[l].uuid]=l;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const o=this;this.stats={objects:{get total(){return o._objects.length},get inUse(){return this.total-o.nCachedObjects_}},get bindingsPerObject(){return o._bindings.length}}}add(){const n=this._objects,o=this._indicesByUUID,l=this._paths,u=this._parsedPaths,p=this._bindings,g=p.length;let y,b=n.length,S=this.nCachedObjects_;for(let A=0,R=arguments.length;A!==R;++A){const N=arguments[A],L=N.uuid;let I=o[L];if(I===void 0){I=b++,o[L]=I,n.push(N);for(let B=0,Z=g;B!==Z;++B)p[B].push(new Jn(N,l[B],u[B]))}else if(I<S){y=n[I];const B=--S,Z=n[B];o[Z.uuid]=I,n[I]=Z,o[L]=B,n[B]=N;for(let q=0,ee=g;q!==ee;++q){const te=p[q],he=te[B];let Re=te[I];te[I]=he,Re===void 0&&(Re=new Jn(N,l[q],u[q])),te[B]=Re}}else n[I]!==y&&Yn("AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=S}remove(){const n=this._objects,o=this._indicesByUUID,l=this._bindings,u=l.length;let p=this.nCachedObjects_;for(let g=0,y=arguments.length;g!==y;++g){const b=arguments[g],S=b.uuid,A=o[S];if(A!==void 0&&A>=p){const R=p++,N=n[R];o[N.uuid]=A,n[A]=N,o[S]=R,n[R]=b;for(let L=0,I=u;L!==I;++L){const B=l[L],Z=B[R],q=B[A];B[A]=Z,B[R]=q}}}this.nCachedObjects_=p}uncache(){const n=this._objects,o=this._indicesByUUID,l=this._bindings,u=l.length;let p=this.nCachedObjects_,g=n.length;for(let y=0,b=arguments.length;y!==b;++y){const S=arguments[y],A=S.uuid,R=o[A];if(R!==void 0)if(delete o[A],R<p){const N=--p,L=n[N],I=--g,B=n[I];o[L.uuid]=R,n[R]=L,o[B.uuid]=N,n[N]=B,n.pop();for(let Z=0,q=u;Z!==q;++Z){const ee=l[Z],te=ee[N],he=ee[I];ee[R]=te,ee[N]=he,ee.pop()}}else{const N=--g,L=n[N];N>0&&(o[L.uuid]=R),n[R]=L,n.pop();for(let I=0,B=u;I!==B;++I){const Z=l[I];Z[R]=Z[N],Z.pop()}}}this.nCachedObjects_=p}subscribe_(n,o){const l=this._bindingsIndicesByPath;let u=l[n];const p=this._bindings;if(u!==void 0)return p[u];const g=this._paths,y=this._parsedPaths,b=this._objects,S=b.length,A=this.nCachedObjects_,R=new Array(S);u=p.length,l[n]=u,g.push(n),y.push(o),p.push(R);for(let N=A,L=b.length;N!==L;++N){const I=b[N];R[N]=new Jn(I,n,o)}return R}unsubscribe_(n){const o=this._bindingsIndicesByPath,l=o[n];if(l!==void 0){const u=this._paths,p=this._parsedPaths,g=this._bindings,y=g.length-1,b=g[y],S=n[y];o[S]=l,g[l]=b,g.pop(),p[l]=p[y],p.pop(),u[l]=u[y],u.pop()}}}class V0{constructor(n,o,l=null,u=o.blendMode){this._mixer=n,this._clip=o,this._localRoot=l,this.blendMode=u;const p=o.tracks,g=p.length,y=new Array(g),b={endingStart:Rc,endingEnd:Rc};for(let S=0;S!==g;++S){const A=p[S].createInterpolant(null);y[S]=A,A.settings=b}this._interpolantSettings=b,this._interpolants=y,this._propertyBindings=new Array(g),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=I_,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&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(n){return this._startTime=n,this}setLoop(n,o){return this.loop=n,this.repetitions=o,this}setEffectiveWeight(n){return this.weight=n,this._effectiveWeight=this.enabled?n:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(n){return this._scheduleFading(n,0,1)}fadeOut(n){return this._scheduleFading(n,1,0)}crossFadeFrom(n,o,l=!1){if(n.fadeOut(o),this.fadeIn(o),l===!0){const u=this._clip.duration,p=n._clip.duration,g=p/u,y=u/p;n.warp(1,g,o),this.warp(y,1,o)}return this}crossFadeTo(n,o,l=!1){return n.crossFadeFrom(this,o,l)}stopFading(){const n=this._weightInterpolant;return n!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(n)),this}setEffectiveTimeScale(n){return this.timeScale=n,this._effectiveTimeScale=this.paused?0:n,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(n){return this.timeScale=this._clip.duration/n,this.stopWarping()}syncWith(n){return this.time=n.time,this.timeScale=n.timeScale,this.stopWarping()}halt(n){return this.warp(this._effectiveTimeScale,0,n)}warp(n,o,l){const u=this._mixer,p=u.time,g=this.timeScale;let y=this._timeScaleInterpolant;y===null&&(y=u._lendControlInterpolant(),this._timeScaleInterpolant=y);const b=y.parameterPositions,S=y.sampleValues;return b[0]=p,b[1]=p+l,S[0]=n/g,S[1]=o/g,this}stopWarping(){const n=this._timeScaleInterpolant;return n!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(n)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(n,o,l,u){if(!this.enabled){this._updateWeight(n);return}const p=this._startTime;if(p!==null){const b=(n-p)*l;b<0||l===0?o=0:(this._startTime=null,o=l*b)}o*=this._updateTimeScale(n);const g=this._updateTime(o),y=this._updateWeight(n);if(y>0){const b=this._interpolants,S=this._propertyBindings;switch(this.blendMode){case lf:for(let A=0,R=b.length;A!==R;++A)b[A].evaluate(g),S[A].accumulateAdditive(y);break;case cf:default:for(let A=0,R=b.length;A!==R;++A)b[A].evaluate(g),S[A].accumulate(u,y)}}}_updateWeight(n){let o=0;if(this.enabled){o=this.weight;const l=this._weightInterpolant;if(l!==null){const u=l.evaluate(n)[0];o*=u,n>l.parameterPositions[1]&&(this.stopFading(),u===0&&(this.enabled=!1))}}return this._effectiveWeight=o,o}_updateTimeScale(n){let o=0;if(!this.paused){o=this.timeScale;const l=this._timeScaleInterpolant;if(l!==null){const u=l.evaluate(n)[0];o*=u,n>l.parameterPositions[1]&&(this.stopWarping(),o===0?this.paused=!0:this.timeScale=o)}}return this._effectiveTimeScale=o,o}_updateTime(n){const o=this._clip.duration,l=this.loop;let u=this.time+n,p=this._loopCount;const g=l===lh;if(n===0)return p===-1?u:g&&(p&1)===1?o-u:u;if(l===L_){p===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(u>=o)u=o;else if(u<0)u=0;else{this.time=u;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=u,this._mixer.dispatchEvent({type:"finished",action:this,direction:n<0?-1:1})}}else{if(p===-1&&(n>=0?(p=0,this._setEndings(!0,this.repetitions===0,g)):this._setEndings(this.repetitions===0,!0,g)),u>=o||u<0){const y=Math.floor(u/o);u-=o*y,p+=Math.abs(y);const b=this.repetitions-p;if(b<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,u=n>0?o:0,this.time=u,this._mixer.dispatchEvent({type:"finished",action:this,direction:n>0?1:-1});else{if(b===1){const S=n<0;this._setEndings(S,!S,g)}else this._setEndings(!1,!1,g);this._loopCount=p,this.time=u,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:y})}}else this.time=u;if(g&&(p&1)===1)return o-u}return u}_setEndings(n,o,l){const u=this._interpolantSettings;l?(u.endingStart=Nc,u.endingEnd=Nc):(n?u.endingStart=this.zeroSlopeAtStart?Nc:Rc:u.endingStart=Pl,o?u.endingEnd=this.zeroSlopeAtEnd?Nc:Rc:u.endingEnd=Pl)}_scheduleFading(n,o,l){const u=this._mixer,p=u.time;let g=this._weightInterpolant;g===null&&(g=u._lendControlInterpolant(),this._weightInterpolant=g);const y=g.parameterPositions,b=g.sampleValues;return y[0]=p,b[0]=o,y[1]=p+n,b[1]=l,this}}const z0=new Float32Array(1);class xb extends null{constructor(n){super(),this._root=n,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(n,o){const l=n._localRoot||this._root,u=n._clip.tracks,p=u.length,g=n._propertyBindings,y=n._interpolants,b=l.uuid,S=this._bindingsByRootAndName;let A=S[b];A===void 0&&(A={},S[b]=A);for(let R=0;R!==p;++R){const N=u[R],L=N.name;let I=A[L];if(I!==void 0)++I.referenceCount,g[R]=I;else{if(I=g[R],I!==void 0){I._cacheIndex===null&&(++I.referenceCount,this._addInactiveBinding(I,b,L));continue}const B=o&&o._propertyBindings[R].binding.parsedPath;I=new N0(Jn.create(l,L,B),N.ValueTypeName,N.getValueSize()),++I.referenceCount,this._addInactiveBinding(I,b,L),g[R]=I}y[R].resultBuffer=I.buffer}}_activateAction(n){if(!this._isActiveAction(n)){if(n._cacheIndex===null){const l=(n._localRoot||this._root).uuid,u=n._clip.uuid,p=this._actionsByClip[u];this._bindAction(n,p&&p.knownActions[0]),this._addInactiveAction(n,u,l)}const o=n._propertyBindings;for(let l=0,u=o.length;l!==u;++l){const p=o[l];p.useCount++===0&&(this._lendBinding(p),p.saveOriginalState())}this._lendAction(n)}}_deactivateAction(n){if(this._isActiveAction(n)){const o=n._propertyBindings;for(let l=0,u=o.length;l!==u;++l){const p=o[l];--p.useCount===0&&(p.restoreOriginalState(),this._takeBackBinding(p))}this._takeBackAction(n)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const n=this;this.stats={actions:{get total(){return n._actions.length},get inUse(){return n._nActiveActions}},bindings:{get total(){return n._bindings.length},get inUse(){return n._nActiveBindings}},controlInterpolants:{get total(){return n._controlInterpolants.length},get inUse(){return n._nActiveControlInterpolants}}}}_isActiveAction(n){const o=n._cacheIndex;return o!==null&&o<this._nActiveActions}_addInactiveAction(n,o,l){const u=this._actions,p=this._actionsByClip;let g=p[o];if(g===void 0)g={knownActions:[n],actionByRoot:{}},n._byClipCacheIndex=0,p[o]=g;else{const y=g.knownActions;n._byClipCacheIndex=y.length,y.push(n)}n._cacheIndex=u.length,u.push(n),g.actionByRoot[l]=n}_removeInactiveAction(n){const o=this._actions,l=o[o.length-1],u=n._cacheIndex;l._cacheIndex=u,o[u]=l,o.pop(),n._cacheIndex=null;const p=n._clip.uuid,g=this._actionsByClip,y=g[p],b=y.knownActions,S=b[b.length-1],A=n._byClipCacheIndex;S._byClipCacheIndex=A,b[A]=S,b.pop(),n._byClipCacheIndex=null;const R=y.actionByRoot,N=(n._localRoot||this._root).uuid;delete R[N],b.length===0&&delete g[p],this._removeInactiveBindingsForAction(n)}_removeInactiveBindingsForAction(n){const o=n._propertyBindings;for(let l=0,u=o.length;l!==u;++l){const p=o[l];--p.referenceCount===0&&this._removeInactiveBinding(p)}}_lendAction(n){const o=this._actions,l=n._cacheIndex,u=this._nActiveActions++,p=o[u];n._cacheIndex=u,o[u]=n,p._cacheIndex=l,o[l]=p}_takeBackAction(n){const o=this._actions,l=n._cacheIndex,u=--this._nActiveActions,p=o[u];n._cacheIndex=u,o[u]=n,p._cacheIndex=l,o[l]=p}_addInactiveBinding(n,o,l){const u=this._bindingsByRootAndName,p=this._bindings;let g=u[o];g===void 0&&(g={},u[o]=g),g[l]=n,n._cacheIndex=p.length,p.push(n)}_removeInactiveBinding(n){const o=this._bindings,l=n.binding,u=l.rootNode.uuid,p=l.path,g=this._bindingsByRootAndName,y=g[u],b=o[o.length-1],S=n._cacheIndex;b._cacheIndex=S,o[S]=b,o.pop(),delete y[p],Object.keys(y).length===0&&delete g[u]}_lendBinding(n){const o=this._bindings,l=n._cacheIndex,u=this._nActiveBindings++,p=o[u];n._cacheIndex=u,o[u]=n,p._cacheIndex=l,o[l]=p}_takeBackBinding(n){const o=this._bindings,l=n._cacheIndex,u=--this._nActiveBindings,p=o[u];n._cacheIndex=u,o[u]=n,p._cacheIndex=l,o[l]=p}_lendControlInterpolant(){const n=this._controlInterpolants,o=this._nActiveControlInterpolants++;let l=n[o];return l===void 0&&(l=new G(new Float32Array(2),new Float32Array(2),1,z0),l.__cacheIndex=o,n[o]=l),l}_takeBackControlInterpolant(n){const o=this._controlInterpolants,l=n.__cacheIndex,u=--this._nActiveControlInterpolants,p=o[u];n.__cacheIndex=u,o[u]=n,p.__cacheIndex=l,o[l]=p}clipAction(n,o,l){const u=o||this._root,p=u.uuid;let g=typeof n=="string"?zo.findByName(u,n):n;const y=g!==null?g.uuid:n,b=this._actionsByClip[y];let S=null;if(l===void 0&&(g!==null?l=g.blendMode:l=cf),b!==void 0){const R=b.actionByRoot[p];if(R!==void 0&&R.blendMode===l)return R;S=b.knownActions[0],g===null&&(g=S._clip)}if(g===null)return null;const A=new V0(this,g,o,l);return this._bindAction(A,S),this._addInactiveAction(A,y,p),A}existingAction(n,o){const l=o||this._root,u=l.uuid,p=typeof n=="string"?zo.findByName(l,n):n,g=p?p.uuid:n,y=this._actionsByClip[g];return y!==void 0&&y.actionByRoot[u]||null}stopAllAction(){const n=this._actions,o=this._nActiveActions;for(let l=o-1;l>=0;--l)n[l].stop();return this}update(n){n*=this.timeScale;const o=this._actions,l=this._nActiveActions,u=this.time+=n,p=Math.sign(n),g=this._accuIndex^=1;for(let S=0;S!==l;++S)o[S]._update(u,n,p,g);const y=this._bindings,b=this._nActiveBindings;for(let S=0;S!==b;++S)y[S].apply(g);return this}setTime(n){this.time=0;for(let o=0;o<this._actions.length;o++)this._actions[o].time=0;return this.update(n)}getRoot(){return this._root}uncacheClip(n){const o=this._actions,l=n.uuid,u=this._actionsByClip,p=u[l];if(p!==void 0){const g=p.knownActions;for(let y=0,b=g.length;y!==b;++y){const S=g[y];this._deactivateAction(S);const A=S._cacheIndex,R=o[o.length-1];S._cacheIndex=null,S._byClipCacheIndex=null,R._cacheIndex=A,o[A]=R,o.pop(),this._removeInactiveBindingsForAction(S)}delete u[l]}}uncacheRoot(n){const o=n.uuid,l=this._actionsByClip;for(const g in l){const y=l[g].actionByRoot,b=y[o];b!==void 0&&(this._deactivateAction(b),this._removeInactiveAction(b))}const u=this._bindingsByRootAndName,p=u[o];if(p!==void 0)for(const g in p){const y=p[g];y.restoreOriginalState(),this._removeInactiveBinding(y)}}uncacheAction(n,o){const l=this.existingAction(n,o);l!==null&&(this._deactivateAction(l),this._removeInactiveAction(l))}}class _b extends null{constructor(n=1,o=1,l=1,u={}){super(n,o,u),this.isRenderTarget3D=!0,this.depth=l,this.texture=new Sf(null,n,o,l),this._setTextureOptions(u),this.texture.isRenderTargetTexture=!0}}class Op{constructor(n){this.value=n}clone(){return new Op(this.value.clone===void 0?this.value:this.value.clone())}}let Se=0;class G0 extends null{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:Se++}),this.name="",this.usage=Pc,this.uniforms=[]}add(n){return this.uniforms.push(n),this}remove(n){const o=this.uniforms.indexOf(n);return o!==-1&&this.uniforms.splice(o,1),this}setName(n){return this.name=n,this}setUsage(n){return this.usage=n,this}dispose(){this.dispatchEvent({type:"dispose"})}copy(n){this.name=n.name,this.usage=n.usage;const o=n.uniforms;this.uniforms.length=0;for(let l=0,u=o.length;l<u;l++){const p=Array.isArray(o[l])?o[l]:[o[l]];for(let g=0;g<p.length;g++)this.uniforms.push(p[g].clone())}return this}clone(){return new this.constructor().copy(this)}}class yb extends Lh{constructor(n,o,l=1){super(n,o),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=l}copy(n){return super.copy(n),this.meshPerAttribute=n.meshPerAttribute,this}clone(n){const o=super.clone(n);return o.meshPerAttribute=this.meshPerAttribute,o}toJSON(n){const o=super.toJSON(n);return o.isInstancedInterleavedBuffer=!0,o.meshPerAttribute=this.meshPerAttribute,o}}class kp{constructor(n,o,l,u,p,g=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=n,this.type=o,this.itemSize=l,this.elementSize=u,this.count=p,this.normalized=g,this.version=0}set needsUpdate(n){n===!0&&this.version++}setBuffer(n){return this.buffer=n,this}setType(n,o){return this.type=n,this.elementSize=o,this}setItemSize(n){return this.itemSize=n,this}setCount(n){return this.count=n,this}}const W0=new Ln;class bb{constructor(n,o,l=0,u=1/0){this.ray=new Bc(n,o),this.near=l,this.far=u,this.camera=null,this.layers=new Cf,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(n,o){this.ray.set(n,o)}setFromCamera(n,o){o.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(o.matrixWorld),this.ray.direction.set(n.x,n.y,.5).unproject(o).sub(this.ray.origin).normalize(),this.camera=o):o.isOrthographicCamera?(this.ray.origin.set(n.x,n.y,(o.near+o.far)/(o.near-o.far)).unproject(o),this.ray.direction.set(0,0,-1).transformDirection(o.matrixWorld),this.camera=o):Yn("Raycaster: Unsupported camera type: "+o.type)}setFromXRController(n){return W0.identity().extractRotation(n.matrixWorld),this.ray.origin.setFromMatrixPosition(n.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(W0),this}intersectObject(n,o=!0,l=[]){return md(n,this,l,o),l.sort(H0),l}intersectObjects(n,o=!0,l=[]){for(let u=0,p=n.length;u<p;u++)md(n[u],this,l,o);return l.sort(H0),l}}function H0(M,n){return M.distance-n.distance}function md(M,n,o,l){let u=!0;if(M.layers.test(n.layers)&&M.raycast(n,o)===!1&&(u=!1),u===!0&&l===!0){const p=M.children;for(let g=0,y=p.length;g<y;g++)md(p[g],n,o,!0)}}class vb{constructor(){this._previousTime=0,this._currentTime=0,this._startTime=performance.now(),this._delta=0,this._elapsed=0,this._timescale=1,this._document=null,this._pageVisibilityHandler=null}connect(n){this._document=n,n.hidden!==void 0&&(this._pageVisibilityHandler=$0.bind(this),n.addEventListener("visibilitychange",this._pageVisibilityHandler,!1))}disconnect(){this._pageVisibilityHandler!==null&&(this._document.removeEventListener("visibilitychange",this._pageVisibilityHandler),this._pageVisibilityHandler=null),this._document=null}getDelta(){return this._delta/1e3}getElapsed(){return this._elapsed/1e3}getTimescale(){return this._timescale}setTimescale(n){return this._timescale=n,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(n){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(n!==void 0?n:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}}function $0(){this._document.hidden===!1&&this.reset()}class j0{constructor(n=1,o=0,l=0){this.radius=n,this.phi=o,this.theta=l}set(n,o,l){return this.radius=n,this.phi=o,this.theta=l,this}copy(n){return this.radius=n.radius,this.phi=n.phi,this.theta=n.theta,this}makeSafe(){return this.phi=an(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(n){return this.setFromCartesianCoords(n.x,n.y,n.z)}setFromCartesianCoords(n,o,l){return this.radius=Math.sqrt(n*n+o*o+l*l),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(n,l),this.phi=Math.acos(an(o/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class X0{constructor(n=1,o=0,l=0){this.radius=n,this.theta=o,this.y=l}set(n,o,l){return this.radius=n,this.theta=o,this.y=l,this}copy(n){return this.radius=n.radius,this.theta=n.theta,this.y=n.y,this}setFromVector3(n){return this.setFromCartesianCoords(n.x,n.y,n.z)}setFromCartesianCoords(n,o,l){return this.radius=Math.sqrt(n*n+l*l),this.theta=Math.atan2(n,l),this.y=o,this}clone(){return new this.constructor().copy(this)}}class ga{constructor(n,o,l,u){ga.prototype.isMatrix2=!0,this.elements=[1,0,0,1],n!==void 0&&this.set(n,o,l,u)}identity(){return this.set(1,0,0,1),this}fromArray(n,o=0){for(let l=0;l<4;l++)this.elements[l]=n[l+o];return this}set(n,o,l,u){const p=this.elements;return p[0]=n,p[2]=o,p[1]=l,p[3]=u,this}}const Su=new dt;class Wo{constructor(n=new dt(1/0,1/0),o=new dt(-1/0,-1/0)){this.isBox2=!0,this.min=n,this.max=o}set(n,o){return this.min.copy(n),this.max.copy(o),this}setFromPoints(n){this.makeEmpty();for(let o=0,l=n.length;o<l;o++)this.expandByPoint(n[o]);return this}setFromCenterAndSize(n,o){const l=Su.copy(o).multiplyScalar(.5);return this.min.copy(n).sub(l),this.max.copy(n).add(l),this}clone(){return new this.constructor().copy(this)}copy(n){return this.min.copy(n.min),this.max.copy(n.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(n){return this.isEmpty()?n.set(0,0):n.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(n){return this.isEmpty()?n.set(0,0):n.subVectors(this.max,this.min)}expandByPoint(n){return this.min.min(n),this.max.max(n),this}expandByVector(n){return this.min.sub(n),this.max.add(n),this}expandByScalar(n){return this.min.addScalar(-n),this.max.addScalar(n),this}containsPoint(n){return n.x>=this.min.x&&n.x<=this.max.x&&n.y>=this.min.y&&n.y<=this.max.y}containsBox(n){return this.min.x<=n.min.x&&n.max.x<=this.max.x&&this.min.y<=n.min.y&&n.max.y<=this.max.y}getParameter(n,o){return o.set((n.x-this.min.x)/(this.max.x-this.min.x),(n.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(n){return n.max.x>=this.min.x&&n.min.x<=this.max.x&&n.max.y>=this.min.y&&n.min.y<=this.max.y}clampPoint(n,o){return o.copy(n).clamp(this.min,this.max)}distanceToPoint(n){return this.clampPoint(n,Su).distanceTo(n)}intersect(n){return this.min.max(n.min),this.max.min(n.max),this.isEmpty()&&this.makeEmpty(),this}union(n){return this.min.min(n.min),this.max.max(n.max),this}translate(n){return this.min.add(n),this.max.add(n),this}equals(n){return n.min.equals(this.min)&&n.max.equals(this.max)}}const Br=new ie,fl=new ie,Or=new ie,Ho=new ie,Er=new ie,Hs=new ie,jr=new ie;class $o{constructor(n=new ie,o=new ie){this.start=n,this.end=o}set(n,o){return this.start.copy(n),this.end.copy(o),this}copy(n){return this.start.copy(n.start),this.end.copy(n.end),this}getCenter(n){return n.addVectors(this.start,this.end).multiplyScalar(.5)}delta(n){return n.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(n,o){return this.delta(o).multiplyScalar(n).add(this.start)}closestPointToPointParameter(n,o){Br.subVectors(n,this.start),fl.subVectors(this.end,this.start);const l=fl.dot(fl);let p=fl.dot(Br)/l;return o&&(p=an(p,0,1)),p}closestPointToPoint(n,o,l){const u=this.closestPointToPointParameter(n,o);return this.delta(l).multiplyScalar(u).add(this.start)}distanceSqToLine3(n,o=Hs,l=jr){const u=10000000000000001e-32;let p,g;const y=this.start,b=n.start,S=this.end,A=n.end;Or.subVectors(S,y),Ho.subVectors(A,b),Er.subVectors(y,b);const R=Or.dot(Or),N=Ho.dot(Ho),L=Ho.dot(Er);if(R<=u&&N<=u)return o.copy(y),l.copy(b),o.sub(l),o.dot(o);if(R<=u)p=0,g=L/N,g=an(g,0,1);else{const I=Or.dot(Er);if(N<=u)g=0,p=an(-I/R,0,1);else{const B=Or.dot(Ho),Z=R*N-B*B;Z!==0?p=an((B*L-I*N)/Z,0,1):p=0,g=(B*p+L)/N,g<0?(g=0,p=an(-I/R,0,1)):g>1&&(g=1,p=an((B-I)/R,0,1))}}return o.copy(y).add(Or.multiplyScalar(p)),l.copy(b).add(Ho.multiplyScalar(g)),o.sub(l),o.dot(o)}applyMatrix4(n){return this.start.applyMatrix4(n),this.end.applyMatrix4(n),this}equals(n){return n.start.equals(this.start)&&n.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Vp=new ie;class Sb extends null{constructor(n,o){super(),this.light=n,this.matrixAutoUpdate=!1,this.color=o,this.type="SpotLightHelper";const l=new $n,u=[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 g=0,y=1,b=32;g<b;g++,y++){const S=g/b*Math.PI*2,A=y/b*Math.PI*2;u.push(Math.cos(S),Math.sin(S),1,Math.cos(A),Math.sin(A),1)}l.setAttribute("position",new Ht(u,3));const p=new Ur({fog:!1,toneMapped:!1});this.cone=new tp(l,p),this.add(this.cone),this.update()}dispose(){this.cone.geometry.dispose(),this.cone.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),this.parent?(this.parent.updateWorldMatrix(!0),this.matrix.copy(this.parent.matrixWorld).invert().multiply(this.light.matrixWorld)):this.matrix.copy(this.light.matrixWorld),this.matrixWorld.copy(this.light.matrixWorld);const n=this.light.distance?this.light.distance:1e3,o=n*Math.tan(this.light.angle);this.cone.scale.set(o,o,n),Vp.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Vp),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const uo=new ie,uc=new Ln,ai=new Ln;class gd extends null{constructor(n){const o=$s(n),l=new $n,u=[],p=[];for(let S=0;S<o.length;S++){const A=o[S];A.parent&&A.parent.isBone&&(u.push(0,0,0),u.push(0,0,0),p.push(0,0,0),p.push(0,0,0))}l.setAttribute("position",new Ht(u,3)),l.setAttribute("color",new Ht(p,3));const g=new Ur({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(l,g),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=n,this.bones=o,this.matrix=n.matrixWorld,this.matrixAutoUpdate=!1;const y=new Nn(255),b=new Nn(65280);this.setColors(y,b)}updateMatrixWorld(n){const o=this.bones,l=this.geometry,u=l.getAttribute("position");ai.copy(this.root.matrixWorld).invert();for(let p=0,g=0;p<o.length;p++){const y=o[p];y.parent&&y.parent.isBone&&(uc.multiplyMatrices(ai,y.matrixWorld),uo.setFromMatrixPosition(uc),u.setXYZ(g,uo.x,uo.y,uo.z),uc.multiplyMatrices(ai,y.parent.matrixWorld),uo.setFromMatrixPosition(uc),u.setXYZ(g+1,uo.x,uo.y,uo.z),g+=2)}l.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(n)}setColors(n,o){const u=this.geometry.getAttribute("color");for(let p=0;p<u.count;p+=2)u.setXYZ(p,n.r,n.g,n.b),u.setXYZ(p+1,o.r,o.g,o.b);return u.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}function $s(M){const n=[];M.isBone===!0&&n.push(M);for(let o=0;o<M.children.length;o++)n.push(...$s(M.children[o]));return n}class Tb extends null{constructor(n,o,l){const u=new ru(o,4,2),p=new Wc({wireframe:!0,fog:!1,toneMapped:!1});super(u,p),this.light=n,this.color=l,this.type="PointLightHelper",this.matrix=this.light.matrixWorld,this.matrixAutoUpdate=!1,this.update()}dispose(){this.geometry.dispose(),this.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.color!==void 0?this.material.color.set(this.color):this.material.color.copy(this.light.color)}}const q0=new ie,xd=new Nn,_d=new Nn;class Mb extends null{constructor(n,o,l){super(),this.light=n,this.matrix=n.matrixWorld,this.matrixAutoUpdate=!1,this.color=l,this.type="HemisphereLightHelper";const u=new sd(o);u.rotateY(Math.PI*.5),this.material=new Wc({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const p=u.getAttribute("position"),g=new Float32Array(p.count*3);u.setAttribute("color",new dr(g,3)),this.add(new aa(u,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const n=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const o=n.geometry.getAttribute("color");xd.copy(this.light.color),_d.copy(this.light.groundColor);for(let l=0,u=o.count;l<u;l++){const p=l<u/2?xd:_d;o.setXYZ(l,p.r,p.g,p.b)}o.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),n.lookAt(q0.setFromMatrixPosition(this.light.matrixWorld).negate())}}class wb extends null{constructor(n=10,o=10,l=4473924,u=8947848){l=new Nn(l),u=new Nn(u);const p=o/2,g=n/o,y=n/2,b=[],S=[];for(let N=0,L=0,I=-y;N<=o;N++,I+=g){b.push(-y,0,I,y,0,I),b.push(I,0,-y,I,0,y);const B=N===p?l:u;B.toArray(S,L),L+=3,B.toArray(S,L),L+=3,B.toArray(S,L),L+=3,B.toArray(S,L),L+=3}const A=new $n;A.setAttribute("position",new Ht(b,3)),A.setAttribute("color",new Ht(S,3));const R=new Ur({vertexColors:!0,toneMapped:!1});super(A,R),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class K0 extends null{constructor(n=10,o=16,l=8,u=64,p=4473924,g=8947848){p=new Nn(p),g=new Nn(g);const y=[],b=[];if(o>1)for(let R=0;R<o;R++){const N=R/o*(Math.PI*2),L=Math.sin(N)*n,I=Math.cos(N)*n;y.push(0,0,0),y.push(L,0,I);const B=R&1?p:g;b.push(B.r,B.g,B.b),b.push(B.r,B.g,B.b)}for(let R=0;R<l;R++){const N=R&1?p:g,L=n-n/l*R;for(let I=0;I<u;I++){let B=I/u*(Math.PI*2),Z=Math.sin(B)*L,q=Math.cos(B)*L;y.push(Z,0,q),b.push(N.r,N.g,N.b),B=(I+1)/u*(Math.PI*2),Z=Math.sin(B)*L,q=Math.cos(B)*L,y.push(Z,0,q),b.push(N.r,N.g,N.b)}}const S=new $n;S.setAttribute("position",new Ht(y,3)),S.setAttribute("color",new Ht(b,3));const A=new Ur({vertexColors:!0,toneMapped:!1});super(S,A),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const yd=new ie,Tu=new ie,zp=new ie;class Ab extends null{constructor(n,o,l){super(),this.light=n,this.matrix=n.matrixWorld,this.matrixAutoUpdate=!1,this.color=l,this.type="DirectionalLightHelper",o===void 0&&(o=1);let u=new $n;u.setAttribute("position",new Ht([-o,o,0,o,o,0,o,-o,0,-o,-o,0,-o,o,0],3));const p=new Ur({fog:!1,toneMapped:!1});this.lightPlane=new Yl(u,p),this.add(this.lightPlane),u=new $n,u.setAttribute("position",new Ht([0,0,0,0,0,1],3)),this.targetLine=new Yl(u,p),this.add(this.targetLine),this.update()}dispose(){this.lightPlane.geometry.dispose(),this.lightPlane.material.dispose(),this.targetLine.geometry.dispose(),this.targetLine.material.dispose()}update(){this.light.updateWorldMatrix(!0,!1),this.light.target.updateWorldMatrix(!0,!1),yd.setFromMatrixPosition(this.light.matrixWorld),Tu.setFromMatrixPosition(this.light.target.matrixWorld),zp.subVectors(Tu,yd),this.lightPlane.lookAt(Tu),this.color!==void 0?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color)),this.targetLine.lookAt(Tu),this.targetLine.scale.z=zp.length()}}const Mu=new ie,Kn=new $c;class Mi extends null{constructor(n){const o=new $n,l=new Ur({color:16777215,vertexColors:!0,toneMapped:!1}),u=[],p=[],g={};y("n1","n2"),y("n2","n4"),y("n4","n3"),y("n3","n1"),y("f1","f2"),y("f2","f4"),y("f4","f3"),y("f3","f1"),y("n1","f1"),y("n2","f2"),y("n3","f3"),y("n4","f4"),y("p","n1"),y("p","n2"),y("p","n3"),y("p","n4"),y("u1","u2"),y("u2","u3"),y("u3","u1"),y("c","t"),y("p","c"),y("cn1","cn2"),y("cn3","cn4"),y("cf1","cf2"),y("cf3","cf4");function y(I,B){b(I),b(B)}function b(I){u.push(0,0,0),p.push(0,0,0),g[I]===void 0&&(g[I]=[]),g[I].push(u.length/3-1)}o.setAttribute("position",new Ht(u,3)),o.setAttribute("color",new Ht(p,3)),super(o,l),this.type="CameraHelper",this.camera=n,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=n.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=g,this.update();const S=new Nn(16755200),A=new Nn(16711680),R=new Nn(43775),N=new Nn(16777215),L=new Nn(3355443);this.setColors(S,A,R,N,L)}setColors(n,o,l,u,p){const y=this.geometry.getAttribute("color");return y.setXYZ(0,n.r,n.g,n.b),y.setXYZ(1,n.r,n.g,n.b),y.setXYZ(2,n.r,n.g,n.b),y.setXYZ(3,n.r,n.g,n.b),y.setXYZ(4,n.r,n.g,n.b),y.setXYZ(5,n.r,n.g,n.b),y.setXYZ(6,n.r,n.g,n.b),y.setXYZ(7,n.r,n.g,n.b),y.setXYZ(8,n.r,n.g,n.b),y.setXYZ(9,n.r,n.g,n.b),y.setXYZ(10,n.r,n.g,n.b),y.setXYZ(11,n.r,n.g,n.b),y.setXYZ(12,n.r,n.g,n.b),y.setXYZ(13,n.r,n.g,n.b),y.setXYZ(14,n.r,n.g,n.b),y.setXYZ(15,n.r,n.g,n.b),y.setXYZ(16,n.r,n.g,n.b),y.setXYZ(17,n.r,n.g,n.b),y.setXYZ(18,n.r,n.g,n.b),y.setXYZ(19,n.r,n.g,n.b),y.setXYZ(20,n.r,n.g,n.b),y.setXYZ(21,n.r,n.g,n.b),y.setXYZ(22,n.r,n.g,n.b),y.setXYZ(23,n.r,n.g,n.b),y.setXYZ(24,o.r,o.g,o.b),y.setXYZ(25,o.r,o.g,o.b),y.setXYZ(26,o.r,o.g,o.b),y.setXYZ(27,o.r,o.g,o.b),y.setXYZ(28,o.r,o.g,o.b),y.setXYZ(29,o.r,o.g,o.b),y.setXYZ(30,o.r,o.g,o.b),y.setXYZ(31,o.r,o.g,o.b),y.setXYZ(32,l.r,l.g,l.b),y.setXYZ(33,l.r,l.g,l.b),y.setXYZ(34,l.r,l.g,l.b),y.setXYZ(35,l.r,l.g,l.b),y.setXYZ(36,l.r,l.g,l.b),y.setXYZ(37,l.r,l.g,l.b),y.setXYZ(38,u.r,u.g,u.b),y.setXYZ(39,u.r,u.g,u.b),y.setXYZ(40,p.r,p.g,p.b),y.setXYZ(41,p.r,p.g,p.b),y.setXYZ(42,p.r,p.g,p.b),y.setXYZ(43,p.r,p.g,p.b),y.setXYZ(44,p.r,p.g,p.b),y.setXYZ(45,p.r,p.g,p.b),y.setXYZ(46,p.r,p.g,p.b),y.setXYZ(47,p.r,p.g,p.b),y.setXYZ(48,p.r,p.g,p.b),y.setXYZ(49,p.r,p.g,p.b),y.needsUpdate=!0,this}update(){const n=this.geometry,o=this.pointMap,l=1,u=1;let p,g;if(Kn.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),this.camera.reversedDepth===!0)p=1,g=0;else if(this.camera.coordinateSystem===Mr)p=-1,g=1;else if(this.camera.coordinateSystem===Ia)p=0,g=1;else throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);Pi("c",o,n,Kn,0,0,p),Pi("t",o,n,Kn,0,0,g),Pi("n1",o,n,Kn,-l,-u,p),Pi("n2",o,n,Kn,l,-u,p),Pi("n3",o,n,Kn,-l,u,p),Pi("n4",o,n,Kn,l,u,p),Pi("f1",o,n,Kn,-l,-u,g),Pi("f2",o,n,Kn,l,-u,g),Pi("f3",o,n,Kn,-l,u,g),Pi("f4",o,n,Kn,l,u,g),Pi("u1",o,n,Kn,l*.7,u*1.1,p),Pi("u2",o,n,Kn,-l*.7,u*1.1,p),Pi("u3",o,n,Kn,0,u*2,p),Pi("cf1",o,n,Kn,-l,0,g),Pi("cf2",o,n,Kn,l,0,g),Pi("cf3",o,n,Kn,0,-u,g),Pi("cf4",o,n,Kn,0,u,g),Pi("cn1",o,n,Kn,-l,0,p),Pi("cn2",o,n,Kn,l,0,p),Pi("cn3",o,n,Kn,0,-u,p),Pi("cn4",o,n,Kn,0,u,p),n.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function Pi(M,n,o,l,u,p,g){Mu.set(u,p,g).unproject(l);const y=n[M];if(y!==void 0){const b=o.getAttribute("position");for(let S=0,A=y.length;S<A;S++)b.setXYZ(y[S],Mu.x,Mu.y,Mu.z)}}const wu=new wr;class Eb extends null{constructor(n,o=16776960){const l=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),u=new Float32Array(8*3),p=new $n;p.setIndex(new dr(l,1)),p.setAttribute("position",new dr(u,3)),super(p,new Ur({color:o,toneMapped:!1})),this.object=n,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&wu.setFromObject(this.object),wu.isEmpty())return;const n=wu.min,o=wu.max,l=this.geometry.attributes.position,u=l.array;u[0]=o.x,u[1]=o.y,u[2]=o.z,u[3]=n.x,u[4]=o.y,u[5]=o.z,u[6]=n.x,u[7]=n.y,u[8]=o.z,u[9]=o.x,u[10]=n.y,u[11]=o.z,u[12]=o.x,u[13]=o.y,u[14]=n.z,u[15]=n.x,u[16]=o.y,u[17]=n.z,u[18]=n.x,u[19]=n.y,u[20]=n.z,u[21]=o.x,u[22]=n.y,u[23]=n.z,l.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(n){return this.object=n,this.update(),this}copy(n,o){return super.copy(n,o),this.object=n.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Cb extends null{constructor(n,o=16776960){const l=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),u=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],p=new $n;p.setIndex(new dr(l,1)),p.setAttribute("position",new Ht(u,3)),super(p,new Ur({color:o,toneMapped:!1})),this.box=n,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(n){const o=this.box;o.isEmpty()||(o.getCenter(this.position),o.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(n))}dispose(){this.geometry.dispose(),this.material.dispose()}}class ho extends null{constructor(n,o=1,l=16776960){const u=l,p=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],g=new $n;g.setAttribute("position",new Ht(p,3)),g.computeBoundingSphere(),super(g,new Ur({color:u,toneMapped:!1})),this.type="PlaneHelper",this.plane=n,this.size=o;const y=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],b=new $n;b.setAttribute("position",new Ht(y,3)),b.computeBoundingSphere(),this.add(new aa(b,new Wc({color:u,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(n){this.position.set(0,0,0),this.scale.set(.5*this.size,.5*this.size,1),this.lookAt(this.plane.normal),this.translateZ(-this.plane.constant),super.updateMatrixWorld(n)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const xa=new ie;let kr,Au;class Rb extends null{constructor(n=new ie(0,0,1),o=new ie(0,0,0),l=1,u=16776960,p=l*.2,g=p*.2){super(),this.type="ArrowHelper",kr===void 0&&(kr=new $n,kr.setAttribute("position",new Ht([0,0,0,0,1,0],3)),Au=new Qc(.5,1,5,1),Au.translate(0,-.5,0)),this.position.copy(o),this.line=new Yl(kr,new Ur({color:u,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new aa(Au,new Wc({color:u,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(n),this.setLength(l,p,g)}setDirection(n){if(n.y>.99999)this.quaternion.set(0,0,0,1);else if(n.y<-.99999)this.quaternion.set(1,0,0,0);else{xa.set(n.z,0,-n.x).normalize();const o=Math.acos(n.y);this.quaternion.setFromAxisAngle(xa,o)}}setLength(n,o=n*.2,l=o*.2){this.line.scale.set(1,Math.max(1e-4,n-o),1),this.line.updateMatrix(),this.cone.scale.set(l,o,l),this.cone.position.y=n,this.cone.updateMatrix()}setColor(n){this.line.material.color.set(n),this.cone.material.color.set(n)}copy(n){return super.copy(n,!1),this.line.copy(n.line),this.cone.copy(n.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class Z0 extends null{constructor(n=1){const o=[0,0,0,n,0,0,0,0,0,0,n,0,0,0,0,0,0,n],l=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],u=new $n;u.setAttribute("position",new Ht(o,3)),u.setAttribute("color",new Ht(l,3));const p=new Ur({vertexColors:!0,toneMapped:!1});super(u,p),this.type="AxesHelper"}setColors(n,o,l){const u=new Nn,p=this.geometry.attributes.color.array;return u.set(n),u.toArray(p,0),u.toArray(p,3),u.set(o),u.toArray(p,6),u.toArray(p,9),u.set(l),u.toArray(p,12),u.toArray(p,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Nb{constructor(){this.type="ShapePath",this.color=new Nn,this.subPaths=[],this.currentPath=null}moveTo(n,o){return this.currentPath=new tl,this.subPaths.push(this.currentPath),this.currentPath.moveTo(n,o),this}lineTo(n,o){return this.currentPath.lineTo(n,o),this}quadraticCurveTo(n,o,l,u){return this.currentPath.quadraticCurveTo(n,o,l,u),this}bezierCurveTo(n,o,l,u,p,g){return this.currentPath.bezierCurveTo(n,o,l,u,p,g),this}splineThru(n){return this.currentPath.splineThru(n),this}toShapes(n){function o(q){const ee=[];for(let te=0,he=q.length;te<he;te++){const Re=q[te],ke=new la;ke.curves=Re.curves,ee.push(ke)}return ee}function l(q,ee){const te=ee.length;let he=!1;for(let Re=te-1,ke=0;ke<te;Re=ke++){let We=ee[Re],ze=ee[ke],lt=ze.x-We.x,mt=ze.y-We.y;if(Math.abs(mt)>Number.EPSILON){if(mt<0&&(We=ee[ke],lt=-lt,ze=ee[Re],mt=-mt),q.y<We.y||q.y>ze.y)continue;if(q.y===We.y){if(q.x===We.x)return!0}else{const Zt=mt*(q.x-We.x)-lt*(q.y-We.y);if(Zt===0)return!0;if(Zt<0)continue;he=!he}}else{if(q.y!==We.y)continue;if(ze.x<=q.x&&q.x<=We.x||We.x<=q.x&&q.x<=ze.x)return!0}}return he}const u=cr.isClockWise,p=this.subPaths;if(p.length===0)return[];let g,y,b;const S=[];if(p.length===1)return y=p[0],b=new la,b.curves=y.curves,S.push(b),S;let A=!u(p[0].getPoints());A=n?!A:A;const R=[],N=[];let L=[],I=0,B;N[I]=void 0,L[I]=[];for(let q=0,ee=p.length;q<ee;q++)y=p[q],B=y.getPoints(),g=u(B),g=n?!g:g,g?(!A&&N[I]&&I++,N[I]={s:new la,p:B},N[I].s.curves=y.curves,A&&I++,L[I]=[]):L[I].push({h:y,p:B[0]});if(!N[0])return o(p);if(N.length>1){let q=!1,ee=0;for(let te=0,he=N.length;te<he;te++)R[te]=[];for(let te=0,he=N.length;te<he;te++){const Re=L[te];for(let ke=0;ke<Re.length;ke++){const We=Re[ke];let ze=!0;for(let lt=0;lt<N.length;lt++)l(We.p,N[lt].p)&&(te!==lt&&ee++,ze?(ze=!1,R[lt].push(We)):q=!0);ze&&R[te].push(We)}}ee>0&&q===!1&&(L=R)}let Z;for(let q=0,ee=N.length;q<ee;q++){b=N[q].s,S.push(b),Z=L[q];for(let te=0,he=Z.length;te<he;te++)b.holes.push(Z[te].h)}return S}}class Y0 extends ea{constructor(n,o=null){super(),this.object=n,this.domElement=o,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(n){if(n===void 0){dn("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=n}disconnect(){}dispose(){}update(){}}function Gp(M,n){const o=M.image&&M.image.width?M.image.width/M.image.height:1;return o>n?(M.repeat.x=1,M.repeat.y=o/n,M.offset.x=0,M.offset.y=(1-M.repeat.y)/2):(M.repeat.x=n/o,M.repeat.y=1,M.offset.x=(1-M.repeat.x)/2,M.offset.y=0),M}function Xn(M,n){const o=M.image&&M.image.width?M.image.width/M.image.height:1;return o>n?(M.repeat.x=n/o,M.repeat.y=1,M.offset.x=(1-M.repeat.x)/2,M.offset.y=0):(M.repeat.x=1,M.repeat.y=o/n,M.offset.x=0,M.offset.y=(1-M.repeat.y)/2),M}function ys(M){return M.repeat.x=1,M.repeat.y=1,M.offset.x=0,M.offset.y=0,M}function bd(M,n,o,l){const u=Wp(l);switch(o){case eg:return M*n;case Qd:return M*n/u.components*u.byteLength;case Rl:return M*n/u.components*u.byteLength;case ig:return M*n*2/u.components*u.byteLength;case rg:return M*n*2/u.components*u.byteLength;case tg:return M*n*3/u.components*u.byteLength;case wo:return M*n*4/u.components*u.byteLength;case og:return M*n*4/u.components*u.byteLength;case ag:case pr:return Math.floor((M+3)/4)*Math.floor((n+3)/4)*8;case Ca:case Nl:return Math.floor((M+3)/4)*Math.floor((n+3)/4)*16;case lg:case hg:return Math.max(M,16)*Math.max(n,8)/4;case cg:case ug:return Math.max(M,8)*Math.max(n,8)/2;case dg:case fg:return Math.floor((M+3)/4)*Math.floor((n+3)/4)*8;case pg:return Math.floor((M+3)/4)*Math.floor((n+3)/4)*16;case mg:return Math.floor((M+3)/4)*Math.floor((n+3)/4)*16;case gg:return Math.floor((M+4)/5)*Math.floor((n+3)/4)*16;case xg:return Math.floor((M+4)/5)*Math.floor((n+4)/5)*16;case Jd:return Math.floor((M+5)/6)*Math.floor((n+4)/5)*16;case Ra:return Math.floor((M+5)/6)*Math.floor((n+5)/6)*16;case Cc:return Math.floor((M+7)/8)*Math.floor((n+4)/5)*16;case Na:return Math.floor((M+7)/8)*Math.floor((n+5)/6)*16;case sh:return Math.floor((M+7)/8)*Math.floor((n+7)/8)*16;case oh:return Math.floor((M+9)/10)*Math.floor((n+4)/5)*16;case ah:return Math.floor((M+9)/10)*Math.floor((n+5)/6)*16;case _g:return Math.floor((M+9)/10)*Math.floor((n+7)/8)*16;case ef:return Math.floor((M+9)/10)*Math.floor((n+9)/10)*16;case N_:return Math.floor((M+11)/12)*Math.floor((n+9)/10)*16;case ch:return Math.floor((M+11)/12)*Math.floor((n+11)/12)*16;case tf:case nf:case rf:return Math.ceil(M/4)*Math.ceil(n/4)*16;case yg:case P_:return Math.ceil(M/4)*Math.ceil(n/4)*8;case sf:case of:return Math.ceil(M/4)*Math.ceil(n/4)*16}throw new Error(`Unable to determine texture byte length for ${o} format.`)}function Wp(M){switch(M){case Cl:case $m:return{byteLength:1,components:1};case Xm:case jm:case Km:return{byteLength:2,components:1};case Zm:case Ym:return{byteLength:2,components:4};case rh:case qm:case Jo:return{byteLength:4,components:1};case Qm:case Jm:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${M}.`)}class bs{static contain(n,o){return Gp(n,o)}static cover(n,o){return Xn(n,o)}static fill(n){return ys(n)}static getByteLength(n,o,l,u){return bd(n,o,l,u)}}typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:d}})),typeof window!="undefined"&&(window.__THREE__?dn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=d)}}]);
}());