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/5896.c1a9528c.async.js

5219 lines
1.9 MiB

!(function(){var tZ=Object.defineProperty,nZ=Object.defineProperties;var iZ=Object.getOwnPropertyDescriptors;var NL=Object.getOwnPropertySymbols,sZ=Object.getPrototypeOf,rZ=Object.prototype.hasOwnProperty,oZ=Object.prototype.propertyIsEnumerable,aZ=Reflect.get;var Cp=Math.pow,PL=(ot,Ve,re)=>Ve in ot?tZ(ot,Ve,{enumerable:!0,configurable:!0,writable:!0,value:re}):ot[Ve]=re,wi=(ot,Ve)=>{for(var re in Ve||(Ve={}))rZ.call(Ve,re)&&PL(ot,re,Ve[re]);if(NL)for(var re of NL(Ve))oZ.call(Ve,re)&&PL(ot,re,Ve[re]);return ot},Mo=(ot,Ve)=>nZ(ot,iZ(Ve));var IL=(ot,Ve,re)=>aZ(sZ(ot),re,Ve);var mn=(ot,Ve,re)=>new Promise((xe,pe)=>{var ce=j=>{try{J(re.next(j))}catch(K){pe(K)}},$=j=>{try{J(re.throw(j))}catch(K){pe(K)}},J=j=>j.done?xe(j.value):Promise.resolve(j.value).then(ce,$);J((re=re.apply(ot,Ve)).next())});(self.webpackChunk=self.webpackChunk||[]).push([[5896],{91998:function(ot,Ve,re){ot.exports=pe,ot.exports.simulator=re(72879);var xe=re(82396);function pe($,J){if(!$)throw new Error("Graph structure cannot be undefined");var j=J&&J.createSimulator||re(72879),K=j(J);if(Array.isArray(J))throw new Error("Physics settings is expected to be an object");var te=$.version>19?xi:tn;J&&typeof J.nodeMass=="function"&&(te=J.nodeMass);var ue=new Map,ge={},oe=0,Me=K.settings.springTransform||ce;at(),ut();var we=!1,Ae={step:function(){if(oe===0)return ve(!0),!0;var gt=K.step();Ae.lastMove=gt,Ae.fire("step");var hn=gt/oe,$n=hn<=.01;return ve($n),$n},getNodePosition:function(gt){return Jt(gt).pos},setNodePosition:function(gt){var hn=Jt(gt);hn.setPosition.apply(hn,Array.prototype.slice.call(arguments,1))},getLinkPosition:function(gt){var hn=ge[gt];if(hn)return{from:hn.from.pos,to:hn.to.pos}},getGraphRect:function(){return K.getBBox()},forEachBody:Ue,pinNode:function(gt,hn){var $n=Jt(gt.id);$n.isPinned=!!hn},isNodePinned:function(gt){return Jt(gt.id).isPinned},dispose:function(){$.off("changed",tt),Ae.fire("disposed")},getBody:Ke,getSpring:Ye,getForceVectorLength:Je,simulator:K,graph:$,lastMove:0};return xe(Ae),Ae;function ve(gt){we!==gt&&(we=gt,nt(gt))}function Ue(gt){ue.forEach(gt)}function Je(){var gt=0,hn=0;return Ue(function($n){gt+=Math.abs($n.force.x),hn+=Math.abs($n.force.y)}),Math.sqrt(gt*gt+hn*hn)}function Ye(gt,hn){var $n;if(hn===void 0)typeof gt!="object"?$n=gt:$n=gt.id;else{var Yi=$.hasLink(gt,hn);if(!Yi)return;$n=Yi.id}return ge[$n]}function Ke(gt){return ue.get(gt)}function ut(){$.on("changed",tt)}function nt(gt){Ae.fire("stable",gt)}function tt(gt){for(var hn=0;hn<gt.length;++hn){var $n=gt[hn];$n.changeType==="add"?($n.node&&_t($n.node.id),$n.link&&Sn($n.link)):$n.changeType==="remove"&&($n.node&&un($n.node),$n.link&&Cn($n.link))}oe=$.getNodesCount()}function at(){oe=0,$.forEachNode(function(gt){_t(gt.id),oe+=1}),$.forEachLink(Sn)}function _t(gt){var hn=ue.get(gt);if(!hn){var $n=$.getNode(gt);if(!$n)throw new Error("initBody() was called with unknown node id");var Yi=$n.position;if(!Yi){var To=Pn($n);Yi=K.getBestNewBodyPosition(To)}hn=K.addBodyAt(Yi),hn.id=gt,ue.set(gt,hn),Rt(gt),Rn($n)&&(hn.isPinned=!0)}}function un(gt){var hn=gt.id,$n=ue.get(hn);$n&&(ue.delete(hn),K.removeBody($n))}function Sn(gt){Rt(gt.fromId),Rt(gt.toId);var hn=ue.get(gt.fromId),$n=ue.get(gt.toId),Yi=K.addSpring(hn,$n,gt.length);Me(gt,Yi),ge[gt.id]=Yi}function Cn(gt){var hn=ge[gt.id];if(hn){var $n=$.getNode(gt.fromId),Yi=$.getNode(gt.toId);$n&&Rt($n.id),Yi&&Rt(Yi.id),delete ge[gt.id],K.removeSpring(hn)}}function Pn(gt){var hn=[];if(!gt.links)return hn;for(var $n=Math.min(gt.links.length,2),Yi=0;Yi<$n;++Yi){var To=gt.links[Yi],Aa=To.fromId!==gt.id?ue.get(To.fromId):ue.get(To.toId);Aa&&Aa.pos&&hn.push(Aa)}return hn}function Rt(gt){var hn=ue.get(gt);if(hn.mass=te(gt),Number.isNaN(hn.mass))throw new Error("Node mass should be a number")}function Rn(gt){return gt&&(gt.isPinned||gt.data&&gt.data.isPinned)}function Jt(gt){var hn=ue.get(gt);return hn||(_t(gt),hn=ue.get(gt)),hn}function tn(gt){var hn=$.getLinks(gt);return hn?1+hn.length/3:1}function xi(gt){var hn=$.getLinks(gt);return hn?1+hn.size/3:1}}function ce(){}},98786:function(ot,Ve,re){const xe=re(59321);ot.exports=function(ce){return $;function $(J,j){let K=j&&j.indent||0,te=j&&j.join!==void 0?j.join:`
`,ue=Array(K+1).join(" "),ge=[];for(let oe=0;oe<ce;++oe){let Me=xe(oe),we=oe===0?"":ue;ge.push(we+J.replace(/{var}/g,Me))}return ge.join(te)}}},41085:function(ot,Ve,re){ot.exports=pe,ot.exports.generateFunctionBody=ce;const xe=re(98786);function pe($){let J=ce($);return new Function("bodies","settings","random",J)}function ce($){let J=xe($);return`
var boundingBox = {
${J("min_{var}: 0, max_{var}: 0,",{indent:4})}
};
return {
box: boundingBox,
update: updateBoundingBox,
reset: resetBoundingBox,
getBestNewPosition: function (neighbors) {
var ${J("base_{var} = 0",{join:", "})};
if (neighbors.length) {
for (var i = 0; i < neighbors.length; ++i) {
let neighborPos = neighbors[i].pos;
${J("base_{var} += neighborPos.{var};",{indent:10})}
}
${J("base_{var} /= neighbors.length;",{indent:8})}
} else {
${J("base_{var} = (boundingBox.min_{var} + boundingBox.max_{var}) / 2;",{indent:8})}
}
var springLength = settings.springLength;
return {
${J("{var}: base_{var} + (random.nextDouble() - 0.5) * springLength,",{indent:8})}
};
}
};
function updateBoundingBox() {
var i = bodies.length;
if (i === 0) return; // No bodies - no borders.
${J("var max_{var} = -Infinity;",{indent:4})}
${J("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;
${J("if (bodyPos.{var} < min_{var}) min_{var} = bodyPos.{var};",{indent:6})}
${J("if (bodyPos.{var} > max_{var}) max_{var} = bodyPos.{var};",{indent:6})}
}
${J("boundingBox.min_{var} = min_{var};",{indent:4})}
${J("boundingBox.max_{var} = max_{var};",{indent:4})}
}
function resetBoundingBox() {
${J("boundingBox.min_{var} = boundingBox.max_{var} = 0;",{indent:4})}
}
`}},53623:function(ot,Ve,re){const xe=re(98786);ot.exports=pe,ot.exports.generateCreateBodyFunctionBody=ce,ot.exports.getVectorCode=J,ot.exports.getBodyCode=$;function pe(j,K){let te=ce(j,K),{Body:ue}=new Function(te)();return ue}function ce(j,K){return`
${J(j,K)}
${$(j,K)}
return {Body: Body, Vector: Vector};
`}function $(j){let K=xe(j),te=K("{var}",{join:", "});return`
function Body(${te}) {
this.isPinned = false;
this.pos = new Vector(${te});
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 (${te}) {
${K("this.pos.{var} = {var} || 0;",{indent:2})}
};`}function J(j,K){let te=xe(j),ue="";return K&&(ue=`${te(`
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(${te("{var}",{join:", "})}) {
${ue}
if (typeof arguments[0] === 'object') {
// could be another vector
let v = arguments[0];
${te('if (!Number.isFinite(v.{var})) throw new Error("Expected value is not a finite number at Vector constructor ({var})");',{indent:4})}
${te("this.{var} = v.{var};",{indent:4})}
} else {
${te('this.{var} = typeof {var} === "number" ? {var} : 0;',{indent:4})}
}
}
Vector.prototype.reset = function () {
${te("this.{var} = ",{join:""})}0;
};`}},48812:function(ot,Ve,re){const xe=re(98786);ot.exports=pe,ot.exports.generateCreateDragForceFunctionBody=ce;function pe($){let J=ce($);return new Function("options",J)}function ce($){return`
if (!Number.isFinite(options.dragCoefficient)) throw new Error('dragCoefficient is not a finite number');
return {
update: function(body) {
${xe($)("body.force.{var} -= options.dragCoefficient * body.velocity.{var};",{indent:6})}
}
};
`}},7584:function(ot,Ve,re){const xe=re(98786);ot.exports=pe,ot.exports.generateCreateSpringForceFunctionBody=ce;function pe($){let J=ce($);return new Function("options","random",J)}function ce($){let J=xe($);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;
${J("var d{var} = body2.pos.{var} - body1.pos.{var};",{indent:6})}
var r = Math.sqrt(${J("d{var} * d{var}",{join:" + "})});
if (r === 0) {
${J("d{var} = (random.nextDouble() - 0.5) / 50;",{indent:8})}
r = Math.sqrt(${J("d{var} * d{var}",{join:" + "})});
}
var d = r - length;
var coefficient = ((spring.coefficient > 0) ? spring.coefficient : options.springCoefficient) * d / r;
${J("body1.force.{var} += coefficient * d{var}",{indent:6})};
body1.springCount += 1;
body1.springLength += r;
${J("body2.force.{var} -= coefficient * d{var}",{indent:6})};
body2.springCount += 1;
body2.springLength += r;
}
};
`}},26302:function(ot,Ve,re){const xe=re(98786);ot.exports=pe,ot.exports.generateIntegratorFunctionBody=ce;function pe($){let J=ce($);return new Function("bodies","timeStep","adaptiveTimeStepWeight",J)}function ce($){let J=xe($);return`
var length = bodies.length;
if (length === 0) return 0;
${J("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;
${J("body.velocity.{var} += coeff * body.force.{var};",{indent:4})}
${J("var v{var} = body.velocity.{var};",{indent:4})}
var v = Math.sqrt(${J("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.
${J("body.velocity.{var} = v{var} / v;",{indent:6})}
}
${J("d{var} = timeStep * body.velocity.{var};",{indent:4})}
${J("body.pos.{var} += d{var};",{indent:4})}
${J("t{var} += Math.abs(d{var});",{indent:4})}
}
return (${J("t{var} * t{var}",{join:" + "})})/length;
`}},24454:function(ot,Ve,re){const xe=re(98786),pe=re(59321);ot.exports=ce,ot.exports.generateQuadTreeFunctionBody=$,ot.exports.getInsertStackCode=ue,ot.exports.getQuadNodeCode=te,ot.exports.isSamePosition=J,ot.exports.getChildBodyCode=K,ot.exports.setChildBodyCode=j;function ce(ge){let oe=$(ge);return new Function(oe)()}function $(ge){let oe=xe(ge),Me=Math.pow(2,ge);return`
${ue()}
${te(ge)}
${J(ge)}
${K(ge)}
${j(ge)}
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) {
${Ue(" node.")}
node.body = null;
node.mass = ${oe("node.mass_{var} = ",{join:""})}0;
${oe("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;
${oe("var d{var};",{indent:4})}
var r;
${oe("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.
${oe("d{var} = body.pos.{var} - sourceBody.pos.{var};",{indent:8})}
r = Math.sqrt(${oe("d{var} * d{var}",{join:" + "})});
if (r === 0) {
// Poor man's protection against zero distance.
${oe("d{var} = (random.nextDouble() - 0.5) / 50;",{indent:10})}
r = Math.sqrt(${oe("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);
${oe("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
${oe("d{var} = node.mass_{var} / node.mass - sourceBody.pos.{var};",{indent:8})}
r = Math.sqrt(${oe("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.
${oe("d{var} = (random.nextDouble() - 0.5) / 50;",{indent:10})}
r = Math.sqrt(${oe("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_${pe(0)} - node.min_${pe(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);
${oe("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.
${ve()}
}
}
}
${oe("sourceBody.force.{var} += f{var};",{indent:4})}
}
function insertBodies(bodies) {
${oe("var {var}min = Number.MAX_VALUE;",{indent:4})}
${oe("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;
${oe("if (pos.{var} < {var}min) {var}min = pos.{var};",{indent:6})}
${oe("if (pos.{var} > {var}max) {var}max = pos.{var};",{indent:6})}
}
// Makes the bounds square.
var maxSideLength = -Infinity;
${oe("if ({var}max - {var}min > maxSideLength) maxSideLength = {var}max - {var}min ;",{indent:4})}
currentInCache = 0;
root = newNode();
${oe("root.min_{var} = {var}min;",{indent:4})}
${oe("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.
${oe("var {var} = body.pos.{var};",{indent:8})}
node.mass += body.mass;
${oe("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.
${oe("var min_{var} = node.min_{var};",{indent:8})}
${oe("var max_{var} = (min_{var} + node.max_{var}) / 2;",{indent:8})}
${Ae(8)}
var child = getChild(node, quadIdx);
if (!child) {
// The node is internal but this quadrant is not taken. Add
// subnode to it.
child = newNode();
${oe("child.min_{var} = min_{var};",{indent:10})}
${oe("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();
${oe("var d{var} = (node.max_{var} - node.min_{var}) * offset;",{indent:12})}
${oe("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 Ae(Je){let Ye=[],Ke=Array(Je+1).join(" ");for(let ut=0;ut<ge;++ut)Ye.push(Ke+`if (${pe(ut)} > max_${pe(ut)}) {`),Ye.push(Ke+` quadIdx = quadIdx + ${Math.pow(2,ut)};`),Ye.push(Ke+` min_${pe(ut)} = max_${pe(ut)};`),Ye.push(Ke+` max_${pe(ut)} = node.max_${pe(ut)};`),Ye.push(Ke+"}");return Ye.join(`
`)}function ve(){let Je=Array(11).join(" "),Ye=[];for(let Ke=0;Ke<Me;++Ke)Ye.push(Je+`if (node.quad${Ke}) {`),Ye.push(Je+` queue[pushIdx] = node.quad${Ke};`),Ye.push(Je+" queueLength += 1;"),Ye.push(Je+" pushIdx += 1;"),Ye.push(Je+"}");return Ye.join(`
`)}function Ue(Je){let Ye=[];for(let Ke=0;Ke<Me;++Ke)Ye.push(`${Je}quad${Ke} = null;`);return Ye.join(`
`)}}function J(ge){let oe=xe(ge);return`
function isSamePosition(point1, point2) {
${oe("var d{var} = Math.abs(point1.{var} - point2.{var});",{indent:2})}
return ${oe("d{var} < 1e-8",{join:" && "})};
}
`}function j(ge){var oe=Math.pow(2,ge);return`
function setChild(node, idx, child) {
${Me()}
}`;function Me(){let we=[];for(let Ae=0;Ae<oe;++Ae){let ve=Ae===0?" ":" else ";we.push(`${ve}if (idx === ${Ae}) node.quad${Ae} = child;`)}return we.join(`
`)}}function K(ge){return`function getChild(node, idx) {
${oe()}
return null;
}`;function oe(){let Me=[],we=Math.pow(2,ge);for(let Ae=0;Ae<we;++Ae)Me.push(` if (idx === ${Ae}) return node.quad${Ae};`);return Me.join(`
`)}}function te(ge){let oe=xe(ge),Me=Math.pow(2,ge);var we=`
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
${Ae(" this.")}
// Total mass of current node
this.mass = 0;
// Center of mass coordinates
${oe("this.mass_{var} = 0;",{indent:2})}
// bounding box coordinates
${oe("this.min_{var} = 0;",{indent:2})}
${oe("this.max_{var} = 0;",{indent:2})}
}
`;return we;function Ae(ve){let Ue=[];for(let Je=0;Je<Me;++Je)Ue.push(`${ve}quad${Je} = null;`);return Ue.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(ot){ot.exports=function(re){return re===0?"x":re===1?"y":re===2?"z":"c"+(re+1)}},72879:function(ot,Ve,re){ot.exports=te;var xe=re(53623),pe=re(24454),ce=re(41085),$=re(48812),J=re(7584),j=re(26302),K={};function te(oe){var Me=re(75877),we=re(35764),Ae=re(82396);if(oe){if(oe.springCoeff!==void 0)throw new Error("springCoeff was renamed to springCoefficient");if(oe.dragCoeff!==void 0)throw new Error("dragCoeff was renamed to dragCoefficient")}oe=we(oe,{springLength:10,springCoefficient:.8,gravity:-12,theta:.8,dragCoefficient:.9,timeStep:.5,adaptiveTimeStepWeight:0,dimensions:2,debug:!1});var ve=K[oe.dimensions];if(!ve){var Ue=oe.dimensions;ve={Body:xe(Ue,oe.debug),createQuadTree:pe(Ue),createBounds:ce(Ue),createDragForce:$(Ue),createSpringForce:J(Ue),integrate:j(Ue)},K[Ue]=ve}var Je=ve.Body,Ye=ve.createQuadTree,Ke=ve.createBounds,ut=ve.createDragForce,nt=ve.createSpringForce,tt=ve.integrate,at=zn=>new Je(zn),_t=re(40232).random(42),un=[],Sn=[],Cn=Ye(oe,_t),Pn=Ke(un,oe,_t),Rt=nt(oe,_t),Rn=ut(oe),Jt=0,tn=[],xi=new Map,gt=0;Yi("nbody",Dl),Yi("spring",nl);var hn={bodies:un,quadTree:Cn,springs:Sn,settings:oe,addForce:Yi,removeForce:To,getForces:Aa,step:function(){for(var zn=0;zn<tn.length;++zn)tn[zn](gt);var Ci=tt(un,oe.timeStep,oe.adaptiveTimeStepWeight);return gt+=1,Ci},addBody:function(zn){if(!zn)throw new Error("Body is required");return un.push(zn),zn},addBodyAt:function(zn){if(!zn)throw new Error("Body position is required");var Ci=at(zn);return un.push(Ci),Ci},removeBody:function(zn){if(zn){var Ci=un.indexOf(zn);if(!(Ci<0))return un.splice(Ci,1),un.length===0&&Pn.reset(),!0}},addSpring:function(zn,Ci,no,$c){if(!zn||!Ci)throw new Error("Cannot add null spring to force simulator");typeof no!="number"&&(no=-1);var qc=new Me(zn,Ci,no,$c>=0?$c:-1);return Sn.push(qc),qc},getTotalMovement:function(){return Jt},removeSpring:function(zn){if(zn){var Ci=Sn.indexOf(zn);if(Ci>-1)return Sn.splice(Ci,1),!0}},getBestNewBodyPosition:function(zn){return Pn.getBestNewPosition(zn)},getBBox:$n,getBoundingBox:$n,invalidateBBox:function(){console.warn("invalidateBBox() is deprecated, bounds always recomputed on `getBBox()` call")},gravity:function(zn){return zn!==void 0?(oe.gravity=zn,Cn.options({gravity:zn}),this):oe.gravity},theta:function(zn){return zn!==void 0?(oe.theta=zn,Cn.options({theta:zn}),this):oe.theta},random:_t};return ue(oe,hn),Ae(hn),hn;function $n(){return Pn.update(),Pn.box}function Yi(zn,Ci){if(xi.has(zn))throw new Error("Force "+zn+" is already added");xi.set(zn,Ci),tn.push(Ci)}function To(zn){var Ci=tn.indexOf(xi.get(zn));Ci<0||(tn.splice(Ci,1),xi.delete(zn))}function Aa(){return xi}function Dl(){if(un.length!==0){Cn.insertBodies(un);for(var zn=un.length;zn--;){var Ci=un[zn];Ci.isPinned||(Ci.reset(),Cn.updateBodyForce(Ci),Rn.update(Ci))}}}function nl(){for(var zn=Sn.length;zn--;)Rt.update(Sn[zn])}}function ue(oe,Me){for(var we in oe)ge(oe,Me,we)}function ge(oe,Me,we){if(oe.hasOwnProperty(we)&&typeof Me[we]!="function"){var Ae=Number.isFinite(oe[we]);Ae?Me[we]=function(ve){if(ve!==void 0){if(!Number.isFinite(ve))throw new Error("Value of "+we+" should be a valid number.");return oe[we]=ve,Me}return oe[we]}:Me[we]=function(ve){return ve!==void 0?(oe[we]=ve,Me):oe[we]}}}},75877:function(ot){ot.exports=Ve;function Ve(re,xe,pe,ce){this.from=re,this.to=xe,this.length=pe,this.coefficient=ce}},35764:function(ot){ot.exports=Ve;function Ve(re,xe){var pe;if(re||(re={}),xe){for(pe in xe)if(xe.hasOwnProperty(pe)){var ce=re.hasOwnProperty(pe),$=typeof xe[pe],J=!ce||typeof re[pe]!==$;J?re[pe]=xe[pe]:$==="object"&&(re[pe]=Ve(re[pe],xe[pe]))}}return re}},40232:function(ot){ot.exports=Ve,ot.exports.random=Ve,ot.exports.randomIterator=j;function Ve(K){var te=typeof K=="number"?K:+new Date;return new re(te)}function re(K){this.seed=K}re.prototype.next=J,re.prototype.nextDouble=$,re.prototype.uniform=$,re.prototype.gaussian=xe,re.prototype.random=$;function xe(){var K,te,ue;do te=this.nextDouble()*2-1,ue=this.nextDouble()*2-1,K=te*te+ue*ue;while(K>=1||K===0);return te*Math.sqrt(-2*Math.log(K)/K)}re.prototype.levy=pe;function pe(){var K=1.5,te=Math.pow(ce(1+K)*Math.sin(Math.PI*K/2)/(ce((1+K)/2)*K*Math.pow(2,(K-1)/2)),1/K);return this.gaussian()*te/Math.pow(Math.abs(this.gaussian()),1/K)}function ce(K){return Math.sqrt(2*Math.PI/K)*Math.pow(1/Math.E*(K+1/(12*K-1/(10*K))),K)}function $(){var K=this.seed;return K=K+2127912214+(K<<12)&4294967295,K=(K^3345072700^K>>>19)&4294967295,K=K+374761393+(K<<5)&4294967295,K=(K+3550635116^K<<9)&4294967295,K=K+4251993797+(K<<3)&4294967295,K=(K^3042594569^K>>>16)&4294967295,this.seed=K,(K&268435455)/268435456}function J(K){return Math.floor(this.nextDouble()*K)}function j(K,te){var ue=te||Ve();if(typeof ue.next!="function")throw new Error("customRandom does not match expected API: next() function is missing");return{forEach:oe,shuffle:ge};function ge(){var Me,we,Ae;for(Me=K.length-1;Me>0;--Me)we=ue.next(Me+1),Ae=K[we],K[we]=K[Me],K[Me]=Ae;return K}function oe(Me){var we,Ae,ve;for(we=K.length-1;we>0;--we)Ae=ue.next(we+1),ve=K[Ae],K[Ae]=K[we],K[we]=ve,Me(ve);K.length&&Me(K[0])}}},82396:function(ot){"use strict";function Ve(pe){xe(pe);const ce=re(pe);return pe.on=ce.on,pe.off=ce.off,pe.fire=ce.fire,pe}function re(pe){let ce=Object.create(null);return{on:function($,J,j){if(typeof J!="function")throw new Error("callback is expected to be a function");let K=ce[$];return K||(K=ce[$]=[]),K.push({callback:J,ctx:j}),pe},off:function($,J){if(typeof $>"u")return ce=Object.create(null),pe;if(ce[$])if(typeof J!="function")delete ce[$];else{const j=ce[$];for(let K=0;K<j.length;++K)j[K].callback===J&&j.splice(K,1)}return pe},fire:function($){const J=ce[$];if(!J)return pe;let j;arguments.length>1&&(j=Array.prototype.slice.call(arguments,1));for(let K=0;K<J.length;++K){const te=J[K];te.callback.apply(te.ctx,j)}return pe}}}function xe(pe){if(!pe)throw new Error("Eventify cannot use falsy object as events subject");const ce=["on","fire","off"];for(let $=0;$<ce.length;++$)if(pe.hasOwnProperty(ce[$]))throw new Error("Subject cannot be eventified, since it already has property '"+ce[$]+"'")}ot.exports=Ve},76820:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return qY}});const xe="182",pe={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},ce={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},$=0,J=1,j=2,K=3,te=0,ue=1,ge=2,oe=3,Me=0,we=1,Ae=2,ve=0,Ue=1,Je=2,Ye=3,Ke=4,ut=5,nt=100,tt=101,at=102,_t=103,un=104,Sn=200,Cn=201,Pn=202,Rt=203,Rn=204,Jt=205,tn=206,xi=207,gt=208,hn=209,$n=210,Yi=211,To=212,Aa=213,Dl=214,nl=0,zn=1,Ci=2,no=3,$c=4,qc=5,Rp=6,Np=7,Xc=0,Hb=1,$b=2,yr=0,o_=1,a_=2,l_=3,c_=4,qb=5,u_=6,h_=7,Cg="attached",Xb="detached",_h=300,Cr=301,Xo=302,jc=303,Yc=304,Fl=306,Ea=1e3,ki=1001,Ca=1002,ni=1003,Pp=1004,LL=1004,Ra=1005,DL=1005,Yn=1006,Zc=1007,FL=1007,Vs=1008,nA=1008,Di=1009,Kc=1010,Jc=1011,jo=1012,er=1013,yi=1014,Si=1015,Hi=1016,Ip=1017,Lp=1018,wo=1020,Dp=35902,Fp=35899,Rg=1021,tf=1022,Ri=1023,tr=1026,Rr=1027,Qc=1028,Bl=1029,Nr=1030,xh=1031,iA=1032,vh=1033,Ol=33776,Ul=33777,kl=33778,zl=33779,nf=35840,sf=35841,rf=35842,of=35843,bh=36196,Sh=37492,Mh=37496,Th=37488,wh=37489,eu=37490,Ah=37491,Eh=37808,Ch=37809,Rh=37810,Nh=37811,Ph=37812,Ih=37813,Lh=37814,Dh=37815,Fh=37816,Bh=37817,Oh=37818,Uh=37819,kh=37820,zh=37821,Vh=36492,Ng=36494,Pg=36495,Gh=36283,Wh=36284,tu=36285,il=36286,Ig=2200,Lg=2201,Hh=2202,sl=2300,$h=2301,af=2302,nu=2400,lf=2401,Dg=2402,d_=2500,f_=2501,BL=0,OL=1,UL=2,qh=3200,kL=3201,jb=3202,Ao=3203,Yo=0,Fg=1,_r="",Pr="srgb",io="srgb-linear",cf="linear",$t="srgb",p_="",Yb="rg",sA="ga",rA=0,Xh=7680,oA=7681,aA=7682,lA=7683,cA=34055,uA=34056,hA=5386,m_=512,dA=513,fA=514,pA=515,mA=516,gA=517,yA=518,g_=519,y_=512,Vl=513,__=514,Bp=515,x_=516,v_=517,Op=518,b_=519,jh=35044,Yh=35048,zL=35040,VL=35045,rl=35049,Up=35041,GL=35046,WL=35050,HL=35042,_A="100",S_="300 es",ws=2e3,xr=2001,ol={COMPUTE:"compute",RENDER:"render"},Zb={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},iu={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"};function M_(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}const xA={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function su(i,e){return new xA[i](e)}function Mn(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function ci(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Bg(){const i=ci("canvas");return i.style.display="block",i}const Kb={};let Zo=null;function Ir(i){Zo=i}function Jb(){return Zo}function Ko(...i){const e="THREE."+i.shift();Zo?Zo("log",e,...i):console.log(e,...i)}function Ie(...i){const e="THREE."+i.shift();Zo?Zo("warn",e,...i):console.warn(e,...i)}function Be(...i){const e="THREE."+i.shift();Zo?Zo("error",e,...i):console.error(e,...i)}function Ut(...i){const e=i.join(" ");e in Kb||(Kb[e]=!0,Ie(...i))}function Og(i,e,t){return new Promise(function(n,r){function o(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:r();break;case i.TIMEOUT_EXPIRED:setTimeout(o,t);break;default:n()}}setTimeout(o,t)})}class Jo{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const r=n[e];if(r!==void 0){const o=r.indexOf(t);o!==-1&&r.splice(o,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const r=n.slice(0);for(let o=0,a=r.length;o<a;o++)r[o].call(this,e);e.target=null}}}const vr=["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 Zh=1234567;const ru=Math.PI/180,ou=180/Math.PI;function so(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(vr[i&255]+vr[i>>8&255]+vr[i>>16&255]+vr[i>>24&255]+"-"+vr[e&255]+vr[e>>8&255]+"-"+vr[e>>16&15|64]+vr[e>>24&255]+"-"+vr[t&63|128]+vr[t>>8&255]+"-"+vr[t>>16&255]+vr[t>>24&255]+vr[n&255]+vr[n>>8&255]+vr[n>>16&255]+vr[n>>24&255]).toLowerCase()}function Vn(i,e,t){return Math.max(e,Math.min(t,i))}function Ug(i,e){return(i%e+e)%e}function Qb(i,e,t,n,r){return n+(i-e)*(r-n)/(t-e)}function eS(i,e,t){return i!==e?(t-i)/(e-i):0}function uf(i,e,t){return(1-t)*i+t*e}function tS(i,e,t,n){return uf(i,e,1-Math.exp(-t*n))}function nS(i,e=1){return e-Math.abs(Ug(i,e*2)-e)}function iS(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function sS(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function rS(i,e){return i+Math.floor(Math.random()*(e-i+1))}function oS(i,e){return i+Math.random()*(e-i)}function Lr(i){return i*(.5-Math.random())}function Qn(i){i!==void 0&&(Zh=i);let e=Zh+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function vA(i){return i*ru}function St(i){return i*ou}function ro(i){return(i&i-1)===0&&i!==0}function ae(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function kg(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function T_(i,e,t,n,r){const o=Math.cos,a=Math.sin,c=o(t/2),u=a(t/2),d=o((e+n)/2),p=a((e+n)/2),m=o((e-n)/2),y=a((e-n)/2),x=o((n-e)/2),v=a((n-e)/2);switch(r){case"XYX":i.set(c*p,u*m,u*y,c*d);break;case"YZY":i.set(u*y,c*p,u*m,c*d);break;case"ZXZ":i.set(u*m,u*y,c*p,c*d);break;case"XZX":i.set(c*p,u*v,u*x,c*d);break;case"YXY":i.set(u*x,c*p,u*v,c*d);break;case"ZYZ":i.set(u*v,u*x,c*p,c*d);break;default:Ie("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function ts(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("Invalid component type.")}}function Jn(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("Invalid component type.")}}const Kh={DEG2RAD:ru,RAD2DEG:ou,generateUUID:so,clamp:Vn,euclideanModulo:Ug,mapLinear:Qb,inverseLerp:eS,lerp:uf,damp:tS,pingpong:nS,smoothstep:iS,smootherstep:sS,randInt:rS,randFloat:oS,randFloatSpread:Lr,seededRandom:Qn,degToRad:vA,radToDeg:St,isPowerOfTwo:ro,ceilPowerOfTwo:ae,floorPowerOfTwo:kg,setQuaternionFromProperEuler:T_,normalize:Jn,denormalize:ts};class ze{constructor(e=0,t=0){ze.prototype.isVector2=!0,this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6],this.y=r[1]*t+r[4]*n+r[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Vn(this.x,e.x,t.x),this.y=Vn(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Vn(this.x,e,t),this.y=Vn(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Vn(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Vn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),r=Math.sin(t),o=this.x-e.x,a=this.y-e.y;return this.x=o*n-a*r+e.x,this.y=o*r+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Gs{constructor(e=0,t=0,n=0,r=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=r}static slerpFlat(e,t,n,r,o,a,c){let u=n[r+0],d=n[r+1],p=n[r+2],m=n[r+3],y=o[a+0],x=o[a+1],v=o[a+2],w=o[a+3];if(c<=0){e[t+0]=u,e[t+1]=d,e[t+2]=p,e[t+3]=m;return}if(c>=1){e[t+0]=y,e[t+1]=x,e[t+2]=v,e[t+3]=w;return}if(m!==w||u!==y||d!==x||p!==v){let M=u*y+d*x+p*v+m*w;M<0&&(y=-y,x=-x,v=-v,w=-w,M=-M);let S=1-c;if(M<.9995){const C=Math.acos(M),N=Math.sin(C);S=Math.sin(S*C)/N,c=Math.sin(c*C)/N,u=u*S+y*c,d=d*S+x*c,p=p*S+v*c,m=m*S+w*c}else{u=u*S+y*c,d=d*S+x*c,p=p*S+v*c,m=m*S+w*c;const C=1/Math.sqrt(u*u+d*d+p*p+m*m);u*=C,d*=C,p*=C,m*=C}}e[t]=u,e[t+1]=d,e[t+2]=p,e[t+3]=m}static multiplyQuaternionsFlat(e,t,n,r,o,a){const c=n[r],u=n[r+1],d=n[r+2],p=n[r+3],m=o[a],y=o[a+1],x=o[a+2],v=o[a+3];return e[t]=c*v+p*m+u*x-d*y,e[t+1]=u*v+p*y+d*m-c*x,e[t+2]=d*v+p*x+c*y-u*m,e[t+3]=p*v-c*m-u*y-d*x,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,r){return this._x=e,this._y=t,this._z=n,this._w=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,r=e._y,o=e._z,a=e._order,c=Math.cos,u=Math.sin,d=c(n/2),p=c(r/2),m=c(o/2),y=u(n/2),x=u(r/2),v=u(o/2);switch(a){case"XYZ":this._x=y*p*m+d*x*v,this._y=d*x*m-y*p*v,this._z=d*p*v+y*x*m,this._w=d*p*m-y*x*v;break;case"YXZ":this._x=y*p*m+d*x*v,this._y=d*x*m-y*p*v,this._z=d*p*v-y*x*m,this._w=d*p*m+y*x*v;break;case"ZXY":this._x=y*p*m-d*x*v,this._y=d*x*m+y*p*v,this._z=d*p*v+y*x*m,this._w=d*p*m-y*x*v;break;case"ZYX":this._x=y*p*m-d*x*v,this._y=d*x*m+y*p*v,this._z=d*p*v-y*x*m,this._w=d*p*m+y*x*v;break;case"YZX":this._x=y*p*m+d*x*v,this._y=d*x*m+y*p*v,this._z=d*p*v-y*x*m,this._w=d*p*m-y*x*v;break;case"XZY":this._x=y*p*m-d*x*v,this._y=d*x*m-y*p*v,this._z=d*p*v+y*x*m,this._w=d*p*m+y*x*v;break;default:Ie("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,r=Math.sin(n);return this._x=e.x*r,this._y=e.y*r,this._z=e.z*r,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],r=t[4],o=t[8],a=t[1],c=t[5],u=t[9],d=t[2],p=t[6],m=t[10],y=n+c+m;if(y>0){const x=.5/Math.sqrt(y+1);this._w=.25/x,this._x=(p-u)*x,this._y=(o-d)*x,this._z=(a-r)*x}else if(n>c&&n>m){const x=2*Math.sqrt(1+n-c-m);this._w=(p-u)/x,this._x=.25*x,this._y=(r+a)/x,this._z=(o+d)/x}else if(c>m){const x=2*Math.sqrt(1+c-n-m);this._w=(o-d)/x,this._x=(r+a)/x,this._y=.25*x,this._z=(u+p)/x}else{const x=2*Math.sqrt(1+m-n-c);this._w=(a-r)/x,this._x=(o+d)/x,this._y=(u+p)/x,this._z=.25*x}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Vn(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const r=Math.min(1,t/n);return this.slerp(e,r),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,r=e._y,o=e._z,a=e._w,c=t._x,u=t._y,d=t._z,p=t._w;return this._x=n*p+a*c+r*d-o*u,this._y=r*p+a*u+o*c-n*d,this._z=o*p+a*d+n*u-r*c,this._w=a*p-n*c-r*u-o*d,this._onChangeCallback(),this}slerp(e,t){if(t<=0)return this;if(t>=1)return this.copy(e);let n=e._x,r=e._y,o=e._z,a=e._w,c=this.dot(e);c<0&&(n=-n,r=-r,o=-o,a=-a,c=-c);let u=1-t;if(c<.9995){const d=Math.acos(c),p=Math.sin(d);u=Math.sin(u*d)/p,t=Math.sin(t*d)/p,this._x=this._x*u+n*t,this._y=this._y*u+r*t,this._z=this._z*u+o*t,this._w=this._w*u+a*t,this._onChangeCallback()}else this._x=this._x*u+n*t,this._y=this._y*u+r*t,this._z=this._z*u+o*t,this._w=this._w*u+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),r=Math.sqrt(1-n),o=Math.sqrt(n);return this.set(r*Math.sin(e),r*Math.cos(e),o*Math.sin(t),o*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class H{constructor(e=0,t=0,n=0){H.prototype.isVector3=!0,this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(au.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(au.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,r=this.z,o=e.elements;return this.x=o[0]*t+o[3]*n+o[6]*r,this.y=o[1]*t+o[4]*n+o[7]*r,this.z=o[2]*t+o[5]*n+o[8]*r,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,o=e.elements,a=1/(o[3]*t+o[7]*n+o[11]*r+o[15]);return this.x=(o[0]*t+o[4]*n+o[8]*r+o[12])*a,this.y=(o[1]*t+o[5]*n+o[9]*r+o[13])*a,this.z=(o[2]*t+o[6]*n+o[10]*r+o[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,r=this.z,o=e.x,a=e.y,c=e.z,u=e.w,d=2*(a*r-c*n),p=2*(c*t-o*r),m=2*(o*n-a*t);return this.x=t+u*d+a*m-c*p,this.y=n+u*p+c*d-o*m,this.z=r+u*m+o*p-a*d,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,r=this.z,o=e.elements;return this.x=o[0]*t+o[4]*n+o[8]*r,this.y=o[1]*t+o[5]*n+o[9]*r,this.z=o[2]*t+o[6]*n+o[10]*r,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Vn(this.x,e.x,t.x),this.y=Vn(this.y,e.y,t.y),this.z=Vn(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Vn(this.x,e,t),this.y=Vn(this.y,e,t),this.z=Vn(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Vn(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,r=e.y,o=e.z,a=t.x,c=t.y,u=t.z;return this.x=r*u-o*c,this.y=o*a-n*u,this.z=n*c-r*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return Qo.copy(this).projectOnVector(e),this.sub(Qo)}reflect(e){return this.sub(Qo.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Vn(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,r=this.z-e.z;return t*t+n*n+r*r}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const r=Math.sin(t)*e;return this.x=r*Math.sin(n),this.y=Math.cos(t)*e,this.z=r*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),r=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=r,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Qo=new H,au=new Gs;class Nn{constructor(e,t,n,r,o,a,c,u,d){Nn.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,r,o,a,c,u,d)}set(e,t,n,r,o,a,c,u,d){const p=this.elements;return p[0]=e,p[1]=r,p[2]=c,p[3]=t,p[4]=o,p[5]=u,p[6]=n,p[7]=a,p[8]=d,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,o=this.elements,a=n[0],c=n[3],u=n[6],d=n[1],p=n[4],m=n[7],y=n[2],x=n[5],v=n[8],w=r[0],M=r[3],S=r[6],C=r[1],N=r[4],I=r[7],U=r[2],F=r[5],k=r[8];return o[0]=a*w+c*C+u*U,o[3]=a*M+c*N+u*F,o[6]=a*S+c*I+u*k,o[1]=d*w+p*C+m*U,o[4]=d*M+p*N+m*F,o[7]=d*S+p*I+m*k,o[2]=y*w+x*C+v*U,o[5]=y*M+x*N+v*F,o[8]=y*S+x*I+v*k,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],r=e[2],o=e[3],a=e[4],c=e[5],u=e[6],d=e[7],p=e[8];return t*a*p-t*c*d-n*o*p+n*c*u+r*o*d-r*a*u}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],o=e[3],a=e[4],c=e[5],u=e[6],d=e[7],p=e[8],m=p*a-c*d,y=c*u-p*o,x=d*o-a*u,v=t*m+n*y+r*x;if(v===0)return this.set(0,0,0,0,0,0,0,0,0);const w=1/v;return e[0]=m*w,e[1]=(r*d-p*n)*w,e[2]=(c*n-r*a)*w,e[3]=y*w,e[4]=(p*t-r*u)*w,e[5]=(r*o-c*t)*w,e[6]=x*w,e[7]=(n*u-d*t)*w,e[8]=(a*t-n*o)*w,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,r,o,a,c){const u=Math.cos(o),d=Math.sin(o);return this.set(n*u,n*d,-n*(u*a+d*c)+a+e,-r*d,r*u,-r*(-d*a+u*c)+c+t,0,0,1),this}scale(e,t){return this.premultiply(zg.makeScale(e,t)),this}rotate(e){return this.premultiply(zg.makeRotation(-e)),this}translate(e,t){return this.premultiply(zg.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<9;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const zg=new Nn,w_=new Nn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Gl=new Nn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Vg(){const i={enabled:!0,workingColorSpace:io,spaces:{},convert:function(r,o,a){return this.enabled===!1||o===a||!o||!a||(this.spaces[o].transfer===$t&&(r.r=ea(r.r),r.g=ea(r.g),r.b=ea(r.b)),this.spaces[o].primaries!==this.spaces[a].primaries&&(r.applyMatrix3(this.spaces[o].toXYZ),r.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===$t&&(r.r=br(r.r),r.g=br(r.g),r.b=br(r.b))),r},workingToColorSpace:function(r,o){return this.convert(r,this.workingColorSpace,o)},colorSpaceToWorking:function(r,o){return this.convert(r,o,this.workingColorSpace)},getPrimaries:function(r){return this.spaces[r].primaries},getTransfer:function(r){return r===_r?cf:this.spaces[r].transfer},getToneMappingMode:function(r){return this.spaces[r].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(r,o=this.workingColorSpace){return r.fromArray(this.spaces[o].luminanceCoefficients)},define:function(r){Object.assign(this.spaces,r)},_getMatrix:function(r,o,a){return r.copy(this.spaces[o].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(r){return this.spaces[r].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(r=this.workingColorSpace){return this.spaces[r].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(r,o){return Ut("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(r,o)},toWorkingColorSpace:function(r,o){return Ut("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(r,o)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[io]:{primaries:e,whitePoint:n,transfer:cf,toXYZ:w_,fromXYZ:Gl,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Pr},outputColorSpaceConfig:{drawingBufferColorSpace:Pr}},[Pr]:{primaries:e,whitePoint:n,transfer:$t,toXYZ:w_,fromXYZ:Gl,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Pr}}}),i}const xn=Vg();function ea(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function br(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let as;class bA{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement=="undefined")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{as===void 0&&(as=ci("canvas")),as.width=e.width,as.height=e.height;const r=as.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=as}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&e instanceof ImageBitmap){const t=ci("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const r=n.getImageData(0,0,e.width,e.height),o=r.data;for(let a=0;a<o.length;a++)o[a]=ea(o[a]/255)*255;return n.putImageData(r,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor(ea(t[n]/255)*255):t[n]=ea(t[n]);return{data:t,width:e.width,height:e.height}}else return Ie("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let SA=0;class lu{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:SA++}),this.uuid=so(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement!="undefined"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame!="undefined"&&t instanceof VideoFrame?e.set(t.displayHeight,t.displayWidth,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},r=this.data;if(r!==null){let o;if(Array.isArray(r)){o=[];for(let a=0,c=r.length;a<c;a++)r[a].isDataTexture?o.push(A_(r[a].image)):o.push(A_(r[a]))}else o=A_(r);n.url=o}return t||(e.images[this.uuid]=n),n}}function A_(i){return typeof HTMLImageElement!="undefined"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&i instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&i instanceof ImageBitmap?bA.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(Ie("Texture: Unable to serialize Texture."),{})}let E_=0;const C_=new H;class fi extends Jo{constructor(e=fi.DEFAULT_IMAGE,t=fi.DEFAULT_MAPPING,n=ki,r=ki,o=Yn,a=Vs,c=Ri,u=Di,d=fi.DEFAULT_ANISOTROPY,p=_r){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:E_++}),this.uuid=so(),this.name="",this.source=new lu(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=r,this.magFilter=o,this.minFilter=a,this.anisotropy=d,this.format=c,this.internalFormat=null,this.type=u,this.offset=new ze(0,0),this.repeat=new ze(1,1),this.center=new ze(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Nn,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=p,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(C_).x}get height(){return this.source.getSize(C_).y}get depth(){return this.source.getSize(C_).z}get image(){return this.source.data}set image(e=null){this.source.data=e}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(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){Ie(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){Ie(`Texture.setValues(): property '${t}' does not exist.`);continue}r&&n&&r.isVector2&&n.isVector2||r&&n&&r.isVector3&&n.isVector3||r&&n&&r.isMatrix3&&n.isMatrix3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).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&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==_h)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ea:e.x=e.x-Math.floor(e.x);break;case ki:e.x=e.x<0?0:1;break;case Ca:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Ea:e.y=e.y-Math.floor(e.y);break;case ki:e.y=e.y<0?0:1;break;case Ca:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}fi.DEFAULT_IMAGE=null,fi.DEFAULT_MAPPING=_h,fi.DEFAULT_ANISOTROPY=1;class gn{constructor(e=0,t=0,n=0,r=1){gn.prototype.isVector4=!0,this.x=e,this.y=t,this.z=n,this.w=r}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,r){return this.x=e,this.y=t,this.z=n,this.w=r,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,r=this.z,o=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*r+a[12]*o,this.y=a[1]*t+a[5]*n+a[9]*r+a[13]*o,this.z=a[2]*t+a[6]*n+a[10]*r+a[14]*o,this.w=a[3]*t+a[7]*n+a[11]*r+a[15]*o,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,r,o;const u=e.elements,d=u[0],p=u[4],m=u[8],y=u[1],x=u[5],v=u[9],w=u[2],M=u[6],S=u[10];if(Math.abs(p-y)<.01&&Math.abs(m-w)<.01&&Math.abs(v-M)<.01){if(Math.abs(p+y)<.1&&Math.abs(m+w)<.1&&Math.abs(v+M)<.1&&Math.abs(d+x+S-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const N=(d+1)/2,I=(x+1)/2,U=(S+1)/2,F=(p+y)/4,k=(m+w)/4,G=(v+M)/4;return N>I&&N>U?N<.01?(n=0,r=.707106781,o=.707106781):(n=Math.sqrt(N),r=F/n,o=k/n):I>U?I<.01?(n=.707106781,r=0,o=.707106781):(r=Math.sqrt(I),n=F/r,o=G/r):U<.01?(n=.707106781,r=.707106781,o=0):(o=Math.sqrt(U),n=k/o,r=G/o),this.set(n,r,o,t),this}let C=Math.sqrt((M-v)*(M-v)+(m-w)*(m-w)+(y-p)*(y-p));return Math.abs(C)<.001&&(C=1),this.x=(M-v)/C,this.y=(m-w)/C,this.z=(y-p)/C,this.w=Math.acos((d+x+S-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Vn(this.x,e.x,t.x),this.y=Vn(this.y,e.y,t.y),this.z=Vn(this.z,e.z,t.z),this.w=Vn(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Vn(this.x,e,t),this.y=Vn(this.y,e,t),this.z=Vn(this.z,e,t),this.w=Vn(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Vn(n,e,t))}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(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}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(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}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 Ws extends Jo{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Yn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},n),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=n.depth,this.scissor=new gn(0,0,e,t),this.scissorTest=!1,this.viewport=new gn(0,0,e,t);const r={width:e,height:t,depth:n.depth},o=new fi(r);this.textures=[];const a=n.count;for(let c=0;c<a;c++)this.textures[c]=o.clone(),this.textures[c].isRenderTargetTexture=!0,this.textures[c].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview}_setTextureOptions(e={}){const t={minFilter:Yn,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let r=0,o=this.textures.length;r<o;r++)this.textures[r].image.width=e,this.textures[r].image.height=t,this.textures[r].image.depth=n,this.textures[r].isData3DTexture!==!0&&(this.textures[r].isArrayTexture=this.textures[r].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const r=Object.assign({},e.textures[t].image);this.textures[t].source=new lu(r)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class qr extends Ws{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class al extends fi{constructor(e=null,t=1,n=1,r=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=ni,this.minFilter=ni,this.wrapR=ki,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class hf extends null{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new al(null,e,t,n),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}}class Wl extends fi{constructor(e=null,t=1,n=1,r=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:r},this.magFilter=ni,this.minFilter=ni,this.wrapR=ki,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class cu extends null{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new Wl(null,e,t,n),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}}class ns{constructor(e=new H(1/0,1/0,1/0),t=new H(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(Fr.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(Fr.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Fr.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.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(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const o=n.getAttribute("position");if(t===!0&&o!==void 0&&e.isInstancedMesh!==!0)for(let a=0,c=o.count;a<c;a++)e.isMesh===!0?e.getVertexPosition(a,Fr):Fr.fromBufferAttribute(o,a),Fr.applyMatrix4(e.matrixWorld),this.expandByPoint(Fr);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),uu.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),uu.copy(n.boundingBox)),uu.applyMatrix4(e.matrixWorld),this.union(uu)}const r=e.children;for(let o=0,a=r.length;o<a;o++)this.expandByObject(r[o],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Fr),Fr.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Ps),Ro.subVectors(this.max,Ps),ll.subVectors(e.a,Ps),Eo.subVectors(e.b,Ps),Hl.subVectors(e.c,Ps),$l.subVectors(Eo,ll),Co.subVectors(Hl,Eo),cl.subVectors(ll,Hl);let t=[0,-$l.z,$l.y,0,-Co.z,Co.y,0,-cl.z,cl.y,$l.z,0,-$l.x,Co.z,0,-Co.x,cl.z,0,-cl.x,-$l.y,$l.x,0,-Co.y,Co.x,0,-cl.y,cl.x,0];return!Pa(t,ll,Eo,Hl,Ro)||(t=[1,0,0,0,1,0,0,0,1],!Pa(t,ll,Eo,Hl,Ro))?!1:(Jh.crossVectors($l,Co),t=[Jh.x,Jh.y,Jh.z],Pa(t,ll,Eo,Hl,Ro))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Fr).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Fr).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Dr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Dr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Dr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Dr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Dr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Dr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Dr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Dr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Dr),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const Dr=[new H,new H,new H,new H,new H,new H,new H,new H],Fr=new H,uu=new ns,ll=new H,Eo=new H,Hl=new H,$l=new H,Co=new H,cl=new H,Ps=new H,Ro=new H,Jh=new H,Na=new H;function Pa(i,e,t,n,r){for(let o=0,a=i.length-3;o<=a;o+=3){Na.fromArray(i,o);const c=r.x*Math.abs(Na.x)+r.y*Math.abs(Na.y)+r.z*Math.abs(Na.z),u=e.dot(Na),d=t.dot(Na),p=n.dot(Na);if(Math.max(-Math.max(u,d,p),Math.min(u,d,p))>c)return!1}return!0}const Gg=new ns,ql=new H,df=new H;class As{constructor(e=new H,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):Gg.setFromPoints(e).getCenter(n);let r=0;for(let o=0,a=e.length;o<a;o++)r=Math.max(r,n.distanceToSquared(e[o]));return this.radius=Math.sqrt(r),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;ql.subVectors(e,this.center);const t=ql.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(ql,r/n),this.radius+=r}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(df.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ql.copy(e.center).add(df)),this.expandByPoint(ql.copy(e.center).sub(df))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}const Dn=new H,Xl=new H,Xr=new H,jl=new H,Wg=new H,ta=new H,Qh=new H;class nr{constructor(e=new H,t=new H(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Dn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Dn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Dn.copy(this.origin).addScaledVector(this.direction,t),Dn.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){Xl.copy(e).add(t).multiplyScalar(.5),Xr.copy(t).sub(e).normalize(),jl.copy(this.origin).sub(Xl);const o=e.distanceTo(t)*.5,a=-this.direction.dot(Xr),c=jl.dot(this.direction),u=-jl.dot(Xr),d=jl.lengthSq(),p=Math.abs(1-a*a);let m,y,x,v;if(p>0)if(m=a*u-c,y=a*c-u,v=o*p,m>=0)if(y>=-v)if(y<=v){const w=1/p;m*=w,y*=w,x=m*(m+a*y+2*c)+y*(a*m+y+2*u)+d}else y=o,m=Math.max(0,-(a*y+c)),x=-m*m+y*(y+2*u)+d;else y=-o,m=Math.max(0,-(a*y+c)),x=-m*m+y*(y+2*u)+d;else y<=-v?(m=Math.max(0,-(-a*o+c)),y=m>0?-o:Math.min(Math.max(-o,-u),o),x=-m*m+y*(y+2*u)+d):y<=v?(m=0,y=Math.min(Math.max(-o,-u),o),x=y*(y+2*u)+d):(m=Math.max(0,-(a*o+c)),y=m>0?o:Math.min(Math.max(-o,-u),o),x=-m*m+y*(y+2*u)+d);else y=a>0?-o:o,m=Math.max(0,-(a*y+c)),x=-m*m+y*(y+2*u)+d;return n&&n.copy(this.origin).addScaledVector(this.direction,m),r&&r.copy(Xl).addScaledVector(Xr,y),x}intersectSphere(e,t){Dn.subVectors(e.center,this.origin);const n=Dn.dot(this.direction),r=Dn.dot(Dn)-n*n,o=e.radius*e.radius;if(r>o)return null;const a=Math.sqrt(o-r),c=n-a,u=n+a;return u<0?null:c<0?this.at(u,t):this.at(c,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,r,o,a,c,u;const d=1/this.direction.x,p=1/this.direction.y,m=1/this.direction.z,y=this.origin;return d>=0?(n=(e.min.x-y.x)*d,r=(e.max.x-y.x)*d):(n=(e.max.x-y.x)*d,r=(e.min.x-y.x)*d),p>=0?(o=(e.min.y-y.y)*p,a=(e.max.y-y.y)*p):(o=(e.max.y-y.y)*p,a=(e.min.y-y.y)*p),n>a||o>r||((o>n||isNaN(n))&&(n=o),(a<r||isNaN(r))&&(r=a),m>=0?(c=(e.min.z-y.z)*m,u=(e.max.z-y.z)*m):(c=(e.max.z-y.z)*m,u=(e.min.z-y.z)*m),n>u||c>r)||((c>n||n!==n)&&(n=c),(u<r||r!==r)&&(r=u),r<0)?null:this.at(n>=0?n:r,t)}intersectsBox(e){return this.intersectBox(e,Dn)!==null}intersectTriangle(e,t,n,r,o){Wg.subVectors(t,e),ta.subVectors(n,e),Qh.crossVectors(Wg,ta);let a=this.direction.dot(Qh),c;if(a>0){if(r)return null;c=1}else if(a<0)c=-1,a=-a;else return null;jl.subVectors(this.origin,e);const u=c*this.direction.dot(ta.crossVectors(jl,ta));if(u<0)return null;const d=c*this.direction.dot(Wg.cross(jl));if(d<0||u+d>a)return null;const p=-c*jl.dot(Qh);return p<0?null:this.at(p/a,o)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Qt{constructor(e,t,n,r,o,a,c,u,d,p,m,y,x,v,w,M){Qt.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,r,o,a,c,u,d,p,m,y,x,v,w,M)}set(e,t,n,r,o,a,c,u,d,p,m,y,x,v,w,M){const S=this.elements;return S[0]=e,S[4]=t,S[8]=n,S[12]=r,S[1]=o,S[5]=a,S[9]=c,S[13]=u,S[2]=d,S[6]=p,S[10]=m,S[14]=y,S[3]=x,S[7]=v,S[11]=w,S[15]=M,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 Qt().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinant()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinant()===0)return this.identity();const t=this.elements,n=e.elements,r=1/hu.setFromMatrixColumn(e,0).length(),o=1/hu.setFromMatrixColumn(e,1).length(),a=1/hu.setFromMatrixColumn(e,2).length();return t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r,t[3]=0,t[4]=n[4]*o,t[5]=n[5]*o,t[6]=n[6]*o,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,r=e.y,o=e.z,a=Math.cos(n),c=Math.sin(n),u=Math.cos(r),d=Math.sin(r),p=Math.cos(o),m=Math.sin(o);if(e.order==="XYZ"){const y=a*p,x=a*m,v=c*p,w=c*m;t[0]=u*p,t[4]=-u*m,t[8]=d,t[1]=x+v*d,t[5]=y-w*d,t[9]=-c*u,t[2]=w-y*d,t[6]=v+x*d,t[10]=a*u}else if(e.order==="YXZ"){const y=u*p,x=u*m,v=d*p,w=d*m;t[0]=y+w*c,t[4]=v*c-x,t[8]=a*d,t[1]=a*m,t[5]=a*p,t[9]=-c,t[2]=x*c-v,t[6]=w+y*c,t[10]=a*u}else if(e.order==="ZXY"){const y=u*p,x=u*m,v=d*p,w=d*m;t[0]=y-w*c,t[4]=-a*m,t[8]=v+x*c,t[1]=x+v*c,t[5]=a*p,t[9]=w-y*c,t[2]=-a*d,t[6]=c,t[10]=a*u}else if(e.order==="ZYX"){const y=a*p,x=a*m,v=c*p,w=c*m;t[0]=u*p,t[4]=v*d-x,t[8]=y*d+w,t[1]=u*m,t[5]=w*d+y,t[9]=x*d-v,t[2]=-d,t[6]=c*u,t[10]=a*u}else if(e.order==="YZX"){const y=a*u,x=a*d,v=c*u,w=c*d;t[0]=u*p,t[4]=w-y*m,t[8]=v*m+x,t[1]=m,t[5]=a*p,t[9]=-c*p,t[2]=-d*p,t[6]=x*m+v,t[10]=y-w*m}else if(e.order==="XZY"){const y=a*u,x=a*d,v=c*u,w=c*d;t[0]=u*p,t[4]=-m,t[8]=d*p,t[1]=y*m+w,t[5]=a*p,t[9]=x*m-v,t[2]=v*m-x,t[6]=c*p,t[10]=w*m+y}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(R_,e,aS)}lookAt(e,t,n){const r=this.elements;return Es.subVectors(e,t),Es.lengthSq()===0&&(Es.z=1),Es.normalize(),ul.crossVectors(n,Es),ul.lengthSq()===0&&(Math.abs(n.z)===1?Es.x+=1e-4:Es.z+=1e-4,Es.normalize(),ul.crossVectors(n,Es)),ul.normalize(),hl.crossVectors(Es,ul),r[0]=ul.x,r[4]=hl.x,r[8]=Es.x,r[1]=ul.y,r[5]=hl.y,r[9]=Es.y,r[2]=ul.z,r[6]=hl.z,r[10]=Es.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,r=t.elements,o=this.elements,a=n[0],c=n[4],u=n[8],d=n[12],p=n[1],m=n[5],y=n[9],x=n[13],v=n[2],w=n[6],M=n[10],S=n[14],C=n[3],N=n[7],I=n[11],U=n[15],F=r[0],k=r[4],G=r[8],B=r[12],z=r[1],Q=r[5],ye=r[9],_e=r[13],Te=r[2],Pe=r[6],Ne=r[10],De=r[14],Qe=r[3],Mt=r[7],Tt=r[11],Fe=r[15];return o[0]=a*F+c*z+u*Te+d*Qe,o[4]=a*k+c*Q+u*Pe+d*Mt,o[8]=a*G+c*ye+u*Ne+d*Tt,o[12]=a*B+c*_e+u*De+d*Fe,o[1]=p*F+m*z+y*Te+x*Qe,o[5]=p*k+m*Q+y*Pe+x*Mt,o[9]=p*G+m*ye+y*Ne+x*Tt,o[13]=p*B+m*_e+y*De+x*Fe,o[2]=v*F+w*z+M*Te+S*Qe,o[6]=v*k+w*Q+M*Pe+S*Mt,o[10]=v*G+w*ye+M*Ne+S*Tt,o[14]=v*B+w*_e+M*De+S*Fe,o[3]=C*F+N*z+I*Te+U*Qe,o[7]=C*k+N*Q+I*Pe+U*Mt,o[11]=C*G+N*ye+I*Ne+U*Tt,o[15]=C*B+N*_e+I*De+U*Fe,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],r=e[8],o=e[12],a=e[1],c=e[5],u=e[9],d=e[13],p=e[2],m=e[6],y=e[10],x=e[14],v=e[3],w=e[7],M=e[11],S=e[15],C=u*x-d*y,N=c*x-d*m,I=c*y-u*m,U=a*x-d*p,F=a*y-u*p,k=a*m-c*p;return t*(w*C-M*N+S*I)-n*(v*C-M*U+S*F)+r*(v*N-w*U+S*k)-o*(v*I-w*F+M*k)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const r=this.elements;return e.isVector3?(r[12]=e.x,r[13]=e.y,r[14]=e.z):(r[12]=e,r[13]=t,r[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],r=e[2],o=e[3],a=e[4],c=e[5],u=e[6],d=e[7],p=e[8],m=e[9],y=e[10],x=e[11],v=e[12],w=e[13],M=e[14],S=e[15],C=m*M*d-w*y*d+w*u*x-c*M*x-m*u*S+c*y*S,N=v*y*d-p*M*d-v*u*x+a*M*x+p*u*S-a*y*S,I=p*w*d-v*m*d+v*c*x-a*w*x-p*c*S+a*m*S,U=v*m*u-p*w*u-v*c*y+a*w*y+p*c*M-a*m*M,F=t*C+n*N+r*I+o*U;if(F===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const k=1/F;return e[0]=C*k,e[1]=(w*y*o-m*M*o-w*r*x+n*M*x+m*r*S-n*y*S)*k,e[2]=(c*M*o-w*u*o+w*r*d-n*M*d-c*r*S+n*u*S)*k,e[3]=(m*u*o-c*y*o-m*r*d+n*y*d+c*r*x-n*u*x)*k,e[4]=N*k,e[5]=(p*M*o-v*y*o+v*r*x-t*M*x-p*r*S+t*y*S)*k,e[6]=(v*u*o-a*M*o-v*r*d+t*M*d+a*r*S-t*u*S)*k,e[7]=(a*y*o-p*u*o+p*r*d-t*y*d-a*r*x+t*u*x)*k,e[8]=I*k,e[9]=(v*m*o-p*w*o-v*n*x+t*w*x+p*n*S-t*m*S)*k,e[10]=(a*w*o-v*c*o+v*n*d-t*w*d-a*n*S+t*c*S)*k,e[11]=(p*c*o-a*m*o-p*n*d+t*m*d+a*n*x-t*c*x)*k,e[12]=U*k,e[13]=(p*w*r-v*m*r+v*n*y-t*w*y-p*n*M+t*m*M)*k,e[14]=(v*c*r-a*w*r-v*n*u+t*w*u+a*n*M-t*c*M)*k,e[15]=(a*m*r-p*c*r+p*n*u-t*m*u-a*n*y+t*c*y)*k,this}scale(e){const t=this.elements,n=e.x,r=e.y,o=e.z;return t[0]*=n,t[4]*=r,t[8]*=o,t[1]*=n,t[5]*=r,t[9]*=o,t[2]*=n,t[6]*=r,t[10]*=o,t[3]*=n,t[7]*=r,t[11]*=o,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],r=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,r))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),r=Math.sin(t),o=1-n,a=e.x,c=e.y,u=e.z,d=o*a,p=o*c;return this.set(d*a+n,d*c-r*u,d*u+r*c,0,d*c+r*u,p*c+n,p*u-r*a,0,d*u-r*c,p*u+r*a,o*u*u+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,r,o,a){return this.set(1,n,o,0,e,1,a,0,t,r,1,0,0,0,0,1),this}compose(e,t,n){const r=this.elements,o=t._x,a=t._y,c=t._z,u=t._w,d=o+o,p=a+a,m=c+c,y=o*d,x=o*p,v=o*m,w=a*p,M=a*m,S=c*m,C=u*d,N=u*p,I=u*m,U=n.x,F=n.y,k=n.z;return r[0]=(1-(w+S))*U,r[1]=(x+I)*U,r[2]=(v-N)*U,r[3]=0,r[4]=(x-I)*F,r[5]=(1-(y+S))*F,r[6]=(M+C)*F,r[7]=0,r[8]=(v+N)*k,r[9]=(M-C)*k,r[10]=(1-(y+w))*k,r[11]=0,r[12]=e.x,r[13]=e.y,r[14]=e.z,r[15]=1,this}decompose(e,t,n){const r=this.elements;if(e.x=r[12],e.y=r[13],e.z=r[14],this.determinant()===0)return n.set(1,1,1),t.identity(),this;let o=hu.set(r[0],r[1],r[2]).length();const a=hu.set(r[4],r[5],r[6]).length(),c=hu.set(r[8],r[9],r[10]).length();this.determinant()<0&&(o=-o),Is.copy(this);const d=1/o,p=1/a,m=1/c;return Is.elements[0]*=d,Is.elements[1]*=d,Is.elements[2]*=d,Is.elements[4]*=p,Is.elements[5]*=p,Is.elements[6]*=p,Is.elements[8]*=m,Is.elements[9]*=m,Is.elements[10]*=m,t.setFromRotationMatrix(Is),n.x=o,n.y=a,n.z=c,this}makePerspective(e,t,n,r,o,a,c=ws,u=!1){const d=this.elements,p=2*o/(t-e),m=2*o/(n-r),y=(t+e)/(t-e),x=(n+r)/(n-r);let v,w;if(u)v=o/(a-o),w=a*o/(a-o);else if(c===ws)v=-(a+o)/(a-o),w=-2*a*o/(a-o);else if(c===xr)v=-a/(a-o),w=-a*o/(a-o);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+c);return d[0]=p,d[4]=0,d[8]=y,d[12]=0,d[1]=0,d[5]=m,d[9]=x,d[13]=0,d[2]=0,d[6]=0,d[10]=v,d[14]=w,d[3]=0,d[7]=0,d[11]=-1,d[15]=0,this}makeOrthographic(e,t,n,r,o,a,c=ws,u=!1){const d=this.elements,p=2/(t-e),m=2/(n-r),y=-(t+e)/(t-e),x=-(n+r)/(n-r);let v,w;if(u)v=1/(a-o),w=a/(a-o);else if(c===ws)v=-2/(a-o),w=-(a+o)/(a-o);else if(c===xr)v=-1/(a-o),w=-o/(a-o);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+c);return d[0]=p,d[4]=0,d[8]=0,d[12]=y,d[1]=0,d[5]=m,d[9]=0,d[13]=x,d[2]=0,d[6]=0,d[10]=v,d[14]=w,d[3]=0,d[7]=0,d[11]=0,d[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let r=0;r<16;r++)if(t[r]!==n[r])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const hu=new H,Is=new Qt,R_=new H(0,0,0),aS=new H(1,1,1),ul=new H,hl=new H,Es=new H,ff=new Qt,ed=new Gs;class jr{constructor(e=0,t=0,n=0,r=jr.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=r}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,r=this._order){return this._x=e,this._y=t,this._z=n,this._order=r,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const r=e.elements,o=r[0],a=r[4],c=r[8],u=r[1],d=r[5],p=r[9],m=r[2],y=r[6],x=r[10];switch(t){case"XYZ":this._y=Math.asin(Vn(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-p,x),this._z=Math.atan2(-a,o)):(this._x=Math.atan2(y,d),this._z=0);break;case"YXZ":this._x=Math.asin(-Vn(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(c,x),this._z=Math.atan2(u,d)):(this._y=Math.atan2(-m,o),this._z=0);break;case"ZXY":this._x=Math.asin(Vn(y,-1,1)),Math.abs(y)<.9999999?(this._y=Math.atan2(-m,x),this._z=Math.atan2(-a,d)):(this._y=0,this._z=Math.atan2(u,o));break;case"ZYX":this._y=Math.asin(-Vn(m,-1,1)),Math.abs(m)<.9999999?(this._x=Math.atan2(y,x),this._z=Math.atan2(u,o)):(this._x=0,this._z=Math.atan2(-a,d));break;case"YZX":this._z=Math.asin(Vn(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(-p,d),this._y=Math.atan2(-m,o)):(this._x=0,this._y=Math.atan2(c,x));break;case"XZY":this._z=Math.asin(-Vn(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(y,d),this._y=Math.atan2(c,o)):(this._x=Math.atan2(-p,x),this._y=0);break;default:Ie("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return ff.makeRotationFromQuaternion(e),this.setFromRotationMatrix(ff,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return ed.setFromEuler(this),this.setFromQuaternion(ed,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}jr.DEFAULT_ORDER="XYZ";class Hg{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let N_=0;const $g=new H,du=new Gs,Ia=new Qt,kp=new H,La=new H,qg=new H,Hs=new Gs,No=new H(1,0,0),Da=new H(0,1,0),zp=new H(0,0,1),Fa={type:"added"},td={type:"removed"},na={type:"childadded",child:null},Vp={type:"childremoved",child:null};class Zi extends Jo{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:N_++}),this.uuid=so(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Zi.DEFAULT_UP.clone();const e=new H,t=new jr,n=new Gs,r=new H(1,1,1);function o(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(o),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:r},modelViewMatrix:{value:new Qt},normalMatrix:{value:new Nn}}),this.matrix=new Qt,this.matrixWorld=new Qt,this.matrixAutoUpdate=Zi.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Zi.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Hg,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(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return du.setFromAxisAngle(e,t),this.quaternion.multiply(du),this}rotateOnWorldAxis(e,t){return du.setFromAxisAngle(e,t),this.quaternion.premultiply(du),this}rotateX(e){return this.rotateOnAxis(No,e)}rotateY(e){return this.rotateOnAxis(Da,e)}rotateZ(e){return this.rotateOnAxis(zp,e)}translateOnAxis(e,t){return $g.copy(e).applyQuaternion(this.quaternion),this.position.add($g.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(No,e)}translateY(e){return this.translateOnAxis(Da,e)}translateZ(e){return this.translateOnAxis(zp,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Ia.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?kp.copy(e):kp.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),La.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ia.lookAt(La,kp,this.up):Ia.lookAt(kp,La,this.up),this.quaternion.setFromRotationMatrix(Ia),r&&(Ia.extractRotation(r.matrixWorld),du.setFromRotationMatrix(Ia),this.quaternion.premultiply(du.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(Be("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Fa),na.child=e,this.dispatchEvent(na),na.child=null):Be("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(td),Vp.child=e,this.dispatchEvent(Vp),Vp.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),Ia.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Ia.multiply(e.parent.matrixWorld)),e.applyMatrix4(Ia),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Fa),na.child=e,this.dispatchEvent(na),na.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,r=this.children.length;n<r;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const r=this.children;for(let o=0,a=r.length;o<a;o++)r[o].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(La,e,qg),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(La,Hs,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,r=t.length;n<r;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t){const n=this.parent;if(e===!0&&n!==null&&n.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)),t===!0){const r=this.children;for(let o=0,a=r.length;o<a;o++)r[o].updateWorldMatrix(!1,!0)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const r={};r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.castShadow===!0&&(r.castShadow=!0),this.receiveShadow===!0&&(r.receiveShadow=!0),this.visible===!1&&(r.visible=!1),this.frustumCulled===!1&&(r.frustumCulled=!1),this.renderOrder!==0&&(r.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(r.userData=this.userData),r.layers=this.layers.mask,r.matrix=this.matrix.toArray(),r.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(r.matrixAutoUpdate=!1),this.isInstancedMesh&&(r.type="InstancedMesh",r.count=this.count,r.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(r.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(r.type="BatchedMesh",r.perObjectFrustumCulled=this.perObjectFrustumCulled,r.sortObjects=this.sortObjects,r.drawRanges=this._drawRanges,r.reservedRanges=this._reservedRanges,r.geometryInfo=this._geometryInfo.map(c=>Mo(wi({},c),{boundingBox:c.boundingBox?c.boundingBox.toJSON():void 0,boundingSphere:c.boundingSphere?c.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(c=>wi({},c)),r.availableInstanceIds=this._availableInstanceIds.slice(),r.availableGeometryIds=this._availableGeometryIds.slice(),r.nextIndexStart=this._nextIndexStart,r.nextVertexStart=this._nextVertexStart,r.geometryCount=this._geometryCount,r.maxInstanceCount=this._maxInstanceCount,r.maxVertexCount=this._maxVertexCount,r.maxIndexCount=this._maxIndexCount,r.geometryInitialized=this._geometryInitialized,r.matricesTexture=this._matricesTexture.toJSON(e),r.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(r.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.toJSON()));function o(c,u){return c[u.uuid]===void 0&&(c[u.uuid]=u.toJSON(e)),u.uuid}if(this.isScene)this.background&&(this.background.isColor?r.background=this.background.toJSON():this.background.isTexture&&(r.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(r.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){r.geometry=o(e.geometries,this.geometry);const c=this.geometry.parameters;if(c!==void 0&&c.shapes!==void 0){const u=c.shapes;if(Array.isArray(u))for(let d=0,p=u.length;d<p;d++){const m=u[d];o(e.shapes,m)}else o(e.shapes,u)}}if(this.isSkinnedMesh&&(r.bindMode=this.bindMode,r.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(o(e.skeletons,this.skeleton),r.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const c=[];for(let u=0,d=this.material.length;u<d;u++)c.push(o(e.materials,this.material[u]));r.material=c}else r.material=o(e.materials,this.material);if(this.children.length>0){r.children=[];for(let c=0;c<this.children.length;c++)r.children.push(this.children[c].toJSON(e).object)}if(this.animations.length>0){r.animations=[];for(let c=0;c<this.animations.length;c++){const u=this.animations[c];r.animations.push(o(e.animations,u))}}if(t){const c=a(e.geometries),u=a(e.materials),d=a(e.textures),p=a(e.images),m=a(e.shapes),y=a(e.skeletons),x=a(e.animations),v=a(e.nodes);c.length>0&&(n.geometries=c),u.length>0&&(n.materials=u),d.length>0&&(n.textures=d),p.length>0&&(n.images=p),m.length>0&&(n.shapes=m),y.length>0&&(n.skeletons=y),x.length>0&&(n.animations=x),v.length>0&&(n.nodes=v)}return n.object=r,n;function a(c){const u=[];for(const d in c){const p=c[d];delete p.metadata,u.push(p)}return u}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const r=e.children[n];this.add(r.clone())}return this}}Zi.DEFAULT_UP=new H(0,1,0),Zi.DEFAULT_MATRIX_AUTO_UPDATE=!0,Zi.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const oo=new H,ia=new H,pf=new H,sa=new H,Yl=new H,ir=new H,Xg=new H,Ba=new H,nd=new H,mf=new H,Zn=new gn,sr=new gn,jg=new gn;class Sr{constructor(e=new H,t=new H,n=new H){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),oo.subVectors(e,t),r.cross(oo);const o=r.lengthSq();return o>0?r.multiplyScalar(1/Math.sqrt(o)):r.set(0,0,0)}static getBarycoord(e,t,n,r,o){oo.subVectors(r,t),ia.subVectors(n,t),pf.subVectors(e,t);const a=oo.dot(oo),c=oo.dot(ia),u=oo.dot(pf),d=ia.dot(ia),p=ia.dot(pf),m=a*d-c*c;if(m===0)return o.set(0,0,0),null;const y=1/m,x=(d*u-c*p)*y,v=(a*p-c*u)*y;return o.set(1-x-v,v,x)}static containsPoint(e,t,n,r){return this.getBarycoord(e,t,n,r,sa)===null?!1:sa.x>=0&&sa.y>=0&&sa.x+sa.y<=1}static getInterpolation(e,t,n,r,o,a,c,u){return this.getBarycoord(e,t,n,r,sa)===null?(u.x=0,u.y=0,"z"in u&&(u.z=0),"w"in u&&(u.w=0),null):(u.setScalar(0),u.addScaledVector(o,sa.x),u.addScaledVector(a,sa.y),u.addScaledVector(c,sa.z),u)}static getInterpolatedAttribute(e,t,n,r,o,a){return Zn.setScalar(0),sr.setScalar(0),jg.setScalar(0),Zn.fromBufferAttribute(e,t),sr.fromBufferAttribute(e,n),jg.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector(Zn,o.x),a.addScaledVector(sr,o.y),a.addScaledVector(jg,o.z),a}static isFrontFacing(e,t,n,r){return oo.subVectors(n,t),ia.subVectors(e,t),oo.cross(ia).dot(r)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,r){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[r]),this}setFromAttributeAndIndices(e,t,n,r){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,r),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return oo.subVectors(this.c,this.b),ia.subVectors(this.a,this.b),oo.cross(ia).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Sr.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Sr.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,o){return Sr.getInterpolation(e,this.a,this.b,this.c,t,n,r,o)}containsPoint(e){return Sr.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Sr.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,r=this.b,o=this.c;let a,c;Yl.subVectors(r,n),ir.subVectors(o,n),Ba.subVectors(e,n);const u=Yl.dot(Ba),d=ir.dot(Ba);if(u<=0&&d<=0)return t.copy(n);nd.subVectors(e,r);const p=Yl.dot(nd),m=ir.dot(nd);if(p>=0&&m<=p)return t.copy(r);const y=u*m-p*d;if(y<=0&&u>=0&&p<=0)return a=u/(u-p),t.copy(n).addScaledVector(Yl,a);mf.subVectors(e,o);const x=Yl.dot(mf),v=ir.dot(mf);if(v>=0&&x<=v)return t.copy(o);const w=x*d-u*v;if(w<=0&&d>=0&&v<=0)return c=d/(d-v),t.copy(n).addScaledVector(ir,c);const M=p*v-x*m;if(M<=0&&m-p>=0&&x-v>=0)return Xg.subVectors(o,r),c=(m-p)/(m-p+(x-v)),t.copy(r).addScaledVector(Xg,c);const S=1/(M+w+y);return a=w*S,c=y*S,t.copy(n).addScaledVector(Yl,a).addScaledVector(ir,c)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const Zl={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},Mr={h:0,s:0,l:0},Yg={h:0,s:0,l:0};function Tr(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}class It{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const r=e;r&&r.isColor?this.copy(r):typeof r=="number"?this.setHex(r):typeof r=="string"&&this.setStyle(r)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=Pr){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,xn.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=xn.workingColorSpace){return this.r=e,this.g=t,this.b=n,xn.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=xn.workingColorSpace){if(e=Ug(e,1),t=Vn(t,0,1),n=Vn(n,0,1),t===0)this.r=this.g=this.b=n;else{const o=n<=.5?n*(1+t):n+t-n*t,a=2*n-o;this.r=Tr(a,o,e+1/3),this.g=Tr(a,o,e),this.b=Tr(a,o,e-1/3)}return xn.colorSpaceToWorking(this,r),this}setStyle(e,t=Pr){function n(o){o!==void 0&&parseFloat(o)<1&&Ie("Color: Alpha component of "+e+" will be ignored.")}let r;if(r=/^(\w+)\(([^\)]*)\)/.exec(e)){let o;const a=r[1],c=r[2];switch(a){case"rgb":case"rgba":if(o=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return n(o[4]),this.setRGB(Math.min(255,parseInt(o[1],10))/255,Math.min(255,parseInt(o[2],10))/255,Math.min(255,parseInt(o[3],10))/255,t);if(o=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return n(o[4]),this.setRGB(Math.min(100,parseInt(o[1],10))/100,Math.min(100,parseInt(o[2],10))/100,Math.min(100,parseInt(o[3],10))/100,t);break;case"hsl":case"hsla":if(o=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(c))return n(o[4]),this.setHSL(parseFloat(o[1])/360,parseFloat(o[2])/100,parseFloat(o[3])/100,t);break;default:Ie("Color: Unknown color model "+e)}}else if(r=/^\#([A-Fa-f\d]+)$/.exec(e)){const o=r[1],a=o.length;if(a===3)return this.setRGB(parseInt(o.charAt(0),16)/15,parseInt(o.charAt(1),16)/15,parseInt(o.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(o,16),t);Ie("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Pr){const n=Zl[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Ie("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=ea(e.r),this.g=ea(e.g),this.b=ea(e.b),this}copyLinearToSRGB(e){return this.r=br(e.r),this.g=br(e.g),this.b=br(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Pr){return xn.workingToColorSpace(Br.copy(this),e),Math.round(Vn(Br.r*255,0,255))*65536+Math.round(Vn(Br.g*255,0,255))*256+Math.round(Vn(Br.b*255,0,255))}getHexString(e=Pr){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=xn.workingColorSpace){xn.workingToColorSpace(Br.copy(this),t);const n=Br.r,r=Br.g,o=Br.b,a=Math.max(n,r,o),c=Math.min(n,r,o);let u,d;const p=(c+a)/2;if(c===a)u=0,d=0;else{const m=a-c;switch(d=p<=.5?m/(a+c):m/(2-a-c),a){case n:u=(r-o)/m+(r<o?6:0);break;case r:u=(o-n)/m+2;break;case o:u=(n-r)/m+4;break}u/=6}return e.h=u,e.s=d,e.l=p,e}getRGB(e,t=xn.workingColorSpace){return xn.workingToColorSpace(Br.copy(this),t),e.r=Br.r,e.g=Br.g,e.b=Br.b,e}getStyle(e=Pr){xn.workingToColorSpace(Br.copy(this),e);const t=Br.r,n=Br.g,r=Br.b;return e!==Pr?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${r.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(r*255)})`}offsetHSL(e,t,n){return this.getHSL(Mr),this.setHSL(Mr.h+e,Mr.s+t,Mr.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(Mr),e.getHSL(Yg);const n=uf(Mr.h,Yg.h,t),r=uf(Mr.s,Yg.s,t),o=uf(Mr.l,Yg.l,t);return this.setHSL(n,r,o),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,r=this.b,o=e.elements;return this.r=o[0]*t+o[3]*n+o[6]*r,this.g=o[1]*t+o[4]*n+o[7]*r,this.b=o[2]*t+o[5]*n+o[8]*r,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Br=new It;It.NAMES=Zl;let Ls=0;class Ds extends Jo{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Ls++}),this.uuid=so(),this.name="",this.type="Material",this.blending=Ue,this.side=Me,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Rn,this.blendDst=Jt,this.blendEquation=nt,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new It(0,0,0),this.blendAlpha=0,this.depthFunc=no,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=g_,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Xh,this.stencilZFail=Xh,this.stencilZPass=Xh,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(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){Ie(`Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){Ie(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}r&&r.isColor?r.set(n):r&&r.isVector3&&n&&n.isVector3?r.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Ue&&(n.blending=this.blending),this.side!==Me&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==Rn&&(n.blendSrc=this.blendSrc),this.blendDst!==Jt&&(n.blendDst=this.blendDst),this.blendEquation!==nt&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==no&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==g_&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Xh&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Xh&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Xh&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function r(o){const a=[];for(const c in o){const u=o[c];delete u.metadata,a.push(u)}return a}if(t){const o=r(e.textures),a=r(e.images);o.length>0&&(n.textures=o),a.length>0&&(n.images=a)}return n}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const r=t.length;n=new Array(r);for(let o=0;o!==r;++o)n[o]=t[o].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class Or extends Ds{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new It(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 jr,this.combine=Xc,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Ki=MA();function MA(){const i=new ArrayBuffer(4),e=new Float32Array(i),t=new Uint32Array(i),n=new Uint32Array(512),r=new Uint32Array(512);for(let u=0;u<256;++u){const d=u-127;d<-27?(n[u]=0,n[u|256]=32768,r[u]=24,r[u|256]=24):d<-14?(n[u]=1024>>-d-14,n[u|256]=1024>>-d-14|32768,r[u]=-d-1,r[u|256]=-d-1):d<=15?(n[u]=d+15<<10,n[u|256]=d+15<<10|32768,r[u]=13,r[u|256]=13):d<128?(n[u]=31744,n[u|256]=64512,r[u]=24,r[u|256]=24):(n[u]=31744,n[u|256]=64512,r[u]=13,r[u|256]=13)}const o=new Uint32Array(2048),a=new Uint32Array(64),c=new Uint32Array(64);for(let u=1;u<1024;++u){let d=u<<13,p=0;for(;!(d&8388608);)d<<=1,p-=8388608;d&=-8388609,p+=947912704,o[u]=d|p}for(let u=1024;u<2048;++u)o[u]=939524096+(u-1024<<13);for(let u=1;u<31;++u)a[u]=u<<23;a[31]=1199570944,a[32]=2147483648;for(let u=33;u<63;++u)a[u]=2147483648+(u-32<<23);a[63]=3347054592;for(let u=1;u<64;++u)u!==32&&(c[u]=1024);return{floatView:e,uint32View:t,baseTable:n,shiftTable:r,mantissaTable:o,exponentTable:a,offsetTable:c}}function ao(i){Math.abs(i)>65504&&Ie("DataUtils.toHalfFloat(): Value out of range."),i=Vn(i,-65504,65504),Ki.floatView[0]=i;const e=Ki.uint32View[0],t=e>>23&511;return Ki.baseTable[t]+((e&8388607)>>Ki.shiftTable[t])}function Gp(i){const e=i>>10;return Ki.uint32View[0]=Ki.mantissaTable[Ki.offsetTable[e]+(i&1023)]+Ki.exponentTable[e],Ki.floatView[0]}class $L{static toHalfFloat(e){return ao(e)}static fromHalfFloat(e){return Gp(e)}}const Fs=new H,Zg=new ze;let lS=0;class $i{constructor(e,t,n=!1){if(Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:lS++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=jh,this.updateRanges=[],this.gpuType=Si,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let r=0,o=this.itemSize;r<o;r++)this.array[e+r]=t.array[n+r];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Zg.fromBufferAttribute(this,t),Zg.applyMatrix3(e),this.setXY(t,Zg.x,Zg.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Fs.fromBufferAttribute(this,t),Fs.applyMatrix3(e),this.setXYZ(t,Fs.x,Fs.y,Fs.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Fs.fromBufferAttribute(this,t),Fs.applyMatrix4(e),this.setXYZ(t,Fs.x,Fs.y,Fs.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Fs.fromBufferAttribute(this,t),Fs.applyNormalMatrix(e),this.setXYZ(t,Fs.x,Fs.y,Fs.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Fs.fromBufferAttribute(this,t),Fs.transformDirection(e),this.setXYZ(t,Fs.x,Fs.y,Fs.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=ts(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Jn(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=ts(t,this.array)),t}setX(e,t){return this.normalized&&(t=Jn(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=ts(t,this.array)),t}setY(e,t){return this.normalized&&(t=Jn(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=ts(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Jn(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=ts(t,this.array)),t}setW(e,t){return this.normalized&&(t=Jn(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Jn(t,this.array),n=Jn(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Jn(t,this.array),n=Jn(n,this.array),r=Jn(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this}setXYZW(e,t,n,r,o){return e*=this.itemSize,this.normalized&&(t=Jn(t,this.array),n=Jn(n,this.array),r=Jn(r,this.array),o=Jn(o,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=r,this.array[e+3]=o,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==jh&&(e.usage=this.usage),e}}class cn extends null{constructor(e,t,n){super(new Int8Array(e),t,n)}}class TA extends null{constructor(e,t,n){super(new Uint8Array(e),t,n)}}class ra extends null{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}}class P_ extends null{constructor(e,t,n){super(new Int16Array(e),t,n)}}class Kl extends $i{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class Po extends null{constructor(e,t,n){super(new Int32Array(e),t,n)}}class fu extends $i{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class $s extends $i{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=Gp(this.array[e*this.itemSize]);return this.normalized&&(t=ts(t,this.array)),t}setX(e,t){return this.normalized&&(t=Jn(t,this.array)),this.array[e*this.itemSize]=ao(t),this}getY(e){let t=Gp(this.array[e*this.itemSize+1]);return this.normalized&&(t=ts(t,this.array)),t}setY(e,t){return this.normalized&&(t=Jn(t,this.array)),this.array[e*this.itemSize+1]=ao(t),this}getZ(e){let t=Gp(this.array[e*this.itemSize+2]);return this.normalized&&(t=ts(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Jn(t,this.array)),this.array[e*this.itemSize+2]=ao(t),this}getW(e){let t=Gp(this.array[e*this.itemSize+3]);return this.normalized&&(t=ts(t,this.array)),t}setW(e,t){return this.normalized&&(t=Jn(t,this.array)),this.array[e*this.itemSize+3]=ao(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Jn(t,this.array),n=Jn(n,this.array)),this.array[e+0]=ao(t),this.array[e+1]=ao(n),this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Jn(t,this.array),n=Jn(n,this.array),r=Jn(r,this.array)),this.array[e+0]=ao(t),this.array[e+1]=ao(n),this.array[e+2]=ao(r),this}setXYZW(e,t,n,r,o){return e*=this.itemSize,this.normalized&&(t=Jn(t,this.array),n=Jn(n,this.array),r=Jn(r,this.array),o=Jn(o,this.array)),this.array[e+0]=ao(t),this.array[e+1]=ao(n),this.array[e+2]=ao(r),this.array[e+3]=ao(o),this}}class ht extends $i{constructor(e,t,n){super(new Float32Array(e),t,n)}}let I_=0;const rr=new Qt,id=new Zi,pu=new H,wr=new ns,Jl=new ns,Cs=new H;class Gn extends Jo{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:I_++}),this.uuid=so(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,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(e){return Array.isArray(e)?this.index=new(M_(e)?fu:Kl)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const o=new Nn().getNormalMatrix(e);n.applyNormalMatrix(o),n.needsUpdate=!0}const r=this.attributes.tangent;return r!==void 0&&(r.transformDirection(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(e){return rr.makeRotationFromQuaternion(e),this.applyMatrix4(rr),this}rotateX(e){return rr.makeRotationX(e),this.applyMatrix4(rr),this}rotateY(e){return rr.makeRotationY(e),this.applyMatrix4(rr),this}rotateZ(e){return rr.makeRotationZ(e),this.applyMatrix4(rr),this}translate(e,t,n){return rr.makeTranslation(e,t,n),this.applyMatrix4(rr),this}scale(e,t,n){return rr.makeScale(e,t,n),this.applyMatrix4(rr),this}lookAt(e){return id.lookAt(e),id.updateMatrix(),this.applyMatrix4(id.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(pu).negate(),this.translate(pu.x,pu.y,pu.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let r=0,o=e.length;r<o;r++){const a=e[r];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new ht(n,3))}else{const n=Math.min(e.length,t.count);for(let r=0;r<n;r++){const o=e[r];t.setXYZ(r,o.x,o.y,o.z||0)}e.length>t.count&&Ie("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ns);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Be("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new H(-1/0,-1/0,-1/0),new H(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,r=t.length;n<r;n++){const o=t[n];wr.setFromBufferAttribute(o),this.morphTargetsRelative?(Cs.addVectors(this.boundingBox.min,wr.min),this.boundingBox.expandByPoint(Cs),Cs.addVectors(this.boundingBox.max,wr.max),this.boundingBox.expandByPoint(Cs)):(this.boundingBox.expandByPoint(wr.min),this.boundingBox.expandByPoint(wr.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Be('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 As);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){Be("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new H,1/0);return}if(e){const n=this.boundingSphere.center;if(wr.setFromBufferAttribute(e),t)for(let o=0,a=t.length;o<a;o++){const c=t[o];Jl.setFromBufferAttribute(c),this.morphTargetsRelative?(Cs.addVectors(wr.min,Jl.min),wr.expandByPoint(Cs),Cs.addVectors(wr.max,Jl.max),wr.expandByPoint(Cs)):(wr.expandByPoint(Jl.min),wr.expandByPoint(Jl.max))}wr.getCenter(n);let r=0;for(let o=0,a=e.count;o<a;o++)Cs.fromBufferAttribute(e,o),r=Math.max(r,n.distanceToSquared(Cs));if(t)for(let o=0,a=t.length;o<a;o++){const c=t[o],u=this.morphTargetsRelative;for(let d=0,p=c.count;d<p;d++)Cs.fromBufferAttribute(c,d),u&&(pu.fromBufferAttribute(e,d),Cs.add(pu)),r=Math.max(r,n.distanceToSquared(Cs))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&Be('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){Be("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,r=t.normal,o=t.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new $i(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),c=[],u=[];for(let G=0;G<n.count;G++)c[G]=new H,u[G]=new H;const d=new H,p=new H,m=new H,y=new ze,x=new ze,v=new ze,w=new H,M=new H;function S(G,B,z){d.fromBufferAttribute(n,G),p.fromBufferAttribute(n,B),m.fromBufferAttribute(n,z),y.fromBufferAttribute(o,G),x.fromBufferAttribute(o,B),v.fromBufferAttribute(o,z),p.sub(d),m.sub(d),x.sub(y),v.sub(y);const Q=1/(x.x*v.y-v.x*x.y);isFinite(Q)&&(w.copy(p).multiplyScalar(v.y).addScaledVector(m,-x.y).multiplyScalar(Q),M.copy(m).multiplyScalar(x.x).addScaledVector(p,-v.x).multiplyScalar(Q),c[G].add(w),c[B].add(w),c[z].add(w),u[G].add(M),u[B].add(M),u[z].add(M))}let C=this.groups;C.length===0&&(C=[{start:0,count:e.count}]);for(let G=0,B=C.length;G<B;++G){const z=C[G],Q=z.start,ye=z.count;for(let _e=Q,Te=Q+ye;_e<Te;_e+=3)S(e.getX(_e+0),e.getX(_e+1),e.getX(_e+2))}const N=new H,I=new H,U=new H,F=new H;function k(G){U.fromBufferAttribute(r,G),F.copy(U);const B=c[G];N.copy(B),N.sub(U.multiplyScalar(U.dot(B))).normalize(),I.crossVectors(F,B);const Q=I.dot(u[G])<0?-1:1;a.setXYZW(G,N.x,N.y,N.z,Q)}for(let G=0,B=C.length;G<B;++G){const z=C[G],Q=z.start,ye=z.count;for(let _e=Q,Te=Q+ye;_e<Te;_e+=3)k(e.getX(_e+0)),k(e.getX(_e+1)),k(e.getX(_e+2))}}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0)n=new $i(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let y=0,x=n.count;y<x;y++)n.setXYZ(y,0,0,0);const r=new H,o=new H,a=new H,c=new H,u=new H,d=new H,p=new H,m=new H;if(e)for(let y=0,x=e.count;y<x;y+=3){const v=e.getX(y+0),w=e.getX(y+1),M=e.getX(y+2);r.fromBufferAttribute(t,v),o.fromBufferAttribute(t,w),a.fromBufferAttribute(t,M),p.subVectors(a,o),m.subVectors(r,o),p.cross(m),c.fromBufferAttribute(n,v),u.fromBufferAttribute(n,w),d.fromBufferAttribute(n,M),c.add(p),u.add(p),d.add(p),n.setXYZ(v,c.x,c.y,c.z),n.setXYZ(w,u.x,u.y,u.z),n.setXYZ(M,d.x,d.y,d.z)}else for(let y=0,x=t.count;y<x;y+=3)r.fromBufferAttribute(t,y+0),o.fromBufferAttribute(t,y+1),a.fromBufferAttribute(t,y+2),p.subVectors(a,o),m.subVectors(r,o),p.cross(m),n.setXYZ(y+0,p.x,p.y,p.z),n.setXYZ(y+1,p.x,p.y,p.z),n.setXYZ(y+2,p.x,p.y,p.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Cs.fromBufferAttribute(e,t),Cs.normalize(),e.setXYZ(t,Cs.x,Cs.y,Cs.z)}toNonIndexed(){function e(c,u){const d=c.array,p=c.itemSize,m=c.normalized,y=new d.constructor(u.length*p);let x=0,v=0;for(let w=0,M=u.length;w<M;w++){c.isInterleavedBufferAttribute?x=u[w]*c.data.stride+c.offset:x=u[w]*p;for(let S=0;S<p;S++)y[v++]=d[x++]}return new $i(y,p,m)}if(this.index===null)return Ie("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new Gn,n=this.index.array,r=this.attributes;for(const c in r){const u=r[c],d=e(u,n);t.setAttribute(c,d)}const o=this.morphAttributes;for(const c in o){const u=[],d=o[c];for(let p=0,m=d.length;p<m;p++){const y=d[p],x=e(y,n);u.push(x)}t.morphAttributes[c]=u}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let c=0,u=a.length;c<u;c++){const d=a[c];t.addGroup(d.start,d.count,d.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0){const u=this.parameters;for(const d in u)u[d]!==void 0&&(e[d]=u[d]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const u in n){const d=n[u];e.data.attributes[u]=d.toJSON(e.data)}const r={};let o=!1;for(const u in this.morphAttributes){const d=this.morphAttributes[u],p=[];for(let m=0,y=d.length;m<y;m++){const x=d[m];p.push(x.toJSON(e.data))}p.length>0&&(r[u]=p,o=!0)}o&&(e.data.morphAttributes=r,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const c=this.boundingSphere;return c!==null&&(e.data.boundingSphere=c.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const r=e.attributes;for(const d in r){const p=r[d];this.setAttribute(d,p.clone(t))}const o=e.morphAttributes;for(const d in o){const p=[],m=o[d];for(let y=0,x=m.length;y<x;y++)p.push(m[y].clone(t));this.morphAttributes[d]=p}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let d=0,p=a.length;d<p;d++){const m=a[d];this.addGroup(m.start,m.count,m.materialIndex)}const c=e.boundingBox;c!==null&&(this.boundingBox=c.clone());const u=e.boundingSphere;return u!==null&&(this.boundingSphere=u.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const gf=new Qt,Ql=new nr,mu=new As,dl=new H,Wp=new H,gu=new H,yu=new H,sd=new H,Hp=new H,L_=new H,Kg=new H;class Ji extends Zi{constructor(e=new Gn,t=new Or){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,a=r.length;o<a;o++){const c=r[o].name||String(o);this.morphTargetInfluences.push(0),this.morphTargetDictionary[c]=o}}}}getVertexPosition(e,t){const n=this.geometry,r=n.attributes.position,o=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(r,e);const c=this.morphTargetInfluences;if(o&&c){Hp.set(0,0,0);for(let u=0,d=o.length;u<d;u++){const p=c[u],m=o[u];p!==0&&(sd.fromBufferAttribute(m,e),a?Hp.addScaledVector(sd,p):Hp.addScaledVector(sd.sub(t),p))}t.add(Hp)}return t}raycast(e,t){const n=this.geometry,r=this.material,o=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),mu.copy(n.boundingSphere),mu.applyMatrix4(o),Ql.copy(e.ray).recast(e.near),!(mu.containsPoint(Ql.origin)===!1&&(Ql.intersectSphere(mu,dl)===null||Ql.origin.distanceToSquared(dl)>Cp(e.far-e.near,2)))&&(gf.copy(o).invert(),Ql.copy(e.ray).applyMatrix4(gf),!(n.boundingBox!==null&&Ql.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Ql)))}_computeIntersections(e,t,n){let r;const o=this.geometry,a=this.material,c=o.index,u=o.attributes.position,d=o.attributes.uv,p=o.attributes.uv1,m=o.attributes.normal,y=o.groups,x=o.drawRange;if(c!==null)if(Array.isArray(a))for(let v=0,w=y.length;v<w;v++){const M=y[v],S=a[M.materialIndex],C=Math.max(M.start,x.start),N=Math.min(c.count,Math.min(M.start+M.count,x.start+x.count));for(let I=C,U=N;I<U;I+=3){const F=c.getX(I),k=c.getX(I+1),G=c.getX(I+2);r=$p(this,S,e,n,d,p,m,F,k,G),r&&(r.faceIndex=Math.floor(I/3),r.face.materialIndex=M.materialIndex,t.push(r))}}else{const v=Math.max(0,x.start),w=Math.min(c.count,x.start+x.count);for(let M=v,S=w;M<S;M+=3){const C=c.getX(M),N=c.getX(M+1),I=c.getX(M+2);r=$p(this,a,e,n,d,p,m,C,N,I),r&&(r.faceIndex=Math.floor(M/3),t.push(r))}}else if(u!==void 0)if(Array.isArray(a))for(let v=0,w=y.length;v<w;v++){const M=y[v],S=a[M.materialIndex],C=Math.max(M.start,x.start),N=Math.min(u.count,Math.min(M.start+M.count,x.start+x.count));for(let I=C,U=N;I<U;I+=3){const F=I,k=I+1,G=I+2;r=$p(this,S,e,n,d,p,m,F,k,G),r&&(r.faceIndex=Math.floor(I/3),r.face.materialIndex=M.materialIndex,t.push(r))}}else{const v=Math.max(0,x.start),w=Math.min(u.count,x.start+x.count);for(let M=v,S=w;M<S;M+=3){const C=M,N=M+1,I=M+2;r=$p(this,a,e,n,d,p,m,C,N,I),r&&(r.faceIndex=Math.floor(M/3),t.push(r))}}}}function cS(i,e,t,n,r,o,a,c){let u;if(e.side===we?u=n.intersectTriangle(a,o,r,!0,c):u=n.intersectTriangle(r,o,a,e.side===Me,c),u===null)return null;Kg.copy(c),Kg.applyMatrix4(i.matrixWorld);const d=t.ray.origin.distanceTo(Kg);return d<t.near||d>t.far?null:{distance:d,point:Kg.clone(),object:i}}function $p(i,e,t,n,r,o,a,c,u,d){i.getVertexPosition(c,Wp),i.getVertexPosition(u,gu),i.getVertexPosition(d,yu);const p=cS(i,e,t,n,Wp,gu,yu,L_);if(p){const m=new H;Sr.getBarycoord(L_,Wp,gu,yu,m),r&&(p.uv=Sr.getInterpolatedAttribute(r,c,u,d,m,new ze)),o&&(p.uv1=Sr.getInterpolatedAttribute(o,c,u,d,m,new ze)),a&&(p.normal=Sr.getInterpolatedAttribute(a,c,u,d,m,new H),p.normal.dot(n.direction)>0&&p.normal.multiplyScalar(-1));const y={a:c,b:u,c:d,normal:new H,materialIndex:0};Sr.getNormal(Wp,gu,yu,y.normal),p.face=y,p.barycoord=m}return p}class fl extends Gn{constructor(e=1,t=1,n=1,r=1,o=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:r,heightSegments:o,depthSegments:a};const c=this;r=Math.floor(r),o=Math.floor(o),a=Math.floor(a);const u=[],d=[],p=[],m=[];let y=0,x=0;v("z","y","x",-1,-1,n,t,e,a,o,0),v("z","y","x",1,-1,n,t,-e,a,o,1),v("x","z","y",1,1,e,n,t,r,a,2),v("x","z","y",1,-1,e,n,-t,r,a,3),v("x","y","z",1,-1,e,t,n,r,o,4),v("x","y","z",-1,-1,e,t,-n,r,o,5),this.setIndex(u),this.setAttribute("position",new ht(d,3)),this.setAttribute("normal",new ht(p,3)),this.setAttribute("uv",new ht(m,2));function v(w,M,S,C,N,I,U,F,k,G,B){const z=I/k,Q=U/G,ye=I/2,_e=U/2,Te=F/2,Pe=k+1,Ne=G+1;let De=0,Qe=0;const Mt=new H;for(let Tt=0;Tt<Ne;Tt++){const Fe=Tt*Q-_e;for(let mt=0;mt<Pe;mt++){const wt=mt*z-ye;Mt[w]=wt*C,Mt[M]=Fe*N,Mt[S]=Te,d.push(Mt.x,Mt.y,Mt.z),Mt[w]=0,Mt[M]=0,Mt[S]=F>0?1:-1,p.push(Mt.x,Mt.y,Mt.z),m.push(mt/k),m.push(1-Tt/G),De+=1}}for(let Tt=0;Tt<G;Tt++)for(let Fe=0;Fe<k;Fe++){const mt=y+Fe+Pe*Tt,wt=y+Fe+Pe*(Tt+1),In=y+(Fe+1)+Pe*(Tt+1),st=y+(Fe+1)+Pe*Tt;u.push(mt,wt,st),u.push(wt,In,st),Qe+=6}c.addGroup(x,Qe,B),x+=Qe,y+=De}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new fl(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function rd(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const r=i[t][n];r&&(r.isColor||r.isMatrix3||r.isMatrix4||r.isVector2||r.isVector3||r.isVector4||r.isTexture||r.isQuaternion)?r.isRenderTargetTexture?(Ie("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=r.clone():Array.isArray(r)?e[t][n]=r.slice():e[t][n]=r}}return e}function fs(i){const e={};for(let t=0;t<i.length;t++){const n=rd(i[t]);for(const r in n)e[r]=n[r]}return e}function D_(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function Jg(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:xn.workingColorSpace}const Io={clone:rd,merge:fs};var od=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,ad=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`;class lo extends Ds{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=od,this.fragmentShader=ad,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,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=rd(e.uniforms),this.uniformsGroups=D_(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const r in this.uniforms){const a=this.uniforms[r].value;a&&a.isTexture?t.uniforms[r]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[r]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[r]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[r]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[r]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[r]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[r]={type:"m4",value:a.toArray()}:t.uniforms[r]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const r in this.extensions)this.extensions[r]===!0&&(n[r]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}}class ld extends Zi{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Qt,this.projectionMatrix=new Qt,this.projectionMatrixInverse=new Qt,this.coordinateSystem=ws,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const _u=new H,xu=new ze,F_=new ze;class Bs extends ld{constructor(e=50,t=1,n=.1,r=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=r,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=ou*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(ru*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return ou*2*Math.atan(Math.tan(ru*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){_u.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(_u.x,_u.y).multiplyScalar(-e/_u.z),_u.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(_u.x,_u.y).multiplyScalar(-e/_u.z)}getViewSize(e,t){return this.getViewBounds(e,xu,F_),t.subVectors(F_,xu)}setViewOffset(e,t,n,r,o,a){this.aspect=e/t,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=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=o,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(ru*.5*this.fov)/this.zoom,n=2*t,r=this.aspect*n,o=-.5*r;const a=this.view;if(this.view!==null&&this.view.enabled){const u=a.fullWidth,d=a.fullHeight;o+=a.offsetX*r/u,t-=a.offsetY*n/d,r*=a.width/u,n*=a.height/d}const c=this.filmOffset;c!==0&&(o+=e*c/this.getFilmWidth()),this.projectionMatrix.makePerspective(o,o+r,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}const ec=-90,tc=1;class B_ extends Zi{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new Bs(ec,tc,e,t);r.layers=this.layers,this.add(r);const o=new Bs(ec,tc,e,t);o.layers=this.layers,this.add(o);const a=new Bs(ec,tc,e,t);a.layers=this.layers,this.add(a);const c=new Bs(ec,tc,e,t);c.layers=this.layers,this.add(c);const u=new Bs(ec,tc,e,t);u.layers=this.layers,this.add(u);const d=new Bs(ec,tc,e,t);d.layers=this.layers,this.add(d)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,r,o,a,c,u]=t;for(const d of t)this.remove(d);if(e===ws)n.up.set(0,1,0),n.lookAt(1,0,0),r.up.set(0,1,0),r.lookAt(-1,0,0),o.up.set(0,0,-1),o.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),c.up.set(0,1,0),c.lookAt(0,0,1),u.up.set(0,1,0),u.lookAt(0,0,-1);else if(e===xr)n.up.set(0,-1,0),n.lookAt(-1,0,0),r.up.set(0,-1,0),r.lookAt(1,0,0),o.up.set(0,0,1),o.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),c.up.set(0,-1,0),c.lookAt(0,0,1),u.up.set(0,-1,0),u.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const d of t)this.add(d),d.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:r}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[o,a,c,u,d,p]=this.children,m=e.getRenderTarget(),y=e.getActiveCubeFace(),x=e.getActiveMipmapLevel(),v=e.xr.enabled;e.xr.enabled=!1;const w=n.texture.generateMipmaps;n.texture.generateMipmaps=!1,e.setRenderTarget(n,0,r),e.render(t,o),e.setRenderTarget(n,1,r),e.render(t,a),e.setRenderTarget(n,2,r),e.render(t,c),e.setRenderTarget(n,3,r),e.render(t,u),e.setRenderTarget(n,4,r),e.render(t,d),n.texture.generateMipmaps=w,e.setRenderTarget(n,5,r),e.render(t,p),e.setRenderTarget(m,y,x),e.xr.enabled=v,n.texture.needsPMREMUpdate=!0}}class nc extends fi{constructor(e=[],t=Cr,n,r,o,a,c,u,d,p){super(e,t,n,r,o,a,c,u,d,p),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class cr extends qr{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const n={width:e,height:e,depth:1},r=[n,n,n,n,n,n];this.texture=new nc(r),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const n={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 );
}
`},r=new fl(5,5,5),o=new lo({name:"CubemapFromEquirect",uniforms:rd(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:we,blending:ve});o.uniforms.tEquirect.value=t;const a=new Ji(r,o),c=t.minFilter;return t.minFilter===Vs&&(t.minFilter=Yn),new B_(1,10,this).update(e,a),t.minFilter=c,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,n=!0,r=!0){const o=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,n,r);e.setRenderTarget(o)}}class Lo extends Zi{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Qg={type:"move"};class pl{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Lo,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 Lo,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new H,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new H),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Lo,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new H,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new H),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let r=null,o=null,a=null;const c=this._targetRay,u=this._grip,d=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(d&&e.hand){a=!0;for(const w of e.hand.values()){const M=t.getJointPose(w,n),S=this._getHandJoint(d,w);M!==null&&(S.matrix.fromArray(M.transform.matrix),S.matrix.decompose(S.position,S.rotation,S.scale),S.matrixWorldNeedsUpdate=!0,S.jointRadius=M.radius),S.visible=M!==null}const p=d.joints["index-finger-tip"],m=d.joints["thumb-tip"],y=p.position.distanceTo(m.position),x=.02,v=.005;d.inputState.pinching&&y>x+v?(d.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!d.inputState.pinching&&y<=x-v&&(d.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else u!==null&&e.gripSpace&&(o=t.getPose(e.gripSpace,n),o!==null&&(u.matrix.fromArray(o.transform.matrix),u.matrix.decompose(u.position,u.rotation,u.scale),u.matrixWorldNeedsUpdate=!0,o.linearVelocity?(u.hasLinearVelocity=!0,u.linearVelocity.copy(o.linearVelocity)):u.hasLinearVelocity=!1,o.angularVelocity?(u.hasAngularVelocity=!0,u.angularVelocity.copy(o.angularVelocity)):u.hasAngularVelocity=!1));c!==null&&(r=t.getPose(e.targetRaySpace,n),r===null&&o!==null&&(r=o),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1,this.dispatchEvent(Qg)))}return c!==null&&(c.visible=r!==null),u!==null&&(u.visible=o!==null),d!==null&&(d.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new Lo;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class vu{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new It(e),this.density=t}clone(){return new vu(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class ic{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new It(e),this.near=t,this.far=n}clone(){return new ic(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Oa extends Zi{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 jr,this.environmentIntensity=1,this.environmentRotation=new jr,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}class ml{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=jh,this.updateRanges=[],this.version=0,this.uuid=so()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let r=0,o=this.stride;r<o;r++)this.array[e+r]=t.array[n+r];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=so()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=so()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.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 qs=new H;class sc{constructor(e,t,n,r=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=r}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)qs.fromBufferAttribute(this,t),qs.applyMatrix4(e),this.setXYZ(t,qs.x,qs.y,qs.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)qs.fromBufferAttribute(this,t),qs.applyNormalMatrix(e),this.setXYZ(t,qs.x,qs.y,qs.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)qs.fromBufferAttribute(this,t),qs.transformDirection(e),this.setXYZ(t,qs.x,qs.y,qs.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=ts(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Jn(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=Jn(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Jn(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Jn(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Jn(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=ts(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=ts(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=ts(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=ts(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Jn(t,this.array),n=Jn(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=Jn(t,this.array),n=Jn(n,this.array),r=Jn(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this}setXYZW(e,t,n,r,o){return e=e*this.data.stride+this.offset,this.normalized&&(t=Jn(t,this.array),n=Jn(n,this.array),r=Jn(r,this.array),o=Jn(o,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=r,this.data.array[e+3]=o,this}clone(e){if(e===void 0){Ko("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let o=0;o<this.itemSize;o++)t.push(this.data.array[r+o])}return new $i(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new sc(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Ko("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const r=n*this.data.stride+this.offset;for(let o=0;o<this.itemSize;o++)t.push(this.data.array[r+o])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class cd extends Ds{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new It(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let Ua;const rc=new H,bu=new H,oc=new H,Su=new ze,ud=new ze,yf=new Qt,Mu=new H,hd=new H,qp=new H,e0=new ze,Xp=new ze,t0=new ze;class uS extends null{constructor(e=new cd){if(super(),this.isSprite=!0,this.type="Sprite",Ua===void 0){Ua=new Gn;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new ml(t,5);Ua.setIndex([0,1,2,0,2,3]),Ua.setAttribute("position",new sc(n,3,0,!1)),Ua.setAttribute("uv",new sc(n,2,3,!1))}this.geometry=Ua,this.material=e,this.center=new ze(.5,.5),this.count=1}raycast(e,t){e.camera===null&&Be('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),bu.setFromMatrixScale(this.matrixWorld),yf.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),oc.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&bu.multiplyScalar(-oc.z);const n=this.material.rotation;let r,o;n!==0&&(o=Math.cos(n),r=Math.sin(n));const a=this.center;_f(Mu.set(-.5,-.5,0),oc,a,bu,r,o),_f(hd.set(.5,-.5,0),oc,a,bu,r,o),_f(qp.set(.5,.5,0),oc,a,bu,r,o),e0.set(0,0),Xp.set(1,0),t0.set(1,1);let c=e.ray.intersectTriangle(Mu,hd,qp,!1,rc);if(c===null&&(_f(hd.set(-.5,.5,0),oc,a,bu,r,o),Xp.set(0,1),c=e.ray.intersectTriangle(Mu,qp,hd,!1,rc),c===null))return;const u=e.ray.origin.distanceTo(rc);u<e.near||u>e.far||t.push({distance:u,point:rc.clone(),uv:Sr.getInterpolation(rc,Mu,hd,qp,e0,Xp,t0,new ze),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function _f(i,e,t,n,r,o){Su.subVectors(i,t).addScalar(.5).multiply(n),r!==void 0?(ud.x=o*Su.x-r*Su.y,ud.y=r*Su.x+o*Su.y):ud.copy(Su),i.copy(e),i.x+=ud.x,i.y+=ud.y,i.applyMatrix4(yf)}const Tu=new H,jp=new H;class O_ extends null{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(e){super.copy(e,!1);const t=e.levels;for(let n=0,r=t.length;n<r;n++){const o=t[n];this.addLevel(o.object.clone(),o.distance,o.hysteresis)}return this.autoUpdate=e.autoUpdate,this}addLevel(e,t=0,n=0){t=Math.abs(t);const r=this.levels;let o;for(o=0;o<r.length&&!(t<r[o].distance);o++);return r.splice(o,0,{distance:t,hysteresis:n,object:e}),this.add(e),this}removeLevel(e){const t=this.levels;for(let n=0;n<t.length;n++)if(t[n].distance===e){const r=t.splice(n,1);return this.remove(r[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(e){const t=this.levels;if(t.length>0){let n,r;for(n=1,r=t.length;n<r;n++){let o=t[n].distance;if(t[n].object.visible&&(o-=o*t[n].hysteresis),e<o)break}return t[n-1].object}return null}raycast(e,t){if(this.levels.length>0){Tu.setFromMatrixPosition(this.matrixWorld);const r=e.ray.origin.distanceTo(Tu);this.getObjectForDistance(r).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){Tu.setFromMatrixPosition(e.matrixWorld),jp.setFromMatrixPosition(this.matrixWorld);const n=Tu.distanceTo(jp)/e.zoom;t[0].object.visible=!0;let r,o;for(r=1,o=t.length;r<o;r++){let a=t[r].distance;if(t[r].object.visible&&(a-=a*t[r].hysteresis),n>=a)t[r-1].object.visible=!1,t[r].object.visible=!0;else break}for(this._currentLevel=r-1;r<o;r++)t[r].object.visible=!1}}toJSON(e){const t=super.toJSON(e);this.autoUpdate===!1&&(t.object.autoUpdate=!1),t.object.levels=[];const n=this.levels;for(let r=0,o=n.length;r<o;r++){const a=n[r];t.object.levels.push({object:a.object.uuid,distance:a.distance,hysteresis:a.hysteresis})}return t}}const Yp=new H,U_=new gn,n0=new gn,gl=new H,i0=new Qt,Zp=new H,xf=new As,dd=new Qt,ac=new nr;class k_ extends null{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Cg,this.bindMatrix=new Qt,this.bindMatrixInverse=new Qt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new ns),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Zp),this.boundingBox.expandByPoint(Zp)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new As),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,Zp),this.boundingSphere.expandByPoint(Zp)}copy(e,t){return super.copy(e,t),this.bindMode=e.bindMode,this.bindMatrix.copy(e.bindMatrix),this.bindMatrixInverse.copy(e.bindMatrixInverse),this.skeleton=e.skeleton,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}raycast(e,t){const n=this.material,r=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),xf.copy(this.boundingSphere),xf.applyMatrix4(r),e.ray.intersectsSphere(xf)!==!1&&(dd.copy(r).invert(),ac.copy(e.ray).applyMatrix4(dd),!(this.boundingBox!==null&&ac.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,ac)))}getVertexPosition(e,t){return super.getVertexPosition(e,t),this.applyBoneTransform(e,t),t}bind(e,t){this.skeleton=e,t===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),t=this.matrixWorld),this.bindMatrix.copy(t),this.bindMatrixInverse.copy(t).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const e=new gn,t=this.geometry.attributes.skinWeight;for(let n=0,r=t.count;n<r;n++){e.fromBufferAttribute(t,n);const o=1/e.manhattanLength();o!==1/0?e.multiplyScalar(o):e.set(1,0,0,0),t.setXYZW(n,e.x,e.y,e.z,e.w)}}updateMatrixWorld(e){super.updateMatrixWorld(e),this.bindMode===Cg?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Xb?this.bindMatrixInverse.copy(this.bindMatrix).invert():Ie("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,r=this.geometry;U_.fromBufferAttribute(r.attributes.skinIndex,e),n0.fromBufferAttribute(r.attributes.skinWeight,e),Yp.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let o=0;o<4;o++){const a=n0.getComponent(o);if(a!==0){const c=U_.getComponent(o);i0.multiplyMatrices(n.bones[c].matrixWorld,n.boneInverses[c]),t.addScaledVector(gl.copy(Yp).applyMatrix4(i0),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class vf extends null{constructor(){super(),this.isBone=!0,this.type="Bone"}}class co extends fi{constructor(e=null,t=1,n=1,r,o,a,c,u,d=ni,p=ni,m,y){super(null,a,c,u,d,p,r,o,m,y),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const z_=new Qt,bf=new Qt;class wu{constructor(e=[],t=[]){this.uuid=so(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=null,this.previousBoneMatrices=null,this.boneTexture=null,this.init()}init(){const e=this.bones,t=this.boneInverses;if(this.boneMatrices=new Float32Array(e.length*16),t.length===0)this.calculateInverses();else if(e.length!==t.length){Ie("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,r=this.bones.length;n<r;n++)this.boneInverses.push(new Qt)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new Qt;this.bones[e]&&n.copy(this.bones[e].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&n.matrixWorld.copy(this.boneInverses[e]).invert()}for(let e=0,t=this.bones.length;e<t;e++){const n=this.bones[e];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const e=this.bones,t=this.boneInverses,n=this.boneMatrices,r=this.boneTexture;for(let o=0,a=e.length;o<a;o++){const c=e[o]?e[o].matrixWorld:bf;z_.multiplyMatrices(c,t[o]),z_.toArray(n,o*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new wu(this.bones,this.boneInverses)}computeBoneTexture(){let e=Math.sqrt(this.bones.length*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4);t.set(this.boneMatrices);const n=new co(t,e,e,Ri,Si);return n.needsUpdate=!0,this.boneMatrices=t,this.boneTexture=n,this}getBoneByName(e){for(let t=0,n=this.bones.length;t<n;t++){const r=this.bones[t];if(r.name===e)return r}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(e,t){this.uuid=e.uuid;for(let n=0,r=e.bones.length;n<r;n++){const o=e.bones[n];let a=t[o];a===void 0&&(Ie("Skeleton: No bone found with UUID:",o),a=new vf),this.bones.push(a),this.boneInverses.push(new Qt().fromArray(e.boneInverses[n]))}return this.init(),this}toJSON(){const e={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};e.uuid=this.uuid;const t=this.bones,n=this.boneInverses;for(let r=0,o=t.length;r<o;r++){const a=t[r];e.bones.push(a.uuid);const c=n[r];e.boneInverses.push(c.toArray())}return e}}class oa extends $i{constructor(e,t,n,r=1){super(e,t,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=r}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}toJSON(){const e=super.toJSON();return e.meshPerAttribute=this.meshPerAttribute,e.isInstancedBufferAttribute=!0,e}}const lc=new Qt,V_=new Qt,Kp=null,Au=new ns,Eu=new Qt,Sf=new Ji,cc=new As;class s0 extends null{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new oa(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let r=0;r<n;r++)this.setMatrixAt(r,Eu)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new ns),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,lc),Au.copy(e.boundingBox).applyMatrix4(lc),this.boundingBox.union(Au)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new As),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,lc),cc.copy(e.boundingSphere).applyMatrix4(lc),this.boundingSphere.union(cc)}copy(e,t){return super.copy(e,t),this.instanceMatrix.copy(e.instanceMatrix),e.morphTexture!==null&&(this.morphTexture=e.morphTexture.clone()),e.instanceColor!==null&&(this.instanceColor=e.instanceColor.clone()),this.count=e.count,e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),this}getColorAt(e,t){t.fromArray(this.instanceColor.array,e*3)}getMatrixAt(e,t){t.fromArray(this.instanceMatrix.array,e*16)}getMorphAt(e,t){const n=t.morphTargetInfluences,r=this.morphTexture.source.data.data,o=n.length+1,a=e*o+1;for(let c=0;c<n.length;c++)n[c]=r[a+c]}raycast(e,t){const n=this.matrixWorld,r=this.count;if(Sf.geometry=this.geometry,Sf.material=this.material,Sf.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),cc.copy(this.boundingSphere),cc.applyMatrix4(n),e.ray.intersectsSphere(cc)!==!1))for(let o=0;o<r;o++){this.getMatrixAt(o,lc),V_.multiplyMatrices(n,lc),Sf.matrixWorld=V_,Sf.raycast(e,Kp);for(let a=0,c=Kp.length;a<c;a++){const u=Kp[a];u.instanceId=o,u.object=this,t.push(u)}Kp.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new oa(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),t.toArray(this.instanceColor.array,e*3)}setMatrixAt(e,t){t.toArray(this.instanceMatrix.array,e*16)}setMorphAt(e,t){const n=t.morphTargetInfluences,r=n.length+1;this.morphTexture===null&&(this.morphTexture=new co(new Float32Array(r*this.count),r,this.count,Qc,Si));const o=this.morphTexture.source.data.data;let a=0;for(let d=0;d<n.length;d++)a+=n[d];const c=this.geometry.morphTargetsRelative?1:1-a,u=r*e;o[u]=c,o.set(n,u+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Do=new H,ka=new H,r0=new Nn;class uo{constructor(e=new H(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,r){return this.normal.set(e,t,n),this.constant=r,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const r=Do.subVectors(n,t).cross(ka.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(r,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t){const n=e.delta(Do),r=this.normal.dot(n);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const o=-(e.start.dot(this.normal)+this.constant)/r;return o<0||o>1?null:t.copy(e.start).addScaledVector(n,o)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||r0.getNormalMatrix(e),r=this.coplanarPoint(Do).applyMatrix4(e),o=this.normal.applyMatrix3(n).normalize();return this.constant=-r.dot(o),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Cu=new As,hS=new ze(.5,.5),Jp=new H;class Xs{constructor(e=new uo,t=new uo,n=new uo,r=new uo,o=new uo,a=new uo){this.planes=[e,t,n,r,o,a]}set(e,t,n,r,o,a){const c=this.planes;return c[0].copy(e),c[1].copy(t),c[2].copy(n),c[3].copy(r),c[4].copy(o),c[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=ws,n=!1){const r=this.planes,o=e.elements,a=o[0],c=o[1],u=o[2],d=o[3],p=o[4],m=o[5],y=o[6],x=o[7],v=o[8],w=o[9],M=o[10],S=o[11],C=o[12],N=o[13],I=o[14],U=o[15];if(r[0].setComponents(d-a,x-p,S-v,U-C).normalize(),r[1].setComponents(d+a,x+p,S+v,U+C).normalize(),r[2].setComponents(d+c,x+m,S+w,U+N).normalize(),r[3].setComponents(d-c,x-m,S-w,U-N).normalize(),n)r[4].setComponents(u,y,M,I).normalize(),r[5].setComponents(d-u,x-y,S-M,U-I).normalize();else if(r[4].setComponents(d-u,x-y,S-M,U-I).normalize(),t===ws)r[5].setComponents(d+u,x+y,S+M,U+I).normalize();else if(t===xr)r[5].setComponents(u,y,M,I).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Cu.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Cu.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Cu)}intersectsSprite(e){Cu.center.set(0,0,0);const t=hS.distanceTo(e.center);return Cu.radius=.7071067811865476+t,Cu.applyMatrix4(e.matrixWorld),this.intersectsSphere(Cu)}intersectsSphere(e){const t=this.planes,n=e.center,r=-e.radius;for(let o=0;o<6;o++)if(t[o].distanceToPoint(n)<r)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const r=t[n];if(Jp.x=r.normal.x>0?e.max.x:e.min.x,Jp.y=r.normal.y>0?e.max.y:e.min.y,Jp.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Jp)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}const za=new Qt,aa=new Xs;class Qp{constructor(){this.coordinateSystem=ws}intersectsObject(e,t){if(!t.isArrayCamera||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const r=t.cameras[n];if(za.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),aa.setFromProjectionMatrix(za,r.coordinateSystem,r.reversedDepth),aa.intersectsObject(e))return!0}return!1}intersectsSprite(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const r=t.cameras[n];if(za.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),aa.setFromProjectionMatrix(za,r.coordinateSystem,r.reversedDepth),aa.intersectsSprite(e))return!0}return!1}intersectsSphere(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const r=t.cameras[n];if(za.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),aa.setFromProjectionMatrix(za,r.coordinateSystem,r.reversedDepth),aa.intersectsSphere(e))return!0}return!1}intersectsBox(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const r=t.cameras[n];if(za.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),aa.setFromProjectionMatrix(za,r.coordinateSystem,r.reversedDepth),aa.intersectsBox(e))return!0}return!1}containsPoint(e,t){if(!t||!t.cameras||t.cameras.length===0)return!1;for(let n=0;n<t.cameras.length;n++){const r=t.cameras[n];if(za.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),aa.setFromProjectionMatrix(za,r.coordinateSystem,r.reversedDepth),aa.containsPoint(e))return!0}return!1}clone(){return new Qp}}function fd(i,e){return i-e}function Ru(i,e){return i.z-e.z}function Mf(i,e){return e.z-i.z}class G_{constructor(){this.index=0,this.pool=[],this.list=[]}push(e,t,n,r){const o=this.pool,a=this.list;this.index>=o.length&&o.push({start:-1,count:-1,z:-1,index:-1});const c=o[this.index];a.push(c),this.index++,c.start=e,c.count=t,c.z=n,c.index=r}reset(){this.list.length=0,this.index=0}}const Yr=new Qt,o0=new It(1,1,1),ur=new Xs,em=new Qp,tm=new ns,ho=new As,Tf=new H,Zr=new H,nm=new H,pd=new G_,hr=new Ji,uc=null;function im(i,e,t=0){const n=e.itemSize;if(i.isInterleavedBufferAttribute||i.array.constructor!==e.array.constructor){const r=i.count;for(let o=0;o<r;o++)for(let a=0;a<n;a++)e.setComponent(o+t,a,i.getComponent(o,a))}else e.array.set(i.array,t*n);e.needsUpdate=!0}function yl(i,e){if(i.constructor!==e.constructor){const t=Math.min(i.length,e.length);for(let n=0;n<t;n++)e[n]=i[n]}else{const t=Math.min(i.length,e.length);e.set(new i.constructor(i.buffer,0,t))}}class W_ extends null{constructor(e,t,n=t*2,r){super(new Gn,r),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=e,this._maxVertexCount=t,this._maxIndexCount=n,this._multiDrawCounts=new Int32Array(e),this._multiDrawStarts=new Int32Array(e),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 e=Math.sqrt(this._maxInstanceCount*4);e=Math.ceil(e/4)*4,e=Math.max(e,4);const t=new Float32Array(e*e*4),n=new co(t,e,e,Ri,Si);this._matricesTexture=n}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),n=new co(t,e,e,Bl,yi);this._indirectTexture=n}_initColorsTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Float32Array(e*e*4).fill(1),n=new co(t,e,e,Ri,Si);n.colorSpace=xn.workingColorSpace,this._colorsTexture=n}_initializeGeometry(e){const t=this.geometry,n=this._maxVertexCount,r=this._maxIndexCount;if(this._geometryInitialized===!1){for(const o in e.attributes){const a=e.getAttribute(o),{array:c,itemSize:u,normalized:d}=a,p=new c.constructor(n*u),m=new $i(p,u,d);t.setAttribute(o,m)}if(e.getIndex()!==null){const o=n>65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new $i(o,1))}this._geometryInitialized=!0}}_validateGeometry(e){const t=this.geometry;if(!!e.getIndex()!=!!t.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const n in t.attributes){if(!e.hasAttribute(n))throw new Error(`THREE.BatchedMesh: Added geometry missing "${n}". All geometries must have consistent attributes.`);const r=e.getAttribute(n),o=t.getAttribute(n);if(r.itemSize!==o.itemSize||r.normalized!==o.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(e){const t=this._instanceInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${e}. Instance is either out of range or has been deleted.`)}validateGeometryId(e){const t=this._geometryInfo;if(e<0||e>=t.length||t[e].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${e}. Geometry is either out of range or has been deleted.`)}setCustomSort(e){return this.customSort=e,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ns);const e=this.boundingBox,t=this._instanceInfo;e.makeEmpty();for(let n=0,r=t.length;n<r;n++){if(t[n].active===!1)continue;const o=t[n].geometryIndex;this.getMatrixAt(n,Yr),this.getBoundingBoxAt(o,tm).applyMatrix4(Yr),e.union(tm)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new As);const e=this.boundingSphere,t=this._instanceInfo;e.makeEmpty();for(let n=0,r=t.length;n<r;n++){if(t[n].active===!1)continue;const o=t[n].geometryIndex;this.getMatrixAt(n,Yr),this.getBoundingSphereAt(o,ho).applyMatrix4(Yr),e.union(ho)}}addInstance(e){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const n={visible:!0,active:!0,geometryIndex:e};let r=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(fd),r=this._availableInstanceIds.shift(),this._instanceInfo[r]=n):(r=this._instanceInfo.length,this._instanceInfo.push(n));const o=this._matricesTexture;Yr.identity().toArray(o.image.data,r*16),o.needsUpdate=!0;const a=this._colorsTexture;return a&&(o0.toArray(a.image.data,r*4),a.needsUpdate=!0),this._visibilityChanged=!0,r}addGeometry(e,t=-1,n=-1){this._initializeGeometry(e),this._validateGeometry(e);const r={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},o=this._geometryInfo;r.vertexStart=this._nextVertexStart,r.reservedVertexCount=t===-1?e.getAttribute("position").count:t;const a=e.getIndex();if(a!==null&&(r.indexStart=this._nextIndexStart,r.reservedIndexCount=n===-1?a.count:n),r.indexStart!==-1&&r.indexStart+r.reservedIndexCount>this._maxIndexCount||r.vertexStart+r.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let u;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(fd),u=this._availableGeometryIds.shift(),o[u]=r):(u=this._geometryCount,this._geometryCount++,o.push(r)),this.setGeometryAt(u,e),this._nextIndexStart=r.indexStart+r.reservedIndexCount,this._nextVertexStart=r.vertexStart+r.reservedVertexCount,u}setGeometryAt(e,t){if(e>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(t);const n=this.geometry,r=n.getIndex()!==null,o=n.getIndex(),a=t.getIndex(),c=this._geometryInfo[e];if(r&&a.count>c.reservedIndexCount||t.attributes.position.count>c.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const u=c.vertexStart,d=c.reservedVertexCount;c.vertexCount=t.getAttribute("position").count;for(const p in n.attributes){const m=t.getAttribute(p),y=n.getAttribute(p);im(m,y,u);const x=m.itemSize;for(let v=m.count,w=d;v<w;v++){const M=u+v;for(let S=0;S<x;S++)y.setComponent(M,S,0)}y.needsUpdate=!0,y.addUpdateRange(u*x,d*x)}if(r){const p=c.indexStart,m=c.reservedIndexCount;c.indexCount=t.getIndex().count;for(let y=0;y<a.count;y++)o.setX(p+y,u+a.getX(y));for(let y=a.count,x=m;y<x;y++)o.setX(p+y,u);o.needsUpdate=!0,o.addUpdateRange(p,c.reservedIndexCount)}return c.start=r?c.indexStart:c.vertexStart,c.count=r?c.indexCount:c.vertexCount,c.boundingBox=null,t.boundingBox!==null&&(c.boundingBox=t.boundingBox.clone()),c.boundingSphere=null,t.boundingSphere!==null&&(c.boundingSphere=t.boundingSphere.clone()),this._visibilityChanged=!0,e}deleteGeometry(e){const t=this._geometryInfo;if(e>=t.length||t[e].active===!1)return this;const n=this._instanceInfo;for(let r=0,o=n.length;r<o;r++)n[r].active&&n[r].geometryIndex===e&&this.deleteInstance(r);return t[e].active=!1,this._availableGeometryIds.push(e),this._visibilityChanged=!0,this}deleteInstance(e){return this.validateInstanceId(e),this._instanceInfo[e].active=!1,this._availableInstanceIds.push(e),this._visibilityChanged=!0,this}optimize(){let e=0,t=0;const n=this._geometryInfo,r=n.map((a,c)=>c).sort((a,c)=>n[a].vertexStart-n[c].vertexStart),o=this.geometry;for(let a=0,c=n.length;a<c;a++){const u=r[a],d=n[u];if(d.active!==!1){if(o.index!==null){if(d.indexStart!==t){const{indexStart:p,vertexStart:m,reservedIndexCount:y}=d,x=o.index,v=x.array,w=e-m;for(let M=p;M<p+y;M++)v[M]=v[M]+w;x.array.copyWithin(t,p,p+y),x.addUpdateRange(t,y),x.needsUpdate=!0,d.indexStart=t}t+=d.reservedIndexCount}if(d.vertexStart!==e){const{vertexStart:p,reservedVertexCount:m}=d,y=o.attributes;for(const x in y){const v=y[x],{array:w,itemSize:M}=v;w.copyWithin(e*M,p*M,(p+m)*M),v.addUpdateRange(e*M,m*M),v.needsUpdate=!0}d.vertexStart=e}e+=d.reservedVertexCount,d.start=o.index?d.indexStart:d.vertexStart,this._nextIndexStart=o.index?d.indexStart+d.reservedIndexCount:0,this._nextVertexStart=d.vertexStart+d.reservedVertexCount}}return this._visibilityChanged=!0,this}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const n=this.geometry,r=this._geometryInfo[e];if(r.boundingBox===null){const o=new ns,a=n.index,c=n.attributes.position;for(let u=r.start,d=r.start+r.count;u<d;u++){let p=u;a&&(p=a.getX(p)),o.expandByPoint(Tf.fromBufferAttribute(c,p))}r.boundingBox=o}return t.copy(r.boundingBox),t}getBoundingSphereAt(e,t){if(e>=this._geometryCount)return null;const n=this.geometry,r=this._geometryInfo[e];if(r.boundingSphere===null){const o=new As;this.getBoundingBoxAt(e,tm),tm.getCenter(o.center);const a=n.index,c=n.attributes.position;let u=0;for(let d=r.start,p=r.start+r.count;d<p;d++){let m=d;a&&(m=a.getX(m)),Tf.fromBufferAttribute(c,m),u=Math.max(u,o.center.distanceToSquared(Tf))}o.radius=Math.sqrt(u),r.boundingSphere=o}return t.copy(r.boundingSphere),t}setMatrixAt(e,t){this.validateInstanceId(e);const n=this._matricesTexture,r=this._matricesTexture.image.data;return t.toArray(r,e*16),n.needsUpdate=!0,this}getMatrixAt(e,t){return this.validateInstanceId(e),t.fromArray(this._matricesTexture.image.data,e*16)}setColorAt(e,t){return this.validateInstanceId(e),this._colorsTexture===null&&this._initColorsTexture(),t.toArray(this._colorsTexture.image.data,e*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(e,t){return this.validateInstanceId(e),t.fromArray(this._colorsTexture.image.data,e*4)}setVisibleAt(e,t){return this.validateInstanceId(e),this._instanceInfo[e].visible===t?this:(this._instanceInfo[e].visible=t,this._visibilityChanged=!0,this)}getVisibleAt(e){return this.validateInstanceId(e),this._instanceInfo[e].visible}setGeometryIdAt(e,t){return this.validateInstanceId(e),this.validateGeometryId(t),this._instanceInfo[e].geometryIndex=t,this}getGeometryIdAt(e){return this.validateInstanceId(e),this._instanceInfo[e].geometryIndex}getGeometryRangeAt(e,t={}){this.validateGeometryId(e);const n=this._geometryInfo[e];return t.vertexStart=n.vertexStart,t.vertexCount=n.vertexCount,t.reservedVertexCount=n.reservedVertexCount,t.indexStart=n.indexStart,t.indexCount=n.indexCount,t.reservedIndexCount=n.reservedIndexCount,t.start=n.start,t.count=n.count,t}setInstanceCount(e){const t=this._availableInstanceIds,n=this._instanceInfo;for(t.sort(fd);t[t.length-1]===n.length-1;)n.pop(),t.pop();if(e<n.length)throw new Error(`BatchedMesh: Instance ids outside the range ${e} are being used. Cannot shrink instance count.`);const r=new Int32Array(e),o=new Int32Array(e);yl(this._multiDrawCounts,r),yl(this._multiDrawStarts,o),this._multiDrawCounts=r,this._multiDrawStarts=o,this._maxInstanceCount=e;const a=this._indirectTexture,c=this._matricesTexture,u=this._colorsTexture;a.dispose(),this._initIndirectTexture(),yl(a.image.data,this._indirectTexture.image.data),c.dispose(),this._initMatricesTexture(),yl(c.image.data,this._matricesTexture.image.data),u&&(u.dispose(),this._initColorsTexture(),yl(u.image.data,this._colorsTexture.image.data))}setGeometrySize(e,t){const n=[...this._geometryInfo].filter(c=>c.active);if(Math.max(...n.map(c=>c.vertexStart+c.reservedVertexCount))>e)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${t}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...n.map(u=>u.indexStart+u.reservedIndexCount))>t)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${t}. Cannot shrink further.`);const o=this.geometry;o.dispose(),this._maxVertexCount=e,this._maxIndexCount=t,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new Gn,this._initializeGeometry(o));const a=this.geometry;o.index&&yl(o.index.array,a.index.array);for(const c in o.attributes)yl(o.attributes[c].array,a.attributes[c].array)}raycast(e,t){const n=this._instanceInfo,r=this._geometryInfo,o=this.matrixWorld,a=this.geometry;hr.material=this.material,hr.geometry.index=a.index,hr.geometry.attributes=a.attributes,hr.geometry.boundingBox===null&&(hr.geometry.boundingBox=new ns),hr.geometry.boundingSphere===null&&(hr.geometry.boundingSphere=new As);for(let c=0,u=n.length;c<u;c++){if(!n[c].visible||!n[c].active)continue;const d=n[c].geometryIndex,p=r[d];hr.geometry.setDrawRange(p.start,p.count),this.getMatrixAt(c,hr.matrixWorld).premultiply(o),this.getBoundingBoxAt(d,hr.geometry.boundingBox),this.getBoundingSphereAt(d,hr.geometry.boundingSphere),hr.raycast(e,uc);for(let m=0,y=uc.length;m<y;m++){const x=uc[m];x.object=this,x.batchId=c,t.push(x)}uc.length=0}hr.material=null,hr.geometry.index=null,hr.geometry.attributes={},hr.geometry.setDrawRange(0,1/0)}copy(e){return super.copy(e),this.geometry=e.geometry.clone(),this.perObjectFrustumCulled=e.perObjectFrustumCulled,this.sortObjects=e.sortObjects,this.boundingBox=e.boundingBox!==null?e.boundingBox.clone():null,this.boundingSphere=e.boundingSphere!==null?e.boundingSphere.clone():null,this._geometryInfo=e._geometryInfo.map(t=>Mo(wi({},t),{boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>wi({},t)),this._availableInstanceIds=e._availableInstanceIds.slice(),this._availableGeometryIds=e._availableGeometryIds.slice(),this._nextIndexStart=e._nextIndexStart,this._nextVertexStart=e._nextVertexStart,this._geometryCount=e._geometryCount,this._maxInstanceCount=e._maxInstanceCount,this._maxVertexCount=e._maxVertexCount,this._maxIndexCount=e._maxIndexCount,this._geometryInitialized=e._geometryInitialized,this._multiDrawCounts=e._multiDrawCounts.slice(),this._multiDrawStarts=e._multiDrawStarts.slice(),this._indirectTexture=e._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=e._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=e._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(e,t,n,r,o){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const a=r.getIndex(),c=a===null?1:a.array.BYTES_PER_ELEMENT,u=this._instanceInfo,d=this._multiDrawStarts,p=this._multiDrawCounts,m=this._geometryInfo,y=this.perObjectFrustumCulled,x=this._indirectTexture,v=x.image.data,w=n.isArrayCamera?em:ur;y&&!n.isArrayCamera&&(Yr.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),ur.setFromProjectionMatrix(Yr,n.coordinateSystem,n.reversedDepth));let M=0;if(this.sortObjects){Yr.copy(this.matrixWorld).invert(),Tf.setFromMatrixPosition(n.matrixWorld).applyMatrix4(Yr),Zr.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(Yr);for(let N=0,I=u.length;N<I;N++)if(u[N].visible&&u[N].active){const U=u[N].geometryIndex;this.getMatrixAt(N,Yr),this.getBoundingSphereAt(U,ho).applyMatrix4(Yr);let F=!1;if(y&&(F=!w.intersectsSphere(ho,n)),!F){const k=m[U],G=nm.subVectors(ho.center,Tf).dot(Zr);pd.push(k.start,k.count,G,N)}}const S=pd.list,C=this.customSort;C===null?S.sort(o.transparent?Mf:Ru):C.call(this,S,n);for(let N=0,I=S.length;N<I;N++){const U=S[N];d[M]=U.start*c,p[M]=U.count,v[M]=U.index,M++}pd.reset()}else for(let S=0,C=u.length;S<C;S++)if(u[S].visible&&u[S].active){const N=u[S].geometryIndex;let I=!1;if(y&&(this.getMatrixAt(S,Yr),this.getBoundingSphereAt(N,ho).applyMatrix4(Yr),I=!w.intersectsSphere(ho,n)),!I){const U=m[N];d[M]=U.start*c,p[M]=U.count,v[M]=S,M++}}x.needsUpdate=!0,this._multiDrawCount=M,this._visibilityChanged=!1}onBeforeShadow(e,t,n,r,o,a){this.onBeforeRender(e,null,r,o,a)}}class js extends Ds{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new It(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Nu=new H,wf=new H,a0=new Qt,md=new nr,sm=new As,rm=new H,l0=new H;class Pu extends Zi{constructor(e=new Gn,t=new js){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[0];for(let r=1,o=t.count;r<o;r++)Nu.fromBufferAttribute(t,r-1),wf.fromBufferAttribute(t,r),n[r]=n[r-1],n[r]+=Nu.distanceTo(wf);e.setAttribute("lineDistance",new ht(n,1))}else Ie("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,o=e.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),sm.copy(n.boundingSphere),sm.applyMatrix4(r),sm.radius+=o,e.ray.intersectsSphere(sm)===!1)return;a0.copy(r).invert(),md.copy(e.ray).applyMatrix4(a0);const c=o/((this.scale.x+this.scale.y+this.scale.z)/3),u=c*c,d=this.isLineSegments?2:1,p=n.index,y=n.attributes.position;if(p!==null){const x=Math.max(0,a.start),v=Math.min(p.count,a.start+a.count);for(let w=x,M=v-1;w<M;w+=d){const S=p.getX(w),C=p.getX(w+1),N=Iu(this,e,md,u,S,C,w);N&&t.push(N)}if(this.isLineLoop){const w=p.getX(v-1),M=p.getX(x),S=Iu(this,e,md,u,w,M,v-1);S&&t.push(S)}}else{const x=Math.max(0,a.start),v=Math.min(y.count,a.start+a.count);for(let w=x,M=v-1;w<M;w+=d){const S=Iu(this,e,md,u,w,w+1,w);S&&t.push(S)}if(this.isLineLoop){const w=Iu(this,e,md,u,v-1,x,v-1);w&&t.push(w)}}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,a=r.length;o<a;o++){const c=r[o].name||String(o);this.morphTargetInfluences.push(0),this.morphTargetDictionary[c]=o}}}}}function Iu(i,e,t,n,r,o,a){const c=i.geometry.attributes.position;if(Nu.fromBufferAttribute(c,r),wf.fromBufferAttribute(c,o),t.distanceSqToSegment(Nu,wf,rm,l0)>n)return;rm.applyMatrix4(i.matrixWorld);const d=e.ray.origin.distanceTo(rm);if(!(d<e.near||d>e.far))return{distance:d,point:l0.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}const Af=new H,H_=new H;class c0 extends null{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,n=[];for(let r=0,o=t.count;r<o;r+=2)Af.fromBufferAttribute(t,r),H_.fromBufferAttribute(t,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+Af.distanceTo(H_);e.setAttribute("lineDistance",new ht(n,1))}else Ie("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class wA extends null{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class $_ extends Ds{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new It(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const dS=new Qt,u0=new nr,h0=new As,d0=new H;class fS extends null{constructor(e=new Gn,t=new $_){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,r=this.matrixWorld,o=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),h0.copy(n.boundingSphere),h0.applyMatrix4(r),h0.radius+=o,e.ray.intersectsSphere(h0)===!1)return;dS.copy(r).invert(),u0.copy(e.ray).applyMatrix4(dS);const c=o/((this.scale.x+this.scale.y+this.scale.z)/3),u=c*c,d=n.index,m=n.attributes.position;if(d!==null){const y=Math.max(0,a.start),x=Math.min(d.count,a.start+a.count);for(let v=y,w=x;v<w;v++){const M=d.getX(v);d0.fromBufferAttribute(m,M),pS(d0,M,u,r,e,t,this)}}else{const y=Math.max(0,a.start),x=Math.min(m.count,a.start+a.count);for(let v=y,w=x;v<w;v++)d0.fromBufferAttribute(m,v),pS(d0,v,u,r,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const r=t[n[0]];if(r!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let o=0,a=r.length;o<a;o++){const c=r[o].name||String(o);this.morphTargetInfluences.push(0),this.morphTargetDictionary[c]=o}}}}}function pS(i,e,t,n,r,o,a){const c=u0.distanceSqToPoint(i);if(c<t){const u=new H;u0.closestPointToPoint(i,u),u.applyMatrix4(n);const d=r.ray.origin.distanceTo(u);if(d<r.near||d>r.far)return;o.push({distance:d,distanceToRay:Math.sqrt(c),point:u,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class qL extends null{constructor(e,t,n,r,o=Yn,a=Yn,c,u,d){super(e,t,n,r,o,a,c,u,d),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const p=this;function m(){p.needsUpdate=!0,p._requestVideoFrameCallbackId=e.requestVideoFrameCallback(m)}"requestVideoFrameCallback"in e&&(this._requestVideoFrameCallbackId=e.requestVideoFrameCallback(m))}clone(){return new this.constructor(this.image).copy(this)}update(){const e=this.image;"requestVideoFrameCallback"in e===!1&&e.readyState>=e.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class q_ extends null{constructor(e,t,n,r,o,a,c,u){super({},e,t,n,r,o,a,c,u),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(e){this.image=e,this.needsUpdate=!0}}class Ef extends fi{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=ni,this.minFilter=ni,this.generateMipmaps=!1,this.needsUpdate=!0}}class om extends null{constructor(e,t,n,r,o,a,c,u,d,p,m,y){super(null,a,c,u,d,p,r,o,m,y),this.isCompressedTexture=!0,this.image={width:t,height:n},this.mipmaps=e,this.flipY=!1,this.generateMipmaps=!1}}class f0 extends null{constructor(e,t,n,r,o,a){super(e,t,n,o,a),this.isCompressedArrayTexture=!0,this.image.depth=r,this.wrapR=ki,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class gd extends null{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,Cr),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class X_ extends null{constructor(e,t,n,r,o,a,c,u,d){super(e,t,n,r,o,a,c,u,d),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Ys extends fi{constructor(e,t,n=yi,r,o,a,c=ni,u=ni,d,p=tr,m=1){if(p!==tr&&p!==Rr)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const y={width:e,height:t,depth:m};super(y,r,o,a,c,u,p,n,d),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new lu(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class Cf extends Ys{constructor(e,t=yi,n=Cr,r,o,a=ni,c=ni,u,d=tr){const p={width:e,height:e,depth:1},m=[p,p,p,p,p,p];super(e,e,t,n,r,o,a,c,u,d),this.image=m,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class am extends fi{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class yd extends Gn{constructor(e=1,t=1,n=4,r=8,o=1){super(),this.type="CapsuleGeometry",this.parameters={radius:e,height:t,capSegments:n,radialSegments:r,heightSegments:o},t=Math.max(0,t),n=Math.max(1,Math.floor(n)),r=Math.max(3,Math.floor(r)),o=Math.max(1,Math.floor(o));const a=[],c=[],u=[],d=[],p=t/2,m=Math.PI/2*e,y=t,x=2*m+y,v=n*2+o,w=r+1,M=new H,S=new H;for(let C=0;C<=v;C++){let N=0,I=0,U=0,F=0;if(C<=n){const B=C/n,z=B*Math.PI/2;I=-p-e*Math.cos(z),U=e*Math.sin(z),F=-e*Math.cos(z),N=B*m}else if(C<=n+o){const B=(C-n)/o;I=-p+B*t,U=e,F=0,N=m+B*y}else{const B=(C-n-o)/n,z=B*Math.PI/2;I=p+e*Math.sin(z),U=e*Math.cos(z),F=e*Math.sin(z),N=m+y+B*m}const k=Math.max(0,Math.min(1,N/x));let G=0;C===0?G=.5/r:C===v&&(G=-.5/r);for(let B=0;B<=r;B++){const z=B/r,Q=z*Math.PI*2,ye=Math.sin(Q),_e=Math.cos(Q);S.x=-U*_e,S.y=I,S.z=U*ye,c.push(S.x,S.y,S.z),M.set(-U*_e,F,U*ye),M.normalize(),u.push(M.x,M.y,M.z),d.push(z+G,k)}if(C>0){const B=(C-1)*w;for(let z=0;z<r;z++){const Q=B+z,ye=B+z+1,_e=C*w+z,Te=C*w+z+1;a.push(Q,ye,_e),a.push(ye,Te,_e)}}}this.setIndex(a),this.setAttribute("position",new ht(c,3)),this.setAttribute("normal",new ht(u,3)),this.setAttribute("uv",new ht(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new yd(e.radius,e.height,e.capSegments,e.radialSegments,e.heightSegments)}}class p0 extends Gn{constructor(e=1,t=32,n=0,r=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:r},t=Math.max(3,t);const o=[],a=[],c=[],u=[],d=new H,p=new ze;a.push(0,0,0),c.push(0,0,1),u.push(.5,.5);for(let m=0,y=3;m<=t;m++,y+=3){const x=n+m/t*r;d.x=e*Math.cos(x),d.y=e*Math.sin(x),a.push(d.x,d.y,d.z),c.push(0,0,1),p.x=(a[y]/e+1)/2,p.y=(a[y+1]/e+1)/2,u.push(p.x,p.y)}for(let m=1;m<=t;m++)o.push(m,m+1,0);this.setIndex(o),this.setAttribute("position",new ht(a,3)),this.setAttribute("normal",new ht(c,3)),this.setAttribute("uv",new ht(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new p0(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class Ur extends Gn{constructor(e=1,t=1,n=1,r=32,o=1,a=!1,c=0,u=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:r,heightSegments:o,openEnded:a,thetaStart:c,thetaLength:u};const d=this;r=Math.floor(r),o=Math.floor(o);const p=[],m=[],y=[],x=[];let v=0;const w=[],M=n/2;let S=0;C(),a===!1&&(e>0&&N(!0),t>0&&N(!1)),this.setIndex(p),this.setAttribute("position",new ht(m,3)),this.setAttribute("normal",new ht(y,3)),this.setAttribute("uv",new ht(x,2));function C(){const I=new H,U=new H;let F=0;const k=(t-e)/n;for(let G=0;G<=o;G++){const B=[],z=G/o,Q=z*(t-e)+e;for(let ye=0;ye<=r;ye++){const _e=ye/r,Te=_e*u+c,Pe=Math.sin(Te),Ne=Math.cos(Te);U.x=Q*Pe,U.y=-z*n+M,U.z=Q*Ne,m.push(U.x,U.y,U.z),I.set(Pe,k,Ne).normalize(),y.push(I.x,I.y,I.z),x.push(_e,1-z),B.push(v++)}w.push(B)}for(let G=0;G<r;G++)for(let B=0;B<o;B++){const z=w[B][G],Q=w[B+1][G],ye=w[B+1][G+1],_e=w[B][G+1];(e>0||B!==0)&&(p.push(z,Q,_e),F+=3),(t>0||B!==o-1)&&(p.push(Q,ye,_e),F+=3)}d.addGroup(S,F,0),S+=F}function N(I){const U=v,F=new ze,k=new H;let G=0;const B=I===!0?e:t,z=I===!0?1:-1;for(let ye=1;ye<=r;ye++)m.push(0,M*z,0),y.push(0,z,0),x.push(.5,.5),v++;const Q=v;for(let ye=0;ye<=r;ye++){const Te=ye/r*u+c,Pe=Math.cos(Te),Ne=Math.sin(Te);k.x=B*Ne,k.y=M*z,k.z=B*Pe,m.push(k.x,k.y,k.z),y.push(0,z,0),F.x=Pe*.5+.5,F.y=Ne*.5*z+.5,x.push(F.x,F.y),v++}for(let ye=0;ye<r;ye++){const _e=U+ye,Te=Q+ye;I===!0?p.push(Te,Te+1,_e):p.push(Te+1,Te,_e),G+=3}d.addGroup(S,G,I===!0?1:2),S+=G}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ur(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Lu extends Ur{constructor(e=1,t=1,n=32,r=1,o=!1,a=0,c=Math.PI*2){super(0,e,t,n,r,o,a,c),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:r,openEnded:o,thetaStart:a,thetaLength:c}}static fromJSON(e){return new Lu(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Du extends Gn{constructor(e=[],t=[],n=1,r=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:e,indices:t,radius:n,detail:r};const o=[],a=[];c(r),d(n),p(),this.setAttribute("position",new ht(o,3)),this.setAttribute("normal",new ht(o.slice(),3)),this.setAttribute("uv",new ht(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function c(C){const N=new H,I=new H,U=new H;for(let F=0;F<t.length;F+=3)x(t[F+0],N),x(t[F+1],I),x(t[F+2],U),u(N,I,U,C)}function u(C,N,I,U){const F=U+1,k=[];for(let G=0;G<=F;G++){k[G]=[];const B=C.clone().lerp(I,G/F),z=N.clone().lerp(I,G/F),Q=F-G;for(let ye=0;ye<=Q;ye++)ye===0&&G===F?k[G][ye]=B:k[G][ye]=B.clone().lerp(z,ye/Q)}for(let G=0;G<F;G++)for(let B=0;B<2*(F-G)-1;B++){const z=Math.floor(B/2);B%2===0?(y(k[G][z+1]),y(k[G+1][z]),y(k[G][z])):(y(k[G][z+1]),y(k[G+1][z+1]),y(k[G+1][z]))}}function d(C){const N=new H;for(let I=0;I<o.length;I+=3)N.x=o[I+0],N.y=o[I+1],N.z=o[I+2],N.normalize().multiplyScalar(C),o[I+0]=N.x,o[I+1]=N.y,o[I+2]=N.z}function p(){const C=new H;for(let N=0;N<o.length;N+=3){C.x=o[N+0],C.y=o[N+1],C.z=o[N+2];const I=M(C)/2/Math.PI+.5,U=S(C)/Math.PI+.5;a.push(I,1-U)}v(),m()}function m(){for(let C=0;C<a.length;C+=6){const N=a[C+0],I=a[C+2],U=a[C+4],F=Math.max(N,I,U),k=Math.min(N,I,U);F>.9&&k<.1&&(N<.2&&(a[C+0]+=1),I<.2&&(a[C+2]+=1),U<.2&&(a[C+4]+=1))}}function y(C){o.push(C.x,C.y,C.z)}function x(C,N){const I=C*3;N.x=e[I+0],N.y=e[I+1],N.z=e[I+2]}function v(){const C=new H,N=new H,I=new H,U=new H,F=new ze,k=new ze,G=new ze;for(let B=0,z=0;B<o.length;B+=9,z+=6){C.set(o[B+0],o[B+1],o[B+2]),N.set(o[B+3],o[B+4],o[B+5]),I.set(o[B+6],o[B+7],o[B+8]),F.set(a[z+0],a[z+1]),k.set(a[z+2],a[z+3]),G.set(a[z+4],a[z+5]),U.copy(C).add(N).add(I).divideScalar(3);const Q=M(U);w(F,z+0,C,Q),w(k,z+2,N,Q),w(G,z+4,I,Q)}}function w(C,N,I,U){U<0&&C.x===1&&(a[N]=C.x-1),I.x===0&&I.z===0&&(a[N]=U/2/Math.PI+.5)}function M(C){return Math.atan2(C.z,-C.x)}function S(C){return Math.atan2(-C.y,Math.sqrt(C.x*C.x+C.z*C.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Du(e.vertices,e.indices,e.radius,e.detail)}}class Rf extends Du{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,r=1/n,o=[-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,-r,-n,0,-r,n,0,r,-n,0,r,n,-r,-n,0,-r,n,0,r,-n,0,r,n,0,-n,0,-r,n,0,-r,-n,0,r,n,0,r],a=[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(o,a,e,t),this.type="DodecahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Rf(e.radius,e.detail)}}const Fu=new H,_d=new H,Nf=new H,xd=new Sr;class mS extends Gn{constructor(e=null,t=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:e,thresholdAngle:t},e!==null){const r=Math.pow(10,4),o=Math.cos(ru*t),a=e.getIndex(),c=e.getAttribute("position"),u=a?a.count:c.count,d=[0,0,0],p=["a","b","c"],m=new Array(3),y={},x=[];for(let v=0;v<u;v+=3){a?(d[0]=a.getX(v),d[1]=a.getX(v+1),d[2]=a.getX(v+2)):(d[0]=v,d[1]=v+1,d[2]=v+2);const{a:w,b:M,c:S}=xd;if(w.fromBufferAttribute(c,d[0]),M.fromBufferAttribute(c,d[1]),S.fromBufferAttribute(c,d[2]),xd.getNormal(Nf),m[0]=`${Math.round(w.x*r)},${Math.round(w.y*r)},${Math.round(w.z*r)}`,m[1]=`${Math.round(M.x*r)},${Math.round(M.y*r)},${Math.round(M.z*r)}`,m[2]=`${Math.round(S.x*r)},${Math.round(S.y*r)},${Math.round(S.z*r)}`,!(m[0]===m[1]||m[1]===m[2]||m[2]===m[0]))for(let C=0;C<3;C++){const N=(C+1)%3,I=m[C],U=m[N],F=xd[p[C]],k=xd[p[N]],G=`${I}_${U}`,B=`${U}_${I}`;B in y&&y[B]?(Nf.dot(y[B].normal)<=o&&(x.push(F.x,F.y,F.z),x.push(k.x,k.y,k.z)),y[B]=null):G in y||(y[G]={index0:d[C],index1:d[N],normal:Nf.clone()})}}for(const v in y)if(y[v]){const{index0:w,index1:M}=y[v];Fu.fromBufferAttribute(c,w),_d.fromBufferAttribute(c,M),x.push(Fu.x,Fu.y,Fu.z),x.push(_d.x,_d.y,_d.z)}this.setAttribute("position",new ht(x,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class la{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){Ie("Curve: .getPoint() not implemented.")}getPointAt(e,t){const n=this.getUtoTmapping(e);return this.getPoint(n,t)}getPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return t}getSpacedPoints(e=5){const t=[];for(let n=0;n<=e;n++)t.push(this.getPointAt(n/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===e+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const t=[];let n,r=this.getPoint(0),o=0;t.push(0);for(let a=1;a<=e;a++)n=this.getPoint(a/e),o+=n.distanceTo(r),t.push(o),r=n;return this.cacheArcLengths=t,t}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(e,t=null){const n=this.getLengths();let r=0;const o=n.length;let a;t?a=t:a=e*n[o-1];let c=0,u=o-1,d;for(;c<=u;)if(r=Math.floor(c+(u-c)/2),d=n[r]-a,d<0)c=r+1;else if(d>0)u=r-1;else{u=r;break}if(r=u,n[r]===a)return r/(o-1);const p=n[r],y=n[r+1]-p,x=(a-p)/y;return(r+x)/(o-1)}getTangent(e,t){let r=e-1e-4,o=e+1e-4;r<0&&(r=0),o>1&&(o=1);const a=this.getPoint(r),c=this.getPoint(o),u=t||(a.isVector2?new ze:new H);return u.copy(c).sub(a).normalize(),u}getTangentAt(e,t){const n=this.getUtoTmapping(e);return this.getTangent(n,t)}computeFrenetFrames(e,t=!1){const n=new H,r=[],o=[],a=[],c=new H,u=new Qt;for(let x=0;x<=e;x++){const v=x/e;r[x]=this.getTangentAt(v,new H)}o[0]=new H,a[0]=new H;let d=Number.MAX_VALUE;const p=Math.abs(r[0].x),m=Math.abs(r[0].y),y=Math.abs(r[0].z);p<=d&&(d=p,n.set(1,0,0)),m<=d&&(d=m,n.set(0,1,0)),y<=d&&n.set(0,0,1),c.crossVectors(r[0],n).normalize(),o[0].crossVectors(r[0],c),a[0].crossVectors(r[0],o[0]);for(let x=1;x<=e;x++){if(o[x]=o[x-1].clone(),a[x]=a[x-1].clone(),c.crossVectors(r[x-1],r[x]),c.length()>Number.EPSILON){c.normalize();const v=Math.acos(Vn(r[x-1].dot(r[x]),-1,1));o[x].applyMatrix4(u.makeRotationAxis(c,v))}a[x].crossVectors(r[x],o[x])}if(t===!0){let x=Math.acos(Vn(o[0].dot(o[e]),-1,1));x/=e,r[0].dot(c.crossVectors(o[0],o[e]))>0&&(x=-x);for(let v=1;v<=e;v++)o[v].applyMatrix4(u.makeRotationAxis(r[v],x*v)),a[v].crossVectors(r[v],o[v])}return{tangents:r,normals:o,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class m0 extends la{constructor(e=0,t=0,n=1,r=1,o=0,a=Math.PI*2,c=!1,u=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=n,this.yRadius=r,this.aStartAngle=o,this.aEndAngle=a,this.aClockwise=c,this.aRotation=u}getPoint(e,t=new ze){const n=t,r=Math.PI*2;let o=this.aEndAngle-this.aStartAngle;const a=Math.abs(o)<Number.EPSILON;for(;o<0;)o+=r;for(;o>r;)o-=r;o<Number.EPSILON&&(a?o=0:o=r),this.aClockwise===!0&&!a&&(o===r?o=-r:o=o-r);const c=this.aStartAngle+e*o;let u=this.aX+this.xRadius*Math.cos(c),d=this.aY+this.yRadius*Math.sin(c);if(this.aRotation!==0){const p=Math.cos(this.aRotation),m=Math.sin(this.aRotation),y=u-this.aX,x=d-this.aY;u=y*p-x*m+this.aX,d=y*m+x*p+this.aY}return n.set(u,d)}copy(e){return super.copy(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}toJSON(){const e=super.toJSON();return e.aX=this.aX,e.aY=this.aY,e.xRadius=this.xRadius,e.yRadius=this.yRadius,e.aStartAngle=this.aStartAngle,e.aEndAngle=this.aEndAngle,e.aClockwise=this.aClockwise,e.aRotation=this.aRotation,e}fromJSON(e){return super.fromJSON(e),this.aX=e.aX,this.aY=e.aY,this.xRadius=e.xRadius,this.yRadius=e.yRadius,this.aStartAngle=e.aStartAngle,this.aEndAngle=e.aEndAngle,this.aClockwise=e.aClockwise,this.aRotation=e.aRotation,this}}class gS extends m0{constructor(e,t,n,r,o,a){super(e,t,n,n,r,o,a),this.isArcCurve=!0,this.type="ArcCurve"}}function g0(){let i=0,e=0,t=0,n=0;function r(o,a,c,u){i=o,e=c,t=-3*o+3*a-2*c-u,n=2*o-2*a+c+u}return{initCatmullRom:function(o,a,c,u,d){r(a,c,d*(c-o),d*(u-a))},initNonuniformCatmullRom:function(o,a,c,u,d,p,m){let y=(a-o)/d-(c-o)/(d+p)+(c-a)/p,x=(c-a)/p-(u-a)/(p+m)+(u-c)/m;y*=p,x*=p,r(a,c,y,x)},calc:function(o){const a=o*o,c=a*o;return i+e*o+t*a+n*c}}}const hc=new H,y0=new g0,_0=new g0,x0=new g0;class yS extends la{constructor(e=[],t=!1,n="centripetal",r=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=e,this.closed=t,this.curveType=n,this.tension=r}getPoint(e,t=new H){const n=t,r=this.points,o=r.length,a=(o-(this.closed?0:1))*e;let c=Math.floor(a),u=a-c;this.closed?c+=c>0?0:(Math.floor(Math.abs(c)/o)+1)*o:u===0&&c===o-1&&(c=o-2,u=1);let d,p;this.closed||c>0?d=r[(c-1)%o]:(hc.subVectors(r[0],r[1]).add(r[0]),d=hc);const m=r[c%o],y=r[(c+1)%o];if(this.closed||c+2<o?p=r[(c+2)%o]:(hc.subVectors(r[o-1],r[o-2]).add(r[o-1]),p=hc),this.curveType==="centripetal"||this.curveType==="chordal"){const x=this.curveType==="chordal"?.5:.25;let v=Math.pow(d.distanceToSquared(m),x),w=Math.pow(m.distanceToSquared(y),x),M=Math.pow(y.distanceToSquared(p),x);w<1e-4&&(w=1),v<1e-4&&(v=w),M<1e-4&&(M=w),y0.initNonuniformCatmullRom(d.x,m.x,y.x,p.x,v,w,M),_0.initNonuniformCatmullRom(d.y,m.y,y.y,p.y,v,w,M),x0.initNonuniformCatmullRom(d.z,m.z,y.z,p.z,v,w,M)}else this.curveType==="catmullrom"&&(y0.initCatmullRom(d.x,m.x,y.x,p.x,this.tension),_0.initCatmullRom(d.y,m.y,y.y,p.y,this.tension),x0.initCatmullRom(d.z,m.z,y.z,p.z,this.tension));return n.set(y0.calc(u),_0.calc(u),x0.calc(u)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(r.clone())}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const r=this.points[t];e.points.push(r.toArray())}return e.closed=this.closed,e.curveType=this.curveType,e.tension=this.tension,e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(new H().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function vd(i,e,t,n,r){const o=(n-e)*.5,a=(r-t)*.5,c=i*i,u=i*c;return(2*t-2*n+o+a)*u+(-3*t+3*n-2*o-a)*c+o*i+t}function j_(i,e){const t=1-i;return t*t*e}function _S(i,e){return 2*(1-i)*i*e}function Y_(i,e){return i*i*e}function Pf(i,e,t,n){return j_(i,e)+_S(i,t)+Y_(i,n)}function Z_(i,e){const t=1-i;return t*t*t*e}function K_(i,e){const t=1-i;return 3*t*t*i*e}function J_(i,e){return 3*(1-i)*i*i*e}function lm(i,e){return i*i*i*e}function If(i,e,t,n,r){return Z_(i,e)+K_(i,t)+J_(i,n)+lm(i,r)}class cm extends la{constructor(e=new ze,t=new ze,n=new ze,r=new ze){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new ze){const n=t,r=this.v0,o=this.v1,a=this.v2,c=this.v3;return n.set(If(e,r.x,o.x,a.x,c.x),If(e,r.y,o.y,a.y,c.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Bu extends la{constructor(e=new H,t=new H,n=new H,r=new H){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new H){const n=t,r=this.v0,o=this.v1,a=this.v2,c=this.v3;return n.set(If(e,r.x,o.x,a.x,c.x),If(e,r.y,o.y,a.y,c.y),If(e,r.z,o.z,a.z,c.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this.v3.copy(e.v3),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e.v3=this.v3.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this.v3.fromArray(e.v3),this}}class Q_ extends la{constructor(e=new ze,t=new ze){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new ze){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new ze){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class ex extends la{constructor(e=new H,t=new H){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new H){const n=t;return e===1?n.copy(this.v2):(n.copy(this.v2).sub(this.v1),n.multiplyScalar(e).add(this.v1)),n}getPointAt(e,t){return this.getPoint(e,t)}getTangent(e,t=new H){return t.subVectors(this.v2,this.v1).normalize()}getTangentAt(e,t){return this.getTangent(e,t)}copy(e){return super.copy(e),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class dc extends la{constructor(e=new ze,t=new ze,n=new ze){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new ze){const n=t,r=this.v0,o=this.v1,a=this.v2;return n.set(Pf(e,r.x,o.x,a.x),Pf(e,r.y,o.y,a.y)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class Ou extends la{constructor(e=new H,t=new H,n=new H){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new H){const n=t,r=this.v0,o=this.v1,a=this.v2;return n.set(Pf(e,r.x,o.x,a.x),Pf(e,r.y,o.y,a.y),Pf(e,r.z,o.z,a.z)),n}copy(e){return super.copy(e),this.v0.copy(e.v0),this.v1.copy(e.v1),this.v2.copy(e.v2),this}toJSON(){const e=super.toJSON();return e.v0=this.v0.toArray(),e.v1=this.v1.toArray(),e.v2=this.v2.toArray(),e}fromJSON(e){return super.fromJSON(e),this.v0.fromArray(e.v0),this.v1.fromArray(e.v1),this.v2.fromArray(e.v2),this}}class tx extends la{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new ze){const n=t,r=this.points,o=(r.length-1)*e,a=Math.floor(o),c=o-a,u=r[a===0?a:a-1],d=r[a],p=r[a>r.length-2?r.length-1:a+1],m=r[a>r.length-3?r.length-1:a+2];return n.set(vd(c,u.x,d.x,p.x,m.x),vd(c,u.y,d.y,p.y,m.y)),n}copy(e){super.copy(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.points=[];for(let t=0,n=this.points.length;t<n;t++){const r=this.points[t];e.points.push(r.toArray())}return e}fromJSON(e){super.fromJSON(e),this.points=[];for(let t=0,n=e.points.length;t<n;t++){const r=e.points[t];this.points.push(new ze().fromArray(r))}return this}}var um=Object.freeze({__proto__:null,ArcCurve:gS,CatmullRomCurve3:yS,CubicBezierCurve:cm,CubicBezierCurve3:Bu,EllipseCurve:m0,LineCurve:Q_,LineCurve3:ex,QuadraticBezierCurve:dc,QuadraticBezierCurve3:Ou,SplineCurve:tx});class xS extends la{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(e){this.curves.push(e)}closePath(){const e=this.curves[0].getPoint(0),t=this.curves[this.curves.length-1].getPoint(1);if(!e.equals(t)){const n=e.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new um[n](t,e))}return this}getPoint(e,t){const n=e*this.getLength(),r=this.getCurveLengths();let o=0;for(;o<r.length;){if(r[o]>=n){const a=r[o]-n,c=this.curves[o],u=c.getLength(),d=u===0?0:1-a/u;return c.getPointAt(d,t)}o++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let n=0,r=this.curves.length;n<r;n++)t+=this.curves[n].getLength(),e.push(t);return this.cacheLengths=e,e}getSpacedPoints(e=40){const t=[];for(let n=0;n<=e;n++)t.push(this.getPoint(n/e));return this.autoClose&&t.push(t[0]),t}getPoints(e=12){const t=[];let n;for(let r=0,o=this.curves;r<o.length;r++){const a=o[r],c=a.isEllipseCurve?e*2:a.isLineCurve||a.isLineCurve3?1:a.isSplineCurve?e*a.points.length:e,u=a.getPoints(c);for(let d=0;d<u.length;d++){const p=u[d];n&&n.equals(p)||(t.push(p),n=p)}}return this.autoClose&&t.length>1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const r=e.curves[t];this.curves.push(r.clone())}return this.autoClose=e.autoClose,this}toJSON(){const e=super.toJSON();e.autoClose=this.autoClose,e.curves=[];for(let t=0,n=this.curves.length;t<n;t++){const r=this.curves[t];e.curves.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.autoClose=e.autoClose,this.curves=[];for(let t=0,n=e.curves.length;t<n;t++){const r=e.curves[t];this.curves.push(new um[r.type]().fromJSON(r))}return this}}class v0 extends xS{constructor(e){super(),this.type="Path",this.currentPoint=new ze,e&&this.setFromPoints(e)}setFromPoints(e){this.moveTo(e[0].x,e[0].y);for(let t=1,n=e.length;t<n;t++)this.lineTo(e[t].x,e[t].y);return this}moveTo(e,t){return this.currentPoint.set(e,t),this}lineTo(e,t){const n=new Q_(this.currentPoint.clone(),new ze(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,r){const o=new dc(this.currentPoint.clone(),new ze(e,t),new ze(n,r));return this.curves.push(o),this.currentPoint.set(n,r),this}bezierCurveTo(e,t,n,r,o,a){const c=new cm(this.currentPoint.clone(),new ze(e,t),new ze(n,r),new ze(o,a));return this.curves.push(c),this.currentPoint.set(o,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new tx(t);return this.curves.push(n),this.currentPoint.copy(e[e.length-1]),this}arc(e,t,n,r,o,a){const c=this.currentPoint.x,u=this.currentPoint.y;return this.absarc(e+c,t+u,n,r,o,a),this}absarc(e,t,n,r,o,a){return this.absellipse(e,t,n,n,r,o,a),this}ellipse(e,t,n,r,o,a,c,u){const d=this.currentPoint.x,p=this.currentPoint.y;return this.absellipse(e+d,t+p,n,r,o,a,c,u),this}absellipse(e,t,n,r,o,a,c,u){const d=new m0(e,t,n,r,o,a,c,u);if(this.curves.length>0){const m=d.getPoint(0);m.equals(this.currentPoint)||this.lineTo(m.x,m.y)}this.curves.push(d);const p=d.getPoint(1);return this.currentPoint.copy(p),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}}class bd extends v0{constructor(e){super(e),this.uuid=so(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let n=0,r=this.holes.length;n<r;n++)t[n]=this.holes[n].getPoints(e);return t}extractPoints(e){return{shape:this.getPoints(e),holes:this.getPointsHoles(e)}}copy(e){super.copy(e),this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const r=e.holes[t];this.holes.push(r.clone())}return this}toJSON(){const e=super.toJSON();e.uuid=this.uuid,e.holes=[];for(let t=0,n=this.holes.length;t<n;t++){const r=this.holes[t];e.holes.push(r.toJSON())}return e}fromJSON(e){super.fromJSON(e),this.uuid=e.uuid,this.holes=[];for(let t=0,n=e.holes.length;t<n;t++){const r=e.holes[t];this.holes.push(new v0().fromJSON(r))}return this}}function vS(i,e,t=2){const n=e&&e.length,r=n?e[0]*t:i.length;let o=nx(i,0,r,t,!0);const a=[];if(!o||o.next===o.prev)return a;let c,u,d;if(n&&(o=ix(i,e,o,t)),i.length>80*t){c=i[0],u=i[1];let p=c,m=u;for(let y=t;y<r;y+=t){const x=i[y],v=i[y+1];x<c&&(c=x),v<u&&(u=v),x>p&&(p=x),v>m&&(m=v)}d=Math.max(p-c,m-u),d=d!==0?32767/d:0}return Lf(o,a,t,c,u,d,0),a}function nx(i,e,t,n,r){let o;if(r===S0(i,e,t,n)>0)for(let a=e;a<t;a+=n)o=ax(a/n|0,i[a],i[a+1],o);else for(let a=t-n;a>=e;a-=n)o=ax(a/n|0,i[a],i[a+1],o);return o&&Va(o,o.next)&&(Bf(o),o=o.next),o}function Uu(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(Va(t,t.next)||is(t.prev,t,t.next)===0)){if(Bf(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function Lf(i,e,t,n,r,o,a){if(!i)return;!a&&o&&sx(i,n,r,o);let c=i;for(;i.prev!==i.next;){const u=i.prev,d=i.next;if(o?SS(i,n,r,o):bS(i)){e.push(u.i,i.i,d.i),Bf(i),i=d.next,c=d.next;continue}if(i=d,i===c){a?a===1?(i=b0(Uu(i),e),Lf(i,e,t,n,r,o,2)):a===2&&MS(i,e,t,n,r,o):Lf(Uu(i),e,t,n,r,o,1);break}}}function bS(i){const e=i.prev,t=i,n=i.next;if(is(e,t,n)>=0)return!1;const r=e.x,o=t.x,a=n.x,c=e.y,u=t.y,d=n.y,p=Math.min(r,o,a),m=Math.min(c,u,d),y=Math.max(r,o,a),x=Math.max(c,u,d);let v=n.next;for(;v!==e;){if(v.x>=p&&v.x<=y&&v.y>=m&&v.y<=x&&Ff(r,c,o,u,a,d,v.x,v.y)&&is(v.prev,v,v.next)>=0)return!1;v=v.next}return!0}function SS(i,e,t,n){const r=i.prev,o=i,a=i.next;if(is(r,o,a)>=0)return!1;const c=r.x,u=o.x,d=a.x,p=r.y,m=o.y,y=a.y,x=Math.min(c,u,d),v=Math.min(p,m,y),w=Math.max(c,u,d),M=Math.max(p,m,y),S=Md(x,v,e,t,n),C=Md(w,M,e,t,n);let N=i.prevZ,I=i.nextZ;for(;N&&N.z>=S&&I&&I.z<=C;){if(N.x>=x&&N.x<=w&&N.y>=v&&N.y<=M&&N!==r&&N!==a&&Ff(c,p,u,m,d,y,N.x,N.y)&&is(N.prev,N,N.next)>=0||(N=N.prevZ,I.x>=x&&I.x<=w&&I.y>=v&&I.y<=M&&I!==r&&I!==a&&Ff(c,p,u,m,d,y,I.x,I.y)&&is(I.prev,I,I.next)>=0))return!1;I=I.nextZ}for(;N&&N.z>=S;){if(N.x>=x&&N.x<=w&&N.y>=v&&N.y<=M&&N!==r&&N!==a&&Ff(c,p,u,m,d,y,N.x,N.y)&&is(N.prev,N,N.next)>=0)return!1;N=N.prevZ}for(;I&&I.z<=C;){if(I.x>=x&&I.x<=w&&I.y>=v&&I.y<=M&&I!==r&&I!==a&&Ff(c,p,u,m,d,y,I.x,I.y)&&is(I.prev,I,I.next)>=0)return!1;I=I.nextZ}return!0}function b0(i,e){let t=i;do{const n=t.prev,r=t.next.next;!Va(n,r)&&dm(n,t,t.next,r)&&wd(n,r)&&wd(r,n)&&(e.push(n.i,t.i,r.i),Bf(t),Bf(t.next),t=i=r),t=t.next}while(t!==i);return Uu(t)}function MS(i,e,t,n,r,o){let a=i;do{let c=a.next.next;for(;c!==a.prev;){if(a.i!==c.i&&rx(a,c)){let u=mm(a,c);a=Uu(a,a.next),u=Uu(u,u.next),Lf(a,e,t,n,r,o,0),Lf(u,e,t,n,r,o,0);return}c=c.next}a=a.next}while(a!==i)}function ix(i,e,t,n){const r=[];for(let o=0,a=e.length;o<a;o++){const c=e[o]*n,u=o<a-1?e[o+1]*n:i.length,d=nx(i,c,u,n,!1);d===d.next&&(d.steiner=!0),r.push(wS(d))}r.sort(Df);for(let o=0;o<r.length;o++)t=TS(r[o],t);return t}function Df(i,e){let t=i.x-e.x;if(t===0&&(t=i.y-e.y,t===0)){const n=(i.next.y-i.y)/(i.next.x-i.x),r=(e.next.y-e.y)/(e.next.x-e.x);t=n-r}return t}function TS(i,e){const t=ls(i,e);if(!t)return e;const n=mm(t,i);return Uu(n,n.next),Uu(t,t.next)}function ls(i,e){let t=e;const n=i.x,r=i.y;let o=-1/0,a;if(Va(i,t))return t;do{if(Va(i,t.next))return t.next;if(r<=t.y&&r>=t.next.y&&t.next.y!==t.y){const m=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(m<=n&&m>o&&(o=m,a=t.x<t.next.x?t:t.next,m===n))return a}t=t.next}while(t!==e);if(!a)return null;const c=a,u=a.x,d=a.y;let p=1/0;t=a;do{if(n>=t.x&&t.x>=u&&n!==t.x&&Td(r<d?n:o,r,u,d,r<d?o:n,r,t.x,t.y)){const m=Math.abs(r-t.y)/(n-t.x);wd(t,i)&&(m<p||m===p&&(t.x>a.x||t.x===a.x&&Sd(a,t)))&&(a=t,p=m)}t=t.next}while(t!==c);return a}function Sd(i,e){return is(i.prev,i,e.prev)<0&&is(e.next,i,i.next)<0}function sx(i,e,t,n){let r=i;do r.z===0&&(r.z=Md(r.x,r.y,e,t,n)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next;while(r!==i);r.prevZ.nextZ=null,r.prevZ=null,hm(r)}function hm(i){let e,t=1;do{let n=i,r;i=null;let o=null;for(e=0;n;){e++;let a=n,c=0;for(let d=0;d<t&&(c++,a=a.nextZ,!!a);d++);let u=t;for(;c>0||u>0&&a;)c!==0&&(u===0||!a||n.z<=a.z)?(r=n,n=n.nextZ,c--):(r=a,a=a.nextZ,u--),o?o.nextZ=r:i=r,r.prevZ=o,o=r;n=a}o.nextZ=null,t*=2}while(e>1);return i}function Md(i,e,t,n,r){return i=(i-t)*r|0,e=(e-n)*r|0,i=(i|i<<8)&16711935,i=(i|i<<4)&252645135,i=(i|i<<2)&858993459,i=(i|i<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,i|e<<1}function wS(i){let e=i,t=i;do(e.x<t.x||e.x===t.x&&e.y<t.y)&&(t=e),e=e.next;while(e!==i);return t}function Td(i,e,t,n,r,o,a,c){return(r-a)*(e-c)>=(i-a)*(o-c)&&(i-a)*(n-c)>=(t-a)*(e-c)&&(t-a)*(o-c)>=(r-a)*(n-c)}function Ff(i,e,t,n,r,o,a,c){return!(i===a&&e===c)&&Td(i,e,t,n,r,o,a,c)}function rx(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!Ga(i,e)&&(wd(i,e)&&wd(e,i)&&ox(i,e)&&(is(i.prev,i,e.prev)||is(i,e.prev,e))||Va(i,e)&&is(i.prev,i,i.next)>0&&is(e.prev,e,e.next)>0)}function is(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function Va(i,e){return i.x===e.x&&i.y===e.y}function dm(i,e,t,n){const r=pm(is(i,e,t)),o=pm(is(i,e,n)),a=pm(is(t,n,i)),c=pm(is(t,n,e));return!!(r!==o&&a!==c||r===0&&fm(i,t,e)||o===0&&fm(i,n,e)||a===0&&fm(t,i,n)||c===0&&fm(t,e,n))}function fm(i,e,t){return e.x<=Math.max(i.x,t.x)&&e.x>=Math.min(i.x,t.x)&&e.y<=Math.max(i.y,t.y)&&e.y>=Math.min(i.y,t.y)}function pm(i){return i>0?1:i<0?-1:0}function Ga(i,e){let t=i;do{if(t.i!==i.i&&t.next.i!==i.i&&t.i!==e.i&&t.next.i!==e.i&&dm(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function wd(i,e){return is(i.prev,i,i.next)<0?is(i,e,i.next)>=0&&is(i,i.prev,e)>=0:is(i,e,i.prev)<0||is(i,i.next,e)<0}function ox(i,e){let t=i,n=!1;const r=(i.x+e.x)/2,o=(i.y+e.y)/2;do t.y>o!=t.next.y>o&&t.next.y!==t.y&&r<(t.next.x-t.x)*(o-t.y)/(t.next.y-t.y)+t.x&&(n=!n),t=t.next;while(t!==i);return n}function mm(i,e){const t=Of(i.i,i.x,i.y),n=Of(e.i,e.x,e.y),r=i.next,o=e.prev;return i.next=e,e.prev=i,t.next=r,r.prev=t,n.next=t,t.prev=n,o.next=n,n.prev=o,n}function ax(i,e,t,n){const r=Of(i,e,t);return n?(r.next=n.next,r.prev=n,n.next.prev=r,n.next=r):(r.prev=r,r.next=r),r}function Bf(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function Of(i,e,t){return{i,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function S0(i,e,t,n){let r=0;for(let o=e,a=t-n;o<t;o+=n)r+=(i[a]-i[o])*(i[o+1]+i[a+1]),a=o;return r}class gm{static triangulate(e,t,n=2){return vS(e,t,n)}}class Fo{static area(e){const t=e.length;let n=0;for(let r=t-1,o=0;o<t;r=o++)n+=e[r].x*e[o].y-e[o].x*e[r].y;return n*.5}static isClockWise(e){return Fo.area(e)<0}static triangulateShape(e,t){const n=[],r=[],o=[];ym(e),_m(n,e);let a=e.length;t.forEach(ym);for(let u=0;u<t.length;u++)r.push(a),a+=t[u].length,_m(n,t[u]);const c=gm.triangulate(n,r);for(let u=0;u<c.length;u+=3)o.push(c.slice(u,u+3));return o}}function ym(i){const e=i.length;e>2&&i[e-1].equals(i[0])&&i.pop()}function _m(i,e){for(let t=0;t<e.length;t++)i.push(e[t].x),i.push(e[t].y)}class M0 extends Gn{constructor(e=new bd([new ze(.5,.5),new ze(-.5,.5),new ze(-.5,-.5),new ze(.5,-.5)]),t={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:e,options:t},e=Array.isArray(e)?e:[e];const n=this,r=[],o=[];for(let c=0,u=e.length;c<u;c++){const d=e[c];a(d)}this.setAttribute("position",new ht(r,3)),this.setAttribute("uv",new ht(o,2)),this.computeVertexNormals();function a(c){const u=[],d=t.curveSegments!==void 0?t.curveSegments:12,p=t.steps!==void 0?t.steps:1,m=t.depth!==void 0?t.depth:1;let y=t.bevelEnabled!==void 0?t.bevelEnabled:!0,x=t.bevelThickness!==void 0?t.bevelThickness:.2,v=t.bevelSize!==void 0?t.bevelSize:x-.1,w=t.bevelOffset!==void 0?t.bevelOffset:0,M=t.bevelSegments!==void 0?t.bevelSegments:3;const S=t.extrudePath,C=t.UVGenerator!==void 0?t.UVGenerator:Uf;let N,I=!1,U,F,k,G;if(S){N=S.getSpacedPoints(p),I=!0,y=!1;const rt=S.isCatmullRomCurve3?S.closed:!1;U=S.computeFrenetFrames(p,rt),F=new H,k=new H,G=new H}y||(M=0,x=0,v=0,w=0);const B=c.extractPoints(d);let z=B.shape;const Q=B.holes;if(!Fo.isClockWise(z)){z=z.reverse();for(let rt=0,yt=Q.length;rt<yt;rt++){const ct=Q[rt];Fo.isClockWise(ct)&&(Q[rt]=ct.reverse())}}function _e(rt){const ct=10000000000000001e-36;let Ft=rt[0];for(let ne=1;ne<=rt.length;ne++){const Ln=ne%rt.length,en=rt[Ln],Hn=en.x-Ft.x,Bt=en.y-Ft.y,ee=Hn*Hn+Bt*Bt,V=Math.max(Math.abs(en.x),Math.abs(en.y),Math.abs(Ft.x),Math.abs(Ft.y)),Se=ct*V*V;if(ee<=Se){rt.splice(Ln,1),ne--;continue}Ft=en}}_e(z),Q.forEach(_e);const Te=Q.length,Pe=z;for(let rt=0;rt<Te;rt++){const yt=Q[rt];z=z.concat(yt)}function Ne(rt,yt,ct){return yt||Be("ExtrudeGeometry: vec does not exist"),rt.clone().addScaledVector(yt,ct)}const De=z.length;function Qe(rt,yt,ct){let Ft,ne,Ln;const en=rt.x-yt.x,Hn=rt.y-yt.y,Bt=ct.x-rt.x,ee=ct.y-rt.y,V=en*en+Hn*Hn,Se=en*ee-Hn*Bt;if(Math.abs(Se)>Number.EPSILON){const je=Math.sqrt(V),dt=Math.sqrt(Bt*Bt+ee*ee),Ze=yt.x-Hn/je,yn=yt.y+en/je,Ot=ct.x-ee/dt,fn=ct.y+Bt/dt,jn=((Ot-Ze)*ee-(fn-yn)*Bt)/(en*ee-Hn*Bt);Ft=Ze+en*jn-rt.x,ne=yn+Hn*jn-rt.y;const bt=Ft*Ft+ne*ne;if(bt<=2)return new ze(Ft,ne);Ln=Math.sqrt(bt/2)}else{let je=!1;en>Number.EPSILON?Bt>Number.EPSILON&&(je=!0):en<-Number.EPSILON?Bt<-Number.EPSILON&&(je=!0):Math.sign(Hn)===Math.sign(ee)&&(je=!0),je?(Ft=-Hn,ne=en,Ln=Math.sqrt(V)):(Ft=en,ne=Hn,Ln=Math.sqrt(V/2))}return new ze(Ft/Ln,ne/Ln)}const Mt=[];for(let rt=0,yt=Pe.length,ct=yt-1,Ft=rt+1;rt<yt;rt++,ct++,Ft++)ct===yt&&(ct=0),Ft===yt&&(Ft=0),Mt[rt]=Qe(Pe[rt],Pe[ct],Pe[Ft]);const Tt=[];let Fe,mt=Mt.concat();for(let rt=0,yt=Te;rt<yt;rt++){const ct=Q[rt];Fe=[];for(let Ft=0,ne=ct.length,Ln=ne-1,en=Ft+1;Ft<ne;Ft++,Ln++,en++)Ln===ne&&(Ln=0),en===ne&&(en=0),Fe[Ft]=Qe(ct[Ft],ct[Ln],ct[en]);Tt.push(Fe),mt=mt.concat(Fe)}let wt;if(M===0)wt=Fo.triangulateShape(Pe,Q);else{const rt=[],yt=[];for(let ct=0;ct<M;ct++){const Ft=ct/M,ne=x*Math.cos(Ft*Math.PI/2),Ln=v*Math.sin(Ft*Math.PI/2)+w;for(let en=0,Hn=Pe.length;en<Hn;en++){const Bt=Ne(Pe[en],Mt[en],Ln);Zt(Bt.x,Bt.y,-ne),Ft===0&&rt.push(Bt)}for(let en=0,Hn=Te;en<Hn;en++){const Bt=Q[en];Fe=Tt[en];const ee=[];for(let V=0,Se=Bt.length;V<Se;V++){const je=Ne(Bt[V],Fe[V],Ln);Zt(je.x,je.y,-ne),Ft===0&&ee.push(je)}Ft===0&&yt.push(ee)}}wt=Fo.triangulateShape(rt,yt)}const In=wt.length,st=v+w;for(let rt=0;rt<De;rt++){const yt=y?Ne(z[rt],mt[rt],st):z[rt];I?(k.copy(U.normals[0]).multiplyScalar(yt.x),F.copy(U.binormals[0]).multiplyScalar(yt.y),G.copy(N[0]).add(k).add(F),Zt(G.x,G.y,G.z)):Zt(yt.x,yt.y,0)}for(let rt=1;rt<=p;rt++)for(let yt=0;yt<De;yt++){const ct=y?Ne(z[yt],mt[yt],st):z[yt];I?(k.copy(U.normals[rt]).multiplyScalar(ct.x),F.copy(U.binormals[rt]).multiplyScalar(ct.y),G.copy(N[rt]).add(k).add(F),Zt(G.x,G.y,G.z)):Zt(ct.x,ct.y,m/p*rt)}for(let rt=M-1;rt>=0;rt--){const yt=rt/M,ct=x*Math.cos(yt*Math.PI/2),Ft=v*Math.sin(yt*Math.PI/2)+w;for(let ne=0,Ln=Pe.length;ne<Ln;ne++){const en=Ne(Pe[ne],Mt[ne],Ft);Zt(en.x,en.y,m+ct)}for(let ne=0,Ln=Q.length;ne<Ln;ne++){const en=Q[ne];Fe=Tt[ne];for(let Hn=0,Bt=en.length;Hn<Bt;Hn++){const ee=Ne(en[Hn],Fe[Hn],Ft);I?Zt(ee.x,ee.y+N[p-1].y,N[p-1].x+ct):Zt(ee.x,ee.y,m+ct)}}}Ee(),Oe();function Ee(){const rt=r.length/3;if(y){let yt=0,ct=De*yt;for(let Ft=0;Ft<In;Ft++){const ne=wt[Ft];Pt(ne[2]+ct,ne[1]+ct,ne[0]+ct)}yt=p+M*2,ct=De*yt;for(let Ft=0;Ft<In;Ft++){const ne=wt[Ft];Pt(ne[0]+ct,ne[1]+ct,ne[2]+ct)}}else{for(let yt=0;yt<In;yt++){const ct=wt[yt];Pt(ct[2],ct[1],ct[0])}for(let yt=0;yt<In;yt++){const ct=wt[yt];Pt(ct[0]+De*p,ct[1]+De*p,ct[2]+De*p)}}n.addGroup(rt,r.length/3-rt,0)}function Oe(){const rt=r.length/3;let yt=0;vt(Pe,yt),yt+=Pe.length;for(let ct=0,Ft=Q.length;ct<Ft;ct++){const ne=Q[ct];vt(ne,yt),yt+=ne.length}n.addGroup(rt,r.length/3-rt,1)}function vt(rt,yt){let ct=rt.length;for(;--ct>=0;){const Ft=ct;let ne=ct-1;ne<0&&(ne=rt.length-1);for(let Ln=0,en=p+M*2;Ln<en;Ln++){const Hn=De*Ln,Bt=De*(Ln+1),ee=yt+Ft+Hn,V=yt+ne+Hn,Se=yt+ne+Bt,je=yt+Ft+Bt;wn(ee,V,Se,je)}}}function Zt(rt,yt,ct){u.push(rt),u.push(yt),u.push(ct)}function Pt(rt,yt,ct){ai(rt),ai(yt),ai(ct);const Ft=r.length/3,ne=C.generateTopUV(n,r,Ft-3,Ft-2,Ft-1);Wn(ne[0]),Wn(ne[1]),Wn(ne[2])}function wn(rt,yt,ct,Ft){ai(rt),ai(yt),ai(Ft),ai(yt),ai(ct),ai(Ft);const ne=r.length/3,Ln=C.generateSideWallUV(n,r,ne-6,ne-3,ne-2,ne-1);Wn(Ln[0]),Wn(Ln[1]),Wn(Ln[3]),Wn(Ln[1]),Wn(Ln[2]),Wn(Ln[3])}function ai(rt){r.push(u[rt*3+0]),r.push(u[rt*3+1]),r.push(u[rt*3+2])}function Wn(rt){o.push(rt.x),o.push(rt.y)}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes,n=this.parameters.options;return T0(t,n,e)}static fromJSON(e,t){const n=[];for(let o=0,a=e.shapes.length;o<a;o++){const c=t[e.shapes[o]];n.push(c)}const r=e.options.extrudePath;return r!==void 0&&(e.options.extrudePath=new um[r.type]().fromJSON(r)),new M0(n,e.options)}}const Uf={generateTopUV:function(i,e,t,n,r){const o=e[t*3],a=e[t*3+1],c=e[n*3],u=e[n*3+1],d=e[r*3],p=e[r*3+1];return[new ze(o,a),new ze(c,u),new ze(d,p)]},generateSideWallUV:function(i,e,t,n,r,o){const a=e[t*3],c=e[t*3+1],u=e[t*3+2],d=e[n*3],p=e[n*3+1],m=e[n*3+2],y=e[r*3],x=e[r*3+1],v=e[r*3+2],w=e[o*3],M=e[o*3+1],S=e[o*3+2];return Math.abs(c-p)<Math.abs(a-d)?[new ze(a,1-u),new ze(d,1-m),new ze(y,1-v),new ze(w,1-S)]:[new ze(c,1-u),new ze(p,1-m),new ze(x,1-v),new ze(M,1-S)]}};function T0(i,e,t){if(t.shapes=[],Array.isArray(i))for(let n=0,r=i.length;n<r;n++){const o=i[n];t.shapes.push(o.uuid)}else t.shapes.push(i.uuid);return t.options=Object.assign({},e),e.extrudePath!==void 0&&(t.options.extrudePath=e.extrudePath.toJSON()),t}class kf extends Du{constructor(e=1,t=0){const n=(1+Math.sqrt(5))/2,r=[-1,n,0,1,n,0,-1,-n,0,1,-n,0,0,-1,n,0,1,n,0,-1,-n,0,1,-n,n,0,-1,n,0,1,-n,0,-1,-n,0,1],o=[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(r,o,e,t),this.type="IcosahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new kf(e.radius,e.detail)}}class zf extends Gn{constructor(e=[new ze(0,-.5),new ze(.5,0),new ze(0,.5)],t=12,n=0,r=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:e,segments:t,phiStart:n,phiLength:r},t=Math.floor(t),r=Vn(r,0,Math.PI*2);const o=[],a=[],c=[],u=[],d=[],p=1/t,m=new H,y=new ze,x=new H,v=new H,w=new H;let M=0,S=0;for(let C=0;C<=e.length-1;C++)switch(C){case 0:M=e[C+1].x-e[C].x,S=e[C+1].y-e[C].y,x.x=S*1,x.y=-M,x.z=S*0,w.copy(x),x.normalize(),u.push(x.x,x.y,x.z);break;case e.length-1:u.push(w.x,w.y,w.z);break;default:M=e[C+1].x-e[C].x,S=e[C+1].y-e[C].y,x.x=S*1,x.y=-M,x.z=S*0,v.copy(x),x.x+=w.x,x.y+=w.y,x.z+=w.z,x.normalize(),u.push(x.x,x.y,x.z),w.copy(v)}for(let C=0;C<=t;C++){const N=n+C*p*r,I=Math.sin(N),U=Math.cos(N);for(let F=0;F<=e.length-1;F++){m.x=e[F].x*I,m.y=e[F].y,m.z=e[F].x*U,a.push(m.x,m.y,m.z),y.x=C/t,y.y=F/(e.length-1),c.push(y.x,y.y);const k=u[3*F+0]*I,G=u[3*F+1],B=u[3*F+0]*U;d.push(k,G,B)}}for(let C=0;C<t;C++)for(let N=0;N<e.length-1;N++){const I=N+C*e.length,U=I,F=I+e.length,k=I+e.length+1,G=I+1;o.push(U,F,G),o.push(k,G,F)}this.setIndex(o),this.setAttribute("position",new ht(a,3)),this.setAttribute("uv",new ht(c,2)),this.setAttribute("normal",new ht(d,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new zf(e.points,e.segments,e.phiStart,e.phiLength)}}class Ad extends Du{constructor(e=1,t=0){const n=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],r=[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(n,r,e,t),this.type="OctahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new Ad(e.radius,e.detail)}}class Ed extends Gn{constructor(e=1,t=1,n=1,r=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:r};const o=e/2,a=t/2,c=Math.floor(n),u=Math.floor(r),d=c+1,p=u+1,m=e/c,y=t/u,x=[],v=[],w=[],M=[];for(let S=0;S<p;S++){const C=S*y-a;for(let N=0;N<d;N++){const I=N*m-o;v.push(I,-C,0),w.push(0,0,1),M.push(N/c),M.push(1-S/u)}}for(let S=0;S<u;S++)for(let C=0;C<c;C++){const N=C+d*S,I=C+d*(S+1),U=C+1+d*(S+1),F=C+1+d*S;x.push(N,I,F),x.push(I,U,F)}this.setIndex(x),this.setAttribute("position",new ht(v,3)),this.setAttribute("normal",new ht(w,3)),this.setAttribute("uv",new ht(M,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ed(e.width,e.height,e.widthSegments,e.heightSegments)}}class xm extends Gn{constructor(e=.5,t=1,n=32,r=1,o=0,a=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:e,outerRadius:t,thetaSegments:n,phiSegments:r,thetaStart:o,thetaLength:a},n=Math.max(3,n),r=Math.max(1,r);const c=[],u=[],d=[],p=[];let m=e;const y=(t-e)/r,x=new H,v=new ze;for(let w=0;w<=r;w++){for(let M=0;M<=n;M++){const S=o+M/n*a;x.x=m*Math.cos(S),x.y=m*Math.sin(S),u.push(x.x,x.y,x.z),d.push(0,0,1),v.x=(x.x/t+1)/2,v.y=(x.y/t+1)/2,p.push(v.x,v.y)}m+=y}for(let w=0;w<r;w++){const M=w*(n+1);for(let S=0;S<n;S++){const C=S+M,N=C,I=C+n+1,U=C+n+2,F=C+1;c.push(N,I,F),c.push(I,U,F)}}this.setIndex(c),this.setAttribute("position",new ht(u,3)),this.setAttribute("normal",new ht(d,3)),this.setAttribute("uv",new ht(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new xm(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class vm extends Gn{constructor(e=new bd([new ze(0,.5),new ze(-.5,-.5),new ze(.5,-.5)]),t=12){super(),this.type="ShapeGeometry",this.parameters={shapes:e,curveSegments:t};const n=[],r=[],o=[],a=[];let c=0,u=0;if(Array.isArray(e)===!1)d(e);else for(let p=0;p<e.length;p++)d(e[p]),this.addGroup(c,u,p),c+=u,u=0;this.setIndex(n),this.setAttribute("position",new ht(r,3)),this.setAttribute("normal",new ht(o,3)),this.setAttribute("uv",new ht(a,2));function d(p){const m=r.length/3,y=p.extractPoints(t);let x=y.shape;const v=y.holes;Fo.isClockWise(x)===!1&&(x=x.reverse());for(let M=0,S=v.length;M<S;M++){const C=v[M];Fo.isClockWise(C)===!0&&(v[M]=C.reverse())}const w=Fo.triangulateShape(x,v);for(let M=0,S=v.length;M<S;M++){const C=v[M];x=x.concat(C)}for(let M=0,S=x.length;M<S;M++){const C=x[M];r.push(C.x,C.y,0),o.push(0,0,1),a.push(C.x,C.y)}for(let M=0,S=w.length;M<S;M++){const C=w[M],N=C[0]+m,I=C[1]+m,U=C[2]+m;n.push(N,I,U),u+=3}}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON(),t=this.parameters.shapes;return AS(t,e)}static fromJSON(e,t){const n=[];for(let r=0,o=e.shapes.length;r<o;r++){const a=t[e.shapes[r]];n.push(a)}return new vm(n,e.curveSegments)}}function AS(i,e){if(e.shapes=[],Array.isArray(i))for(let t=0,n=i.length;t<n;t++){const r=i[t];e.shapes.push(r.uuid)}else e.shapes.push(i.uuid);return e}class ku extends Gn{constructor(e=1,t=32,n=16,r=0,o=Math.PI*2,a=0,c=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:r,phiLength:o,thetaStart:a,thetaLength:c},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const u=Math.min(a+c,Math.PI);let d=0;const p=[],m=new H,y=new H,x=[],v=[],w=[],M=[];for(let S=0;S<=n;S++){const C=[],N=S/n;let I=0;S===0&&a===0?I=.5/t:S===n&&u===Math.PI&&(I=-.5/t);for(let U=0;U<=t;U++){const F=U/t;m.x=-e*Math.cos(r+F*o)*Math.sin(a+N*c),m.y=e*Math.cos(a+N*c),m.z=e*Math.sin(r+F*o)*Math.sin(a+N*c),v.push(m.x,m.y,m.z),y.copy(m).normalize(),w.push(y.x,y.y,y.z),M.push(F+I,1-N),C.push(d++)}p.push(C)}for(let S=0;S<n;S++)for(let C=0;C<t;C++){const N=p[S][C+1],I=p[S][C],U=p[S+1][C],F=p[S+1][C+1];(S!==0||a>0)&&x.push(N,I,F),(S!==n-1||u<Math.PI)&&x.push(I,U,F)}this.setIndex(x),this.setAttribute("position",new ht(v,3)),this.setAttribute("normal",new ht(w,3)),this.setAttribute("uv",new ht(M,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ku(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class w0 extends Du{constructor(e=1,t=0){const n=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],r=[2,1,0,0,3,2,1,3,0,2,3,1];super(n,r,e,t),this.type="TetrahedronGeometry",this.parameters={radius:e,detail:t}}static fromJSON(e){return new w0(e.radius,e.detail)}}class A0 extends Gn{constructor(e=1,t=.4,n=12,r=48,o=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:e,tube:t,radialSegments:n,tubularSegments:r,arc:o},n=Math.floor(n),r=Math.floor(r);const a=[],c=[],u=[],d=[],p=new H,m=new H,y=new H;for(let x=0;x<=n;x++)for(let v=0;v<=r;v++){const w=v/r*o,M=x/n*Math.PI*2;m.x=(e+t*Math.cos(M))*Math.cos(w),m.y=(e+t*Math.cos(M))*Math.sin(w),m.z=t*Math.sin(M),c.push(m.x,m.y,m.z),p.x=e*Math.cos(w),p.y=e*Math.sin(w),y.subVectors(m,p).normalize(),u.push(y.x,y.y,y.z),d.push(v/r),d.push(x/n)}for(let x=1;x<=n;x++)for(let v=1;v<=r;v++){const w=(r+1)*x+v-1,M=(r+1)*(x-1)+v-1,S=(r+1)*(x-1)+v,C=(r+1)*x+v;a.push(w,M,C),a.push(M,S,C)}this.setIndex(a),this.setAttribute("position",new ht(c,3)),this.setAttribute("normal",new ht(u,3)),this.setAttribute("uv",new ht(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new A0(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class bm extends Gn{constructor(e=1,t=.4,n=64,r=8,o=2,a=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:e,tube:t,tubularSegments:n,radialSegments:r,p:o,q:a},n=Math.floor(n),r=Math.floor(r);const c=[],u=[],d=[],p=[],m=new H,y=new H,x=new H,v=new H,w=new H,M=new H,S=new H;for(let N=0;N<=n;++N){const I=N/n*o*Math.PI*2;C(I,o,a,e,x),C(I+.01,o,a,e,v),M.subVectors(v,x),S.addVectors(v,x),w.crossVectors(M,S),S.crossVectors(w,M),w.normalize(),S.normalize();for(let U=0;U<=r;++U){const F=U/r*Math.PI*2,k=-t*Math.cos(F),G=t*Math.sin(F);m.x=x.x+(k*S.x+G*w.x),m.y=x.y+(k*S.y+G*w.y),m.z=x.z+(k*S.z+G*w.z),u.push(m.x,m.y,m.z),y.subVectors(m,x).normalize(),d.push(y.x,y.y,y.z),p.push(N/n),p.push(U/r)}}for(let N=1;N<=n;N++)for(let I=1;I<=r;I++){const U=(r+1)*(N-1)+(I-1),F=(r+1)*N+(I-1),k=(r+1)*N+I,G=(r+1)*(N-1)+I;c.push(U,F,G),c.push(F,k,G)}this.setIndex(c),this.setAttribute("position",new ht(u,3)),this.setAttribute("normal",new ht(d,3)),this.setAttribute("uv",new ht(p,2));function C(N,I,U,F,k){const G=Math.cos(N),B=Math.sin(N),z=U/I*N,Q=Math.cos(z);k.x=F*(2+Q)*.5*G,k.y=F*(2+Q)*B*.5,k.z=F*Math.sin(z)*.5}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new bm(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class Sm extends Gn{constructor(e=new Ou(new H(-1,-1,0),new H(-1,1,0),new H(1,1,0)),t=64,n=1,r=8,o=!1){super(),this.type="TubeGeometry",this.parameters={path:e,tubularSegments:t,radius:n,radialSegments:r,closed:o};const a=e.computeFrenetFrames(t,o);this.tangents=a.tangents,this.normals=a.normals,this.binormals=a.binormals;const c=new H,u=new H,d=new ze;let p=new H;const m=[],y=[],x=[],v=[];w(),this.setIndex(v),this.setAttribute("position",new ht(m,3)),this.setAttribute("normal",new ht(y,3)),this.setAttribute("uv",new ht(x,2));function w(){for(let N=0;N<t;N++)M(N);M(o===!1?t:0),C(),S()}function M(N){p=e.getPointAt(N/t,p);const I=a.normals[N],U=a.binormals[N];for(let F=0;F<=r;F++){const k=F/r*Math.PI*2,G=Math.sin(k),B=-Math.cos(k);u.x=B*I.x+G*U.x,u.y=B*I.y+G*U.y,u.z=B*I.z+G*U.z,u.normalize(),y.push(u.x,u.y,u.z),c.x=p.x+n*u.x,c.y=p.y+n*u.y,c.z=p.z+n*u.z,m.push(c.x,c.y,c.z)}}function S(){for(let N=1;N<=t;N++)for(let I=1;I<=r;I++){const U=(r+1)*(N-1)+(I-1),F=(r+1)*N+(I-1),k=(r+1)*N+I,G=(r+1)*(N-1)+I;v.push(U,F,G),v.push(F,k,G)}}function C(){for(let N=0;N<=t;N++)for(let I=0;I<=r;I++)d.x=N/t,d.y=I/r,x.push(d.x,d.y)}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}toJSON(){const e=super.toJSON();return e.path=this.parameters.path.toJSON(),e}static fromJSON(e){return new Sm(new um[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class ES extends Gn{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],n=new Set,r=new H,o=new H;if(e.index!==null){const a=e.attributes.position,c=e.index;let u=e.groups;u.length===0&&(u=[{start:0,count:c.count,materialIndex:0}]);for(let d=0,p=u.length;d<p;++d){const m=u[d],y=m.start,x=m.count;for(let v=y,w=y+x;v<w;v+=3)for(let M=0;M<3;M++){const S=c.getX(v+M),C=c.getX(v+(M+1)%3);r.fromBufferAttribute(a,S),o.fromBufferAttribute(a,C),lx(r,o,n)===!0&&(t.push(r.x,r.y,r.z),t.push(o.x,o.y,o.z))}}}else{const a=e.attributes.position;for(let c=0,u=a.count/3;c<u;c++)for(let d=0;d<3;d++){const p=3*c+d,m=3*c+(d+1)%3;r.fromBufferAttribute(a,p),o.fromBufferAttribute(a,m),lx(r,o,n)===!0&&(t.push(r.x,r.y,r.z),t.push(o.x,o.y,o.z))}}this.setAttribute("position",new ht(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function lx(i,e,t){const n=`${i.x},${i.y},${i.z}-${e.x},${e.y},${e.z}`,r=`${e.x},${e.y},${e.z}-${i.x},${i.y},${i.z}`;return t.has(n)===!0||t.has(r)===!0?!1:(t.add(n),t.add(r),!0)}var cx=Object.freeze({__proto__:null,BoxGeometry:fl,CapsuleGeometry:yd,CircleGeometry:p0,ConeGeometry:Lu,CylinderGeometry:Ur,DodecahedronGeometry:Rf,EdgesGeometry:mS,ExtrudeGeometry:M0,IcosahedronGeometry:kf,LatheGeometry:zf,OctahedronGeometry:Ad,PlaneGeometry:Ed,PolyhedronGeometry:Du,RingGeometry:xm,ShapeGeometry:vm,SphereGeometry:ku,TetrahedronGeometry:w0,TorusGeometry:A0,TorusKnotGeometry:bm,TubeGeometry:Sm,WireframeGeometry:ES});class ux extends Ds{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new It(0),this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.fog=e.fog,this}}class hx extends lo{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class E0 extends Ds{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new It(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 It(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Yo,this.normalScale=new ze(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 jr,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={STANDARD:""},this.color.copy(e.color),this.roughness=e.roughness,this.metalness=e.metalness,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.roughnessMap=e.roughnessMap,this.metalnessMap=e.metalnessMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.envMapIntensity=e.envMapIntensity,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class fc extends E0{constructor(e){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 ze(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Vn(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(t){this.ior=(1+.4*t)/(1-.4*t)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new It(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 It(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new It(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(e)}get anisotropy(){return this._anisotropy}set anisotropy(e){this._anisotropy>0!=e>0&&this.version++,this._anisotropy=e}get clearcoat(){return this._clearcoat}set clearcoat(e){this._clearcoat>0!=e>0&&this.version++,this._clearcoat=e}get iridescence(){return this._iridescence}set iridescence(e){this._iridescence>0!=e>0&&this.version++,this._iridescence=e}get dispersion(){return this._dispersion}set dispersion(e){this._dispersion>0!=e>0&&this.version++,this._dispersion=e}get sheen(){return this._sheen}set sheen(e){this._sheen>0!=e>0&&this.version++,this._sheen=e}get transmission(){return this._transmission}set transmission(e){this._transmission>0!=e>0&&this.version++,this._transmission=e}copy(e){return super.copy(e),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=e.anisotropy,this.anisotropyRotation=e.anisotropyRotation,this.anisotropyMap=e.anisotropyMap,this.clearcoat=e.clearcoat,this.clearcoatMap=e.clearcoatMap,this.clearcoatRoughness=e.clearcoatRoughness,this.clearcoatRoughnessMap=e.clearcoatRoughnessMap,this.clearcoatNormalMap=e.clearcoatNormalMap,this.clearcoatNormalScale.copy(e.clearcoatNormalScale),this.dispersion=e.dispersion,this.ior=e.ior,this.iridescence=e.iridescence,this.iridescenceMap=e.iridescenceMap,this.iridescenceIOR=e.iridescenceIOR,this.iridescenceThicknessRange=[...e.iridescenceThicknessRange],this.iridescenceThicknessMap=e.iridescenceThicknessMap,this.sheen=e.sheen,this.sheenColor.copy(e.sheenColor),this.sheenColorMap=e.sheenColorMap,this.sheenRoughness=e.sheenRoughness,this.sheenRoughnessMap=e.sheenRoughnessMap,this.transmission=e.transmission,this.transmissionMap=e.transmissionMap,this.thickness=e.thickness,this.thicknessMap=e.thicknessMap,this.attenuationDistance=e.attenuationDistance,this.attenuationColor.copy(e.attenuationColor),this.specularIntensity=e.specularIntensity,this.specularIntensityMap=e.specularIntensityMap,this.specularColor.copy(e.specularColor),this.specularColorMap=e.specularColorMap,this}}class C0 extends Ds{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new It(16777215),this.specular=new It(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new It(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Yo,this.normalScale=new ze(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new jr,this.combine=Xc,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.specular.copy(e.specular),this.shininess=e.shininess,this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class R0 extends Ds{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new It(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new It(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Yo,this.normalScale=new ze(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.gradientMap=e.gradientMap,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}class Mm extends Ds{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Yo,this.normalScale=new ze(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(e)}copy(e){return super.copy(e),this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this}}class Vf extends Ds{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new It(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new It(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Yo,this.normalScale=new ze(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new jr,this.combine=Xc,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class dx extends Ds{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=qh,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class fx extends Ds{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class CS extends Ds{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new It(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Yo,this.normalScale=new ze(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(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.flatShading=e.flatShading,this.fog=e.fog,this}}class Cd extends js{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}function zu(i,e){return!i||i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function N0(i){function e(r,o){return i[r]-i[o]}const t=i.length,n=new Array(t);for(let r=0;r!==t;++r)n[r]=r;return n.sort(e),n}function P0(i,e,t){const n=i.length,r=new i.constructor(n);for(let o=0,a=0;a!==n;++o){const c=t[o]*e;for(let u=0;u!==e;++u)r[a++]=i[c+u]}return r}function fo(i,e,t,n){let r=1,o=i[0];for(;o!==void 0&&o[n]===void 0;)o=i[r++];if(o===void 0)return;let a=o[n];if(a!==void 0)if(Array.isArray(a))do a=o[n],a!==void 0&&(e.push(o.time),t.push(...a)),o=i[r++];while(o!==void 0);else if(a.toArray!==void 0)do a=o[n],a!==void 0&&(e.push(o.time),a.toArray(t,t.length)),o=i[r++];while(o!==void 0);else do a=o[n],a!==void 0&&(e.push(o.time),t.push(a)),o=i[r++];while(o!==void 0)}function Rd(i,e,t,n,r=30){const o=i.clone();o.name=e;const a=[];for(let u=0;u<o.tracks.length;++u){const d=o.tracks[u],p=d.getValueSize(),m=[],y=[];for(let x=0;x<d.times.length;++x){const v=d.times[x]*r;if(!(v<t||v>=n)){m.push(d.times[x]);for(let w=0;w<p;++w)y.push(d.values[x*p+w])}}m.length!==0&&(d.times=zu(m,d.times.constructor),d.values=zu(y,d.values.constructor),a.push(d))}o.tracks=a;let c=1/0;for(let u=0;u<o.tracks.length;++u)c>o.tracks[u].times[0]&&(c=o.tracks[u].times[0]);for(let u=0;u<o.tracks.length;++u)o.tracks[u].shift(-1*c);return o.resetDuration(),o}function px(i,e=0,t=i,n=30){n<=0&&(n=30);const r=t.tracks.length,o=e/n;for(let a=0;a<r;++a){const c=t.tracks[a],u=c.ValueTypeName;if(u==="bool"||u==="string")continue;const d=i.tracks.find(function(S){return S.name===c.name&&S.ValueTypeName===u});if(d===void 0)continue;let p=0;const m=c.getValueSize();c.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(p=m/3);let y=0;const x=d.getValueSize();d.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(y=x/3);const v=c.times.length-1;let w;if(o<=c.times[0]){const S=p,C=m-p;w=c.values.slice(S,C)}else if(o>=c.times[v]){const S=v*m+p,C=S+m-p;w=c.values.slice(S,C)}else{const S=c.createInterpolant(),C=p,N=m-p;S.evaluate(o),w=S.resultBuffer.slice(C,N)}u==="quaternion"&&new Gs().fromArray(w).normalize().conjugate().toArray(w);const M=d.times.length;for(let S=0;S<M;++S){const C=S*x+y;if(u==="quaternion")Gs.multiplyQuaternionsFlat(d.values,C,w,0,d.values,C);else{const N=x-y*2;for(let I=0;I<N;++I)d.values[C+I]-=w[I]}}}return i.blendMode=f_,i}class I0{static convertArray(e,t){return zu(e,t)}static isTypedArray(e){return Mn(e)}static getKeyframeOrder(e){return N0(e)}static sortedArray(e,t,n){return P0(e,t,n)}static flattenJSON(e,t,n,r){fo(e,t,n,r)}static subclip(e,t,n,r,o=30){return Rd(e,t,n,r,o)}static makeClipAdditive(e,t=0,n=e,r=30){return px(e,t,n,r)}}class Tm{constructor(e,t,n,r){this.parameterPositions=e,this._cachedIndex=0,this.resultBuffer=r!==void 0?r:new t.constructor(n),this.sampleValues=t,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(e){const t=this.parameterPositions;let n=this._cachedIndex,r=t[n],o=t[n-1];e:{t:{let a;n:{i:if(!(e<r)){for(let c=n+2;;){if(r===void 0){if(e<o)break i;return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===c)break;if(o=r,r=t[++n],e<r)break t}a=t.length;break n}if(!(e>=o)){const c=t[1];e<c&&(n=2,o=c);for(let u=n-2;;){if(o===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===u)break;if(r=o,o=t[--n-1],e>=o)break t}a=n,n=0;break n}break e}for(;n<a;){const c=n+a>>>1;e<t[c]?a=c:n=c+1}if(r=t[n],o=t[n-1],o===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(r===void 0)return n=t.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,o,r)}return this.interpolate_(n,o,e,r)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,o=e*r;for(let a=0;a!==r;++a)t[a]=n[o+a];return t}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class wm extends Tm{constructor(e,t,n,r){super(e,t,n,r),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:nu,endingEnd:nu}}intervalChanged_(e,t,n){const r=this.parameterPositions;let o=e-2,a=e+1,c=r[o],u=r[a];if(c===void 0)switch(this.getSettings_().endingStart){case lf:o=e,c=2*t-n;break;case Dg:o=r.length-2,c=t+r[o]-r[o+1];break;default:o=e,c=n}if(u===void 0)switch(this.getSettings_().endingEnd){case lf:a=e,u=2*n-t;break;case Dg:a=1,u=n+r[1]-r[0];break;default:a=e-1,u=t}const d=(n-t)*.5,p=this.valueSize;this._weightPrev=d/(t-c),this._weightNext=d/(u-n),this._offsetPrev=o*p,this._offsetNext=a*p}interpolate_(e,t,n,r){const o=this.resultBuffer,a=this.sampleValues,c=this.valueSize,u=e*c,d=u-c,p=this._offsetPrev,m=this._offsetNext,y=this._weightPrev,x=this._weightNext,v=(n-t)/(r-t),w=v*v,M=w*v,S=-y*M+2*y*w-y*v,C=(1+y)*M+(-1.5-2*y)*w+(-.5+y)*v+1,N=(-1-x)*M+(1.5+x)*w+.5*v,I=x*M-x*w;for(let U=0;U!==c;++U)o[U]=S*a[p+U]+C*a[d+U]+N*a[u+U]+I*a[m+U];return o}}class Vu extends Tm{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const o=this.resultBuffer,a=this.sampleValues,c=this.valueSize,u=e*c,d=u-c,p=(n-t)/(r-t),m=1-p;for(let y=0;y!==c;++y)o[y]=a[d+y]*m+a[u+y]*p;return o}}class Am extends Tm{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class Kr{constructor(e,t,n,r){if(e===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(t===void 0||t.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+e);this.name=e,this.times=zu(t,this.TimeBufferType),this.values=zu(n,this.ValueBufferType),this.setInterpolation(r||this.DefaultInterpolation)}static toJSON(e){const t=e.constructor;let n;if(t.toJSON!==this.toJSON)n=t.toJSON(e);else{n={name:e.name,times:zu(e.times,Array),values:zu(e.values,Array)};const r=e.getInterpolation();r!==e.DefaultInterpolation&&(n.interpolation=r)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new Am(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new Vu(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new wm(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case sl:t=this.InterpolantFactoryMethodDiscrete;break;case $h:t=this.InterpolantFactoryMethodLinear;break;case af:t=this.InterpolantFactoryMethodSmooth;break}if(t===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(e!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return Ie("KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return sl;case this.InterpolantFactoryMethodLinear:return $h;case this.InterpolantFactoryMethodSmooth:return af}}getValueSize(){return this.values.length/this.times.length}shift(e){if(e!==0){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]+=e}return this}scale(e){if(e!==1){const t=this.times;for(let n=0,r=t.length;n!==r;++n)t[n]*=e}return this}trim(e,t){const n=this.times,r=n.length;let o=0,a=r-1;for(;o!==r&&n[o]<e;)++o;for(;a!==-1&&n[a]>t;)--a;if(++a,o!==0||a!==r){o>=a&&(a=Math.max(a,1),o=a-1);const c=this.getValueSize();this.times=n.slice(o,a),this.values=this.values.slice(o*c,a*c)}return this}validate(){let e=!0;const t=this.getValueSize();t-Math.floor(t)!==0&&(Be("KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,r=this.values,o=n.length;o===0&&(Be("KeyframeTrack: Track is empty.",this),e=!1);let a=null;for(let c=0;c!==o;c++){const u=n[c];if(typeof u=="number"&&isNaN(u)){Be("KeyframeTrack: Time is not a valid number.",this,c,u),e=!1;break}if(a!==null&&a>u){Be("KeyframeTrack: Out of order keys.",this,c,u,a),e=!1;break}a=u}if(r!==void 0&&Mn(r))for(let c=0,u=r.length;c!==u;++c){const d=r[c];if(isNaN(d)){Be("KeyframeTrack: Value is not a valid number.",this,c,d),e=!1;break}}return e}optimize(){const e=this.times.slice(),t=this.values.slice(),n=this.getValueSize(),r=this.getInterpolation()===af,o=e.length-1;let a=1;for(let c=1;c<o;++c){let u=!1;const d=e[c],p=e[c+1];if(d!==p&&(c!==1||d!==e[0]))if(r)u=!0;else{const m=c*n,y=m-n,x=m+n;for(let v=0;v!==n;++v){const w=t[m+v];if(w!==t[y+v]||w!==t[x+v]){u=!0;break}}}if(u){if(c!==a){e[a]=e[c];const m=c*n,y=a*n;for(let x=0;x!==n;++x)t[y+x]=t[m+x]}++a}}if(o>0){e[a]=e[o];for(let c=o*n,u=a*n,d=0;d!==n;++d)t[u+d]=t[c+d];++a}return a!==e.length?(this.times=e.slice(0,a),this.values=t.slice(0,a*n)):(this.times=e,this.values=t),this}clone(){const e=this.times.slice(),t=this.values.slice(),n=this.constructor,r=new n(this.name,e,t);return r.createInterpolant=this.createInterpolant,r}}Kr.prototype.ValueTypeName="",Kr.prototype.TimeBufferType=Float32Array,Kr.prototype.ValueBufferType=Float32Array,Kr.prototype.DefaultInterpolation=$h;class Nd extends Kr{constructor(e,t,n){super(e,t,n)}}Nd.prototype.ValueTypeName="bool",Nd.prototype.ValueBufferType=Array,Nd.prototype.DefaultInterpolation=sl,Nd.prototype.InterpolantFactoryMethodLinear=void 0,Nd.prototype.InterpolantFactoryMethodSmooth=void 0;class mx extends Kr{constructor(e,t,n,r){super(e,t,n,r)}}mx.prototype.ValueTypeName="color";class Bo extends Kr{constructor(e,t,n,r){super(e,t,n,r)}}Bo.prototype.ValueTypeName="number";class gx extends Tm{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e,t,n,r){const o=this.resultBuffer,a=this.sampleValues,c=this.valueSize,u=(n-t)/(r-t);let d=e*c;for(let p=d+c;d!==p;d+=4)Gs.slerpFlat(o,0,a,d-c,a,d,u);return o}}class Em extends Kr{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new gx(this.times,this.values,this.getValueSize(),e)}}Em.prototype.ValueTypeName="quaternion",Em.prototype.InterpolantFactoryMethodSmooth=void 0;class Pd extends Kr{constructor(e,t,n){super(e,t,n)}}Pd.prototype.ValueTypeName="string",Pd.prototype.ValueBufferType=Array,Pd.prototype.DefaultInterpolation=sl,Pd.prototype.InterpolantFactoryMethodLinear=void 0,Pd.prototype.InterpolantFactoryMethodSmooth=void 0;class Oo extends Kr{constructor(e,t,n,r){super(e,t,n,r)}}Oo.prototype.ValueTypeName="vector";class Cm{constructor(e="",t=-1,n=[],r=d_){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=so(),this.userData={},this.duration<0&&this.resetDuration()}static parse(e){const t=[],n=e.tracks,r=1/(e.fps||1);for(let a=0,c=n.length;a!==c;++a)t.push(AA(n[a]).scale(r));const o=new this(e.name,e.duration,t,e.blendMode);return o.uuid=e.uuid,o.userData=JSON.parse(e.userData||"{}"),o}static toJSON(e){const t=[],n=e.tracks,r={name:e.name,duration:e.duration,tracks:t,uuid:e.uuid,blendMode:e.blendMode,userData:JSON.stringify(e.userData)};for(let o=0,a=n.length;o!==a;++o)t.push(Kr.toJSON(n[o]));return r}static CreateFromMorphTargetSequence(e,t,n,r){const o=t.length,a=[];for(let c=0;c<o;c++){let u=[],d=[];u.push((c+o-1)%o,c,(c+1)%o),d.push(0,1,0);const p=N0(u);u=P0(u,1,p),d=P0(d,1,p),!r&&u[0]===0&&(u.push(o),d.push(d[0])),a.push(new Bo(".morphTargetInfluences["+t[c].name+"]",u,d).scale(1/n))}return new this(e,-1,a)}static findByName(e,t){let n=e;if(!Array.isArray(e)){const r=e;n=r.geometry&&r.geometry.animations||r.animations}for(let r=0;r<n.length;r++)if(n[r].name===t)return n[r];return null}static CreateClipsFromMorphTargetSequences(e,t,n){const r={},o=/^([\w-]*?)([\d]+)$/;for(let c=0,u=e.length;c<u;c++){const d=e[c],p=d.name.match(o);if(p&&p.length>1){const m=p[1];let y=r[m];y||(r[m]=y=[]),y.push(d)}}const a=[];for(const c in r)a.push(this.CreateFromMorphTargetSequence(c,r[c],t,n));return a}static parseAnimation(e,t){if(Ie("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return Be("AnimationClip: No animation in JSONLoader data."),null;const n=function(m,y,x,v,w){if(x.length!==0){const M=[],S=[];fo(x,M,S,v),M.length!==0&&w.push(new m(y,M,S))}},r=[],o=e.name||"default",a=e.fps||30,c=e.blendMode;let u=e.length||-1;const d=e.hierarchy||[];for(let m=0;m<d.length;m++){const y=d[m].keys;if(!(!y||y.length===0))if(y[0].morphTargets){const x={};let v;for(v=0;v<y.length;v++)if(y[v].morphTargets)for(let w=0;w<y[v].morphTargets.length;w++)x[y[v].morphTargets[w]]=-1;for(const w in x){const M=[],S=[];for(let C=0;C!==y[v].morphTargets.length;++C){const N=y[v];M.push(N.time),S.push(N.morphTarget===w?1:0)}r.push(new Bo(".morphTargetInfluence["+w+"]",M,S))}u=x.length*a}else{const x=".bones["+t[m].name+"]";n(Oo,x+".position",y,"pos",r),n(Em,x+".quaternion",y,"rot",r),n(Oo,x+".scale",y,"scl",r)}}return r.length===0?null:new this(o,u,r,c)}resetDuration(){const e=this.tracks;let t=0;for(let n=0,r=e.length;n!==r;++n){const o=this.tracks[n];t=Math.max(t,o.times[o.times.length-1])}return this.duration=t,this}trim(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].trim(0,this.duration);return this}validate(){let e=!0;for(let t=0;t<this.tracks.length;t++)e=e&&this.tracks[t].validate();return e}optimize(){for(let e=0;e<this.tracks.length;e++)this.tracks[e].optimize();return this}clone(){const e=[];for(let n=0;n<this.tracks.length;n++)e.push(this.tracks[n].clone());const t=new this.constructor(this.name,this.duration,e,this.blendMode);return t.userData=JSON.parse(JSON.stringify(this.userData)),t}toJSON(){return this.constructor.toJSON(this)}}function pc(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Bo;case"vector":case"vector2":case"vector3":case"vector4":return Oo;case"color":return mx;case"quaternion":return Em;case"bool":case"boolean":return Nd;case"string":return Pd}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function AA(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=pc(i.type);if(i.times===void 0){const t=[],n=[];fo(i.keys,t,n,"value"),i.times=t,i.values=n}return e.parse!==void 0?e.parse(i):new e(i.name,i.times,i.values,i.interpolation)}const mc={enabled:!1,files:{},add:function(i,e){this.enabled!==!1&&(this.files[i]=e)},get:function(i){if(this.enabled!==!1)return this.files[i]},remove:function(i){delete this.files[i]},clear:function(){this.files={}}};class Gu{constructor(e,t,n){const r=this;let o=!1,a=0,c=0,u;const d=[];this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=n,this._abortController=null,this.itemStart=function(p){c++,o===!1&&r.onStart!==void 0&&r.onStart(p,a,c),o=!0},this.itemEnd=function(p){a++,r.onProgress!==void 0&&r.onProgress(p,a,c),a===c&&(o=!1,r.onLoad!==void 0&&r.onLoad())},this.itemError=function(p){r.onError!==void 0&&r.onError(p)},this.resolveURL=function(p){return u?u(p):p},this.setURLModifier=function(p){return u=p,this},this.addHandler=function(p,m){return d.push(p,m),this},this.removeHandler=function(p){const m=d.indexOf(p);return m!==-1&&d.splice(m,2),this},this.getHandler=function(p){for(let m=0,y=d.length;m<y;m+=2){const x=d[m],v=d[m+1];if(x.global&&(x.lastIndex=0),x.test(p))return v}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 Rm=new Gu;class yx{constructor(e){this.manager=e!==void 0?e:Rm,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(e,t){const n=this;return new Promise(function(r,o){n.load(e,r,t,o)})}parse(){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}abort(){return this}}yx.DEFAULT_MATERIAL_NAME="__DEFAULT";const gc={};class EA extends null{constructor(e,t){super(e),this.response=t}}class Wu extends null{constructor(e){super(e),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const o=mc.get(`file:${e}`);if(o!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(o),this.manager.itemEnd(e)},0),o;if(gc[e]!==void 0){gc[e].push({onLoad:t,onProgress:n,onError:r});return}gc[e]=[],gc[e].push({onLoad:t,onProgress:n,onError:r});const a=new Request(e,{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}),c=this.mimeType,u=this.responseType;fetch(a).then(d=>{if(d.status===200||d.status===0){if(d.status===0&&Ie("FileLoader: HTTP Status 0 received."),typeof ReadableStream=="undefined"||d.body===void 0||d.body.getReader===void 0)return d;const p=gc[e],m=d.body.getReader(),y=d.headers.get("X-File-Size")||d.headers.get("Content-Length"),x=y?parseInt(y):0,v=x!==0;let w=0;const M=new ReadableStream({start(S){C();function C(){m.read().then(({done:N,value:I})=>{if(N)S.close();else{w+=I.byteLength;const U=new ProgressEvent("progress",{lengthComputable:v,loaded:w,total:x});for(let F=0,k=p.length;F<k;F++){const G=p[F];G.onProgress&&G.onProgress(U)}S.enqueue(I),C()}},N=>{S.error(N)})}}});return new Response(M)}else throw new EA(`fetch for "${d.url}" responded with ${d.status}: ${d.statusText}`,d)}).then(d=>{switch(u){case"arraybuffer":return d.arrayBuffer();case"blob":return d.blob();case"document":return d.text().then(p=>new DOMParser().parseFromString(p,c));case"json":return d.json();default:if(c==="")return d.text();{const m=/charset="?([^;"\s]*)"?/i.exec(c),y=m&&m[1]?m[1].toLowerCase():void 0,x=new TextDecoder(y);return d.arrayBuffer().then(v=>x.decode(v))}}}).then(d=>{mc.add(`file:${e}`,d);const p=gc[e];delete gc[e];for(let m=0,y=p.length;m<y;m++){const x=p[m];x.onLoad&&x.onLoad(d)}}).catch(d=>{const p=gc[e];if(p===void 0)throw this.manager.itemError(e),d;delete gc[e];for(let m=0,y=p.length;m<y;m++){const x=p[m];x.onError&&x.onError(d)}this.manager.itemError(e)}).finally(()=>{this.manager.itemEnd(e)}),this.manager.itemStart(e)}setResponseType(e){return this.responseType=e,this}setMimeType(e){return this.mimeType=e,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class CA extends null{constructor(e){super(e)}load(e,t,n,r){const o=this,a=new Wu(this.manager);a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){try{t(o.parse(JSON.parse(c)))}catch(u){r?r(u):Be(u),o.manager.itemError(e)}},n,r)}parse(e){const t=[];for(let n=0;n<e.length;n++){const r=Cm.parse(e[n]);t.push(r)}return t}}class _x extends null{constructor(e){super(e)}load(e,t,n,r){const o=this,a=[],c=new om,u=new Wu(this.manager);u.setPath(this.path),u.setResponseType("arraybuffer"),u.setRequestHeader(this.requestHeader),u.setWithCredentials(o.withCredentials);let d=0;function p(m){u.load(e[m],function(y){const x=o.parse(y,!0);a[m]={width:x.width,height:x.height,format:x.format,mipmaps:x.mipmaps},d+=1,d===6&&(x.mipmapCount===1&&(c.minFilter=Yn),c.image=a,c.format=x.format,c.needsUpdate=!0,t&&t(c))},n,r)}if(Array.isArray(e))for(let m=0,y=e.length;m<y;++m)p(m);else u.load(e,function(m){const y=o.parse(m,!0);if(y.isCubemap){const x=y.mipmaps.length/y.mipmapCount;for(let v=0;v<x;v++){a[v]={mipmaps:[]};for(let w=0;w<y.mipmapCount;w++)a[v].mipmaps.push(y.mipmaps[v*y.mipmapCount+w]),a[v].format=y.format,a[v].width=y.width,a[v].height=y.height}c.image=a}else c.image.width=y.width,c.image.height=y.height,c.mipmaps=y.mipmaps;y.mipmapCount===1&&(c.minFilter=Yn),c.format=y.format,c.needsUpdate=!0,t&&t(c)},n,r);return c}}const Hu=new WeakMap;class Gf extends yx{constructor(e){super(e)}load(e,t,n,r){this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const o=this,a=mc.get(`image:${e}`);if(a!==void 0){if(a.complete===!0)o.manager.itemStart(e),setTimeout(function(){t&&t(a),o.manager.itemEnd(e)},0);else{let m=Hu.get(a);m===void 0&&(m=[],Hu.set(a,m)),m.push({onLoad:t,onError:r})}return a}const c=ci("img");function u(){p(),t&&t(this);const m=Hu.get(this)||[];for(let y=0;y<m.length;y++){const x=m[y];x.onLoad&&x.onLoad(this)}Hu.delete(this),o.manager.itemEnd(e)}function d(m){p(),r&&r(m),mc.remove(`image:${e}`);const y=Hu.get(this)||[];for(let x=0;x<y.length;x++){const v=y[x];v.onError&&v.onError(m)}Hu.delete(this),o.manager.itemError(e),o.manager.itemEnd(e)}function p(){c.removeEventListener("load",u,!1),c.removeEventListener("error",d,!1)}return c.addEventListener("load",u,!1),c.addEventListener("error",d,!1),e.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(c.crossOrigin=this.crossOrigin),mc.add(`image:${e}`,c),o.manager.itemStart(e),c.src=e,c}}class XL extends null{constructor(e){super(e)}load(e,t,n,r){const o=new nc;o.colorSpace=Pr;const a=new Gf(this.manager);a.setCrossOrigin(this.crossOrigin),a.setPath(this.path);let c=0;function u(d){a.load(e[d],function(p){o.images[d]=p,c++,c===6&&(o.needsUpdate=!0,t&&t(o))},void 0,r)}for(let d=0;d<e.length;++d)u(d);return o}}class RA extends null{constructor(e){super(e)}load(e,t,n,r){const o=this,a=new co,c=new Wu(this.manager);return c.setResponseType("arraybuffer"),c.setRequestHeader(this.requestHeader),c.setPath(this.path),c.setWithCredentials(o.withCredentials),c.load(e,function(u){let d;try{d=o.parse(u)}catch(p){if(r!==void 0)r(p);else{p(p);return}}d.image!==void 0?a.image=d.image:d.data!==void 0&&(a.image.width=d.width,a.image.height=d.height,a.image.data=d.data),a.wrapS=d.wrapS!==void 0?d.wrapS:ki,a.wrapT=d.wrapT!==void 0?d.wrapT:ki,a.magFilter=d.magFilter!==void 0?d.magFilter:Yn,a.minFilter=d.minFilter!==void 0?d.minFilter:Yn,a.anisotropy=d.anisotropy!==void 0?d.anisotropy:1,d.colorSpace!==void 0&&(a.colorSpace=d.colorSpace),d.flipY!==void 0&&(a.flipY=d.flipY),d.format!==void 0&&(a.format=d.format),d.type!==void 0&&(a.type=d.type),d.mipmaps!==void 0&&(a.mipmaps=d.mipmaps,a.minFilter=Vs),d.mipmapCount===1&&(a.minFilter=Yn),d.generateMipmaps!==void 0&&(a.generateMipmaps=d.generateMipmaps),a.needsUpdate=!0,t&&t(a,d)},n,r),a}}class RS extends yx{constructor(e){super(e)}load(e,t,n,r){const o=new fi,a=new Gf(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(e,function(c){o.image=c,o.needsUpdate=!0,t!==void 0&&t(o)},n,r),o}}class yc extends Zi{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new It(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class Id extends yc{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Zi.DEFAULT_UP),this.updateMatrix(),this.groundColor=new It(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){const t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}const Wf=new Qt,xx=new H,vx=new H;class Nm{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new ze(512,512),this.mapType=Di,this.map=null,this.mapPass=null,this.matrix=new Qt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Xs,this._frameExtents=new ze(1,1),this._viewportCount=1,this._viewports=[new gn(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;xx.setFromMatrixPosition(e.matrixWorld),t.position.copy(xx),vx.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(vx),t.updateMatrixWorld(),Wf.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Wf,t.coordinateSystem,t.reversedDepth),t.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Wf)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}class NS extends Nm{constructor(){super(new Bs(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,n=ou*2*e.angle*this.focus,r=this.mapSize.width/this.mapSize.height*this.aspect,o=e.distance||t.far;(n!==t.fov||r!==t.aspect||o!==t.far)&&(t.fov=n,t.aspect=r,t.far=o,t.updateProjectionMatrix()),super.updateMatrices(e)}copy(e){return super.copy(e),this.focus=e.focus,this}}class Pm extends yc{constructor(e,t,n=0,r=Math.PI/3,o=0,a=2){super(e,t),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Zi.DEFAULT_UP),this.updateMatrix(),this.target=new Zi,this.distance=n,this.angle=r,this.penumbra=o,this.decay=a,this.map=null,this.shadow=new NS}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.map=e.map,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.angle=this.angle,t.object.decay=this.decay,t.object.penumbra=this.penumbra,t.object.target=this.target.uuid,this.map&&this.map.isTexture&&(t.object.map=this.map.toJSON(e).uuid),t.object.shadow=this.shadow.toJSON(),t}}class PS extends Nm{constructor(){super(new Bs(90,1,.5,500)),this.isPointLightShadow=!0}}class bx extends yc{constructor(e,t,n=0,r=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=r,this.shadow=new PS}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class $u extends ld{constructor(e=-1,t=1,n=1,r=-1,o=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=r,this.near=o,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,r,o,a){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=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=r,this.view.width=o,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,r=(this.top+this.bottom)/2;let o=n-e,a=n+e,c=r+t,u=r-t;if(this.view!==null&&this.view.enabled){const d=(this.right-this.left)/this.view.fullWidth/this.zoom,p=(this.top-this.bottom)/this.view.fullHeight/this.zoom;o+=d*this.view.offsetX,a=o+d*this.view.width,c-=p*this.view.offsetY,u=c-p*this.view.height}this.projectionMatrix.makeOrthographic(o,a,c,u,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class IS extends Nm{constructor(){super(new $u(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Hf extends yc{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Zi.DEFAULT_UP),this.updateMatrix(),this.target=new Zi,this.shadow=new IS}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}class Im extends yc{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Sx extends yc{constructor(e,t,n=10,r=10){super(e,t),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=n,this.height=r}get power(){return this.intensity*this.width*this.height*Math.PI}set power(e){this.intensity=e/(this.width*this.height*Math.PI)}copy(e){return super.copy(e),this.width=e.width,this.height=e.height,this}toJSON(e){const t=super.toJSON(e);return t.object.width=this.width,t.object.height=this.height,t}}class Mx{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new H)}set(e){for(let t=0;t<9;t++)this.coefficients[t].copy(e[t]);return this}zero(){for(let e=0;e<9;e++)this.coefficients[e].set(0,0,0);return this}getAt(e,t){const n=e.x,r=e.y,o=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.282095),t.addScaledVector(a[1],.488603*r),t.addScaledVector(a[2],.488603*o),t.addScaledVector(a[3],.488603*n),t.addScaledVector(a[4],1.092548*(n*r)),t.addScaledVector(a[5],1.092548*(r*o)),t.addScaledVector(a[6],.315392*(3*o*o-1)),t.addScaledVector(a[7],1.092548*(n*o)),t.addScaledVector(a[8],.546274*(n*n-r*r)),t}getIrradianceAt(e,t){const n=e.x,r=e.y,o=e.z,a=this.coefficients;return t.copy(a[0]).multiplyScalar(.886227),t.addScaledVector(a[1],2*.511664*r),t.addScaledVector(a[2],2*.511664*o),t.addScaledVector(a[3],2*.511664*n),t.addScaledVector(a[4],2*.429043*n*r),t.addScaledVector(a[5],2*.429043*r*o),t.addScaledVector(a[6],.743125*o*o-.247708),t.addScaledVector(a[7],2*.429043*n*o),t.addScaledVector(a[8],.429043*(n*n-r*r)),t}add(e){for(let t=0;t<9;t++)this.coefficients[t].add(e.coefficients[t]);return this}addScaledSH(e,t){for(let n=0;n<9;n++)this.coefficients[n].addScaledVector(e.coefficients[n],t);return this}scale(e){for(let t=0;t<9;t++)this.coefficients[t].multiplyScalar(e);return this}lerp(e,t){for(let n=0;n<9;n++)this.coefficients[n].lerp(e.coefficients[n],t);return this}equals(e){for(let t=0;t<9;t++)if(!this.coefficients[t].equals(e.coefficients[t]))return!1;return!0}copy(e){return this.set(e.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(e,t=0){const n=this.coefficients;for(let r=0;r<9;r++)n[r].fromArray(e,t+r*3);return this}toArray(e=[],t=0){const n=this.coefficients;for(let r=0;r<9;r++)n[r].toArray(e,t+r*3);return e}static getBasisAt(e,t){const n=e.x,r=e.y,o=e.z;t[0]=.282095,t[1]=.488603*r,t[2]=.488603*o,t[3]=.488603*n,t[4]=1.092548*n*r,t[5]=1.092548*r*o,t[6]=.315392*(3*o*o-1),t[7]=1.092548*n*o,t[8]=.546274*(n*n-r*r)}}class LS extends yc{constructor(e=new Mx,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class L0 extends null{constructor(e){super(e),this.textures={}}load(e,t,n,r){const o=this,a=new Wu(o.manager);a.setPath(o.path),a.setRequestHeader(o.requestHeader),a.setWithCredentials(o.withCredentials),a.load(e,function(c){try{t(o.parse(JSON.parse(c)))}catch(u){r?r(u):Be(u),o.manager.itemError(e)}},n,r)}parse(e){const t=this.textures;function n(o){return t[o]===void 0&&Ie("MaterialLoader: Undefined texture",o),t[o]}const r=this.createMaterialFromType(e.type);if(e.uuid!==void 0&&(r.uuid=e.uuid),e.name!==void 0&&(r.name=e.name),e.color!==void 0&&r.color!==void 0&&r.color.setHex(e.color),e.roughness!==void 0&&(r.roughness=e.roughness),e.metalness!==void 0&&(r.metalness=e.metalness),e.sheen!==void 0&&(r.sheen=e.sheen),e.sheenColor!==void 0&&(r.sheenColor=new It().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(r.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&r.emissive!==void 0&&r.emissive.setHex(e.emissive),e.specular!==void 0&&r.specular!==void 0&&r.specular.setHex(e.specular),e.specularIntensity!==void 0&&(r.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&r.specularColor!==void 0&&r.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(r.shininess=e.shininess),e.clearcoat!==void 0&&(r.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(r.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(r.dispersion=e.dispersion),e.iridescence!==void 0&&(r.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(r.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(r.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(r.transmission=e.transmission),e.thickness!==void 0&&(r.thickness=e.thickness),e.attenuationDistance!==void 0&&(r.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&r.attenuationColor!==void 0&&r.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(r.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(r.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(r.fog=e.fog),e.flatShading!==void 0&&(r.flatShading=e.flatShading),e.blending!==void 0&&(r.blending=e.blending),e.combine!==void 0&&(r.combine=e.combine),e.side!==void 0&&(r.side=e.side),e.shadowSide!==void 0&&(r.shadowSide=e.shadowSide),e.opacity!==void 0&&(r.opacity=e.opacity),e.transparent!==void 0&&(r.transparent=e.transparent),e.alphaTest!==void 0&&(r.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(r.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(r.depthFunc=e.depthFunc),e.depthTest!==void 0&&(r.depthTest=e.depthTest),e.depthWrite!==void 0&&(r.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(r.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(r.blendSrc=e.blendSrc),e.blendDst!==void 0&&(r.blendDst=e.blendDst),e.blendEquation!==void 0&&(r.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(r.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(r.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(r.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&r.blendColor!==void 0&&r.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(r.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(r.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(r.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(r.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(r.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(r.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(r.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(r.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(r.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(r.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(r.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(r.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(r.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(r.rotation=e.rotation),e.linewidth!==void 0&&(r.linewidth=e.linewidth),e.dashSize!==void 0&&(r.dashSize=e.dashSize),e.gapSize!==void 0&&(r.gapSize=e.gapSize),e.scale!==void 0&&(r.scale=e.scale),e.polygonOffset!==void 0&&(r.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(r.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(r.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(r.dithering=e.dithering),e.alphaToCoverage!==void 0&&(r.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(r.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(r.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(r.allowOverride=e.allowOverride),e.visible!==void 0&&(r.visible=e.visible),e.toneMapped!==void 0&&(r.toneMapped=e.toneMapped),e.userData!==void 0&&(r.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?r.vertexColors=e.vertexColors>0:r.vertexColors=e.vertexColors),e.uniforms!==void 0)for(const o in e.uniforms){const a=e.uniforms[o];switch(r.uniforms[o]={},a.type){case"t":r.uniforms[o].value=n(a.value);break;case"c":r.uniforms[o].value=new It().setHex(a.value);break;case"v2":r.uniforms[o].value=new ze().fromArray(a.value);break;case"v3":r.uniforms[o].value=new H().fromArray(a.value);break;case"v4":r.uniforms[o].value=new gn().fromArray(a.value);break;case"m3":r.uniforms[o].value=new Nn().fromArray(a.value);break;case"m4":r.uniforms[o].value=new Qt().fromArray(a.value);break;default:r.uniforms[o].value=a.value}}if(e.defines!==void 0&&(r.defines=e.defines),e.vertexShader!==void 0&&(r.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(r.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(r.glslVersion=e.glslVersion),e.extensions!==void 0)for(const o in e.extensions)r.extensions[o]=e.extensions[o];if(e.lights!==void 0&&(r.lights=e.lights),e.clipping!==void 0&&(r.clipping=e.clipping),e.size!==void 0&&(r.size=e.size),e.sizeAttenuation!==void 0&&(r.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(r.map=n(e.map)),e.matcap!==void 0&&(r.matcap=n(e.matcap)),e.alphaMap!==void 0&&(r.alphaMap=n(e.alphaMap)),e.bumpMap!==void 0&&(r.bumpMap=n(e.bumpMap)),e.bumpScale!==void 0&&(r.bumpScale=e.bumpScale),e.normalMap!==void 0&&(r.normalMap=n(e.normalMap)),e.normalMapType!==void 0&&(r.normalMapType=e.normalMapType),e.normalScale!==void 0){let o=e.normalScale;Array.isArray(o)===!1&&(o=[o,o]),r.normalScale=new ze().fromArray(o)}return e.displacementMap!==void 0&&(r.displacementMap=n(e.displacementMap)),e.displacementScale!==void 0&&(r.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(r.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(r.roughnessMap=n(e.roughnessMap)),e.metalnessMap!==void 0&&(r.metalnessMap=n(e.metalnessMap)),e.emissiveMap!==void 0&&(r.emissiveMap=n(e.emissiveMap)),e.emissiveIntensity!==void 0&&(r.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(r.specularMap=n(e.specularMap)),e.specularIntensityMap!==void 0&&(r.specularIntensityMap=n(e.specularIntensityMap)),e.specularColorMap!==void 0&&(r.specularColorMap=n(e.specularColorMap)),e.envMap!==void 0&&(r.envMap=n(e.envMap)),e.envMapRotation!==void 0&&r.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(r.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(r.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(r.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(r.lightMap=n(e.lightMap)),e.lightMapIntensity!==void 0&&(r.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(r.aoMap=n(e.aoMap)),e.aoMapIntensity!==void 0&&(r.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(r.gradientMap=n(e.gradientMap)),e.clearcoatMap!==void 0&&(r.clearcoatMap=n(e.clearcoatMap)),e.clearcoatRoughnessMap!==void 0&&(r.clearcoatRoughnessMap=n(e.clearcoatRoughnessMap)),e.clearcoatNormalMap!==void 0&&(r.clearcoatNormalMap=n(e.clearcoatNormalMap)),e.clearcoatNormalScale!==void 0&&(r.clearcoatNormalScale=new ze().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(r.iridescenceMap=n(e.iridescenceMap)),e.iridescenceThicknessMap!==void 0&&(r.iridescenceThicknessMap=n(e.iridescenceThicknessMap)),e.transmissionMap!==void 0&&(r.transmissionMap=n(e.transmissionMap)),e.thicknessMap!==void 0&&(r.thicknessMap=n(e.thicknessMap)),e.anisotropyMap!==void 0&&(r.anisotropyMap=n(e.anisotropyMap)),e.sheenColorMap!==void 0&&(r.sheenColorMap=n(e.sheenColorMap)),e.sheenRoughnessMap!==void 0&&(r.sheenRoughnessMap=n(e.sheenRoughnessMap)),r}setTextures(e){return this.textures=e,this}createMaterialFromType(e){return L0.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:ux,SpriteMaterial:cd,RawShaderMaterial:hx,ShaderMaterial:lo,PointsMaterial:$_,MeshPhysicalMaterial:fc,MeshStandardMaterial:E0,MeshPhongMaterial:C0,MeshToonMaterial:R0,MeshNormalMaterial:Mm,MeshLambertMaterial:Vf,MeshDepthMaterial:dx,MeshDistanceMaterial:fx,MeshBasicMaterial:Or,MeshMatcapMaterial:CS,LineDashedMaterial:Cd,LineBasicMaterial:js,Material:Ds};return new t[e]}}class D0{static extractUrlBase(e){const t=e.lastIndexOf("/");return t===-1?"./":e.slice(0,t+1)}static resolveURL(e,t){return typeof e!="string"||e===""?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}}class Tx extends null{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(e){return super.copy(e),this.instanceCount=e.instanceCount,this}toJSON(){const e=super.toJSON();return e.instanceCount=this.instanceCount,e.isInstancedBufferGeometry=!0,e}}class F0 extends null{constructor(e){super(e)}load(e,t,n,r){const o=this,a=new Wu(o.manager);a.setPath(o.path),a.setRequestHeader(o.requestHeader),a.setWithCredentials(o.withCredentials),a.load(e,function(c){try{t(o.parse(JSON.parse(c)))}catch(u){r?r(u):Be(u),o.manager.itemError(e)}},n,r)}parse(e){const t={},n={};function r(x,v){if(t[v]!==void 0)return t[v];const M=x.interleavedBuffers[v],S=o(x,M.buffer),C=su(M.type,S),N=new ml(C,M.stride);return N.uuid=M.uuid,t[v]=N,N}function o(x,v){if(n[v]!==void 0)return n[v];const M=x.arrayBuffers[v],S=new Uint32Array(M).buffer;return n[v]=S,S}const a=e.isInstancedBufferGeometry?new Tx:new Gn,c=e.data.index;if(c!==void 0){const x=su(c.type,c.array);a.setIndex(new $i(x,1))}const u=e.data.attributes;for(const x in u){const v=u[x];let w;if(v.isInterleavedBufferAttribute){const M=r(e.data,v.data);w=new sc(M,v.itemSize,v.offset,v.normalized)}else{const M=su(v.type,v.array),S=v.isInstancedBufferAttribute?oa:$i;w=new S(M,v.itemSize,v.normalized)}v.name!==void 0&&(w.name=v.name),v.usage!==void 0&&w.setUsage(v.usage),a.setAttribute(x,w)}const d=e.data.morphAttributes;if(d)for(const x in d){const v=d[x],w=[];for(let M=0,S=v.length;M<S;M++){const C=v[M];let N;if(C.isInterleavedBufferAttribute){const I=r(e.data,C.data);N=new sc(I,C.itemSize,C.offset,C.normalized)}else{const I=su(C.type,C.array);N=new $i(I,C.itemSize,C.normalized)}C.name!==void 0&&(N.name=C.name),w.push(N)}a.morphAttributes[x]=w}e.data.morphTargetsRelative&&(a.morphTargetsRelative=!0);const m=e.data.groups||e.data.drawcalls||e.data.offsets;if(m!==void 0)for(let x=0,v=m.length;x!==v;++x){const w=m[x];a.addGroup(w.start,w.count,w.materialIndex)}const y=e.data.boundingSphere;return y!==void 0&&(a.boundingSphere=new As().fromJSON(y)),e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}}class jL extends null{constructor(e){super(e)}load(e,t,n,r){const o=this,a=this.path===""?D0.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;const c=new Wu(this.manager);c.setPath(this.path),c.setRequestHeader(this.requestHeader),c.setWithCredentials(this.withCredentials),c.load(e,function(u){let d=null;try{d=JSON.parse(u)}catch(m){r!==void 0&&r(m),m("ObjectLoader: Can't parse "+e+".",m.message);return}const p=d.metadata;if(p===void 0||p.type===void 0||p.type.toLowerCase()==="geometry"){r!==void 0&&r(new Error("THREE.ObjectLoader: Can't load "+e)),Be("ObjectLoader: Can't load "+e);return}o.parse(d,t)},n,r)}loadAsync(e,t){return mn(this,null,function*(){const n=this,r=this.path===""?D0.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;const o=new Wu(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials);const a=yield o.loadAsync(e,t),c=JSON.parse(a),u=c.metadata;if(u===void 0||u.type===void 0||u.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+e);return yield n.parseAsync(c)})}parse(e,t){const n=this.parseAnimations(e.animations),r=this.parseShapes(e.shapes),o=this.parseGeometries(e.geometries,r),a=this.parseImages(e.images,function(){t!==void 0&&t(d)}),c=this.parseTextures(e.textures,a),u=this.parseMaterials(e.materials,c),d=this.parseObject(e.object,o,u,c,n),p=this.parseSkeletons(e.skeletons,d);if(this.bindSkeletons(d,p),this.bindLightTargets(d),t!==void 0){let m=!1;for(const y in a)if(a[y].data instanceof HTMLImageElement){m=!0;break}m===!1&&t(d)}return d}parseAsync(e){return mn(this,null,function*(){const t=this.parseAnimations(e.animations),n=this.parseShapes(e.shapes),r=this.parseGeometries(e.geometries,n),o=yield this.parseImagesAsync(e.images),a=this.parseTextures(e.textures,o),c=this.parseMaterials(e.materials,a),u=this.parseObject(e.object,r,c,a,t),d=this.parseSkeletons(e.skeletons,u);return this.bindSkeletons(u,d),this.bindLightTargets(u),u})}parseShapes(e){const t={};if(e!==void 0)for(let n=0,r=e.length;n<r;n++){const o=new bd().fromJSON(e[n]);t[o.uuid]=o}return t}parseSkeletons(e,t){const n={},r={};if(t.traverse(function(o){o.isBone&&(r[o.uuid]=o)}),e!==void 0)for(let o=0,a=e.length;o<a;o++){const c=new wu().fromJSON(e[o],r);n[c.uuid]=c}return n}parseGeometries(e,t){const n={};if(e!==void 0){const r=new F0;for(let o=0,a=e.length;o<a;o++){let c;const u=e[o];switch(u.type){case"BufferGeometry":case"InstancedBufferGeometry":c=r.parse(u);break;default:u.type in cx?c=cx[u.type].fromJSON(u,t):Ie(`ObjectLoader: Unsupported geometry type "${u.type}"`)}c.uuid=u.uuid,u.name!==void 0&&(c.name=u.name),u.userData!==void 0&&(c.userData=u.userData),n[u.uuid]=c}}return n}parseMaterials(e,t){const n={},r={};if(e!==void 0){const o=new L0;o.setTextures(t);for(let a=0,c=e.length;a<c;a++){const u=e[a];n[u.uuid]===void 0&&(n[u.uuid]=o.parse(u)),r[u.uuid]=n[u.uuid]}}return r}parseAnimations(e){const t={};if(e!==void 0)for(let n=0;n<e.length;n++){const r=e[n],o=Cm.parse(r);t[o.uuid]=o}return t}parseImages(e,t){const n=this,r={};let o;function a(u){return n.manager.itemStart(u),o.load(u,function(){n.manager.itemEnd(u)},void 0,function(){n.manager.itemError(u),n.manager.itemEnd(u)})}function c(u){if(typeof u=="string"){const d=u,p=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(d)?d:n.resourcePath+d;return a(p)}else return u.data?{data:su(u.type,u.data),width:u.width,height:u.height}:null}if(e!==void 0&&e.length>0){const u=new Gu(t);o=new Gf(u),o.setCrossOrigin(this.crossOrigin);for(let d=0,p=e.length;d<p;d++){const m=e[d],y=m.url;if(Array.isArray(y)){const x=[];for(let v=0,w=y.length;v<w;v++){const M=y[v],S=c(M);S!==null&&(S instanceof HTMLImageElement?x.push(S):x.push(new co(S.data,S.width,S.height)))}r[m.uuid]=new lu(x)}else{const x=c(m.url);r[m.uuid]=new lu(x)}}}return r}parseImagesAsync(e){return mn(this,null,function*(){const t=this,n={};let r;function o(a){return mn(this,null,function*(){if(typeof a=="string"){const c=a,u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(c)?c:t.resourcePath+c;return yield r.loadAsync(u)}else return a.data?{data:su(a.type,a.data),width:a.width,height:a.height}:null})}if(e!==void 0&&e.length>0){r=new Gf(this.manager),r.setCrossOrigin(this.crossOrigin);for(let a=0,c=e.length;a<c;a++){const u=e[a],d=u.url;if(Array.isArray(d)){const p=[];for(let m=0,y=d.length;m<y;m++){const x=d[m],v=yield o(x);v!==null&&(v instanceof HTMLImageElement?p.push(v):p.push(new co(v.data,v.width,v.height)))}n[u.uuid]=new lu(p)}else{const p=yield o(u.url);n[u.uuid]=new lu(p)}}}return n})}parseTextures(e,t){function n(o,a){return typeof o=="number"?o:(Ie("ObjectLoader.parseTexture: Constant should be in numeric form.",o),a[o])}const r={};if(e!==void 0)for(let o=0,a=e.length;o<a;o++){const c=e[o];c.image===void 0&&Ie('ObjectLoader: No "image" specified for',c.uuid),t[c.image]===void 0&&Ie("ObjectLoader: Undefined image",c.image);const u=t[c.image],d=u.data;let p;Array.isArray(d)?(p=new nc,d.length===6&&(p.needsUpdate=!0)):(d&&d.data?p=new co:p=new fi,d&&(p.needsUpdate=!0)),p.source=u,p.uuid=c.uuid,c.name!==void 0&&(p.name=c.name),c.mapping!==void 0&&(p.mapping=n(c.mapping,Lm)),c.channel!==void 0&&(p.channel=c.channel),c.offset!==void 0&&p.offset.fromArray(c.offset),c.repeat!==void 0&&p.repeat.fromArray(c.repeat),c.center!==void 0&&p.center.fromArray(c.center),c.rotation!==void 0&&(p.rotation=c.rotation),c.wrap!==void 0&&(p.wrapS=n(c.wrap[0],B0),p.wrapT=n(c.wrap[1],B0)),c.format!==void 0&&(p.format=c.format),c.internalFormat!==void 0&&(p.internalFormat=c.internalFormat),c.type!==void 0&&(p.type=c.type),c.colorSpace!==void 0&&(p.colorSpace=c.colorSpace),c.minFilter!==void 0&&(p.minFilter=n(c.minFilter,DS)),c.magFilter!==void 0&&(p.magFilter=n(c.magFilter,DS)),c.anisotropy!==void 0&&(p.anisotropy=c.anisotropy),c.flipY!==void 0&&(p.flipY=c.flipY),c.generateMipmaps!==void 0&&(p.generateMipmaps=c.generateMipmaps),c.premultiplyAlpha!==void 0&&(p.premultiplyAlpha=c.premultiplyAlpha),c.unpackAlignment!==void 0&&(p.unpackAlignment=c.unpackAlignment),c.compareFunction!==void 0&&(p.compareFunction=c.compareFunction),c.userData!==void 0&&(p.userData=c.userData),r[c.uuid]=p}return r}parseObject(e,t,n,r,o){let a;function c(y){return t[y]===void 0&&Ie("ObjectLoader: Undefined geometry",y),t[y]}function u(y){if(y!==void 0){if(Array.isArray(y)){const x=[];for(let v=0,w=y.length;v<w;v++){const M=y[v];n[M]===void 0&&Ie("ObjectLoader: Undefined material",M),x.push(n[M])}return x}return n[y]===void 0&&Ie("ObjectLoader: Undefined material",y),n[y]}}function d(y){return r[y]===void 0&&Ie("ObjectLoader: Undefined texture",y),r[y]}let p,m;switch(e.type){case"Scene":a=new Oa,e.background!==void 0&&(Number.isInteger(e.background)?a.background=new It(e.background):a.background=d(e.background)),e.environment!==void 0&&(a.environment=d(e.environment)),e.fog!==void 0&&(e.fog.type==="Fog"?a.fog=new ic(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(a.fog=new vu(e.fog.color,e.fog.density)),e.fog.name!==""&&(a.fog.name=e.fog.name)),e.backgroundBlurriness!==void 0&&(a.backgroundBlurriness=e.backgroundBlurriness),e.backgroundIntensity!==void 0&&(a.backgroundIntensity=e.backgroundIntensity),e.backgroundRotation!==void 0&&a.backgroundRotation.fromArray(e.backgroundRotation),e.environmentIntensity!==void 0&&(a.environmentIntensity=e.environmentIntensity),e.environmentRotation!==void 0&&a.environmentRotation.fromArray(e.environmentRotation);break;case"PerspectiveCamera":a=new Bs(e.fov,e.aspect,e.near,e.far),e.focus!==void 0&&(a.focus=e.focus),e.zoom!==void 0&&(a.zoom=e.zoom),e.filmGauge!==void 0&&(a.filmGauge=e.filmGauge),e.filmOffset!==void 0&&(a.filmOffset=e.filmOffset),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"OrthographicCamera":a=new $u(e.left,e.right,e.top,e.bottom,e.near,e.far),e.zoom!==void 0&&(a.zoom=e.zoom),e.view!==void 0&&(a.view=Object.assign({},e.view));break;case"AmbientLight":a=new Im(e.color,e.intensity);break;case"DirectionalLight":a=new Hf(e.color,e.intensity),a.target=e.target||"";break;case"PointLight":a=new bx(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new Sx(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new Pm(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),a.target=e.target||"";break;case"HemisphereLight":a=new Id(e.color,e.groundColor,e.intensity);break;case"LightProbe":const y=new Mx().fromArray(e.sh);a=new LS(y,e.intensity);break;case"SkinnedMesh":p=c(e.geometry),m=u(e.material),a=new k_(p,m),e.bindMode!==void 0&&(a.bindMode=e.bindMode),e.bindMatrix!==void 0&&a.bindMatrix.fromArray(e.bindMatrix),e.skeleton!==void 0&&(a.skeleton=e.skeleton);break;case"Mesh":p=c(e.geometry),m=u(e.material),a=new Ji(p,m);break;case"InstancedMesh":p=c(e.geometry),m=u(e.material);const x=e.count,v=e.instanceMatrix,w=e.instanceColor;a=new s0(p,m,x),a.instanceMatrix=new oa(new Float32Array(v.array),16),w!==void 0&&(a.instanceColor=new oa(new Float32Array(w.array),w.itemSize));break;case"BatchedMesh":p=c(e.geometry),m=u(e.material),a=new W_(e.maxInstanceCount,e.maxVertexCount,e.maxIndexCount,m),a.geometry=p,a.perObjectFrustumCulled=e.perObjectFrustumCulled,a.sortObjects=e.sortObjects,a._drawRanges=e.drawRanges,a._reservedRanges=e.reservedRanges,a._geometryInfo=e.geometryInfo.map(M=>{let S=null,C=null;return M.boundingBox!==void 0&&(S=new ns().fromJSON(M.boundingBox)),M.boundingSphere!==void 0&&(C=new As().fromJSON(M.boundingSphere)),Mo(wi({},M),{boundingBox:S,boundingSphere:C})}),a._instanceInfo=e.instanceInfo,a._availableInstanceIds=e._availableInstanceIds,a._availableGeometryIds=e._availableGeometryIds,a._nextIndexStart=e.nextIndexStart,a._nextVertexStart=e.nextVertexStart,a._geometryCount=e.geometryCount,a._maxInstanceCount=e.maxInstanceCount,a._maxVertexCount=e.maxVertexCount,a._maxIndexCount=e.maxIndexCount,a._geometryInitialized=e.geometryInitialized,a._matricesTexture=d(e.matricesTexture.uuid),a._indirectTexture=d(e.indirectTexture.uuid),e.colorsTexture!==void 0&&(a._colorsTexture=d(e.colorsTexture.uuid)),e.boundingSphere!==void 0&&(a.boundingSphere=new As().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(a.boundingBox=new ns().fromJSON(e.boundingBox));break;case"LOD":a=new O_;break;case"Line":a=new Pu(c(e.geometry),u(e.material));break;case"LineLoop":a=new wA(c(e.geometry),u(e.material));break;case"LineSegments":a=new c0(c(e.geometry),u(e.material));break;case"PointCloud":case"Points":a=new fS(c(e.geometry),u(e.material));break;case"Sprite":a=new uS(u(e.material));break;case"Group":a=new Lo;break;case"Bone":a=new vf;break;default:a=new Zi}if(a.uuid=e.uuid,e.name!==void 0&&(a.name=e.name),e.matrix!==void 0?(a.matrix.fromArray(e.matrix),e.matrixAutoUpdate!==void 0&&(a.matrixAutoUpdate=e.matrixAutoUpdate),a.matrixAutoUpdate&&a.matrix.decompose(a.position,a.quaternion,a.scale)):(e.position!==void 0&&a.position.fromArray(e.position),e.rotation!==void 0&&a.rotation.fromArray(e.rotation),e.quaternion!==void 0&&a.quaternion.fromArray(e.quaternion),e.scale!==void 0&&a.scale.fromArray(e.scale)),e.up!==void 0&&a.up.fromArray(e.up),e.castShadow!==void 0&&(a.castShadow=e.castShadow),e.receiveShadow!==void 0&&(a.receiveShadow=e.receiveShadow),e.shadow&&(e.shadow.intensity!==void 0&&(a.shadow.intensity=e.shadow.intensity),e.shadow.bias!==void 0&&(a.shadow.bias=e.shadow.bias),e.shadow.normalBias!==void 0&&(a.shadow.normalBias=e.shadow.normalBias),e.shadow.radius!==void 0&&(a.shadow.radius=e.shadow.radius),e.shadow.mapSize!==void 0&&a.shadow.mapSize.fromArray(e.shadow.mapSize),e.shadow.camera!==void 0&&(a.shadow.camera=this.parseObject(e.shadow.camera))),e.visible!==void 0&&(a.visible=e.visible),e.frustumCulled!==void 0&&(a.frustumCulled=e.frustumCulled),e.renderOrder!==void 0&&(a.renderOrder=e.renderOrder),e.userData!==void 0&&(a.userData=e.userData),e.layers!==void 0&&(a.layers.mask=e.layers),e.children!==void 0){const y=e.children;for(let x=0;x<y.length;x++)a.add(this.parseObject(y[x],t,n,r,o))}if(e.animations!==void 0){const y=e.animations;for(let x=0;x<y.length;x++){const v=y[x];a.animations.push(o[v])}}if(e.type==="LOD"){e.autoUpdate!==void 0&&(a.autoUpdate=e.autoUpdate);const y=e.levels;for(let x=0;x<y.length;x++){const v=y[x],w=a.getObjectByProperty("uuid",v.object);w!==void 0&&a.addLevel(w,v.distance,v.hysteresis)}}return a}bindSkeletons(e,t){Object.keys(t).length!==0&&e.traverse(function(n){if(n.isSkinnedMesh===!0&&n.skeleton!==void 0){const r=t[n.skeleton];r===void 0?Ie("ObjectLoader: No skeleton found with UUID:",n.skeleton):n.bind(r,n.bindMatrix)}})}bindLightTargets(e){e.traverse(function(t){if(t.isDirectionalLight||t.isSpotLight){const n=t.target,r=e.getObjectByProperty("uuid",n);r!==void 0?t.target=r:t.target=new Zi}})}}const Lm={UVMapping:_h,CubeReflectionMapping:Cr,CubeRefractionMapping:Xo,EquirectangularReflectionMapping:jc,EquirectangularRefractionMapping:Yc,CubeUVReflectionMapping:Fl},B0={RepeatWrapping:Ea,ClampToEdgeWrapping:ki,MirroredRepeatWrapping:Ca},DS={NearestFilter:ni,NearestMipmapNearestFilter:Pp,NearestMipmapLinearFilter:Ra,LinearFilter:Yn,LinearMipmapNearestFilter:Zc,LinearMipmapLinearFilter:Vs},Dm=new WeakMap;class FS extends null{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap=="undefined"&&Ie("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch=="undefined"&&Ie("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(e){return this.options=e,this}load(e,t,n,r){e===void 0&&(e=""),this.path!==void 0&&(e=this.path+e),e=this.manager.resolveURL(e);const o=this,a=mc.get(`image-bitmap:${e}`);if(a!==void 0){if(o.manager.itemStart(e),a.then){a.then(d=>{if(Dm.has(a)===!0)r&&r(Dm.get(a)),o.manager.itemError(e),o.manager.itemEnd(e);else return t&&t(d),o.manager.itemEnd(e),d});return}return setTimeout(function(){t&&t(a),o.manager.itemEnd(e)},0),a}const c={};c.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",c.headers=this.requestHeader,c.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const u=fetch(e,c).then(function(d){return d.blob()}).then(function(d){return createImageBitmap(d,Object.assign(o.options,{colorSpaceConversion:"none"}))}).then(function(d){return mc.add(`image-bitmap:${e}`,d),t&&t(d),o.manager.itemEnd(e),d}).catch(function(d){r&&r(d),Dm.set(u,d),mc.remove(`image-bitmap:${e}`),o.manager.itemError(e),o.manager.itemEnd(e)});mc.add(`image-bitmap:${e}`,u),o.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let Wa;class BS{static getContext(){return Wa===void 0&&(Wa=new(window.AudioContext||window.webkitAudioContext)),Wa}static setContext(e){Wa=e}}class YL extends null{constructor(e){super(e)}load(e,t,n,r){const o=this,a=new Wu(this.manager);a.setResponseType("arraybuffer"),a.setPath(this.path),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(u){try{const d=u.slice(0);BS.getContext().decodeAudioData(d,function(m){t(m)}).catch(c)}catch(d){c(d)}},n,r);function c(u){r?r(u):Be(u),o.manager.itemError(e)}}}const wx=new Qt,_c=new Qt,_l=new Qt;class NA{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Bs,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Bs,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1,this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}update(e){const t=this._cache;if(t.focus!==e.focus||t.fov!==e.fov||t.aspect!==e.aspect*this.aspect||t.near!==e.near||t.far!==e.far||t.zoom!==e.zoom||t.eyeSep!==this.eyeSep){t.focus=e.focus,t.fov=e.fov,t.aspect=e.aspect*this.aspect,t.near=e.near,t.far=e.far,t.zoom=e.zoom,t.eyeSep=this.eyeSep,_l.copy(e.projectionMatrix);const r=t.eyeSep/2,o=r*t.near/t.focus,a=t.near*Math.tan(ru*t.fov*.5)/t.zoom;let c,u;_c.elements[12]=-r,wx.elements[12]=r,c=-a*t.aspect+o,u=a*t.aspect+o,_l.elements[0]=2*t.near/(u-c),_l.elements[8]=(u+c)/(u-c),this.cameraL.projectionMatrix.copy(_l),c=-a*t.aspect-o,u=a*t.aspect-o,_l.elements[0]=2*t.near/(u-c),_l.elements[8]=(u+c)/(u-c),this.cameraR.projectionMatrix.copy(_l)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(_c),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(wx)}}class xc extends Bs{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class xl{constructor(e=!0){this.autoStart=e,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 e=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const t=performance.now();e=(t-this.oldTime)/1e3,this.oldTime=t,this.elapsedTime+=e}return e}}const Ld=new H,Ax=new Gs,qu=new H,vc=new H,Xu=new H;class Dd extends null{constructor(){super(),this.type="AudioListener",this.context=BS.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new xl}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(e){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=e,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}updateMatrixWorld(e){super.updateMatrixWorld(e);const t=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(Ld,Ax,qu),vc.set(0,0,-1).applyQuaternion(Ax),Xu.set(0,1,0).applyQuaternion(Ax),t.positionX){const n=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(Ld.x,n),t.positionY.linearRampToValueAtTime(Ld.y,n),t.positionZ.linearRampToValueAtTime(Ld.z,n),t.forwardX.linearRampToValueAtTime(vc.x,n),t.forwardY.linearRampToValueAtTime(vc.y,n),t.forwardZ.linearRampToValueAtTime(vc.z,n),t.upX.linearRampToValueAtTime(Xu.x,n),t.upY.linearRampToValueAtTime(Xu.y,n),t.upZ.linearRampToValueAtTime(Xu.z,n)}else t.setPosition(Ld.x,Ld.y,Ld.z),t.setOrientation(vc.x,vc.y,vc.z,Xu.x,Xu.y,Xu.z)}}class ZL extends null{constructor(e){super(),this.type="Audio",this.listener=e,this.context=e.context,this.gain=this.context.createGain(),this.gain.connect(e.getInput()),this.autoplay=!1,this.buffer=null,this.detune=0,this.loop=!1,this.loopStart=0,this.loopEnd=0,this.offset=0,this.duration=void 0,this.playbackRate=1,this.isPlaying=!1,this.hasPlaybackControl=!0,this.source=null,this.sourceType="empty",this._startedAt=0,this._progress=0,this._connected=!1,this.filters=[]}getOutput(){return this.gain}setNodeSource(e){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=e,this.connect(),this}setMediaElementSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(e),this.connect(),this}setMediaStreamSource(e){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(e),this.connect(),this}setBuffer(e){return this.buffer=e,this.sourceType="buffer",this.autoplay&&this.play(),this}play(e=0){if(this.isPlaying===!0){Ie("Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){Ie("Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+e;const t=this.context.createBufferSource();return t.buffer=this.buffer,t.loop=this.loop,t.loopStart=this.loopStart,t.loopEnd=this.loopEnd,t.onended=this.onEnded.bind(this),t.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=t,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){Ie("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(e=0){if(this.hasPlaybackControl===!1){Ie("Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+e),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let e=1,t=this.filters.length;e<t;e++)this.filters[e-1].connect(this.filters[e]);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 e=1,t=this.filters.length;e<t;e++)this.filters[e-1].disconnect(this.filters[e]);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(e){return e||(e=[]),this._connected===!0?(this.disconnect(),this.filters=e.slice(),this.connect()):this.filters=e.slice(),this}setDetune(e){return this.detune=e,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(e){return this.setFilters(e?[e]:[])}setPlaybackRate(e){if(this.hasPlaybackControl===!1){Ie("Audio: this Audio has no playback control.");return}return this.playbackRate=e,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?(Ie("Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){Ie("Audio: this Audio has no playback control.");return}return this.loop=e,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(e){return this.loopStart=e,this}setLoopEnd(e){return this.loopEnd=e,this}getVolume(){return this.gain.gain.value}setVolume(e){return this.gain.gain.setTargetAtTime(e,this.context.currentTime,.01),this}copy(e,t){return super.copy(e,t),e.sourceType!=="buffer"?(Ie("Audio: Audio source type cannot be copied."),this):(this.autoplay=e.autoplay,this.buffer=e.buffer,this.detune=e.detune,this.loop=e.loop,this.loopStart=e.loopStart,this.loopEnd=e.loopEnd,this.offset=e.offset,this.duration=e.duration,this.playbackRate=e.playbackRate,this.hasPlaybackControl=e.hasPlaybackControl,this.sourceType=e.sourceType,this.filters=e.filters.slice(),this)}clone(e){return new this.constructor(this.listener).copy(this,e)}}const Fd=new H,Ex=new Gs,O0=new H,ju=new H;class Cx extends null{constructor(e){super(e),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(e){return this.panner.refDistance=e,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(e){return this.panner.rolloffFactor=e,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(e){return this.panner.distanceModel=e,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(e){return this.panner.maxDistance=e,this}setDirectionalCone(e,t,n){return this.panner.coneInnerAngle=e,this.panner.coneOuterAngle=t,this.panner.coneOuterGain=n,this}updateMatrixWorld(e){if(super.updateMatrixWorld(e),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(Fd,Ex,O0),ju.set(0,0,1).applyQuaternion(Ex);const t=this.panner;if(t.positionX){const n=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(Fd.x,n),t.positionY.linearRampToValueAtTime(Fd.y,n),t.positionZ.linearRampToValueAtTime(Fd.z,n),t.orientationX.linearRampToValueAtTime(ju.x,n),t.orientationY.linearRampToValueAtTime(ju.y,n),t.orientationZ.linearRampToValueAtTime(ju.z,n)}else t.setPosition(Fd.x,Fd.y,Fd.z),t.setOrientation(ju.x,ju.y,ju.z)}}class PA{constructor(e,t=2048){this.analyser=e.context.createAnalyser(),this.analyser.fftSize=t,this.data=new Uint8Array(this.analyser.frequencyBinCount),e.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let e=0;const t=this.getFrequencyData();for(let n=0;n<t.length;n++)e+=t[n];return e/t.length}}class OS{constructor(e,t,n){this.binding=e,this.valueSize=n;let r,o,a;switch(t){case"quaternion":r=this._slerp,o=this._slerpAdditive,a=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(n*6),this._workIndex=5;break;case"string":case"bool":r=this._select,o=this._select,a=this._setAdditiveIdentityOther,this.buffer=new Array(n*5);break;default:r=this._lerp,o=this._lerpAdditive,a=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(n*5)}this._mixBufferRegion=r,this._mixBufferRegionAdditive=o,this._setIdentity=a,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(e,t){const n=this.buffer,r=this.valueSize,o=e*r+r;let a=this.cumulativeWeight;if(a===0){for(let c=0;c!==r;++c)n[o+c]=n[c];a=t}else{a+=t;const c=t/a;this._mixBufferRegion(n,o,0,c,r)}this.cumulativeWeight=a}accumulateAdditive(e){const t=this.buffer,n=this.valueSize,r=n*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(t,r,0,e,n),this.cumulativeWeightAdditive+=e}apply(e){const t=this.valueSize,n=this.buffer,r=e*t+t,o=this.cumulativeWeight,a=this.cumulativeWeightAdditive,c=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,o<1){const u=t*this._origIndex;this._mixBufferRegion(n,r,u,1-o,t)}a>0&&this._mixBufferRegionAdditive(n,r,this._addIndex*t,1,t);for(let u=t,d=t+t;u!==d;++u)if(n[u]!==n[u+t]){c.setValue(n,r);break}}saveOriginalState(){const e=this.binding,t=this.buffer,n=this.valueSize,r=n*this._origIndex;e.getValue(t,r);for(let o=n,a=r;o!==a;++o)t[o]=t[r+o%n];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const e=this.valueSize*3;this.binding.setValue(this.buffer,e)}_setAdditiveIdentityNumeric(){const e=this._addIndex*this.valueSize,t=e+this.valueSize;for(let n=e;n<t;n++)this.buffer[n]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const e=this._origIndex*this.valueSize,t=this._addIndex*this.valueSize;for(let n=0;n<this.valueSize;n++)this.buffer[t+n]=this.buffer[e+n]}_select(e,t,n,r,o){if(r>=.5)for(let a=0;a!==o;++a)e[t+a]=e[n+a]}_slerp(e,t,n,r){Gs.slerpFlat(e,t,e,t,e,n,r)}_slerpAdditive(e,t,n,r,o){const a=this._workIndex*o;Gs.multiplyQuaternionsFlat(e,a,e,t,e,n),Gs.slerpFlat(e,t,e,t,e,a,r)}_lerp(e,t,n,r,o){const a=1-r;for(let c=0;c!==o;++c){const u=t+c;e[u]=e[u]*a+e[n+c]*r}}_lerpAdditive(e,t,n,r,o){for(let a=0;a!==o;++a){const c=t+a;e[c]=e[c]+e[n+a]*r}}}const U0="\\[\\]\\.:\\/",US=new RegExp("["+U0+"]","g"),k0="[^"+U0+"]",kS="[^"+U0.replace("\\.","")+"]",zS=/((?:WC+[\/:])*)/.source.replace("WC",k0),VS=/(WCOD+)?/.source.replace("WCOD",kS),vi=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",k0),IA=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",k0),GS=new RegExp("^"+zS+VS+vi+IA+"$"),WS=["material","materials","bones","map"];class LA{constructor(e,t,n){const r=n||Mi.parseTrackName(t);this._targetGroup=e,this._bindings=e.subscribe_(t,r)}getValue(e,t){this.bind();const n=this._targetGroup.nCachedObjects_,r=this._bindings[n];r!==void 0&&r.getValue(e,t)}setValue(e,t){const n=this._bindings;for(let r=this._targetGroup.nCachedObjects_,o=n.length;r!==o;++r)n[r].setValue(e,t)}bind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].bind()}unbind(){const e=this._bindings;for(let t=this._targetGroup.nCachedObjects_,n=e.length;t!==n;++t)e[t].unbind()}}class Mi{constructor(e,t,n){this.path=t,this.parsedPath=n||Mi.parseTrackName(t),this.node=Mi.findNode(e,this.parsedPath.nodeName),this.rootNode=e,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(e,t,n){return e&&e.isAnimationObjectGroup?new Mi.Composite(e,t,n):new Mi(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(US,"")}static parseTrackName(e){const t=GS.exec(e);if(t===null)throw new Error("PropertyBinding: Cannot parse trackName: "+e);const n={nodeName:t[2],objectName:t[3],objectIndex:t[4],propertyName:t[5],propertyIndex:t[6]},r=n.nodeName&&n.nodeName.lastIndexOf(".");if(r!==void 0&&r!==-1){const o=n.nodeName.substring(r+1);WS.indexOf(o)!==-1&&(n.nodeName=n.nodeName.substring(0,r),n.objectName=o)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+e);return n}static findNode(e,t){if(t===void 0||t===""||t==="."||t===-1||t===e.name||t===e.uuid)return e;if(e.skeleton){const n=e.skeleton.getBoneByName(t);if(n!==void 0)return n}if(e.children){const n=function(o){for(let a=0;a<o.length;a++){const c=o[a];if(c.name===t||c.uuid===t)return c;const u=n(c.children);if(u)return u}return null},r=n(e.children);if(r)return r}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(e,t){e[t]=this.targetObject[this.propertyName]}_getValue_array(e,t){const n=this.resolvedProperty;for(let r=0,o=n.length;r!==o;++r)e[t++]=n[r]}_getValue_arrayElement(e,t){e[t]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(e,t){this.resolvedProperty.toArray(e,t)}_setValue_direct(e,t){this.targetObject[this.propertyName]=e[t]}_setValue_direct_setNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(e,t){this.targetObject[this.propertyName]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(e,t){const n=this.resolvedProperty;for(let r=0,o=n.length;r!==o;++r)n[r]=e[t++]}_setValue_array_setNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,o=n.length;r!==o;++r)n[r]=e[t++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(e,t){const n=this.resolvedProperty;for(let r=0,o=n.length;r!==o;++r)n[r]=e[t++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(e,t){this.resolvedProperty[this.propertyIndex]=e[t]}_setValue_arrayElement_setNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty[this.propertyIndex]=e[t],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(e,t){this.resolvedProperty.fromArray(e,t)}_setValue_fromArray_setNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(e,t){this.resolvedProperty.fromArray(e,t),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(e,t){this.bind(),this.getValue(e,t)}_setValue_unbound(e,t){this.bind(),this.setValue(e,t)}bind(){let e=this.node;const t=this.parsedPath,n=t.objectName,r=t.propertyName;let o=t.propertyIndex;if(e||(e=Mi.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){Ie("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let d=t.objectIndex;switch(n){case"materials":if(!e.material){Be("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){Be("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}e=e.material.materials;break;case"bones":if(!e.skeleton){Be("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}e=e.skeleton.bones;for(let p=0;p<e.length;p++)if(e[p].name===d){d=p;break}break;case"map":if("map"in e){e=e.map;break}if(!e.material){Be("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){Be("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}e=e.material.map;break;default:if(e[n]===void 0){Be("PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(d!==void 0){if(e[d]===void 0){Be("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,e);return}e=e[d]}}const a=e[r];if(a===void 0){const d=t.nodeName;Be("PropertyBinding: Trying to update property for track: "+d+"."+r+" but it wasn't found.",e);return}let c=this.Versioning.None;this.targetObject=e,e.isMaterial===!0?c=this.Versioning.NeedsUpdate:e.isObject3D===!0&&(c=this.Versioning.MatrixWorldNeedsUpdate);let u=this.BindingType.Direct;if(o!==void 0){if(r==="morphTargetInfluences"){if(!e.geometry){Be("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){Be("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}e.morphTargetDictionary[o]!==void 0&&(o=e.morphTargetDictionary[o])}u=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=o}else a.fromArray!==void 0&&a.toArray!==void 0?(u=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(u=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=r;this.getValue=this.GetterByBindingType[u],this.setValue=this.SetterByBindingTypeAndVersioning[u][c]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}Mi.Composite=LA,Mi.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Mi.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},Mi.prototype.GetterByBindingType=[Mi.prototype._getValue_direct,Mi.prototype._getValue_array,Mi.prototype._getValue_arrayElement,Mi.prototype._getValue_toArray],Mi.prototype.SetterByBindingTypeAndVersioning=[[Mi.prototype._setValue_direct,Mi.prototype._setValue_direct_setNeedsUpdate,Mi.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[Mi.prototype._setValue_array,Mi.prototype._setValue_array_setNeedsUpdate,Mi.prototype._setValue_array_setMatrixWorldNeedsUpdate],[Mi.prototype._setValue_arrayElement,Mi.prototype._setValue_arrayElement_setNeedsUpdate,Mi.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[Mi.prototype._setValue_fromArray,Mi.prototype._setValue_fromArray_setNeedsUpdate,Mi.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class HS{constructor(){this.isAnimationObjectGroup=!0,this.uuid=so(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const e={};this._indicesByUUID=e;for(let n=0,r=arguments.length;n!==r;++n)e[arguments[n].uuid]=n;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const t=this;this.stats={objects:{get total(){return t._objects.length},get inUse(){return this.total-t.nCachedObjects_}},get bindingsPerObject(){return t._bindings.length}}}add(){const e=this._objects,t=this._indicesByUUID,n=this._paths,r=this._parsedPaths,o=this._bindings,a=o.length;let c,u=e.length,d=this.nCachedObjects_;for(let p=0,m=arguments.length;p!==m;++p){const y=arguments[p],x=y.uuid;let v=t[x];if(v===void 0){v=u++,t[x]=v,e.push(y);for(let w=0,M=a;w!==M;++w)o[w].push(new Mi(y,n[w],r[w]))}else if(v<d){c=e[v];const w=--d,M=e[w];t[M.uuid]=v,e[v]=M,t[x]=w,e[w]=y;for(let S=0,C=a;S!==C;++S){const N=o[S],I=N[w];let U=N[v];N[v]=I,U===void 0&&(U=new Mi(y,n[S],r[S])),N[w]=U}}else e[v]!==c&&Be("AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=d}remove(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length;let o=this.nCachedObjects_;for(let a=0,c=arguments.length;a!==c;++a){const u=arguments[a],d=u.uuid,p=t[d];if(p!==void 0&&p>=o){const m=o++,y=e[m];t[y.uuid]=p,e[p]=y,t[d]=m,e[m]=u;for(let x=0,v=r;x!==v;++x){const w=n[x],M=w[m],S=w[p];w[p]=M,w[m]=S}}}this.nCachedObjects_=o}uncache(){const e=this._objects,t=this._indicesByUUID,n=this._bindings,r=n.length;let o=this.nCachedObjects_,a=e.length;for(let c=0,u=arguments.length;c!==u;++c){const d=arguments[c],p=d.uuid,m=t[p];if(m!==void 0)if(delete t[p],m<o){const y=--o,x=e[y],v=--a,w=e[v];t[x.uuid]=m,e[m]=x,t[w.uuid]=y,e[y]=w,e.pop();for(let M=0,S=r;M!==S;++M){const C=n[M],N=C[y],I=C[v];C[m]=N,C[y]=I,C.pop()}}else{const y=--a,x=e[y];y>0&&(t[x.uuid]=m),e[m]=x,e.pop();for(let v=0,w=r;v!==w;++v){const M=n[v];M[m]=M[y],M.pop()}}}this.nCachedObjects_=o}subscribe_(e,t){const n=this._bindingsIndicesByPath;let r=n[e];const o=this._bindings;if(r!==void 0)return o[r];const a=this._paths,c=this._parsedPaths,u=this._objects,d=u.length,p=this.nCachedObjects_,m=new Array(d);r=o.length,n[e]=r,a.push(e),c.push(t),o.push(m);for(let y=p,x=u.length;y!==x;++y){const v=u[y];m[y]=new Mi(v,e,t)}return m}unsubscribe_(e){const t=this._bindingsIndicesByPath,n=t[e];if(n!==void 0){const r=this._paths,o=this._parsedPaths,a=this._bindings,c=a.length-1,u=a[c],d=e[c];t[d]=n,a[n]=u,a.pop(),o[n]=o[c],o.pop(),r[n]=r[c],r.pop()}}}class $S{constructor(e,t,n=null,r=t.blendMode){this._mixer=e,this._clip=t,this._localRoot=n,this.blendMode=r;const o=t.tracks,a=o.length,c=new Array(a),u={endingStart:nu,endingEnd:nu};for(let d=0;d!==a;++d){const p=o[d].createInterpolant(null);c[d]=p,p.settings=u}this._interpolantSettings=u,this._interpolants=c,this._propertyBindings=new Array(a),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Lg,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(e){return this._startTime=e,this}setLoop(e,t){return this.loop=e,this.repetitions=t,this}setEffectiveWeight(e){return this.weight=e,this._effectiveWeight=this.enabled?e:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(e){return this._scheduleFading(e,0,1)}fadeOut(e){return this._scheduleFading(e,1,0)}crossFadeFrom(e,t,n=!1){if(e.fadeOut(t),this.fadeIn(t),n===!0){const r=this._clip.duration,o=e._clip.duration,a=o/r,c=r/o;e.warp(1,a,t),this.warp(c,1,t)}return this}crossFadeTo(e,t,n=!1){return e.crossFadeFrom(this,t,n)}stopFading(){const e=this._weightInterpolant;return e!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}setEffectiveTimeScale(e){return this.timeScale=e,this._effectiveTimeScale=this.paused?0:e,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(e){return this.timeScale=this._clip.duration/e,this.stopWarping()}syncWith(e){return this.time=e.time,this.timeScale=e.timeScale,this.stopWarping()}halt(e){return this.warp(this._effectiveTimeScale,0,e)}warp(e,t,n){const r=this._mixer,o=r.time,a=this.timeScale;let c=this._timeScaleInterpolant;c===null&&(c=r._lendControlInterpolant(),this._timeScaleInterpolant=c);const u=c.parameterPositions,d=c.sampleValues;return u[0]=o,u[1]=o+n,d[0]=e/a,d[1]=t/a,this}stopWarping(){const e=this._timeScaleInterpolant;return e!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(e)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(e,t,n,r){if(!this.enabled){this._updateWeight(e);return}const o=this._startTime;if(o!==null){const u=(e-o)*n;u<0||n===0?t=0:(this._startTime=null,t=n*u)}t*=this._updateTimeScale(e);const a=this._updateTime(t),c=this._updateWeight(e);if(c>0){const u=this._interpolants,d=this._propertyBindings;switch(this.blendMode){case f_:for(let p=0,m=u.length;p!==m;++p)u[p].evaluate(a),d[p].accumulateAdditive(c);break;case d_:default:for(let p=0,m=u.length;p!==m;++p)u[p].evaluate(a),d[p].accumulate(r,c)}}}_updateWeight(e){let t=0;if(this.enabled){t=this.weight;const n=this._weightInterpolant;if(n!==null){const r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopFading(),r===0&&(this.enabled=!1))}}return this._effectiveWeight=t,t}_updateTimeScale(e){let t=0;if(!this.paused){t=this.timeScale;const n=this._timeScaleInterpolant;if(n!==null){const r=n.evaluate(e)[0];t*=r,e>n.parameterPositions[1]&&(this.stopWarping(),t===0?this.paused=!0:this.timeScale=t)}}return this._effectiveTimeScale=t,t}_updateTime(e){const t=this._clip.duration,n=this.loop;let r=this.time+e,o=this._loopCount;const a=n===Hh;if(e===0)return o===-1?r:a&&(o&1)===1?t-r:r;if(n===Ig){o===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(r>=t)r=t;else if(r<0)r=0;else{this.time=r;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e<0?-1:1})}}else{if(o===-1&&(e>=0?(o=0,this._setEndings(!0,this.repetitions===0,a)):this._setEndings(this.repetitions===0,!0,a)),r>=t||r<0){const c=Math.floor(r/t);r-=t*c,o+=Math.abs(c);const u=this.repetitions-o;if(u<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,r=e>0?t:0,this.time=r,this._mixer.dispatchEvent({type:"finished",action:this,direction:e>0?1:-1});else{if(u===1){const d=e<0;this._setEndings(d,!d,a)}else this._setEndings(!1,!1,a);this._loopCount=o,this.time=r,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:c})}}else this.time=r;if(a&&(o&1)===1)return t-r}return r}_setEndings(e,t,n){const r=this._interpolantSettings;n?(r.endingStart=lf,r.endingEnd=lf):(e?r.endingStart=this.zeroSlopeAtStart?lf:nu:r.endingStart=Dg,t?r.endingEnd=this.zeroSlopeAtEnd?lf:nu:r.endingEnd=Dg)}_scheduleFading(e,t,n){const r=this._mixer,o=r.time;let a=this._weightInterpolant;a===null&&(a=r._lendControlInterpolant(),this._weightInterpolant=a);const c=a.parameterPositions,u=a.sampleValues;return c[0]=o,u[0]=t,c[1]=o+e,u[1]=n,this}}const DA=new Float32Array(1);class KL extends null{constructor(e){super(),this._root=e,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(e,t){const n=e._localRoot||this._root,r=e._clip.tracks,o=r.length,a=e._propertyBindings,c=e._interpolants,u=n.uuid,d=this._bindingsByRootAndName;let p=d[u];p===void 0&&(p={},d[u]=p);for(let m=0;m!==o;++m){const y=r[m],x=y.name;let v=p[x];if(v!==void 0)++v.referenceCount,a[m]=v;else{if(v=a[m],v!==void 0){v._cacheIndex===null&&(++v.referenceCount,this._addInactiveBinding(v,u,x));continue}const w=t&&t._propertyBindings[m].binding.parsedPath;v=new OS(Mi.create(n,x,w),y.ValueTypeName,y.getValueSize()),++v.referenceCount,this._addInactiveBinding(v,u,x),a[m]=v}c[m].resultBuffer=v.buffer}}_activateAction(e){if(!this._isActiveAction(e)){if(e._cacheIndex===null){const n=(e._localRoot||this._root).uuid,r=e._clip.uuid,o=this._actionsByClip[r];this._bindAction(e,o&&o.knownActions[0]),this._addInactiveAction(e,r,n)}const t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){const o=t[n];o.useCount++===0&&(this._lendBinding(o),o.saveOriginalState())}this._lendAction(e)}}_deactivateAction(e){if(this._isActiveAction(e)){const t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){const o=t[n];--o.useCount===0&&(o.restoreOriginalState(),this._takeBackBinding(o))}this._takeBackAction(e)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const e=this;this.stats={actions:{get total(){return e._actions.length},get inUse(){return e._nActiveActions}},bindings:{get total(){return e._bindings.length},get inUse(){return e._nActiveBindings}},controlInterpolants:{get total(){return e._controlInterpolants.length},get inUse(){return e._nActiveControlInterpolants}}}}_isActiveAction(e){const t=e._cacheIndex;return t!==null&&t<this._nActiveActions}_addInactiveAction(e,t,n){const r=this._actions,o=this._actionsByClip;let a=o[t];if(a===void 0)a={knownActions:[e],actionByRoot:{}},e._byClipCacheIndex=0,o[t]=a;else{const c=a.knownActions;e._byClipCacheIndex=c.length,c.push(e)}e._cacheIndex=r.length,r.push(e),a.actionByRoot[n]=e}_removeInactiveAction(e){const t=this._actions,n=t[t.length-1],r=e._cacheIndex;n._cacheIndex=r,t[r]=n,t.pop(),e._cacheIndex=null;const o=e._clip.uuid,a=this._actionsByClip,c=a[o],u=c.knownActions,d=u[u.length-1],p=e._byClipCacheIndex;d._byClipCacheIndex=p,u[p]=d,u.pop(),e._byClipCacheIndex=null;const m=c.actionByRoot,y=(e._localRoot||this._root).uuid;delete m[y],u.length===0&&delete a[o],this._removeInactiveBindingsForAction(e)}_removeInactiveBindingsForAction(e){const t=e._propertyBindings;for(let n=0,r=t.length;n!==r;++n){const o=t[n];--o.referenceCount===0&&this._removeInactiveBinding(o)}}_lendAction(e){const t=this._actions,n=e._cacheIndex,r=this._nActiveActions++,o=t[r];e._cacheIndex=r,t[r]=e,o._cacheIndex=n,t[n]=o}_takeBackAction(e){const t=this._actions,n=e._cacheIndex,r=--this._nActiveActions,o=t[r];e._cacheIndex=r,t[r]=e,o._cacheIndex=n,t[n]=o}_addInactiveBinding(e,t,n){const r=this._bindingsByRootAndName,o=this._bindings;let a=r[t];a===void 0&&(a={},r[t]=a),a[n]=e,e._cacheIndex=o.length,o.push(e)}_removeInactiveBinding(e){const t=this._bindings,n=e.binding,r=n.rootNode.uuid,o=n.path,a=this._bindingsByRootAndName,c=a[r],u=t[t.length-1],d=e._cacheIndex;u._cacheIndex=d,t[d]=u,t.pop(),delete c[o],Object.keys(c).length===0&&delete a[r]}_lendBinding(e){const t=this._bindings,n=e._cacheIndex,r=this._nActiveBindings++,o=t[r];e._cacheIndex=r,t[r]=e,o._cacheIndex=n,t[n]=o}_takeBackBinding(e){const t=this._bindings,n=e._cacheIndex,r=--this._nActiveBindings,o=t[r];e._cacheIndex=r,t[r]=e,o._cacheIndex=n,t[n]=o}_lendControlInterpolant(){const e=this._controlInterpolants,t=this._nActiveControlInterpolants++;let n=e[t];return n===void 0&&(n=new Vu(new Float32Array(2),new Float32Array(2),1,DA),n.__cacheIndex=t,e[t]=n),n}_takeBackControlInterpolant(e){const t=this._controlInterpolants,n=e.__cacheIndex,r=--this._nActiveControlInterpolants,o=t[r];e.__cacheIndex=r,t[r]=e,o.__cacheIndex=n,t[n]=o}clipAction(e,t,n){const r=t||this._root,o=r.uuid;let a=typeof e=="string"?Cm.findByName(r,e):e;const c=a!==null?a.uuid:e,u=this._actionsByClip[c];let d=null;if(n===void 0&&(a!==null?n=a.blendMode:n=d_),u!==void 0){const m=u.actionByRoot[o];if(m!==void 0&&m.blendMode===n)return m;d=u.knownActions[0],a===null&&(a=d._clip)}if(a===null)return null;const p=new $S(this,a,t,n);return this._bindAction(p,d),this._addInactiveAction(p,c,o),p}existingAction(e,t){const n=t||this._root,r=n.uuid,o=typeof e=="string"?Cm.findByName(n,e):e,a=o?o.uuid:e,c=this._actionsByClip[a];return c!==void 0&&c.actionByRoot[r]||null}stopAllAction(){const e=this._actions,t=this._nActiveActions;for(let n=t-1;n>=0;--n)e[n].stop();return this}update(e){e*=this.timeScale;const t=this._actions,n=this._nActiveActions,r=this.time+=e,o=Math.sign(e),a=this._accuIndex^=1;for(let d=0;d!==n;++d)t[d]._update(r,e,o,a);const c=this._bindings,u=this._nActiveBindings;for(let d=0;d!==u;++d)c[d].apply(a);return this}setTime(e){this.time=0;for(let t=0;t<this._actions.length;t++)this._actions[t].time=0;return this.update(e)}getRoot(){return this._root}uncacheClip(e){const t=this._actions,n=e.uuid,r=this._actionsByClip,o=r[n];if(o!==void 0){const a=o.knownActions;for(let c=0,u=a.length;c!==u;++c){const d=a[c];this._deactivateAction(d);const p=d._cacheIndex,m=t[t.length-1];d._cacheIndex=null,d._byClipCacheIndex=null,m._cacheIndex=p,t[p]=m,t.pop(),this._removeInactiveBindingsForAction(d)}delete r[n]}}uncacheRoot(e){const t=e.uuid,n=this._actionsByClip;for(const a in n){const c=n[a].actionByRoot,u=c[t];u!==void 0&&(this._deactivateAction(u),this._removeInactiveAction(u))}const r=this._bindingsByRootAndName,o=r[t];if(o!==void 0)for(const a in o){const c=o[a];c.restoreOriginalState(),this._removeInactiveBinding(c)}}uncacheAction(e,t){const n=this.existingAction(e,t);n!==null&&(this._deactivateAction(n),this._removeInactiveAction(n))}}class JL extends null{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isRenderTarget3D=!0,this.depth=n,this.texture=new Wl(null,e,t,n),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}}class z0{constructor(e){this.value=e}clone(){return new z0(this.value.clone===void 0?this.value:this.value.clone())}}let FA=0;class qS extends null{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:FA++}),this.name="",this.usage=jh,this.uniforms=[]}add(e){return this.uniforms.push(e),this}remove(e){const t=this.uniforms.indexOf(e);return t!==-1&&this.uniforms.splice(t,1),this}setName(e){return this.name=e,this}setUsage(e){return this.usage=e,this}dispose(){this.dispatchEvent({type:"dispose"})}copy(e){this.name=e.name,this.usage=e.usage;const t=e.uniforms;this.uniforms.length=0;for(let n=0,r=t.length;n<r;n++){const o=Array.isArray(t[n])?t[n]:[t[n]];for(let a=0;a<o.length;a++)this.uniforms.push(o[a].clone())}return this}clone(){return new this.constructor().copy(this)}}class V0 extends ml{constructor(e,t,n=1){super(e,t),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=n}copy(e){return super.copy(e),this.meshPerAttribute=e.meshPerAttribute,this}clone(e){const t=super.clone(e);return t.meshPerAttribute=this.meshPerAttribute,t}toJSON(e){const t=super.toJSON(e);return t.isInstancedInterleavedBuffer=!0,t.meshPerAttribute=this.meshPerAttribute,t}}class QL{constructor(e,t,n,r,o,a=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=e,this.type=t,this.itemSize=n,this.elementSize=r,this.count=o,this.normalized=a,this.version=0}set needsUpdate(e){e===!0&&this.version++}setBuffer(e){return this.buffer=e,this}setType(e,t){return this.type=e,this.elementSize=t,this}setItemSize(e){return this.itemSize=e,this}setCount(e){return this.count=e,this}}const Rx=new Qt;class XS{constructor(e,t,n=0,r=1/0){this.ray=new nr(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new Hg,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,(t.near+t.far)/(t.near-t.far)).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):Be("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Rx.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Rx),this}intersectObject(e,t=!0,n=[]){return Fm(e,this,n,t),n.sort(jS),n}intersectObjects(e,t=!0,n=[]){for(let r=0,o=e.length;r<o;r++)Fm(e[r],this,n,t);return n.sort(jS),n}}function jS(i,e){return i.distance-e.distance}function Fm(i,e,t,n){let r=!0;if(i.layers.test(e.layers)&&i.raycast(e,t)===!1&&(r=!1),r===!0&&n===!0){const o=i.children;for(let a=0,c=o.length;a<c;a++)Fm(o[a],e,t,!0)}}class YS{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(e){this._document=e,e.hidden!==void 0&&(this._pageVisibilityHandler=BA.bind(this),e.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(e){return this._timescale=e,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(e){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(e!==void 0?e:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}}function BA(){this._document.hidden===!1&&this.reset()}class G0{constructor(e=1,t=0,n=0){this.radius=e,this.phi=t,this.theta=n}set(e,t,n){return this.radius=e,this.phi=t,this.theta=n,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Vn(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+t*t+n*n),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,n),this.phi=Math.acos(Vn(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class W0{constructor(e=1,t=0,n=0){this.radius=e,this.theta=t,this.y=n}set(e,t,n){return this.radius=e,this.theta=t,this.y=n,this}copy(e){return this.radius=e.radius,this.theta=e.theta,this.y=e.y,this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,n){return this.radius=Math.sqrt(e*e+n*n),this.theta=Math.atan2(e,n),this.y=t,this}clone(){return new this.constructor().copy(this)}}class vl{constructor(e,t,n,r){vl.prototype.isMatrix2=!0,this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,r)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,r){const o=this.elements;return o[0]=e,o[2]=t,o[1]=n,o[3]=r,this}}const Yu=new ze;class Nx{constructor(e=new ze(1/0,1/0),t=new ze(-1/0,-1/0)){this.isBox2=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=Yu.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.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(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Yu).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}}const Px=new H,Bm=new H,$f=new H,Zu=new H,Ix=new H,bc=new H,Om=new H;class Lx{constructor(e=new H,t=new H){this.start=e,this.end=t}set(e,t){return this.start.copy(e),this.end.copy(t),this}copy(e){return this.start.copy(e.start),this.end.copy(e.end),this}getCenter(e){return e.addVectors(this.start,this.end).multiplyScalar(.5)}delta(e){return e.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(e,t){return this.delta(t).multiplyScalar(e).add(this.start)}closestPointToPointParameter(e,t){Px.subVectors(e,this.start),Bm.subVectors(this.end,this.start);const n=Bm.dot(Bm);let o=Bm.dot(Px)/n;return t&&(o=Vn(o,0,1)),o}closestPointToPoint(e,t,n){const r=this.closestPointToPointParameter(e,t);return this.delta(n).multiplyScalar(r).add(this.start)}distanceSqToLine3(e,t=bc,n=Om){const r=10000000000000001e-32;let o,a;const c=this.start,u=e.start,d=this.end,p=e.end;$f.subVectors(d,c),Zu.subVectors(p,u),Ix.subVectors(c,u);const m=$f.dot($f),y=Zu.dot(Zu),x=Zu.dot(Ix);if(m<=r&&y<=r)return t.copy(c),n.copy(u),t.sub(n),t.dot(t);if(m<=r)o=0,a=x/y,a=Vn(a,0,1);else{const v=$f.dot(Ix);if(y<=r)a=0,o=Vn(-v/m,0,1);else{const w=$f.dot(Zu),M=m*y-w*w;M!==0?o=Vn((w*x-v*y)/M,0,1):o=0,a=(w*o+x)/y,a<0?(a=0,o=Vn(-v/m,0,1)):a>1&&(a=1,o=Vn((w-v)/m,0,1))}}return t.copy(c).add($f.multiplyScalar(o)),n.copy(u).add(Zu.multiplyScalar(a)),t.sub(n),t.dot(t)}applyMatrix4(e){return this.start.applyMatrix4(e),this.end.applyMatrix4(e),this}equals(e){return e.start.equals(this.start)&&e.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const ZS=new H;class KS extends null{constructor(e,t){super(),this.light=e,this.matrixAutoUpdate=!1,this.color=t,this.type="SpotLightHelper";const n=new Gn,r=[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 a=0,c=1,u=32;a<u;a++,c++){const d=a/u*Math.PI*2,p=c/u*Math.PI*2;r.push(Math.cos(d),Math.sin(d),1,Math.cos(p),Math.sin(p),1)}n.setAttribute("position",new ht(r,3));const o=new js({fog:!1,toneMapped:!1});this.cone=new c0(n,o),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 e=this.light.distance?this.light.distance:1e3,t=e*Math.tan(this.light.angle);this.cone.scale.set(t,t,e),ZS.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(ZS),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const Ku=new H,Um=new Qt,km=new Qt;class JS extends null{constructor(e){const t=QS(e),n=new Gn,r=[],o=[];for(let d=0;d<t.length;d++){const p=t[d];p.parent&&p.parent.isBone&&(r.push(0,0,0),r.push(0,0,0),o.push(0,0,0),o.push(0,0,0))}n.setAttribute("position",new ht(r,3)),n.setAttribute("color",new ht(o,3));const a=new js({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(n,a),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=e,this.bones=t,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1;const c=new It(255),u=new It(65280);this.setColors(c,u)}updateMatrixWorld(e){const t=this.bones,n=this.geometry,r=n.getAttribute("position");km.copy(this.root.matrixWorld).invert();for(let o=0,a=0;o<t.length;o++){const c=t[o];c.parent&&c.parent.isBone&&(Um.multiplyMatrices(km,c.matrixWorld),Ku.setFromMatrixPosition(Um),r.setXYZ(a,Ku.x,Ku.y,Ku.z),Um.multiplyMatrices(km,c.parent.matrixWorld),Ku.setFromMatrixPosition(Um),r.setXYZ(a+1,Ku.x,Ku.y,Ku.z),a+=2)}n.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(e)}setColors(e,t){const r=this.geometry.getAttribute("color");for(let o=0;o<r.count;o+=2)r.setXYZ(o,e.r,e.g,e.b),r.setXYZ(o+1,t.r,t.g,t.b);return r.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}function QS(i){const e=[];i.isBone===!0&&e.push(i);for(let t=0;t<i.children.length;t++)e.push(...QS(i.children[t]));return e}class eD extends null{constructor(e,t,n){const r=new ku(t,4,2),o=new Or({wireframe:!0,fog:!1,toneMapped:!1});super(r,o),this.light=e,this.color=n,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 OA=new H,H0=new It,qf=new It;class eM extends null{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="HemisphereLightHelper";const r=new Ad(t);r.rotateY(Math.PI*.5),this.material=new Or({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const o=r.getAttribute("position"),a=new Float32Array(o.count*3);r.setAttribute("color",new $i(a,3)),this.add(new Ji(r,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const e=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const t=e.geometry.getAttribute("color");H0.copy(this.light.color),qf.copy(this.light.groundColor);for(let n=0,r=t.count;n<r;n++){const o=n<r/2?H0:qf;t.setXYZ(n,o.r,o.g,o.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(OA.setFromMatrixPosition(this.light.matrixWorld).negate())}}class tD extends null{constructor(e=10,t=10,n=4473924,r=8947848){n=new It(n),r=new It(r);const o=t/2,a=e/t,c=e/2,u=[],d=[];for(let y=0,x=0,v=-c;y<=t;y++,v+=a){u.push(-c,0,v,c,0,v),u.push(v,0,-c,v,0,c);const w=y===o?n:r;w.toArray(d,x),x+=3,w.toArray(d,x),x+=3,w.toArray(d,x),x+=3,w.toArray(d,x),x+=3}const p=new Gn;p.setAttribute("position",new ht(u,3)),p.setAttribute("color",new ht(d,3));const m=new js({vertexColors:!0,toneMapped:!1});super(p,m),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class $0 extends null{constructor(e=10,t=16,n=8,r=64,o=4473924,a=8947848){o=new It(o),a=new It(a);const c=[],u=[];if(t>1)for(let m=0;m<t;m++){const y=m/t*(Math.PI*2),x=Math.sin(y)*e,v=Math.cos(y)*e;c.push(0,0,0),c.push(x,0,v);const w=m&1?o:a;u.push(w.r,w.g,w.b),u.push(w.r,w.g,w.b)}for(let m=0;m<n;m++){const y=m&1?o:a,x=e-e/n*m;for(let v=0;v<r;v++){let w=v/r*(Math.PI*2),M=Math.sin(w)*x,S=Math.cos(w)*x;c.push(M,0,S),u.push(y.r,y.g,y.b),w=(v+1)/r*(Math.PI*2),M=Math.sin(w)*x,S=Math.cos(w)*x,c.push(M,0,S),u.push(y.r,y.g,y.b)}}const d=new Gn;d.setAttribute("position",new ht(c,3)),d.setAttribute("color",new ht(u,3));const p=new js({vertexColors:!0,toneMapped:!1});super(d,p),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const cs=new H,q0=new H,ps=new H;class X0 extends null{constructor(e,t,n){super(),this.light=e,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.color=n,this.type="DirectionalLightHelper",t===void 0&&(t=1);let r=new Gn;r.setAttribute("position",new ht([-t,t,0,t,t,0,t,-t,0,-t,-t,0,-t,t,0],3));const o=new js({fog:!1,toneMapped:!1});this.lightPlane=new Pu(r,o),this.add(this.lightPlane),r=new Gn,r.setAttribute("position",new ht([0,0,0,0,0,1],3)),this.targetLine=new Pu(r,o),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),cs.setFromMatrixPosition(this.light.matrixWorld),q0.setFromMatrixPosition(this.light.target.matrixWorld),ps.subVectors(q0,cs),this.lightPlane.lookAt(q0),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(q0),this.targetLine.scale.z=ps.length()}}const j0=new H,Rs=new ld;class nD extends null{constructor(e){const t=new Gn,n=new js({color:16777215,vertexColors:!0,toneMapped:!1}),r=[],o=[],a={};c("n1","n2"),c("n2","n4"),c("n4","n3"),c("n3","n1"),c("f1","f2"),c("f2","f4"),c("f4","f3"),c("f3","f1"),c("n1","f1"),c("n2","f2"),c("n3","f3"),c("n4","f4"),c("p","n1"),c("p","n2"),c("p","n3"),c("p","n4"),c("u1","u2"),c("u2","u3"),c("u3","u1"),c("c","t"),c("p","c"),c("cn1","cn2"),c("cn3","cn4"),c("cf1","cf2"),c("cf3","cf4");function c(v,w){u(v),u(w)}function u(v){r.push(0,0,0),o.push(0,0,0),a[v]===void 0&&(a[v]=[]),a[v].push(r.length/3-1)}t.setAttribute("position",new ht(r,3)),t.setAttribute("color",new ht(o,3)),super(t,n),this.type="CameraHelper",this.camera=e,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=a,this.update();const d=new It(16755200),p=new It(16711680),m=new It(43775),y=new It(16777215),x=new It(3355443);this.setColors(d,p,m,y,x)}setColors(e,t,n,r,o){const c=this.geometry.getAttribute("color");return c.setXYZ(0,e.r,e.g,e.b),c.setXYZ(1,e.r,e.g,e.b),c.setXYZ(2,e.r,e.g,e.b),c.setXYZ(3,e.r,e.g,e.b),c.setXYZ(4,e.r,e.g,e.b),c.setXYZ(5,e.r,e.g,e.b),c.setXYZ(6,e.r,e.g,e.b),c.setXYZ(7,e.r,e.g,e.b),c.setXYZ(8,e.r,e.g,e.b),c.setXYZ(9,e.r,e.g,e.b),c.setXYZ(10,e.r,e.g,e.b),c.setXYZ(11,e.r,e.g,e.b),c.setXYZ(12,e.r,e.g,e.b),c.setXYZ(13,e.r,e.g,e.b),c.setXYZ(14,e.r,e.g,e.b),c.setXYZ(15,e.r,e.g,e.b),c.setXYZ(16,e.r,e.g,e.b),c.setXYZ(17,e.r,e.g,e.b),c.setXYZ(18,e.r,e.g,e.b),c.setXYZ(19,e.r,e.g,e.b),c.setXYZ(20,e.r,e.g,e.b),c.setXYZ(21,e.r,e.g,e.b),c.setXYZ(22,e.r,e.g,e.b),c.setXYZ(23,e.r,e.g,e.b),c.setXYZ(24,t.r,t.g,t.b),c.setXYZ(25,t.r,t.g,t.b),c.setXYZ(26,t.r,t.g,t.b),c.setXYZ(27,t.r,t.g,t.b),c.setXYZ(28,t.r,t.g,t.b),c.setXYZ(29,t.r,t.g,t.b),c.setXYZ(30,t.r,t.g,t.b),c.setXYZ(31,t.r,t.g,t.b),c.setXYZ(32,n.r,n.g,n.b),c.setXYZ(33,n.r,n.g,n.b),c.setXYZ(34,n.r,n.g,n.b),c.setXYZ(35,n.r,n.g,n.b),c.setXYZ(36,n.r,n.g,n.b),c.setXYZ(37,n.r,n.g,n.b),c.setXYZ(38,r.r,r.g,r.b),c.setXYZ(39,r.r,r.g,r.b),c.setXYZ(40,o.r,o.g,o.b),c.setXYZ(41,o.r,o.g,o.b),c.setXYZ(42,o.r,o.g,o.b),c.setXYZ(43,o.r,o.g,o.b),c.setXYZ(44,o.r,o.g,o.b),c.setXYZ(45,o.r,o.g,o.b),c.setXYZ(46,o.r,o.g,o.b),c.setXYZ(47,o.r,o.g,o.b),c.setXYZ(48,o.r,o.g,o.b),c.setXYZ(49,o.r,o.g,o.b),c.needsUpdate=!0,this}update(){const e=this.geometry,t=this.pointMap,n=1,r=1;let o,a;if(Rs.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),this.camera.reversedDepth===!0)o=1,a=0;else if(this.camera.coordinateSystem===ws)o=-1,a=1;else if(this.camera.coordinateSystem===xr)o=0,a=1;else throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);ms("c",t,e,Rs,0,0,o),ms("t",t,e,Rs,0,0,a),ms("n1",t,e,Rs,-n,-r,o),ms("n2",t,e,Rs,n,-r,o),ms("n3",t,e,Rs,-n,r,o),ms("n4",t,e,Rs,n,r,o),ms("f1",t,e,Rs,-n,-r,a),ms("f2",t,e,Rs,n,-r,a),ms("f3",t,e,Rs,-n,r,a),ms("f4",t,e,Rs,n,r,a),ms("u1",t,e,Rs,n*.7,r*1.1,o),ms("u2",t,e,Rs,-n*.7,r*1.1,o),ms("u3",t,e,Rs,0,r*2,o),ms("cf1",t,e,Rs,-n,0,a),ms("cf2",t,e,Rs,n,0,a),ms("cf3",t,e,Rs,0,-r,a),ms("cf4",t,e,Rs,0,r,a),ms("cn1",t,e,Rs,-n,0,o),ms("cn2",t,e,Rs,n,0,o),ms("cn3",t,e,Rs,0,-r,o),ms("cn4",t,e,Rs,0,r,o),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function ms(i,e,t,n,r,o,a){j0.set(r,o,a).unproject(n);const c=e[i];if(c!==void 0){const u=t.getAttribute("position");for(let d=0,p=c.length;d<p;d++)u.setXYZ(c[d],j0.x,j0.y,j0.z)}}const Ju=new ns;class Dx extends null{constructor(e,t=16776960){const n=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]),r=new Float32Array(8*3),o=new Gn;o.setIndex(new $i(n,1)),o.setAttribute("position",new $i(r,3)),super(o,new js({color:t,toneMapped:!1})),this.object=e,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&Ju.setFromObject(this.object),Ju.isEmpty())return;const e=Ju.min,t=Ju.max,n=this.geometry.attributes.position,r=n.array;r[0]=t.x,r[1]=t.y,r[2]=t.z,r[3]=e.x,r[4]=t.y,r[5]=t.z,r[6]=e.x,r[7]=e.y,r[8]=t.z,r[9]=t.x,r[10]=e.y,r[11]=t.z,r[12]=t.x,r[13]=t.y,r[14]=e.z,r[15]=e.x,r[16]=t.y,r[17]=e.z,r[18]=e.x,r[19]=e.y,r[20]=e.z,r[21]=t.x,r[22]=e.y,r[23]=e.z,n.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(e){return this.object=e,this.update(),this}copy(e,t){return super.copy(e,t),this.object=e.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class iD extends null{constructor(e,t=16776960){const n=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]),r=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],o=new Gn;o.setIndex(new $i(n,1)),o.setAttribute("position",new ht(r,3)),super(o,new js({color:t,toneMapped:!1})),this.box=e,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(e){const t=this.box;t.isEmpty()||(t.getCenter(this.position),t.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(e))}dispose(){this.geometry.dispose(),this.material.dispose()}}class sD extends null{constructor(e,t=1,n=16776960){const r=n,o=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],a=new Gn;a.setAttribute("position",new ht(o,3)),a.computeBoundingSphere(),super(a,new js({color:r,toneMapped:!1})),this.type="PlaneHelper",this.plane=e,this.size=t;const c=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],u=new Gn;u.setAttribute("position",new ht(c,3)),u.computeBoundingSphere(),this.add(new Ji(u,new Or({color:r,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(e){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(e)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const tM=new H;let Y0,Z0;class UA extends null{constructor(e=new H(0,0,1),t=new H(0,0,0),n=1,r=16776960,o=n*.2,a=o*.2){super(),this.type="ArrowHelper",Y0===void 0&&(Y0=new Gn,Y0.setAttribute("position",new ht([0,0,0,0,1,0],3)),Z0=new Lu(.5,1,5,1),Z0.translate(0,-.5,0)),this.position.copy(t),this.line=new Pu(Y0,new js({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Ji(Z0,new Or({color:r,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(e),this.setLength(n,o,a)}setDirection(e){if(e.y>.99999)this.quaternion.set(0,0,0,1);else if(e.y<-.99999)this.quaternion.set(1,0,0,0);else{tM.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(tM,t)}}setLength(e,t=e*.2,n=t*.2){this.line.scale.set(1,Math.max(1e-4,e-t),1),this.line.updateMatrix(),this.cone.scale.set(n,t,n),this.cone.position.y=e,this.cone.updateMatrix()}setColor(e){this.line.material.color.set(e),this.cone.material.color.set(e)}copy(e){return super.copy(e,!1),this.line.copy(e.line),this.cone.copy(e.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class kA extends null{constructor(e=1){const t=[0,0,0,e,0,0,0,0,0,0,e,0,0,0,0,0,0,e],n=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],r=new Gn;r.setAttribute("position",new ht(t,3)),r.setAttribute("color",new ht(n,3));const o=new js({vertexColors:!0,toneMapped:!1});super(r,o),this.type="AxesHelper"}setColors(e,t,n){const r=new It,o=this.geometry.attributes.color.array;return r.set(e),r.toArray(o,0),r.toArray(o,3),r.set(t),r.toArray(o,6),r.toArray(o,9),r.set(n),r.toArray(o,12),r.toArray(o,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class zA{constructor(){this.type="ShapePath",this.color=new It,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new v0,this.subPaths.push(this.currentPath),this.currentPath.moveTo(e,t),this}lineTo(e,t){return this.currentPath.lineTo(e,t),this}quadraticCurveTo(e,t,n,r){return this.currentPath.quadraticCurveTo(e,t,n,r),this}bezierCurveTo(e,t,n,r,o,a){return this.currentPath.bezierCurveTo(e,t,n,r,o,a),this}splineThru(e){return this.currentPath.splineThru(e),this}toShapes(e){function t(S){const C=[];for(let N=0,I=S.length;N<I;N++){const U=S[N],F=new bd;F.curves=U.curves,C.push(F)}return C}function n(S,C){const N=C.length;let I=!1;for(let U=N-1,F=0;F<N;U=F++){let k=C[U],G=C[F],B=G.x-k.x,z=G.y-k.y;if(Math.abs(z)>Number.EPSILON){if(z<0&&(k=C[F],B=-B,G=C[U],z=-z),S.y<k.y||S.y>G.y)continue;if(S.y===k.y){if(S.x===k.x)return!0}else{const Q=z*(S.x-k.x)-B*(S.y-k.y);if(Q===0)return!0;if(Q<0)continue;I=!I}}else{if(S.y!==k.y)continue;if(G.x<=S.x&&S.x<=k.x||k.x<=S.x&&S.x<=G.x)return!0}}return I}const r=Fo.isClockWise,o=this.subPaths;if(o.length===0)return[];let a,c,u;const d=[];if(o.length===1)return c=o[0],u=new bd,u.curves=c.curves,d.push(u),d;let p=!r(o[0].getPoints());p=e?!p:p;const m=[],y=[];let x=[],v=0,w;y[v]=void 0,x[v]=[];for(let S=0,C=o.length;S<C;S++)c=o[S],w=c.getPoints(),a=r(w),a=e?!a:a,a?(!p&&y[v]&&v++,y[v]={s:new bd,p:w},y[v].s.curves=c.curves,p&&v++,x[v]=[]):x[v].push({h:c,p:w[0]});if(!y[0])return t(o);if(y.length>1){let S=!1,C=0;for(let N=0,I=y.length;N<I;N++)m[N]=[];for(let N=0,I=y.length;N<I;N++){const U=x[N];for(let F=0;F<U.length;F++){const k=U[F];let G=!0;for(let B=0;B<y.length;B++)n(k.p,y[B].p)&&(N!==B&&C++,G?(G=!1,m[B].push(k)):S=!0);G&&m[N].push(k)}}C>0&&S===!1&&(x=m)}let M;for(let S=0,C=y.length;S<C;S++){u=y[S].s,d.push(u),M=x[S];for(let N=0,I=M.length;N<I;N++)u.holes.push(M[N].h)}return d}}class zm extends Jo{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){Ie("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function VA(i,e){const t=i.image&&i.image.width?i.image.width/i.image.height:1;return t>e?(i.repeat.x=1,i.repeat.y=t/e,i.offset.x=0,i.offset.y=(1-i.repeat.y)/2):(i.repeat.x=e/t,i.repeat.y=1,i.offset.x=(1-i.repeat.x)/2,i.offset.y=0),i}function E(i,e){const t=i.image&&i.image.width?i.image.width/i.image.height:1;return t>e?(i.repeat.x=e/t,i.repeat.y=1,i.offset.x=(1-i.repeat.x)/2,i.offset.y=0):(i.repeat.x=1,i.repeat.y=t/e,i.offset.x=0,i.offset.y=(1-i.repeat.y)/2),i}function s(i){return i.repeat.x=1,i.repeat.y=1,i.offset.x=0,i.offset.y=0,i}function l(i,e,t,n){const r=h(n);switch(t){case Rg:return i*e;case Qc:return i*e/r.components*r.byteLength;case Bl:return i*e/r.components*r.byteLength;case Nr:return i*e*2/r.components*r.byteLength;case xh:return i*e*2/r.components*r.byteLength;case tf:return i*e*3/r.components*r.byteLength;case Ri:return i*e*4/r.components*r.byteLength;case vh:return i*e*4/r.components*r.byteLength;case Ol:case Ul:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case kl:case zl:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case sf:case of:return Math.max(i,16)*Math.max(e,8)/4;case nf:case rf:return Math.max(i,8)*Math.max(e,8)/2;case bh:case Sh:case Th:case wh:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Mh:case eu:case Ah:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Eh:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Ch:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case Rh:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case Nh:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case Ph:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case Ih:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case Lh:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case Dh:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case Fh:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case Bh:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case Oh:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case Uh:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case kh:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case zh:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case Vh:case Ng:case Pg:return Math.ceil(i/4)*Math.ceil(e/4)*16;case Gh:case Wh:return Math.ceil(i/4)*Math.ceil(e/4)*8;case tu:case il:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function h(i){switch(i){case Di:case Kc:return{byteLength:1,components:1};case jo:case Jc:case Hi:return{byteLength:2,components:1};case Ip:case Lp:return{byteLength:2,components:4};case yi:case er:case Si:return{byteLength:4,components:1};case Dp:case Fp:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}class f{static contain(e,t){return VA(e,t)}static cover(e,t){return E(e,t)}static fill(e){return s(e)}static getByteLength(e,t,n,r){return l(e,t,n,r)}}typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:xe}})),typeof window!="undefined"&&(window.__THREE__?Ie("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=xe);const g=new uo,_=new ze,b=new H,T=new ze,A=new ze,R=new H,P=new H,L=new Qt,D=new H,O=new H;let W=null,Z=null;const Y=[],ie={NONE:-1,PAN:0,ROTATE:1};class se extends zm{constructor(e,t,n=null){super(t,n),this.objects=e,this.recursive=!0,this.transformGroup=!1,this.rotateSpeed=1,this.raycaster=new XS,this.mouseButtons={LEFT:pe.PAN,MIDDLE:pe.PAN,RIGHT:pe.ROTATE},this.touches={ONE:ce.PAN},this._onPointerMove=de.bind(this),this._onPointerDown=ke.bind(this),this._onPointerCancel=$e.bind(this),this._onContextMenu=et.bind(this),n!==null&&this.connect(n)}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();_.x=(e.clientX-t.left)/t.width*2-1,_.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 pe.PAN:case ce.PAN:this.state=ie.PAN;break;case pe.ROTATE:case ce.ROTATE:this.state=ie.ROTATE;break;default:this.state=ie.NONE}}}function de(i){const e=this.object,t=this.domElement,n=this.raycaster;if(this.enabled!==!1){if(this._updatePointer(i),n.setFromCamera(_,e),W)this.state===ie.PAN?n.ray.intersectPlane(g,R)&&(W.position.copy(R.sub(b).applyMatrix4(L)),this.dispatchEvent({type:"drag",object:W})):this.state===ie.ROTATE&&(T.subVectors(_,A).multiplyScalar(this.rotateSpeed),W.rotateOnWorldAxis(D,T.x),W.rotateOnWorldAxis(O.normalize(),-T.y),this.dispatchEvent({type:"drag",object:W})),A.copy(_);else if(i.pointerType==="mouse"||i.pointerType==="pen")if(Y.length=0,n.setFromCamera(_,e),n.intersectObjects(this.objects,this.recursive,Y),Y.length>0){const r=Y[0].object;g.setFromNormalAndCoplanarPoint(e.getWorldDirection(g.normal),P.setFromMatrixPosition(r.matrixWorld)),Z!==r&&Z!==null&&(this.dispatchEvent({type:"hoveroff",object:Z}),t.style.cursor="auto",Z=null),Z!==r&&(this.dispatchEvent({type:"hoveron",object:r}),t.style.cursor="pointer",Z=r)}else Z!==null&&(this.dispatchEvent({type:"hoveroff",object:Z}),t.style.cursor="auto",Z=null);A.copy(_)}}function ke(i){const e=this.object,t=this.domElement,n=this.raycaster;this.enabled!==!1&&(this._updatePointer(i),this._updateState(i),Y.length=0,n.setFromCamera(_,e),n.intersectObjects(this.objects,this.recursive,Y),Y.length>0&&(this.transformGroup===!0?W=qe(Y[0].object):W=Y[0].object,g.setFromNormalAndCoplanarPoint(e.getWorldDirection(g.normal),P.setFromMatrixPosition(W.matrixWorld)),n.ray.intersectPlane(g,R)&&(this.state===ie.PAN?(L.copy(W.parent.matrixWorld).invert(),b.copy(R).sub(P.setFromMatrixPosition(W.matrixWorld)),t.style.cursor="move",this.dispatchEvent({type:"dragstart",object:W})):this.state===ie.ROTATE&&(D.set(0,1,0).applyQuaternion(e.quaternion).normalize(),O.set(1,0,0).applyQuaternion(e.quaternion).normalize(),t.style.cursor="move",this.dispatchEvent({type:"dragstart",object:W})))),A.copy(_))}function $e(){this.enabled!==!1&&(W&&(this.dispatchEvent({type:"dragend",object:W}),W=null),this.domElement.style.cursor=Z?"pointer":"auto",this.state=ie.NONE)}function et(i){this.enabled!==!1&&i.preventDefault()}function qe(i,e=null){return i.isGroup&&(e=i),i.parent===null?e:qe(i.parent,e)}var xt=re(21668),Et=re(76633),_n=re(61147),ei=re(38192),ii=re(85320);function zi(i,e,t,n){var r,o,a=(0,ii.Z)(.1),c,u;typeof i!="function"&&(i=(0,ii.Z)(+i)),e==null&&(e=0),t==null&&(t=0),n==null&&(n=0);function d(m){for(var y=0,x=r.length;y<x;++y){var v=r[y],w=v.x-e||1e-6,M=(v.y||0)-t||1e-6,S=(v.z||0)-n||1e-6,C=Math.sqrt(w*w+M*M+S*S),N=(u[y]-C)*c[y]*m/C;v.vx+=w*N,o>1&&(v.vy+=M*N),o>2&&(v.vz+=S*N)}}function p(){if(r){var m,y=r.length;for(c=new Array(y),u=new Array(y),m=0;m<y;++m)u[m]=+i(r[m],m,r),c[m]=isNaN(u[m])?0:+a(r[m],m,r)}}return d.initialize=function(m,...y){r=m,o=y.find(x=>[1,2,3].includes(x))||2,p()},d.strength=function(m){return arguments.length?(a=typeof m=="function"?m:(0,ii.Z)(+m),p(),d):a},d.radius=function(m){return arguments.length?(i=typeof m=="function"?m:(0,ii.Z)(+m),p(),d):i},d.x=function(m){return arguments.length?(e=+m,d):e},d.y=function(m){return arguments.length?(t=+m,d):t},d.z=function(m){return arguments.length?(n=+m,d):n},d}function Fi(i){dr(i);const e=Zs(i);return i.on=e.on,i.off=e.off,i.fire=e.fire,i}function Zs(i){let e=Object.create(null);return{on:function(t,n,r){if(typeof n!="function")throw new Error("callback is expected to be a function");let o=e[t];return o||(o=e[t]=[]),o.push({callback:n,ctx:r}),i},off:function(t,n){if(typeof t=="undefined")return e=Object.create(null),i;if(e[t])if(typeof n!="function")delete e[t];else{const a=e[t];for(let c=0;c<a.length;++c)a[c].callback===n&&a.splice(c,1)}return i},fire:function(t){const n=e[t];if(!n)return i;let r;arguments.length>1&&(r=Array.prototype.slice.call(arguments,1));for(let o=0;o<n.length;++o){const a=n[o];a.callback.apply(a.ctx,r)}return i}}}function dr(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 ca=gs;function gs(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,n={},r=0,o=i.multigraph?I:N,a=[],c=De,u=De,d=De,p=De,m={version:20,addNode:w,addLink:C,removeLink:G,removeNode:S,getNode:M,getNodeCount:U,getLinkCount:F,getEdgeCount:F,getLinksCount:F,getNodesCount:U,getLinks:k,forEachNode:Tt,forEachLinkedNode:Te,forEachLink:_e,beginUpdate:d,endUpdate:p,clear:ye,hasLink:z,hasNode:M,getLink:z,getLinkById:Q};return Fi(m),y(),m;function y(){var Fe=m.on;m.on=mt;function mt(){return m.beginUpdate=d=Qe,m.endUpdate=p=Mt,c=x,u=v,m.on=Fe,Fe.apply(m,arguments)}}function x(Fe,mt){a.push({link:Fe,changeType:mt})}function v(Fe,mt){a.push({node:Fe,changeType:mt})}function w(Fe,mt){if(Fe===void 0)throw new Error("Invalid node identifier");d();var wt=M(Fe);return wt?(wt.data=mt,u(wt,"update")):(wt=new Os(Fe,mt),u(wt,"add")),e.set(Fe,wt),p(),wt}function M(Fe){return e.get(Fe)}function S(Fe){var mt=M(Fe);if(!mt)return!1;d();var wt=mt.links;return wt&&(wt.forEach(B),mt.links=null),e.delete(Fe),u(mt,"remove"),p(),!0}function C(Fe,mt,wt){d();var In=M(Fe)||w(Fe),st=M(mt)||w(mt),Ee=o(Fe,mt,wt),Oe=t.has(Ee.id);return t.set(Ee.id,Ee),us(In,Ee),Fe!==mt&&us(st,Ee),c(Ee,Oe?"update":"add"),p(),Ee}function N(Fe,mt,wt){var In=kr(Fe,mt),st=t.get(In);return st?(st.data=wt,st):new Uo(Fe,mt,wt,In)}function I(Fe,mt,wt){var In=kr(Fe,mt),st=n.hasOwnProperty(In);if(st||z(Fe,mt)){st||(n[In]=0);var Ee="@"+ ++n[In];In=kr(Fe+Ee,mt+Ee)}return new Uo(Fe,mt,wt,In)}function U(){return e.size}function F(){return t.size}function k(Fe){var mt=M(Fe);return mt?mt.links:null}function G(Fe,mt){return mt!==void 0&&(Fe=z(Fe,mt)),B(Fe)}function B(Fe){if(!Fe||!t.get(Fe.id))return!1;d(),t.delete(Fe.id);var mt=M(Fe.fromId),wt=M(Fe.toId);return mt&&mt.links.delete(Fe),wt&&wt.links.delete(Fe),c(Fe,"remove"),p(),!0}function z(Fe,mt){if(!(Fe===void 0||mt===void 0))return t.get(kr(Fe,mt))}function Q(Fe){if(Fe!==void 0)return t.get(Fe)}function ye(){d(),Tt(function(Fe){S(Fe.id)}),p()}function _e(Fe){if(typeof Fe=="function")for(var mt=t.values(),wt=mt.next();!wt.done;){if(Fe(wt.value))return!0;wt=mt.next()}}function Te(Fe,mt,wt){var In=M(Fe);if(In&&In.links&&typeof mt=="function")return wt?Ne(In.links,Fe,mt):Pe(In.links,Fe,mt)}function Pe(Fe,mt,wt){for(var In,st=Fe.values(),Ee=st.next();!Ee.done;){var Oe=Ee.value,vt=Oe.fromId===mt?Oe.toId:Oe.fromId;if(In=wt(e.get(vt),Oe),In)return!0;Ee=st.next()}}function Ne(Fe,mt,wt){for(var In,st=Fe.values(),Ee=st.next();!Ee.done;){var Oe=Ee.value;if(Oe.fromId===mt&&(In=wt(e.get(Oe.toId),Oe),In))return!0;Ee=st.next()}}function De(){}function Qe(){r+=1}function Mt(){r-=1,r===0&&a.length>0&&(m.fire("changed",a),a.length=0)}function Tt(Fe){if(typeof Fe!="function")throw new Error("Function is expected to iterate over graph nodes. You passed "+Fe);for(var mt=e.values(),wt=mt.next();!wt.done;){if(Fe(wt.value))return!0;wt=mt.next()}}}function Os(i,e){this.id=i,this.links=null,this.data=e}function us(i,e){i.links?i.links.add(e):i.links=new Set([e])}function Uo(i,e,t,n){this.fromId=i,this.toId=e,this.data=t,this.id=n}function kr(i,e){return i.toString()+"\u{1F449} "+e.toString()}var Bd=re(91998);function Xf(i){var e=typeof i;return i!=null&&(e=="object"||e=="function")}var K0=Xf,nM=typeof global=="object"&&global&&global.Object===Object&&global,Fx=nM,bl=typeof self=="object"&&self&&self.Object===Object&&self,Vm=Fx||bl||Function("return this")(),Bx=Vm,Sl=function(){return Bx.Date.now()},ua=Sl,Gt=/\s/;function sn(i){for(var e=i.length;e--&&Gt.test(i.charAt(e)););return e}var on=sn,En=/^\s+/;function Tn(i){return i&&i.slice(0,on(i)+1).replace(En,"")}var bi=Tn,si=Bx.Symbol,Vi=si,ss=Object.prototype,Ks=ss.hasOwnProperty,po=ss.toString,ha=Vi?Vi.toStringTag:void 0;function mo(i){var e=Ks.call(i,ha),t=i[ha];try{i[ha]=void 0;var n=!0}catch(o){}var r=po.call(i);return n&&(e?i[ha]=t:delete i[ha]),r}var Ox=mo,Ux=Object.prototype,kx=Ux.toString;function iM(i){return kx.call(i)}var sM=iM,zx="[object Null]",Vx="[object Undefined]",GA=Vi?Vi.toStringTag:void 0;function rD(i){return i==null?i===void 0?Vx:zx:GA&&GA in Object(i)?Ox(i):sM(i)}var oD=rD;function aD(i){return i!=null&&typeof i=="object"}var lD=aD,cD="[object Symbol]";function uD(i){return typeof i=="symbol"||lD(i)&&oD(i)==cD}var hD=uD,WA=NaN,dD=/^[-+]0x[0-9a-f]+$/i,fD=/^0b[01]+$/i,pD=/^0o[0-7]+$/i,mD=parseInt;function gD(i){if(typeof i=="number")return i;if(hD(i))return WA;if(K0(i)){var e=typeof i.valueOf=="function"?i.valueOf():i;i=K0(e)?e+"":e}if(typeof i!="string")return i===0?i:+i;i=bi(i);var t=fD.test(i);return t||pD.test(i)?mD(i.slice(2),t?2:8):dD.test(i)?WA:+i}var HA=gD,yD="Expected a function",_D=Math.max,xD=Math.min;function vD(i,e,t){var n,r,o,a,c,u,d=0,p=!1,m=!1,y=!0;if(typeof i!="function")throw new TypeError(yD);e=HA(e)||0,K0(t)&&(p=!!t.leading,m="maxWait"in t,o=m?_D(HA(t.maxWait)||0,e):o,y="trailing"in t?!!t.trailing:y);function x(F){var k=n,G=r;return n=r=void 0,d=F,a=i.apply(G,k),a}function v(F){return d=F,c=setTimeout(S,e),p?x(F):a}function w(F){var k=F-u,G=F-d,B=e-k;return m?xD(B,o-G):B}function M(F){var k=F-u,G=F-d;return u===void 0||k>=e||k<0||m&&G>=o}function S(){var F=ua();if(M(F))return C(F);c=setTimeout(S,w(F))}function C(F){return c=void 0,y&&n?x(F):(n=r=void 0,a)}function N(){c!==void 0&&clearTimeout(c),d=0,n=u=r=c=void 0}function I(){return c===void 0?a:C(ua())}function U(){var F=ua(),k=M(F);if(n=arguments,r=this,u=F,k){if(c===void 0)return v(u);if(m)return clearTimeout(c),c=setTimeout(S,e),x(u)}return c===void 0&&(c=setTimeout(S,e)),a}return U.cancel=N,U.flush=I,U}var bD=vD;function $A(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t<e;t++)n[t]=i[t];return n}function SD(i){if(Array.isArray(i))return i}function MD(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")}function TD(i,e,t){return Object.defineProperty(i,"prototype",{writable:!1}),i}function wD(i,e){var t=i==null?null:typeof Symbol!="undefined"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,r,o,a,c=[],u=!0,d=!1;try{if(o=(t=t.call(i)).next,e!==0)for(;!(u=(n=o.call(t)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(p){d=!0,r=p}finally{try{if(!u&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(d)throw r}}return c}}function AD(){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 ED(i,e){return SD(i)||wD(i,e)||CD(i,e)||AD()}function CD(i,e){if(i){if(typeof i=="string")return $A(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)?$A(i,e):void 0}}var RD=TD(function i(e,t){var n=t.default,r=n===void 0?null:n,o=t.triggerUpdate,a=o===void 0?!0:o,c=t.onChange,u=c===void 0?function(d,p){}:c;MD(this,i),this.name=e,this.defaultVal=r,this.triggerUpdate=a,this.onChange=u});function Gx(i){var e=i.stateInit,t=e===void 0?function(){return{}}:e,n=i.props,r=n===void 0?{}:n,o=i.methods,a=o===void 0?{}:o,c=i.aliases,u=c===void 0?{}:c,d=i.init,p=d===void 0?function(){}:d,m=i.update,y=m===void 0?function(){}:m,x=Object.keys(r).map(function(v){return new RD(v,r[v])});return function v(){for(var w=arguments.length,M=new Array(w),S=0;S<w;S++)M[S]=arguments[S];var C=!!(this instanceof v&&this.constructor),N=C?M.shift():void 0,I=M[0],U=I===void 0?{}:I,F=Object.assign({},t instanceof Function?t(U):t,{initialised:!1}),k={};function G(Q){return B(Q,U),z(),G}var B=function(ye,_e){p.call(G,ye,F,_e),F.initialised=!0},z=bD(function(){F.initialised&&(y.call(G,F,k),k={})},1);return x.forEach(function(Q){G[Q.name]=ye(Q);function ye(_e){var Te=_e.name,Pe=_e.triggerUpdate,Ne=Pe===void 0?!1:Pe,De=_e.onChange,Qe=De===void 0?function(Fe,mt){}:De,Mt=_e.defaultVal,Tt=Mt===void 0?null:Mt;return function(Fe){var mt=F[Te];if(!arguments.length)return mt;var wt=Fe===void 0?Tt:Fe;return F[Te]=wt,Qe.call(G,wt,F,mt),!k.hasOwnProperty(Te)&&(k[Te]=mt),Ne&&z(),G}}}),Object.keys(a).forEach(function(Q){G[Q]=function(){for(var ye,_e=arguments.length,Te=new Array(_e),Pe=0;Pe<_e;Pe++)Te[Pe]=arguments[Pe];return(ye=a[Q]).call.apply(ye,[G,F].concat(Te))}}),Object.entries(u).forEach(function(Q){var ye=ED(Q,2),_e=ye[0],Te=ye[1];return G[_e]=G[Te]}),G.resetProps=function(){return x.forEach(function(Q){G[Q.name](Q.defaultVal)}),G},G.resetProps(),F._rerender=z,C&&N&&G(N),G}}var pi=function(i){return typeof i=="function"?i:typeof i=="string"?function(e){return e[i]}:function(e){return i}};function ND(i,e){let t;if(e===void 0)for(const n of i)n!=null&&(t>n||t===void 0&&n>=n)&&(t=n);else{let n=-1;for(let r of i)(r=e(r,++n,i))!=null&&(t>r||t===void 0&&r>=r)&&(t=r)}return t}function PD(i,e){let t;if(e===void 0)for(const n of i)n!=null&&(t<n||t===void 0&&n>=n)&&(t=n);else{let n=-1;for(let r of i)(r=e(r,++n,i))!=null&&(t<r||t===void 0&&r>=r)&&(t=r)}return t}function rM(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t<e;t++)n[t]=i[t];return n}function ID(i){if(Array.isArray(i))return i}function LD(i){if(Array.isArray(i))return rM(i)}function qA(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 DD(i,e){if(e.has(i))throw new TypeError("Cannot initialize the same private elements twice on an object")}function FD(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")}function Jr(i,e){return i.get(qA(i,e))}function Gm(i,e,t){DD(i,e),e.set(i,t)}function Wx(i,e,t){return i.set(qA(i,e),t),t}function BD(i,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(i,$D(n.key),n)}}function OD(i,e,t){return e&&BD(i.prototype,e),Object.defineProperty(i,"prototype",{writable:!1}),i}function UD(i){if(typeof Symbol!="undefined"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function kD(i,e){var t=i==null?null:typeof Symbol!="undefined"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,r,o,a,c=[],u=!0,d=!1;try{if(o=(t=t.call(i)).next,e!==0)for(;!(u=(n=o.call(t)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(p){d=!0,r=p}finally{try{if(!u&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(d)throw r}}return c}}function zD(){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 VD(){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 GD(i,e){return ID(i)||kD(i,e)||XA(i,e)||zD()}function WD(i){return LD(i)||UD(i)||XA(i)||VD()}function HD(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(i)}function $D(i){var e=HD(i,"string");return typeof e=="symbol"?e:e+""}function XA(i,e){if(i){if(typeof i=="string")return rM(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)?rM(i,e):void 0}}var Wm=new WeakMap,J0=new WeakMap,Hm=new WeakMap,oM=new WeakMap,aM=new WeakMap,lM=new WeakMap,qD=function(){function i(){FD(this,i),Gm(this,Wm,new Map),Gm(this,J0,new Map),Gm(this,Hm,function(e){return e}),Gm(this,oM,function(){return{}}),Gm(this,aM,function(){}),Gm(this,lM,function(){})}return OD(i,[{key:"getObj",value:function(t){return Jr(Wm,this).get(Jr(Hm,this).call(this,t))}},{key:"getData",value:function(t){return Jr(J0,this).get(t)}},{key:"entries",value:function(){return WD(Jr(J0,this).entries()).map(function(t){var n=GD(t,2),r=n[0],o=n[1];return[o,r]})}},{key:"id",value:function(t){return Wx(Hm,this,pi(t)),this}},{key:"onCreateObj",value:function(t){return Wx(oM,this,t),this}},{key:"onUpdateObj",value:function(t){return Wx(aM,this,t),this}},{key:"onRemoveObj",value:function(t){return Wx(lM,this,t),this}},{key:"digest",value:function(t){var n=this;t.filter(function(o){return!Jr(Wm,n).has(Jr(Hm,n).call(n,o))}).forEach(function(o){var a=Jr(oM,n).call(n,o);Jr(Wm,n).set(Jr(Hm,n).call(n,o),a),Jr(J0,n).set(a,o)});var r=new Map(t.map(function(o){return[Jr(Hm,n).call(n,o),o]}));return Jr(Wm,this).forEach(function(o,a){r.has(a)?Jr(aM,n).call(n,o,r.get(a)):(Jr(lM,n).call(n,o,a),Jr(Wm,n).delete(a),Jr(J0,n).delete(o))}),this}},{key:"clear",value:function(){return this.digest([]),this}}])}();class jA extends Map{constructor(e,t=KA){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(const[n,r]of e)this.set(n,r)}get(e){return super.get(cM(this,e))}has(e){return super.has(cM(this,e))}set(e,t){return super.set(YA(this,e),t)}delete(e){return super.delete(ZA(this,e))}}class lZ extends null{constructor(e,t=KA){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:t}}),e!=null)for(const n of e)this.add(n)}has(e){return super.has(cM(this,e))}add(e){return super.add(YA(this,e))}delete(e){return super.delete(ZA(this,e))}}function cM({_intern:i,_key:e},t){const n=e(t);return i.has(n)?i.get(n):t}function YA({_intern:i,_key:e},t){const n=e(t);return i.has(n)?i.get(n):(i.set(n,t),t)}function ZA({_intern:i,_key:e},t){const n=e(t);return i.has(n)&&(t=i.get(n),i.delete(n)),t}function KA(i){return i!==null&&typeof i=="object"?i.valueOf():i}function XD(i,e){switch(arguments.length){case 0:break;case 1:this.range(i);break;default:this.range(e).domain(i);break}return this}function cZ(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 JA=Symbol("implicit");function QA(){var i=new jA,e=[],t=[],n=JA;function r(o){let a=i.get(o);if(a===void 0){if(n!==JA)return n;i.set(o,a=e.push(o)-1)}return t[a%t.length]}return r.domain=function(o){if(!arguments.length)return e.slice();e=[],i=new jA;for(const a of o)i.has(a)||i.set(a,e.push(a)-1);return r},r.range=function(o){return arguments.length?(t=Array.from(o),r):t.slice()},r.unknown=function(o){return arguments.length?(n=o,r):n},r.copy=function(){return QA(e,t).unknown(n)},XD.apply(r,arguments),r}function jD(i){for(var e=i.length/6|0,t=new Array(e),n=0;n<e;)t[n]="#"+i.slice(n*6,++n*6);return t}var YD=jD("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928");function Hx(i){"@babel/helpers - typeof";return Hx=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},Hx(i)}var ZD=/^\s+/,KD=/\s+$/;function bn(i,e){if(i=i||"",e=e||{},i instanceof bn)return i;if(!(this instanceof bn))return new bn(i,e);var t=JD(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}bn.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,n,r,o,a,c;return t=e.r/255,n=e.g/255,r=e.b/255,t<=.03928?o=t/12.92:o=Math.pow((t+.055)/1.055,2.4),n<=.03928?a=n/12.92:a=Math.pow((n+.055)/1.055,2.4),r<=.03928?c=r/12.92:c=Math.pow((r+.055)/1.055,2.4),.2126*o+.7152*a+.0722*c},setAlpha:function(e){return this._a=rE(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=tE(this._r,this._g,this._b);return{h:e.h*360,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=tE(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.v*100);return this._a==1?"hsv("+t+", "+n+"%, "+r+"%)":"hsva("+t+", "+n+"%, "+r+"%, "+this._roundA+")"},toHsl:function(){var e=eE(this._r,this._g,this._b);return{h:e.h*360,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=eE(this._r,this._g,this._b),t=Math.round(e.h*360),n=Math.round(e.s*100),r=Math.round(e.l*100);return this._a==1?"hsl("+t+", "+n+"%, "+r+"%)":"hsla("+t+", "+n+"%, "+r+"%, "+this._roundA+")"},toHex:function(e){return nE(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return nF(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(ys(this._r,255)*100)+"%",g:Math.round(ys(this._g,255)*100)+"%",b:Math.round(ys(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(ys(this._r,255)*100)+"%, "+Math.round(ys(this._g,255)*100)+"%, "+Math.round(ys(this._b,255)*100)+"%)":"rgba("+Math.round(ys(this._r,255)*100)+"%, "+Math.round(ys(this._g,255)*100)+"%, "+Math.round(ys(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:pF[nE(this._r,this._g,this._b,!0)]||!1},toFilter:function(e){var t="#"+iE(this._r,this._g,this._b,this._a),n=t,r=this._gradientType?"GradientType = 1, ":"";if(e){var o=bn(e);n="#"+iE(o._r,o._g,o._b,o._a)}return"progid:DXImageTransform.Microsoft.gradient("+r+"startColorstr="+t+",endColorstr="+n+")"},toString:function(e){var t=!!e;e=e||this._format;var n=!1,r=this._a<1&&this._a>=0,o=!t&&r&&(e==="hex"||e==="hex6"||e==="hex3"||e==="hex4"||e==="hex8"||e==="name");return o?e==="name"&&this._a===0?this.toName():this.toRgbString():(e==="rgb"&&(n=this.toRgbString()),e==="prgb"&&(n=this.toPercentageRgbString()),(e==="hex"||e==="hex6")&&(n=this.toHexString()),e==="hex3"&&(n=this.toHexString(!0)),e==="hex4"&&(n=this.toHex8String(!0)),e==="hex8"&&(n=this.toHex8String()),e==="name"&&(n=this.toName()),e==="hsl"&&(n=this.toHslString()),e==="hsv"&&(n=this.toHsvString()),n||this.toHexString())},clone:function(){return bn(this.toString())},_applyModification:function(e,t){var n=e.apply(null,[this].concat([].slice.call(t)));return this._r=n._r,this._g=n._g,this._b=n._b,this.setAlpha(n._a),this},lighten:function(){return this._applyModification(oF,arguments)},brighten:function(){return this._applyModification(aF,arguments)},darken:function(){return this._applyModification(lF,arguments)},desaturate:function(){return this._applyModification(iF,arguments)},saturate:function(){return this._applyModification(sF,arguments)},greyscale:function(){return this._applyModification(rF,arguments)},spin:function(){return this._applyModification(cF,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(dF,arguments)},complement:function(){return this._applyCombination(uF,arguments)},monochromatic:function(){return this._applyCombination(fF,arguments)},splitcomplement:function(){return this._applyCombination(hF,arguments)},triad:function(){return this._applyCombination(sE,[3])},tetrad:function(){return this._applyCombination(sE,[4])}},bn.fromRatio=function(i,e){if(Hx(i)=="object"){var t={};for(var n in i)i.hasOwnProperty(n)&&(n==="a"?t[n]=i[n]:t[n]=Q0(i[n]));i=t}return bn(i,e)};function JD(i){var e={r:0,g:0,b:0},t=1,n=null,r=null,o=null,a=!1,c=!1;return typeof i=="string"&&(i=_F(i)),Hx(i)=="object"&&(Qu(i.r)&&Qu(i.g)&&Qu(i.b)?(e=QD(i.r,i.g,i.b),a=!0,c=String(i.r).substr(-1)==="%"?"prgb":"rgb"):Qu(i.h)&&Qu(i.s)&&Qu(i.v)?(n=Q0(i.s),r=Q0(i.v),e=tF(i.h,n,r),a=!0,c="hsv"):Qu(i.h)&&Qu(i.s)&&Qu(i.l)&&(n=Q0(i.s),o=Q0(i.l),e=eF(i.h,n,o),a=!0,c="hsl"),i.hasOwnProperty("a")&&(t=i.a)),t=rE(t),{ok:a,format:i.format||c,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 QD(i,e,t){return{r:ys(i,255)*255,g:ys(e,255)*255,b:ys(t,255)*255}}function eE(i,e,t){i=ys(i,255),e=ys(e,255),t=ys(t,255);var n=Math.max(i,e,t),r=Math.min(i,e,t),o,a,c=(n+r)/2;if(n==r)o=a=0;else{var u=n-r;switch(a=c>.5?u/(2-n-r):u/(n+r),n){case i:o=(e-t)/u+(e<t?6:0);break;case e:o=(t-i)/u+2;break;case t:o=(i-e)/u+4;break}o/=6}return{h:o,s:a,l:c}}function eF(i,e,t){var n,r,o;i=ys(i,360),e=ys(e,100),t=ys(t,100);function a(d,p,m){return m<0&&(m+=1),m>1&&(m-=1),m<1/6?d+(p-d)*6*m:m<1/2?p:m<2/3?d+(p-d)*(2/3-m)*6:d}if(e===0)n=r=o=t;else{var c=t<.5?t*(1+e):t+e-t*e,u=2*t-c;n=a(u,c,i+1/3),r=a(u,c,i),o=a(u,c,i-1/3)}return{r:n*255,g:r*255,b:o*255}}function tE(i,e,t){i=ys(i,255),e=ys(e,255),t=ys(t,255);var n=Math.max(i,e,t),r=Math.min(i,e,t),o,a,c=n,u=n-r;if(a=n===0?0:u/n,n==r)o=0;else{switch(n){case i:o=(e-t)/u+(e<t?6:0);break;case e:o=(t-i)/u+2;break;case t:o=(i-e)/u+4;break}o/=6}return{h:o,s:a,v:c}}function tF(i,e,t){i=ys(i,360)*6,e=ys(e,100),t=ys(t,100);var n=Math.floor(i),r=i-n,o=t*(1-e),a=t*(1-r*e),c=t*(1-(1-r)*e),u=n%6,d=[t,a,o,o,c,t][u],p=[c,t,t,a,o,o][u],m=[o,o,c,t,t,a][u];return{r:d*255,g:p*255,b:m*255}}function nE(i,e,t,n){var r=[Ml(Math.round(i).toString(16)),Ml(Math.round(e).toString(16)),Ml(Math.round(t).toString(16))];return n&&r[0].charAt(0)==r[0].charAt(1)&&r[1].charAt(0)==r[1].charAt(1)&&r[2].charAt(0)==r[2].charAt(1)?r[0].charAt(0)+r[1].charAt(0)+r[2].charAt(0):r.join("")}function nF(i,e,t,n,r){var o=[Ml(Math.round(i).toString(16)),Ml(Math.round(e).toString(16)),Ml(Math.round(t).toString(16)),Ml(oE(n))];return r&&o[0].charAt(0)==o[0].charAt(1)&&o[1].charAt(0)==o[1].charAt(1)&&o[2].charAt(0)==o[2].charAt(1)&&o[3].charAt(0)==o[3].charAt(1)?o[0].charAt(0)+o[1].charAt(0)+o[2].charAt(0)+o[3].charAt(0):o.join("")}function iE(i,e,t,n){var r=[Ml(oE(n)),Ml(Math.round(i).toString(16)),Ml(Math.round(e).toString(16)),Ml(Math.round(t).toString(16))];return r.join("")}bn.equals=function(i,e){return!i||!e?!1:bn(i).toRgbString()==bn(e).toRgbString()},bn.random=function(){return bn.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function iF(i,e){e=e===0?0:e||10;var t=bn(i).toHsl();return t.s-=e/100,t.s=$x(t.s),bn(t)}function sF(i,e){e=e===0?0:e||10;var t=bn(i).toHsl();return t.s+=e/100,t.s=$x(t.s),bn(t)}function rF(i){return bn(i).desaturate(100)}function oF(i,e){e=e===0?0:e||10;var t=bn(i).toHsl();return t.l+=e/100,t.l=$x(t.l),bn(t)}function aF(i,e){e=e===0?0:e||10;var t=bn(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)))),bn(t)}function lF(i,e){e=e===0?0:e||10;var t=bn(i).toHsl();return t.l-=e/100,t.l=$x(t.l),bn(t)}function cF(i,e){var t=bn(i).toHsl(),n=(t.h+e)%360;return t.h=n<0?360+n:n,bn(t)}function uF(i){var e=bn(i).toHsl();return e.h=(e.h+180)%360,bn(e)}function sE(i,e){if(isNaN(e)||e<=0)throw new Error("Argument to polyad must be a positive number");for(var t=bn(i).toHsl(),n=[bn(i)],r=360/e,o=1;o<e;o++)n.push(bn({h:(t.h+o*r)%360,s:t.s,l:t.l}));return n}function hF(i){var e=bn(i).toHsl(),t=e.h;return[bn(i),bn({h:(t+72)%360,s:e.s,l:e.l}),bn({h:(t+216)%360,s:e.s,l:e.l})]}function dF(i,e,t){e=e||6,t=t||30;var n=bn(i).toHsl(),r=360/t,o=[bn(i)];for(n.h=(n.h-(r*e>>1)+720)%360;--e;)n.h=(n.h+r)%360,o.push(bn(n));return o}function fF(i,e){e=e||6;for(var t=bn(i).toHsv(),n=t.h,r=t.s,o=t.v,a=[],c=1/e;e--;)a.push(bn({h:n,s:r,v:o})),o=(o+c)%1;return a}bn.mix=function(i,e,t){t=t===0?0:t||50;var n=bn(i).toRgb(),r=bn(e).toRgb(),o=t/100,a={r:(r.r-n.r)*o+n.r,g:(r.g-n.g)*o+n.g,b:(r.b-n.b)*o+n.b,a:(r.a-n.a)*o+n.a};return bn(a)},bn.readability=function(i,e){var t=bn(i),n=bn(e);return(Math.max(t.getLuminance(),n.getLuminance())+.05)/(Math.min(t.getLuminance(),n.getLuminance())+.05)},bn.isReadable=function(i,e,t){var n=bn.readability(i,e),r,o;switch(o=!1,r=xF(t),r.level+r.size){case"AAsmall":case"AAAlarge":o=n>=4.5;break;case"AAlarge":o=n>=3;break;case"AAAsmall":o=n>=7;break}return o},bn.mostReadable=function(i,e,t){var n=null,r=0,o,a,c,u;t=t||{},a=t.includeFallbackColors,c=t.level,u=t.size;for(var d=0;d<e.length;d++)o=bn.readability(i,e[d]),o>r&&(r=o,n=bn(e[d]));return bn.isReadable(i,n,{level:c,size:u})||!a?n:(t.includeFallbackColors=!1,bn.mostReadable(i,["#fff","#000"],t))};var uM=bn.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"},pF=bn.hexNames=mF(uM);function mF(i){var e={};for(var t in i)i.hasOwnProperty(t)&&(e[i[t]]=t);return e}function rE(i){return i=parseFloat(i),(isNaN(i)||i<0||i>1)&&(i=1),i}function ys(i,e){gF(i)&&(i="100%");var t=yF(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 $x(i){return Math.min(1,Math.max(0,i))}function da(i){return parseInt(i,16)}function gF(i){return typeof i=="string"&&i.indexOf(".")!=-1&&parseFloat(i)===1}function yF(i){return typeof i=="string"&&i.indexOf("%")!=-1}function Ml(i){return i.length==1?"0"+i:""+i}function Q0(i){return i<=1&&(i=i*100+"%"),i}function oE(i){return Math.round(parseFloat(i)*255).toString(16)}function aE(i){return da(i)/255}var Tl=function(){var i="[-\\+]?\\d+%?",e="[-\\+]?\\d*\\.\\d+%?",t="(?:"+e+")|(?:"+i+")",n="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?",r="[\\s|\\(]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")[,|\\s]+("+t+")\\s*\\)?";return{CSS_UNIT:new RegExp(t),rgb:new RegExp("rgb"+n),rgba:new RegExp("rgba"+r),hsl:new RegExp("hsl"+n),hsla:new RegExp("hsla"+r),hsv:new RegExp("hsv"+n),hsva:new RegExp("hsva"+r),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 Qu(i){return!!Tl.CSS_UNIT.exec(i)}function _F(i){i=i.replace(ZD,"").replace(KD,"").toLowerCase();var e=!1;if(uM[i])i=uM[i],e=!0;else if(i=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var t;return(t=Tl.rgb.exec(i))?{r:t[1],g:t[2],b:t[3]}:(t=Tl.rgba.exec(i))?{r:t[1],g:t[2],b:t[3],a:t[4]}:(t=Tl.hsl.exec(i))?{h:t[1],s:t[2],l:t[3]}:(t=Tl.hsla.exec(i))?{h:t[1],s:t[2],l:t[3],a:t[4]}:(t=Tl.hsv.exec(i))?{h:t[1],s:t[2],v:t[3]}:(t=Tl.hsva.exec(i))?{h:t[1],s:t[2],v:t[3],a:t[4]}:(t=Tl.hex8.exec(i))?{r:da(t[1]),g:da(t[2]),b:da(t[3]),a:aE(t[4]),format:e?"name":"hex8"}:(t=Tl.hex6.exec(i))?{r:da(t[1]),g:da(t[2]),b:da(t[3]),format:e?"name":"hex"}:(t=Tl.hex4.exec(i))?{r:da(t[1]+""+t[1]),g:da(t[2]+""+t[2]),b:da(t[3]+""+t[3]),a:aE(t[4]+""+t[4]),format:e?"name":"hex8"}:(t=Tl.hex3.exec(i))?{r:da(t[1]+""+t[1]),g:da(t[2]+""+t[2]),b:da(t[3]+""+t[3]),format:e?"name":"hex"}:!1}function xF(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 hM(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t<e;t++)n[t]=i[t];return n}function vF(i){if(Array.isArray(i))return i}function bF(i){if(Array.isArray(i))return hM(i)}function lE(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 SF(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function cE(i,e,t){return e=$m(e),NF(i,pM()?Reflect.construct(e,t||[],$m(i).constructor):e.apply(i,t))}function MF(i,e){if(e.has(i))throw new TypeError("Cannot initialize the same private elements twice on an object")}function uE(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")}function dM(i,e){return i.get(lE(i,e))}function hE(i,e,t){MF(i,e),e.set(i,t)}function dE(i,e,t){return i.set(lE(i,e),t),t}function fE(i,e,t){if(pM())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var r=new(i.bind.apply(i,n));return r}function TF(i,e){for(var t=0;t<e.length;t++){var n=e[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(i,yE(n.key),n)}}function pE(i,e,t){return e&&TF(i.prototype,e),Object.defineProperty(i,"prototype",{writable:!1}),i}function qx(i,e,t){return(e=yE(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function fM(){return fM=typeof Reflect!="undefined"&&Reflect.get?Reflect.get.bind():function(i,e,t){var n=PF(i,e);if(n){var r=Object.getOwnPropertyDescriptor(n,e);return r.get?r.get.call(arguments.length<3?i:t):r.value}},fM.apply(null,arguments)}function $m(i){return $m=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},$m(i)}function mE(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&&mM(i,e)}function pM(){try{var i=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(pM=function(){return!!i})()}function wF(i){if(typeof Symbol!="undefined"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function AF(i,e){var t=i==null?null:typeof Symbol!="undefined"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,r,o,a,c=[],u=!0,d=!1;try{if(o=(t=t.call(i)).next,e!==0)for(;!(u=(n=o.call(t)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(p){d=!0,r=p}finally{try{if(!u&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(d)throw r}}return c}}function EF(){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 CF(){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 gE(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function RF(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?gE(Object(t),!0).forEach(function(n){qx(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):gE(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function NF(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 SF(i)}function mM(i,e){return mM=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},mM(i,e)}function ey(i,e){return vF(i)||AF(i,e)||_E(i,e)||EF()}function PF(i,e){for(;!{}.hasOwnProperty.call(i,e)&&(i=$m(i))!==null;);return i}function gM(i,e,t,n){var r=fM($m(i.prototype),e,t);return typeof r=="function"?function(o){return r.apply(t,o)}:r}function wl(i){return bF(i)||wF(i)||_E(i)||CF()}function IF(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function yE(i){var e=IF(i,"string");return typeof e=="symbol"?e:e+""}function yM(i){"@babel/helpers - typeof";return yM=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},yM(i)}function _E(i,e){if(i){if(typeof i=="string")return hM(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)?hM(i,e):void 0}}var xE=function(e){e instanceof Array?e.forEach(xE):(e.map&&e.map.dispose(),e.dispose())},vE=function(e){e.geometry&&e.geometry.dispose(),e.material&&xE(e.material),e.texture&&e.texture.dispose(),e.children&&e.children.forEach(vE)},_M=function(e){for(;e.children.length;){var t=e.children[0];e.remove(t),vE(t)}},xM=new WeakMap,Xx=new WeakMap,ty=function(i){function e(t){var n,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=r.dataBindAttr,a=o===void 0?"__data":o,c=r.objBindAttr,u=c===void 0?"__threeObj":c;return uE(this,e),n=cE(this,e),qx(n,"scene",void 0),hE(n,xM,void 0),hE(n,Xx,void 0),n.scene=t,dE(xM,n,a),dE(Xx,n,u),n.onRemoveObj(function(){}),n}return mE(e,i),pE(e,[{key:"onCreateObj",value:function(n){var r=this;return gM(e,"onCreateObj",this)([function(o){var a=n(o);return o[dM(Xx,r)]=a,a[dM(xM,r)]=o,r.scene.add(a),a}]),this}},{key:"onRemoveObj",value:function(n){var r=this;return gM(e,"onRemoveObj",this)([function(o,a){var c=gM(e,"getData",r)([o]);n(o,a),r.scene.remove(o),_M(o),delete c[dM(Xx,r)]}]),this}}])}(qD),ny=function(e){return isNaN(e)?parseInt(bn(e).toHex(),16):e},vM=function(e){return isNaN(e)?bn(e).getAlpha():1},LF=QA(YD);function bE(i,e,t){!e||typeof t!="string"||i.filter(function(n){return!n[t]}).forEach(function(n){n[t]=LF(e(n))})}function DF(i,e){var t=i.nodes,n=i.links,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=r.nodeFilter,a=o===void 0?function(){return!0}:o,c=r.onLoopError,u=c===void 0?function(x){throw"Invalid DAG structure! Found cycle in node path: ".concat(x.join(" -> "),".")}:c,d={};t.forEach(function(x){return d[e(x)]={data:x,out:[],depth:-1,skip:!a(x)}}),n.forEach(function(x){var v=x.source,w=x.target,M=I(v),S=I(w);if(!d.hasOwnProperty(M))throw"Missing source node with id: ".concat(M);if(!d.hasOwnProperty(S))throw"Missing target node with id: ".concat(S);var C=d[M],N=d[S];C.out.push(N);function I(U){return yM(U)==="object"?e(U):U}});var p=[];y(Object.values(d));var m=Object.assign.apply(Object,[{}].concat(wl(Object.entries(d).filter(function(x){var v=ey(x,2),w=v[1];return!w.skip}).map(function(x){var v=ey(x,2),w=v[0],M=v[1];return qx({},w,M.depth)}))));return m;function y(x){for(var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,M=function(){var I=x[S];if(v.indexOf(I)!==-1){var U=[].concat(wl(v.slice(v.indexOf(I))),[I]).map(function(F){return e(F.data)});return p.some(function(F){return F.length===U.length&&F.every(function(k,G){return k===U[G]})})||(p.push(U),u(U)),1}w>I.depth&&(I.depth=w,y(I.out,[].concat(wl(v),[I]),w+(I.skip?0:1)))},S=0,C=x.length;S<C;S++)M()}}var qn=window.THREE?window.THREE:{Group:Lo,Mesh:Ji,MeshLambertMaterial:Vf,Color:It,BufferGeometry:Gn,BufferAttribute:$i,Matrix4:Qt,Vector3:H,SphereGeometry:ku,CylinderGeometry:Ur,TubeGeometry:Sm,ConeGeometry:Lu,Line:Pu,LineBasicMaterial:js,QuadraticBezierCurve3:Ou,CubicBezierCurve3:Bu,Box3:ns},SE={graph:ca,forcelayout:Bd},FF=2,bM=new qn.BufferGeometry().setAttribute?"setAttribute":"addAttribute",jx=new qn.BufferGeometry().applyMatrix4?"applyMatrix4":"applyMatrix",BF=Gx({props:{jsonUrl:{onChange:function(e,t){var n=this;e&&!t.fetchingJson&&(t.fetchingJson=!0,t.onLoading(),fetch(e).then(function(r){return r.json()}).then(function(r){t.fetchingJson=!1,t.onFinishLoading(r),n.graphData(r)}))},triggerUpdate:!1},graphData:{default:{nodes:[],links:[]},onChange:function(e,t){t.engineRunning=!1}},numDimensions:{default:3,onChange:function(e,t){var n=t.d3ForceLayout.force("charge");n&&n.strength(e>2?-60:-30),e<3&&r(t.graphData.nodes,"z"),e<2&&r(t.graphData.nodes,"y");function r(o,a){o.forEach(function(c){delete c[a],delete c["v".concat(a)]})}}},dagMode:{onChange:function(e,t){!e&&t.forceEngine==="d3"&&(t.graphData.nodes||[]).forEach(function(n){return n.fx=n.fy=n.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,n){return n===void 0?e.d3ForceLayout.force(t):(e.d3ForceLayout.force(t,n),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&&n(),r(),o(),this;function n(){++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 a=pi(e.nodeThreeObjectExtend);e.nodeDataMapper.entries().forEach(function(y){var x=ey(y,2),v=x[0],w=x[1];if(w){var M=t?v:e.layout.getNodePosition(v[e.nodeId]),S=a(v);(!e.nodePositionUpdate||!e.nodePositionUpdate(S?w.children[0]:w,{x:M.x,y:M.y,z:M.z},v)||S)&&(w.position.x=M.x,w.position.y=M.y||0,w.position.z=M.z||0)}});var c=pi(e.linkWidth),u=pi(e.linkCurvature),d=pi(e.linkCurveRotation),p=pi(e.linkThreeObjectExtend);e.linkDataMapper.entries().forEach(function(y){var x=ey(y,2),v=x[0],w=x[1];if(w){var M=t?v:e.layout.getLinkPosition(e.layout.graph.getLink(v.source,v.target).id),S=M[t?"source":"from"],C=M[t?"target":"to"];if(!(!S||!C||!S.hasOwnProperty("x")||!C.hasOwnProperty("x"))){m(v);var N=p(v);if(!(e.linkPositionUpdate&&e.linkPositionUpdate(N?w.children[1]:w,{start:{x:S.x,y:S.y,z:S.z},end:{x:C.x,y:C.y,z:C.z}},v)&&!N)){var I=30,U=v.__curve,F=w.children.length?w.children[0]:w;if(F.type==="Line"){if(U){var G=U.getPoints(I);F.geometry.getAttribute("position").array.length!==G.length*3&&F.geometry[bM]("position",new qn.BufferAttribute(new Float32Array(G.length*3),3)),F.geometry.setFromPoints(G)}else{var k=F.geometry.getAttribute("position");(!k||!k.array||k.array.length!==6)&&F.geometry[bM]("position",k=new qn.BufferAttribute(new Float32Array(2*3),3)),k.array[0]=S.x,k.array[1]=S.y||0,k.array[2]=S.z||0,k.array[3]=C.x,k.array[4]=C.y||0,k.array[5]=C.z||0,k.needsUpdate=!0}F.geometry.computeBoundingSphere()}else if(F.type==="Mesh")if(U){F.geometry.type.match(/^Tube(Buffer)?Geometry$/)||(F.position.set(0,0,0),F.rotation.set(0,0,0),F.scale.set(1,1,1));var Pe=Math.ceil(c(v)*10)/10,Ne=Pe/2,De=new qn.TubeGeometry(U,I,Ne,e.linkResolution,!1);F.geometry.dispose(),F.geometry=De}else{if(!F.geometry.type.match(/^Cylinder(Buffer)?Geometry$/)){var B=Math.ceil(c(v)*10)/10,z=B/2,Q=new qn.CylinderGeometry(z,z,1,e.linkResolution,1,!1);Q[jx](new qn.Matrix4().makeTranslation(0,1/2,0)),Q[jx](new qn.Matrix4().makeRotationX(Math.PI/2)),F.geometry.dispose(),F.geometry=Q}var ye=new qn.Vector3(S.x,S.y||0,S.z||0),_e=new qn.Vector3(C.x,C.y||0,C.z||0),Te=ye.distanceTo(_e);F.position.x=ye.x,F.position.y=ye.y,F.position.z=ye.z,F.scale.z=Te,F.parent.localToWorld(_e),F.lookAt(_e)}}}}});function m(y){var x=t?y:e.layout.getLinkPosition(e.layout.graph.getLink(y.source,y.target).id),v=x[t?"source":"from"],w=x[t?"target":"to"];if(!(!v||!w||!v.hasOwnProperty("x")||!w.hasOwnProperty("x"))){var M=u(y);if(!M)y.__curve=null;else{var S=new qn.Vector3(v.x,v.y||0,v.z||0),C=new qn.Vector3(w.x,w.y||0,w.z||0),N=S.distanceTo(C),I,U=d(y);if(N>0){var F=w.x-v.x,k=w.y-v.y||0,G=new qn.Vector3().subVectors(C,S),B=G.clone().multiplyScalar(M).cross(F!==0||k!==0?new qn.Vector3(0,0,1):new qn.Vector3(0,1,0)).applyAxisAngle(G.normalize(),U).add(new qn.Vector3().addVectors(S,C).divideScalar(2));I=new qn.QuadraticBezierCurve3(S,B,C)}else{var z=M*70,Q=-U,ye=Q+Math.PI/2;I=new qn.CubicBezierCurve3(S,new qn.Vector3(z*Math.cos(ye),z*Math.sin(ye),0).add(S),new qn.Vector3(z*Math.cos(Q),z*Math.sin(Q),0).add(S),C)}y.__curve=I}}}}function r(){var a=pi(e.linkDirectionalArrowRelPos),c=pi(e.linkDirectionalArrowLength),u=pi(e.nodeVal);e.arrowDataMapper.entries().forEach(function(d){var p=ey(d,2),m=p[0],y=p[1];if(y){var x=t?m:e.layout.getLinkPosition(e.layout.graph.getLink(m.source,m.target).id),v=x[t?"source":"from"],w=x[t?"target":"to"];if(!(!v||!w||!v.hasOwnProperty("x")||!w.hasOwnProperty("x"))){var M=Math.cbrt(Math.max(0,u(v)||1))*e.nodeRelSize,S=Math.cbrt(Math.max(0,u(w)||1))*e.nodeRelSize,C=c(m),N=a(m),I=m.__curve?function(z){return m.__curve.getPoint(z)}:function(z){var Q=function(_e,Te,Pe,Ne){return Te[_e]+(Pe[_e]-Te[_e])*Ne||0};return{x:Q("x",v,w,z),y:Q("y",v,w,z),z:Q("z",v,w,z)}},U=m.__curve?m.__curve.getLength():Math.sqrt(["x","y","z"].map(function(z){return Math.pow((w[z]||0)-(v[z]||0),2)}).reduce(function(z,Q){return z+Q},0)),F=M+C+(U-M-S-C)*N,k=I(F/U),G=I((F-C)/U);["x","y","z"].forEach(function(z){return y.position[z]=G[z]});var B=fE(qn.Vector3,wl(["x","y","z"].map(function(z){return k[z]})));y.parent.localToWorld(B),y.lookAt(B)}}})}function o(){var a=pi(e.linkDirectionalParticleSpeed),c=pi(e.linkDirectionalParticleOffset);e.graphData.links.forEach(function(u){var d=e.particlesDataMapper.getObj(u),p=d&&d.children,m=u.__singleHopPhotonsObj&&u.__singleHopPhotonsObj.children;if(!((!m||!m.length)&&(!p||!p.length))){var y=t?u:e.layout.getLinkPosition(e.layout.graph.getLink(u.source,u.target).id),x=y[t?"source":"from"],v=y[t?"target":"to"];if(!(!x||!v||!x.hasOwnProperty("x")||!v.hasOwnProperty("x"))){var w=a(u),M=Math.abs(c(u)),S=u.__curve?function(N){return u.__curve.getPoint(N)}:function(N){var I=function(F,k,G,B){return k[F]+(G[F]-k[F])*B||0};return{x:I("x",x,v,N),y:I("y",x,v,N),z:I("z",x,v,N)}},C=[].concat(wl(p||[]),wl(m||[]));C.forEach(function(N,I){var U=N.parent.__linkThreeObjType==="singleHopPhotons";if(N.hasOwnProperty("__progressRatio")||(N.__progressRatio=U?0:(I+M)/p.length),N.__progressRatio+=w,N.__progressRatio>=1)if(!U)N.__progressRatio=N.__progressRatio%1;else{N.parent.remove(N),_M(N);return}var F=N.__progressRatio,k=S(F);N.geometry.type!=="SphereGeometry"&&N.lookAt(k.x,k.y,k.z),["x","y","z"].forEach(function(G){return N.position[G]=k[G]})})}}})}},emitParticle:function(e,t){if(t&&e.graphData.links.includes(t)){if(!t.__singleHopPhotonsObj){var n=new qn.Group;n.__linkThreeObjType="singleHopPhotons",t.__singleHopPhotonsObj=n,e.graphScene.add(n)}var r=pi(e.linkDirectionalParticleThreeObject)(t);if(r&&e.linkDirectionalParticleThreeObject===r&&(r=r.clone()),!r){var o=pi(e.linkDirectionalParticleWidth),a=Math.ceil(o(t)*10)/10/2,c=e.linkDirectionalParticleResolution,u=new qn.SphereGeometry(a,c,c),d=pi(e.linkColor),p=pi(e.linkDirectionalParticleColor),m=p(t)||d(t)||"#f0f0f0",y=new qn.Color(ny(m)),x=e.linkOpacity*3,v=new qn.MeshLambertMaterial({color:y,transparent:!0,opacity:x});r=new qn.Mesh(u,v)}t.__singleHopPhotonsObj.add(r)}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 n=function r(o){var a=[];if(o.geometry){o.geometry.computeBoundingBox();var c=new qn.Box3;c.copy(o.geometry.boundingBox).applyMatrix4(o.matrixWorld),a.push(c)}return a.concat.apply(a,wl((o.children||[]).filter(function(u){return!u.hasOwnProperty("__graphObjType")||u.__graphObjType==="node"&&t(u.__data)}).map(r)))}(e.graphScene);return n.length?Object.assign.apply(Object,wl(["x","y","z"].map(function(r){return qx({},r,[ND(n,function(o){return o.min[r]}),PD(n,function(o){return o.max[r]})])}))):null}},stateInit:function(){return{d3ForceLayout:(0,xt.Z)().force("link",(0,Et.Z)()).force("charge",(0,_n.Z)()).force("center",(0,ei.Z)()).force("dagRadial",null).stop(),engineRunning:!1}},init:function(e,t){t.graphScene=e,t.nodeDataMapper=new ty(e,{objBindAttr:"__threeObj"}),t.linkDataMapper=new ty(e,{objBindAttr:"__lineObj"}),t.arrowDataMapper=new ty(e,{objBindAttr:"__arrowObj"}),t.particlesDataMapper=new ty(e,{objBindAttr:"__photonsObj"})},update:function(e,t){var n=function(Ee){return Ee.some(function(Oe){return t.hasOwnProperty(Oe)})};if(e.engineRunning=!1,typeof e.onUpdate=="function"&&e.onUpdate(),e.nodeAutoColorBy!==null&&n(["nodeAutoColorBy","graphData","nodeColor"])&&bE(e.graphData.nodes,pi(e.nodeAutoColorBy),e.nodeColor),e.linkAutoColorBy!==null&&n(["linkAutoColorBy","graphData","linkColor"])&&bE(e.graphData.links,pi(e.linkAutoColorBy),e.linkColor),e._flushObjects||n(["graphData","nodeThreeObject","nodeThreeObjectExtend","nodeVal","nodeColor","nodeVisibility","nodeRelSize","nodeResolution","nodeOpacity"])){var r=pi(e.nodeThreeObject),o=pi(e.nodeThreeObjectExtend),a=pi(e.nodeVal),c=pi(e.nodeColor),u=pi(e.nodeVisibility),d={},p={};(e._flushObjects||n(["nodeThreeObject","nodeThreeObjectExtend"]))&&e.nodeDataMapper.clear(),e.nodeDataMapper.onCreateObj(function(st){var Ee=r(st),Oe=o(st);Ee&&e.nodeThreeObject===Ee&&(Ee=Ee.clone());var vt;return Ee&&!Oe?vt=Ee:(vt=new qn.Mesh,vt.__graphDefaultObj=!0,Ee&&Oe&&vt.add(Ee)),vt.__graphObjType="node",vt}).onUpdateObj(function(st,Ee){if(st.__graphDefaultObj){var Oe=a(Ee)||1,vt=Math.cbrt(Oe)*e.nodeRelSize,Zt=e.nodeResolution;(!st.geometry.type.match(/^Sphere(Buffer)?Geometry$/)||st.geometry.parameters.radius!==vt||st.geometry.parameters.widthSegments!==Zt)&&(d.hasOwnProperty(Oe)||(d[Oe]=new qn.SphereGeometry(vt,Zt,Zt)),st.geometry.dispose(),st.geometry=d[Oe]);var Pt=c(Ee),wn=new qn.Color(ny(Pt||"#ffffaa")),ai=e.nodeOpacity*vM(Pt);(st.material.type!=="MeshLambertMaterial"||!st.material.color.equals(wn)||st.material.opacity!==ai)&&(p.hasOwnProperty(Pt)||(p[Pt]=new qn.MeshLambertMaterial({color:wn,transparent:!0,opacity:ai})),st.material.dispose(),st.material=p[Pt])}}).digest(e.graphData.nodes.filter(u))}if(e._flushObjects||n(["graphData","linkThreeObject","linkThreeObjectExtend","linkMaterial","linkColor","linkWidth","linkVisibility","linkResolution","linkOpacity","linkDirectionalArrowLength","linkDirectionalArrowColor","linkDirectionalArrowResolution","linkDirectionalParticles","linkDirectionalParticleWidth","linkDirectionalParticleColor","linkDirectionalParticleResolution","linkDirectionalParticleThreeObject"])){var m=pi(e.linkThreeObject),y=pi(e.linkThreeObjectExtend),x=pi(e.linkMaterial),v=pi(e.linkVisibility),w=pi(e.linkColor),M=pi(e.linkWidth),S={},C={},N={},I=e.graphData.links.filter(v);if((e._flushObjects||n(["linkThreeObject","linkThreeObjectExtend","linkWidth"]))&&e.linkDataMapper.clear(),e.linkDataMapper.onRemoveObj(function(st){var Ee=st.__data&&st.__data.__singleHopPhotonsObj;Ee&&(Ee.parent.remove(Ee),_M(Ee),delete st.__data.__singleHopPhotonsObj)}).onCreateObj(function(st){var Ee=m(st),Oe=y(st);Ee&&e.linkThreeObject===Ee&&(Ee=Ee.clone());var vt;if(!Ee||Oe){var Zt=!!M(st);if(Zt)vt=new qn.Mesh;else{var Pt=new qn.BufferGeometry;Pt[bM]("position",new qn.BufferAttribute(new Float32Array(2*3),3)),vt=new qn.Line(Pt)}}var wn;return Ee?Oe?(wn=new qn.Group,wn.__graphDefaultObj=!0,wn.add(vt),wn.add(Ee)):wn=Ee:(wn=vt,wn.__graphDefaultObj=!0),wn.renderOrder=10,wn.__graphObjType="link",wn}).onUpdateObj(function(st,Ee){if(st.__graphDefaultObj){var Oe=st.children.length?st.children[0]:st,vt=Math.ceil(M(Ee)*10)/10,Zt=!!vt;if(Zt){var Pt=vt/2,wn=e.linkResolution;if(!Oe.geometry.type.match(/^Cylinder(Buffer)?Geometry$/)||Oe.geometry.parameters.radiusTop!==Pt||Oe.geometry.parameters.radialSegments!==wn){if(!S.hasOwnProperty(vt)){var ai=new qn.CylinderGeometry(Pt,Pt,1,wn,1,!1);ai[jx](new qn.Matrix4().makeTranslation(0,1/2,0)),ai[jx](new qn.Matrix4().makeRotationX(Math.PI/2)),S[vt]=ai}Oe.geometry.dispose(),Oe.geometry=S[vt]}}var Wn=x(Ee);if(Wn)Oe.material=Wn;else{var rt=w(Ee),yt=new qn.Color(ny(rt||"#f0f0f0")),ct=e.linkOpacity*vM(rt),Ft=Zt?"MeshLambertMaterial":"LineBasicMaterial";if(Oe.material.type!==Ft||!Oe.material.color.equals(yt)||Oe.material.opacity!==ct){var ne=Zt?C:N;ne.hasOwnProperty(rt)||(ne[rt]=new qn[Ft]({color:yt,transparent:ct<1,opacity:ct,depthWrite:ct>=1})),Oe.material.dispose(),Oe.material=ne[rt]}}}}).digest(I),e.linkDirectionalArrowLength||t.hasOwnProperty("linkDirectionalArrowLength")){var U=pi(e.linkDirectionalArrowLength),F=pi(e.linkDirectionalArrowColor);e.arrowDataMapper.onCreateObj(function(){var st=new qn.Mesh(void 0,new qn.MeshLambertMaterial({transparent:!0}));return st.__linkThreeObjType="arrow",st}).onUpdateObj(function(st,Ee){var Oe=U(Ee),vt=e.linkDirectionalArrowResolution;if(!st.geometry.type.match(/^Cone(Buffer)?Geometry$/)||st.geometry.parameters.height!==Oe||st.geometry.parameters.radialSegments!==vt){var Zt=new qn.ConeGeometry(Oe*.25,Oe,vt);Zt.translate(0,Oe/2,0),Zt.rotateX(Math.PI/2),st.geometry.dispose(),st.geometry=Zt}var Pt=F(Ee)||w(Ee)||"#f0f0f0";st.material.color=new qn.Color(ny(Pt)),st.material.opacity=e.linkOpacity*3*vM(Pt)}).digest(I.filter(U))}if(e.linkDirectionalParticles||t.hasOwnProperty("linkDirectionalParticles")){var k=pi(e.linkDirectionalParticles),G=pi(e.linkDirectionalParticleWidth),B=pi(e.linkDirectionalParticleColor),z=pi(e.linkDirectionalParticleThreeObject),Q={},ye={};e.particlesDataMapper.onCreateObj(function(){var st=new qn.Group;return st.__linkThreeObjType="photons",st.__photonDataMapper=new ty(st),st}).onUpdateObj(function(st,Ee){var Oe=!!st.children.length&&st.children[0],vt=z(Ee),Zt,Pt;if(vt)Zt=vt.geometry,Pt=vt.material;else{var wn=Math.ceil(G(Ee)*10)/10/2,ai=e.linkDirectionalParticleResolution;Oe&&Oe.geometry.parameters.radius===wn&&Oe.geometry.parameters.widthSegments===ai?Zt=Oe.geometry:(ye.hasOwnProperty(wn)||(ye[wn]=new qn.SphereGeometry(wn,ai,ai)),Zt=ye[wn]);var Wn=B(Ee)||w(Ee)||"#f0f0f0",rt=new qn.Color(ny(Wn)),yt=e.linkOpacity*3;Oe&&Oe.material.color.equals(rt)&&Oe.material.opacity===yt?Pt=Oe.material:(Q.hasOwnProperty(Wn)||(Q[Wn]=new qn.MeshLambertMaterial({color:rt,transparent:!0,opacity:yt})),Pt=Q[Wn])}Oe&&(Oe.geometry!==Zt&&Oe.geometry.dispose(),Oe.material!==Pt&&Oe.material.dispose());var ct=Math.round(Math.abs(k(Ee)));st.__photonDataMapper.id(function(Ft){return Ft.idx}).onCreateObj(function(){return new qn.Mesh(Zt,Pt)}).onUpdateObj(function(Ft){Ft.geometry=Zt,Ft.material=Pt}).digest(wl(new Array(ct)).map(function(Ft,ne){return{idx:ne}}))}).digest(I.filter(k))}}if(e._flushObjects=!1,n(["graphData","nodeId","linkSource","linkTarget","numDimensions","forceEngine","dagMode","dagNodeFilter","dagLevelDistance"])){e.engineRunning=!1,e.graphData.links.forEach(function(st){st.source=st[e.linkSource],st.target=st[e.linkTarget]});var _e=e.forceEngine!=="ngraph",Te;if(_e){(Te=e.d3ForceLayout).stop().alpha(1).numDimensions(e.numDimensions).nodes(e.graphData.nodes);var Pe=e.d3ForceLayout.force("link");Pe&&Pe.id(function(st){return st[e.nodeId]}).links(e.graphData.links);var Ne=e.dagMode&&DF(e.graphData,function(st){return st[e.nodeId]},{nodeFilter:e.dagNodeFilter,onLoopError:e.onDagError||void 0}),De=Math.max.apply(Math,wl(Object.values(Ne||[]))),Qe=e.dagLevelDistance||e.graphData.nodes.length/(De||1)*FF*(["radialin","radialout"].indexOf(e.dagMode)!==-1?.7:1);if(["lr","rl","td","bu","zin","zout"].includes(t.dagMode)){var Mt=["lr","rl"].includes(t.dagMode)?"fx":["td","bu"].includes(t.dagMode)?"fy":"fz";e.graphData.nodes.filter(e.dagNodeFilter).forEach(function(st){return delete st[Mt]})}if(["lr","rl","td","bu","zin","zout"].includes(e.dagMode)){var Tt=["rl","td","zout"].includes(e.dagMode),Fe=function(Ee){return(Ne[Ee[e.nodeId]]-De/2)*Qe*(Tt?-1:1)},mt=["lr","rl"].includes(e.dagMode)?"fx":["td","bu"].includes(e.dagMode)?"fy":"fz";e.graphData.nodes.filter(e.dagNodeFilter).forEach(function(st){return st[mt]=Fe(st)})}e.d3ForceLayout.force("dagRadial",["radialin","radialout"].indexOf(e.dagMode)!==-1?zi(function(st){var Ee=Ne[st[e.nodeId]]||-1;return(e.dagMode==="radialin"?De-Ee:Ee)*Qe}).strength(function(st){return e.dagNodeFilter(st)?1:0}):null)}else{var wt=SE.graph();e.graphData.nodes.forEach(function(st){wt.addNode(st[e.nodeId])}),e.graphData.links.forEach(function(st){wt.addLink(st.source,st.target)}),Te=SE.forcelayout(wt,RF({dimensions:e.numDimensions},e.ngraphPhysics)),Te.graph=wt}for(var In=0;In<e.warmupTicks&&!(_e&&e.d3AlphaMin>0&&e.d3ForceLayout.alpha()<e.d3AlphaMin);In++)Te[_e?"tick":"step"]();e.layout=Te,this.resetCountdown()}e.engineRunning=!0,e.onFinishUpdate()}});function OF(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Object,t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,n=function(r){function o(){var a;uE(this,o);for(var c=arguments.length,u=new Array(c),d=0;d<c;d++)u[d]=arguments[d];return a=cE(this,o,[].concat(u)),a.__kapsuleInstance=fE(i,[].concat(wl(t?[a]:[]),u)),a}return mE(o,r),pE(o)}(e);return Object.keys(i()).forEach(function(r){return n.prototype[r]=function(){var o,a=(o=this.__kapsuleInstance)[r].apply(o,arguments);return a===this.__kapsuleInstance?this:a}}),n}var UF=window.THREE?window.THREE:{Group:Lo},ME=OF(BF,UF.Group,!0);function TE(){let i=null,e=!1,t=null,n=null;function r(o,a){t(o,a),n=i.requestAnimationFrame(r)}return{start:function(){e!==!0&&t!==null&&(n=i.requestAnimationFrame(r),e=!0)},stop:function(){i.cancelAnimationFrame(n),e=!1},setAnimationLoop:function(o){t=o},setContext:function(o){i=o}}}function kF(i){const e=new WeakMap;function t(c,u){const d=c.array,p=c.usage,m=d.byteLength,y=i.createBuffer();i.bindBuffer(u,y),i.bufferData(u,d,p),c.onUploadCallback();let x;if(d instanceof Float32Array)x=i.FLOAT;else if(typeof Float16Array!="undefined"&&d instanceof Float16Array)x=i.HALF_FLOAT;else if(d instanceof Uint16Array)c.isFloat16BufferAttribute?x=i.HALF_FLOAT:x=i.UNSIGNED_SHORT;else if(d instanceof Int16Array)x=i.SHORT;else if(d instanceof Uint32Array)x=i.UNSIGNED_INT;else if(d instanceof Int32Array)x=i.INT;else if(d instanceof Int8Array)x=i.BYTE;else if(d instanceof Uint8Array)x=i.UNSIGNED_BYTE;else if(d instanceof Uint8ClampedArray)x=i.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+d);return{buffer:y,type:x,bytesPerElement:d.BYTES_PER_ELEMENT,version:c.version,size:m}}function n(c,u,d){const p=u.array,m=u.updateRanges;if(i.bindBuffer(d,c),m.length===0)i.bufferSubData(d,0,p);else{m.sort((x,v)=>x.start-v.start);let y=0;for(let x=1;x<m.length;x++){const v=m[y],w=m[x];w.start<=v.start+v.count+1?v.count=Math.max(v.count,w.start+w.count-v.start):(++y,m[y]=w)}m.length=y+1;for(let x=0,v=m.length;x<v;x++){const w=m[x];i.bufferSubData(d,w.start*p.BYTES_PER_ELEMENT,p,w.start,w.count)}u.clearUpdateRanges()}u.onUploadCallback()}function r(c){return c.isInterleavedBufferAttribute&&(c=c.data),e.get(c)}function o(c){c.isInterleavedBufferAttribute&&(c=c.data);const u=e.get(c);u&&(i.deleteBuffer(u.buffer),e.delete(c))}function a(c,u){if(c.isInterleavedBufferAttribute&&(c=c.data),c.isGLBufferAttribute){const p=e.get(c);(!p||p.version<c.version)&&e.set(c,{buffer:c.buffer,type:c.type,bytesPerElement:c.elementSize,version:c.version});return}const d=e.get(c);if(d===void 0)e.set(c,t(c,u));else if(d.version<c.version){if(d.size!==c.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.");n(d.buffer,c,u),d.version=c.version}}return{get:r,remove:o,update:a}}var zF=`#ifdef USE_ALPHAHASH
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
#endif`,VF=`#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`,GF=`#ifdef USE_ALPHAMAP
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
#endif`,WF=`#ifdef USE_ALPHAMAP
uniform sampler2D alphaMap;
#endif`,HF=`#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`,$F=`#ifdef USE_ALPHATEST
uniform float alphaTest;
#endif`,qF=`#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`,XF=`#ifdef USE_AOMAP
uniform sampler2D aoMap;
uniform float aoMapIntensity;
#endif`,jF=`#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`,YF=`#ifdef USE_BATCHING
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
#endif`,ZF=`vec3 transformed = vec3( position );
#ifdef USE_ALPHAHASH
vPosition = vec3( position );
#endif`,KF=`vec3 objectNormal = vec3( normal );
#ifdef USE_TANGENT
vec3 objectTangent = vec3( tangent.xyz );
#endif`,JF=`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`,QF=`#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`,eB=`#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`,tB=`#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`,nB=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
#endif`,iB=`#if NUM_CLIPPING_PLANES > 0
varying vec3 vClipPosition;
#endif`,sB=`#if NUM_CLIPPING_PLANES > 0
vClipPosition = - mvPosition.xyz;
#endif`,rB=`#if defined( USE_COLOR_ALPHA )
diffuseColor *= vColor;
#elif defined( USE_COLOR )
diffuseColor.rgb *= vColor;
#endif`,oB=`#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#elif defined( USE_COLOR )
varying vec3 vColor;
#endif`,aB=`#if defined( USE_COLOR_ALPHA )
varying vec4 vColor;
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
varying vec3 vColor;
#endif`,lB=`#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`,cB=`#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`,uB=`#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`,hB=`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`,dB=`#ifdef USE_DISPLACEMENTMAP
uniform sampler2D displacementMap;
uniform float displacementScale;
uniform float displacementBias;
#endif`,fB=`#ifdef USE_DISPLACEMENTMAP
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
#endif`,pB=`#ifdef USE_EMISSIVEMAP
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
emissiveColor = sRGBTransferEOTF( emissiveColor );
#endif
totalEmissiveRadiance *= emissiveColor.rgb;
#endif`,mB=`#ifdef USE_EMISSIVEMAP
uniform sampler2D emissiveMap;
#endif`,gB="gl_FragColor = linearToOutputTexel( gl_FragColor );",yB=`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 );
}`,_B=`#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`,xB=`#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`,vB=`#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`,bB=`#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`,SB=`#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`,MB=`#ifdef USE_FOG
vFogDepth = - mvPosition.z;
#endif`,TB=`#ifdef USE_FOG
varying float vFogDepth;
#endif`,wB=`#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`,AB=`#ifdef USE_FOG
uniform vec3 fogColor;
varying float vFogDepth;
#ifdef FOG_EXP2
uniform float fogDensity;
#else
uniform float fogNear;
uniform float fogFar;
#endif
#endif`,EB=`#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
}`,CB=`#ifdef USE_LIGHTMAP
uniform sampler2D lightMap;
uniform float lightMapIntensity;
#endif`,RB=`LambertMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularStrength = specularStrength;`,NB=`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`,PB=`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`,IB=`#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`,LB=`ToonMaterial material;
material.diffuseColor = diffuseColor.rgb;`,DB=`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`,FB=`BlinnPhongMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.specularColor = specular;
material.specularShininess = shininess;
material.specularStrength = specularStrength;`,BB=`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`,OB=`PhysicalMaterial material;
material.diffuseColor = diffuseColor.rgb;
material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
material.metalness = 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 = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor;
material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor );
#else
material.specularColor = vec3( 0.04 );
material.specularColorBlended = mix( material.specularColor, 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.0001, 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`,UB=`uniform sampler2D dfgLUT;
struct PhysicalMaterial {
vec3 diffuseColor;
vec3 diffuseContribution;
vec3 specularColor;
vec3 specularColorBlended;
float roughness;
float metalness;
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;
vec3 iridescenceFresnelDielectric;
vec3 iridescenceFresnelMetallic;
#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 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.specularColorBlended;
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 rInv = 1.0 / ( roughness + 0.1 );
float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv;
float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv;
float DG = exp( a * dotNV + b );
return saturate( DG );
}
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
float dotNV = saturate( dot( normal, viewDir ) );
vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;
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
float dotNV = saturate( dot( normal, viewDir ) );
vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg;
#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 = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg;
vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg;
vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y;
vec3 FssEss_L = material.specularColorBlended * 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.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619;
vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * 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.specularColorBlended * t2.x + ( vec3( 1.0 ) - material.specularColorBlended ) * t2.y );
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
reflectedLight.directDiffuse += lightColor * material.diffuseContribution * 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 );
float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness );
float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL );
irradiance *= sheenEnergyComp;
#endif
reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material );
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution );
}
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 ) {
vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution );
#ifdef USE_SHEEN
float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;
diffuse *= sheenEnergyComp;
#endif
reflectedLight.indirectDiffuse += diffuse;
}
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 ) * RECIPROCAL_PI;
#endif
vec3 singleScatteringDielectric = vec3( 0.0 );
vec3 multiScatteringDielectric = vec3( 0.0 );
vec3 singleScatteringMetallic = vec3( 0.0 );
vec3 multiScatteringMetallic = vec3( 0.0 );
#ifdef USE_IRIDESCENCE
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
#else
computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric );
computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic );
#endif
vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness );
vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness );
vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric;
vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric );
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
vec3 indirectSpecular = radiance * singleScattering;
indirectSpecular += multiScattering * cosineWeightedIrradiance;
vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance;
#ifdef USE_SHEEN
float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo;
indirectSpecular *= sheenEnergyComp;
indirectDiffuse *= sheenEnergyComp;
#endif
reflectedLight.indirectSpecular += indirectSpecular;
reflectedLight.indirectDiffuse += indirectDiffuse;
}
#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 );
}`,kB=`
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.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor );
material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness );
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 ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )
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`,zB=`#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`,VB=`#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`,GB=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
#endif`,WB=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
uniform float logDepthBufFC;
varying float vFragDepth;
varying float vIsPerspective;
#endif`,HB=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
varying float vFragDepth;
varying float vIsPerspective;
#endif`,$B=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
vFragDepth = 1.0 + gl_Position.w;
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
#endif`,qB=`#ifdef USE_MAP
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
#ifdef DECODE_VIDEO_TEXTURE
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
#endif
diffuseColor *= sampledDiffuseColor;
#endif`,XB=`#ifdef USE_MAP
uniform sampler2D map;
#endif`,jB=`#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`,YB=`#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`,ZB=`float metalnessFactor = metalness;
#ifdef USE_METALNESSMAP
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
metalnessFactor *= texelMetalness.b;
#endif`,KB=`#ifdef USE_METALNESSMAP
uniform sampler2D metalnessMap;
#endif`,JB=`#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`,QB=`#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`,eO=`#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`,tO=`#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`,nO=`#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`,iO=`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;`,sO=`#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`,rO=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,oO=`#ifndef FLAT_SHADED
varying vec3 vNormal;
#ifdef USE_TANGENT
varying vec3 vTangent;
varying vec3 vBitangent;
#endif
#endif`,aO=`#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`,cO=`#ifdef USE_CLEARCOAT
vec3 clearcoatNormal = nonPerturbedNormal;
#endif`,uO=`#ifdef USE_CLEARCOAT_NORMALMAP
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
clearcoatMapN.xy *= clearcoatNormalScale;
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
#endif`,hO=`#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`,dO=`#ifdef USE_IRIDESCENCEMAP
uniform sampler2D iridescenceMap;
#endif
#ifdef USE_IRIDESCENCE_THICKNESSMAP
uniform sampler2D iridescenceThicknessMap;
#endif`,fO=`#ifdef OPAQUE
diffuseColor.a = 1.0;
#endif
#ifdef USE_TRANSMISSION
diffuseColor.a *= material.transmissionAlpha;
#endif
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,pO=`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 );
}`,mO=`#ifdef PREMULTIPLIED_ALPHA
gl_FragColor.rgb *= gl_FragColor.a;
#endif`,gO=`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;`,yO=`#ifdef DITHERING
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
#endif`,_O=`#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`,xO=`float roughnessFactor = roughness;
#ifdef USE_ROUGHNESSMAP
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
roughnessFactor *= texelRoughness.g;
#endif`,vO=`#ifdef USE_ROUGHNESSMAP
uniform sampler2D roughnessMap;
#endif`,bO=`#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
#if defined( SHADOWMAP_TYPE_PCF )
uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
#else
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
#endif
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
#if defined( SHADOWMAP_TYPE_PCF )
uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
#else
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
#endif
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
#if defined( SHADOWMAP_TYPE_PCF )
uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
#elif defined( SHADOWMAP_TYPE_BASIC )
uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
#endif
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
#if defined( SHADOWMAP_TYPE_PCF )
float interleavedGradientNoise( vec2 position ) {
return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );
}
vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {
const float goldenAngle = 2.399963229728653;
float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );
float theta = float( sampleIndex ) * goldenAngle + phi;
return vec2( cos( theta ), sin( theta ) ) * r;
}
#endif
#if defined( SHADOWMAP_TYPE_PCF )
float getShadow( sampler2DShadow 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 ) {
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
float radius = shadowRadius * texelSize.x;
float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;
shadow = (
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )
) * 0.2;
}
return mix( 1.0, shadow, shadowIntensity );
}
#elif defined( SHADOWMAP_TYPE_VSM )
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 ) {
vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;
float mean = distribution.x;
float variance = distribution.y * distribution.y;
#ifdef USE_REVERSED_DEPTH_BUFFER
float hard_shadow = step( mean, shadowCoord.z );
#else
float hard_shadow = step( shadowCoord.z, mean );
#endif
if ( hard_shadow == 1.0 ) {
shadow = 1.0;
} else {
variance = max( variance, 0.0000001 );
float d = shadowCoord.z - mean;
float p_max = variance / ( variance + d * d );
p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );
shadow = max( hard_shadow, p_max );
}
}
return mix( 1.0, shadow, shadowIntensity );
}
#else
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 ) {
float depth = texture2D( shadowMap, shadowCoord.xy ).r;
#ifdef USE_REVERSED_DEPTH_BUFFER
shadow = step( depth, shadowCoord.z );
#else
shadow = step( shadowCoord.z, depth );
#endif
}
return mix( 1.0, shadow, shadowIntensity );
}
#endif
#if NUM_POINT_LIGHT_SHADOWS > 0
#if defined( SHADOWMAP_TYPE_PCF )
float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
float shadow = 1.0;
vec3 lightToPosition = shadowCoord.xyz;
vec3 bd3D = normalize( lightToPosition );
vec3 absVec = abs( lightToPosition );
float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
dp += shadowBias;
float texelSize = shadowRadius / shadowMapSize.x;
vec3 absDir = abs( bd3D );
vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );
tangent = normalize( cross( bd3D, tangent ) );
vec3 bitangent = cross( bd3D, tangent );
float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;
shadow = (
texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 0, 5, phi ).x + bitangent * vogelDiskSample( 0, 5, phi ).y ) * texelSize, dp ) ) +
texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 1, 5, phi ).x + bitangent * vogelDiskSample( 1, 5, phi ).y ) * texelSize, dp ) ) +
texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 2, 5, phi ).x + bitangent * vogelDiskSample( 2, 5, phi ).y ) * texelSize, dp ) ) +
texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 3, 5, phi ).x + bitangent * vogelDiskSample( 3, 5, phi ).y ) * texelSize, dp ) ) +
texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 4, 5, phi ).x + bitangent * vogelDiskSample( 4, 5, phi ).y ) * texelSize, dp ) )
) * 0.2;
}
return mix( 1.0, shadow, shadowIntensity );
}
#elif defined( SHADOWMAP_TYPE_BASIC )
float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
float shadow = 1.0;
vec3 lightToPosition = shadowCoord.xyz;
vec3 bd3D = normalize( lightToPosition );
vec3 absVec = abs( lightToPosition );
float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
dp += shadowBias;
float depth = textureCube( shadowMap, bd3D ).r;
#ifdef USE_REVERSED_DEPTH_BUFFER
shadow = step( depth, dp );
#else
shadow = step( dp, depth );
#endif
}
return mix( 1.0, shadow, shadowIntensity );
}
#endif
#endif
#endif`,SO=`#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`,MO=`#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`,TO=`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 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) )
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;
}`,wO=`#ifdef USE_SKINNING
mat4 boneMatX = getBoneMatrix( skinIndex.x );
mat4 boneMatY = getBoneMatrix( skinIndex.y );
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
mat4 boneMatW = getBoneMatrix( skinIndex.w );
#endif`,AO=`#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`,EO=`#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`,CO=`#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`,RO=`float specularStrength;
#ifdef USE_SPECULARMAP
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
specularStrength = texelSpecular.r;
#else
specularStrength = 1.0;
#endif`,NO=`#ifdef USE_SPECULARMAP
uniform sampler2D specularMap;
#endif`,PO=`#if defined( TONE_MAPPING )
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
#endif`,IO=`#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; }`,LO=`#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.diffuseContribution, material.specularColorBlended, 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`,DO=`#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`,FO=`#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`,BO=`#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`,OO=`#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`,UO=`#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 ri={alphahash_fragment:zF,alphahash_pars_fragment:VF,alphamap_fragment:GF,alphamap_pars_fragment:WF,alphatest_fragment:HF,alphatest_pars_fragment:$F,aomap_fragment:qF,aomap_pars_fragment:XF,batching_pars_vertex:jF,batching_vertex:YF,begin_vertex:ZF,beginnormal_vertex:KF,bsdfs:JF,iridescence_fragment:QF,bumpmap_pars_fragment:eB,clipping_planes_fragment:tB,clipping_planes_pars_fragment:nB,clipping_planes_pars_vertex:iB,clipping_planes_vertex:sB,color_fragment:rB,color_pars_fragment:oB,color_pars_vertex:aB,color_vertex:lB,common:cB,cube_uv_reflection_fragment:uB,defaultnormal_vertex:hB,displacementmap_pars_vertex:dB,displacementmap_vertex:fB,emissivemap_fragment:pB,emissivemap_pars_fragment:mB,colorspace_fragment:gB,colorspace_pars_fragment:yB,envmap_fragment:_B,envmap_common_pars_fragment:xB,envmap_pars_fragment:vB,envmap_pars_vertex:bB,envmap_physical_pars_fragment:IB,envmap_vertex:SB,fog_vertex:MB,fog_pars_vertex:TB,fog_fragment:wB,fog_pars_fragment:AB,gradientmap_pars_fragment:EB,lightmap_pars_fragment:CB,lights_lambert_fragment:RB,lights_lambert_pars_fragment:NB,lights_pars_begin:PB,lights_toon_fragment:LB,lights_toon_pars_fragment:DB,lights_phong_fragment:FB,lights_phong_pars_fragment:BB,lights_physical_fragment:OB,lights_physical_pars_fragment:UB,lights_fragment_begin:kB,lights_fragment_maps:zB,lights_fragment_end:VB,logdepthbuf_fragment:GB,logdepthbuf_pars_fragment:WB,logdepthbuf_pars_vertex:HB,logdepthbuf_vertex:$B,map_fragment:qB,map_pars_fragment:XB,map_particle_fragment:jB,map_particle_pars_fragment:YB,metalnessmap_fragment:ZB,metalnessmap_pars_fragment:KB,morphinstance_vertex:JB,morphcolor_vertex:QB,morphnormal_vertex:eO,morphtarget_pars_vertex:tO,morphtarget_vertex:nO,normal_fragment_begin:iO,normal_fragment_maps:sO,normal_pars_fragment:rO,normal_pars_vertex:oO,normal_vertex:aO,normalmap_pars_fragment:lO,clearcoat_normal_fragment_begin:cO,clearcoat_normal_fragment_maps:uO,clearcoat_pars_fragment:hO,iridescence_pars_fragment:dO,opaque_fragment:fO,packing:pO,premultiplied_alpha_fragment:mO,project_vertex:gO,dithering_fragment:yO,dithering_pars_fragment:_O,roughnessmap_fragment:xO,roughnessmap_pars_fragment:vO,shadowmap_pars_fragment:bO,shadowmap_pars_vertex:SO,shadowmap_vertex:MO,shadowmask_pars_fragment:TO,skinbase_vertex:wO,skinning_pars_vertex:AO,skinning_vertex:EO,skinnormal_vertex:CO,specularmap_fragment:RO,specularmap_pars_fragment:NO,tonemapping_fragment:PO,tonemapping_pars_fragment:IO,transmission_fragment:LO,transmission_pars_fragment:DO,uv_pars_fragment:FO,uv_pars_vertex:BO,uv_vertex:OO,worldpos_vertex:UO,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
}`,distance_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;
}`,distance_frag:`#define DISTANCE
uniform vec3 referencePosition;
uniform float nearDistance;
uniform float farDistance;
varying vec3 vWorldPosition;
#include <common>
#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 = vec4( dist, 0.0, 0.0, 1.0 );
}`,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 <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 <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( normalize( normal ) * 0.5 + 0.5, 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 <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 <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
outgoingLight = outgoingLight + 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 <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 <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>
}`},qt={common:{diffuse:{value:new It(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Nn},alphaMap:{value:null},alphaMapTransform:{value:new Nn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Nn}},envmap:{envMap:{value:null},envMapRotation:{value:new Nn},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 Nn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Nn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Nn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Nn},normalScale:{value:new ze(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Nn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Nn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Nn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Nn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new It(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 It(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Nn},alphaTest:{value:0},uvTransform:{value:new Nn}},sprite:{diffuse:{value:new It(16777215)},opacity:{value:1},center:{value:new ze(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Nn},alphaMap:{value:null},alphaMapTransform:{value:new Nn},alphaTest:{value:0}}},Sc={basic:{uniforms:fs([qt.common,qt.specularmap,qt.envmap,qt.aomap,qt.lightmap,qt.fog]),vertexShader:ri.meshbasic_vert,fragmentShader:ri.meshbasic_frag},lambert:{uniforms:fs([qt.common,qt.specularmap,qt.envmap,qt.aomap,qt.lightmap,qt.emissivemap,qt.bumpmap,qt.normalmap,qt.displacementmap,qt.fog,qt.lights,{emissive:{value:new It(0)}}]),vertexShader:ri.meshlambert_vert,fragmentShader:ri.meshlambert_frag},phong:{uniforms:fs([qt.common,qt.specularmap,qt.envmap,qt.aomap,qt.lightmap,qt.emissivemap,qt.bumpmap,qt.normalmap,qt.displacementmap,qt.fog,qt.lights,{emissive:{value:new It(0)},specular:{value:new It(1118481)},shininess:{value:30}}]),vertexShader:ri.meshphong_vert,fragmentShader:ri.meshphong_frag},standard:{uniforms:fs([qt.common,qt.envmap,qt.aomap,qt.lightmap,qt.emissivemap,qt.bumpmap,qt.normalmap,qt.displacementmap,qt.roughnessmap,qt.metalnessmap,qt.fog,qt.lights,{emissive:{value:new It(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:ri.meshphysical_vert,fragmentShader:ri.meshphysical_frag},toon:{uniforms:fs([qt.common,qt.aomap,qt.lightmap,qt.emissivemap,qt.bumpmap,qt.normalmap,qt.displacementmap,qt.gradientmap,qt.fog,qt.lights,{emissive:{value:new It(0)}}]),vertexShader:ri.meshtoon_vert,fragmentShader:ri.meshtoon_frag},matcap:{uniforms:fs([qt.common,qt.bumpmap,qt.normalmap,qt.displacementmap,qt.fog,{matcap:{value:null}}]),vertexShader:ri.meshmatcap_vert,fragmentShader:ri.meshmatcap_frag},points:{uniforms:fs([qt.points,qt.fog]),vertexShader:ri.points_vert,fragmentShader:ri.points_frag},dashed:{uniforms:fs([qt.common,qt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:ri.linedashed_vert,fragmentShader:ri.linedashed_frag},depth:{uniforms:fs([qt.common,qt.displacementmap]),vertexShader:ri.depth_vert,fragmentShader:ri.depth_frag},normal:{uniforms:fs([qt.common,qt.bumpmap,qt.normalmap,qt.displacementmap,{opacity:{value:1}}]),vertexShader:ri.meshnormal_vert,fragmentShader:ri.meshnormal_frag},sprite:{uniforms:fs([qt.sprite,qt.fog]),vertexShader:ri.sprite_vert,fragmentShader:ri.sprite_frag},background:{uniforms:{uvTransform:{value:new Nn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:ri.background_vert,fragmentShader:ri.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Nn}},vertexShader:ri.backgroundCube_vert,fragmentShader:ri.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:ri.cube_vert,fragmentShader:ri.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:ri.equirect_vert,fragmentShader:ri.equirect_frag},distance:{uniforms:fs([qt.common,qt.displacementmap,{referencePosition:{value:new H},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:ri.distance_vert,fragmentShader:ri.distance_frag},shadow:{uniforms:fs([qt.lights,qt.fog,{color:{value:new It(0)},opacity:{value:1}}]),vertexShader:ri.shadow_vert,fragmentShader:ri.shadow_frag}};Sc.physical={uniforms:fs([Sc.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Nn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Nn},clearcoatNormalScale:{value:new ze(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Nn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Nn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Nn},sheen:{value:0},sheenColor:{value:new It(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Nn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Nn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Nn},transmissionSamplerSize:{value:new ze},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Nn},attenuationDistance:{value:0},attenuationColor:{value:new It(0)},specularColor:{value:new It(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Nn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Nn},anisotropyVector:{value:new ze},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Nn}}]),vertexShader:ri.meshphysical_vert,fragmentShader:ri.meshphysical_frag};const Yx={r:0,b:0,g:0},jf=new jr,kO=new Qt;function zO(i,e,t,n,r,o,a){const c=new It(0);let u=o===!0?0:1,d,p,m=null,y=0,x=null;function v(N){let I=N.isScene===!0?N.background:null;return I&&I.isTexture&&(I=(N.backgroundBlurriness>0?t:e).get(I)),I}function w(N){let I=!1;const U=v(N);U===null?S(c,u):U&&U.isColor&&(S(U,1),I=!0);const F=i.xr.getEnvironmentBlendMode();F==="additive"?n.buffers.color.setClear(0,0,0,1,a):F==="alpha-blend"&&n.buffers.color.setClear(0,0,0,0,a),(i.autoClear||I)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function M(N,I){const U=v(I);U&&(U.isCubeTexture||U.mapping===Fl)?(p===void 0&&(p=new Ji(new fl(1,1,1),new lo({name:"BackgroundCubeMaterial",uniforms:rd(Sc.backgroundCube.uniforms),vertexShader:Sc.backgroundCube.vertexShader,fragmentShader:Sc.backgroundCube.fragmentShader,side:we,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),p.geometry.deleteAttribute("normal"),p.geometry.deleteAttribute("uv"),p.onBeforeRender=function(F,k,G){this.matrixWorld.copyPosition(G.matrixWorld)},Object.defineProperty(p.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(p)),jf.copy(I.backgroundRotation),jf.x*=-1,jf.y*=-1,jf.z*=-1,U.isCubeTexture&&U.isRenderTargetTexture===!1&&(jf.y*=-1,jf.z*=-1),p.material.uniforms.envMap.value=U,p.material.uniforms.flipEnvMap.value=U.isCubeTexture&&U.isRenderTargetTexture===!1?-1:1,p.material.uniforms.backgroundBlurriness.value=I.backgroundBlurriness,p.material.uniforms.backgroundIntensity.value=I.backgroundIntensity,p.material.uniforms.backgroundRotation.value.setFromMatrix4(kO.makeRotationFromEuler(jf)),p.material.toneMapped=xn.getTransfer(U.colorSpace)!==$t,(m!==U||y!==U.version||x!==i.toneMapping)&&(p.material.needsUpdate=!0,m=U,y=U.version,x=i.toneMapping),p.layers.enableAll(),N.unshift(p,p.geometry,p.material,0,0,null)):U&&U.isTexture&&(d===void 0&&(d=new Ji(new Ed(2,2),new lo({name:"BackgroundMaterial",uniforms:rd(Sc.background.uniforms),vertexShader:Sc.background.vertexShader,fragmentShader:Sc.background.fragmentShader,side:Me,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),d.geometry.deleteAttribute("normal"),Object.defineProperty(d.material,"map",{get:function(){return this.uniforms.t2D.value}}),r.update(d)),d.material.uniforms.t2D.value=U,d.material.uniforms.backgroundIntensity.value=I.backgroundIntensity,d.material.toneMapped=xn.getTransfer(U.colorSpace)!==$t,U.matrixAutoUpdate===!0&&U.updateMatrix(),d.material.uniforms.uvTransform.value.copy(U.matrix),(m!==U||y!==U.version||x!==i.toneMapping)&&(d.material.needsUpdate=!0,m=U,y=U.version,x=i.toneMapping),d.layers.enableAll(),N.unshift(d,d.geometry,d.material,0,0,null))}function S(N,I){N.getRGB(Yx,Jg(i)),n.buffers.color.setClear(Yx.r,Yx.g,Yx.b,I,a)}function C(){p!==void 0&&(p.geometry.dispose(),p.material.dispose(),p=void 0),d!==void 0&&(d.geometry.dispose(),d.material.dispose(),d=void 0)}return{getClearColor:function(){return c},setClearColor:function(N,I=1){c.set(N),u=I,S(c,u)},getClearAlpha:function(){return u},setClearAlpha:function(N){u=N,S(c,u)},render:w,addToRenderList:M,dispose:C}}function VO(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=y(null);let o=r,a=!1;function c(z,Q,ye,_e,Te){let Pe=!1;const Ne=m(_e,ye,Q);o!==Ne&&(o=Ne,d(o.object)),Pe=x(z,_e,ye,Te),Pe&&v(z,_e,ye,Te),Te!==null&&e.update(Te,i.ELEMENT_ARRAY_BUFFER),(Pe||a)&&(a=!1,I(z,Q,ye,_e),Te!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(Te).buffer))}function u(){return i.createVertexArray()}function d(z){return i.bindVertexArray(z)}function p(z){return i.deleteVertexArray(z)}function m(z,Q,ye){const _e=ye.wireframe===!0;let Te=n[z.id];Te===void 0&&(Te={},n[z.id]=Te);let Pe=Te[Q.id];Pe===void 0&&(Pe={},Te[Q.id]=Pe);let Ne=Pe[_e];return Ne===void 0&&(Ne=y(u()),Pe[_e]=Ne),Ne}function y(z){const Q=[],ye=[],_e=[];for(let Te=0;Te<t;Te++)Q[Te]=0,ye[Te]=0,_e[Te]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:Q,enabledAttributes:ye,attributeDivisors:_e,object:z,attributes:{},index:null}}function x(z,Q,ye,_e){const Te=o.attributes,Pe=Q.attributes;let Ne=0;const De=ye.getAttributes();for(const Qe in De)if(De[Qe].location>=0){const Tt=Te[Qe];let Fe=Pe[Qe];if(Fe===void 0&&(Qe==="instanceMatrix"&&z.instanceMatrix&&(Fe=z.instanceMatrix),Qe==="instanceColor"&&z.instanceColor&&(Fe=z.instanceColor)),Tt===void 0||Tt.attribute!==Fe||Fe&&Tt.data!==Fe.data)return!0;Ne++}return o.attributesNum!==Ne||o.index!==_e}function v(z,Q,ye,_e){const Te={},Pe=Q.attributes;let Ne=0;const De=ye.getAttributes();for(const Qe in De)if(De[Qe].location>=0){let Tt=Pe[Qe];Tt===void 0&&(Qe==="instanceMatrix"&&z.instanceMatrix&&(Tt=z.instanceMatrix),Qe==="instanceColor"&&z.instanceColor&&(Tt=z.instanceColor));const Fe={};Fe.attribute=Tt,Tt&&Tt.data&&(Fe.data=Tt.data),Te[Qe]=Fe,Ne++}o.attributes=Te,o.attributesNum=Ne,o.index=_e}function w(){const z=o.newAttributes;for(let Q=0,ye=z.length;Q<ye;Q++)z[Q]=0}function M(z){S(z,0)}function S(z,Q){const ye=o.newAttributes,_e=o.enabledAttributes,Te=o.attributeDivisors;ye[z]=1,_e[z]===0&&(i.enableVertexAttribArray(z),_e[z]=1),Te[z]!==Q&&(i.vertexAttribDivisor(z,Q),Te[z]=Q)}function C(){const z=o.newAttributes,Q=o.enabledAttributes;for(let ye=0,_e=Q.length;ye<_e;ye++)Q[ye]!==z[ye]&&(i.disableVertexAttribArray(ye),Q[ye]=0)}function N(z,Q,ye,_e,Te,Pe,Ne){Ne===!0?i.vertexAttribIPointer(z,Q,ye,Te,Pe):i.vertexAttribPointer(z,Q,ye,_e,Te,Pe)}function I(z,Q,ye,_e){w();const Te=_e.attributes,Pe=ye.getAttributes(),Ne=Q.defaultAttributeValues;for(const De in Pe){const Qe=Pe[De];if(Qe.location>=0){let Mt=Te[De];if(Mt===void 0&&(De==="instanceMatrix"&&z.instanceMatrix&&(Mt=z.instanceMatrix),De==="instanceColor"&&z.instanceColor&&(Mt=z.instanceColor)),Mt!==void 0){const Tt=Mt.normalized,Fe=Mt.itemSize,mt=e.get(Mt);if(mt===void 0)continue;const wt=mt.buffer,In=mt.type,st=mt.bytesPerElement,Ee=In===i.INT||In===i.UNSIGNED_INT||Mt.gpuType===er;if(Mt.isInterleavedBufferAttribute){const Oe=Mt.data,vt=Oe.stride,Zt=Mt.offset;if(Oe.isInstancedInterleavedBuffer){for(let Pt=0;Pt<Qe.locationSize;Pt++)S(Qe.location+Pt,Oe.meshPerAttribute);z.isInstancedMesh!==!0&&_e._maxInstanceCount===void 0&&(_e._maxInstanceCount=Oe.meshPerAttribute*Oe.count)}else for(let Pt=0;Pt<Qe.locationSize;Pt++)M(Qe.location+Pt);i.bindBuffer(i.ARRAY_BUFFER,wt);for(let Pt=0;Pt<Qe.locationSize;Pt++)N(Qe.location+Pt,Fe/Qe.locationSize,In,Tt,vt*st,(Zt+Fe/Qe.locationSize*Pt)*st,Ee)}else{if(Mt.isInstancedBufferAttribute){for(let Oe=0;Oe<Qe.locationSize;Oe++)S(Qe.location+Oe,Mt.meshPerAttribute);z.isInstancedMesh!==!0&&_e._maxInstanceCount===void 0&&(_e._maxInstanceCount=Mt.meshPerAttribute*Mt.count)}else for(let Oe=0;Oe<Qe.locationSize;Oe++)M(Qe.location+Oe);i.bindBuffer(i.ARRAY_BUFFER,wt);for(let Oe=0;Oe<Qe.locationSize;Oe++)N(Qe.location+Oe,Fe/Qe.locationSize,In,Tt,Fe*st,Fe/Qe.locationSize*Oe*st,Ee)}}else if(Ne!==void 0){const Tt=Ne[De];if(Tt!==void 0)switch(Tt.length){case 2:i.vertexAttrib2fv(Qe.location,Tt);break;case 3:i.vertexAttrib3fv(Qe.location,Tt);break;case 4:i.vertexAttrib4fv(Qe.location,Tt);break;default:i.vertexAttrib1fv(Qe.location,Tt)}}}}C()}function U(){G();for(const z in n){const Q=n[z];for(const ye in Q){const _e=Q[ye];for(const Te in _e)p(_e[Te].object),delete _e[Te];delete Q[ye]}delete n[z]}}function F(z){if(n[z.id]===void 0)return;const Q=n[z.id];for(const ye in Q){const _e=Q[ye];for(const Te in _e)p(_e[Te].object),delete _e[Te];delete Q[ye]}delete n[z.id]}function k(z){for(const Q in n){const ye=n[Q];if(ye[z.id]===void 0)continue;const _e=ye[z.id];for(const Te in _e)p(_e[Te].object),delete _e[Te];delete ye[z.id]}}function G(){B(),a=!0,o!==r&&(o=r,d(o.object))}function B(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:c,reset:G,resetDefaultState:B,dispose:U,releaseStatesOfGeometry:F,releaseStatesOfProgram:k,initAttributes:w,enableAttribute:M,disableUnusedAttributes:C}}function GO(i,e,t){let n;function r(d){n=d}function o(d,p){i.drawArrays(n,d,p),t.update(p,n,1)}function a(d,p,m){m!==0&&(i.drawArraysInstanced(n,d,p,m),t.update(p,n,m))}function c(d,p,m){if(m===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,d,0,p,0,m);let x=0;for(let v=0;v<m;v++)x+=p[v];t.update(x,n,1)}function u(d,p,m,y){if(m===0)return;const x=e.get("WEBGL_multi_draw");if(x===null)for(let v=0;v<d.length;v++)a(d[v],p[v],y[v]);else{x.multiDrawArraysInstancedWEBGL(n,d,0,p,0,y,0,m);let v=0;for(let w=0;w<m;w++)v+=p[w]*y[w];t.update(v,n,1)}}this.setMode=r,this.render=o,this.renderInstances=a,this.renderMultiDraw=c,this.renderMultiDrawInstances=u}function WO(i,e,t,n){let r;function o(){if(r!==void 0)return r;if(e.has("EXT_texture_filter_anisotropic")===!0){const k=e.get("EXT_texture_filter_anisotropic");r=i.getParameter(k.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else r=0;return r}function a(k){return!(k!==Ri&&n.convert(k)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function c(k){const G=k===Hi&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(k!==Di&&n.convert(k)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&k!==Si&&!G)}function u(k){if(k==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";k="mediump"}return k==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let d=t.precision!==void 0?t.precision:"highp";const p=u(d);p!==d&&(Ie("WebGLRenderer:",d,"not supported, using",p,"instead."),d=p);const m=t.logarithmicDepthBuffer===!0,y=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control"),x=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),v=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),w=i.getParameter(i.MAX_TEXTURE_SIZE),M=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),S=i.getParameter(i.MAX_VERTEX_ATTRIBS),C=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),N=i.getParameter(i.MAX_VARYING_VECTORS),I=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),U=i.getParameter(i.MAX_SAMPLES),F=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:o,getMaxPrecision:u,textureFormatReadable:a,textureTypeReadable:c,precision:d,logarithmicDepthBuffer:m,reversedDepthBuffer:y,maxTextures:x,maxVertexTextures:v,maxTextureSize:w,maxCubemapSize:M,maxAttributes:S,maxVertexUniforms:C,maxVaryings:N,maxFragmentUniforms:I,maxSamples:U,samples:F}}function HO(i){const e=this;let t=null,n=0,r=!1,o=!1;const a=new uo,c=new Nn,u={value:null,needsUpdate:!1};this.uniform=u,this.numPlanes=0,this.numIntersection=0,this.init=function(m,y){const x=m.length!==0||y||n!==0||r;return r=y,n=m.length,x},this.beginShadows=function(){o=!0,p(null)},this.endShadows=function(){o=!1},this.setGlobalState=function(m,y){t=p(m,y,0)},this.setState=function(m,y,x){const v=m.clippingPlanes,w=m.clipIntersection,M=m.clipShadows,S=i.get(m);if(!r||v===null||v.length===0||o&&!M)o?p(null):d();else{const C=o?0:n,N=C*4;let I=S.clippingState||null;u.value=I,I=p(v,y,N,x);for(let U=0;U!==N;++U)I[U]=t[U];S.clippingState=I,this.numIntersection=w?this.numPlanes:0,this.numPlanes+=C}};function d(){u.value!==t&&(u.value=t,u.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function p(m,y,x,v){const w=m!==null?m.length:0;let M=null;if(w!==0){if(M=u.value,v!==!0||M===null){const S=x+w*4,C=y.matrixWorldInverse;c.getNormalMatrix(C),(M===null||M.length<S)&&(M=new Float32Array(S));for(let N=0,I=x;N!==w;++N,I+=4)a.copy(m[N]).applyMatrix4(C,c),a.normal.toArray(M,I),M[I+3]=a.constant}u.value=M,u.needsUpdate=!0}return e.numPlanes=w,e.numIntersection=0,M}}function $O(i){let e=new WeakMap;function t(a,c){return c===jc?a.mapping=Cr:c===Yc&&(a.mapping=Xo),a}function n(a){if(a&&a.isTexture){const c=a.mapping;if(c===jc||c===Yc)if(e.has(a)){const u=e.get(a).texture;return t(u,a.mapping)}else{const u=a.image;if(u&&u.height>0){const d=new cr(u.height);return d.fromEquirectangularTexture(i,a),e.set(a,d),a.addEventListener("dispose",r),t(d.texture,a.mapping)}else return null}}return a}function r(a){const c=a.target;c.removeEventListener("dispose",r);const u=e.get(c);u!==void 0&&(e.delete(c),u.dispose())}function o(){e=new WeakMap}return{get:n,dispose:o}}const Od=4,wE=[.125,.215,.35,.446,.526,.582],Yf=20,qO=256,iy=new $u,AE=new It;let SM=null,MM=0,TM=0,wM=!1;const XO=new H;class EE{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,n=.1,r=100,o={}){const{size:a=256,position:c=XO}=o;SM=this._renderer.getRenderTarget(),MM=this._renderer.getActiveCubeFace(),TM=this._renderer.getActiveMipmapLevel(),wM=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const u=this._allocateTargets();return u.depthBuffer=!0,this._sceneToCubeUV(e,n,r,u,c),t>0&&this._blur(u,0,0,t),this._applyPMREM(u),this._cleanup(u),u}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=NE(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=RE(),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(SM,MM,TM),this._renderer.xr.enabled=wM,e.scissorTest=!1,qm(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Cr||e.mapping===Xo?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),SM=this._renderer.getRenderTarget(),MM=this._renderer.getActiveCubeFace(),TM=this._renderer.getActiveMipmapLevel(),wM=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Yn,minFilter:Yn,generateMipmaps:!1,type:Hi,format:Ri,colorSpace:io,depthBuffer:!1},r=CE(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=CE(e,t,n);const{_lodMax:o}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=jO(o)),this._blurMaterial=ZO(o,e,t),this._ggxMaterial=YO(o,e,t)}return r}_compileMaterial(e){const t=new Ji(new Gn,e);this._renderer.compile(t,iy)}_sceneToCubeUV(e,t,n,r,o){const u=new Bs(90,1,t,n),d=[1,-1,1,1,1,1],p=[1,1,1,-1,-1,-1],m=this._renderer,y=m.autoClear,x=m.toneMapping;m.getClearColor(AE),m.toneMapping=yr,m.autoClear=!1,m.state.buffers.depth.getReversed()&&(m.setRenderTarget(r),m.clearDepth(),m.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Ji(new fl,new Or({name:"PMREM.Background",side:we,depthWrite:!1,depthTest:!1})));const w=this._backgroundBox,M=w.material;let S=!1;const C=e.background;C?C.isColor&&(M.color.copy(C),e.background=null,S=!0):(M.color.copy(AE),S=!0);for(let N=0;N<6;N++){const I=N%3;I===0?(u.up.set(0,d[N],0),u.position.set(o.x,o.y,o.z),u.lookAt(o.x+p[N],o.y,o.z)):I===1?(u.up.set(0,0,d[N]),u.position.set(o.x,o.y,o.z),u.lookAt(o.x,o.y+p[N],o.z)):(u.up.set(0,d[N],0),u.position.set(o.x,o.y,o.z),u.lookAt(o.x,o.y,o.z+p[N]));const U=this._cubeSize;qm(r,I*U,N>2?U:0,U,U),m.setRenderTarget(r),S&&m.render(w,u),m.render(e,u)}m.toneMapping=x,m.autoClear=y,e.background=C}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===Cr||e.mapping===Xo;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=NE()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=RE());const o=r?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=o;const c=o.uniforms;c.envMap.value=e;const u=this._cubeSize;qm(t,0,0,3*u,2*u),n.setRenderTarget(t),n.render(a,iy)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodMeshes.length;for(let o=1;o<r;o++)this._applyGGXFilter(e,o-1,o);t.autoClear=n}_applyGGXFilter(e,t,n){const r=this._renderer,o=this._pingPongRenderTarget,a=this._ggxMaterial,c=this._lodMeshes[n];c.material=a;const u=a.uniforms,d=n/(this._lodMeshes.length-1),p=t/(this._lodMeshes.length-1),m=Math.sqrt(d*d-p*p),y=0+d*1.25,x=m*y,{_lodMax:v}=this,w=this._sizeLods[n],M=3*w*(n>v-Od?n-v+Od:0),S=4*(this._cubeSize-w);u.envMap.value=e.texture,u.roughness.value=x,u.mipInt.value=v-t,qm(o,M,S,3*w,2*w),r.setRenderTarget(o),r.render(c,iy),u.envMap.value=o.texture,u.roughness.value=0,u.mipInt.value=v-n,qm(e,M,S,3*w,2*w),r.setRenderTarget(e),r.render(c,iy)}_blur(e,t,n,r,o){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,"latitudinal",o),this._halfBlur(a,e,n,n,r,"longitudinal",o)}_halfBlur(e,t,n,r,o,a,c){const u=this._renderer,d=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Be("blur direction must be either latitudinal or longitudinal!");const p=3,m=this._lodMeshes[r];m.material=d;const y=d.uniforms,x=this._sizeLods[n]-1,v=isFinite(o)?Math.PI/(2*x):2*Math.PI/(2*Yf-1),w=o/v,M=isFinite(o)?1+Math.floor(p*w):Yf;M>Yf&&Ie(`sigmaRadians, ${o}, is too large and will clip, as it requested ${M} samples when the maximum is set to ${Yf}`);const S=[];let C=0;for(let k=0;k<Yf;++k){const G=k/w,B=Math.exp(-G*G/2);S.push(B),k===0?C+=B:k<M&&(C+=2*B)}for(let k=0;k<S.length;k++)S[k]=S[k]/C;y.envMap.value=e.texture,y.samples.value=M,y.weights.value=S,y.latitudinal.value=a==="latitudinal",c&&(y.poleAxis.value=c);const{_lodMax:N}=this;y.dTheta.value=v,y.mipInt.value=N-n;const I=this._sizeLods[r],U=3*I*(r>N-Od?r-N+Od:0),F=4*(this._cubeSize-I);qm(t,U,F,3*I,2*I),u.setRenderTarget(t),u.render(m,iy)}}function jO(i){const e=[],t=[],n=[];let r=i;const o=i-Od+1+wE.length;for(let a=0;a<o;a++){const c=Math.pow(2,r);e.push(c);let u=1/c;a>i-Od?u=wE[a-i+Od-1]:a===0&&(u=0),t.push(u);const d=1/(c-2),p=-d,m=1+d,y=[p,p,m,p,m,m,p,p,m,m,p,m],x=6,v=6,w=3,M=2,S=1,C=new Float32Array(w*v*x),N=new Float32Array(M*v*x),I=new Float32Array(S*v*x);for(let F=0;F<x;F++){const k=F%3*2/3-1,G=F>2?0:-1,B=[k,G,0,k+2/3,G,0,k+2/3,G+1,0,k,G,0,k+2/3,G+1,0,k,G+1,0];C.set(B,w*v*F),N.set(y,M*v*F);const z=[F,F,F,F,F,F];I.set(z,S*v*F)}const U=new Gn;U.setAttribute("position",new $i(C,w)),U.setAttribute("uv",new $i(N,M)),U.setAttribute("faceIndex",new $i(I,S)),n.push(new Ji(U,null)),r>Od&&r--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function CE(i,e,t){const n=new qr(i,e,t);return n.texture.mapping=Fl,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function qm(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function YO(i,e,t){return new lo({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:qO,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:Zx(),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:ve,depthTest:!1,depthWrite:!1})}function ZO(i,e,t){const n=new Float32Array(Yf),r=new H(0,1,0);return new lo({name:"SphericalGaussianBlur",defines:{n:Yf,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:r}},vertexShader:Zx(),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:ve,depthTest:!1,depthWrite:!1})}function RE(){return new lo({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Zx(),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:ve,depthTest:!1,depthWrite:!1})}function NE(){return new lo({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Zx(),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:ve,depthTest:!1,depthWrite:!1})}function Zx(){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 KO(i){let e=new WeakMap,t=null;function n(c){if(c&&c.isTexture){const u=c.mapping,d=u===jc||u===Yc,p=u===Cr||u===Xo;if(d||p){let m=e.get(c);const y=m!==void 0?m.texture.pmremVersion:0;if(c.isRenderTargetTexture&&c.pmremVersion!==y)return t===null&&(t=new EE(i)),m=d?t.fromEquirectangular(c,m):t.fromCubemap(c,m),m.texture.pmremVersion=c.pmremVersion,e.set(c,m),m.texture;if(m!==void 0)return m.texture;{const x=c.image;return d&&x&&x.height>0||p&&x&&r(x)?(t===null&&(t=new EE(i)),m=d?t.fromEquirectangular(c):t.fromCubemap(c),m.texture.pmremVersion=c.pmremVersion,e.set(c,m),c.addEventListener("dispose",o),m.texture):null}}}return c}function r(c){let u=0;const d=6;for(let p=0;p<d;p++)c[p]!==void 0&&u++;return u===d}function o(c){const u=c.target;u.removeEventListener("dispose",o);const d=e.get(u);d!==void 0&&(e.delete(u),d.dispose())}function a(){e=new WeakMap,t!==null&&(t.dispose(),t=null)}return{get:n,dispose:a}}function JO(i){const e={};function t(n){if(e[n]!==void 0)return e[n];const r=i.getExtension(n);return e[n]=r,r}return{has:function(n){return t(n)!==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(n){const r=t(n);return r===null&&Ut("WebGLRenderer: "+n+" extension not supported."),r}}}function QO(i,e,t,n){const r={},o=new WeakMap;function a(m){const y=m.target;y.index!==null&&e.remove(y.index);for(const v in y.attributes)e.remove(y.attributes[v]);y.removeEventListener("dispose",a),delete r[y.id];const x=o.get(y);x&&(e.remove(x),o.delete(y)),n.releaseStatesOfGeometry(y),y.isInstancedBufferGeometry===!0&&delete y._maxInstanceCount,t.memory.geometries--}function c(m,y){return r[y.id]===!0||(y.addEventListener("dispose",a),r[y.id]=!0,t.memory.geometries++),y}function u(m){const y=m.attributes;for(const x in y)e.update(y[x],i.ARRAY_BUFFER)}function d(m){const y=[],x=m.index,v=m.attributes.position;let w=0;if(x!==null){const C=x.array;w=x.version;for(let N=0,I=C.length;N<I;N+=3){const U=C[N+0],F=C[N+1],k=C[N+2];y.push(U,F,F,k,k,U)}}else if(v!==void 0){const C=v.array;w=v.version;for(let N=0,I=C.length/3-1;N<I;N+=3){const U=N+0,F=N+1,k=N+2;y.push(U,F,F,k,k,U)}}else return;const M=new(M_(y)?fu:Kl)(y,1);M.version=w;const S=o.get(m);S&&e.remove(S),o.set(m,M)}function p(m){const y=o.get(m);if(y){const x=m.index;x!==null&&y.version<x.version&&d(m)}else d(m);return o.get(m)}return{get:c,update:u,getWireframeAttribute:p}}function eU(i,e,t){let n;function r(y){n=y}let o,a;function c(y){o=y.type,a=y.bytesPerElement}function u(y,x){i.drawElements(n,x,o,y*a),t.update(x,n,1)}function d(y,x,v){v!==0&&(i.drawElementsInstanced(n,x,o,y*a,v),t.update(x,n,v))}function p(y,x,v){if(v===0)return;e.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,x,0,o,y,0,v);let M=0;for(let S=0;S<v;S++)M+=x[S];t.update(M,n,1)}function m(y,x,v,w){if(v===0)return;const M=e.get("WEBGL_multi_draw");if(M===null)for(let S=0;S<y.length;S++)d(y[S]/a,x[S],w[S]);else{M.multiDrawElementsInstancedWEBGL(n,x,0,o,y,0,w,0,v);let S=0;for(let C=0;C<v;C++)S+=x[C]*w[C];t.update(S,n,1)}}this.setMode=r,this.setIndex=c,this.render=u,this.renderInstances=d,this.renderMultiDraw=p,this.renderMultiDrawInstances=m}function tU(i){const e={geometries:0,textures:0},t={frame:0,calls:0,triangles:0,points:0,lines:0};function n(o,a,c){switch(t.calls++,a){case i.TRIANGLES:t.triangles+=c*(o/3);break;case i.LINES:t.lines+=c*(o/2);break;case i.LINE_STRIP:t.lines+=c*(o-1);break;case i.LINE_LOOP:t.lines+=c*o;break;case i.POINTS:t.points+=c*o;break;default:Be("WebGLInfo: Unknown draw mode:",a);break}}function r(){t.calls=0,t.triangles=0,t.points=0,t.lines=0}return{memory:e,render:t,programs:null,autoReset:!0,reset:r,update:n}}function nU(i,e,t){const n=new WeakMap,r=new gn;function o(a,c,u){const d=a.morphTargetInfluences,p=c.morphAttributes.position||c.morphAttributes.normal||c.morphAttributes.color,m=p!==void 0?p.length:0;let y=n.get(c);if(y===void 0||y.count!==m){let B=function(){k.dispose(),n.delete(c),c.removeEventListener("dispose",B)};y!==void 0&&y.texture.dispose();const x=c.morphAttributes.position!==void 0,v=c.morphAttributes.normal!==void 0,w=c.morphAttributes.color!==void 0,M=c.morphAttributes.position||[],S=c.morphAttributes.normal||[],C=c.morphAttributes.color||[];let N=0;x===!0&&(N=1),v===!0&&(N=2),w===!0&&(N=3);let I=c.attributes.position.count*N,U=1;I>e.maxTextureSize&&(U=Math.ceil(I/e.maxTextureSize),I=e.maxTextureSize);const F=new Float32Array(I*U*4*m),k=new al(F,I,U,m);k.type=Si,k.needsUpdate=!0;const G=N*4;for(let z=0;z<m;z++){const Q=M[z],ye=S[z],_e=C[z],Te=I*U*4*z;for(let Pe=0;Pe<Q.count;Pe++){const Ne=Pe*G;x===!0&&(r.fromBufferAttribute(Q,Pe),F[Te+Ne+0]=r.x,F[Te+Ne+1]=r.y,F[Te+Ne+2]=r.z,F[Te+Ne+3]=0),v===!0&&(r.fromBufferAttribute(ye,Pe),F[Te+Ne+4]=r.x,F[Te+Ne+5]=r.y,F[Te+Ne+6]=r.z,F[Te+Ne+7]=0),w===!0&&(r.fromBufferAttribute(_e,Pe),F[Te+Ne+8]=r.x,F[Te+Ne+9]=r.y,F[Te+Ne+10]=r.z,F[Te+Ne+11]=_e.itemSize===4?r.w:1)}}y={count:m,texture:k,size:new ze(I,U)},n.set(c,y),c.addEventListener("dispose",B)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)u.getUniforms().setValue(i,"morphTexture",a.morphTexture,t);else{let x=0;for(let w=0;w<d.length;w++)x+=d[w];const v=c.morphTargetsRelative?1:1-x;u.getUniforms().setValue(i,"morphTargetBaseInfluence",v),u.getUniforms().setValue(i,"morphTargetInfluences",d)}u.getUniforms().setValue(i,"morphTargetsTexture",y.texture,t),u.getUniforms().setValue(i,"morphTargetsTextureSize",y.size)}return{update:o}}function iU(i,e,t,n){let r=new WeakMap;function o(u){const d=n.render.frame,p=u.geometry,m=e.get(u,p);if(r.get(m)!==d&&(e.update(m),r.set(m,d)),u.isInstancedMesh&&(u.hasEventListener("dispose",c)===!1&&u.addEventListener("dispose",c),r.get(u)!==d&&(t.update(u.instanceMatrix,i.ARRAY_BUFFER),u.instanceColor!==null&&t.update(u.instanceColor,i.ARRAY_BUFFER),r.set(u,d))),u.isSkinnedMesh){const y=u.skeleton;r.get(y)!==d&&(y.update(),r.set(y,d))}return m}function a(){r=new WeakMap}function c(u){const d=u.target;d.removeEventListener("dispose",c),t.remove(d.instanceMatrix),d.instanceColor!==null&&t.remove(d.instanceColor)}return{update:o,dispose:a}}const sU={[o_]:"LINEAR_TONE_MAPPING",[a_]:"REINHARD_TONE_MAPPING",[l_]:"CINEON_TONE_MAPPING",[c_]:"ACES_FILMIC_TONE_MAPPING",[u_]:"AGX_TONE_MAPPING",[h_]:"NEUTRAL_TONE_MAPPING",[qb]:"CUSTOM_TONE_MAPPING"};function rU(i,e,t,n,r){const o=new qr(e,t,{type:i,depthBuffer:n,stencilBuffer:r}),a=new qr(e,t,{type:Hi,depthBuffer:!1,stencilBuffer:!1}),c=new Gn;c.setAttribute("position",new ht([-1,3,0,-1,-1,0,3,-1,0],3)),c.setAttribute("uv",new ht([0,2,0,0,2,0],2));const u=new hx({uniforms:{tDiffuse:{value:null}},vertexShader:`
precision highp float;
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
attribute vec3 position;
attribute vec2 uv;
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,fragmentShader:`
precision highp float;
uniform sampler2D tDiffuse;
varying vec2 vUv;
#include <tonemapping_pars_fragment>
#include <colorspace_pars_fragment>
void main() {
gl_FragColor = texture2D( tDiffuse, vUv );
#ifdef LINEAR_TONE_MAPPING
gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
#elif defined( REINHARD_TONE_MAPPING )
gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
#elif defined( CINEON_TONE_MAPPING )
gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
#elif defined( ACES_FILMIC_TONE_MAPPING )
gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
#elif defined( AGX_TONE_MAPPING )
gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
#elif defined( NEUTRAL_TONE_MAPPING )
gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
#elif defined( CUSTOM_TONE_MAPPING )
gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
#endif
#ifdef SRGB_TRANSFER
gl_FragColor = sRGBTransferOETF( gl_FragColor );
#endif
}`,depthTest:!1,depthWrite:!1}),d=new Ji(c,u),p=new $u(-1,1,1,-1,0,1);let m=null,y=null,x=!1,v,w=null,M=[],S=!1;this.setSize=function(C,N){o.setSize(C,N),a.setSize(C,N);for(let I=0;I<M.length;I++){const U=M[I];U.setSize&&U.setSize(C,N)}},this.setEffects=function(C){M=C,S=M.length>0&&M[0].isRenderPass===!0;const N=o.width,I=o.height;for(let U=0;U<M.length;U++){const F=M[U];F.setSize&&F.setSize(N,I)}},this.begin=function(C,N){if(x||C.toneMapping===yr&&M.length===0)return!1;if(w=N,N!==null){const I=N.width,U=N.height;(o.width!==I||o.height!==U)&&this.setSize(I,U)}return S===!1&&C.setRenderTarget(o),v=C.toneMapping,C.toneMapping=yr,!0},this.hasRenderPass=function(){return S},this.end=function(C,N){C.toneMapping=v,x=!0;let I=o,U=a;for(let F=0;F<M.length;F++){const k=M[F];if(k.enabled!==!1&&(k.render(C,U,I,N),k.needsSwap!==!1)){const G=I;I=U,U=G}}if(m!==C.outputColorSpace||y!==C.toneMapping){m=C.outputColorSpace,y=C.toneMapping,u.defines={},xn.getTransfer(m)===$t&&(u.defines.SRGB_TRANSFER="");const F=sU[y];F&&(u.defines[F]=""),u.needsUpdate=!0}u.uniforms.tDiffuse.value=I.texture,C.setRenderTarget(w),C.render(d,p),w=null,x=!1},this.isCompositing=function(){return x},this.dispose=function(){o.dispose(),a.dispose(),c.dispose(),u.dispose()}}const PE=new fi,AM=new Ys(1,1),IE=new al,LE=new Wl,DE=new nc,FE=[],BE=[],OE=new Float32Array(16),UE=new Float32Array(9),kE=new Float32Array(4);function Xm(i,e,t){const n=i[0];if(n<=0||n>0)return i;const r=e*t;let o=FE[r];if(o===void 0&&(o=new Float32Array(r),FE[r]=o),e!==0){n.toArray(o,0);for(let a=1,c=0;a!==e;++a)c+=t,i[a].toArray(o,c)}return o}function fr(i,e){if(i.length!==e.length)return!1;for(let t=0,n=i.length;t<n;t++)if(i[t]!==e[t])return!1;return!0}function pr(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function Kx(i,e){let t=BE[e];t===void 0&&(t=new Int32Array(e),BE[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function oU(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function aU(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(fr(t,e))return;i.uniform2fv(this.addr,e),pr(t,e)}}function lU(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(fr(t,e))return;i.uniform3fv(this.addr,e),pr(t,e)}}function cU(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(fr(t,e))return;i.uniform4fv(this.addr,e),pr(t,e)}}function uU(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(fr(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),pr(t,e)}else{if(fr(t,n))return;kE.set(n),i.uniformMatrix2fv(this.addr,!1,kE),pr(t,n)}}function hU(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(fr(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),pr(t,e)}else{if(fr(t,n))return;UE.set(n),i.uniformMatrix3fv(this.addr,!1,UE),pr(t,n)}}function dU(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(fr(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),pr(t,e)}else{if(fr(t,n))return;OE.set(n),i.uniformMatrix4fv(this.addr,!1,OE),pr(t,n)}}function fU(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function pU(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(fr(t,e))return;i.uniform2iv(this.addr,e),pr(t,e)}}function mU(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(fr(t,e))return;i.uniform3iv(this.addr,e),pr(t,e)}}function gU(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(fr(t,e))return;i.uniform4iv(this.addr,e),pr(t,e)}}function yU(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function _U(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(fr(t,e))return;i.uniform2uiv(this.addr,e),pr(t,e)}}function xU(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(fr(t,e))return;i.uniform3uiv(this.addr,e),pr(t,e)}}function vU(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(fr(t,e))return;i.uniform4uiv(this.addr,e),pr(t,e)}}function bU(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r);let o;this.type===i.SAMPLER_2D_SHADOW?(AM.compareFunction=t.isReversedDepthBuffer()?Op:Bp,o=AM):o=PE,t.setTexture2D(e||o,r)}function SU(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture3D(e||LE,r)}function MU(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTextureCube(e||DE,r)}function TU(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture2DArray(e||IE,r)}function wU(i){switch(i){case 5126:return oU;case 35664:return aU;case 35665:return lU;case 35666:return cU;case 35674:return uU;case 35675:return hU;case 35676:return dU;case 5124:case 35670:return fU;case 35667:case 35671:return pU;case 35668:case 35672:return mU;case 35669:case 35673:return gU;case 5125:return yU;case 36294:return _U;case 36295:return xU;case 36296:return vU;case 35678:case 36198:case 36298:case 36306:case 35682:return bU;case 35679:case 36299:case 36307:return SU;case 35680:case 36300:case 36308:case 36293:return MU;case 36289:case 36303:case 36311:case 36292:return TU}}function AU(i,e){i.uniform1fv(this.addr,e)}function EU(i,e){const t=Xm(e,this.size,2);i.uniform2fv(this.addr,t)}function CU(i,e){const t=Xm(e,this.size,3);i.uniform3fv(this.addr,t)}function RU(i,e){const t=Xm(e,this.size,4);i.uniform4fv(this.addr,t)}function NU(i,e){const t=Xm(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function PU(i,e){const t=Xm(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function IU(i,e){const t=Xm(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function LU(i,e){i.uniform1iv(this.addr,e)}function DU(i,e){i.uniform2iv(this.addr,e)}function FU(i,e){i.uniform3iv(this.addr,e)}function BU(i,e){i.uniform4iv(this.addr,e)}function OU(i,e){i.uniform1uiv(this.addr,e)}function UU(i,e){i.uniform2uiv(this.addr,e)}function kU(i,e){i.uniform3uiv(this.addr,e)}function zU(i,e){i.uniform4uiv(this.addr,e)}function VU(i,e,t){const n=this.cache,r=e.length,o=Kx(t,r);fr(n,o)||(i.uniform1iv(this.addr,o),pr(n,o));let a;this.type===i.SAMPLER_2D_SHADOW?a=AM:a=PE;for(let c=0;c!==r;++c)t.setTexture2D(e[c]||a,o[c])}function GU(i,e,t){const n=this.cache,r=e.length,o=Kx(t,r);fr(n,o)||(i.uniform1iv(this.addr,o),pr(n,o));for(let a=0;a!==r;++a)t.setTexture3D(e[a]||LE,o[a])}function WU(i,e,t){const n=this.cache,r=e.length,o=Kx(t,r);fr(n,o)||(i.uniform1iv(this.addr,o),pr(n,o));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||DE,o[a])}function HU(i,e,t){const n=this.cache,r=e.length,o=Kx(t,r);fr(n,o)||(i.uniform1iv(this.addr,o),pr(n,o));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||IE,o[a])}function $U(i){switch(i){case 5126:return AU;case 35664:return EU;case 35665:return CU;case 35666:return RU;case 35674:return NU;case 35675:return PU;case 35676:return IU;case 5124:case 35670:return LU;case 35667:case 35671:return DU;case 35668:case 35672:return FU;case 35669:case 35673:return BU;case 5125:return OU;case 36294:return UU;case 36295:return kU;case 36296:return zU;case 35678:case 36198:case 36298:case 36306:case 35682:return VU;case 35679:case 36299:case 36307:return GU;case 35680:case 36300:case 36308:case 36293:return WU;case 36289:case 36303:case 36311:case 36292:return HU}}class qU{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=wU(t.type)}}class XU{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=$U(t.type)}}class jU{constructor(e){this.id=e,this.seq=[],this.map={}}setValue(e,t,n){const r=this.seq;for(let o=0,a=r.length;o!==a;++o){const c=r[o];c.setValue(e,t[c.id],n)}}}const EM=/(\w+)(\])?(\[|\.)?/g;function zE(i,e){i.seq.push(e),i.map[e.id]=e}function YU(i,e,t){const n=i.name,r=n.length;for(EM.lastIndex=0;;){const o=EM.exec(n),a=EM.lastIndex;let c=o[1];const u=o[2]==="]",d=o[3];if(u&&(c=c|0),d===void 0||d==="["&&a+2===r){zE(t,d===void 0?new qU(c,i,e):new XU(c,i,e));break}else{let m=t.map[c];m===void 0&&(m=new jU(c),zE(t,m)),t=m}}}class Jx{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let a=0;a<n;++a){const c=e.getActiveUniform(t,a),u=e.getUniformLocation(t,c.name);YU(c,u,this)}const r=[],o=[];for(const a of this.seq)a.type===e.SAMPLER_2D_SHADOW||a.type===e.SAMPLER_CUBE_SHADOW||a.type===e.SAMPLER_2D_ARRAY_SHADOW?r.push(a):o.push(a);r.length>0&&(this.seq=r.concat(o))}setValue(e,t,n,r){const o=this.map[t];o!==void 0&&o.setValue(e,n,r)}setOptional(e,t,n){const r=t[n];r!==void 0&&this.setValue(e,n,r)}static upload(e,t,n,r){for(let o=0,a=t.length;o!==a;++o){const c=t[o],u=n[c.id];u.needsUpdate!==!1&&c.setValue(e,u.value,r)}}static seqWithValue(e,t){const n=[];for(let r=0,o=e.length;r!==o;++r){const a=e[r];a.id in t&&n.push(a)}return n}}function VE(i,e,t){const n=i.createShader(e);return i.shaderSource(n,t),i.compileShader(n),n}const ZU=37297;let KU=0;function JU(i,e){const t=i.split(`
`),n=[],r=Math.max(e-6,0),o=Math.min(e+6,t.length);for(let a=r;a<o;a++){const c=a+1;n.push(`${c===e?">":" "} ${c}: ${t[a]}`)}return n.join(`
`)}const GE=new Nn;function QU(i){xn._getMatrix(GE,xn.workingColorSpace,i);const e=`mat3( ${GE.elements.map(t=>t.toFixed(4))} )`;switch(xn.getTransfer(i)){case cf:return[e,"LinearTransferOETF"];case $t:return[e,"sRGBTransferOETF"];default:return Ie("WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function WE(i,e,t){const n=i.getShaderParameter(e,i.COMPILE_STATUS),o=(i.getShaderInfoLog(e)||"").trim();if(n&&o==="")return"";const a=/ERROR: 0:(\d+)/.exec(o);if(a){const c=parseInt(a[1]);return t.toUpperCase()+`
`+o+`
`+JU(i.getShaderSource(e),c)}else return o}function ek(i,e){const t=QU(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
`)}const tk={[o_]:"Linear",[a_]:"Reinhard",[l_]:"Cineon",[c_]:"ACESFilmic",[u_]:"AgX",[h_]:"Neutral",[qb]:"Custom"};function nk(i,e){const t=tk[e];return t===void 0?(Ie("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Qx=new H;function ik(){xn.getLuminanceCoefficients(Qx);const i=Qx.x.toFixed(4),e=Qx.y.toFixed(4),t=Qx.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
`)}function sk(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(sy).join(`
`)}function rk(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
`)}function ok(i,e){const t={},n=i.getProgramParameter(e,i.ACTIVE_ATTRIBUTES);for(let r=0;r<n;r++){const o=i.getActiveAttrib(e,r),a=o.name;let c=1;o.type===i.FLOAT_MAT2&&(c=2),o.type===i.FLOAT_MAT3&&(c=3),o.type===i.FLOAT_MAT4&&(c=4),t[a]={type:o.type,location:i.getAttribLocation(e,a),locationSize:c}}return t}function sy(i){return i!==""}function HE(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 $E(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const ak=/^[ \t]*#include +<([\w\d./]+)>/gm;function CM(i){return i.replace(ak,ck)}const lk=new Map;function ck(i,e){let t=ri[e];if(t===void 0){const n=lk.get(e);if(n!==void 0)t=ri[n],Ie('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return CM(t)}const uk=/#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 qE(i){return i.replace(uk,hk)}function hk(i,e,t,n){let r="";for(let o=parseInt(e);o<parseInt(t);o++)r+=n.replace(/\[\s*i\s*\]/g,"[ "+o+" ]").replace(/UNROLLED_LOOP_INDEX/g,o);return r}function XE(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}const dk={[ue]:"SHADOWMAP_TYPE_PCF",[oe]:"SHADOWMAP_TYPE_VSM"};function fk(i){return dk[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const pk={[Cr]:"ENVMAP_TYPE_CUBE",[Xo]:"ENVMAP_TYPE_CUBE",[Fl]:"ENVMAP_TYPE_CUBE_UV"};function mk(i){return i.envMap===!1?"ENVMAP_TYPE_CUBE":pk[i.envMapMode]||"ENVMAP_TYPE_CUBE"}const gk={[Xo]:"ENVMAP_MODE_REFRACTION"};function yk(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":gk[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}const _k={[Xc]:"ENVMAP_BLENDING_MULTIPLY",[Hb]:"ENVMAP_BLENDING_MIX",[$b]:"ENVMAP_BLENDING_ADD"};function xk(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":_k[i.combine]||"ENVMAP_BLENDING_NONE"}function vk(i){const e=i.envMapCubeUVHeight;if(e===null)return null;const t=Math.log2(e)-2,n=1/e;return{texelWidth:1/(3*Math.max(Math.pow(2,t),7*16)),texelHeight:n,maxMip:t}}function bk(i,e,t,n){const r=i.getContext(),o=t.defines;let a=t.vertexShader,c=t.fragmentShader;const u=fk(t),d=mk(t),p=yk(t),m=xk(t),y=vk(t),x=sk(t),v=rk(o),w=r.createProgram();let M,S,C=t.glslVersion?"#version "+t.glslVersion+`
`:"";t.isRawShaderMaterial?(M=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v].filter(sy).join(`
`),M.length>0&&(M+=`
`),S=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v].filter(sy).join(`
`),S.length>0&&(S+=`
`)):(M=[XE(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v,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 "+p:"",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 "+u:"",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(sy).join(`
`),S=[XE(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v,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 "+d:"",t.envMap?"#define "+p:"",t.envMap?"#define "+m:"",y?"#define CUBEUV_TEXEL_WIDTH "+y.texelWidth:"",y?"#define CUBEUV_TEXEL_HEIGHT "+y.texelHeight:"",y?"#define CUBEUV_MAX_MIP "+y.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 "+u:"",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!==yr?"#define TONE_MAPPING":"",t.toneMapping!==yr?ri.tonemapping_pars_fragment:"",t.toneMapping!==yr?nk("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",ri.colorspace_pars_fragment,ek("linearToOutputTexel",t.outputColorSpace),ik(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
`].filter(sy).join(`
`)),a=CM(a),a=HE(a,t),a=$E(a,t),c=CM(c),c=HE(c,t),c=$E(c,t),a=qE(a),c=qE(c),t.isRawShaderMaterial!==!0&&(C=`#version 300 es
`,M=[x,"#define attribute in","#define varying out","#define texture2D texture"].join(`
`)+`
`+M,S=["#define varying in",t.glslVersion===S_?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===S_?"":"#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(`
`)+`
`+S);const N=C+M+a,I=C+S+c,U=VE(r,r.VERTEX_SHADER,N),F=VE(r,r.FRAGMENT_SHADER,I);r.attachShader(w,U),r.attachShader(w,F),t.index0AttributeName!==void 0?r.bindAttribLocation(w,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(w,0,"position"),r.linkProgram(w);function k(Q){if(i.debug.checkShaderErrors){const ye=r.getProgramInfoLog(w)||"",_e=r.getShaderInfoLog(U)||"",Te=r.getShaderInfoLog(F)||"",Pe=ye.trim(),Ne=_e.trim(),De=Te.trim();let Qe=!0,Mt=!0;if(r.getProgramParameter(w,r.LINK_STATUS)===!1)if(Qe=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,w,U,F);else{const Tt=WE(r,U,"vertex"),Fe=WE(r,F,"fragment");Be("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(w,r.VALIDATE_STATUS)+`
Material Name: `+Q.name+`
Material Type: `+Q.type+`
Program Info Log: `+Pe+`
`+Tt+`
`+Fe)}else Pe!==""?Ie("WebGLProgram: Program Info Log:",Pe):(Ne===""||De==="")&&(Mt=!1);Mt&&(Q.diagnostics={runnable:Qe,programLog:Pe,vertexShader:{log:Ne,prefix:M},fragmentShader:{log:De,prefix:S}})}r.deleteShader(U),r.deleteShader(F),G=new Jx(r,w),B=ok(r,w)}let G;this.getUniforms=function(){return G===void 0&&k(this),G};let B;this.getAttributes=function(){return B===void 0&&k(this),B};let z=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return z===!1&&(z=r.getProgramParameter(w,ZU)),z},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(w),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=KU++,this.cacheKey=e,this.usedTimes=1,this.program=w,this.vertexShader=U,this.fragmentShader=F,this}let Sk=0;class Mk{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e){const t=e.vertexShader,n=e.fragmentShader,r=this._getShaderStage(t),o=this._getShaderStage(n),a=this._getShaderCacheForMaterial(e);return a.has(r)===!1&&(a.add(r),r.usedTimes++),a.has(o)===!1&&(a.add(o),o.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.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 n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new Tk(e),t.set(e,n)),n}}class Tk{constructor(e){this.id=Sk++,this.code=e,this.usedTimes=0}}function wk(i,e,t,n,r,o,a){const c=new Hg,u=new Mk,d=new Set,p=[],m=new Map,y=r.logarithmicDepthBuffer;let x=r.precision;const v={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",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 w(B){return d.add(B),B===0?"uv":`uv${B}`}function M(B,z,Q,ye,_e){const Te=ye.fog,Pe=_e.geometry,Ne=B.isMeshStandardMaterial?ye.environment:null,De=(B.isMeshStandardMaterial?t:e).get(B.envMap||Ne),Qe=De&&De.mapping===Fl?De.image.height:null,Mt=v[B.type];B.precision!==null&&(x=r.getMaxPrecision(B.precision),x!==B.precision&&Ie("WebGLProgram.getParameters:",B.precision,"not supported, using",x,"instead."));const Tt=Pe.morphAttributes.position||Pe.morphAttributes.normal||Pe.morphAttributes.color,Fe=Tt!==void 0?Tt.length:0;let mt=0;Pe.morphAttributes.position!==void 0&&(mt=1),Pe.morphAttributes.normal!==void 0&&(mt=2),Pe.morphAttributes.color!==void 0&&(mt=3);let wt,In,st,Ee;if(Mt){const Gi=Sc[Mt];wt=Gi.vertexShader,In=Gi.fragmentShader}else wt=B.vertexShader,In=B.fragmentShader,u.update(B),st=u.getVertexShaderID(B),Ee=u.getFragmentShaderID(B);const Oe=i.getRenderTarget(),vt=i.state.buffers.depth.getReversed(),Zt=_e.isInstancedMesh===!0,Pt=_e.isBatchedMesh===!0,wn=!!B.map,ai=!!B.matcap,Wn=!!De,rt=!!B.aoMap,yt=!!B.lightMap,ct=!!B.bumpMap,Ft=!!B.normalMap,ne=!!B.displacementMap,Ln=!!B.emissiveMap,en=!!B.metalnessMap,Hn=!!B.roughnessMap,Bt=B.anisotropy>0,ee=B.clearcoat>0,V=B.dispersion>0,Se=B.iridescence>0,je=B.sheen>0,dt=B.transmission>0,Ze=Bt&&!!B.anisotropyMap,yn=ee&&!!B.clearcoatMap,Ot=ee&&!!B.clearcoatNormalMap,fn=ee&&!!B.clearcoatRoughnessMap,jn=Se&&!!B.iridescenceMap,bt=Se&&!!B.iridescenceThicknessMap,Wt=je&&!!B.sheenColorMap,pn=je&&!!B.sheenRoughnessMap,vn=!!B.specularMap,Vt=!!B.specularColorMap,li=!!B.specularIntensityMap,be=dt&&!!B.transmissionMap,Kt=dt&&!!B.thicknessMap,Lt=!!B.gradientMap,nn=!!B.alphaMap,At=B.alphaTest>0,ft=!!B.alphaHash,kt=!!B.extensions;let ti=yr;B.toneMapped&&(Oe===null||Oe.isXRRenderTarget===!0)&&(ti=i.toneMapping);const rs={shaderID:Mt,shaderType:B.type,shaderName:B.name,vertexShader:wt,fragmentShader:In,defines:B.defines,customVertexShaderID:st,customFragmentShaderID:Ee,isRawShaderMaterial:B.isRawShaderMaterial===!0,glslVersion:B.glslVersion,precision:x,batching:Pt,batchingColor:Pt&&_e._colorsTexture!==null,instancing:Zt,instancingColor:Zt&&_e.instanceColor!==null,instancingMorph:Zt&&_e.morphTexture!==null,outputColorSpace:Oe===null?i.outputColorSpace:Oe.isXRRenderTarget===!0?Oe.texture.colorSpace:io,alphaToCoverage:!!B.alphaToCoverage,map:wn,matcap:ai,envMap:Wn,envMapMode:Wn&&De.mapping,envMapCubeUVHeight:Qe,aoMap:rt,lightMap:yt,bumpMap:ct,normalMap:Ft,displacementMap:ne,emissiveMap:Ln,normalMapObjectSpace:Ft&&B.normalMapType===Fg,normalMapTangentSpace:Ft&&B.normalMapType===Yo,metalnessMap:en,roughnessMap:Hn,anisotropy:Bt,anisotropyMap:Ze,clearcoat:ee,clearcoatMap:yn,clearcoatNormalMap:Ot,clearcoatRoughnessMap:fn,dispersion:V,iridescence:Se,iridescenceMap:jn,iridescenceThicknessMap:bt,sheen:je,sheenColorMap:Wt,sheenRoughnessMap:pn,specularMap:vn,specularColorMap:Vt,specularIntensityMap:li,transmission:dt,transmissionMap:be,thicknessMap:Kt,gradientMap:Lt,opaque:B.transparent===!1&&B.blending===Ue&&B.alphaToCoverage===!1,alphaMap:nn,alphaTest:At,alphaHash:ft,combine:B.combine,mapUv:wn&&w(B.map.channel),aoMapUv:rt&&w(B.aoMap.channel),lightMapUv:yt&&w(B.lightMap.channel),bumpMapUv:ct&&w(B.bumpMap.channel),normalMapUv:Ft&&w(B.normalMap.channel),displacementMapUv:ne&&w(B.displacementMap.channel),emissiveMapUv:Ln&&w(B.emissiveMap.channel),metalnessMapUv:en&&w(B.metalnessMap.channel),roughnessMapUv:Hn&&w(B.roughnessMap.channel),anisotropyMapUv:Ze&&w(B.anisotropyMap.channel),clearcoatMapUv:yn&&w(B.clearcoatMap.channel),clearcoatNormalMapUv:Ot&&w(B.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:fn&&w(B.clearcoatRoughnessMap.channel),iridescenceMapUv:jn&&w(B.iridescenceMap.channel),iridescenceThicknessMapUv:bt&&w(B.iridescenceThicknessMap.channel),sheenColorMapUv:Wt&&w(B.sheenColorMap.channel),sheenRoughnessMapUv:pn&&w(B.sheenRoughnessMap.channel),specularMapUv:vn&&w(B.specularMap.channel),specularColorMapUv:Vt&&w(B.specularColorMap.channel),specularIntensityMapUv:li&&w(B.specularIntensityMap.channel),transmissionMapUv:be&&w(B.transmissionMap.channel),thicknessMapUv:Kt&&w(B.thicknessMap.channel),alphaMapUv:nn&&w(B.alphaMap.channel),vertexTangents:!!Pe.attributes.tangent&&(Ft||Bt),vertexColors:B.vertexColors,vertexAlphas:B.vertexColors===!0&&!!Pe.attributes.color&&Pe.attributes.color.itemSize===4,pointsUvs:_e.isPoints===!0&&!!Pe.attributes.uv&&(wn||nn),fog:!!Te,useFog:B.fog===!0,fogExp2:!!Te&&Te.isFogExp2,flatShading:B.flatShading===!0&&B.wireframe===!1,sizeAttenuation:B.sizeAttenuation===!0,logarithmicDepthBuffer:y,reversedDepthBuffer:vt,skinning:_e.isSkinnedMesh===!0,morphTargets:Pe.morphAttributes.position!==void 0,morphNormals:Pe.morphAttributes.normal!==void 0,morphColors:Pe.morphAttributes.color!==void 0,morphTargetsCount:Fe,morphTextureStride:mt,numDirLights:z.directional.length,numPointLights:z.point.length,numSpotLights:z.spot.length,numSpotLightMaps:z.spotLightMap.length,numRectAreaLights:z.rectArea.length,numHemiLights:z.hemi.length,numDirLightShadows:z.directionalShadowMap.length,numPointLightShadows:z.pointShadowMap.length,numSpotLightShadows:z.spotShadowMap.length,numSpotLightShadowsWithMaps:z.numSpotLightShadowsWithMaps,numLightProbes:z.numLightProbes,numClippingPlanes:a.numPlanes,numClipIntersection:a.numIntersection,dithering:B.dithering,shadowMapEnabled:i.shadowMap.enabled&&Q.length>0,shadowMapType:i.shadowMap.type,toneMapping:ti,decodeVideoTexture:wn&&B.map.isVideoTexture===!0&&xn.getTransfer(B.map.colorSpace)===$t,decodeVideoTextureEmissive:Ln&&B.emissiveMap.isVideoTexture===!0&&xn.getTransfer(B.emissiveMap.colorSpace)===$t,premultipliedAlpha:B.premultipliedAlpha,doubleSided:B.side===Ae,flipSided:B.side===we,useDepthPacking:B.depthPacking>=0,depthPacking:B.depthPacking||0,index0AttributeName:B.index0AttributeName,extensionClipCullDistance:kt&&B.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(kt&&B.extensions.multiDraw===!0||Pt)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:B.customProgramCacheKey()};return rs.vertexUv1s=d.has(1),rs.vertexUv2s=d.has(2),rs.vertexUv3s=d.has(3),d.clear(),rs}function S(B){const z=[];if(B.shaderID?z.push(B.shaderID):(z.push(B.customVertexShaderID),z.push(B.customFragmentShaderID)),B.defines!==void 0)for(const Q in B.defines)z.push(Q),z.push(B.defines[Q]);return B.isRawShaderMaterial===!1&&(C(z,B),N(z,B),z.push(i.outputColorSpace)),z.push(B.customProgramCacheKey),z.join()}function C(B,z){B.push(z.precision),B.push(z.outputColorSpace),B.push(z.envMapMode),B.push(z.envMapCubeUVHeight),B.push(z.mapUv),B.push(z.alphaMapUv),B.push(z.lightMapUv),B.push(z.aoMapUv),B.push(z.bumpMapUv),B.push(z.normalMapUv),B.push(z.displacementMapUv),B.push(z.emissiveMapUv),B.push(z.metalnessMapUv),B.push(z.roughnessMapUv),B.push(z.anisotropyMapUv),B.push(z.clearcoatMapUv),B.push(z.clearcoatNormalMapUv),B.push(z.clearcoatRoughnessMapUv),B.push(z.iridescenceMapUv),B.push(z.iridescenceThicknessMapUv),B.push(z.sheenColorMapUv),B.push(z.sheenRoughnessMapUv),B.push(z.specularMapUv),B.push(z.specularColorMapUv),B.push(z.specularIntensityMapUv),B.push(z.transmissionMapUv),B.push(z.thicknessMapUv),B.push(z.combine),B.push(z.fogExp2),B.push(z.sizeAttenuation),B.push(z.morphTargetsCount),B.push(z.morphAttributeCount),B.push(z.numDirLights),B.push(z.numPointLights),B.push(z.numSpotLights),B.push(z.numSpotLightMaps),B.push(z.numHemiLights),B.push(z.numRectAreaLights),B.push(z.numDirLightShadows),B.push(z.numPointLightShadows),B.push(z.numSpotLightShadows),B.push(z.numSpotLightShadowsWithMaps),B.push(z.numLightProbes),B.push(z.shadowMapType),B.push(z.toneMapping),B.push(z.numClippingPlanes),B.push(z.numClipIntersection),B.push(z.depthPacking)}function N(B,z){c.disableAll(),z.instancing&&c.enable(0),z.instancingColor&&c.enable(1),z.instancingMorph&&c.enable(2),z.matcap&&c.enable(3),z.envMap&&c.enable(4),z.normalMapObjectSpace&&c.enable(5),z.normalMapTangentSpace&&c.enable(6),z.clearcoat&&c.enable(7),z.iridescence&&c.enable(8),z.alphaTest&&c.enable(9),z.vertexColors&&c.enable(10),z.vertexAlphas&&c.enable(11),z.vertexUv1s&&c.enable(12),z.vertexUv2s&&c.enable(13),z.vertexUv3s&&c.enable(14),z.vertexTangents&&c.enable(15),z.anisotropy&&c.enable(16),z.alphaHash&&c.enable(17),z.batching&&c.enable(18),z.dispersion&&c.enable(19),z.batchingColor&&c.enable(20),z.gradientMap&&c.enable(21),B.push(c.mask),c.disableAll(),z.fog&&c.enable(0),z.useFog&&c.enable(1),z.flatShading&&c.enable(2),z.logarithmicDepthBuffer&&c.enable(3),z.reversedDepthBuffer&&c.enable(4),z.skinning&&c.enable(5),z.morphTargets&&c.enable(6),z.morphNormals&&c.enable(7),z.morphColors&&c.enable(8),z.premultipliedAlpha&&c.enable(9),z.shadowMapEnabled&&c.enable(10),z.doubleSided&&c.enable(11),z.flipSided&&c.enable(12),z.useDepthPacking&&c.enable(13),z.dithering&&c.enable(14),z.transmission&&c.enable(15),z.sheen&&c.enable(16),z.opaque&&c.enable(17),z.pointsUvs&&c.enable(18),z.decodeVideoTexture&&c.enable(19),z.decodeVideoTextureEmissive&&c.enable(20),z.alphaToCoverage&&c.enable(21),B.push(c.mask)}function I(B){const z=v[B.type];let Q;if(z){const ye=Sc[z];Q=Io.clone(ye.uniforms)}else Q=B.uniforms;return Q}function U(B,z){let Q=m.get(z);return Q!==void 0?++Q.usedTimes:(Q=new bk(i,z,B,o),p.push(Q),m.set(z,Q)),Q}function F(B){if(--B.usedTimes===0){const z=p.indexOf(B);p[z]=p[p.length-1],p.pop(),m.delete(B.cacheKey),B.destroy()}}function k(B){u.remove(B)}function G(){u.dispose()}return{getParameters:M,getProgramCacheKey:S,getUniforms:I,acquireProgram:U,releaseProgram:F,releaseShaderCache:k,programs:p,dispose:G}}function Ak(){let i=new WeakMap;function e(a){return i.has(a)}function t(a){let c=i.get(a);return c===void 0&&(c={},i.set(a,c)),c}function n(a){i.delete(a)}function r(a,c,u){i.get(a)[c]=u}function o(){i=new WeakMap}return{has:e,get:t,remove:n,update:r,dispose:o}}function Ek(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 jE(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 YE(){const i=[];let e=0;const t=[],n=[],r=[];function o(){e=0,t.length=0,n.length=0,r.length=0}function a(m,y,x,v,w,M){let S=i[e];return S===void 0?(S={id:m.id,object:m,geometry:y,material:x,groupOrder:v,renderOrder:m.renderOrder,z:w,group:M},i[e]=S):(S.id=m.id,S.object=m,S.geometry=y,S.material=x,S.groupOrder=v,S.renderOrder=m.renderOrder,S.z=w,S.group=M),e++,S}function c(m,y,x,v,w,M){const S=a(m,y,x,v,w,M);x.transmission>0?n.push(S):x.transparent===!0?r.push(S):t.push(S)}function u(m,y,x,v,w,M){const S=a(m,y,x,v,w,M);x.transmission>0?n.unshift(S):x.transparent===!0?r.unshift(S):t.unshift(S)}function d(m,y){t.length>1&&t.sort(m||Ek),n.length>1&&n.sort(y||jE),r.length>1&&r.sort(y||jE)}function p(){for(let m=e,y=i.length;m<y;m++){const x=i[m];if(x.id===null)break;x.id=null,x.object=null,x.geometry=null,x.material=null,x.group=null}}return{opaque:t,transmissive:n,transparent:r,init:o,push:c,unshift:u,finish:p,sort:d}}function Ck(){let i=new WeakMap;function e(n,r){const o=i.get(n);let a;return o===void 0?(a=new YE,i.set(n,[a])):r>=o.length?(a=new YE,o.push(a)):a=o[r],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function Rk(){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 H,color:new It};break;case"SpotLight":t={position:new H,direction:new H,color:new It,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new H,color:new It,distance:0,decay:0};break;case"HemisphereLight":t={direction:new H,skyColor:new It,groundColor:new It};break;case"RectAreaLight":t={color:new It,position:new H,halfWidth:new H,halfHeight:new H};break}return i[e.id]=t,t}}}function Nk(){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 ze};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ze};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new ze,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let Pk=0;function Ik(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function Lk(i){const e=new Rk,t=Nk(),n={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 d=0;d<9;d++)n.probe.push(new H);const r=new H,o=new Qt,a=new Qt;function c(d){let p=0,m=0,y=0;for(let B=0;B<9;B++)n.probe[B].set(0,0,0);let x=0,v=0,w=0,M=0,S=0,C=0,N=0,I=0,U=0,F=0,k=0;d.sort(Ik);for(let B=0,z=d.length;B<z;B++){const Q=d[B],ye=Q.color,_e=Q.intensity,Te=Q.distance;let Pe=null;if(Q.shadow&&Q.shadow.map&&(Q.shadow.map.texture.format===Nr?Pe=Q.shadow.map.texture:Pe=Q.shadow.map.depthTexture||Q.shadow.map.texture),Q.isAmbientLight)p+=ye.r*_e,m+=ye.g*_e,y+=ye.b*_e;else if(Q.isLightProbe){for(let Ne=0;Ne<9;Ne++)n.probe[Ne].addScaledVector(Q.sh.coefficients[Ne],_e);k++}else if(Q.isDirectionalLight){const Ne=e.get(Q);if(Ne.color.copy(Q.color).multiplyScalar(Q.intensity),Q.castShadow){const De=Q.shadow,Qe=t.get(Q);Qe.shadowIntensity=De.intensity,Qe.shadowBias=De.bias,Qe.shadowNormalBias=De.normalBias,Qe.shadowRadius=De.radius,Qe.shadowMapSize=De.mapSize,n.directionalShadow[x]=Qe,n.directionalShadowMap[x]=Pe,n.directionalShadowMatrix[x]=Q.shadow.matrix,C++}n.directional[x]=Ne,x++}else if(Q.isSpotLight){const Ne=e.get(Q);Ne.position.setFromMatrixPosition(Q.matrixWorld),Ne.color.copy(ye).multiplyScalar(_e),Ne.distance=Te,Ne.coneCos=Math.cos(Q.angle),Ne.penumbraCos=Math.cos(Q.angle*(1-Q.penumbra)),Ne.decay=Q.decay,n.spot[w]=Ne;const De=Q.shadow;if(Q.map&&(n.spotLightMap[U]=Q.map,U++,De.updateMatrices(Q),Q.castShadow&&F++),n.spotLightMatrix[w]=De.matrix,Q.castShadow){const Qe=t.get(Q);Qe.shadowIntensity=De.intensity,Qe.shadowBias=De.bias,Qe.shadowNormalBias=De.normalBias,Qe.shadowRadius=De.radius,Qe.shadowMapSize=De.mapSize,n.spotShadow[w]=Qe,n.spotShadowMap[w]=Pe,I++}w++}else if(Q.isRectAreaLight){const Ne=e.get(Q);Ne.color.copy(ye).multiplyScalar(_e),Ne.halfWidth.set(Q.width*.5,0,0),Ne.halfHeight.set(0,Q.height*.5,0),n.rectArea[M]=Ne,M++}else if(Q.isPointLight){const Ne=e.get(Q);if(Ne.color.copy(Q.color).multiplyScalar(Q.intensity),Ne.distance=Q.distance,Ne.decay=Q.decay,Q.castShadow){const De=Q.shadow,Qe=t.get(Q);Qe.shadowIntensity=De.intensity,Qe.shadowBias=De.bias,Qe.shadowNormalBias=De.normalBias,Qe.shadowRadius=De.radius,Qe.shadowMapSize=De.mapSize,Qe.shadowCameraNear=De.camera.near,Qe.shadowCameraFar=De.camera.far,n.pointShadow[v]=Qe,n.pointShadowMap[v]=Pe,n.pointShadowMatrix[v]=Q.shadow.matrix,N++}n.point[v]=Ne,v++}else if(Q.isHemisphereLight){const Ne=e.get(Q);Ne.skyColor.copy(Q.color).multiplyScalar(_e),Ne.groundColor.copy(Q.groundColor).multiplyScalar(_e),n.hemi[S]=Ne,S++}}M>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=qt.LTC_FLOAT_1,n.rectAreaLTC2=qt.LTC_FLOAT_2):(n.rectAreaLTC1=qt.LTC_HALF_1,n.rectAreaLTC2=qt.LTC_HALF_2)),n.ambient[0]=p,n.ambient[1]=m,n.ambient[2]=y;const G=n.hash;(G.directionalLength!==x||G.pointLength!==v||G.spotLength!==w||G.rectAreaLength!==M||G.hemiLength!==S||G.numDirectionalShadows!==C||G.numPointShadows!==N||G.numSpotShadows!==I||G.numSpotMaps!==U||G.numLightProbes!==k)&&(n.directional.length=x,n.spot.length=w,n.rectArea.length=M,n.point.length=v,n.hemi.length=S,n.directionalShadow.length=C,n.directionalShadowMap.length=C,n.pointShadow.length=N,n.pointShadowMap.length=N,n.spotShadow.length=I,n.spotShadowMap.length=I,n.directionalShadowMatrix.length=C,n.pointShadowMatrix.length=N,n.spotLightMatrix.length=I+U-F,n.spotLightMap.length=U,n.numSpotLightShadowsWithMaps=F,n.numLightProbes=k,G.directionalLength=x,G.pointLength=v,G.spotLength=w,G.rectAreaLength=M,G.hemiLength=S,G.numDirectionalShadows=C,G.numPointShadows=N,G.numSpotShadows=I,G.numSpotMaps=U,G.numLightProbes=k,n.version=Pk++)}function u(d,p){let m=0,y=0,x=0,v=0,w=0;const M=p.matrixWorldInverse;for(let S=0,C=d.length;S<C;S++){const N=d[S];if(N.isDirectionalLight){const I=n.directional[m];I.direction.setFromMatrixPosition(N.matrixWorld),r.setFromMatrixPosition(N.target.matrixWorld),I.direction.sub(r),I.direction.transformDirection(M),m++}else if(N.isSpotLight){const I=n.spot[x];I.position.setFromMatrixPosition(N.matrixWorld),I.position.applyMatrix4(M),I.direction.setFromMatrixPosition(N.matrixWorld),r.setFromMatrixPosition(N.target.matrixWorld),I.direction.sub(r),I.direction.transformDirection(M),x++}else if(N.isRectAreaLight){const I=n.rectArea[v];I.position.setFromMatrixPosition(N.matrixWorld),I.position.applyMatrix4(M),a.identity(),o.copy(N.matrixWorld),o.premultiply(M),a.extractRotation(o),I.halfWidth.set(N.width*.5,0,0),I.halfHeight.set(0,N.height*.5,0),I.halfWidth.applyMatrix4(a),I.halfHeight.applyMatrix4(a),v++}else if(N.isPointLight){const I=n.point[y];I.position.setFromMatrixPosition(N.matrixWorld),I.position.applyMatrix4(M),y++}else if(N.isHemisphereLight){const I=n.hemi[w];I.direction.setFromMatrixPosition(N.matrixWorld),I.direction.transformDirection(M),w++}}}return{setup:c,setupView:u,state:n}}function ZE(i){const e=new Lk(i),t=[],n=[];function r(p){d.camera=p,t.length=0,n.length=0}function o(p){t.push(p)}function a(p){n.push(p)}function c(){e.setup(t)}function u(p){e.setupView(t,p)}const d={lightsArray:t,shadowsArray:n,camera:null,lights:e,transmissionRenderTarget:{}};return{init:r,state:d,setupLights:c,setupLightsView:u,pushLight:o,pushShadow:a}}function Dk(i){let e=new WeakMap;function t(r,o=0){const a=e.get(r);let c;return a===void 0?(c=new ZE(i),e.set(r,[c])):o>=a.length?(c=new ZE(i),a.push(c)):c=a[o],c}function n(){e=new WeakMap}return{get:t,dispose:n}}const Fk=`void main() {
gl_Position = vec4( position, 1.0 );
}`,Bk=`uniform sampler2D shadow_pass;
uniform vec2 resolution;
uniform float radius;
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 = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg;
mean += distribution.x;
squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
#else
float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r;
mean += depth;
squared_mean += depth * depth;
#endif
}
mean = mean / samples;
squared_mean = squared_mean / samples;
float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
}`,Ok=[new H(1,0,0),new H(-1,0,0),new H(0,1,0),new H(0,-1,0),new H(0,0,1),new H(0,0,-1)],Uk=[new H(0,-1,0),new H(0,-1,0),new H(0,0,1),new H(0,0,-1),new H(0,-1,0),new H(0,-1,0)],KE=new Qt,ry=new H,RM=new H;function kk(i,e,t){let n=new Xs;const r=new ze,o=new ze,a=new gn,c=new dx,u=new fx,d={},p=t.maxTextureSize,m={[Me]:we,[we]:Me,[Ae]:Ae},y=new lo({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new ze},radius:{value:4}},vertexShader:Fk,fragmentShader:Bk}),x=y.clone();x.defines.HORIZONTAL_PASS=1;const v=new Gn;v.setAttribute("position",new $i(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const w=new Ji(v,y),M=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ue;let S=this.type;this.render=function(F,k,G){if(M.enabled===!1||M.autoUpdate===!1&&M.needsUpdate===!1||F.length===0)return;F.type===ge&&(Ie("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),F.type=ue);const B=i.getRenderTarget(),z=i.getActiveCubeFace(),Q=i.getActiveMipmapLevel(),ye=i.state;ye.setBlending(ve),ye.buffers.depth.getReversed()===!0?ye.buffers.color.setClear(0,0,0,0):ye.buffers.color.setClear(1,1,1,1),ye.buffers.depth.setTest(!0),ye.setScissorTest(!1);const _e=S!==this.type;_e&&k.traverse(function(Te){Te.material&&(Array.isArray(Te.material)?Te.material.forEach(Pe=>Pe.needsUpdate=!0):Te.material.needsUpdate=!0)});for(let Te=0,Pe=F.length;Te<Pe;Te++){const Ne=F[Te],De=Ne.shadow;if(De===void 0){Ie("WebGLShadowMap:",Ne,"has no shadow.");continue}if(De.autoUpdate===!1&&De.needsUpdate===!1)continue;r.copy(De.mapSize);const Qe=De.getFrameExtents();if(r.multiply(Qe),o.copy(De.mapSize),(r.x>p||r.y>p)&&(r.x>p&&(o.x=Math.floor(p/Qe.x),r.x=o.x*Qe.x,De.mapSize.x=o.x),r.y>p&&(o.y=Math.floor(p/Qe.y),r.y=o.y*Qe.y,De.mapSize.y=o.y)),De.map===null||_e===!0){if(De.map!==null&&(De.map.depthTexture!==null&&(De.map.depthTexture.dispose(),De.map.depthTexture=null),De.map.dispose()),this.type===oe){if(Ne.isPointLight){Ie("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}De.map=new qr(r.x,r.y,{format:Nr,type:Hi,minFilter:Yn,magFilter:Yn,generateMipmaps:!1}),De.map.texture.name=Ne.name+".shadowMap",De.map.depthTexture=new Ys(r.x,r.y,Si),De.map.depthTexture.name=Ne.name+".shadowMapDepth",De.map.depthTexture.format=tr,De.map.depthTexture.compareFunction=null,De.map.depthTexture.minFilter=ni,De.map.depthTexture.magFilter=ni}else{Ne.isPointLight?(De.map=new cr(r.x),De.map.depthTexture=new Cf(r.x,yi)):(De.map=new qr(r.x,r.y),De.map.depthTexture=new Ys(r.x,r.y,yi)),De.map.depthTexture.name=Ne.name+".shadowMap",De.map.depthTexture.format=tr;const Tt=i.state.buffers.depth.getReversed();this.type===ue?(De.map.depthTexture.compareFunction=Tt?Op:Bp,De.map.depthTexture.minFilter=Yn,De.map.depthTexture.magFilter=Yn):(De.map.depthTexture.compareFunction=null,De.map.depthTexture.minFilter=ni,De.map.depthTexture.magFilter=ni)}De.camera.updateProjectionMatrix()}const Mt=De.map.isWebGLCubeRenderTarget?6:1;for(let Tt=0;Tt<Mt;Tt++){if(De.map.isWebGLCubeRenderTarget)i.setRenderTarget(De.map,Tt),i.clear();else{Tt===0&&(i.setRenderTarget(De.map),i.clear());const Fe=De.getViewport(Tt);a.set(o.x*Fe.x,o.y*Fe.y,o.x*Fe.z,o.y*Fe.w),ye.viewport(a)}if(Ne.isPointLight){const Fe=De.camera,mt=De.matrix,wt=Ne.distance||Fe.far;wt!==Fe.far&&(Fe.far=wt,Fe.updateProjectionMatrix()),ry.setFromMatrixPosition(Ne.matrixWorld),Fe.position.copy(ry),RM.copy(Fe.position),RM.add(Ok[Tt]),Fe.up.copy(Uk[Tt]),Fe.lookAt(RM),Fe.updateMatrixWorld(),mt.makeTranslation(-ry.x,-ry.y,-ry.z),KE.multiplyMatrices(Fe.projectionMatrix,Fe.matrixWorldInverse),De._frustum.setFromProjectionMatrix(KE,Fe.coordinateSystem,Fe.reversedDepth)}else De.updateMatrices(Ne);n=De.getFrustum(),I(k,G,De.camera,Ne,this.type)}De.isPointLightShadow!==!0&&this.type===oe&&C(De,G),De.needsUpdate=!1}S=this.type,M.needsUpdate=!1,i.setRenderTarget(B,z,Q)};function C(F,k){const G=e.update(w);y.defines.VSM_SAMPLES!==F.blurSamples&&(y.defines.VSM_SAMPLES=F.blurSamples,x.defines.VSM_SAMPLES=F.blurSamples,y.needsUpdate=!0,x.needsUpdate=!0),F.mapPass===null&&(F.mapPass=new qr(r.x,r.y,{format:Nr,type:Hi})),y.uniforms.shadow_pass.value=F.map.depthTexture,y.uniforms.resolution.value=F.mapSize,y.uniforms.radius.value=F.radius,i.setRenderTarget(F.mapPass),i.clear(),i.renderBufferDirect(k,null,G,y,w,null),x.uniforms.shadow_pass.value=F.mapPass.texture,x.uniforms.resolution.value=F.mapSize,x.uniforms.radius.value=F.radius,i.setRenderTarget(F.map),i.clear(),i.renderBufferDirect(k,null,G,x,w,null)}function N(F,k,G,B){let z=null;const Q=G.isPointLight===!0?F.customDistanceMaterial:F.customDepthMaterial;if(Q!==void 0)z=Q;else if(z=G.isPointLight===!0?u:c,i.localClippingEnabled&&k.clipShadows===!0&&Array.isArray(k.clippingPlanes)&&k.clippingPlanes.length!==0||k.displacementMap&&k.displacementScale!==0||k.alphaMap&&k.alphaTest>0||k.map&&k.alphaTest>0||k.alphaToCoverage===!0){const ye=z.uuid,_e=k.uuid;let Te=d[ye];Te===void 0&&(Te={},d[ye]=Te);let Pe=Te[_e];Pe===void 0&&(Pe=z.clone(),Te[_e]=Pe,k.addEventListener("dispose",U)),z=Pe}if(z.visible=k.visible,z.wireframe=k.wireframe,B===oe?z.side=k.shadowSide!==null?k.shadowSide:k.side:z.side=k.shadowSide!==null?k.shadowSide:m[k.side],z.alphaMap=k.alphaMap,z.alphaTest=k.alphaToCoverage===!0?.5:k.alphaTest,z.map=k.map,z.clipShadows=k.clipShadows,z.clippingPlanes=k.clippingPlanes,z.clipIntersection=k.clipIntersection,z.displacementMap=k.displacementMap,z.displacementScale=k.displacementScale,z.displacementBias=k.displacementBias,z.wireframeLinewidth=k.wireframeLinewidth,z.linewidth=k.linewidth,G.isPointLight===!0&&z.isMeshDistanceMaterial===!0){const ye=i.properties.get(z);ye.light=G}return z}function I(F,k,G,B,z){if(F.visible===!1)return;if(F.layers.test(k.layers)&&(F.isMesh||F.isLine||F.isPoints)&&(F.castShadow||F.receiveShadow&&z===oe)&&(!F.frustumCulled||n.intersectsObject(F))){F.modelViewMatrix.multiplyMatrices(G.matrixWorldInverse,F.matrixWorld);const _e=e.update(F),Te=F.material;if(Array.isArray(Te)){const Pe=_e.groups;for(let Ne=0,De=Pe.length;Ne<De;Ne++){const Qe=Pe[Ne],Mt=Te[Qe.materialIndex];if(Mt&&Mt.visible){const Tt=N(F,Mt,B,z);F.onBeforeShadow(i,F,k,G,_e,Tt,Qe),i.renderBufferDirect(G,null,_e,Tt,F,Qe),F.onAfterShadow(i,F,k,G,_e,Tt,Qe)}}}else if(Te.visible){const Pe=N(F,Te,B,z);F.onBeforeShadow(i,F,k,G,_e,Pe,null),i.renderBufferDirect(G,null,_e,Pe,F,null),F.onAfterShadow(i,F,k,G,_e,Pe,null)}}const ye=F.children;for(let _e=0,Te=ye.length;_e<Te;_e++)I(ye[_e],k,G,B,z)}function U(F){F.target.removeEventListener("dispose",U);for(const G in d){const B=d[G],z=F.target.uuid;z in B&&(B[z].dispose(),delete B[z])}}}const zk={[nl]:zn,[Ci]:Rp,[$c]:Np,[no]:qc,[zn]:nl,[Rp]:Ci,[Np]:$c,[qc]:no};function Vk(i,e){function t(){let be=!1;const Kt=new gn;let Lt=null;const nn=new gn(0,0,0,0);return{setMask:function(At){Lt!==At&&!be&&(i.colorMask(At,At,At,At),Lt=At)},setLocked:function(At){be=At},setClear:function(At,ft,kt,ti,rs){rs===!0&&(At*=ti,ft*=ti,kt*=ti),Kt.set(At,ft,kt,ti),nn.equals(Kt)===!1&&(i.clearColor(At,ft,kt,ti),nn.copy(Kt))},reset:function(){be=!1,Lt=null,nn.set(-1,0,0,0)}}}function n(){let be=!1,Kt=!1,Lt=null,nn=null,At=null;return{setReversed:function(ft){if(Kt!==ft){const kt=e.get("EXT_clip_control");ft?kt.clipControlEXT(kt.LOWER_LEFT_EXT,kt.ZERO_TO_ONE_EXT):kt.clipControlEXT(kt.LOWER_LEFT_EXT,kt.NEGATIVE_ONE_TO_ONE_EXT),Kt=ft;const ti=At;At=null,this.setClear(ti)}},getReversed:function(){return Kt},setTest:function(ft){ft?Oe(i.DEPTH_TEST):vt(i.DEPTH_TEST)},setMask:function(ft){Lt!==ft&&!be&&(i.depthMask(ft),Lt=ft)},setFunc:function(ft){if(Kt&&(ft=zk[ft]),nn!==ft){switch(ft){case nl:i.depthFunc(i.NEVER);break;case zn:i.depthFunc(i.ALWAYS);break;case Ci:i.depthFunc(i.LESS);break;case no:i.depthFunc(i.LEQUAL);break;case $c:i.depthFunc(i.EQUAL);break;case qc:i.depthFunc(i.GEQUAL);break;case Rp:i.depthFunc(i.GREATER);break;case Np:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}nn=ft}},setLocked:function(ft){be=ft},setClear:function(ft){At!==ft&&(Kt&&(ft=1-ft),i.clearDepth(ft),At=ft)},reset:function(){be=!1,Lt=null,nn=null,At=null,Kt=!1}}}function r(){let be=!1,Kt=null,Lt=null,nn=null,At=null,ft=null,kt=null,ti=null,rs=null;return{setTest:function(Gi){be||(Gi?Oe(i.STENCIL_TEST):vt(i.STENCIL_TEST))},setMask:function(Gi){Kt!==Gi&&!be&&(i.stencilMask(Gi),Kt=Gi)},setFunc:function(Gi,Hc,yh){(Lt!==Gi||nn!==Hc||At!==yh)&&(i.stencilFunc(Gi,Hc,yh),Lt=Gi,nn=Hc,At=yh)},setOp:function(Gi,Hc,yh){(ft!==Gi||kt!==Hc||ti!==yh)&&(i.stencilOp(Gi,Hc,yh),ft=Gi,kt=Hc,ti=yh)},setLocked:function(Gi){be=Gi},setClear:function(Gi){rs!==Gi&&(i.clearStencil(Gi),rs=Gi)},reset:function(){be=!1,Kt=null,Lt=null,nn=null,At=null,ft=null,kt=null,ti=null,rs=null}}}const o=new t,a=new n,c=new r,u=new WeakMap,d=new WeakMap;let p={},m={},y=new WeakMap,x=[],v=null,w=!1,M=null,S=null,C=null,N=null,I=null,U=null,F=null,k=new It(0,0,0),G=0,B=!1,z=null,Q=null,ye=null,_e=null,Te=null;const Pe=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Ne=!1,De=0;const Qe=i.getParameter(i.VERSION);Qe.indexOf("WebGL")!==-1?(De=parseFloat(/^WebGL (\d)/.exec(Qe)[1]),Ne=De>=1):Qe.indexOf("OpenGL ES")!==-1&&(De=parseFloat(/^OpenGL ES (\d)/.exec(Qe)[1]),Ne=De>=2);let Mt=null,Tt={};const Fe=i.getParameter(i.SCISSOR_BOX),mt=i.getParameter(i.VIEWPORT),wt=new gn().fromArray(Fe),In=new gn().fromArray(mt);function st(be,Kt,Lt,nn){const At=new Uint8Array(4),ft=i.createTexture();i.bindTexture(be,ft),i.texParameteri(be,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(be,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let kt=0;kt<Lt;kt++)be===i.TEXTURE_3D||be===i.TEXTURE_2D_ARRAY?i.texImage3D(Kt,0,i.RGBA,1,1,nn,0,i.RGBA,i.UNSIGNED_BYTE,At):i.texImage2D(Kt+kt,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,At);return ft}const Ee={};Ee[i.TEXTURE_2D]=st(i.TEXTURE_2D,i.TEXTURE_2D,1),Ee[i.TEXTURE_CUBE_MAP]=st(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),Ee[i.TEXTURE_2D_ARRAY]=st(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),Ee[i.TEXTURE_3D]=st(i.TEXTURE_3D,i.TEXTURE_3D,1,1),o.setClear(0,0,0,1),a.setClear(1),c.setClear(0),Oe(i.DEPTH_TEST),a.setFunc(no),ct(!1),Ft(J),Oe(i.CULL_FACE),rt(ve);function Oe(be){p[be]!==!0&&(i.enable(be),p[be]=!0)}function vt(be){p[be]!==!1&&(i.disable(be),p[be]=!1)}function Zt(be,Kt){return m[be]!==Kt?(i.bindFramebuffer(be,Kt),m[be]=Kt,be===i.DRAW_FRAMEBUFFER&&(m[i.FRAMEBUFFER]=Kt),be===i.FRAMEBUFFER&&(m[i.DRAW_FRAMEBUFFER]=Kt),!0):!1}function Pt(be,Kt){let Lt=x,nn=!1;if(be){Lt=y.get(Kt),Lt===void 0&&(Lt=[],y.set(Kt,Lt));const At=be.textures;if(Lt.length!==At.length||Lt[0]!==i.COLOR_ATTACHMENT0){for(let ft=0,kt=At.length;ft<kt;ft++)Lt[ft]=i.COLOR_ATTACHMENT0+ft;Lt.length=At.length,nn=!0}}else Lt[0]!==i.BACK&&(Lt[0]=i.BACK,nn=!0);nn&&i.drawBuffers(Lt)}function wn(be){return v!==be?(i.useProgram(be),v=be,!0):!1}const ai={[nt]:i.FUNC_ADD,[tt]:i.FUNC_SUBTRACT,[at]:i.FUNC_REVERSE_SUBTRACT};ai[_t]=i.MIN,ai[un]=i.MAX;const Wn={[Sn]:i.ZERO,[Cn]:i.ONE,[Pn]:i.SRC_COLOR,[Rn]:i.SRC_ALPHA,[$n]:i.SRC_ALPHA_SATURATE,[gt]:i.DST_COLOR,[tn]:i.DST_ALPHA,[Rt]:i.ONE_MINUS_SRC_COLOR,[Jt]:i.ONE_MINUS_SRC_ALPHA,[hn]:i.ONE_MINUS_DST_COLOR,[xi]:i.ONE_MINUS_DST_ALPHA,[Yi]:i.CONSTANT_COLOR,[To]:i.ONE_MINUS_CONSTANT_COLOR,[Aa]:i.CONSTANT_ALPHA,[Dl]:i.ONE_MINUS_CONSTANT_ALPHA};function rt(be,Kt,Lt,nn,At,ft,kt,ti,rs,Gi){if(be===ve){w===!0&&(vt(i.BLEND),w=!1);return}if(w===!1&&(Oe(i.BLEND),w=!0),be!==ut){if(be!==M||Gi!==B){if((S!==nt||I!==nt)&&(i.blendEquation(i.FUNC_ADD),S=nt,I=nt),Gi)switch(be){case Ue:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Je:i.blendFunc(i.ONE,i.ONE);break;case Ye:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Ke:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:Be("WebGLState: Invalid blending: ",be);break}else switch(be){case Ue:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Je:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case Ye:Be("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Ke:Be("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Be("WebGLState: Invalid blending: ",be);break}C=null,N=null,U=null,F=null,k.set(0,0,0),G=0,M=be,B=Gi}return}At=At||Kt,ft=ft||Lt,kt=kt||nn,(Kt!==S||At!==I)&&(i.blendEquationSeparate(ai[Kt],ai[At]),S=Kt,I=At),(Lt!==C||nn!==N||ft!==U||kt!==F)&&(i.blendFuncSeparate(Wn[Lt],Wn[nn],Wn[ft],Wn[kt]),C=Lt,N=nn,U=ft,F=kt),(ti.equals(k)===!1||rs!==G)&&(i.blendColor(ti.r,ti.g,ti.b,rs),k.copy(ti),G=rs),M=be,B=!1}function yt(be,Kt){be.side===Ae?vt(i.CULL_FACE):Oe(i.CULL_FACE);let Lt=be.side===we;Kt&&(Lt=!Lt),ct(Lt),be.blending===Ue&&be.transparent===!1?rt(ve):rt(be.blending,be.blendEquation,be.blendSrc,be.blendDst,be.blendEquationAlpha,be.blendSrcAlpha,be.blendDstAlpha,be.blendColor,be.blendAlpha,be.premultipliedAlpha),a.setFunc(be.depthFunc),a.setTest(be.depthTest),a.setMask(be.depthWrite),o.setMask(be.colorWrite);const nn=be.stencilWrite;c.setTest(nn),nn&&(c.setMask(be.stencilWriteMask),c.setFunc(be.stencilFunc,be.stencilRef,be.stencilFuncMask),c.setOp(be.stencilFail,be.stencilZFail,be.stencilZPass)),Ln(be.polygonOffset,be.polygonOffsetFactor,be.polygonOffsetUnits),be.alphaToCoverage===!0?Oe(i.SAMPLE_ALPHA_TO_COVERAGE):vt(i.SAMPLE_ALPHA_TO_COVERAGE)}function ct(be){z!==be&&(be?i.frontFace(i.CW):i.frontFace(i.CCW),z=be)}function Ft(be){be!==$?(Oe(i.CULL_FACE),be!==Q&&(be===J?i.cullFace(i.BACK):be===j?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):vt(i.CULL_FACE),Q=be}function ne(be){be!==ye&&(Ne&&i.lineWidth(be),ye=be)}function Ln(be,Kt,Lt){be?(Oe(i.POLYGON_OFFSET_FILL),(_e!==Kt||Te!==Lt)&&(i.polygonOffset(Kt,Lt),_e=Kt,Te=Lt)):vt(i.POLYGON_OFFSET_FILL)}function en(be){be?Oe(i.SCISSOR_TEST):vt(i.SCISSOR_TEST)}function Hn(be){be===void 0&&(be=i.TEXTURE0+Pe-1),Mt!==be&&(i.activeTexture(be),Mt=be)}function Bt(be,Kt,Lt){Lt===void 0&&(Mt===null?Lt=i.TEXTURE0+Pe-1:Lt=Mt);let nn=Tt[Lt];nn===void 0&&(nn={type:void 0,texture:void 0},Tt[Lt]=nn),(nn.type!==be||nn.texture!==Kt)&&(Mt!==Lt&&(i.activeTexture(Lt),Mt=Lt),i.bindTexture(be,Kt||Ee[be]),nn.type=be,nn.texture=Kt)}function ee(){const be=Tt[Mt];be!==void 0&&be.type!==void 0&&(i.bindTexture(be.type,null),be.type=void 0,be.texture=void 0)}function V(){try{i.compressedTexImage2D(...arguments)}catch(be){Be("WebGLState:",be)}}function Se(){try{i.compressedTexImage3D(...arguments)}catch(be){Be("WebGLState:",be)}}function je(){try{i.texSubImage2D(...arguments)}catch(be){Be("WebGLState:",be)}}function dt(){try{i.texSubImage3D(...arguments)}catch(be){Be("WebGLState:",be)}}function Ze(){try{i.compressedTexSubImage2D(...arguments)}catch(be){Be("WebGLState:",be)}}function yn(){try{i.compressedTexSubImage3D(...arguments)}catch(be){Be("WebGLState:",be)}}function Ot(){try{i.texStorage2D(...arguments)}catch(be){Be("WebGLState:",be)}}function fn(){try{i.texStorage3D(...arguments)}catch(be){Be("WebGLState:",be)}}function jn(){try{i.texImage2D(...arguments)}catch(be){Be("WebGLState:",be)}}function bt(){try{i.texImage3D(...arguments)}catch(be){Be("WebGLState:",be)}}function Wt(be){wt.equals(be)===!1&&(i.scissor(be.x,be.y,be.z,be.w),wt.copy(be))}function pn(be){In.equals(be)===!1&&(i.viewport(be.x,be.y,be.z,be.w),In.copy(be))}function vn(be,Kt){let Lt=d.get(Kt);Lt===void 0&&(Lt=new WeakMap,d.set(Kt,Lt));let nn=Lt.get(be);nn===void 0&&(nn=i.getUniformBlockIndex(Kt,be.name),Lt.set(be,nn))}function Vt(be,Kt){const nn=d.get(Kt).get(be);u.get(Kt)!==nn&&(i.uniformBlockBinding(Kt,nn,be.__bindingPointIndex),u.set(Kt,nn))}function li(){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),a.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),p={},Mt=null,Tt={},m={},y=new WeakMap,x=[],v=null,w=!1,M=null,S=null,C=null,N=null,I=null,U=null,F=null,k=new It(0,0,0),G=0,B=!1,z=null,Q=null,ye=null,_e=null,Te=null,wt.set(0,0,i.canvas.width,i.canvas.height),In.set(0,0,i.canvas.width,i.canvas.height),o.reset(),a.reset(),c.reset()}return{buffers:{color:o,depth:a,stencil:c},enable:Oe,disable:vt,bindFramebuffer:Zt,drawBuffers:Pt,useProgram:wn,setBlending:rt,setMaterial:yt,setFlipSided:ct,setCullFace:Ft,setLineWidth:ne,setPolygonOffset:Ln,setScissorTest:en,activeTexture:Hn,bindTexture:Bt,unbindTexture:ee,compressedTexImage2D:V,compressedTexImage3D:Se,texImage2D:jn,texImage3D:bt,updateUBOMapping:vn,uniformBlockBinding:Vt,texStorage2D:Ot,texStorage3D:fn,texSubImage2D:je,texSubImage3D:dt,compressedTexSubImage2D:Ze,compressedTexSubImage3D:yn,scissor:Wt,viewport:pn,reset:li}}function Gk(i,e,t,n,r,o,a){const c=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,u=typeof navigator=="undefined"?!1:/OculusBrowser/g.test(navigator.userAgent),d=new ze,p=new WeakMap;let m;const y=new WeakMap;let x=!1;try{x=typeof OffscreenCanvas!="undefined"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch(ee){}function v(ee,V){return x?new OffscreenCanvas(ee,V):ci("canvas")}function w(ee,V,Se){let je=1;const dt=Bt(ee);if((dt.width>Se||dt.height>Se)&&(je=Se/Math.max(dt.width,dt.height)),je<1)if(typeof HTMLImageElement!="undefined"&&ee instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&ee instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&ee instanceof ImageBitmap||typeof VideoFrame!="undefined"&&ee instanceof VideoFrame){const Ze=Math.floor(je*dt.width),yn=Math.floor(je*dt.height);m===void 0&&(m=v(Ze,yn));const Ot=V?v(Ze,yn):m;return Ot.width=Ze,Ot.height=yn,Ot.getContext("2d").drawImage(ee,0,0,Ze,yn),Ie("WebGLRenderer: Texture has been resized from ("+dt.width+"x"+dt.height+") to ("+Ze+"x"+yn+")."),Ot}else return"data"in ee&&Ie("WebGLRenderer: Image in DataTexture is too big ("+dt.width+"x"+dt.height+")."),ee;return ee}function M(ee){return ee.generateMipmaps}function S(ee){i.generateMipmap(ee)}function C(ee){return ee.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:ee.isWebGL3DRenderTarget?i.TEXTURE_3D:ee.isWebGLArrayRenderTarget||ee.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function N(ee,V,Se,je,dt=!1){if(ee!==null){if(i[ee]!==void 0)return i[ee];Ie("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+ee+"'")}let Ze=V;if(V===i.RED&&(Se===i.FLOAT&&(Ze=i.R32F),Se===i.HALF_FLOAT&&(Ze=i.R16F),Se===i.UNSIGNED_BYTE&&(Ze=i.R8)),V===i.RED_INTEGER&&(Se===i.UNSIGNED_BYTE&&(Ze=i.R8UI),Se===i.UNSIGNED_SHORT&&(Ze=i.R16UI),Se===i.UNSIGNED_INT&&(Ze=i.R32UI),Se===i.BYTE&&(Ze=i.R8I),Se===i.SHORT&&(Ze=i.R16I),Se===i.INT&&(Ze=i.R32I)),V===i.RG&&(Se===i.FLOAT&&(Ze=i.RG32F),Se===i.HALF_FLOAT&&(Ze=i.RG16F),Se===i.UNSIGNED_BYTE&&(Ze=i.RG8)),V===i.RG_INTEGER&&(Se===i.UNSIGNED_BYTE&&(Ze=i.RG8UI),Se===i.UNSIGNED_SHORT&&(Ze=i.RG16UI),Se===i.UNSIGNED_INT&&(Ze=i.RG32UI),Se===i.BYTE&&(Ze=i.RG8I),Se===i.SHORT&&(Ze=i.RG16I),Se===i.INT&&(Ze=i.RG32I)),V===i.RGB_INTEGER&&(Se===i.UNSIGNED_BYTE&&(Ze=i.RGB8UI),Se===i.UNSIGNED_SHORT&&(Ze=i.RGB16UI),Se===i.UNSIGNED_INT&&(Ze=i.RGB32UI),Se===i.BYTE&&(Ze=i.RGB8I),Se===i.SHORT&&(Ze=i.RGB16I),Se===i.INT&&(Ze=i.RGB32I)),V===i.RGBA_INTEGER&&(Se===i.UNSIGNED_BYTE&&(Ze=i.RGBA8UI),Se===i.UNSIGNED_SHORT&&(Ze=i.RGBA16UI),Se===i.UNSIGNED_INT&&(Ze=i.RGBA32UI),Se===i.BYTE&&(Ze=i.RGBA8I),Se===i.SHORT&&(Ze=i.RGBA16I),Se===i.INT&&(Ze=i.RGBA32I)),V===i.RGB&&(Se===i.UNSIGNED_INT_5_9_9_9_REV&&(Ze=i.RGB9_E5),Se===i.UNSIGNED_INT_10F_11F_11F_REV&&(Ze=i.R11F_G11F_B10F)),V===i.RGBA){const yn=dt?cf:xn.getTransfer(je);Se===i.FLOAT&&(Ze=i.RGBA32F),Se===i.HALF_FLOAT&&(Ze=i.RGBA16F),Se===i.UNSIGNED_BYTE&&(Ze=yn===$t?i.SRGB8_ALPHA8:i.RGBA8),Se===i.UNSIGNED_SHORT_4_4_4_4&&(Ze=i.RGBA4),Se===i.UNSIGNED_SHORT_5_5_5_1&&(Ze=i.RGB5_A1)}return(Ze===i.R16F||Ze===i.R32F||Ze===i.RG16F||Ze===i.RG32F||Ze===i.RGBA16F||Ze===i.RGBA32F)&&e.get("EXT_color_buffer_float"),Ze}function I(ee,V){let Se;return ee?V===null||V===yi||V===wo?Se=i.DEPTH24_STENCIL8:V===Si?Se=i.DEPTH32F_STENCIL8:V===jo&&(Se=i.DEPTH24_STENCIL8,Ie("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):V===null||V===yi||V===wo?Se=i.DEPTH_COMPONENT24:V===Si?Se=i.DEPTH_COMPONENT32F:V===jo&&(Se=i.DEPTH_COMPONENT16),Se}function U(ee,V){return M(ee)===!0||ee.isFramebufferTexture&&ee.minFilter!==ni&&ee.minFilter!==Yn?Math.log2(Math.max(V.width,V.height))+1:ee.mipmaps!==void 0&&ee.mipmaps.length>0?ee.mipmaps.length:ee.isCompressedTexture&&Array.isArray(ee.image)?V.mipmaps.length:1}function F(ee){const V=ee.target;V.removeEventListener("dispose",F),G(V),V.isVideoTexture&&p.delete(V)}function k(ee){const V=ee.target;V.removeEventListener("dispose",k),z(V)}function G(ee){const V=n.get(ee);if(V.__webglInit===void 0)return;const Se=ee.source,je=y.get(Se);if(je){const dt=je[V.__cacheKey];dt.usedTimes--,dt.usedTimes===0&&B(ee),Object.keys(je).length===0&&y.delete(Se)}n.remove(ee)}function B(ee){const V=n.get(ee);i.deleteTexture(V.__webglTexture);const Se=ee.source,je=y.get(Se);delete je[V.__cacheKey],a.memory.textures--}function z(ee){const V=n.get(ee);if(ee.depthTexture&&(ee.depthTexture.dispose(),n.remove(ee.depthTexture)),ee.isWebGLCubeRenderTarget)for(let je=0;je<6;je++){if(Array.isArray(V.__webglFramebuffer[je]))for(let dt=0;dt<V.__webglFramebuffer[je].length;dt++)i.deleteFramebuffer(V.__webglFramebuffer[je][dt]);else i.deleteFramebuffer(V.__webglFramebuffer[je]);V.__webglDepthbuffer&&i.deleteRenderbuffer(V.__webglDepthbuffer[je])}else{if(Array.isArray(V.__webglFramebuffer))for(let je=0;je<V.__webglFramebuffer.length;je++)i.deleteFramebuffer(V.__webglFramebuffer[je]);else i.deleteFramebuffer(V.__webglFramebuffer);if(V.__webglDepthbuffer&&i.deleteRenderbuffer(V.__webglDepthbuffer),V.__webglMultisampledFramebuffer&&i.deleteFramebuffer(V.__webglMultisampledFramebuffer),V.__webglColorRenderbuffer)for(let je=0;je<V.__webglColorRenderbuffer.length;je++)V.__webglColorRenderbuffer[je]&&i.deleteRenderbuffer(V.__webglColorRenderbuffer[je]);V.__webglDepthRenderbuffer&&i.deleteRenderbuffer(V.__webglDepthRenderbuffer)}const Se=ee.textures;for(let je=0,dt=Se.length;je<dt;je++){const Ze=n.get(Se[je]);Ze.__webglTexture&&(i.deleteTexture(Ze.__webglTexture),a.memory.textures--),n.remove(Se[je])}n.remove(ee)}let Q=0;function ye(){Q=0}function _e(){const ee=Q;return ee>=r.maxTextures&&Ie("WebGLTextures: Trying to use "+ee+" texture units while this GPU supports only "+r.maxTextures),Q+=1,ee}function Te(ee){const V=[];return V.push(ee.wrapS),V.push(ee.wrapT),V.push(ee.wrapR||0),V.push(ee.magFilter),V.push(ee.minFilter),V.push(ee.anisotropy),V.push(ee.internalFormat),V.push(ee.format),V.push(ee.type),V.push(ee.generateMipmaps),V.push(ee.premultiplyAlpha),V.push(ee.flipY),V.push(ee.unpackAlignment),V.push(ee.colorSpace),V.join()}function Pe(ee,V){const Se=n.get(ee);if(ee.isVideoTexture&&en(ee),ee.isRenderTargetTexture===!1&&ee.isExternalTexture!==!0&&ee.version>0&&Se.__version!==ee.version){const je=ee.image;if(je===null)Ie("WebGLRenderer: Texture marked for update but no image data found.");else if(je.complete===!1)Ie("WebGLRenderer: Texture marked for update but image is incomplete");else{Ee(Se,ee,V);return}}else ee.isExternalTexture&&(Se.__webglTexture=ee.sourceTexture?ee.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,Se.__webglTexture,i.TEXTURE0+V)}function Ne(ee,V){const Se=n.get(ee);if(ee.isRenderTargetTexture===!1&&ee.version>0&&Se.__version!==ee.version){Ee(Se,ee,V);return}else ee.isExternalTexture&&(Se.__webglTexture=ee.sourceTexture?ee.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,Se.__webglTexture,i.TEXTURE0+V)}function De(ee,V){const Se=n.get(ee);if(ee.isRenderTargetTexture===!1&&ee.version>0&&Se.__version!==ee.version){Ee(Se,ee,V);return}t.bindTexture(i.TEXTURE_3D,Se.__webglTexture,i.TEXTURE0+V)}function Qe(ee,V){const Se=n.get(ee);if(ee.isCubeDepthTexture!==!0&&ee.version>0&&Se.__version!==ee.version){Oe(Se,ee,V);return}t.bindTexture(i.TEXTURE_CUBE_MAP,Se.__webglTexture,i.TEXTURE0+V)}const Mt={[Ea]:i.REPEAT,[ki]:i.CLAMP_TO_EDGE,[Ca]:i.MIRRORED_REPEAT},Tt={[ni]:i.NEAREST,[Pp]:i.NEAREST_MIPMAP_NEAREST,[Ra]:i.NEAREST_MIPMAP_LINEAR,[Yn]:i.LINEAR,[Zc]:i.LINEAR_MIPMAP_NEAREST,[Vs]:i.LINEAR_MIPMAP_LINEAR},Fe={[y_]:i.NEVER,[b_]:i.ALWAYS,[Vl]:i.LESS,[Bp]:i.LEQUAL,[__]:i.EQUAL,[Op]:i.GEQUAL,[x_]:i.GREATER,[v_]:i.NOTEQUAL};function mt(ee,V){if(V.type===Si&&e.has("OES_texture_float_linear")===!1&&(V.magFilter===Yn||V.magFilter===Zc||V.magFilter===Ra||V.magFilter===Vs||V.minFilter===Yn||V.minFilter===Zc||V.minFilter===Ra||V.minFilter===Vs)&&Ie("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(ee,i.TEXTURE_WRAP_S,Mt[V.wrapS]),i.texParameteri(ee,i.TEXTURE_WRAP_T,Mt[V.wrapT]),(ee===i.TEXTURE_3D||ee===i.TEXTURE_2D_ARRAY)&&i.texParameteri(ee,i.TEXTURE_WRAP_R,Mt[V.wrapR]),i.texParameteri(ee,i.TEXTURE_MAG_FILTER,Tt[V.magFilter]),i.texParameteri(ee,i.TEXTURE_MIN_FILTER,Tt[V.minFilter]),V.compareFunction&&(i.texParameteri(ee,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(ee,i.TEXTURE_COMPARE_FUNC,Fe[V.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(V.magFilter===ni||V.minFilter!==Ra&&V.minFilter!==Vs||V.type===Si&&e.has("OES_texture_float_linear")===!1)return;if(V.anisotropy>1||n.get(V).__currentAnisotropy){const Se=e.get("EXT_texture_filter_anisotropic");i.texParameterf(ee,Se.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(V.anisotropy,r.getMaxAnisotropy())),n.get(V).__currentAnisotropy=V.anisotropy}}}function wt(ee,V){let Se=!1;ee.__webglInit===void 0&&(ee.__webglInit=!0,V.addEventListener("dispose",F));const je=V.source;let dt=y.get(je);dt===void 0&&(dt={},y.set(je,dt));const Ze=Te(V);if(Ze!==ee.__cacheKey){dt[Ze]===void 0&&(dt[Ze]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,Se=!0),dt[Ze].usedTimes++;const yn=dt[ee.__cacheKey];yn!==void 0&&(dt[ee.__cacheKey].usedTimes--,yn.usedTimes===0&&B(V)),ee.__cacheKey=Ze,ee.__webglTexture=dt[Ze].texture}return Se}function In(ee,V,Se){return Math.floor(Math.floor(ee/Se)/V)}function st(ee,V,Se,je){const Ze=ee.updateRanges;if(Ze.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,V.width,V.height,Se,je,V.data);else{Ze.sort((bt,Wt)=>bt.start-Wt.start);let yn=0;for(let bt=1;bt<Ze.length;bt++){const Wt=Ze[yn],pn=Ze[bt],vn=Wt.start+Wt.count,Vt=In(pn.start,V.width,4),li=In(Wt.start,V.width,4);pn.start<=vn+1&&Vt===li&&In(pn.start+pn.count-1,V.width,4)===Vt?Wt.count=Math.max(Wt.count,pn.start+pn.count-Wt.start):(++yn,Ze[yn]=pn)}Ze.length=yn+1;const Ot=i.getParameter(i.UNPACK_ROW_LENGTH),fn=i.getParameter(i.UNPACK_SKIP_PIXELS),jn=i.getParameter(i.UNPACK_SKIP_ROWS);i.pixelStorei(i.UNPACK_ROW_LENGTH,V.width);for(let bt=0,Wt=Ze.length;bt<Wt;bt++){const pn=Ze[bt],vn=Math.floor(pn.start/4),Vt=Math.ceil(pn.count/4),li=vn%V.width,be=Math.floor(vn/V.width),Kt=Vt,Lt=1;i.pixelStorei(i.UNPACK_SKIP_PIXELS,li),i.pixelStorei(i.UNPACK_SKIP_ROWS,be),t.texSubImage2D(i.TEXTURE_2D,0,li,be,Kt,Lt,Se,je,V.data)}ee.clearUpdateRanges(),i.pixelStorei(i.UNPACK_ROW_LENGTH,Ot),i.pixelStorei(i.UNPACK_SKIP_PIXELS,fn),i.pixelStorei(i.UNPACK_SKIP_ROWS,jn)}}function Ee(ee,V,Se){let je=i.TEXTURE_2D;(V.isDataArrayTexture||V.isCompressedArrayTexture)&&(je=i.TEXTURE_2D_ARRAY),V.isData3DTexture&&(je=i.TEXTURE_3D);const dt=wt(ee,V),Ze=V.source;t.bindTexture(je,ee.__webglTexture,i.TEXTURE0+Se);const yn=n.get(Ze);if(Ze.version!==yn.__version||dt===!0){t.activeTexture(i.TEXTURE0+Se);const Ot=xn.getPrimaries(xn.workingColorSpace),fn=V.colorSpace===_r?null:xn.getPrimaries(V.colorSpace),jn=V.colorSpace===_r||Ot===fn?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,jn);let bt=w(V.image,!1,r.maxTextureSize);bt=Hn(V,bt);const Wt=o.convert(V.format,V.colorSpace),pn=o.convert(V.type);let vn=N(V.internalFormat,Wt,pn,V.colorSpace,V.isVideoTexture);mt(je,V);let Vt;const li=V.mipmaps,be=V.isVideoTexture!==!0,Kt=yn.__version===void 0||dt===!0,Lt=Ze.dataReady,nn=U(V,bt);if(V.isDepthTexture)vn=I(V.format===Rr,V.type),Kt&&(be?t.texStorage2D(i.TEXTURE_2D,1,vn,bt.width,bt.height):t.texImage2D(i.TEXTURE_2D,0,vn,bt.width,bt.height,0,Wt,pn,null));else if(V.isDataTexture)if(li.length>0){be&&Kt&&t.texStorage2D(i.TEXTURE_2D,nn,vn,li[0].width,li[0].height);for(let At=0,ft=li.length;At<ft;At++)Vt=li[At],be?Lt&&t.texSubImage2D(i.TEXTURE_2D,At,0,0,Vt.width,Vt.height,Wt,pn,Vt.data):t.texImage2D(i.TEXTURE_2D,At,vn,Vt.width,Vt.height,0,Wt,pn,Vt.data);V.generateMipmaps=!1}else be?(Kt&&t.texStorage2D(i.TEXTURE_2D,nn,vn,bt.width,bt.height),Lt&&st(V,bt,Wt,pn)):t.texImage2D(i.TEXTURE_2D,0,vn,bt.width,bt.height,0,Wt,pn,bt.data);else if(V.isCompressedTexture)if(V.isCompressedArrayTexture){be&&Kt&&t.texStorage3D(i.TEXTURE_2D_ARRAY,nn,vn,li[0].width,li[0].height,bt.depth);for(let At=0,ft=li.length;At<ft;At++)if(Vt=li[At],V.format!==Ri)if(Wt!==null)if(be){if(Lt)if(V.layerUpdates.size>0){const kt=l(Vt.width,Vt.height,V.format,V.type);for(const ti of V.layerUpdates){const rs=Vt.data.subarray(ti*kt/Vt.data.BYTES_PER_ELEMENT,(ti+1)*kt/Vt.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,At,0,0,ti,Vt.width,Vt.height,1,Wt,rs)}V.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,At,0,0,0,Vt.width,Vt.height,bt.depth,Wt,Vt.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,At,vn,Vt.width,Vt.height,bt.depth,0,Vt.data,0,0);else Ie("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else be?Lt&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,At,0,0,0,Vt.width,Vt.height,bt.depth,Wt,pn,Vt.data):t.texImage3D(i.TEXTURE_2D_ARRAY,At,vn,Vt.width,Vt.height,bt.depth,0,Wt,pn,Vt.data)}else{be&&Kt&&t.texStorage2D(i.TEXTURE_2D,nn,vn,li[0].width,li[0].height);for(let At=0,ft=li.length;At<ft;At++)Vt=li[At],V.format!==Ri?Wt!==null?be?Lt&&t.compressedTexSubImage2D(i.TEXTURE_2D,At,0,0,Vt.width,Vt.height,Wt,Vt.data):t.compressedTexImage2D(i.TEXTURE_2D,At,vn,Vt.width,Vt.height,0,Vt.data):Ie("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):be?Lt&&t.texSubImage2D(i.TEXTURE_2D,At,0,0,Vt.width,Vt.height,Wt,pn,Vt.data):t.texImage2D(i.TEXTURE_2D,At,vn,Vt.width,Vt.height,0,Wt,pn,Vt.data)}else if(V.isDataArrayTexture)if(be){if(Kt&&t.texStorage3D(i.TEXTURE_2D_ARRAY,nn,vn,bt.width,bt.height,bt.depth),Lt)if(V.layerUpdates.size>0){const At=l(bt.width,bt.height,V.format,V.type);for(const ft of V.layerUpdates){const kt=bt.data.subarray(ft*At/bt.data.BYTES_PER_ELEMENT,(ft+1)*At/bt.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,ft,bt.width,bt.height,1,Wt,pn,kt)}V.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,bt.width,bt.height,bt.depth,Wt,pn,bt.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,vn,bt.width,bt.height,bt.depth,0,Wt,pn,bt.data);else if(V.isData3DTexture)be?(Kt&&t.texStorage3D(i.TEXTURE_3D,nn,vn,bt.width,bt.height,bt.depth),Lt&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,bt.width,bt.height,bt.depth,Wt,pn,bt.data)):t.texImage3D(i.TEXTURE_3D,0,vn,bt.width,bt.height,bt.depth,0,Wt,pn,bt.data);else if(V.isFramebufferTexture){if(Kt)if(be)t.texStorage2D(i.TEXTURE_2D,nn,vn,bt.width,bt.height);else{let At=bt.width,ft=bt.height;for(let kt=0;kt<nn;kt++)t.texImage2D(i.TEXTURE_2D,kt,vn,At,ft,0,Wt,pn,null),At>>=1,ft>>=1}}else if(li.length>0){if(be&&Kt){const At=Bt(li[0]);t.texStorage2D(i.TEXTURE_2D,nn,vn,At.width,At.height)}for(let At=0,ft=li.length;At<ft;At++)Vt=li[At],be?Lt&&t.texSubImage2D(i.TEXTURE_2D,At,0,0,Wt,pn,Vt):t.texImage2D(i.TEXTURE_2D,At,vn,Wt,pn,Vt);V.generateMipmaps=!1}else if(be){if(Kt){const At=Bt(bt);t.texStorage2D(i.TEXTURE_2D,nn,vn,At.width,At.height)}Lt&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,Wt,pn,bt)}else t.texImage2D(i.TEXTURE_2D,0,vn,Wt,pn,bt);M(V)&&S(je),yn.__version=Ze.version,V.onUpdate&&V.onUpdate(V)}ee.__version=V.version}function Oe(ee,V,Se){if(V.image.length!==6)return;const je=wt(ee,V),dt=V.source;t.bindTexture(i.TEXTURE_CUBE_MAP,ee.__webglTexture,i.TEXTURE0+Se);const Ze=n.get(dt);if(dt.version!==Ze.__version||je===!0){t.activeTexture(i.TEXTURE0+Se);const yn=xn.getPrimaries(xn.workingColorSpace),Ot=V.colorSpace===_r?null:xn.getPrimaries(V.colorSpace),fn=V.colorSpace===_r||yn===Ot?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,fn);const jn=V.isCompressedTexture||V.image[0].isCompressedTexture,bt=V.image[0]&&V.image[0].isDataTexture,Wt=[];for(let ft=0;ft<6;ft++)!jn&&!bt?Wt[ft]=w(V.image[ft],!0,r.maxCubemapSize):Wt[ft]=bt?V.image[ft].image:V.image[ft],Wt[ft]=Hn(V,Wt[ft]);const pn=Wt[0],vn=o.convert(V.format,V.colorSpace),Vt=o.convert(V.type),li=N(V.internalFormat,vn,Vt,V.colorSpace),be=V.isVideoTexture!==!0,Kt=Ze.__version===void 0||je===!0,Lt=dt.dataReady;let nn=U(V,pn);mt(i.TEXTURE_CUBE_MAP,V);let At;if(jn){be&&Kt&&t.texStorage2D(i.TEXTURE_CUBE_MAP,nn,li,pn.width,pn.height);for(let ft=0;ft<6;ft++){At=Wt[ft].mipmaps;for(let kt=0;kt<At.length;kt++){const ti=At[kt];V.format!==Ri?vn!==null?be?Lt&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ft,kt,0,0,ti.width,ti.height,vn,ti.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ft,kt,li,ti.width,ti.height,0,ti.data):Ie("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):be?Lt&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ft,kt,0,0,ti.width,ti.height,vn,Vt,ti.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ft,kt,li,ti.width,ti.height,0,vn,Vt,ti.data)}}}else{if(At=V.mipmaps,be&&Kt){At.length>0&&nn++;const ft=Bt(Wt[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,nn,li,ft.width,ft.height)}for(let ft=0;ft<6;ft++)if(bt){be?Lt&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ft,0,0,0,Wt[ft].width,Wt[ft].height,vn,Vt,Wt[ft].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ft,0,li,Wt[ft].width,Wt[ft].height,0,vn,Vt,Wt[ft].data);for(let kt=0;kt<At.length;kt++){const rs=At[kt].image[ft].image;be?Lt&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ft,kt+1,0,0,rs.width,rs.height,vn,Vt,rs.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ft,kt+1,li,rs.width,rs.height,0,vn,Vt,rs.data)}}else{be?Lt&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ft,0,0,0,vn,Vt,Wt[ft]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ft,0,li,vn,Vt,Wt[ft]);for(let kt=0;kt<At.length;kt++){const ti=At[kt];be?Lt&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ft,kt+1,0,0,vn,Vt,ti.image[ft]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ft,kt+1,li,vn,Vt,ti.image[ft])}}}M(V)&&S(i.TEXTURE_CUBE_MAP),Ze.__version=dt.version,V.onUpdate&&V.onUpdate(V)}ee.__version=V.version}function vt(ee,V,Se,je,dt,Ze){const yn=o.convert(Se.format,Se.colorSpace),Ot=o.convert(Se.type),fn=N(Se.internalFormat,yn,Ot,Se.colorSpace),jn=n.get(V),bt=n.get(Se);if(bt.__renderTarget=V,!jn.__hasExternalTextures){const Wt=Math.max(1,V.width>>Ze),pn=Math.max(1,V.height>>Ze);dt===i.TEXTURE_3D||dt===i.TEXTURE_2D_ARRAY?t.texImage3D(dt,Ze,fn,Wt,pn,V.depth,0,yn,Ot,null):t.texImage2D(dt,Ze,fn,Wt,pn,0,yn,Ot,null)}t.bindFramebuffer(i.FRAMEBUFFER,ee),Ln(V)?c.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,je,dt,bt.__webglTexture,0,ne(V)):(dt===i.TEXTURE_2D||dt>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&dt<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,je,dt,bt.__webglTexture,Ze),t.bindFramebuffer(i.FRAMEBUFFER,null)}function Zt(ee,V,Se){if(i.bindRenderbuffer(i.RENDERBUFFER,ee),V.depthBuffer){const je=V.depthTexture,dt=je&&je.isDepthTexture?je.type:null,Ze=I(V.stencilBuffer,dt),yn=V.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;Ln(V)?c.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ne(V),Ze,V.width,V.height):Se?i.renderbufferStorageMultisample(i.RENDERBUFFER,ne(V),Ze,V.width,V.height):i.renderbufferStorage(i.RENDERBUFFER,Ze,V.width,V.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,yn,i.RENDERBUFFER,ee)}else{const je=V.textures;for(let dt=0;dt<je.length;dt++){const Ze=je[dt],yn=o.convert(Ze.format,Ze.colorSpace),Ot=o.convert(Ze.type),fn=N(Ze.internalFormat,yn,Ot,Ze.colorSpace);Ln(V)?c.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ne(V),fn,V.width,V.height):Se?i.renderbufferStorageMultisample(i.RENDERBUFFER,ne(V),fn,V.width,V.height):i.renderbufferStorage(i.RENDERBUFFER,fn,V.width,V.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Pt(ee,V,Se){const je=V.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(i.FRAMEBUFFER,ee),!(V.depthTexture&&V.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const dt=n.get(V.depthTexture);if(dt.__renderTarget=V,(!dt.__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),je){if(dt.__webglInit===void 0&&(dt.__webglInit=!0,V.depthTexture.addEventListener("dispose",F)),dt.__webglTexture===void 0){dt.__webglTexture=i.createTexture(),t.bindTexture(i.TEXTURE_CUBE_MAP,dt.__webglTexture),mt(i.TEXTURE_CUBE_MAP,V.depthTexture);const jn=o.convert(V.depthTexture.format),bt=o.convert(V.depthTexture.type);let Wt;V.depthTexture.format===tr?Wt=i.DEPTH_COMPONENT24:V.depthTexture.format===Rr&&(Wt=i.DEPTH24_STENCIL8);for(let pn=0;pn<6;pn++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+pn,0,Wt,V.width,V.height,0,jn,bt,null)}}else Pe(V.depthTexture,0);const Ze=dt.__webglTexture,yn=ne(V),Ot=je?i.TEXTURE_CUBE_MAP_POSITIVE_X+Se:i.TEXTURE_2D,fn=V.depthTexture.format===Rr?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(V.depthTexture.format===tr)Ln(V)?c.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,fn,Ot,Ze,0,yn):i.framebufferTexture2D(i.FRAMEBUFFER,fn,Ot,Ze,0);else if(V.depthTexture.format===Rr)Ln(V)?c.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,fn,Ot,Ze,0,yn):i.framebufferTexture2D(i.FRAMEBUFFER,fn,Ot,Ze,0);else throw new Error("Unknown depthTexture format")}function wn(ee){const V=n.get(ee),Se=ee.isWebGLCubeRenderTarget===!0;if(V.__boundDepthTexture!==ee.depthTexture){const je=ee.depthTexture;if(V.__depthDisposeCallback&&V.__depthDisposeCallback(),je){const dt=()=>{delete V.__boundDepthTexture,delete V.__depthDisposeCallback,je.removeEventListener("dispose",dt)};je.addEventListener("dispose",dt),V.__depthDisposeCallback=dt}V.__boundDepthTexture=je}if(ee.depthTexture&&!V.__autoAllocateDepthBuffer)if(Se)for(let je=0;je<6;je++)Pt(V.__webglFramebuffer[je],ee,je);else{const je=ee.texture.mipmaps;je&&je.length>0?Pt(V.__webglFramebuffer[0],ee,0):Pt(V.__webglFramebuffer,ee,0)}else if(Se){V.__webglDepthbuffer=[];for(let je=0;je<6;je++)if(t.bindFramebuffer(i.FRAMEBUFFER,V.__webglFramebuffer[je]),V.__webglDepthbuffer[je]===void 0)V.__webglDepthbuffer[je]=i.createRenderbuffer(),Zt(V.__webglDepthbuffer[je],ee,!1);else{const dt=ee.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Ze=V.__webglDepthbuffer[je];i.bindRenderbuffer(i.RENDERBUFFER,Ze),i.framebufferRenderbuffer(i.FRAMEBUFFER,dt,i.RENDERBUFFER,Ze)}}else{const je=ee.texture.mipmaps;if(je&&je.length>0?t.bindFramebuffer(i.FRAMEBUFFER,V.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,V.__webglFramebuffer),V.__webglDepthbuffer===void 0)V.__webglDepthbuffer=i.createRenderbuffer(),Zt(V.__webglDepthbuffer,ee,!1);else{const dt=ee.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Ze=V.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,Ze),i.framebufferRenderbuffer(i.FRAMEBUFFER,dt,i.RENDERBUFFER,Ze)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function ai(ee,V,Se){const je=n.get(ee);V!==void 0&&vt(je.__webglFramebuffer,ee,ee.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),Se!==void 0&&wn(ee)}function Wn(ee){const V=ee.texture,Se=n.get(ee),je=n.get(V);ee.addEventListener("dispose",k);const dt=ee.textures,Ze=ee.isWebGLCubeRenderTarget===!0,yn=dt.length>1;if(yn||(je.__webglTexture===void 0&&(je.__webglTexture=i.createTexture()),je.__version=V.version,a.memory.textures++),Ze){Se.__webglFramebuffer=[];for(let Ot=0;Ot<6;Ot++)if(V.mipmaps&&V.mipmaps.length>0){Se.__webglFramebuffer[Ot]=[];for(let fn=0;fn<V.mipmaps.length;fn++)Se.__webglFramebuffer[Ot][fn]=i.createFramebuffer()}else Se.__webglFramebuffer[Ot]=i.createFramebuffer()}else{if(V.mipmaps&&V.mipmaps.length>0){Se.__webglFramebuffer=[];for(let Ot=0;Ot<V.mipmaps.length;Ot++)Se.__webglFramebuffer[Ot]=i.createFramebuffer()}else Se.__webglFramebuffer=i.createFramebuffer();if(yn)for(let Ot=0,fn=dt.length;Ot<fn;Ot++){const jn=n.get(dt[Ot]);jn.__webglTexture===void 0&&(jn.__webglTexture=i.createTexture(),a.memory.textures++)}if(ee.samples>0&&Ln(ee)===!1){Se.__webglMultisampledFramebuffer=i.createFramebuffer(),Se.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,Se.__webglMultisampledFramebuffer);for(let Ot=0;Ot<dt.length;Ot++){const fn=dt[Ot];Se.__webglColorRenderbuffer[Ot]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,Se.__webglColorRenderbuffer[Ot]);const jn=o.convert(fn.format,fn.colorSpace),bt=o.convert(fn.type),Wt=N(fn.internalFormat,jn,bt,fn.colorSpace,ee.isXRRenderTarget===!0),pn=ne(ee);i.renderbufferStorageMultisample(i.RENDERBUFFER,pn,Wt,ee.width,ee.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Ot,i.RENDERBUFFER,Se.__webglColorRenderbuffer[Ot])}i.bindRenderbuffer(i.RENDERBUFFER,null),ee.depthBuffer&&(Se.__webglDepthRenderbuffer=i.createRenderbuffer(),Zt(Se.__webglDepthRenderbuffer,ee,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(Ze){t.bindTexture(i.TEXTURE_CUBE_MAP,je.__webglTexture),mt(i.TEXTURE_CUBE_MAP,V);for(let Ot=0;Ot<6;Ot++)if(V.mipmaps&&V.mipmaps.length>0)for(let fn=0;fn<V.mipmaps.length;fn++)vt(Se.__webglFramebuffer[Ot][fn],ee,V,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+Ot,fn);else vt(Se.__webglFramebuffer[Ot],ee,V,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+Ot,0);M(V)&&S(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(yn){for(let Ot=0,fn=dt.length;Ot<fn;Ot++){const jn=dt[Ot],bt=n.get(jn);let Wt=i.TEXTURE_2D;(ee.isWebGL3DRenderTarget||ee.isWebGLArrayRenderTarget)&&(Wt=ee.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(Wt,bt.__webglTexture),mt(Wt,jn),vt(Se.__webglFramebuffer,ee,jn,i.COLOR_ATTACHMENT0+Ot,Wt,0),M(jn)&&S(Wt)}t.unbindTexture()}else{let Ot=i.TEXTURE_2D;if((ee.isWebGL3DRenderTarget||ee.isWebGLArrayRenderTarget)&&(Ot=ee.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(Ot,je.__webglTexture),mt(Ot,V),V.mipmaps&&V.mipmaps.length>0)for(let fn=0;fn<V.mipmaps.length;fn++)vt(Se.__webglFramebuffer[fn],ee,V,i.COLOR_ATTACHMENT0,Ot,fn);else vt(Se.__webglFramebuffer,ee,V,i.COLOR_ATTACHMENT0,Ot,0);M(V)&&S(Ot),t.unbindTexture()}ee.depthBuffer&&wn(ee)}function rt(ee){const V=ee.textures;for(let Se=0,je=V.length;Se<je;Se++){const dt=V[Se];if(M(dt)){const Ze=C(ee),yn=n.get(dt).__webglTexture;t.bindTexture(Ze,yn),S(Ze),t.unbindTexture()}}}const yt=[],ct=[];function Ft(ee){if(ee.samples>0){if(Ln(ee)===!1){const V=ee.textures,Se=ee.width,je=ee.height;let dt=i.COLOR_BUFFER_BIT;const Ze=ee.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,yn=n.get(ee),Ot=V.length>1;if(Ot)for(let jn=0;jn<V.length;jn++)t.bindFramebuffer(i.FRAMEBUFFER,yn.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+jn,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,yn.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+jn,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,yn.__webglMultisampledFramebuffer);const fn=ee.texture.mipmaps;fn&&fn.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,yn.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,yn.__webglFramebuffer);for(let jn=0;jn<V.length;jn++){if(ee.resolveDepthBuffer&&(ee.depthBuffer&&(dt|=i.DEPTH_BUFFER_BIT),ee.stencilBuffer&&ee.resolveStencilBuffer&&(dt|=i.STENCIL_BUFFER_BIT)),Ot){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,yn.__webglColorRenderbuffer[jn]);const bt=n.get(V[jn]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,bt,0)}i.blitFramebuffer(0,0,Se,je,0,0,Se,je,dt,i.NEAREST),u===!0&&(yt.length=0,ct.length=0,yt.push(i.COLOR_ATTACHMENT0+jn),ee.depthBuffer&&ee.resolveDepthBuffer===!1&&(yt.push(Ze),ct.push(Ze),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,ct)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,yt))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),Ot)for(let jn=0;jn<V.length;jn++){t.bindFramebuffer(i.FRAMEBUFFER,yn.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+jn,i.RENDERBUFFER,yn.__webglColorRenderbuffer[jn]);const bt=n.get(V[jn]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,yn.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+jn,i.TEXTURE_2D,bt,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,yn.__webglMultisampledFramebuffer)}else if(ee.depthBuffer&&ee.resolveDepthBuffer===!1&&u){const V=ee.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[V])}}}function ne(ee){return Math.min(r.maxSamples,ee.samples)}function Ln(ee){const V=n.get(ee);return ee.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&V.__useRenderToTexture!==!1}function en(ee){const V=a.render.frame;p.get(ee)!==V&&(p.set(ee,V),ee.update())}function Hn(ee,V){const Se=ee.colorSpace,je=ee.format,dt=ee.type;return ee.isCompressedTexture===!0||ee.isVideoTexture===!0||Se!==io&&Se!==_r&&(xn.getTransfer(Se)===$t?(je!==Ri||dt!==Di)&&Ie("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Be("WebGLTextures: Unsupported texture color space:",Se)),V}function Bt(ee){return typeof HTMLImageElement!="undefined"&&ee instanceof HTMLImageElement?(d.width=ee.naturalWidth||ee.width,d.height=ee.naturalHeight||ee.height):typeof VideoFrame!="undefined"&&ee instanceof VideoFrame?(d.width=ee.displayWidth,d.height=ee.displayHeight):(d.width=ee.width,d.height=ee.height),d}this.allocateTextureUnit=_e,this.resetTextureUnits=ye,this.setTexture2D=Pe,this.setTexture2DArray=Ne,this.setTexture3D=De,this.setTextureCube=Qe,this.rebindTextures=ai,this.setupRenderTarget=Wn,this.updateRenderTargetMipmap=rt,this.updateMultisampleRenderTarget=Ft,this.setupDepthRenderbuffer=wn,this.setupFrameBufferTexture=vt,this.useMultisampledRTT=Ln,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Wk(i,e){function t(n,r=_r){let o;const a=xn.getTransfer(r);if(n===Di)return i.UNSIGNED_BYTE;if(n===Ip)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Lp)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Dp)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Fp)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===Kc)return i.BYTE;if(n===Jc)return i.SHORT;if(n===jo)return i.UNSIGNED_SHORT;if(n===er)return i.INT;if(n===yi)return i.UNSIGNED_INT;if(n===Si)return i.FLOAT;if(n===Hi)return i.HALF_FLOAT;if(n===Rg)return i.ALPHA;if(n===tf)return i.RGB;if(n===Ri)return i.RGBA;if(n===tr)return i.DEPTH_COMPONENT;if(n===Rr)return i.DEPTH_STENCIL;if(n===Qc)return i.RED;if(n===Bl)return i.RED_INTEGER;if(n===Nr)return i.RG;if(n===xh)return i.RG_INTEGER;if(n===vh)return i.RGBA_INTEGER;if(n===Ol||n===Ul||n===kl||n===zl)if(a===$t)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(n===Ol)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Ul)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===kl)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===zl)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(n===Ol)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Ul)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===kl)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===zl)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===nf||n===sf||n===rf||n===of)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(n===nf)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===sf)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===rf)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===of)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===bh||n===Sh||n===Mh||n===Th||n===wh||n===eu||n===Ah)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(n===bh||n===Sh)return a===$t?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(n===Mh)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC;if(n===Th)return o.COMPRESSED_R11_EAC;if(n===wh)return o.COMPRESSED_SIGNED_R11_EAC;if(n===eu)return o.COMPRESSED_RG11_EAC;if(n===Ah)return o.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Eh||n===Ch||n===Rh||n===Nh||n===Ph||n===Ih||n===Lh||n===Dh||n===Fh||n===Bh||n===Oh||n===Uh||n===kh||n===zh)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(n===Eh)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Ch)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Rh)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Nh)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Ph)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Ih)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Lh)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Dh)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Fh)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Bh)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Oh)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Uh)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===kh)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===zh)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Vh||n===Ng||n===Pg)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(n===Vh)return a===$t?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Ng)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Pg)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Gh||n===Wh||n===tu||n===il)if(o=e.get("EXT_texture_compression_rgtc"),o!==null){if(n===Gh)return o.COMPRESSED_RED_RGTC1_EXT;if(n===Wh)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===tu)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===il)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===wo?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const Hk=`
void main() {
gl_Position = vec4( position, 1.0 );
}`,$k=`
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 qk{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new am(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new lo({vertexShader:Hk,fragmentShader:$k,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Ji(new Ed(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Xk extends Jo{constructor(e,t){super();const n=this;let r=null,o=1,a=null,c="local-floor",u=1,d=null,p=null,m=null,y=null,x=null,v=null;const w=typeof XRWebGLBinding!="undefined",M=new qk,S={},C=t.getContextAttributes();let N=null,I=null;const U=[],F=[],k=new ze;let G=null;const B=new Bs;B.viewport=new gn;const z=new Bs;z.viewport=new gn;const Q=[B,z],ye=new xc;let _e=null,Te=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Ee){let Oe=U[Ee];return Oe===void 0&&(Oe=new pl,U[Ee]=Oe),Oe.getTargetRaySpace()},this.getControllerGrip=function(Ee){let Oe=U[Ee];return Oe===void 0&&(Oe=new pl,U[Ee]=Oe),Oe.getGripSpace()},this.getHand=function(Ee){let Oe=U[Ee];return Oe===void 0&&(Oe=new pl,U[Ee]=Oe),Oe.getHandSpace()};function Pe(Ee){const Oe=F.indexOf(Ee.inputSource);if(Oe===-1)return;const vt=U[Oe];vt!==void 0&&(vt.update(Ee.inputSource,Ee.frame,d||a),vt.dispatchEvent({type:Ee.type,data:Ee.inputSource}))}function Ne(){r.removeEventListener("select",Pe),r.removeEventListener("selectstart",Pe),r.removeEventListener("selectend",Pe),r.removeEventListener("squeeze",Pe),r.removeEventListener("squeezestart",Pe),r.removeEventListener("squeezeend",Pe),r.removeEventListener("end",Ne),r.removeEventListener("inputsourceschange",De);for(let Ee=0;Ee<U.length;Ee++){const Oe=F[Ee];Oe!==null&&(F[Ee]=null,U[Ee].disconnect(Oe))}_e=null,Te=null,M.reset();for(const Ee in S)delete S[Ee];e.setRenderTarget(N),x=null,y=null,m=null,r=null,I=null,st.stop(),n.isPresenting=!1,e.setPixelRatio(G),e.setSize(k.width,k.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Ee){o=Ee,n.isPresenting===!0&&Ie("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Ee){c=Ee,n.isPresenting===!0&&Ie("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return d||a},this.setReferenceSpace=function(Ee){d=Ee},this.getBaseLayer=function(){return y!==null?y:x},this.getBinding=function(){return m===null&&w&&(m=new XRWebGLBinding(r,t)),m},this.getFrame=function(){return v},this.getSession=function(){return r},this.setSession=function(Ee){return mn(this,null,function*(){if(r=Ee,r!==null){if(N=e.getRenderTarget(),r.addEventListener("select",Pe),r.addEventListener("selectstart",Pe),r.addEventListener("selectend",Pe),r.addEventListener("squeeze",Pe),r.addEventListener("squeezestart",Pe),r.addEventListener("squeezeend",Pe),r.addEventListener("end",Ne),r.addEventListener("inputsourceschange",De),C.xrCompatible!==!0&&(yield t.makeXRCompatible()),G=e.getPixelRatio(),e.getSize(k),w&&"createProjectionLayer"in XRWebGLBinding.prototype){let vt=null,Zt=null,Pt=null;C.depth&&(Pt=C.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,vt=C.stencil?Rr:tr,Zt=C.stencil?wo:yi);const wn={colorFormat:t.RGBA8,depthFormat:Pt,scaleFactor:o};m=this.getBinding(),y=m.createProjectionLayer(wn),r.updateRenderState({layers:[y]}),e.setPixelRatio(1),e.setSize(y.textureWidth,y.textureHeight,!1),I=new qr(y.textureWidth,y.textureHeight,{format:Ri,type:Di,depthTexture:new Ys(y.textureWidth,y.textureHeight,Zt,void 0,void 0,void 0,void 0,void 0,void 0,vt),stencilBuffer:C.stencil,colorSpace:e.outputColorSpace,samples:C.antialias?4:0,resolveDepthBuffer:y.ignoreDepthValues===!1,resolveStencilBuffer:y.ignoreDepthValues===!1})}else{const vt={antialias:C.antialias,alpha:!0,depth:C.depth,stencil:C.stencil,framebufferScaleFactor:o};x=new XRWebGLLayer(r,t,vt),r.updateRenderState({baseLayer:x}),e.setPixelRatio(1),e.setSize(x.framebufferWidth,x.framebufferHeight,!1),I=new qr(x.framebufferWidth,x.framebufferHeight,{format:Ri,type:Di,colorSpace:e.outputColorSpace,stencilBuffer:C.stencil,resolveDepthBuffer:x.ignoreDepthValues===!1,resolveStencilBuffer:x.ignoreDepthValues===!1})}I.isXRRenderTarget=!0,this.setFoveation(u),d=null,a=yield r.requestReferenceSpace(c),st.setContext(r),st.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}})},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return M.getDepthTexture()};function De(Ee){for(let Oe=0;Oe<Ee.removed.length;Oe++){const vt=Ee.removed[Oe],Zt=F.indexOf(vt);Zt>=0&&(F[Zt]=null,U[Zt].disconnect(vt))}for(let Oe=0;Oe<Ee.added.length;Oe++){const vt=Ee.added[Oe];let Zt=F.indexOf(vt);if(Zt===-1){for(let wn=0;wn<U.length;wn++)if(wn>=F.length){F.push(vt),Zt=wn;break}else if(F[wn]===null){F[wn]=vt,Zt=wn;break}if(Zt===-1)break}const Pt=U[Zt];Pt&&Pt.connect(vt)}}const Qe=new H,Mt=new H;function Tt(Ee,Oe,vt){Qe.setFromMatrixPosition(Oe.matrixWorld),Mt.setFromMatrixPosition(vt.matrixWorld);const Zt=Qe.distanceTo(Mt),Pt=Oe.projectionMatrix.elements,wn=vt.projectionMatrix.elements,ai=Pt[14]/(Pt[10]-1),Wn=Pt[14]/(Pt[10]+1),rt=(Pt[9]+1)/Pt[5],yt=(Pt[9]-1)/Pt[5],ct=(Pt[8]-1)/Pt[0],Ft=(wn[8]+1)/wn[0],ne=ai*ct,Ln=ai*Ft,en=Zt/(-ct+Ft),Hn=en*-ct;if(Oe.matrixWorld.decompose(Ee.position,Ee.quaternion,Ee.scale),Ee.translateX(Hn),Ee.translateZ(en),Ee.matrixWorld.compose(Ee.position,Ee.quaternion,Ee.scale),Ee.matrixWorldInverse.copy(Ee.matrixWorld).invert(),Pt[10]===-1)Ee.projectionMatrix.copy(Oe.projectionMatrix),Ee.projectionMatrixInverse.copy(Oe.projectionMatrixInverse);else{const Bt=ai+en,ee=Wn+en,V=ne-Hn,Se=Ln+(Zt-Hn),je=rt*Wn/ee*Bt,dt=yt*Wn/ee*Bt;Ee.projectionMatrix.makePerspective(V,Se,je,dt,Bt,ee),Ee.projectionMatrixInverse.copy(Ee.projectionMatrix).invert()}}function Fe(Ee,Oe){Oe===null?Ee.matrixWorld.copy(Ee.matrix):Ee.matrixWorld.multiplyMatrices(Oe.matrixWorld,Ee.matrix),Ee.matrixWorldInverse.copy(Ee.matrixWorld).invert()}this.updateCamera=function(Ee){if(r===null)return;let Oe=Ee.near,vt=Ee.far;M.texture!==null&&(M.depthNear>0&&(Oe=M.depthNear),M.depthFar>0&&(vt=M.depthFar)),ye.near=z.near=B.near=Oe,ye.far=z.far=B.far=vt,(_e!==ye.near||Te!==ye.far)&&(r.updateRenderState({depthNear:ye.near,depthFar:ye.far}),_e=ye.near,Te=ye.far),ye.layers.mask=Ee.layers.mask|6,B.layers.mask=ye.layers.mask&3,z.layers.mask=ye.layers.mask&5;const Zt=Ee.parent,Pt=ye.cameras;Fe(ye,Zt);for(let wn=0;wn<Pt.length;wn++)Fe(Pt[wn],Zt);Pt.length===2?Tt(ye,B,z):ye.projectionMatrix.copy(B.projectionMatrix),mt(Ee,ye,Zt)};function mt(Ee,Oe,vt){vt===null?Ee.matrix.copy(Oe.matrixWorld):(Ee.matrix.copy(vt.matrixWorld),Ee.matrix.invert(),Ee.matrix.multiply(Oe.matrixWorld)),Ee.matrix.decompose(Ee.position,Ee.quaternion,Ee.scale),Ee.updateMatrixWorld(!0),Ee.projectionMatrix.copy(Oe.projectionMatrix),Ee.projectionMatrixInverse.copy(Oe.projectionMatrixInverse),Ee.isPerspectiveCamera&&(Ee.fov=ou*2*Math.atan(1/Ee.projectionMatrix.elements[5]),Ee.zoom=1)}this.getCamera=function(){return ye},this.getFoveation=function(){if(!(y===null&&x===null))return u},this.setFoveation=function(Ee){u=Ee,y!==null&&(y.fixedFoveation=Ee),x!==null&&x.fixedFoveation!==void 0&&(x.fixedFoveation=Ee)},this.hasDepthSensing=function(){return M.texture!==null},this.getDepthSensingMesh=function(){return M.getMesh(ye)},this.getCameraTexture=function(Ee){return S[Ee]};let wt=null;function In(Ee,Oe){if(p=Oe.getViewerPose(d||a),v=Oe,p!==null){const vt=p.views;x!==null&&(e.setRenderTargetFramebuffer(I,x.framebuffer),e.setRenderTarget(I));let Zt=!1;vt.length!==ye.cameras.length&&(ye.cameras.length=0,Zt=!0);for(let Wn=0;Wn<vt.length;Wn++){const rt=vt[Wn];let yt=null;if(x!==null)yt=x.getViewport(rt);else{const Ft=m.getViewSubImage(y,rt);yt=Ft.viewport,Wn===0&&(e.setRenderTargetTextures(I,Ft.colorTexture,Ft.depthStencilTexture),e.setRenderTarget(I))}let ct=Q[Wn];ct===void 0&&(ct=new Bs,ct.layers.enable(Wn),ct.viewport=new gn,Q[Wn]=ct),ct.matrix.fromArray(rt.transform.matrix),ct.matrix.decompose(ct.position,ct.quaternion,ct.scale),ct.projectionMatrix.fromArray(rt.projectionMatrix),ct.projectionMatrixInverse.copy(ct.projectionMatrix).invert(),ct.viewport.set(yt.x,yt.y,yt.width,yt.height),Wn===0&&(ye.matrix.copy(ct.matrix),ye.matrix.decompose(ye.position,ye.quaternion,ye.scale)),Zt===!0&&ye.cameras.push(ct)}const Pt=r.enabledFeatures;if(Pt&&Pt.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&w){m=n.getBinding();const Wn=m.getDepthInformation(vt[0]);Wn&&Wn.isValid&&Wn.texture&&M.init(Wn,r.renderState)}if(Pt&&Pt.includes("camera-access")&&w){e.state.unbindTexture(),m=n.getBinding();for(let Wn=0;Wn<vt.length;Wn++){const rt=vt[Wn].camera;if(rt){let yt=S[rt];yt||(yt=new am,S[rt]=yt);const ct=m.getCameraImage(rt);yt.sourceTexture=ct}}}}for(let vt=0;vt<U.length;vt++){const Zt=F[vt],Pt=U[vt];Zt!==null&&Pt!==void 0&&Pt.update(Zt,Oe,d||a)}wt&&wt(Ee,Oe),Oe.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:Oe}),v=null}const st=new TE;st.setAnimationLoop(In),this.setAnimationLoop=function(Ee){wt=Ee},this.dispose=function(){}}}const Zf=new jr,jk=new Qt;function Yk(i,e){function t(M,S){M.matrixAutoUpdate===!0&&M.updateMatrix(),S.value.copy(M.matrix)}function n(M,S){S.color.getRGB(M.fogColor.value,Jg(i)),S.isFog?(M.fogNear.value=S.near,M.fogFar.value=S.far):S.isFogExp2&&(M.fogDensity.value=S.density)}function r(M,S,C,N,I){S.isMeshBasicMaterial||S.isMeshLambertMaterial?o(M,S):S.isMeshToonMaterial?(o(M,S),m(M,S)):S.isMeshPhongMaterial?(o(M,S),p(M,S)):S.isMeshStandardMaterial?(o(M,S),y(M,S),S.isMeshPhysicalMaterial&&x(M,S,I)):S.isMeshMatcapMaterial?(o(M,S),v(M,S)):S.isMeshDepthMaterial?o(M,S):S.isMeshDistanceMaterial?(o(M,S),w(M,S)):S.isMeshNormalMaterial?o(M,S):S.isLineBasicMaterial?(a(M,S),S.isLineDashedMaterial&&c(M,S)):S.isPointsMaterial?u(M,S,C,N):S.isSpriteMaterial?d(M,S):S.isShadowMaterial?(M.color.value.copy(S.color),M.opacity.value=S.opacity):S.isShaderMaterial&&(S.uniformsNeedUpdate=!1)}function o(M,S){M.opacity.value=S.opacity,S.color&&M.diffuse.value.copy(S.color),S.emissive&&M.emissive.value.copy(S.emissive).multiplyScalar(S.emissiveIntensity),S.map&&(M.map.value=S.map,t(S.map,M.mapTransform)),S.alphaMap&&(M.alphaMap.value=S.alphaMap,t(S.alphaMap,M.alphaMapTransform)),S.bumpMap&&(M.bumpMap.value=S.bumpMap,t(S.bumpMap,M.bumpMapTransform),M.bumpScale.value=S.bumpScale,S.side===we&&(M.bumpScale.value*=-1)),S.normalMap&&(M.normalMap.value=S.normalMap,t(S.normalMap,M.normalMapTransform),M.normalScale.value.copy(S.normalScale),S.side===we&&M.normalScale.value.negate()),S.displacementMap&&(M.displacementMap.value=S.displacementMap,t(S.displacementMap,M.displacementMapTransform),M.displacementScale.value=S.displacementScale,M.displacementBias.value=S.displacementBias),S.emissiveMap&&(M.emissiveMap.value=S.emissiveMap,t(S.emissiveMap,M.emissiveMapTransform)),S.specularMap&&(M.specularMap.value=S.specularMap,t(S.specularMap,M.specularMapTransform)),S.alphaTest>0&&(M.alphaTest.value=S.alphaTest);const C=e.get(S),N=C.envMap,I=C.envMapRotation;N&&(M.envMap.value=N,Zf.copy(I),Zf.x*=-1,Zf.y*=-1,Zf.z*=-1,N.isCubeTexture&&N.isRenderTargetTexture===!1&&(Zf.y*=-1,Zf.z*=-1),M.envMapRotation.value.setFromMatrix4(jk.makeRotationFromEuler(Zf)),M.flipEnvMap.value=N.isCubeTexture&&N.isRenderTargetTexture===!1?-1:1,M.reflectivity.value=S.reflectivity,M.ior.value=S.ior,M.refractionRatio.value=S.refractionRatio),S.lightMap&&(M.lightMap.value=S.lightMap,M.lightMapIntensity.value=S.lightMapIntensity,t(S.lightMap,M.lightMapTransform)),S.aoMap&&(M.aoMap.value=S.aoMap,M.aoMapIntensity.value=S.aoMapIntensity,t(S.aoMap,M.aoMapTransform))}function a(M,S){M.diffuse.value.copy(S.color),M.opacity.value=S.opacity,S.map&&(M.map.value=S.map,t(S.map,M.mapTransform))}function c(M,S){M.dashSize.value=S.dashSize,M.totalSize.value=S.dashSize+S.gapSize,M.scale.value=S.scale}function u(M,S,C,N){M.diffuse.value.copy(S.color),M.opacity.value=S.opacity,M.size.value=S.size*C,M.scale.value=N*.5,S.map&&(M.map.value=S.map,t(S.map,M.uvTransform)),S.alphaMap&&(M.alphaMap.value=S.alphaMap,t(S.alphaMap,M.alphaMapTransform)),S.alphaTest>0&&(M.alphaTest.value=S.alphaTest)}function d(M,S){M.diffuse.value.copy(S.color),M.opacity.value=S.opacity,M.rotation.value=S.rotation,S.map&&(M.map.value=S.map,t(S.map,M.mapTransform)),S.alphaMap&&(M.alphaMap.value=S.alphaMap,t(S.alphaMap,M.alphaMapTransform)),S.alphaTest>0&&(M.alphaTest.value=S.alphaTest)}function p(M,S){M.specular.value.copy(S.specular),M.shininess.value=Math.max(S.shininess,1e-4)}function m(M,S){S.gradientMap&&(M.gradientMap.value=S.gradientMap)}function y(M,S){M.metalness.value=S.metalness,S.metalnessMap&&(M.metalnessMap.value=S.metalnessMap,t(S.metalnessMap,M.metalnessMapTransform)),M.roughness.value=S.roughness,S.roughnessMap&&(M.roughnessMap.value=S.roughnessMap,t(S.roughnessMap,M.roughnessMapTransform)),S.envMap&&(M.envMapIntensity.value=S.envMapIntensity)}function x(M,S,C){M.ior.value=S.ior,S.sheen>0&&(M.sheenColor.value.copy(S.sheenColor).multiplyScalar(S.sheen),M.sheenRoughness.value=S.sheenRoughness,S.sheenColorMap&&(M.sheenColorMap.value=S.sheenColorMap,t(S.sheenColorMap,M.sheenColorMapTransform)),S.sheenRoughnessMap&&(M.sheenRoughnessMap.value=S.sheenRoughnessMap,t(S.sheenRoughnessMap,M.sheenRoughnessMapTransform))),S.clearcoat>0&&(M.clearcoat.value=S.clearcoat,M.clearcoatRoughness.value=S.clearcoatRoughness,S.clearcoatMap&&(M.clearcoatMap.value=S.clearcoatMap,t(S.clearcoatMap,M.clearcoatMapTransform)),S.clearcoatRoughnessMap&&(M.clearcoatRoughnessMap.value=S.clearcoatRoughnessMap,t(S.clearcoatRoughnessMap,M.clearcoatRoughnessMapTransform)),S.clearcoatNormalMap&&(M.clearcoatNormalMap.value=S.clearcoatNormalMap,t(S.clearcoatNormalMap,M.clearcoatNormalMapTransform),M.clearcoatNormalScale.value.copy(S.clearcoatNormalScale),S.side===we&&M.clearcoatNormalScale.value.negate())),S.dispersion>0&&(M.dispersion.value=S.dispersion),S.iridescence>0&&(M.iridescence.value=S.iridescence,M.iridescenceIOR.value=S.iridescenceIOR,M.iridescenceThicknessMinimum.value=S.iridescenceThicknessRange[0],M.iridescenceThicknessMaximum.value=S.iridescenceThicknessRange[1],S.iridescenceMap&&(M.iridescenceMap.value=S.iridescenceMap,t(S.iridescenceMap,M.iridescenceMapTransform)),S.iridescenceThicknessMap&&(M.iridescenceThicknessMap.value=S.iridescenceThicknessMap,t(S.iridescenceThicknessMap,M.iridescenceThicknessMapTransform))),S.transmission>0&&(M.transmission.value=S.transmission,M.transmissionSamplerMap.value=C.texture,M.transmissionSamplerSize.value.set(C.width,C.height),S.transmissionMap&&(M.transmissionMap.value=S.transmissionMap,t(S.transmissionMap,M.transmissionMapTransform)),M.thickness.value=S.thickness,S.thicknessMap&&(M.thicknessMap.value=S.thicknessMap,t(S.thicknessMap,M.thicknessMapTransform)),M.attenuationDistance.value=S.attenuationDistance,M.attenuationColor.value.copy(S.attenuationColor)),S.anisotropy>0&&(M.anisotropyVector.value.set(S.anisotropy*Math.cos(S.anisotropyRotation),S.anisotropy*Math.sin(S.anisotropyRotation)),S.anisotropyMap&&(M.anisotropyMap.value=S.anisotropyMap,t(S.anisotropyMap,M.anisotropyMapTransform))),M.specularIntensity.value=S.specularIntensity,M.specularColor.value.copy(S.specularColor),S.specularColorMap&&(M.specularColorMap.value=S.specularColorMap,t(S.specularColorMap,M.specularColorMapTransform)),S.specularIntensityMap&&(M.specularIntensityMap.value=S.specularIntensityMap,t(S.specularIntensityMap,M.specularIntensityMapTransform))}function v(M,S){S.matcap&&(M.matcap.value=S.matcap)}function w(M,S){const C=e.get(S).light;M.referencePosition.value.setFromMatrixPosition(C.matrixWorld),M.nearDistance.value=C.shadow.camera.near,M.farDistance.value=C.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function Zk(i,e,t,n){let r={},o={},a=[];const c=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function u(C,N){const I=N.program;n.uniformBlockBinding(C,I)}function d(C,N){let I=r[C.id];I===void 0&&(v(C),I=p(C),r[C.id]=I,C.addEventListener("dispose",M));const U=N.program;n.updateUBOMapping(C,U);const F=e.render.frame;o[C.id]!==F&&(y(C),o[C.id]=F)}function p(C){const N=m();C.__bindingPointIndex=N;const I=i.createBuffer(),U=C.__size,F=C.usage;return i.bindBuffer(i.UNIFORM_BUFFER,I),i.bufferData(i.UNIFORM_BUFFER,U,F),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,N,I),I}function m(){for(let C=0;C<c;C++)if(a.indexOf(C)===-1)return a.push(C),C;return Be("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function y(C){const N=r[C.id],I=C.uniforms,U=C.__cache;i.bindBuffer(i.UNIFORM_BUFFER,N);for(let F=0,k=I.length;F<k;F++){const G=Array.isArray(I[F])?I[F]:[I[F]];for(let B=0,z=G.length;B<z;B++){const Q=G[B];if(x(Q,F,B,U)===!0){const ye=Q.__offset,_e=Array.isArray(Q.value)?Q.value:[Q.value];let Te=0;for(let Pe=0;Pe<_e.length;Pe++){const Ne=_e[Pe],De=w(Ne);typeof Ne=="number"||typeof Ne=="boolean"?(Q.__data[0]=Ne,i.bufferSubData(i.UNIFORM_BUFFER,ye+Te,Q.__data)):Ne.isMatrix3?(Q.__data[0]=Ne.elements[0],Q.__data[1]=Ne.elements[1],Q.__data[2]=Ne.elements[2],Q.__data[3]=0,Q.__data[4]=Ne.elements[3],Q.__data[5]=Ne.elements[4],Q.__data[6]=Ne.elements[5],Q.__data[7]=0,Q.__data[8]=Ne.elements[6],Q.__data[9]=Ne.elements[7],Q.__data[10]=Ne.elements[8],Q.__data[11]=0):(Ne.toArray(Q.__data,Te),Te+=De.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,ye,Q.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function x(C,N,I,U){const F=C.value,k=N+"_"+I;if(U[k]===void 0)return typeof F=="number"||typeof F=="boolean"?U[k]=F:U[k]=F.clone(),!0;{const G=U[k];if(typeof F=="number"||typeof F=="boolean"){if(G!==F)return U[k]=F,!0}else if(G.equals(F)===!1)return G.copy(F),!0}return!1}function v(C){const N=C.uniforms;let I=0;const U=16;for(let k=0,G=N.length;k<G;k++){const B=Array.isArray(N[k])?N[k]:[N[k]];for(let z=0,Q=B.length;z<Q;z++){const ye=B[z],_e=Array.isArray(ye.value)?ye.value:[ye.value];for(let Te=0,Pe=_e.length;Te<Pe;Te++){const Ne=_e[Te],De=w(Ne),Qe=I%U,Mt=Qe%De.boundary,Tt=Qe+Mt;I+=Mt,Tt!==0&&U-Tt<De.storage&&(I+=U-Tt),ye.__data=new Float32Array(De.storage/Float32Array.BYTES_PER_ELEMENT),ye.__offset=I,I+=De.storage}}}const F=I%U;return F>0&&(I+=U-F),C.__size=I,C.__cache={},this}function w(C){const N={boundary:0,storage:0};return typeof C=="number"||typeof C=="boolean"?(N.boundary=4,N.storage=4):C.isVector2?(N.boundary=8,N.storage=8):C.isVector3||C.isColor?(N.boundary=16,N.storage=12):C.isVector4?(N.boundary=16,N.storage=16):C.isMatrix3?(N.boundary=48,N.storage=48):C.isMatrix4?(N.boundary=64,N.storage=64):C.isTexture?Ie("WebGLRenderer: Texture samplers can not be part of an uniforms group."):Ie("WebGLRenderer: Unsupported uniform value type.",C),N}function M(C){const N=C.target;N.removeEventListener("dispose",M);const I=a.indexOf(N.__bindingPointIndex);a.splice(I,1),i.deleteBuffer(r[N.id]),delete r[N.id],delete o[N.id]}function S(){for(const C in r)i.deleteBuffer(r[C]);a=[],r={},o={}}return{bind:u,update:d,dispose:S}}const Kk=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let Mc=null;function Jk(){return Mc===null&&(Mc=new co(Kk,16,16,Nr,Hi),Mc.name="DFG_LUT",Mc.minFilter=Yn,Mc.magFilter=Yn,Mc.wrapS=ki,Mc.wrapT=ki,Mc.generateMipmaps=!1,Mc.needsUpdate=!0),Mc}class Qk{constructor(e={}){const{canvas:t=Bg(),context:n=null,depth:r=!0,stencil:o=!1,alpha:a=!1,antialias:c=!1,premultipliedAlpha:u=!0,preserveDrawingBuffer:d=!1,powerPreference:p="default",failIfMajorPerformanceCaveat:m=!1,reversedDepthBuffer:y=!1,outputBufferType:x=Di}=e;this.isWebGLRenderer=!0;let v;if(n!==null){if(typeof WebGLRenderingContext!="undefined"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");v=n.getContextAttributes().alpha}else v=a;const w=x,M=new Set([vh,xh,Bl]),S=new Set([Di,yi,jo,wo,Ip,Lp]),C=new Uint32Array(4),N=new Int32Array(4);let I=null,U=null;const F=[],k=[];let G=null;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=yr,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const B=this;let z=!1;this._outputColorSpace=Pr;let Q=0,ye=0,_e=null,Te=-1,Pe=null;const Ne=new gn,De=new gn;let Qe=null;const Mt=new It(0);let Tt=0,Fe=t.width,mt=t.height,wt=1,In=null,st=null;const Ee=new gn(0,0,Fe,mt),Oe=new gn(0,0,Fe,mt);let vt=!1;const Zt=new Xs;let Pt=!1,wn=!1;const ai=new Qt,Wn=new H,rt=new gn,yt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ct=!1;function Ft(){return _e===null?wt:1}let ne=n;function Ln(X,Ce){return t.getContext(X,Ce)}try{const X={alpha:!0,depth:r,stencil:o,antialias:c,premultipliedAlpha:u,preserveDrawingBuffer:d,powerPreference:p,failIfMajorPerformanceCaveat:m};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${xe}`),t.addEventListener("webglcontextlost",ti,!1),t.addEventListener("webglcontextrestored",rs,!1),t.addEventListener("webglcontextcreationerror",Gi,!1),ne===null){const Ce="webgl2";if(ne=Ln(Ce,X),ne===null)throw Ln(Ce)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(X){throw Be("WebGLRenderer: "+X.message),X}let en,Hn,Bt,ee,V,Se,je,dt,Ze,yn,Ot,fn,jn,bt,Wt,pn,vn,Vt,li,be,Kt,Lt,nn,At;function ft(){en=new JO(ne),en.init(),Lt=new Wk(ne,en),Hn=new WO(ne,en,e,Lt),Bt=new Vk(ne,en),Hn.reversedDepthBuffer&&y&&Bt.buffers.depth.setReversed(!0),ee=new tU(ne),V=new Ak,Se=new Gk(ne,en,Bt,V,Hn,Lt,ee),je=new $O(B),dt=new KO(B),Ze=new kF(ne),nn=new VO(ne,Ze),yn=new QO(ne,Ze,ee,nn),Ot=new iU(ne,yn,Ze,ee),li=new nU(ne,Hn,Se),pn=new HO(V),fn=new wk(B,je,dt,en,Hn,nn,pn),jn=new Yk(B,V),bt=new Ck,Wt=new Dk(en),Vt=new zO(B,je,dt,Bt,Ot,v,u),vn=new kk(B,Ot,Hn),At=new Zk(ne,ee,Hn,Bt),be=new GO(ne,en,ee),Kt=new eU(ne,en,ee),ee.programs=fn.programs,B.capabilities=Hn,B.extensions=en,B.properties=V,B.renderLists=bt,B.shadowMap=vn,B.state=Bt,B.info=ee}ft(),w!==Di&&(G=new rU(w,t.width,t.height,r,o));const kt=new Xk(B,ne);this.xr=kt,this.getContext=function(){return ne},this.getContextAttributes=function(){return ne.getContextAttributes()},this.forceContextLoss=function(){const X=en.get("WEBGL_lose_context");X&&X.loseContext()},this.forceContextRestore=function(){const X=en.get("WEBGL_lose_context");X&&X.restoreContext()},this.getPixelRatio=function(){return wt},this.setPixelRatio=function(X){X!==void 0&&(wt=X,this.setSize(Fe,mt,!1))},this.getSize=function(X){return X.set(Fe,mt)},this.setSize=function(X,Ce,He=!0){if(kt.isPresenting){Ie("WebGLRenderer: Can't change size while VR device is presenting.");return}Fe=X,mt=Ce,t.width=Math.floor(X*wt),t.height=Math.floor(Ce*wt),He===!0&&(t.style.width=X+"px",t.style.height=Ce+"px"),G!==null&&G.setSize(t.width,t.height),this.setViewport(0,0,X,Ce)},this.getDrawingBufferSize=function(X){return X.set(Fe*wt,mt*wt).floor()},this.setDrawingBufferSize=function(X,Ce,He){Fe=X,mt=Ce,wt=He,t.width=Math.floor(X*He),t.height=Math.floor(Ce*He),this.setViewport(0,0,X,Ce)},this.setEffects=function(X){if(w===Di){console.error("THREE.WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(X){for(let Ce=0;Ce<X.length;Ce++)if(X[Ce].isOutputPass===!0){console.warn("THREE.WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}G.setEffects(X||[])},this.getCurrentViewport=function(X){return X.copy(Ne)},this.getViewport=function(X){return X.copy(Ee)},this.setViewport=function(X,Ce,He,Ge){X.isVector4?Ee.set(X.x,X.y,X.z,X.w):Ee.set(X,Ce,He,Ge),Bt.viewport(Ne.copy(Ee).multiplyScalar(wt).round())},this.getScissor=function(X){return X.copy(Oe)},this.setScissor=function(X,Ce,He,Ge){X.isVector4?Oe.set(X.x,X.y,X.z,X.w):Oe.set(X,Ce,He,Ge),Bt.scissor(De.copy(Oe).multiplyScalar(wt).round())},this.getScissorTest=function(){return vt},this.setScissorTest=function(X){Bt.setScissorTest(vt=X)},this.setOpaqueSort=function(X){In=X},this.setTransparentSort=function(X){st=X},this.getClearColor=function(X){return X.copy(Vt.getClearColor())},this.setClearColor=function(){Vt.setClearColor(...arguments)},this.getClearAlpha=function(){return Vt.getClearAlpha()},this.setClearAlpha=function(){Vt.setClearAlpha(...arguments)},this.clear=function(X=!0,Ce=!0,He=!0){let Ge=0;if(X){let Le=!1;if(_e!==null){const Ht=_e.texture.format;Le=M.has(Ht)}if(Le){const Ht=_e.texture.type,ln=S.has(Ht),Yt=Vt.getClearColor(),dn=Vt.getClearAlpha(),An=Yt.r,Kn=Yt.g,Un=Yt.b;ln?(C[0]=An,C[1]=Kn,C[2]=Un,C[3]=dn,ne.clearBufferuiv(ne.COLOR,0,C)):(N[0]=An,N[1]=Kn,N[2]=Un,N[3]=dn,ne.clearBufferiv(ne.COLOR,0,N))}else Ge|=ne.COLOR_BUFFER_BIT}Ce&&(Ge|=ne.DEPTH_BUFFER_BIT),He&&(Ge|=ne.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),ne.clear(Ge)},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",ti,!1),t.removeEventListener("webglcontextrestored",rs,!1),t.removeEventListener("webglcontextcreationerror",Gi,!1),Vt.dispose(),bt.dispose(),Wt.dispose(),V.dispose(),je.dispose(),dt.dispose(),Ot.dispose(),nn.dispose(),At.dispose(),fn.dispose(),kt.dispose(),kt.removeEventListener("sessionstart",ML),kt.removeEventListener("sessionend",TL),Ap.stop()};function ti(X){X.preventDefault(),Ko("WebGLRenderer: Context Lost."),z=!0}function rs(){Ko("WebGLRenderer: Context Restored."),z=!1;const X=ee.autoReset,Ce=vn.enabled,He=vn.autoUpdate,Ge=vn.needsUpdate,Le=vn.type;ft(),ee.autoReset=X,vn.enabled=Ce,vn.autoUpdate=He,vn.needsUpdate=Ge,vn.type=Le}function Gi(X){Be("WebGLRenderer: A WebGL context could not be created. Reason: ",X.statusMessage)}function Hc(X){const Ce=X.target;Ce.removeEventListener("dispose",Hc),yh(Ce)}function yh(X){XY(X),V.remove(X)}function XY(X){const Ce=V.get(X).programs;Ce!==void 0&&(Ce.forEach(function(He){fn.releaseProgram(He)}),X.isShaderMaterial&&fn.releaseShaderCache(X))}this.renderBufferDirect=function(X,Ce,He,Ge,Le,Ht){Ce===null&&(Ce=yt);const ln=Le.isMesh&&Le.matrixWorld.determinant()<0,Yt=YY(X,Ce,He,Ge,Le);Bt.setMaterial(Ge,ln);let dn=He.index,An=1;if(Ge.wireframe===!0){if(dn=yn.getWireframeAttribute(He),dn===void 0)return;An=2}const Kn=He.drawRange,Un=He.attributes.position;let di=Kn.start*An,ji=(Kn.start+Kn.count)*An;Ht!==null&&(di=Math.max(di,Ht.start*An),ji=Math.min(ji,(Ht.start+Ht.count)*An)),dn!==null?(di=Math.max(di,0),ji=Math.min(ji,dn.count)):Un!=null&&(di=Math.max(di,0),ji=Math.min(ji,Un.count));const ks=ji-di;if(ks<0||ks===1/0)return;nn.setup(Le,Ge,Yt,He,dn);let zs,es=be;if(dn!==null&&(zs=Ze.get(dn),es=Kt,es.setIndex(zs)),Le.isMesh)Ge.wireframe===!0?(Bt.setLineWidth(Ge.wireframeLinewidth*Ft()),es.setMode(ne.LINES)):es.setMode(ne.TRIANGLES);else if(Le.isLine){let kn=Ge.linewidth;kn===void 0&&(kn=1),Bt.setLineWidth(kn*Ft()),Le.isLineSegments?es.setMode(ne.LINES):Le.isLineLoop?es.setMode(ne.LINE_LOOP):es.setMode(ne.LINE_STRIP)}else Le.isPoints?es.setMode(ne.POINTS):Le.isSprite&&es.setMode(ne.TRIANGLES);if(Le.isBatchedMesh)if(Le._multiDrawInstances!==null)Ut("WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),es.renderMultiDrawInstances(Le._multiDrawStarts,Le._multiDrawCounts,Le._multiDrawCount,Le._multiDrawInstances);else if(en.get("WEBGL_multi_draw"))es.renderMultiDraw(Le._multiDrawStarts,Le._multiDrawCounts,Le._multiDrawCount);else{const kn=Le._multiDrawStarts,Wi=Le._multiDrawCounts,Ei=Le._multiDrawCount,Ta=dn?Ze.get(dn).bytesPerElement:1,Eg=V.get(Ge).currentProgram.getUniforms();for(let wa=0;wa<Ei;wa++)Eg.setValue(ne,"_gl_DrawID",wa),es.render(kn[wa]/Ta,Wi[wa])}else if(Le.isInstancedMesh)es.renderInstances(di,ks,Le.count);else if(He.isInstancedBufferGeometry){const kn=He._maxInstanceCount!==void 0?He._maxInstanceCount:1/0,Wi=Math.min(He.instanceCount,kn);es.renderInstances(di,ks,Wi)}else es.render(di,ks)};function SL(X,Ce,He){X.transparent===!0&&X.side===Ae&&X.forceSinglePass===!1?(X.side=we,X.needsUpdate=!0,Wb(X,Ce,He),X.side=Me,X.needsUpdate=!0,Wb(X,Ce,He),X.side=Ae):Wb(X,Ce,He)}this.compile=function(X,Ce,He=null){He===null&&(He=X),U=Wt.get(He),U.init(Ce),k.push(U),He.traverseVisible(function(Le){Le.isLight&&Le.layers.test(Ce.layers)&&(U.pushLight(Le),Le.castShadow&&U.pushShadow(Le))}),X!==He&&X.traverseVisible(function(Le){Le.isLight&&Le.layers.test(Ce.layers)&&(U.pushLight(Le),Le.castShadow&&U.pushShadow(Le))}),U.setupLights();const Ge=new Set;return X.traverse(function(Le){if(!(Le.isMesh||Le.isPoints||Le.isLine||Le.isSprite))return;const Ht=Le.material;if(Ht)if(Array.isArray(Ht))for(let ln=0;ln<Ht.length;ln++){const Yt=Ht[ln];SL(Yt,He,Le),Ge.add(Yt)}else SL(Ht,He,Le),Ge.add(Ht)}),U=k.pop(),Ge},this.compileAsync=function(X,Ce,He=null){const Ge=this.compile(X,Ce,He);return new Promise(Le=>{function Ht(){if(Ge.forEach(function(ln){V.get(ln).currentProgram.isReady()&&Ge.delete(ln)}),Ge.size===0){Le(X);return}setTimeout(Ht,10)}en.get("KHR_parallel_shader_compile")!==null?Ht():setTimeout(Ht,10)})};let Q1=null;function jY(X){Q1&&Q1(X)}function ML(){Ap.stop()}function TL(){Ap.start()}const Ap=new TE;Ap.setAnimationLoop(jY),typeof self!="undefined"&&Ap.setContext(self),this.setAnimationLoop=function(X){Q1=X,kt.setAnimationLoop(X),X===null?Ap.stop():Ap.start()},kt.addEventListener("sessionstart",ML),kt.addEventListener("sessionend",TL),this.render=function(X,Ce){if(Ce!==void 0&&Ce.isCamera!==!0){Be("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(z===!0)return;const He=kt.enabled===!0&&kt.isPresenting===!0,Ge=G!==null&&(_e===null||He)&&G.begin(B,_e);if(X.matrixWorldAutoUpdate===!0&&X.updateMatrixWorld(),Ce.parent===null&&Ce.matrixWorldAutoUpdate===!0&&Ce.updateMatrixWorld(),kt.enabled===!0&&kt.isPresenting===!0&&(G===null||G.isCompositing()===!1)&&(kt.cameraAutoUpdate===!0&&kt.updateCamera(Ce),Ce=kt.getCamera()),X.isScene===!0&&X.onBeforeRender(B,X,Ce,_e),U=Wt.get(X,k.length),U.init(Ce),k.push(U),ai.multiplyMatrices(Ce.projectionMatrix,Ce.matrixWorldInverse),Zt.setFromProjectionMatrix(ai,ws,Ce.reversedDepth),wn=this.localClippingEnabled,Pt=pn.init(this.clippingPlanes,wn),I=bt.get(X,F.length),I.init(),F.push(I),kt.enabled===!0&&kt.isPresenting===!0){const ln=B.xr.getDepthSensingMesh();ln!==null&&eA(ln,Ce,-1/0,B.sortObjects)}eA(X,Ce,0,B.sortObjects),I.finish(),B.sortObjects===!0&&I.sort(In,st),ct=kt.enabled===!1||kt.isPresenting===!1||kt.hasDepthSensing()===!1,ct&&Vt.addToRenderList(I,X),this.info.render.frame++,Pt===!0&&pn.beginShadows();const Le=U.state.shadowsArray;if(vn.render(Le,X,Ce),Pt===!0&&pn.endShadows(),this.info.autoReset===!0&&this.info.reset(),(Ge&&G.hasRenderPass())===!1){const ln=I.opaque,Yt=I.transmissive;if(U.setupLights(),Ce.isArrayCamera){const dn=Ce.cameras;if(Yt.length>0)for(let An=0,Kn=dn.length;An<Kn;An++){const Un=dn[An];AL(ln,Yt,X,Un)}ct&&Vt.render(X);for(let An=0,Kn=dn.length;An<Kn;An++){const Un=dn[An];wL(I,X,Un,Un.viewport)}}else Yt.length>0&&AL(ln,Yt,X,Ce),ct&&Vt.render(X),wL(I,X,Ce)}_e!==null&&ye===0&&(Se.updateMultisampleRenderTarget(_e),Se.updateRenderTargetMipmap(_e)),Ge&&G.end(B),X.isScene===!0&&X.onAfterRender(B,X,Ce),nn.resetDefaultState(),Te=-1,Pe=null,k.pop(),k.length>0?(U=k[k.length-1],Pt===!0&&pn.setGlobalState(B.clippingPlanes,U.state.camera)):U=null,F.pop(),F.length>0?I=F[F.length-1]:I=null};function eA(X,Ce,He,Ge){if(X.visible===!1)return;if(X.layers.test(Ce.layers)){if(X.isGroup)He=X.renderOrder;else if(X.isLOD)X.autoUpdate===!0&&X.update(Ce);else if(X.isLight)U.pushLight(X),X.castShadow&&U.pushShadow(X);else if(X.isSprite){if(!X.frustumCulled||Zt.intersectsSprite(X)){Ge&&rt.setFromMatrixPosition(X.matrixWorld).applyMatrix4(ai);const ln=Ot.update(X),Yt=X.material;Yt.visible&&I.push(X,ln,Yt,He,rt.z,null)}}else if((X.isMesh||X.isLine||X.isPoints)&&(!X.frustumCulled||Zt.intersectsObject(X))){const ln=Ot.update(X),Yt=X.material;if(Ge&&(X.boundingSphere!==void 0?(X.boundingSphere===null&&X.computeBoundingSphere(),rt.copy(X.boundingSphere.center)):(ln.boundingSphere===null&&ln.computeBoundingSphere(),rt.copy(ln.boundingSphere.center)),rt.applyMatrix4(X.matrixWorld).applyMatrix4(ai)),Array.isArray(Yt)){const dn=ln.groups;for(let An=0,Kn=dn.length;An<Kn;An++){const Un=dn[An],di=Yt[Un.materialIndex];di&&di.visible&&I.push(X,ln,di,He,rt.z,Un)}}else Yt.visible&&I.push(X,ln,Yt,He,rt.z,null)}}const Ht=X.children;for(let ln=0,Yt=Ht.length;ln<Yt;ln++)eA(Ht[ln],Ce,He,Ge)}function wL(X,Ce,He,Ge){const{opaque:Le,transmissive:Ht,transparent:ln}=X;U.setupLightsView(He),Pt===!0&&pn.setGlobalState(B.clippingPlanes,He),Ge&&Bt.viewport(Ne.copy(Ge)),Le.length>0&&Gb(Le,Ce,He),Ht.length>0&&Gb(Ht,Ce,He),ln.length>0&&Gb(ln,Ce,He),Bt.buffers.depth.setTest(!0),Bt.buffers.depth.setMask(!0),Bt.buffers.color.setMask(!0),Bt.setPolygonOffset(!1)}function AL(X,Ce,He,Ge){if((He.isScene===!0?He.overrideMaterial:null)!==null)return;if(U.state.transmissionRenderTarget[Ge.id]===void 0){const di=en.has("EXT_color_buffer_half_float")||en.has("EXT_color_buffer_float");U.state.transmissionRenderTarget[Ge.id]=new qr(1,1,{generateMipmaps:!0,type:di?Hi:Di,minFilter:Vs,samples:Hn.samples,stencilBuffer:o,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:xn.workingColorSpace})}const Ht=U.state.transmissionRenderTarget[Ge.id],ln=Ge.viewport||Ne;Ht.setSize(ln.z*B.transmissionResolutionScale,ln.w*B.transmissionResolutionScale);const Yt=B.getRenderTarget(),dn=B.getActiveCubeFace(),An=B.getActiveMipmapLevel();B.setRenderTarget(Ht),B.getClearColor(Mt),Tt=B.getClearAlpha(),Tt<1&&B.setClearColor(16777215,.5),B.clear(),ct&&Vt.render(He);const Kn=B.toneMapping;B.toneMapping=yr;const Un=Ge.viewport;if(Ge.viewport!==void 0&&(Ge.viewport=void 0),U.setupLightsView(Ge),Pt===!0&&pn.setGlobalState(B.clippingPlanes,Ge),Gb(X,He,Ge),Se.updateMultisampleRenderTarget(Ht),Se.updateRenderTargetMipmap(Ht),en.has("WEBGL_multisampled_render_to_texture")===!1){let di=!1;for(let ji=0,ks=Ce.length;ji<ks;ji++){const zs=Ce[ji],{object:es,geometry:kn,material:Wi,group:Ei}=zs;if(Wi.side===Ae&&es.layers.test(Ge.layers)){const Ta=Wi.side;Wi.side=we,Wi.needsUpdate=!0,EL(es,He,Ge,kn,Wi,Ei),Wi.side=Ta,Wi.needsUpdate=!0,di=!0}}di===!0&&(Se.updateMultisampleRenderTarget(Ht),Se.updateRenderTargetMipmap(Ht))}B.setRenderTarget(Yt,dn,An),B.setClearColor(Mt,Tt),Un!==void 0&&(Ge.viewport=Un),B.toneMapping=Kn}function Gb(X,Ce,He){const Ge=Ce.isScene===!0?Ce.overrideMaterial:null;for(let Le=0,Ht=X.length;Le<Ht;Le++){const ln=X[Le],{object:Yt,geometry:dn,group:An}=ln;let Kn=ln.material;Kn.allowOverride===!0&&Ge!==null&&(Kn=Ge),Yt.layers.test(He.layers)&&EL(Yt,Ce,He,dn,Kn,An)}}function EL(X,Ce,He,Ge,Le,Ht){X.onBeforeRender(B,Ce,He,Ge,Le,Ht),X.modelViewMatrix.multiplyMatrices(He.matrixWorldInverse,X.matrixWorld),X.normalMatrix.getNormalMatrix(X.modelViewMatrix),Le.onBeforeRender(B,Ce,He,Ge,X,Ht),Le.transparent===!0&&Le.side===Ae&&Le.forceSinglePass===!1?(Le.side=we,Le.needsUpdate=!0,B.renderBufferDirect(He,Ce,Ge,Le,X,Ht),Le.side=Me,Le.needsUpdate=!0,B.renderBufferDirect(He,Ce,Ge,Le,X,Ht),Le.side=Ae):B.renderBufferDirect(He,Ce,Ge,Le,X,Ht),X.onAfterRender(B,Ce,He,Ge,Le,Ht)}function Wb(X,Ce,He){Ce.isScene!==!0&&(Ce=yt);const Ge=V.get(X),Le=U.state.lights,Ht=U.state.shadowsArray,ln=Le.state.version,Yt=fn.getParameters(X,Le.state,Ht,Ce,He),dn=fn.getProgramCacheKey(Yt);let An=Ge.programs;Ge.environment=X.isMeshStandardMaterial?Ce.environment:null,Ge.fog=Ce.fog,Ge.envMap=(X.isMeshStandardMaterial?dt:je).get(X.envMap||Ge.environment),Ge.envMapRotation=Ge.environment!==null&&X.envMap===null?Ce.environmentRotation:X.envMapRotation,An===void 0&&(X.addEventListener("dispose",Hc),An=new Map,Ge.programs=An);let Kn=An.get(dn);if(Kn!==void 0){if(Ge.currentProgram===Kn&&Ge.lightsStateVersion===ln)return RL(X,Yt),Kn}else Yt.uniforms=fn.getUniforms(X),X.onBeforeCompile(Yt,B),Kn=fn.acquireProgram(Yt,dn),An.set(dn,Kn),Ge.uniforms=Yt.uniforms;const Un=Ge.uniforms;return(!X.isShaderMaterial&&!X.isRawShaderMaterial||X.clipping===!0)&&(Un.clippingPlanes=pn.uniform),RL(X,Yt),Ge.needsLights=KY(X),Ge.lightsStateVersion=ln,Ge.needsLights&&(Un.ambientLightColor.value=Le.state.ambient,Un.lightProbe.value=Le.state.probe,Un.directionalLights.value=Le.state.directional,Un.directionalLightShadows.value=Le.state.directionalShadow,Un.spotLights.value=Le.state.spot,Un.spotLightShadows.value=Le.state.spotShadow,Un.rectAreaLights.value=Le.state.rectArea,Un.ltc_1.value=Le.state.rectAreaLTC1,Un.ltc_2.value=Le.state.rectAreaLTC2,Un.pointLights.value=Le.state.point,Un.pointLightShadows.value=Le.state.pointShadow,Un.hemisphereLights.value=Le.state.hemi,Un.directionalShadowMap.value=Le.state.directionalShadowMap,Un.directionalShadowMatrix.value=Le.state.directionalShadowMatrix,Un.spotShadowMap.value=Le.state.spotShadowMap,Un.spotLightMatrix.value=Le.state.spotLightMatrix,Un.spotLightMap.value=Le.state.spotLightMap,Un.pointShadowMap.value=Le.state.pointShadowMap,Un.pointShadowMatrix.value=Le.state.pointShadowMatrix),Ge.currentProgram=Kn,Ge.uniformsList=null,Kn}function CL(X){if(X.uniformsList===null){const Ce=X.currentProgram.getUniforms();X.uniformsList=Jx.seqWithValue(Ce.seq,X.uniforms)}return X.uniformsList}function RL(X,Ce){const He=V.get(X);He.outputColorSpace=Ce.outputColorSpace,He.batching=Ce.batching,He.batchingColor=Ce.batchingColor,He.instancing=Ce.instancing,He.instancingColor=Ce.instancingColor,He.instancingMorph=Ce.instancingMorph,He.skinning=Ce.skinning,He.morphTargets=Ce.morphTargets,He.morphNormals=Ce.morphNormals,He.morphColors=Ce.morphColors,He.morphTargetsCount=Ce.morphTargetsCount,He.numClippingPlanes=Ce.numClippingPlanes,He.numIntersection=Ce.numClipIntersection,He.vertexAlphas=Ce.vertexAlphas,He.vertexTangents=Ce.vertexTangents,He.toneMapping=Ce.toneMapping}function YY(X,Ce,He,Ge,Le){Ce.isScene!==!0&&(Ce=yt),Se.resetTextureUnits();const Ht=Ce.fog,ln=Ge.isMeshStandardMaterial?Ce.environment:null,Yt=_e===null?B.outputColorSpace:_e.isXRRenderTarget===!0?_e.texture.colorSpace:io,dn=(Ge.isMeshStandardMaterial?dt:je).get(Ge.envMap||ln),An=Ge.vertexColors===!0&&!!He.attributes.color&&He.attributes.color.itemSize===4,Kn=!!He.attributes.tangent&&(!!Ge.normalMap||Ge.anisotropy>0),Un=!!He.morphAttributes.position,di=!!He.morphAttributes.normal,ji=!!He.morphAttributes.color;let ks=yr;Ge.toneMapped&&(_e===null||_e.isXRRenderTarget===!0)&&(ks=B.toneMapping);const zs=He.morphAttributes.position||He.morphAttributes.normal||He.morphAttributes.color,es=zs!==void 0?zs.length:0,kn=V.get(Ge),Wi=U.state.lights;if(Pt===!0&&(wn===!0||X!==Pe)){const So=X===Pe&&Ge.id===Te;pn.setState(Ge,X,So)}let Ei=!1;Ge.version===kn.__version?(kn.needsLights&&kn.lightsStateVersion!==Wi.state.version||kn.outputColorSpace!==Yt||Le.isBatchedMesh&&kn.batching===!1||!Le.isBatchedMesh&&kn.batching===!0||Le.isBatchedMesh&&kn.batchingColor===!0&&Le.colorTexture===null||Le.isBatchedMesh&&kn.batchingColor===!1&&Le.colorTexture!==null||Le.isInstancedMesh&&kn.instancing===!1||!Le.isInstancedMesh&&kn.instancing===!0||Le.isSkinnedMesh&&kn.skinning===!1||!Le.isSkinnedMesh&&kn.skinning===!0||Le.isInstancedMesh&&kn.instancingColor===!0&&Le.instanceColor===null||Le.isInstancedMesh&&kn.instancingColor===!1&&Le.instanceColor!==null||Le.isInstancedMesh&&kn.instancingMorph===!0&&Le.morphTexture===null||Le.isInstancedMesh&&kn.instancingMorph===!1&&Le.morphTexture!==null||kn.envMap!==dn||Ge.fog===!0&&kn.fog!==Ht||kn.numClippingPlanes!==void 0&&(kn.numClippingPlanes!==pn.numPlanes||kn.numIntersection!==pn.numIntersection)||kn.vertexAlphas!==An||kn.vertexTangents!==Kn||kn.morphTargets!==Un||kn.morphNormals!==di||kn.morphColors!==ji||kn.toneMapping!==ks||kn.morphTargetsCount!==es)&&(Ei=!0):(Ei=!0,kn.__version=Ge.version);let Ta=kn.currentProgram;Ei===!0&&(Ta=Wb(Ge,Ce,Le));let Eg=!1,wa=!1,r_=!1;const os=Ta.getUniforms(),$o=kn.uniforms;if(Bt.useProgram(Ta.program)&&(Eg=!0,wa=!0,r_=!0),Ge.id!==Te&&(Te=Ge.id,wa=!0),Eg||Pe!==X){Bt.buffers.depth.getReversed()&&X.reversedDepth!==!0&&(X._reversedDepth=!0,X.updateProjectionMatrix()),os.setValue(ne,"projectionMatrix",X.projectionMatrix),os.setValue(ne,"viewMatrix",X.matrixWorldInverse);const qo=os.map.cameraPosition;qo!==void 0&&qo.setValue(ne,Wn.setFromMatrixPosition(X.matrixWorld)),Hn.logarithmicDepthBuffer&&os.setValue(ne,"logDepthBufFC",2/(Math.log(X.far+1)/Math.LN2)),(Ge.isMeshPhongMaterial||Ge.isMeshToonMaterial||Ge.isMeshLambertMaterial||Ge.isMeshBasicMaterial||Ge.isMeshStandardMaterial||Ge.isShaderMaterial)&&os.setValue(ne,"isOrthographic",X.isOrthographicCamera===!0),Pe!==X&&(Pe=X,wa=!0,r_=!0)}if(kn.needsLights&&(Wi.state.directionalShadowMap.length>0&&os.setValue(ne,"directionalShadowMap",Wi.state.directionalShadowMap,Se),Wi.state.spotShadowMap.length>0&&os.setValue(ne,"spotShadowMap",Wi.state.spotShadowMap,Se),Wi.state.pointShadowMap.length>0&&os.setValue(ne,"pointShadowMap",Wi.state.pointShadowMap,Se)),Le.isSkinnedMesh){os.setOptional(ne,Le,"bindMatrix"),os.setOptional(ne,Le,"bindMatrixInverse");const So=Le.skeleton;So&&(So.boneTexture===null&&So.computeBoneTexture(),os.setValue(ne,"boneTexture",So.boneTexture,Se))}Le.isBatchedMesh&&(os.setOptional(ne,Le,"batchingTexture"),os.setValue(ne,"batchingTexture",Le._matricesTexture,Se),os.setOptional(ne,Le,"batchingIdTexture"),os.setValue(ne,"batchingIdTexture",Le._indirectTexture,Se),os.setOptional(ne,Le,"batchingColorTexture"),Le._colorsTexture!==null&&os.setValue(ne,"batchingColorTexture",Le._colorsTexture,Se));const tl=He.morphAttributes;if((tl.position!==void 0||tl.normal!==void 0||tl.color!==void 0)&&li.update(Le,He,Ta),(wa||kn.receiveShadow!==Le.receiveShadow)&&(kn.receiveShadow=Le.receiveShadow,os.setValue(ne,"receiveShadow",Le.receiveShadow)),Ge.isMeshGouraudMaterial&&Ge.envMap!==null&&($o.envMap.value=dn,$o.flipEnvMap.value=dn.isCubeTexture&&dn.isRenderTargetTexture===!1?-1:1),Ge.isMeshStandardMaterial&&Ge.envMap===null&&Ce.environment!==null&&($o.envMapIntensity.value=Ce.environmentIntensity),$o.dfgLUT!==void 0&&($o.dfgLUT.value=Jk()),wa&&(os.setValue(ne,"toneMappingExposure",B.toneMappingExposure),kn.needsLights&&ZY($o,r_),Ht&&Ge.fog===!0&&jn.refreshFogUniforms($o,Ht),jn.refreshMaterialUniforms($o,Ge,wt,mt,U.state.transmissionRenderTarget[X.id]),Jx.upload(ne,CL(kn),$o,Se)),Ge.isShaderMaterial&&Ge.uniformsNeedUpdate===!0&&(Jx.upload(ne,CL(kn),$o,Se),Ge.uniformsNeedUpdate=!1),Ge.isSpriteMaterial&&os.setValue(ne,"center",Le.center),os.setValue(ne,"modelViewMatrix",Le.modelViewMatrix),os.setValue(ne,"normalMatrix",Le.normalMatrix),os.setValue(ne,"modelMatrix",Le.matrixWorld),Ge.isShaderMaterial||Ge.isRawShaderMaterial){const So=Ge.uniformsGroups;for(let qo=0,tA=So.length;qo<tA;qo++){const Ep=So[qo];At.update(Ep,Ta),At.bind(Ep,Ta)}}return Ta}function ZY(X,Ce){X.ambientLightColor.needsUpdate=Ce,X.lightProbe.needsUpdate=Ce,X.directionalLights.needsUpdate=Ce,X.directionalLightShadows.needsUpdate=Ce,X.pointLights.needsUpdate=Ce,X.pointLightShadows.needsUpdate=Ce,X.spotLights.needsUpdate=Ce,X.spotLightShadows.needsUpdate=Ce,X.rectAreaLights.needsUpdate=Ce,X.hemisphereLights.needsUpdate=Ce}function KY(X){return X.isMeshLambertMaterial||X.isMeshToonMaterial||X.isMeshPhongMaterial||X.isMeshStandardMaterial||X.isShadowMaterial||X.isShaderMaterial&&X.lights===!0}this.getActiveCubeFace=function(){return Q},this.getActiveMipmapLevel=function(){return ye},this.getRenderTarget=function(){return _e},this.setRenderTargetTextures=function(X,Ce,He){const Ge=V.get(X);Ge.__autoAllocateDepthBuffer=X.resolveDepthBuffer===!1,Ge.__autoAllocateDepthBuffer===!1&&(Ge.__useRenderToTexture=!1),V.get(X.texture).__webglTexture=Ce,V.get(X.depthTexture).__webglTexture=Ge.__autoAllocateDepthBuffer?void 0:He,Ge.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(X,Ce){const He=V.get(X);He.__webglFramebuffer=Ce,He.__useDefaultFramebuffer=Ce===void 0};const JY=ne.createFramebuffer();this.setRenderTarget=function(X,Ce=0,He=0){_e=X,Q=Ce,ye=He;let Ge=null,Le=!1,Ht=!1;if(X){const Yt=V.get(X);if(Yt.__useDefaultFramebuffer!==void 0){Bt.bindFramebuffer(ne.FRAMEBUFFER,Yt.__webglFramebuffer),Ne.copy(X.viewport),De.copy(X.scissor),Qe=X.scissorTest,Bt.viewport(Ne),Bt.scissor(De),Bt.setScissorTest(Qe),Te=-1;return}else if(Yt.__webglFramebuffer===void 0)Se.setupRenderTarget(X);else if(Yt.__hasExternalTextures)Se.rebindTextures(X,V.get(X.texture).__webglTexture,V.get(X.depthTexture).__webglTexture);else if(X.depthBuffer){const Kn=X.depthTexture;if(Yt.__boundDepthTexture!==Kn){if(Kn!==null&&V.has(Kn)&&(X.width!==Kn.image.width||X.height!==Kn.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Se.setupDepthRenderbuffer(X)}}const dn=X.texture;(dn.isData3DTexture||dn.isDataArrayTexture||dn.isCompressedArrayTexture)&&(Ht=!0);const An=V.get(X).__webglFramebuffer;X.isWebGLCubeRenderTarget?(Array.isArray(An[Ce])?Ge=An[Ce][He]:Ge=An[Ce],Le=!0):X.samples>0&&Se.useMultisampledRTT(X)===!1?Ge=V.get(X).__webglMultisampledFramebuffer:Array.isArray(An)?Ge=An[He]:Ge=An,Ne.copy(X.viewport),De.copy(X.scissor),Qe=X.scissorTest}else Ne.copy(Ee).multiplyScalar(wt).floor(),De.copy(Oe).multiplyScalar(wt).floor(),Qe=vt;if(He!==0&&(Ge=JY),Bt.bindFramebuffer(ne.FRAMEBUFFER,Ge)&&Bt.drawBuffers(X,Ge),Bt.viewport(Ne),Bt.scissor(De),Bt.setScissorTest(Qe),Le){const Yt=V.get(X.texture);ne.framebufferTexture2D(ne.FRAMEBUFFER,ne.COLOR_ATTACHMENT0,ne.TEXTURE_CUBE_MAP_POSITIVE_X+Ce,Yt.__webglTexture,He)}else if(Ht){const Yt=Ce;for(let dn=0;dn<X.textures.length;dn++){const An=V.get(X.textures[dn]);ne.framebufferTextureLayer(ne.FRAMEBUFFER,ne.COLOR_ATTACHMENT0+dn,An.__webglTexture,He,Yt)}}else if(X!==null&&He!==0){const Yt=V.get(X.texture);ne.framebufferTexture2D(ne.FRAMEBUFFER,ne.COLOR_ATTACHMENT0,ne.TEXTURE_2D,Yt.__webglTexture,He)}Te=-1},this.readRenderTargetPixels=function(X,Ce,He,Ge,Le,Ht,ln,Yt=0){if(!(X&&X.isWebGLRenderTarget)){Be("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let dn=V.get(X).__webglFramebuffer;if(X.isWebGLCubeRenderTarget&&ln!==void 0&&(dn=dn[ln]),dn){Bt.bindFramebuffer(ne.FRAMEBUFFER,dn);try{const An=X.textures[Yt],Kn=An.format,Un=An.type;if(!Hn.textureFormatReadable(Kn)){Be("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!Hn.textureTypeReadable(Un)){Be("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}Ce>=0&&Ce<=X.width-Ge&&He>=0&&He<=X.height-Le&&(X.textures.length>1&&ne.readBuffer(ne.COLOR_ATTACHMENT0+Yt),ne.readPixels(Ce,He,Ge,Le,Lt.convert(Kn),Lt.convert(Un),Ht))}finally{const An=_e!==null?V.get(_e).__webglFramebuffer:null;Bt.bindFramebuffer(ne.FRAMEBUFFER,An)}}},this.readRenderTargetPixelsAsync=function(X,Ce,He,Ge,Le,Ht,ln,Yt=0){return mn(this,null,function*(){if(!(X&&X.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let dn=V.get(X).__webglFramebuffer;if(X.isWebGLCubeRenderTarget&&ln!==void 0&&(dn=dn[ln]),dn)if(Ce>=0&&Ce<=X.width-Ge&&He>=0&&He<=X.height-Le){Bt.bindFramebuffer(ne.FRAMEBUFFER,dn);const An=X.textures[Yt],Kn=An.format,Un=An.type;if(!Hn.textureFormatReadable(Kn))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!Hn.textureTypeReadable(Un))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const di=ne.createBuffer();ne.bindBuffer(ne.PIXEL_PACK_BUFFER,di),ne.bufferData(ne.PIXEL_PACK_BUFFER,Ht.byteLength,ne.STREAM_READ),X.textures.length>1&&ne.readBuffer(ne.COLOR_ATTACHMENT0+Yt),ne.readPixels(Ce,He,Ge,Le,Lt.convert(Kn),Lt.convert(Un),0);const ji=_e!==null?V.get(_e).__webglFramebuffer:null;Bt.bindFramebuffer(ne.FRAMEBUFFER,ji);const ks=ne.fenceSync(ne.SYNC_GPU_COMMANDS_COMPLETE,0);return ne.flush(),yield Og(ne,ks,4),ne.bindBuffer(ne.PIXEL_PACK_BUFFER,di),ne.getBufferSubData(ne.PIXEL_PACK_BUFFER,0,Ht),ne.deleteBuffer(di),ne.deleteSync(ks),Ht}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")})},this.copyFramebufferToTexture=function(X,Ce=null,He=0){const Ge=Math.pow(2,-He),Le=Math.floor(X.image.width*Ge),Ht=Math.floor(X.image.height*Ge),ln=Ce!==null?Ce.x:0,Yt=Ce!==null?Ce.y:0;Se.setTexture2D(X,0),ne.copyTexSubImage2D(ne.TEXTURE_2D,He,0,0,ln,Yt,Le,Ht),Bt.unbindTexture()};const QY=ne.createFramebuffer(),eZ=ne.createFramebuffer();this.copyTextureToTexture=function(X,Ce,He=null,Ge=null,Le=0,Ht=null){Ht===null&&(Le!==0?(Ut("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),Ht=Le,Le=0):Ht=0);let ln,Yt,dn,An,Kn,Un,di,ji,ks;const zs=X.isCompressedTexture?X.mipmaps[Ht]:X.image;if(He!==null)ln=He.max.x-He.min.x,Yt=He.max.y-He.min.y,dn=He.isBox3?He.max.z-He.min.z:1,An=He.min.x,Kn=He.min.y,Un=He.isBox3?He.min.z:0;else{const tl=Math.pow(2,-Le);ln=Math.floor(zs.width*tl),Yt=Math.floor(zs.height*tl),X.isDataArrayTexture?dn=zs.depth:X.isData3DTexture?dn=Math.floor(zs.depth*tl):dn=1,An=0,Kn=0,Un=0}Ge!==null?(di=Ge.x,ji=Ge.y,ks=Ge.z):(di=0,ji=0,ks=0);const es=Lt.convert(Ce.format),kn=Lt.convert(Ce.type);let Wi;Ce.isData3DTexture?(Se.setTexture3D(Ce,0),Wi=ne.TEXTURE_3D):Ce.isDataArrayTexture||Ce.isCompressedArrayTexture?(Se.setTexture2DArray(Ce,0),Wi=ne.TEXTURE_2D_ARRAY):(Se.setTexture2D(Ce,0),Wi=ne.TEXTURE_2D),ne.pixelStorei(ne.UNPACK_FLIP_Y_WEBGL,Ce.flipY),ne.pixelStorei(ne.UNPACK_PREMULTIPLY_ALPHA_WEBGL,Ce.premultiplyAlpha),ne.pixelStorei(ne.UNPACK_ALIGNMENT,Ce.unpackAlignment);const Ei=ne.getParameter(ne.UNPACK_ROW_LENGTH),Ta=ne.getParameter(ne.UNPACK_IMAGE_HEIGHT),Eg=ne.getParameter(ne.UNPACK_SKIP_PIXELS),wa=ne.getParameter(ne.UNPACK_SKIP_ROWS),r_=ne.getParameter(ne.UNPACK_SKIP_IMAGES);ne.pixelStorei(ne.UNPACK_ROW_LENGTH,zs.width),ne.pixelStorei(ne.UNPACK_IMAGE_HEIGHT,zs.height),ne.pixelStorei(ne.UNPACK_SKIP_PIXELS,An),ne.pixelStorei(ne.UNPACK_SKIP_ROWS,Kn),ne.pixelStorei(ne.UNPACK_SKIP_IMAGES,Un);const os=X.isDataArrayTexture||X.isData3DTexture,$o=Ce.isDataArrayTexture||Ce.isData3DTexture;if(X.isDepthTexture){const tl=V.get(X),So=V.get(Ce),qo=V.get(tl.__renderTarget),tA=V.get(So.__renderTarget);Bt.bindFramebuffer(ne.READ_FRAMEBUFFER,qo.__webglFramebuffer),Bt.bindFramebuffer(ne.DRAW_FRAMEBUFFER,tA.__webglFramebuffer);for(let Ep=0;Ep<dn;Ep++)os&&(ne.framebufferTextureLayer(ne.READ_FRAMEBUFFER,ne.COLOR_ATTACHMENT0,V.get(X).__webglTexture,Le,Un+Ep),ne.framebufferTextureLayer(ne.DRAW_FRAMEBUFFER,ne.COLOR_ATTACHMENT0,V.get(Ce).__webglTexture,Ht,ks+Ep)),ne.blitFramebuffer(An,Kn,ln,Yt,di,ji,ln,Yt,ne.DEPTH_BUFFER_BIT,ne.NEAREST);Bt.bindFramebuffer(ne.READ_FRAMEBUFFER,null),Bt.bindFramebuffer(ne.DRAW_FRAMEBUFFER,null)}else if(Le!==0||X.isRenderTargetTexture||V.has(X)){const tl=V.get(X),So=V.get(Ce);Bt.bindFramebuffer(ne.READ_FRAMEBUFFER,QY),Bt.bindFramebuffer(ne.DRAW_FRAMEBUFFER,eZ);for(let qo=0;qo<dn;qo++)os?ne.framebufferTextureLayer(ne.READ_FRAMEBUFFER,ne.COLOR_ATTACHMENT0,tl.__webglTexture,Le,Un+qo):ne.framebufferTexture2D(ne.READ_FRAMEBUFFER,ne.COLOR_ATTACHMENT0,ne.TEXTURE_2D,tl.__webglTexture,Le),$o?ne.framebufferTextureLayer(ne.DRAW_FRAMEBUFFER,ne.COLOR_ATTACHMENT0,So.__webglTexture,Ht,ks+qo):ne.framebufferTexture2D(ne.DRAW_FRAMEBUFFER,ne.COLOR_ATTACHMENT0,ne.TEXTURE_2D,So.__webglTexture,Ht),Le!==0?ne.blitFramebuffer(An,Kn,ln,Yt,di,ji,ln,Yt,ne.COLOR_BUFFER_BIT,ne.NEAREST):$o?ne.copyTexSubImage3D(Wi,Ht,di,ji,ks+qo,An,Kn,ln,Yt):ne.copyTexSubImage2D(Wi,Ht,di,ji,An,Kn,ln,Yt);Bt.bindFramebuffer(ne.READ_FRAMEBUFFER,null),Bt.bindFramebuffer(ne.DRAW_FRAMEBUFFER,null)}else $o?X.isDataTexture||X.isData3DTexture?ne.texSubImage3D(Wi,Ht,di,ji,ks,ln,Yt,dn,es,kn,zs.data):Ce.isCompressedArrayTexture?ne.compressedTexSubImage3D(Wi,Ht,di,ji,ks,ln,Yt,dn,es,zs.data):ne.texSubImage3D(Wi,Ht,di,ji,ks,ln,Yt,dn,es,kn,zs):X.isDataTexture?ne.texSubImage2D(ne.TEXTURE_2D,Ht,di,ji,ln,Yt,es,kn,zs.data):X.isCompressedTexture?ne.compressedTexSubImage2D(ne.TEXTURE_2D,Ht,di,ji,zs.width,zs.height,es,zs.data):ne.texSubImage2D(ne.TEXTURE_2D,Ht,di,ji,ln,Yt,es,kn,zs);ne.pixelStorei(ne.UNPACK_ROW_LENGTH,Ei),ne.pixelStorei(ne.UNPACK_IMAGE_HEIGHT,Ta),ne.pixelStorei(ne.UNPACK_SKIP_PIXELS,Eg),ne.pixelStorei(ne.UNPACK_SKIP_ROWS,wa),ne.pixelStorei(ne.UNPACK_SKIP_IMAGES,r_),Ht===0&&Ce.generateMipmaps&&ne.generateMipmap(Wi),Bt.unbindTexture()},this.initRenderTarget=function(X){V.get(X).__webglFramebuffer===void 0&&Se.setupRenderTarget(X)},this.initTexture=function(X){X.isCubeTexture?Se.setTextureCube(X,0):X.isData3DTexture?Se.setTexture3D(X,0):X.isDataArrayTexture||X.isCompressedArrayTexture?Se.setTexture2DArray(X,0):Se.setTexture2D(X,0),Bt.unbindTexture()},this.resetState=function(){Q=0,ye=0,_e=null,Bt.reset(),nn.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ws}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=xn._getDrawingBufferColorSpace(e),t.unpackColorSpace=xn._getUnpackColorSpace()}}const ez=["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"],NM=new WeakMap;class tz{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=ez,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:n,material:r,object:o}=e;if(t={material:this.getMaterialData(r),geometry:{id:n.id,attributes:this.getAttributesData(n.attributes),indexVersion:n.index?n.index.version:null,drawRange:{start:n.drawRange.start,count:n.drawRange.count}},worldMatrix:o.matrixWorld.clone()},o.center&&(t.center=o.center.clone()),o.morphTargetInfluences&&(t.morphTargetInfluences=o.morphTargetInfluences.slice()),e.bundle!==null&&(t.version=e.bundle.version),t.material.transmission>0){const{width:a,height:c}=e.context;t.bufferWidth=a,t.bufferHeight=c}t.lights=this.getLightsData(e.lightsNode.getLights()),this.renderObjects.set(e,t)}return t}getAttributesData(e){const t={};for(const n in e){const r=e[n];t[n]={version:r.version}}return t}containsNode(e){const t=e.material;for(const n in t)if(t[n]&&t[n].isNode)return!0;return!!(e.context.modelViewMatrix||e.context.modelNormalViewMatrix||e.context.getAO||e.context.getShadow)}getMaterialData(e){const t={};for(const n of this.refreshUniforms){const r=e[n];r!=null&&(typeof r=="object"&&r.clone!==void 0?r.isTexture===!0?t[n]={id:r.id,version:r.version}:t[n]=r.clone():t[n]=r)}return t}equals(e,t){const{object:n,material:r,geometry:o}=e,a=this.getRenderObjectData(e);if(a.worldMatrix.equals(n.matrixWorld)!==!0)return a.worldMatrix.copy(n.matrixWorld),!1;const c=a.material;for(const M in c){const S=c[M],C=r[M];if(S.equals!==void 0){if(S.equals(C)===!1)return S.copy(C),!1}else if(C.isTexture===!0){if(S.id!==C.id||S.version!==C.version)return S.id=C.id,S.version=C.version,!1}else if(S!==C)return c[M]=C,!1}if(c.transmission>0){const{width:M,height:S}=e.context;if(a.bufferWidth!==M||a.bufferHeight!==S)return a.bufferWidth=M,a.bufferHeight=S,!1}const u=a.geometry,d=o.attributes,p=u.attributes,m=Object.keys(p),y=Object.keys(d);if(u.id!==o.id)return u.id=o.id,!1;if(m.length!==y.length)return a.geometry.attributes=this.getAttributesData(d),!1;for(const M of m){const S=p[M],C=d[M];if(C===void 0)return delete p[M],!1;if(S.version!==C.version)return S.version=C.version,!1}const x=o.index,v=u.indexVersion,w=x?x.version:null;if(v!==w)return u.indexVersion=w,!1;if(u.drawRange.start!==o.drawRange.start||u.drawRange.count!==o.drawRange.count)return u.drawRange.start=o.drawRange.start,u.drawRange.count=o.drawRange.count,!1;if(a.morphTargetInfluences){let M=!1;for(let S=0;S<a.morphTargetInfluences.length;S++)a.morphTargetInfluences[S]!==n.morphTargetInfluences[S]&&(a.morphTargetInfluences[S]=n.morphTargetInfluences[S],M=!0);if(M)return!1}if(a.lights){for(let M=0;M<t.length;M++)if(a.lights[M].map!==t[M].map)return!1}return a.center&&a.center.equals(n.center)===!1?(a.center.copy(n.center),!0):(e.bundle!==null&&(a.version=e.bundle.version),!0)}getLightsData(e){const t=[];for(const n of e)n.isSpotLight===!0&&n.map!==null&&t.push({map:n.map.version});return t}getLights(e,t){if(NM.has(e)){const r=NM.get(e);if(r.renderId===t)return r.lightsData}const n=this.getLightsData(e.getLights());return NM.set(e,{renderId:t,lightsData:n}),n}needsRefresh(e,t){if(this.hasNode||this.hasAnimation||this.firstInitialization(e)||this.needsVelocity(t.renderer))return!0;const{renderId:n}=t;if(this.renderId!==n)return this.renderId=n,!0;const r=e.object.static===!0,o=e.bundle!==null&&e.bundle.static===!0&&this.getRenderObjectData(e).version===e.bundle.version;if(r||o)return!1;const a=this.getLights(e.lightsNode,n);return this.equals(e,a)!==!0}}function PM(i,e=0){let t=3735928559^e,n=1103547991^e;if(i instanceof Array)for(let r=0,o;r<i.length;r++)o=i[r],t=Math.imul(t^o,2654435761),n=Math.imul(n^o,1597334677);else for(let r=0,o;r<i.length;r++)o=i.charCodeAt(r),t=Math.imul(t^o,2654435761),n=Math.imul(n^o,1597334677);return t=Math.imul(t^t>>>16,2246822507),t^=Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507),n^=Math.imul(t^t>>>13,3266489909),4294967296*(2097151&n)+(t>>>0)}const jm=i=>PM(i),Kf=i=>PM(i),Ym=(...i)=>PM(i),nz=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),JE=new WeakMap;function IM(i){return nz.get(i)}function oy(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 LM(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;Be("TSL: Unsupported type:",i)}function QE(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;Be("TSL: Unsupported type:",i)}function eC(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)||/mat4/.test(i))return 16;Be("TSL: Unsupported type:",i)}function eh(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 ev(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 It(...e):t==="vec2"?new ze(...e):t==="vec3"?new H(...e):t==="vec4"?new gn(...e):t==="mat2"?new vl(...e):t==="mat3"?new Nn(...e):t==="mat4"?new Qt(...e):i==="bool"?e[0]||!1:i==="float"||i==="int"||i==="uint"?e[0]||0:i==="string"?e[0]||"":i==="ArrayBuffer"?BM(e[0]):null}function DM(i){let e=JE.get(i);return e===void 0&&(e={},JE.set(i,e)),e}function FM(i){let e="";const t=new Uint8Array(i);for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}function BM(i){return Uint8Array.from(atob(i),e=>e.charCodeAt(0)).buffer}var HZ=Object.freeze({__proto__:null,arrayBufferToBase64:FM,base64ToArrayBuffer:BM,getAlignmentFromType:eC,getDataFromObject:DM,getLengthFromType:LM,getMemoryLengthFromType:QE,getTypeFromLength:IM,getTypedArrayFromType:oy,getValueFromType:ev,getValueType:eh,hash:Ym,hashArray:Kf,hashString:jm});const ay={VERTEX:"vertex",FRAGMENT:"fragment"},Xn={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},iz={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},zr={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},tC=["fragment","vertex"],OM=["setup","analyze","generate"],UM=[...tC,"compute"],Jf=["x","y","z","w"],sz={analyze:"setup",generate:"analyze"};let rz=0;class Xt extends Jo{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=Kh.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:rz++})}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 n of Object.getOwnPropertyNames(this)){const r=this[n];if(!(n.startsWith("_")===!0||e.has(r))){if(Array.isArray(r)===!0)for(let o=0;o<r.length;o++){const a=r[o];a&&a.isNode===!0&&t.push({property:n,index:o,childNode:a})}else if(r&&r.isNode===!0)t.push({property:n,childNode:r});else if(r&&Object.getPrototypeOf(r)===Object.prototype)for(const o in r){if(o.startsWith("_")===!0)continue;const a=r[o];a&&a.isNode===!0&&t.push({property:n,index:o,childNode:a})}}}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 n=[];for(const{property:r,childNode:o}of this._getChildren(t))n.push(jm(r.slice(0,-4)),o.getCacheKey(e,t));this._cacheKey=Ym(Kf(n),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 n=0;for(const r of this.getChildren())t["node"+n++]=r;return t.outputNode||null}analyze(e,t=null){const n=e.increaseUsage(this);if(this.parents===!0){const r=e.getDataFromNode(this,"any");r.stages=r.stages||{},r.stages[e.shaderStage]=r.stages[e.shaderStage]||[],r.stages[e.shaderStage].push(t)}if(n===1){const r=e.getNodeProperties(this);for(const o of Object.values(r))o&&o.isNode===!0&&o.build(e,this)}}generate(e,t){const{outputNode:n}=e.getNodeProperties(this);if(n&&n.isNode===!0)return n.build(e,t)}updateBefore(){Ie("Abstract function.")}updateAfter(){Ie("Abstract function.")}update(){Ie("Abstract function.")}before(e){return this._beforeNodes===null&&(this._beforeNodes=[]),this._beforeNodes.push(e),this}build(e,t=null){const n=this.getShared(e);if(this!==n)return n.build(e,t);if(this._beforeNodes!==null){const u=this._beforeNodes;this._beforeNodes=null;for(const d of u)d.build(e,t);this._beforeNodes=u}const r=e.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[e.buildStage]=!0;const o=sz[e.buildStage];if(o&&r.buildStages[o]!==!0){const u=e.getBuildStage();e.setBuildStage(o),this.build(e),e.setBuildStage(u)}e.addNode(this),e.addChain(this);let a=null;const c=e.getBuildStage();if(c==="setup"){this.updateReference(e);const u=e.getNodeProperties(this);if(u.initialized!==!0){u.initialized=!0,u.outputNode=this.setup(e)||u.outputNode||null;for(const d of Object.values(u))if(d&&d.isNode===!0){if(d.parents===!0){const p=e.getNodeProperties(d);p.parents=p.parents||[],p.parents.push(this)}d.build(e)}}a=u.outputNode}else if(c==="analyze")this.analyze(e,t);else if(c==="generate"){if(this.generate.length<2){const d=this.getNodeType(e),p=e.getDataFromNode(this);a=p.snippet,a===void 0?p.generated===void 0?(p.generated=!0,a=this.generate(e)||"",p.snippet=a):(Ie("Node: Recursion detected.",this),a="/* Recursion detected. */"):p.flowCodes!==void 0&&e.context.nodeBlock!==void 0&&e.addFlowCodeHierarchy(this,e.context.nodeBlock),a=e.format(a,d,t)}else a=this.generate(e,t)||"";a===""&&t!==null&&t!=="void"&&t!=="OutputType"&&(Be(`TSL: Invalid generated code, expected a "${t}".`),a=e.generateConst(t))}return e.removeChain(this),e.addSequentialNode(this),a}getSerializeChildren(){return this._getChildren()}serialize(e){const t=this.getSerializeChildren(),n={};for(const{property:r,index:o,childNode:a}of t)o!==void 0?(n[r]===void 0&&(n[r]=Number.isInteger(o)?[]:{}),n[r][o]=a.toJSON(e.meta).uuid):n[r]=a.toJSON(e.meta).uuid;Object.keys(n).length>0&&(e.inputNodes=n)}deserialize(e){if(e.inputNodes!==void 0){const t=e.meta.nodes;for(const n in e.inputNodes)if(Array.isArray(e.inputNodes[n])){const r=[];for(const o of e.inputNodes[n])r.push(t[o]);this[n]=r}else if(typeof e.inputNodes[n]=="object"){const r={};for(const o in e.inputNodes[n]){const a=e.inputNodes[n][o];r[o]=t[a]}this[n]=r}else{const r=e.inputNodes[n];this[n]=t[r]}}}toJSON(e){const{uuid:t,type:n}=this,r=e===void 0||typeof e=="string";r&&(e={textures:{},images:{},nodes:{}});let o=e.nodes[t];o===void 0&&(o={uuid:t,type:n,meta:e,metadata:{version:4.7,type:"Node",generator:"Node.toJSON"}},r!==!0&&(e.nodes[o.uuid]=o),this.serialize(o),delete o.meta);function a(c){const u=[];for(const d in c){const p=c[d];delete p.metadata,u.push(p)}return u}if(r){const c=a(e.textures),u=a(e.images),d=a(e.nodes);c.length>0&&(o.textures=c),u.length>0&&(o.images=u),d.length>0&&(o.nodes=d)}return o}}class Qf extends Xt{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)}getMemberType(e,t){return this.node.getMemberType(e,t)}generate(e){const t=this.indexNode.getNodeType(e),n=this.node.build(e),r=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint");return`${n}[ ${r} ]`}}class nC extends Xt{static get type(){return"ConvertNode"}constructor(e,t){super(),this.node=e,this.convertTo=t}getNodeType(e){const t=this.node.getNodeType(e);let n=null;for(const r of this.convertTo.split("|"))(n===null||e.getTypeLength(t)===e.getTypeLength(r))&&(n=r);return n}serialize(e){super.serialize(e),e.convertTo=this.convertTo}deserialize(e){super.deserialize(e),this.convertTo=e.convertTo}generate(e,t){const n=this.node,r=this.getNodeType(e),o=n.build(e,r);return e.format(o,r,t)}}class _s extends Xt{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 r=e.getVectorType(this.getNodeType(e,t)),o=e.getDataFromNode(this);if(o.propertyName!==void 0)return e.format(o.propertyName,r,t);if(r!=="void"&&t!=="void"&&this.hasDependencies(e)){const a=super.build(e,r),c=e.getVarFromNode(this,null,r),u=e.getPropertyName(c);return e.addLineFlowCode(`${u} = ${a}`,this),o.snippet=a,o.propertyName=u,e.format(o.propertyName,r,t)}}return super.build(e,t)}}class oz extends _s{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,n)=>t+e.getTypeLength(n.getNodeType(e)),0))}generate(e,t){const n=this.getNodeType(e),r=e.getTypeLength(n),o=this.nodes,a=e.getComponentType(n),c=[];let u=0;for(const p of o){if(u>=r){Be(`TSL: Length of parameters exceeds maximum length of function '${n}()' type.`);break}let m=p.getNodeType(e),y=e.getTypeLength(m),x;if(u+y>r&&(Be(`TSL: Length of '${n}()' data exceeds maximum length of output type.`),y=r-u,m=e.getTypeFromLength(y)),u+=y,x=p.build(e,m),e.getComponentType(m)!==a){const w=e.getTypeFromLength(y,a);x=e.format(x,m,w)}c.push(x)}const d=`${e.getType(n)}( ${c.join(", ")} )`;return e.format(d,n,t)}}const az=Jf.join("");class iC extends Xt{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(Jf.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 n=this.node,r=e.getTypeLength(n.getNodeType(e));let o=null;if(r>1){let a=null;this.getVectorLength()>=r&&(a=e.getTypeFromLength(this.getVectorLength(),this.getComponentType(e)));const u=n.build(e,a);this.components.length===r&&this.components===az.slice(0,this.components.length)?o=e.format(u,a,t):o=e.format(`${u}.${this.components}`,this.getNodeType(e),t)}else o=n.build(e,t);return o}serialize(e){super.serialize(e),e.components=this.components}deserialize(e){super.deserialize(e),this.components=e.components}}class lz extends _s{static get type(){return"SetNode"}constructor(e,t,n){super(),this.sourceNode=e,this.components=t,this.targetNode=n}getNodeType(e){return this.sourceNode.getNodeType(e)}generate(e){const{sourceNode:t,components:n,targetNode:r}=this,o=this.getNodeType(e),a=e.getComponentType(r.getNodeType(e)),c=e.getTypeFromLength(n.length,a),u=r.build(e,c),d=t.build(e,o),p=e.getTypeLength(o),m=[];for(let y=0;y<p;y++){const x=Jf[y];x===n[0]?(m.push(u),y+=n.length-1):m.push(d+"."+x)}return`${e.getType(o)}( ${m.join(", ")} )`}}class cz extends _s{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:n}=this,r=this.getNodeType(e),o=n.build(e),a=e.getVarFromNode(this),c=e.getPropertyName(a);e.addLineFlowCode(c+" = "+o,this);const u=e.getTypeLength(r),d=[];let p=0;for(let m=0;m<u;m++){const y=Jf[m];y===t[p]?(d.push("1.0 - "+(c+"."+y)),p++):d.push(c+"."+y)}return`${e.getType(r)}( ${d.join(", ")} )`}}class kM extends Xt{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?eh(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=eh(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=FM(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?ev(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){Ie("Abstract function.")}}const sC=/float|u?int/;class Ha extends kM{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 n=this.getNodeType(e);return sC.test(n)&&sC.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),n,t)}}class uz extends Xt{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 n=this.getNodeType(e);return e.getStructTypeNode(n).getMemberType(e,t)}generate(e){if(this.hasMember(e)===!1){Ie(`TSL: Member "${this.property}" does not exist in struct.`);const n=this.getNodeType(e);return e.generateConst(n)}return this.structNode.build(e)+"."+this.property}}let Ud=null;const zM=new Map;function We(i,e){if(zM.has(i)){Ie(`TSL: Redefinition of method chaining '${i}'.`);return}if(typeof e!="function")throw new Error(`THREE.TSL: Node element ${i} is not a function`);zM.set(i,e),i!=="assign"&&(Xt.prototype[i]=function(...t){return this.isStackNode?this.addToStack(e(...t)):e(this,...t)},Xt.prototype[i+"Assign"]=function(...t){return this.isStackNode?this.assign(t[0],e(...t)):this.assign(e(this,...t))})}const hz=i=>i.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),rC=i=>hz(i).split("").sort().join("");Xt.prototype.assign=function(...i){if(this.isStackNode!==!0)return Ud!==null?Ud.assign(this,...i):Be("TSL: No stack defined for assign operation. Make sure the assign is inside a Fn()."),this;{const e=zM.get("assign");return this.addToStack(e(...i))}},Xt.prototype.toVarIntent=function(){return this},Xt.prototype.get=function(i){return new uz(this,i)};const ly={};function tv(i,e,t){ly[i]=ly[e]=ly[t]={get(){this._cache=this._cache||{};let a=this._cache[i];return a===void 0&&(a=new iC(this,i),this._cache[i]=a),a},set(a){this[i].assign(Nt(a))}};const n=i.toUpperCase(),r=e.toUpperCase(),o=t.toUpperCase();Xt.prototype["set"+n]=Xt.prototype["set"+r]=Xt.prototype["set"+o]=function(a){const c=rC(i);return new lz(this,c,Nt(a))},Xt.prototype["flip"+n]=Xt.prototype["flip"+r]=Xt.prototype["flip"+o]=function(){const a=rC(i);return new cz(this,a)}}const Tc=["x","y","z","w"],wc=["r","g","b","a"],Ac=["s","t","p","q"];for(let i=0;i<4;i++){let e=Tc[i],t=wc[i],n=Ac[i];tv(e,t,n);for(let r=0;r<4;r++){e=Tc[i]+Tc[r],t=wc[i]+wc[r],n=Ac[i]+Ac[r],tv(e,t,n);for(let o=0;o<4;o++){e=Tc[i]+Tc[r]+Tc[o],t=wc[i]+wc[r]+wc[o],n=Ac[i]+Ac[r]+Ac[o],tv(e,t,n);for(let a=0;a<4;a++)e=Tc[i]+Tc[r]+Tc[o]+Tc[a],t=wc[i]+wc[r]+wc[o]+wc[a],n=Ac[i]+Ac[r]+Ac[o]+Ac[a],tv(e,t,n)}}}for(let i=0;i<32;i++)ly[i]={get(){this._cache=this._cache||{};let e=this._cache[i];return e===void 0&&(e=new Qf(this,new Ha(i,"uint")),this._cache[i]=e),e},set(e){this[i].assign(Nt(e))}};Object.defineProperties(Xt.prototype,ly);const oC=new WeakMap,dz=function(i,e=null){const t=eh(i);return t==="node"?i:e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string"?Nt(HM(i,e)):t==="shader"?i.isFn?i:me(i):i},fz=function(i,e=null){for(const t in i)i[t]=Nt(i[t],e);return i},pz=function(i,e=null){const t=i.length;for(let n=0;n<t;n++)i[n]=Nt(i[n],e);return i},aC=function(i,e=null,t=null,n=null){function r(p){return n!==null?(p=Nt(Object.assign(p,n)),n.intent===!0&&(p=p.toVarIntent())):p=Nt(p),p}let o,a=e,c,u;function d(p){let m;return a?m=/[a-z]/i.test(a)?a+"()":a:m=i.type,c!==void 0&&p.length<c?(Be(`TSL: "${m}" parameter length is less than minimum required.`),p.concat(new Array(c-p.length).fill(0))):u!==void 0&&p.length>u?(Be(`TSL: "${m}" parameter length exceeds limit.`),p.slice(0,u)):p}return e===null?o=(...p)=>r(new i(...ep(d(p)))):t!==null?(t=Nt(t),o=(...p)=>r(new i(e,...ep(d(p)),t))):o=(...p)=>r(new i(e,...ep(d(p)))),o.setParameterLength=(...p)=>(p.length===1?c=u=p[0]:p.length===2&&([c,u]=p),o),o.setName=p=>(a=p,o),o},mz=function(i,...e){return new i(...ep(e))};class gz extends Xt{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:n}=this,r=e.getNodeProperties(t),o=e.getClosestSubBuild(t.subBuilds)||"",a=o||"default";if(r[a])return r[a];const c=e.subBuildFn,u=e.fnCall;e.subBuildFn=o,e.fnCall=this;let d=null;if(t.layout){let p=oC.get(e.constructor);p===void 0&&(p=new WeakMap,oC.set(e.constructor,p));let m=p.get(t);m===void 0&&(m=Nt(e.buildFunctionNode(t)),p.set(t,m)),e.addInclude(m);const y=n?yz(n):null;d=Nt(m.call(y))}else{const p=new Proxy(e,{get:(w,M,S)=>{let C;return Symbol.iterator===M?C=function*(){yield void 0}:C=Reflect.get(w,M,S),C}}),m=n?_z(n):null,y=Array.isArray(n)?n.length>0:n!==null,x=t.jsFunc,v=y||x.length>1?x(m,p):x(p);d=Nt(v)}return e.subBuildFn=c,e.fnCall=u,t.once&&(r[a]=d),d}setupOutput(e){return e.addStack(),e.stack.outputNode=this.call(e),e.removeStack()}getOutputNode(e){const t=e.getNodeProperties(this),n=e.getSubBuildOutput(this);return t[n]=t[n]||this.setupOutput(e),t[n].subBuild=e.getClosestSubBuild(this),t[n]}build(e,t=null){let n=null;const r=e.getBuildStage(),o=e.getNodeProperties(this),a=e.getSubBuildOutput(this),c=this.getOutputNode(e),u=e.fnCall;if(e.fnCall=this,r==="setup"){const d=e.getSubBuildProperty("initialized",this);if(o[d]!==!0&&(o[d]=!0,o[a]=this.getOutputNode(e),o[a].build(e),this.shaderNode.subBuilds))for(const p of e.chaining){const m=e.getDataFromNode(p,"any");m.subBuilds=m.subBuilds||new Set;for(const y of this.shaderNode.subBuilds)m.subBuilds.add(y)}n=o[a]}else r==="analyze"?c.build(e,t):r==="generate"&&(n=c.build(e,t)||"");return e.fnCall=u,n}}function yz(i){let e;return sv(i),i[0]&&(i[0].isNode||Object.getPrototypeOf(i[0])!==Object.prototype)?e=[...i]:e=i[0],e}function _z(i){let e=0;return sv(i),new Proxy(i,{get:(t,n,r)=>{let o;if(n==="length")return o=i.length,o;if(Symbol.iterator===n)o=function*(){for(const a of i)yield Nt(a)};else{if(i.length>0)if(Object.getPrototypeOf(i[0])===Object.prototype){const a=i[0];a[n]===void 0?o=a[e++]:o=Reflect.get(a,n,r)}else i[0]instanceof Xt&&(i[n]===void 0?o=i[e++]:o=Reflect.get(i,n,r));else o=Reflect.get(t,n,r);o=Nt(o)}return o}})}class xz extends Xt{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 gz(this,e)}setup(){return this.call()}}const vz=[!1,!0],bz=[0,1,2,3],Sz=[-1,-2],lC=[.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],VM=new Map;for(const i of vz)VM.set(i,new Ha(i));const GM=new Map;for(const i of bz)GM.set(i,new Ha(i,"uint"));const WM=new Map([...GM].map(i=>new Ha(i.value,"int")));for(const i of Sz)WM.set(i,new Ha(i,"int"));const nv=new Map([...WM].map(i=>new Ha(i.value)));for(const i of lC)nv.set(i,new Ha(i));for(const i of lC)nv.set(-i,new Ha(-i));const iv={bool:VM,uint:GM,ints:WM,float:nv},cC=new Map([...VM,...nv]),HM=(i,e)=>cC.has(i)?cC.get(i):i.isNode===!0?i:new Ha(i,e),or=function(i,e=null){return(...t)=>{for(const r of t)if(r===void 0)return Be(`TSL: Invalid parameter for the type "${i}".`),new Ha(0,i);if((t.length===0||!["bool","float","int","uint"].includes(i)&&t.every(r=>{const o=typeof r;return o!=="object"&&o!=="function"}))&&(t=[ev(i,...t)]),t.length===1&&e!==null&&e.has(t[0]))return uy(e.get(t[0]));if(t.length===1){const r=HM(t[0],i);return r.nodeType===i?uy(r):uy(new nC(r,i))}const n=t.map(r=>HM(r));return uy(new oz(n,i))}},cy=i=>typeof i=="object"&&i!==null?i.value:i,uC=i=>i!=null?i.nodeType||i.convertTo||(typeof i=="string"?i:null):null;function Zm(i,e){return new xz(i,e)}const Nt=(i,e=null)=>dz(i,e),uy=(i,e=null)=>Nt(i,e).toVarIntent(),sv=(i,e=null)=>new fz(i,e),ep=(i,e=null)=>new pz(i,e),Fn=(i,e=null,t=null,n=null)=>new aC(i,e,t,n),Ct=(i,...e)=>new mz(i,...e),pt=(i,e=null,t=null,n={})=>new aC(i,e,t,Mo(wi({},n),{intent:!0}));let Mz=0;class Tz extends Xt{constructor(e,t=null){super();let n=null;t!==null&&(typeof t=="object"?n=t.return:(typeof t=="string"?n=t:Be("TSL: Invalid layout type."),t=null)),this.shaderNode=new Zm(e,n),t!==null&&this.setLayout(t),this.isFn=!0}setLayout(e){const t=this.shaderNode.nodeType;if(typeof e.inputs!="object"){const n={name:"fn"+Mz++,type:t,inputs:[]};for(const r in e)r!=="return"&&n.inputs.push({name:r,type:e[r]});e=n}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 Be('TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".'),e.generateConst(t)}}function me(i,e=null){const t=new Tz(i,e);return new Proxy(()=>{},{apply(n,r,o){return t.call(...o)},get(n,r,o){return Reflect.get(t,r,o)},set(n,r,o,a){return Reflect.set(t,r,o,a)}})}const hy=i=>{Ud=i},$M=()=>Ud,jt=(...i)=>Ud.If(...i),wz=(...i)=>Ud.Switch(...i);function rv(i){return Ud&&Ud.addToStack(i),i}We("toStack",rv);const hC=new or("color"),q=new or("float",iv.float),le=new or("int",iv.ints),it=new or("uint",iv.uint),$a=new or("bool",iv.bool),lt=new or("vec2"),ar=new or("ivec2"),qM=new or("uvec2"),dC=new or("bvec2"),he=new or("vec3"),XM=new or("ivec3"),tp=new or("uvec3"),jM=new or("bvec3"),zt=new or("vec4"),YM=new or("ivec4"),ZM=new or("uvec4"),fC=new or("bvec4"),ov=new or("mat2"),Vr=new or("mat3"),kd=new or("mat4"),Az=(i="")=>new Ha(i,"string"),Ez=i=>new Ha(i,"ArrayBuffer");We("toColor",hC),We("toFloat",q),We("toInt",le),We("toUint",it),We("toBool",$a),We("toVec2",lt),We("toIVec2",ar),We("toUVec2",qM),We("toBVec2",dC),We("toVec3",he),We("toIVec3",XM),We("toUVec3",tp),We("toBVec3",jM),We("toVec4",zt),We("toIVec4",YM),We("toUVec4",ZM),We("toBVec4",fC),We("toMat2",ov),We("toMat3",Vr),We("toMat4",kd);const pC=Fn(Qf).setParameterLength(2),mC=(i,e)=>Nt(new nC(Nt(i),e)),Cz=(i,e)=>Nt(new iC(Nt(i),e));We("element",pC),We("convert",mC);const Rz=i=>(Ie("TSL: append() has been renamed to Stack()."),rv(i));We("append",i=>(Ie("TSL: .append() has been renamed to .toStack()."),rv(i)));class Ti extends Xt{static get type(){return"PropertyNode"}constructor(e,t=null,n=!1){super(e),this.name=t,this.varying=n,this.isPropertyNode=!0,this.global=!0}customCacheKey(){return jm(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 Al=(i,e)=>new Ti(i,e),fa=(i,e)=>new Ti(i,e,!0),Ni=Ct(Ti,"vec4","DiffuseColor"),np=Ct(Ti,"vec3","DiffuseContribution"),KM=Ct(Ti,"vec3","EmissiveColor"),Ec=Ct(Ti,"float","Roughness"),th=Ct(Ti,"float","Metalness"),av=Ct(Ti,"float","Clearcoat"),dy=Ct(Ti,"float","ClearcoatRoughness"),pa=Ct(Ti,"vec3","Sheen"),zd=Ct(Ti,"float","SheenRoughness"),lv=Ct(Ti,"float","Iridescence"),cv=Ct(Ti,"float","IridescenceIOR"),uv=Ct(Ti,"float","IridescenceThickness"),hv=Ct(Ti,"float","AlphaT"),Vd=Ct(Ti,"float","Anisotropy"),fy=Ct(Ti,"vec3","AnisotropyT"),ip=Ct(Ti,"vec3","AnisotropyB"),Gd=Ct(Ti,"color","SpecularColor"),sp=Ct(Ti,"color","SpecularColorBlended"),Km=Ct(Ti,"float","SpecularF90"),dv=Ct(Ti,"float","Shininess"),Jm=Ct(Ti,"vec4","Output"),rp=Ct(Ti,"float","dashSize"),py=Ct(Ti,"float","gapSize"),Nz=Ct(Ti,"float","pointWidth"),my=Ct(Ti,"float","IOR"),fv=Ct(Ti,"float","Transmission"),JM=Ct(Ti,"float","Thickness"),QM=Ct(Ti,"float","AttenuationDistance"),eT=Ct(Ti,"color","AttenuationColor"),tT=Ct(Ti,"float","Dispersion");class gC extends Xt{static get type(){return"UniformGroupNode"}constructor(e,t=!1,n=1){super("string"),this.name=e,this.shared=t,this.order=n,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 yC=i=>new gC(i),pv=(i,e=0)=>new gC(i,!0,e),_C=pv("frame"),an=pv("render"),nT=yC("object");class gy extends kM{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=nT}setName(e){return this.name=e,this}label(e){return Ie('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(n=>{const r=e(n,this);r!==void 0&&(this.value=r)},t)}getInputType(e){let t=super.getInputType(e);return t==="bool"&&(t="uint"),t}generate(e,t){const n=this.getNodeType(e),r=this.getUniformHash(e);let o=e.getNodeFromHash(r);o===void 0&&(e.setHashNode(this,r),o=this);const a=o.getInputType(e),c=e.getUniformFromNode(o,a,e.shaderStage,this.name||e.context.nodeName),u=e.getPropertyName(c);e.context.nodeName!==void 0&&delete e.context.nodeName;let d=u;if(n==="bool"){const p=e.getDataFromNode(this);let m=p.propertyName;if(m===void 0){const y=e.getVarFromNode(this,null,"bool");m=e.getPropertyName(y),p.propertyName=m,d=e.format(u,a,n),e.addLineFlowCode(`${m} = ${d}`,this)}d=m}return e.format(d,n,t)}}const rn=(i,e)=>{const t=uC(e||i);if(t===i&&(i=ev(t)),i&&i.isNode===!0){let n=i.value;i.traverse(r=>{r.isConstNode===!0&&(n=r.value)}),i=n}return new gy(i,t)};class xC extends _s{static get type(){return"ArrayNode"}constructor(e,t,n=null){super(e),this.count=t,this.values=n,this.isArrayNode=!0}getArrayCount(){return this.count}getNodeType(e){return this.nodeType===null?this.values[0].getNodeType(e):this.nodeType}getElementType(e){return this.getNodeType(e)}getMemberType(e,t){return this.nodeType===null?this.values[0].getMemberType(e,t):super.getMemberType(e,t)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const vC=(...i)=>{let e;if(i.length===1){const t=i[0];e=new xC(null,t.length,t)}else{const t=i[0],n=i[1];e=new xC(t,n)}return Nt(e)};We("toArray",(i,e)=>vC(Array(e).fill(i)));class Pz extends _s{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 n=e.getTypeLength(t.node.getNodeType(e));return Jf.join("").slice(0,n)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:n}=this,r=t.getScope(),o=e.getDataFromNode(r);o.assign=!0;const a=e.getNodeProperties(this);a.sourceNode=n,a.targetNode=t.context({assign:!0})}generate(e,t){const{targetNode:n,sourceNode:r}=e.getNodeProperties(this),o=this.needsSplitAssign(e),a=n.build(e),c=n.getNodeType(e),u=r.build(e,c),d=r.getNodeType(e),p=e.getDataFromNode(this);let m;if(p.initialized===!0)t!=="void"&&(m=a);else if(o){const y=e.getVarFromNode(this,null,c),x=e.getPropertyName(y);e.addLineFlowCode(`${x} = ${u}`,this);const v=n.node,M=v.node.context({assign:!0}).build(e);for(let S=0;S<v.components.length;S++){const C=v.components[S];e.addLineFlowCode(`${M}.${C} = ${x}[ ${S} ]`,this)}t!=="void"&&(m=a)}else m=`${a} = ${u}`,(t==="void"||d==="void")&&(e.addLineFlowCode(m,this),t!=="void"&&(m=a));return p.initialized=!0,e.format(m,c,t)}}const bC=Fn(Pz).setParameterLength(2);We("assign",bC);class Iz extends _s{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=[],n=this.functionNode,r=n.getInputs(e),o=this.parameters,a=(u,d)=>{const p=d.type,m=p==="pointer";let y;return m?y="&"+u.build(e):y=u.build(e,p),y};if(Array.isArray(o)){if(o.length>r.length)Be("TSL: The number of provided parameters exceeds the expected number of inputs in 'Fn()'."),o.length=r.length;else if(o.length<r.length)for(Be("TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");o.length<r.length;)o.push(q(0));for(let u=0;u<o.length;u++)t.push(a(o[u],r[u]))}else for(const u of r){const d=o[u.name];d!==void 0?t.push(a(d,u)):(Be(`TSL: Input '${u.name}' not found in 'Fn()'.`),t.push(a(q(0),u)))}return`${n.build(e,"property")}( ${t.join(", ")} )`}}const SC=(i,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?ep(e):sv(e[0]),new Iz(Nt(i),e));We("call",SC);const Lz={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class xs extends _s{static get type(){return"OperatorNode"}constructor(e,t,n,...r){if(super(),r.length>0){let o=new xs(e,t,n);for(let a=0;a<r.length-1;a++)o=new xs(e,o,r[a]);t=o,n=r[r.length-1]}this.op=e,this.aNode=t,this.bNode=n,this.isOperatorNode=!0}getOperatorMethod(e,t){return e.getMethod(Lz[this.op],t)}getNodeType(e,t=null){const n=this.op,r=this.aNode,o=this.bNode,a=r.getNodeType(e),c=o?o.getNodeType(e):null;if(a==="void"||c==="void")return t||"void";if(n==="%")return a;if(n==="~"||n==="&"||n==="|"||n==="^"||n===">>"||n==="<<")return e.getIntegerType(a);if(n==="!"||n==="&&"||n==="||"||n==="^^")return"bool";if(n==="=="||n==="!="||n==="<"||n===">"||n==="<="||n===">="){const u=Math.max(e.getTypeLength(a),e.getTypeLength(c));return u>1?`bvec${u}`:"bool"}else{if(e.isMatrix(a)){if(c==="float")return a;if(e.isVector(c))return e.getVectorFromMatrix(a);if(e.isMatrix(c))return a}else if(e.isMatrix(c)){if(a==="float")return c;if(e.isVector(a))return e.getVectorFromMatrix(c)}return e.getTypeLength(c)>e.getTypeLength(a)?c:a}}generate(e,t){const n=this.op,{aNode:r,bNode:o}=this,a=this.getNodeType(e,t);let c=null,u=null;a!=="void"?(c=r.getNodeType(e),u=o?o.getNodeType(e):null,n==="<"||n===">"||n==="<="||n===">="||n==="=="||n==="!="?e.isVector(c)?u=c:e.isVector(u)?c=u:c!==u&&(c=u="float"):n===">>"||n==="<<"?(c=a,u=e.changeComponentType(u,"uint")):n==="%"?(c=a,u=e.isInteger(c)&&e.isInteger(u)?u:c):e.isMatrix(c)?u==="float"?u="float":e.isVector(u)?u=e.getVectorFromMatrix(c):e.isMatrix(u)||(c=u=a):e.isMatrix(u)?c==="float"?c="float":e.isVector(c)?c=e.getVectorFromMatrix(u):c=u=a:c=u=a):c=u=a;const d=r.build(e,c),p=o?o.build(e,u):null,m=e.getFunctionOperator(n);if(t!=="void"){const y=e.renderer.coordinateSystem===ws;if(n==="=="||n==="!="||n==="<"||n===">"||n==="<="||n===">=")return y?e.isVector(c)?e.format(`${this.getOperatorMethod(e,t)}( ${d}, ${p} )`,a,t):e.format(`( ${d} ${n} ${p} )`,a,t):e.format(`( ${d} ${n} ${p} )`,a,t);if(n==="%")return e.isInteger(u)?e.format(`( ${d} % ${p} )`,a,t):e.format(`${this.getOperatorMethod(e,a)}( ${d}, ${p} )`,a,t);if(n==="!"||n==="~")return e.format(`(${n}${d})`,c,t);if(m)return e.format(`${m}( ${d}, ${p} )`,a,t);if(e.isMatrix(c)&&u==="float")return e.format(`( ${p} ${n} ${d} )`,a,t);if(c==="float"&&e.isMatrix(u))return e.format(`${d} ${n} ${p}`,a,t);{let x=`( ${d} ${n} ${p} )`;return!y&&a==="bool"&&e.isVector(c)&&e.isVector(u)&&(x=`all${x}`),e.format(x,a,t)}}else if(c!=="void")return m?e.format(`${m}( ${d}, ${p} )`,a,t):e.isMatrix(c)&&u==="float"?e.format(`${p} ${n} ${d}`,a,t):e.format(`${d} ${n} ${p}`,a,t)}serialize(e){super.serialize(e),e.op=this.op}deserialize(e){super.deserialize(e),this.op=e.op}}const Js=pt(xs,"+").setParameterLength(2,1/0).setName("add"),ui=pt(xs,"-").setParameterLength(2,1/0).setName("sub"),Bn=pt(xs,"*").setParameterLength(2,1/0).setName("mul"),ma=pt(xs,"/").setParameterLength(2,1/0).setName("div"),yy=pt(xs,"%").setParameterLength(2).setName("mod"),iT=pt(xs,"==").setParameterLength(2).setName("equal"),MC=pt(xs,"!=").setParameterLength(2).setName("notEqual"),TC=pt(xs,"<").setParameterLength(2).setName("lessThan"),sT=pt(xs,">").setParameterLength(2).setName("greaterThan"),wC=pt(xs,"<=").setParameterLength(2).setName("lessThanEqual"),AC=pt(xs,">=").setParameterLength(2).setName("greaterThanEqual"),EC=pt(xs,"&&").setParameterLength(2,1/0).setName("and"),CC=pt(xs,"||").setParameterLength(2,1/0).setName("or"),RC=pt(xs,"!").setParameterLength(1).setName("not"),NC=pt(xs,"^^").setParameterLength(2).setName("xor"),PC=pt(xs,"&").setParameterLength(2).setName("bitAnd"),IC=pt(xs,"~").setParameterLength(1).setName("bitNot"),LC=pt(xs,"|").setParameterLength(2).setName("bitOr"),DC=pt(xs,"^").setParameterLength(2).setName("bitXor"),FC=pt(xs,"<<").setParameterLength(2).setName("shiftLeft"),BC=pt(xs,">>").setParameterLength(2).setName("shiftRight"),OC=me(([i])=>(i.addAssign(1),i)),UC=me(([i])=>(i.subAssign(1),i)),kC=me(([i])=>{const e=le(i).toConst();return i.addAssign(1),e}),zC=me(([i])=>{const e=le(i).toConst();return i.subAssign(1),e});We("add",Js),We("sub",ui),We("mul",Bn),We("div",ma),We("mod",yy),We("equal",iT),We("notEqual",MC),We("lessThan",TC),We("greaterThan",sT),We("lessThanEqual",wC),We("greaterThanEqual",AC),We("and",EC),We("or",CC),We("not",RC),We("xor",NC),We("bitAnd",PC),We("bitNot",IC),We("bitOr",LC),We("bitXor",DC),We("shiftLeft",FC),We("shiftRight",BC),We("incrementBefore",OC),We("decrementBefore",UC),We("increment",kC),We("decrement",zC);const VC=(i,e)=>(Ie('TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),yy(le(i),le(e)));We("modInt",VC);class Re extends _s{static get type(){return"MathNode"}constructor(e,t,n=null,r=null){if(super(),(e===Re.MAX||e===Re.MIN)&&arguments.length>3){let o=new Re(e,t,n);for(let a=2;a<arguments.length-1;a++)o=new Re(e,o,arguments[a]);t=o,n=arguments[arguments.length-1],r=null}this.method=e,this.aNode=t,this.bNode=n,this.cNode=r,this.isMathNode=!0}getInputType(e){const t=this.aNode.getNodeType(e),n=this.bNode?this.bNode.getNodeType(e):null,r=this.cNode?this.cNode.getNodeType(e):null,o=e.isMatrix(t)?0:e.getTypeLength(t),a=e.isMatrix(n)?0:e.getTypeLength(n),c=e.isMatrix(r)?0:e.getTypeLength(r);return o>a&&o>c?t:a>c?n:c>o?r:t}getNodeType(e){const t=this.method;return t===Re.LENGTH||t===Re.DISTANCE||t===Re.DOT?"float":t===Re.CROSS?"vec3":t===Re.ALL||t===Re.ANY?"bool":t===Re.EQUALS?e.changeComponentType(this.aNode.getNodeType(e),"bool"):this.getInputType(e)}setup(e){const{aNode:t,bNode:n,method:r}=this;let o=null;if(r===Re.ONE_MINUS)o=ui(1,t);else if(r===Re.RECIPROCAL)o=ma(1,t);else if(r===Re.DIFFERENCE)o=qi(ui(t,n));else if(r===Re.TRANSFORM_DIRECTION){let a=t,c=n;e.isMatrix(a.getNodeType(e))?c=zt(he(c),0):a=zt(he(a),0);const u=Bn(a,c).xyz;o=go(u)}return o!==null?o:super.setup(e)}generate(e,t){if(e.getNodeProperties(this).outputNode)return super.generate(e,t);let r=this.method;const o=this.getNodeType(e),a=this.getInputType(e),c=this.aNode,u=this.bNode,d=this.cNode,p=e.renderer.coordinateSystem;if(r===Re.NEGATE)return e.format("( - "+c.build(e,a)+" )",o,t);{const m=[];return r===Re.CROSS?m.push(c.build(e,o),u.build(e,o)):p===ws&&r===Re.STEP?m.push(c.build(e,e.getTypeLength(c.getNodeType(e))===1?"float":a),u.build(e,a)):p===ws&&(r===Re.MIN||r===Re.MAX)?m.push(c.build(e,a),u.build(e,e.getTypeLength(u.getNodeType(e))===1?"float":a)):r===Re.REFRACT?m.push(c.build(e,a),u.build(e,a),d.build(e,"float")):r===Re.MIX?m.push(c.build(e,a),u.build(e,a),d.build(e,e.getTypeLength(d.getNodeType(e))===1?"float":a)):(p===xr&&r===Re.ATAN&&u!==null&&(r="atan2"),e.shaderStage!=="fragment"&&(r===Re.DFDX||r===Re.DFDY)&&(Ie(`TSL: '${r}' is not supported in the ${e.shaderStage} stage.`),r="/*"+r+"*/"),m.push(c.build(e,a)),u!==null&&m.push(u.build(e,a)),d!==null&&m.push(d.build(e,a))),e.format(`${e.getMethod(r,o)}( ${m.join(", ")} )`,o,t)}}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}Re.ALL="all",Re.ANY="any",Re.RADIANS="radians",Re.DEGREES="degrees",Re.EXP="exp",Re.EXP2="exp2",Re.LOG="log",Re.LOG2="log2",Re.SQRT="sqrt",Re.INVERSE_SQRT="inversesqrt",Re.FLOOR="floor",Re.CEIL="ceil",Re.NORMALIZE="normalize",Re.FRACT="fract",Re.SIN="sin",Re.COS="cos",Re.TAN="tan",Re.ASIN="asin",Re.ACOS="acos",Re.ATAN="atan",Re.ABS="abs",Re.SIGN="sign",Re.LENGTH="length",Re.NEGATE="negate",Re.ONE_MINUS="oneMinus",Re.DFDX="dFdx",Re.DFDY="dFdy",Re.ROUND="round",Re.RECIPROCAL="reciprocal",Re.TRUNC="trunc",Re.FWIDTH="fwidth",Re.TRANSPOSE="transpose",Re.DETERMINANT="determinant",Re.INVERSE="inverse",Re.EQUALS="equals",Re.MIN="min",Re.MAX="max",Re.STEP="step",Re.REFLECT="reflect",Re.DISTANCE="distance",Re.DIFFERENCE="difference",Re.DOT="dot",Re.CROSS="cross",Re.POW="pow",Re.TRANSFORM_DIRECTION="transformDirection",Re.MIX="mix",Re.CLAMP="clamp",Re.REFRACT="refract",Re.SMOOTHSTEP="smoothstep",Re.FACEFORWARD="faceforward";const rT=q(1e-6),Dz=q(1e6),mv=q(Math.PI),Fz=q(Math.PI*2),Bz=q(Math.PI*2),Oz=q(Math.PI*.5),GC=pt(Re,Re.ALL).setParameterLength(1),WC=pt(Re,Re.ANY).setParameterLength(1),HC=pt(Re,Re.RADIANS).setParameterLength(1),$C=pt(Re,Re.DEGREES).setParameterLength(1),oT=pt(Re,Re.EXP).setParameterLength(1),Qm=pt(Re,Re.EXP2).setParameterLength(1),gv=pt(Re,Re.LOG).setParameterLength(1),Cc=pt(Re,Re.LOG2).setParameterLength(1),Qr=pt(Re,Re.SQRT).setParameterLength(1),aT=pt(Re,Re.INVERSE_SQRT).setParameterLength(1),Rc=pt(Re,Re.FLOOR).setParameterLength(1),yv=pt(Re,Re.CEIL).setParameterLength(1),go=pt(Re,Re.NORMALIZE).setParameterLength(1),El=pt(Re,Re.FRACT).setParameterLength(1),yo=pt(Re,Re.SIN).setParameterLength(1),Cl=pt(Re,Re.COS).setParameterLength(1),qC=pt(Re,Re.TAN).setParameterLength(1),XC=pt(Re,Re.ASIN).setParameterLength(1),lT=pt(Re,Re.ACOS).setParameterLength(1),_v=pt(Re,Re.ATAN).setParameterLength(1,2),qi=pt(Re,Re.ABS).setParameterLength(1),cT=pt(Re,Re.SIGN).setParameterLength(1),Nc=pt(Re,Re.LENGTH).setParameterLength(1),uT=pt(Re,Re.NEGATE).setParameterLength(1),jC=pt(Re,Re.ONE_MINUS).setParameterLength(1),hT=pt(Re,Re.DFDX).setParameterLength(1),dT=pt(Re,Re.DFDY).setParameterLength(1),YC=pt(Re,Re.ROUND).setParameterLength(1),ZC=pt(Re,Re.RECIPROCAL).setParameterLength(1),fT=pt(Re,Re.TRUNC).setParameterLength(1),pT=pt(Re,Re.FWIDTH).setParameterLength(1),KC=pt(Re,Re.TRANSPOSE).setParameterLength(1),JC=pt(Re,Re.DETERMINANT).setParameterLength(1),QC=pt(Re,Re.INVERSE).setParameterLength(1),eR=(i,e)=>(Ie('TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),iT(i,e)),ko=pt(Re,Re.MIN).setParameterLength(2,1/0),vs=pt(Re,Re.MAX).setParameterLength(2,1/0),xv=pt(Re,Re.STEP).setParameterLength(2),tR=pt(Re,Re.REFLECT).setParameterLength(2),nR=pt(Re,Re.DISTANCE).setParameterLength(2),iR=pt(Re,Re.DIFFERENCE).setParameterLength(2),qa=pt(Re,Re.DOT).setParameterLength(2),nh=pt(Re,Re.CROSS).setParameterLength(2),Xa=pt(Re,Re.POW).setParameterLength(2),mT=i=>Bn(i,i),sR=i=>Bn(i,i,i),gT=i=>Bn(i,i,i,i),rR=pt(Re,Re.TRANSFORM_DIRECTION).setParameterLength(2),oR=i=>Bn(cT(i),Xa(qi(i),1/3)),yT=i=>qa(i,i),oi=pt(Re,Re.MIX).setParameterLength(3),Rl=(i,e=0,t=1)=>Nt(new Re(Re.CLAMP,Nt(i),Nt(e),Nt(t))),vv=i=>Rl(i),_T=pt(Re,Re.REFRACT).setParameterLength(3),ga=pt(Re,Re.SMOOTHSTEP).setParameterLength(3),xT=pt(Re,Re.FACEFORWARD).setParameterLength(3),aR=me(([i])=>{const n=43758.5453,r=qa(i.xy,lt(12.9898,78.233)),o=yy(r,mv);return El(yo(o).mul(n))}),lR=(i,e,t)=>oi(e,t,i),cR=(i,e,t)=>ga(e,t,i),uR=(i,e)=>xv(e,i),hR=(i,e)=>(Ie('TSL: "atan2" is overloaded. Use "atan" instead.'),_v(i,e)),Uz=xT,kz=aT;We("all",GC),We("any",WC),We("equals",eR),We("radians",HC),We("degrees",$C),We("exp",oT),We("exp2",Qm),We("log",gv),We("log2",Cc),We("sqrt",Qr),We("inverseSqrt",aT),We("floor",Rc),We("ceil",yv),We("normalize",go),We("fract",El),We("sin",yo),We("cos",Cl),We("tan",qC),We("asin",XC),We("acos",lT),We("atan",_v),We("abs",qi),We("sign",cT),We("length",Nc),We("lengthSq",yT),We("negate",uT),We("oneMinus",jC),We("dFdx",hT),We("dFdy",dT),We("round",YC),We("reciprocal",ZC),We("trunc",fT),We("fwidth",pT),We("atan2",hR),We("min",ko),We("max",vs),We("step",uR),We("reflect",tR),We("distance",nR),We("dot",qa),We("cross",nh),We("pow",Xa),We("pow2",mT),We("pow3",sR),We("pow4",gT),We("transformDirection",rR),We("mix",lR),We("clamp",Rl),We("refract",_T),We("smoothstep",cR),We("faceForward",xT),We("difference",iR),We("saturate",vv),We("cbrt",oR),We("transpose",KC),We("determinant",JC),We("inverse",QC),We("rand",aR);class zz extends Xt{static get type(){return"ConditionalNode"}constructor(e,t,n=null){super(),this.condNode=e,this.ifNode=t,this.elseNode=n}getNodeType(e){const{ifNode:t,elseNode:n}=e.getNodeProperties(this);if(t===void 0)return e.flowBuildStage(this,"setup"),this.getNodeType(e);const r=t.getNodeType(e);if(n!==null){const o=n.getNodeType(e);if(e.getTypeLength(o)>e.getTypeLength(r))return o}return r}setup(e){const t=this.condNode,n=this.ifNode.isolate(),r=this.elseNode?this.elseNode.isolate():null,o=e.context.nodeBlock;e.getDataFromNode(n).parentNodeBlock=o,r!==null&&(e.getDataFromNode(r).parentNodeBlock=o);const a=e.context.uniformFlow,c=e.getNodeProperties(this);c.condNode=t,c.ifNode=a?n:n.context({nodeBlock:n}),c.elseNode=r?a?r:r.context({nodeBlock:r}):null}generate(e,t){const n=this.getNodeType(e),r=e.getDataFromNode(this);if(r.nodeProperty!==void 0)return r.nodeProperty;const{condNode:o,ifNode:a,elseNode:c}=e.getNodeProperties(this),u=e.currentFunctionNode,d=t!=="void",p=d?Al(n).build(e):"";r.nodeProperty=p;const m=o.build(e,"bool");if(e.context.uniformFlow&&c!==null){const v=a.build(e,n),w=c.build(e,n),M=e.getTernary(m,v,w);return e.format(M,n,t)}e.addFlowCode(`
${e.tab}if ( ${m} ) {
`).addFlowTab();let x=a.build(e,n);if(x&&(d?x=p+" = "+x+";":(x="return "+x+";",u===null&&(Ie("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),x="// "+x))),e.removeFlowTab().addFlowCode(e.tab+" "+x+`
`+e.tab+"}"),c!==null){e.addFlowCode(` else {
`).addFlowTab();let v=c.build(e,n);v&&(d?v=p+" = "+v+";":(v="return "+v+";",u===null&&(Ie("TSL: Return statement used in an inline 'Fn()'. Define a layout struct to allow return values."),v="// "+v))),e.removeFlowTab().addFlowCode(e.tab+" "+v+`
`+e.tab+`}
`)}else e.addFlowCode(`
`);return e.format(p,n,t)}}const Gr=Fn(zz).setParameterLength(2,3);We("select",Gr);class dR extends Xt{static get type(){return"ContextNode"}constructor(e=null,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}getFlowContextData(){const e=[];return this.traverse(t=>{t.isContextNode===!0&&e.push(t.value)}),Object.assign({},...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 n=e.addContext(this.value),r=this.node.build(e,t);return e.setContext(n),r}}const ih=(i=null,e={})=>{let t=i;return(t===null||t.isNode!==!0)&&(e=t||e,t=null),new dR(t,e)},fR=i=>ih(i,{uniformFlow:!0}),vT=(i,e)=>ih(i,{nodeName:e});function pR(i,e,t=null){return ih(t,{getShadow:({light:n,shadowColorNode:r})=>e===n?r.mul(i):r})}function mR(i,e=null){return ih(e,{getAO:(t,{material:n})=>n.transparent===!0?t:t!==null?t.mul(i):i})}function gR(i,e){return Ie('TSL: "label()" has been deprecated. Use "setName()" instead.'),vT(i,e)}We("context",ih),We("label",gR),We("uniformFlow",fR),We("setName",vT),We("builtinShadowContext",(i,e,t)=>pR(e,t,i)),We("builtinAOContext",(i,e)=>mR(e,i));class bv extends Xt{static get type(){return"VarNode"}constructor(e,t=null,n=!1){super(),this.node=e,this.name=t,this.global=!0,this.isVarNode=!0,this.readOnly=n,this.parents=!0,this.intent=!1}setIntent(e){return this.intent=e,this}isIntent(e){return e.getDataFromNode(this).forceDeclaration===!0?!1:this.intent}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){return e.getDataFromNode(this).assign}build(...e){const t=e[0];if(this._hasStack(t)===!1&&t.buildStage==="setup"&&(t.context.nodeLoop||t.context.nodeBlock)){let n=!1;if(this.node.isShaderCallNodeInternal&&this.node.shaderNode.getLayout()===null&&t.fnCall&&t.fnCall.shaderNode&&t.getDataFromNode(this.node.shaderNode).hasLoop){const a=t.getDataFromNode(this);a.forceDeclaration=!0,n=!0}const r=t.getBaseStack();n?r.addToStackBefore(this):r.addToStack(this)}return this.isIntent(t)&&this.isAssign(t)!==!0?this.node.build(...e):super.build(...e)}generate(e){const{node:t,name:n,readOnly:r}=this,{renderer:o}=e,a=o.backend.isWebGPUBackend===!0;let c=!1,u=!1;r&&(c=e.isDeterministic(t),u=a?r:c);const d=this.getNodeType(e);if(d=="void")return this.isIntent(e)!==!0&&Be('TSL: ".toVar()" can not be used with void type.'),t.build(e);const p=e.getVectorType(d),m=t.build(e,p),y=e.getVarFromNode(this,n,p,void 0,u),x=e.getPropertyName(y);let v=x;if(u)if(a)v=c?`const ${x}`:`let ${x}`;else{const w=t.getArrayCount(e);v=`const ${e.getVar(y.type,x,w)}`}return e.addLineFlowCode(`${v} = ${m}`,this),x}_hasStack(e){return e.getDataFromNode(this).stack!==void 0}}const bT=Fn(bv),yR=(i,e=null)=>bT(i,e).toStack(),_R=(i,e=null)=>bT(i,e,!0).toStack(),xR=i=>bT(i).setIntent(!0).toStack();We("toVar",yR),We("toConst",_R),We("toVarIntent",xR);class Vz extends Xt{static get type(){return"SubBuild"}constructor(e,t,n=null){super(n),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 n=this.node.build(e,...t);return e.removeSubBuild(),n}}const eg=(i,e,t=null)=>Nt(new Vz(Nt(i),e,t));class Gz extends Xt{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 n=t.varying;if(n===void 0){const r=this.name,o=this.getNodeType(e),a=this.interpolationType,c=this.interpolationSampling;t.varying=n=e.getVaryingFromNode(this,r,o,a,c),t.node=eg(this.node,"VERTEX")}return n.needsInterpolation||(n.needsInterpolation=e.shaderStage==="fragment"),n}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(ay.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(ay.VERTEX,this.node)}generate(e){const t=e.getSubBuildProperty("property",e.currentStack),n=e.getNodeProperties(this),r=this.setupVarying(e);if(n[t]===void 0){const o=this.getNodeType(e),a=e.getPropertyName(r,ay.VERTEX);e.flowNodeFromShaderStage(ay.VERTEX,n.node,o,a),n[t]=a}return e.getPropertyName(r)}}const Pc=Fn(Gz).setParameterLength(1,2),vR=i=>Pc(i);We("toVarying",Pc),We("toVertexStage",vR),We("varying",(...i)=>(Ie("TSL: .varying() has been renamed to .toVarying()."),Pc(...i))),We("vertexStage",(...i)=>(Ie("TSL: .vertexStage() has been renamed to .toVertexStage()."),Pc(...i)));const bR=me(([i])=>{const e=i.mul(.9478672986).add(.0521327014).pow(2.4),t=i.mul(.0773993808),n=i.lessThanEqual(.04045);return oi(e,t,n)}).setLayout({name:"sRGBTransferEOTF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),SR=me(([i])=>{const e=i.pow(.41666).mul(1.055).sub(.055),t=i.mul(12.92),n=i.lessThanEqual(.0031308);return oi(e,t,n)}).setLayout({name:"sRGBTransferOETF",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),ST="WorkingColorSpace",Wz="OutputColorSpace";class MT extends _s{static get type(){return"ColorSpaceNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.source=t,this.target=n}resolveColorSpace(e,t){return t===ST?xn.workingColorSpace:t===Wz?e.context.outputColorSpace||e.renderer.outputColorSpace:t}setup(e){const{colorNode:t}=this,n=this.resolveColorSpace(e,this.source),r=this.resolveColorSpace(e,this.target);let o=t;return xn.enabled===!1||n===r||!n||!r||(xn.getTransfer(n)===$t&&(o=zt(bR(o.rgb),o.a)),xn.getPrimaries(n)!==xn.getPrimaries(r)&&(o=zt(Vr(xn._getMatrix(new Nn,n,r)).mul(o.rgb),o.a)),xn.getTransfer(r)===$t&&(o=zt(SR(o.rgb),o.a))),o}}const MR=(i,e)=>Nt(new MT(Nt(i),ST,e)),Sv=(i,e)=>Nt(new MT(Nt(i),e,ST)),Hz=(i,e,t)=>Nt(new MT(Nt(i),e,t));We("workingToColorSpace",MR),We("colorSpaceToWorking",Sv);let $z=class extends Qf{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),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}};class TR extends Xt{static get type(){return"ReferenceBaseNode"}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.updateType=Xn.OBJECT}setGroup(e){return this.group=e,this}element(e){return new $z(this,Nt(e))}setNodeType(e){const t=rn(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 n=e[t[0]];for(let r=1;r<t.length;r++)n=n[t[r]];return n}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 qz=(i,e,t)=>new TR(i,e,t);class Xz extends TR{static get type(){return"RendererReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(an)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const wR=(i,e,t=null)=>new Xz(i,e,t);class jz extends _s{static get type(){return"ToneMappingNode"}constructor(e,t=ER,n=null){super("vec3"),this._toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return Ym(this._toneMapping)}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup(e){const t=this.colorNode||e.context.color,n=this._toneMapping;if(n===yr)return t;let r=null;const o=e.renderer.library.getToneMappingFunction(n);return o!==null?r=zt(o(t.rgb,this.exposureNode),t.a):(Be("ToneMappingNode: Unsupported Tone Mapping configuration.",n),r=t),r}}const AR=(i,e,t)=>Nt(new jz(i,Nt(e),Nt(t))),ER=wR("toneMappingExposure","float");We("toneMapping",(i,e,t)=>AR(e,t,i));const CR=new WeakMap;function RR(i,e){let t=CR.get(i);return t===void 0&&(t=new ml(i,e),CR.set(i,t)),t}class Wd extends kM{static get type(){return"BufferAttributeNode"}constructor(e,t=null,n=0,r=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferStride=n,this.bufferOffset=r,this.usage=jh,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&e.itemSize<=4&&(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),n=e.getTypeLength(t),r=this.value,o=this.bufferStride||n,a=this.bufferOffset;let c;r.isInterleavedBuffer===!0?c=r:r.isBufferAttribute===!0?c=RR(r.array,o):c=RR(r,o);const u=new sc(c,n,a);c.setUsage(this.usage),this.attribute=u,this.attribute.isInstancedBufferAttribute=this.instanced}generate(e){const t=this.getNodeType(e),n=e.getBufferAttributeFromNode(this,t),r=e.getPropertyName(n);let o=null;return e.shaderStage==="vertex"||e.shaderStage==="compute"?(this.name=r,o=r):o=Pc(this).build(e,t),o}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}}function Mv(i,e=null,t=0,n=0,r=jh,o=!1){return e==="mat3"||e===null&&i.itemSize===9?Vr(new Wd(i,"vec3",9,0).setUsage(r).setInstanced(o),new Wd(i,"vec3",9,3).setUsage(r).setInstanced(o),new Wd(i,"vec3",9,6).setUsage(r).setInstanced(o)):e==="mat4"||e===null&&i.itemSize===16?kd(new Wd(i,"vec4",16,0).setUsage(r).setInstanced(o),new Wd(i,"vec4",16,4).setUsage(r).setInstanced(o),new Wd(i,"vec4",16,8).setUsage(r).setInstanced(o),new Wd(i,"vec4",16,12).setUsage(r).setInstanced(o)):new Wd(i,e,t,n)}const TT=(i,e=null,t=0,n=0)=>Mv(i,e,t,n),Yz=(i,e=null,t=0,n=0)=>Mv(i,e,t,n,Yh),Tv=(i,e=null,t=0,n=0)=>Mv(i,e,t,n,jh,!0),wT=(i,e=null,t=0,n=0)=>Mv(i,e,t,n,Yh,!0);We("toAttribute",i=>TT(i.value));class Zz extends Xt{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 Ie('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 n=e.getNodeProperties(this);n.outputComputeNode=t.outputNode,t.outputNode=null}return t}generate(e,t){const{shaderStage:n}=e;if(n==="compute"){const r=this.computeNode.build(e,"void");r!==""&&e.addLineFlowCode(r,this)}else{const o=e.getNodeProperties(this).outputComputeNode;if(o)return o.build(e,t)}}}const AT=(i,e=[64])=>{(e.length===0||e.length>3)&&Be("TSL: compute() workgroupSize must have 1, 2, or 3 elements");for(let t=0;t<e.length;t++){const n=e[t];(typeof n!="number"||n<=0||!Number.isInteger(n))&&Be(`TSL: compute() workgroupSize element at index [ ${t} ] must be a positive integer`)}for(;e.length<3;)e.push(1);return Nt(new Zz(Nt(i),e))},NR=(i,e,t)=>AT(i,t).setCount(e);We("compute",NR),We("computeKernel",AT);class Kz extends Xt{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(),n=e.getCacheFromNode(this,this.parent);e.setCache(n);const r=this.node.getNodeType(e);return e.setCache(t),r}build(e,...t){const n=e.getCache(),r=e.getCacheFromNode(this,this.parent);e.setCache(r);const o=this.node.build(e,...t);return e.setCache(n),o}setParent(e){return this.parent=e,this}getParent(){return this.parent}}const tg=i=>new Kz(Nt(i));function PR(i,e=!0){return Ie('TSL: "cache()" has been deprecated. Use "isolate()" instead.'),tg(i).setParent(e)}We("cache",PR),We("isolate",tg);class Jz extends Xt{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 IR=Fn(Jz).setParameterLength(2);We("bypass",IR);class LR extends Xt{static get type(){return"RemapNode"}constructor(e,t,n,r=q(0),o=q(1)){super(),this.node=e,this.inLowNode=t,this.inHighNode=n,this.outLowNode=r,this.outHighNode=o,this.doClamp=!0}setup(){const{node:e,inLowNode:t,inHighNode:n,outLowNode:r,outHighNode:o,doClamp:a}=this;let c=e.sub(t).div(n.sub(t));return a===!0&&(c=c.clamp()),c.mul(o.sub(r)).add(r)}}const DR=Fn(LR,null,null,{doClamp:!1}).setParameterLength(3,5),FR=Fn(LR).setParameterLength(3,5);We("remap",DR),We("remapClamp",FR);class wv extends Xt{static get type(){return"ExpressionNode"}constructor(e="",t="void"){super(t),this.snippet=e}generate(e,t){const n=this.getNodeType(e),r=this.snippet;if(n==="void")e.addLineFlowCode(r,this);else return e.format(r,n,t)}}const sh=Fn(wv).setParameterLength(1,2),BR=i=>(i?Gr(i,sh("discard")):sh("discard")).toStack(),Qz=()=>sh("return").toStack();We("discard",BR);class eV extends _s{static get type(){return"RenderOutputNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this._toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setToneMapping(e){return this._toneMapping=e,this}getToneMapping(){return this._toneMapping}setup({context:e}){let t=this.colorNode||e.color;const n=(this._toneMapping!==null?this._toneMapping:e.toneMapping)||yr,r=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||_r;return n!==yr&&(t=t.toneMapping(n)),r!==_r&&r!==xn.workingColorSpace&&(t=t.workingToColorSpace(r)),t}}const ET=(i,e=null,t=null)=>Nt(new eV(Nt(i),e,t));We("renderOutput",ET);class tV extends _s{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,n=this.node.build(e),r="--- TSL debug - "+e.shaderStage+" shader ---",o="-".repeat(r.length);let a="";return a+="// #"+r+`#
`,a+=e.flow.code.replace(/^\t/mg,"")+`
`,a+="/* ... */ "+n+` /* ... */
`,a+="// #"+o+`#
`,t!==null?t(e,a):Ko(a),n}}const OR=(i,e=null)=>Nt(new tV(Nt(i),e)).toStack();We("debug",OR);class UR{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 nV extends Xt{static get type(){return"InspectorNode"}constructor(e,t="",n=null){super(),this.node=e,this.name=t,this.callback=n,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!==UR&&Ut('TSL: ".toInspector()" is only available with WebGPU.'),t}}function kR(i,e="",t=null){return i=Nt(i),i.before(new nV(i,e,t))}We("toInspector",kR);function iV(i){Ie("TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",i)}class zR extends Xt{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 n=this.getAttributeName(e);if(e.hasGeometryAttribute(n)){const r=e.geometry.getAttribute(n);t=e.getTypeFromAttribute(r)}else t="float"}return t}setAttributeName(e){return this._attributeName=e,this}getAttributeName(){return this._attributeName}generate(e){const t=this.getAttributeName(e),n=this.getNodeType(e);if(e.hasGeometryAttribute(t)===!0){const o=e.geometry.getAttribute(t),a=e.getTypeFromAttribute(o),c=e.getAttribute(t,a);return e.shaderStage==="vertex"?e.format(c.name,a,n):Pc(this).build(e,n)}else return Ie(`AttributeNode: Vertex attribute "${t}" not found on geometry.`),e.generateConst(n)}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 _o=(i,e=null)=>new zR(i,e),Pi=(i=0)=>_o("uv"+(i>0?i:""),"vec2");class sV extends Xt{static get type(){return"TextureSizeNode"}constructor(e,t=null){super("uvec2"),this.isTextureSizeNode=!0,this.textureNode=e,this.levelNode=t}generate(e,t){const n=this.textureNode.build(e,"property"),r=this.levelNode===null?"0":this.levelNode.build(e,"int");return e.format(`${e.getMethod("textureDimensions")}( ${n}, ${r} )`,this.getNodeType(e),t)}}const rh=Fn(sV).setParameterLength(1,2);class rV extends gy{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,n=t&&t.length>0?t[0]&&t[0].image||t[0]:e.image;if(n&&n.width!==void 0){const{width:r,height:o}=n;this.value=Math.log2(Math.max(r,o))}}}const CT=Fn(rV).setParameterLength(1),RT=new fi;class Ic extends gy{static get type(){return"TextureNode"}constructor(e=RT,t=null,n=null,r=null){super(e),this.isTextureNode=!0,this.uvNode=t,this.levelNode=n,this.biasNode=r,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===yi?"uvec4":this.value.type===er?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return Pi(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=rn(this.value.matrix)),this._matrixUniform.mul(he(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this}setupUV(e,t){return e.isFlipY()&&(this._flipYUniform===null&&(this._flipYUniform=rn(!1)),t=t.toVar(),this.sampler?t=this._flipYUniform.select(t.flipY(),t):t=this._flipYUniform.select(t.setY(le(rh(this,this.levelNode).y).sub(t.y).sub(1)),t)),t}setup(e){const t=e.getNodeProperties(this);t.referenceNode=this.referenceNode;const n=this.value;if(!n||n.isTexture!==!0)throw new Error("THREE.TSL: `texture( value )` function expects a valid instance of THREE.Texture().");const r=me(()=>{let a=this.uvNode;return(a===null||e.context.forceUVContext===!0)&&e.context.getUV&&(a=e.context.getUV(this,e)),a||(a=this.getDefaultUV()),this.updateMatrix===!0&&(a=this.getTransformedUV(a)),a=this.setupUV(e,a),this.updateType=this._matrixUniform!==null||this._flipYUniform!==null?Xn.OBJECT:Xn.NONE,a})();let o=this.levelNode;o===null&&e.context.getTextureLevel&&(o=e.context.getTextureLevel(this)),t.uvNode=r,t.levelNode=o,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,n,r,o,a,c,u,d){const p=this.value;let m;return o?m=e.generateTextureBias(p,t,n,o,a,d):u?m=e.generateTextureGrad(p,t,n,u,a,d):c?m=e.generateTextureCompare(p,t,n,c,a,d):this.sampler===!1?m=e.generateTextureLoad(p,t,n,r,a,d):r?m=e.generateTextureLevel(p,t,n,r,a,d):m=e.generateTexture(p,t,n,a,d),m}generate(e,t){const n=this.value,r=e.getNodeProperties(this),o=super.generate(e,"property");if(/^sampler/.test(t))return o+"_sampler";if(e.isReference(t))return o;{const a=e.getDataFromNode(this);let c=a.propertyName;if(c===void 0){const{uvNode:p,levelNode:m,biasNode:y,compareNode:x,depthNode:v,gradNode:w,offsetNode:M}=r,S=this.generateUV(e,p),C=m?m.build(e,"float"):null,N=y?y.build(e,"float"):null,I=v?v.build(e,"int"):null,U=x?x.build(e,"float"):null,F=w?[w[0].build(e,"vec2"),w[1].build(e,"vec2")]:null,k=M?this.generateOffset(e,M):null,G=e.getVarFromNode(this);c=e.getPropertyName(G);const B=this.generateSnippet(e,o,S,C,N,I,U,F,k);e.addLineFlowCode(`${c} = ${B}`,this),a.snippet=B,a.propertyName=c}let u=c;const d=this.getNodeType(e);return e.needsToWorkingColorSpace(n)&&(u=Sv(sh(u,d),n.colorSpace).setup(e).build(e,d)),e.format(u,d,t)}}setSampler(e){return this.sampler=e,this}getSampler(){return this.sampler}uv(e){return Ie("TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){const t=this.clone();return t.uvNode=Nt(e),t.referenceNode=this.getBase(),Nt(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){const t=this.clone();t.biasNode=Nt(e).mul(CT(t)),t.referenceNode=this.getBase();const n=t.value;return t.generateMipmaps===!1&&(n&&n.generateMipmaps===!1||n.minFilter===ni||n.magFilter===ni)&&(Ie("TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),Nt(t)}level(e){const t=this.clone();return t.levelNode=Nt(e),t.referenceNode=this.getBase(),Nt(t)}size(e){return rh(this,e)}bias(e){const t=this.clone();return t.biasNode=Nt(e),t.referenceNode=this.getBase(),Nt(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){const t=this.clone();return t.compareNode=Nt(e),t.referenceNode=this.getBase(),Nt(t)}grad(e,t){const n=this.clone();return n.gradNode=[Nt(e),Nt(t)],n.referenceNode=this.getBase(),Nt(n)}depth(e){const t=this.clone();return t.depthNode=Nt(e),t.referenceNode=this.getBase(),Nt(t)}offset(e){const t=this.clone();return t.offsetNode=Nt(e),t.referenceNode=this.getBase(),Nt(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 n=this._flipYUniform;n!==null&&(n.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 oV=Fn(Ic).setParameterLength(1,4).setName("texture"),_i=(i=RT,e=null,t=null,n=null)=>{let r;return i&&i.isTextureNode===!0?(r=Nt(i.clone()),r.referenceNode=i.getBase(),e!==null&&(r.uvNode=Nt(e)),t!==null&&(r.levelNode=Nt(t)),n!==null&&(r.biasNode=Nt(n))):r=oV(i,e,t,n),r},aV=(i=RT)=>_i(i),Ns=(...i)=>_i(...i).setSampler(!1),lV=(i,e,t)=>_i(i,e).level(t),cV=i=>(i.isNode===!0?i:_i(i)).convert("sampler"),uV=i=>(i.isNode===!0?i:_i(i)).convert("samplerComparison");class NT extends gy{static get type(){return"BufferNode"}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n,this.updateRanges=[]}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const _y=(i,e,t)=>new NT(i,e,t);class hV extends Qf{static get type(){return"UniformArrayElementNode"}constructor(e,t){super(e,t),this.isArrayBufferElementNode=!0}generate(e){const t=super.generate(e),n=this.getNodeType(),r=this.node.getPaddedType();return e.format(t,r,n)}}class dV extends NT{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?eh(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,n=this.elementType;if(n==="float"||n==="int"||n==="uint")for(let r=0;r<e.length;r++){const o=r*4;t[o]=e[r]}else if(n==="color")for(let r=0;r<e.length;r++){const o=r*4,a=e[r];t[o]=a.r,t[o+1]=a.g,t[o+2]=a.b||0}else if(n==="mat2")for(let r=0;r<e.length;r++){const o=r*4,a=e[r];t[o]=a.elements[0],t[o+1]=a.elements[1],t[o+2]=a.elements[2],t[o+3]=a.elements[3]}else if(n==="mat3")for(let r=0;r<e.length;r++){const o=r*16,a=e[r];t[o]=a.elements[0],t[o+1]=a.elements[1],t[o+2]=a.elements[2],t[o+4]=a.elements[3],t[o+5]=a.elements[4],t[o+6]=a.elements[5],t[o+8]=a.elements[6],t[o+9]=a.elements[7],t[o+10]=a.elements[8],t[o+15]=1}else if(n==="mat4")for(let r=0;r<e.length;r++){const o=r*16,a=e[r];for(let c=0;c<a.elements.length;c++)t[o+c]=a.elements[c]}else for(let r=0;r<e.length;r++){const o=r*4,a=e[r];t[o]=a.x,t[o+1]=a.y,t[o+2]=a.z||0,t[o+3]=a.w||0}}setup(e){const t=this.array.length,n=this.elementType;let r=Float32Array;const o=this.paddedType,a=e.getTypeLength(o);return n.charAt(0)==="i"&&(r=Int32Array),n.charAt(0)==="u"&&(r=Uint32Array),this.value=new r(t*a),this.bufferCount=t,this.bufferType=o,super.setup(e)}element(e){return new hV(this,Nt(e))}}const eo=(i,e)=>new dV(i,e);class fV extends Xt{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const oh=Fn(fV).setParameterLength(1);let xy,vy;class Qi extends Xt{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}getNodeType(){return this.scope===Qi.DPR?"float":this.scope===Qi.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=Xn.NONE;return(this.scope===Qi.SIZE||this.scope===Qi.VIEWPORT||this.scope===Qi.DPR)&&(e=Xn.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===Qi.VIEWPORT?t!==null?vy.copy(t.viewport):(e.getViewport(vy),vy.multiplyScalar(e.getPixelRatio())):this.scope===Qi.DPR?this._output.value=e.getPixelRatio():t!==null?(xy.width=t.width,xy.height=t.height):e.getDrawingBufferSize(xy)}setup(){const e=this.scope;let t=null;return e===Qi.SIZE?t=rn(xy||(xy=new ze)):e===Qi.VIEWPORT?t=rn(vy||(vy=new gn)):e===Qi.DPR?t=rn(1):t=lt(ap.div(op)),this._output=t,t}generate(e){if(this.scope===Qi.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const n=e.getNodeProperties(op).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${n}.y - ${t}.y )`}return t}return super.generate(e)}}Qi.COORDINATE="coordinate",Qi.VIEWPORT="viewport",Qi.SIZE="size",Qi.UV="uv",Qi.DPR="dpr";const PT=Ct(Qi,Qi.DPR),ah=Ct(Qi,Qi.UV),op=Ct(Qi,Qi.SIZE),ap=Ct(Qi,Qi.COORDINATE),ng=Ct(Qi,Qi.VIEWPORT),IT=ng.zw,VR=ap.sub(ng.xy),pV=VR.div(IT),mV=me(()=>(Ie('TSL: "viewportResolution" is deprecated. Use "screenSize" instead.'),op),"vec2").once()(),Hd=rn(0,"uint").setName("u_cameraIndex").setGroup(pv("cameraIndex")).toVarying("v_cameraIndex"),lh=rn("float").setName("cameraNear").setGroup(an).onRenderUpdate(({camera:i})=>i.near),ch=rn("float").setName("cameraFar").setGroup(an).onRenderUpdate(({camera:i})=>i.far),xo=me(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const r of i.cameras)t.push(r.projectionMatrix);e=eo(t).setGroup(an).setName("cameraProjectionMatrices").element(i.isMultiViewCamera?oh("gl_ViewID_OVR"):Hd).toConst("cameraProjectionMatrix")}else e=rn("mat4").setName("cameraProjectionMatrix").setGroup(an).onRenderUpdate(({camera:t})=>t.projectionMatrix);return e}).once()(),gV=me(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const r of i.cameras)t.push(r.projectionMatrixInverse);e=eo(t).setGroup(an).setName("cameraProjectionMatricesInverse").element(i.isMultiViewCamera?oh("gl_ViewID_OVR"):Hd).toConst("cameraProjectionMatrixInverse")}else e=rn("mat4").setName("cameraProjectionMatrixInverse").setGroup(an).onRenderUpdate(({camera:t})=>t.projectionMatrixInverse);return e}).once()(),ya=me(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const r of i.cameras)t.push(r.matrixWorldInverse);e=eo(t).setGroup(an).setName("cameraViewMatrices").element(i.isMultiViewCamera?oh("gl_ViewID_OVR"):Hd).toConst("cameraViewMatrix")}else e=rn("mat4").setName("cameraViewMatrix").setGroup(an).onRenderUpdate(({camera:t})=>t.matrixWorldInverse);return e}).once()(),yV=me(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const r of i.cameras)t.push(r.matrixWorld);e=eo(t).setGroup(an).setName("cameraWorldMatrices").element(i.isMultiViewCamera?oh("gl_ViewID_OVR"):Hd).toConst("cameraWorldMatrix")}else e=rn("mat4").setName("cameraWorldMatrix").setGroup(an).onRenderUpdate(({camera:t})=>t.matrixWorld);return e}).once()(),_V=me(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const r of i.cameras)t.push(r.normalMatrix);e=eo(t).setGroup(an).setName("cameraNormalMatrices").element(i.isMultiViewCamera?oh("gl_ViewID_OVR"):Hd).toConst("cameraNormalMatrix")}else e=rn("mat3").setName("cameraNormalMatrix").setGroup(an).onRenderUpdate(({camera:t})=>t.normalMatrix);return e}).once()(),by=me(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(let r=0,o=i.cameras.length;r<o;r++)t.push(new H);e=eo(t).setGroup(an).setName("cameraPositions").onRenderUpdate(({camera:r},o)=>{const a=r.cameras,c=o.array;for(let u=0,d=a.length;u<d;u++)c[u].setFromMatrixPosition(a[u].matrixWorld)}).element(i.isMultiViewCamera?oh("gl_ViewID_OVR"):Hd).toConst("cameraPosition")}else e=rn(new H).setName("cameraPosition").setGroup(an).onRenderUpdate(({camera:t},n)=>n.value.setFromMatrixPosition(t.matrixWorld));return e}).once()(),xV=me(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const r of i.cameras)t.push(r.viewport);e=eo(t,"vec4").setGroup(an).setName("cameraViewports").element(Hd).toConst("cameraViewport")}else e=zt(0,0,op.x,op.y).toConst("cameraViewport");return e}).once()(),GR=new As;class hi extends Xt{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=Xn.OBJECT,this.uniformNode=new gy(null)}getNodeType(){const e=this.scope;if(e===hi.WORLD_MATRIX)return"mat4";if(e===hi.POSITION||e===hi.VIEW_POSITION||e===hi.DIRECTION||e===hi.SCALE)return"vec3";if(e===hi.RADIUS)return"float"}update(e){const t=this.object3d,n=this.uniformNode,r=this.scope;if(r===hi.WORLD_MATRIX)n.value=t.matrixWorld;else if(r===hi.POSITION)n.value=n.value||new H,n.value.setFromMatrixPosition(t.matrixWorld);else if(r===hi.SCALE)n.value=n.value||new H,n.value.setFromMatrixScale(t.matrixWorld);else if(r===hi.DIRECTION)n.value=n.value||new H,t.getWorldDirection(n.value);else if(r===hi.VIEW_POSITION){const o=e.camera;n.value=n.value||new H,n.value.setFromMatrixPosition(t.matrixWorld),n.value.applyMatrix4(o.matrixWorldInverse)}else if(r===hi.RADIUS){const o=e.object.geometry;o.boundingSphere===null&&o.computeBoundingSphere(),GR.copy(o.boundingSphere).applyMatrix4(t.matrixWorld),n.value=GR.radius}}generate(e){const t=this.scope;return t===hi.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===hi.POSITION||t===hi.VIEW_POSITION||t===hi.DIRECTION||t===hi.SCALE?this.uniformNode.nodeType="vec3":t===hi.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}}hi.WORLD_MATRIX="worldMatrix",hi.POSITION="position",hi.SCALE="scale",hi.VIEW_POSITION="viewPosition",hi.DIRECTION="direction",hi.RADIUS="radius";const vV=Fn(hi,hi.DIRECTION).setParameterLength(1),bV=Fn(hi,hi.WORLD_MATRIX).setParameterLength(1),WR=Fn(hi,hi.POSITION).setParameterLength(1),SV=Fn(hi,hi.SCALE).setParameterLength(1),MV=Fn(hi,hi.VIEW_POSITION).setParameterLength(1),TV=Fn(hi,hi.RADIUS).setParameterLength(1);class ja extends hi{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const wV=Ct(ja,ja.DIRECTION),Ya=Ct(ja,ja.WORLD_MATRIX),AV=Ct(ja,ja.POSITION),EV=Ct(ja,ja.SCALE),CV=Ct(ja,ja.VIEW_POSITION),HR=Ct(ja,ja.RADIUS),$R=rn(new Nn).onObjectUpdate(({object:i},e)=>e.value.getNormalMatrix(i.matrixWorld)),RV=rn(new Qt).onObjectUpdate(({object:i},e)=>e.value.copy(i.matrixWorld).invert()),Lc=me(i=>i.context.modelViewMatrix||qR).once()().toVar("modelViewMatrix"),qR=ya.mul(Ya),LT=me(i=>(i.context.isHighPrecisionModelViewMatrix=!0,rn("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),DT=me(i=>{const e=i.context.isHighPrecisionModelViewMatrix;return rn("mat3").onObjectUpdate(({object:t,camera:n})=>(e!==!0&&t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),Wr=_o("position","vec3"),bs=Wr.toVarying("positionLocal"),Av=Wr.toVarying("positionPrevious"),_a=me(i=>Ya.mul(bs).xyz.toVarying(i.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),FT=me(()=>bs.transformDirection(Ya).toVarying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),"vec3").once(["POSITION"])(),Us=me(i=>i.context.setupPositionView().toVarying("v_positionView"),"vec3").once(["POSITION"])(),Bi=me(i=>{let e;return i.camera.isOrthographicCamera?e=he(0,0,1):e=Us.negate().toVarying("v_positionViewDirection").normalize(),e.toVar("positionViewDirection")},"vec3").once(["POSITION"])();class NV extends Xt{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===we?"false":e.getFrontFacing()}}const XR=Ct(NV),BT=q(XR).mul(2).sub(1),ig=me(([i],{material:e})=>{const t=e.side;return t===we?i=i.mul(-1):t===Ae&&(i=i.mul(BT)),i}),Ev=_o("normal","vec3"),zo=me(i=>i.geometry.hasAttribute("normal")===!1?(Ie('TSL: Vertex attribute "normal" not found on geometry.'),he(0,1,0)):Ev,"vec3").once()().toVar("normalLocal"),jR=Us.dFdx().cross(Us.dFdy()).normalize().toVar("normalFlat"),sg=me(i=>{let e;return i.material.flatShading===!0?e=jR:e=OT(zo).toVarying("v_normalViewGeometry").normalize(),e},"vec3").once()().toVar("normalViewGeometry"),YR=me(i=>{let e=sg.transformDirection(ya);return i.material.flatShading!==!0&&(e=e.toVarying("v_normalWorldGeometry")),e.normalize().toVar("normalWorldGeometry")},"vec3").once()(),mi=me(({subBuildFn:i,material:e,context:t})=>{let n;return i==="NORMAL"||i==="VERTEX"?(n=sg,e.flatShading!==!0&&(n=ig(n))):n=t.setupNormal().context({getUV:null}),n},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),$d=mi.transformDirection(ya).toVar("normalWorld"),lp=me(({subBuildFn:i,context:e})=>{let t;return i==="NORMAL"||i==="VERTEX"?t=mi:t=e.setupClearcoatNormal().context({getUV:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),ZR=me(([i,e=Ya])=>{const t=Vr(e),n=i.div(he(t[0].dot(t[0]),t[1].dot(t[1]),t[2].dot(t[2])));return t.mul(n).xyz}),OT=me(([i],e)=>{const t=e.context.modelNormalViewMatrix;if(t)return t.transformDirection(i);const n=$R.mul(i);return ya.transformDirection(n)}),PV=me(()=>(Ie('TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),mi)).once(["NORMAL","VERTEX"])(),IV=me(()=>(Ie('TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),$d)).once(["NORMAL","VERTEX"])(),LV=me(()=>(Ie('TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),lp)).once(["NORMAL","VERTEX"])(),KR=new jr,UT=new Qt,JR=rn(0).onReference(({material:i})=>i).onObjectUpdate(({material:i})=>i.refractionRatio),Cv=rn(1).onReference(({material:i})=>i).onObjectUpdate(function({material:i,scene:e}){return i.envMap?i.envMapIntensity:e.environmentIntensity}),kT=rn(new Qt).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?(KR.copy(t),UT.makeRotationFromEuler(KR)):UT.identity(),UT}),QR=Bi.negate().reflect(mi),eN=Bi.negate().refract(mi,JR),tN=QR.transformDirection(ya).toVar("reflectVector"),nN=eN.transformDirection(ya).toVar("reflectVector"),iN=new nc;class DV extends Ic{static get type(){return"CubeTextureNode"}constructor(e,t=null,n=null,r=null){super(e,t,n,r),this.isCubeTextureNode=!0}getInputType(){return this.value.isDepthTexture===!0?"cubeDepthTexture":"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===Cr?tN:e.mapping===Xo?nN:(Be('CubeTextureNode: Mapping "%s" not supported.',e.mapping),he(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return n.isDepthTexture===!0?e.renderer.coordinateSystem===xr?he(t.x,t.y.negate(),t.z):t:((e.renderer.coordinateSystem===xr||!n.isRenderTargetTexture)&&(t=he(t.x.negate(),t.yz)),kT.mul(t))}generateUV(e,t){return t.build(e,this.sampler===!0?"vec3":"ivec3")}}const zT=Fn(DV).setParameterLength(1,4).setName("cubeTexture"),vo=(i=iN,e=null,t=null,n=null)=>{let r;return i&&i.isCubeTextureNode===!0?(r=Nt(i.clone()),r.referenceNode=i,e!==null&&(r.uvNode=Nt(e)),t!==null&&(r.levelNode=Nt(t)),n!==null&&(r.biasNode=Nt(n))):r=zT(i,e,t,n),r},FV=(i=iN)=>zT(i);class BV extends Qf{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),n=this.referenceNode.getNodeType(),r=this.getNodeType();return e.format(t,n,r)}}class Rv extends Xt{static get type(){return"ReferenceNode"}constructor(e,t,n=null,r=null){super(),this.property=e,this.uniformType=t,this.object=n,this.count=r,this.properties=e.split("."),this.reference=n,this.node=null,this.group=null,this.name=null,this.updateType=Xn.OBJECT}element(e){return new BV(this,Nt(e))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return Ie('TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setNodeType(e){let t=null;this.count!==null?t=_y(null,e,this.count):Array.isArray(this.getValueFromReference())?t=eo(null,e):e==="texture"?t=_i(null):e==="cubeTexture"?t=vo(null):t=rn(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 n=e[t[0]];for(let r=1;r<t.length;r++)n=n[t[r]];return n}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 Oi=(i,e,t)=>new Rv(i,e,t),VT=(i,e,t,n)=>new Rv(i,e,n,t);class OV extends Rv{static get type(){return"MaterialReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.material=n,this.isMaterialReferenceNode=!0}updateReference(e){return this.reference=this.material!==null?this.material:e.material,this.reference}}const uh=(i,e,t=null)=>new OV(i,e,t),sN=Pi(),UV=Us.dFdx(),kV=Us.dFdy(),rN=sN.dFdx(),oN=sN.dFdy(),aN=mi,lN=kV.cross(aN),cN=aN.cross(UV),GT=lN.mul(rN.x).add(cN.mul(oN.x)),WT=lN.mul(rN.y).add(cN.mul(oN.y)),uN=GT.dot(GT).max(WT.dot(WT)),hN=uN.equal(0).select(0,uN.inverseSqrt()),zV=GT.mul(hN).toVar("tangentViewFrame"),VV=WT.mul(hN).toVar("bitangentViewFrame"),Nv=_o("tangent","vec4"),Sy=Nv.xyz.toVar("tangentLocal"),Pv=me(({subBuildFn:i,geometry:e,material:t})=>{let n;return i==="VERTEX"||e.hasAttribute("tangent")?n=Lc.mul(zt(Sy,0)).xyz.toVarying("v_tangentView").normalize():n=zV,t.flatShading!==!0&&(n=ig(n)),n},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),dN=Pv.transformDirection(ya).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),Iv=me(([i,e],{subBuildFn:t,material:n})=>{let r=i.mul(Nv.w).xyz;return t==="NORMAL"&&n.flatShading!==!0&&(r=r.toVarying(e)),r}).once(["NORMAL"]),GV=Iv(Ev.cross(Nv),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),WV=Iv(zo.cross(Sy),"v_bitangentLocal").normalize().toVar("bitangentLocal"),fN=me(({subBuildFn:i,geometry:e,material:t})=>{let n;return i==="VERTEX"||e.hasAttribute("tangent")?n=Iv(mi.cross(Pv),"v_bitangentView").normalize():n=VV,t.flatShading!==!0&&(n=ig(n)),n},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),HV=Iv($d.cross(dN),"v_bitangentWorld").normalize().toVar("bitangentWorld"),cp=Vr(Pv,fN,mi).toVar("TBNViewMatrix"),pN=Bi.mul(cp),$V=(i,e)=>i.sub(pN.mul(e)),mN=me(()=>{let i=ip.cross(Bi);return i=i.cross(ip).normalize(),i=oi(i,mi,Vd.mul(Ec.oneMinus()).oneMinus().pow2().pow2()).normalize(),i}).once()(),gN=i=>Nt(i).mul(.5).add(.5),qV=i=>Nt(i).mul(2).sub(1),HT=i=>he(i,Qr(vv(q(1).sub(qa(i,i)))));class XV extends _s{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=Yo,this.unpackNormalMode=p_}setup({material:e}){const{normalMapType:t,scaleNode:n,unpackNormalMode:r}=this;let o=this.node.mul(2).sub(1);if(t===Yo?r===Yb?o=HT(o.xy):r===sA?o=HT(o.yw):r!==p_&&console.error(`THREE.NodeMaterial: Unexpected unpack normal mode: ${r}`):r!==p_&&console.error(`THREE.NodeMaterial: Normal map type '${t}' is not compatible with unpack normal mode '${r}'`),n!==null){let c=n;e.flatShading===!0&&(c=ig(c)),o=he(o.xy.mul(c),o.z)}let a=null;return t===Fg?a=OT(o):t===Yo?a=cp.mul(o).normalize():(Be(`NodeMaterial: Unsupported normal map type: ${t}`),a=mi),a}}const $T=Fn(XV).setParameterLength(1,2),jV=me(({textureNode:i,bumpScale:e})=>{const t=r=>i.isolate().context({getUV:o=>r(o.uvNode||Pi()),forceUVContext:!0}),n=q(t(r=>r));return lt(q(t(r=>r.add(r.dFdx()))).sub(n),q(t(r=>r.add(r.dFdy()))).sub(n)).mul(e)}),YV=me(i=>{const{surf_pos:e,surf_norm:t,dHdxy:n}=i,r=e.dFdx().normalize(),o=e.dFdy().normalize(),a=t,c=o.cross(a),u=a.cross(r),d=r.dot(c).mul(BT),p=d.sign().mul(n.x.mul(c).add(n.y.mul(u)));return d.abs().mul(t).sub(p).normalize()});class ZV extends _s{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=jV({textureNode:this.textureNode,bumpScale:e});return YV({surf_pos:Us,surf_norm:mi,dHdxy:t})}}const qT=Fn(ZV).setParameterLength(1,2),yN=new Map;class Xe extends Xt{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let n=yN.get(e);return n===void 0&&(n=uh(e,t),yN.set(e,n)),n}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,n=this.scope;let r=null;if(n===Xe.COLOR){const o=t.color!==void 0?this.getColor(n):he();t.map&&t.map.isTexture===!0?r=o.mul(this.getTexture("map")):r=o}else if(n===Xe.OPACITY){const o=this.getFloat(n);t.alphaMap&&t.alphaMap.isTexture===!0?r=o.mul(this.getTexture("alpha")):r=o}else if(n===Xe.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?r=this.getTexture("specular").r:r=q(1);else if(n===Xe.SPECULAR_INTENSITY){const o=this.getFloat(n);t.specularIntensityMap&&t.specularIntensityMap.isTexture===!0?r=o.mul(this.getTexture(n).a):r=o}else if(n===Xe.SPECULAR_COLOR){const o=this.getColor(n);t.specularColorMap&&t.specularColorMap.isTexture===!0?r=o.mul(this.getTexture(n).rgb):r=o}else if(n===Xe.ROUGHNESS){const o=this.getFloat(n);t.roughnessMap&&t.roughnessMap.isTexture===!0?r=o.mul(this.getTexture(n).g):r=o}else if(n===Xe.METALNESS){const o=this.getFloat(n);t.metalnessMap&&t.metalnessMap.isTexture===!0?r=o.mul(this.getTexture(n).b):r=o}else if(n===Xe.EMISSIVE){const o=this.getFloat("emissiveIntensity"),a=this.getColor(n).mul(o);t.emissiveMap&&t.emissiveMap.isTexture===!0?r=a.mul(this.getTexture(n)):r=a}else if(n===Xe.NORMAL)t.normalMap?(r=$T(this.getTexture("normal"),this.getCache("normalScale","vec2")),r.normalMapType=t.normalMapType,(t.normalMap.format==Nr||t.normalMap.format==tu||t.normalMap.format==eu)&&(r.unpackNormalMode=Yb)):t.bumpMap?r=qT(this.getTexture("bump").r,this.getFloat("bumpScale")):r=mi;else if(n===Xe.CLEARCOAT){const o=this.getFloat(n);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?r=o.mul(this.getTexture(n).r):r=o}else if(n===Xe.CLEARCOAT_ROUGHNESS){const o=this.getFloat(n);t.clearcoatRoughnessMap&&t.clearcoatRoughnessMap.isTexture===!0?r=o.mul(this.getTexture(n).r):r=o}else if(n===Xe.CLEARCOAT_NORMAL)t.clearcoatNormalMap?r=$T(this.getTexture(n),this.getCache(n+"Scale","vec2")):r=mi;else if(n===Xe.SHEEN){const o=this.getColor("sheenColor").mul(this.getFloat("sheen"));t.sheenColorMap&&t.sheenColorMap.isTexture===!0?r=o.mul(this.getTexture("sheenColor").rgb):r=o}else if(n===Xe.SHEEN_ROUGHNESS){const o=this.getFloat(n);t.sheenRoughnessMap&&t.sheenRoughnessMap.isTexture===!0?r=o.mul(this.getTexture(n).a):r=o,r=r.clamp(1e-4,1)}else if(n===Xe.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){const o=this.getTexture(n);r=ov(rg.x,rg.y,rg.y.negate(),rg.x).mul(o.rg.mul(2).sub(lt(1)).normalize().mul(o.b))}else r=rg;else if(n===Xe.IRIDESCENCE_THICKNESS){const o=Oi("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const a=Oi("0","float",t.iridescenceThicknessRange);r=o.sub(a).mul(this.getTexture(n).g).add(a)}else r=o}else if(n===Xe.TRANSMISSION){const o=this.getFloat(n);t.transmissionMap?r=o.mul(this.getTexture(n).r):r=o}else if(n===Xe.THICKNESS){const o=this.getFloat(n);t.thicknessMap?r=o.mul(this.getTexture(n).g):r=o}else if(n===Xe.IOR)r=this.getFloat(n);else if(n===Xe.LIGHT_MAP)r=this.getTexture(n).rgb.mul(this.getFloat("lightMapIntensity"));else if(n===Xe.AO)r=this.getTexture(n).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(n===Xe.LINE_DASH_OFFSET)r=t.dashOffset?this.getFloat(n):q(0);else{const o=this.getNodeType(e);r=this.getCache(n,o)}return r}}Xe.ALPHA_TEST="alphaTest",Xe.COLOR="color",Xe.OPACITY="opacity",Xe.SHININESS="shininess",Xe.SPECULAR="specular",Xe.SPECULAR_STRENGTH="specularStrength",Xe.SPECULAR_INTENSITY="specularIntensity",Xe.SPECULAR_COLOR="specularColor",Xe.REFLECTIVITY="reflectivity",Xe.ROUGHNESS="roughness",Xe.METALNESS="metalness",Xe.NORMAL="normal",Xe.CLEARCOAT="clearcoat",Xe.CLEARCOAT_ROUGHNESS="clearcoatRoughness",Xe.CLEARCOAT_NORMAL="clearcoatNormal",Xe.EMISSIVE="emissive",Xe.ROTATION="rotation",Xe.SHEEN="sheen",Xe.SHEEN_ROUGHNESS="sheenRoughness",Xe.ANISOTROPY="anisotropy",Xe.IRIDESCENCE="iridescence",Xe.IRIDESCENCE_IOR="iridescenceIOR",Xe.IRIDESCENCE_THICKNESS="iridescenceThickness",Xe.IOR="ior",Xe.TRANSMISSION="transmission",Xe.THICKNESS="thickness",Xe.ATTENUATION_DISTANCE="attenuationDistance",Xe.ATTENUATION_COLOR="attenuationColor",Xe.LINE_SCALE="scale",Xe.LINE_DASH_SIZE="dashSize",Xe.LINE_GAP_SIZE="gapSize",Xe.LINE_WIDTH="linewidth",Xe.LINE_DASH_OFFSET="dashOffset",Xe.POINT_SIZE="size",Xe.DISPERSION="dispersion",Xe.LIGHT_MAP="light",Xe.AO="ao";const _N=Ct(Xe,Xe.ALPHA_TEST),Lv=Ct(Xe,Xe.COLOR),xN=Ct(Xe,Xe.SHININESS),vN=Ct(Xe,Xe.EMISSIVE),Dv=Ct(Xe,Xe.OPACITY),bN=Ct(Xe,Xe.SPECULAR),XT=Ct(Xe,Xe.SPECULAR_INTENSITY),SN=Ct(Xe,Xe.SPECULAR_COLOR),My=Ct(Xe,Xe.SPECULAR_STRENGTH),Fv=Ct(Xe,Xe.REFLECTIVITY),MN=Ct(Xe,Xe.ROUGHNESS),TN=Ct(Xe,Xe.METALNESS),wN=Ct(Xe,Xe.NORMAL),AN=Ct(Xe,Xe.CLEARCOAT),EN=Ct(Xe,Xe.CLEARCOAT_ROUGHNESS),CN=Ct(Xe,Xe.CLEARCOAT_NORMAL),RN=Ct(Xe,Xe.ROTATION),NN=Ct(Xe,Xe.SHEEN),PN=Ct(Xe,Xe.SHEEN_ROUGHNESS),IN=Ct(Xe,Xe.ANISOTROPY),LN=Ct(Xe,Xe.IRIDESCENCE),DN=Ct(Xe,Xe.IRIDESCENCE_IOR),FN=Ct(Xe,Xe.IRIDESCENCE_THICKNESS),BN=Ct(Xe,Xe.TRANSMISSION),ON=Ct(Xe,Xe.THICKNESS),UN=Ct(Xe,Xe.IOR),kN=Ct(Xe,Xe.ATTENUATION_DISTANCE),zN=Ct(Xe,Xe.ATTENUATION_COLOR),jT=Ct(Xe,Xe.LINE_SCALE),YT=Ct(Xe,Xe.LINE_DASH_SIZE),ZT=Ct(Xe,Xe.LINE_GAP_SIZE),Bv=Ct(Xe,Xe.LINE_WIDTH),KT=Ct(Xe,Xe.LINE_DASH_OFFSET),VN=Ct(Xe,Xe.POINT_SIZE),GN=Ct(Xe,Xe.DISPERSION),JT=Ct(Xe,Xe.LIGHT_MAP),WN=Ct(Xe,Xe.AO),rg=rn(new ze).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))}),HN=me(i=>i.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class KV extends Qf{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 n=this.storageBufferNode.structTypeNode;return n?n.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 n;const r=e.context.assign;if(e.isAvailable("storageBuffer")===!1?this.node.isPBO===!0&&r!==!0&&(this.node.value.isInstancedBufferAttribute||e.shaderStage!=="compute")?n=e.generatePBO(this):n=this.node.build(e):n=super.generate(e),r!==!0){const o=this.getNodeType(e);n=e.format(n,o,t)}return n}}const JV=Fn(KV).setParameterLength(2);class QV extends NT{static get type(){return"StorageBufferNode"}constructor(e,t=null,n=0){let r,o=null;t&&t.isStruct?(r="struct",o=t.layout,(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)&&(n=e.count)):t===null&&(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute)?(r=IM(e.itemSize),n=e.count):r=t,super(e,r,n),this.isStorageBufferNode=!0,this.structTypeNode=o,this.access=zr.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 JV(this,e)}setPBO(e){return this.isPBO=e,this}getPBO(){return this.isPBO}setAccess(e){return this.access=e,this}toReadOnly(){return this.setAccess(zr.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=TT(this.value),this._varying=Pc(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:n}=this.getAttributeData(),r=n.build(e);return e.registerTransform(r,t),r}}const hh=(i,e=null,t=0)=>new QV(i,e,t),eG=(i,e,t)=>(Ie('TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),hh(i,e,t).setPBO(!0));class hs extends Xt{static get type(){return"IndexNode"}constructor(e){super("uint"),this.scope=e,this.isIndexNode=!0}generate(e){const t=this.getNodeType(e),n=this.scope;let r;if(n===hs.VERTEX)r=e.getVertexIndex();else if(n===hs.INSTANCE)r=e.getInstanceIndex();else if(n===hs.DRAW)r=e.getDrawIndex();else if(n===hs.INVOCATION_LOCAL)r=e.getInvocationLocalIndex();else if(n===hs.INVOCATION_SUBGROUP)r=e.getInvocationSubgroupIndex();else if(n===hs.SUBGROUP)r=e.getSubgroupIndex();else throw new Error("THREE.IndexNode: Unknown scope: "+n);let o;return e.shaderStage==="vertex"||e.shaderStage==="compute"?o=r:o=Pc(this).build(e,t),o}}hs.VERTEX="vertex",hs.INSTANCE="instance",hs.SUBGROUP="subgroup",hs.INVOCATION_LOCAL="invocationLocal",hs.INVOCATION_SUBGROUP="invocationSubgroup",hs.DRAW="draw";const $N=Ct(hs,hs.VERTEX),Dc=Ct(hs,hs.INSTANCE),tG=Ct(hs,hs.SUBGROUP),nG=Ct(hs,hs.INVOCATION_SUBGROUP),iG=Ct(hs,hs.INVOCATION_LOCAL),qN=Ct(hs,hs.DRAW);class XN extends Xt{static get type(){return"InstanceNode"}constructor(e,t,n=null){super("void"),this.count=e,this.instanceMatrix=t,this.instanceColor=n,this.instanceMatrixNode=null,this.instanceColorNode=null,this.updateType=Xn.FRAME,this.buffer=null,this.bufferColor=null}get isStorageMatrix(){const{instanceMatrix:e}=this;return e&&e.isStorageInstancedBufferAttribute===!0}get isStorageColor(){const{instanceColor:e}=this;return e&&e.isStorageInstancedBufferAttribute===!0}setup(e){const{instanceMatrix:t,instanceColor:n,isStorageMatrix:r,isStorageColor:o}=this,{count:a}=t;let{instanceMatrixNode:c,instanceColorNode:u}=this;if(c===null){if(r)c=hh(t,"mat4",Math.max(a,1)).element(Dc);else if(a<=1e3)c=_y(t.array,"mat4",Math.max(a,1)).element(Dc);else{const p=new V0(t.array,16,1);this.buffer=p;const m=t.usage===Yh?wT:Tv,y=[m(p,"vec4",16,0),m(p,"vec4",16,4),m(p,"vec4",16,8),m(p,"vec4",16,12)];c=kd(...y)}this.instanceMatrixNode=c}if(n&&u===null){if(o)u=hh(n,"vec3",Math.max(n.count,1)).element(Dc);else{const p=new oa(n.array,3),m=n.usage===Yh?wT:Tv;this.bufferColor=p,u=he(m(p,"vec3",3,0))}this.instanceColorNode=u}const d=c.mul(bs).xyz;if(bs.assign(d),e.hasGeometryAttribute("normal")){const p=ZR(zo,c);zo.assign(p)}this.instanceColorNode!==null&&fa("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.buffer!==null&&this.isStorageMatrix!==!0&&(this.buffer.clearUpdateRanges(),this.buffer.updateRanges.push(...this.instanceMatrix.updateRanges),this.instanceMatrix.usage!==Yh&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version)),this.instanceColor&&this.bufferColor!==null&&this.isStorageColor!==!0&&(this.bufferColor.clearUpdateRanges(),this.bufferColor.updateRanges.push(...this.instanceColor.updateRanges),this.instanceColor.usage!==Yh&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version))}}const sG=Fn(XN).setParameterLength(2,3);class rG extends XN{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:n,instanceColor:r}=e;super(t,n,r),this.instancedMesh=e}}const jN=Fn(rG).setParameterLength(1);class oG extends Xt{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=Dc:this.batchingIdNode=qN);const n=me(([v])=>{const w=le(rh(Ns(this.batchMesh._indirectTexture),0).x).toConst(),M=le(v).mod(w).toConst(),S=le(v).div(w).toConst();return Ns(this.batchMesh._indirectTexture,ar(M,S)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(le(this.batchingIdNode)),r=this.batchMesh._matricesTexture,o=le(rh(Ns(r),0).x).toConst(),a=q(n).mul(4).toInt().toConst(),c=a.mod(o).toConst(),u=a.div(o).toConst(),d=kd(Ns(r,ar(c,u)),Ns(r,ar(c.add(1),u)),Ns(r,ar(c.add(2),u)),Ns(r,ar(c.add(3),u))),p=this.batchMesh._colorsTexture;if(p!==null){const w=me(([M])=>{const S=le(rh(Ns(p),0).x).toConst(),C=M,N=C.mod(S).toConst(),I=C.div(S).toConst();return Ns(p,ar(N,I)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(n);fa("vec3","vBatchColor").assign(w)}const m=Vr(d);bs.assign(d.mul(bs));const y=zo.div(he(m[0].dot(m[0]),m[1].dot(m[1]),m[2].dot(m[2]))),x=m.mul(y).xyz;zo.assign(x),e.hasGeometryAttribute("tangent")&&Sy.mulAssign(m)}}const YN=Fn(oG).setParameterLength(1),ZN=new WeakMap;class KN extends Xt{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=Xn.OBJECT,this.skinIndexNode=_o("skinIndex","uvec4"),this.skinWeightNode=_o("skinWeight","vec4"),this.bindMatrixNode=Oi("bindMatrix","mat4"),this.bindMatrixInverseNode=Oi("bindMatrixInverse","mat4"),this.boneMatricesNode=VT("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=bs,this.toPositionNode=bs,this.previousBoneMatricesNode=null}getSkinnedPosition(e=this.boneMatricesNode,t=this.positionNode){const{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:o,bindMatrixInverseNode:a}=this,c=e.element(n.x),u=e.element(n.y),d=e.element(n.z),p=e.element(n.w),m=o.mul(t),y=Js(c.mul(r.x).mul(m),u.mul(r.y).mul(m),d.mul(r.z).mul(m),p.mul(r.w).mul(m));return a.mul(y).xyz}getSkinnedNormal(e=this.boneMatricesNode,t=zo){const{skinIndexNode:n,skinWeightNode:r,bindMatrixNode:o,bindMatrixInverseNode:a}=this,c=e.element(n.x),u=e.element(n.y),d=e.element(n.z),p=e.element(n.w);let m=Js(r.x.mul(c),r.y.mul(u),r.z.mul(d),r.w.mul(p));return m=a.mul(m).mul(o),m.transformDirection(t).xyz}getPreviousSkinnedPosition(e){const t=e.object;return this.previousBoneMatricesNode===null&&(t.skeleton.previousBoneMatrices=new Float32Array(t.skeleton.boneMatrices),this.previousBoneMatricesNode=VT("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,Av)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")||DM(e.object).useVelocity===!0}setup(e){this.needsPreviousBoneMatrices(e)&&Av.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){const n=this.getSkinnedNormal();zo.assign(n),e.hasGeometryAttribute("tangent")&&Sy.assign(n)}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;ZN.get(t)!==e.frameId&&(ZN.set(t,e.frameId),this.previousBoneMatricesNode!==null&&(t.previousBoneMatrices===null&&(t.previousBoneMatrices=new Float32Array(t.boneMatrices)),t.previousBoneMatrices.set(t.boneMatrices)),t.update())}}const JN=i=>new KN(i),aG=(i,e=null)=>{const t=new KN(i);return t.positionNode=hh(new oa(i.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(Dc).toVar(),t.skinIndexNode=hh(new oa(new Uint32Array(i.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(Dc).toVar(),t.skinWeightNode=hh(new oa(i.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(Dc).toVar(),t.bindMatrixNode=rn(i.bindMatrix,"mat4"),t.bindMatrixInverseNode=rn(i.bindMatrixInverse,"mat4"),t.boneMatricesNode=_y(i.skeleton.boneMatrices,"mat4",i.skeleton.bones.length),t.toPositionNode=e,Nt(t)};class lG extends Xt{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 n={};for(let c=0,u=this.params.length-1;c<u;c++){const d=this.params[c],p=d.isNode!==!0&&d.name||this.getVarName(c),m=d.isNode!==!0&&d.type||"int";n[p]=sh(p,m)}const r=e.addStack(),o=this.params[this.params.length-1](n);t.returnsNode=o.context({nodeLoop:o}),t.stackNode=r;const a=this.params[0];if(a.isNode!==!0&&typeof a.update=="function"){const c=me(this.params[0].update)(n);t.updateNode=c.context({nodeLoop:c})}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),n=this.params,r=t.stackNode;for(let a=0,c=n.length-1;a<c;a++){const u=n[a];let d=!1,p=null,m=null,y=null,x=null,v=null,w=null;u.isNode?u.getNodeType(e)==="bool"?(d=!0,x="bool",m=u.build(e,x)):(x="int",y=this.getVarName(a),p="0",m=u.build(e,x),v="<"):(x=u.type||"int",y=u.name||this.getVarName(a),p=u.start,m=u.end,v=u.condition,w=u.update,typeof p=="number"?p=e.generateConst(x,p):p&&p.isNode&&(p=p.build(e,x)),typeof m=="number"?m=e.generateConst(x,m):m&&m.isNode&&(m=m.build(e,x)),p!==void 0&&m===void 0?(p=p+" - 1",m="0",v=">="):m!==void 0&&p===void 0&&(p="0",v="<"),v===void 0&&(Number(p)>Number(m)?v=">=":v="<"));let M;if(d)M=`while ( ${m} )`;else{const S={start:p,end:m},C=S.start,N=S.end;let I;const U=()=>v.includes("<")?"+=":"-=";if(w!=null)switch(typeof w){case"function":I=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":I=y+" "+U()+" "+e.generateConst(x,w);break;case"string":I=y+" "+w;break;default:w.isNode?I=y+" "+U()+" "+w.build(e):(Be("TSL: 'Loop( { update: ... } )' is not a function, string or number."),I="break /* invalid update */")}else x==="int"||x==="uint"?w=v.includes("<")?"++":"--":w=U()+" 1.",I=y+" "+w;const F=e.getVar(x,y)+" = "+C,k=y+" "+v+" "+N;M=`for ( ${F}; ${k}; ${I} )`}e.addFlowCode((a===0?`
`:"")+e.tab+M+` {
`).addFlowTab()}const o=r.build(e,"void");t.returnsNode.build(e,"void"),e.removeFlowTab().addFlowCode(`
`+e.tab+o);for(let a=0,c=this.params.length-1;a<c;a++)e.addFlowCode((a===0?"":e.tab)+`}
`).removeFlowTab();e.addFlowTab()}}const Ai=(...i)=>new lG(ep(i,"int")).toStack(),cG=()=>sh("continue").toStack(),QN=()=>sh("break").toStack(),QT=new WeakMap,xa=new gn,eP=me(({bufferMap:i,influence:e,stride:t,width:n,depth:r,offset:o})=>{const a=le($N).mul(t).add(o),c=a.div(n),u=a.sub(c.mul(n));return Ns(i,ar(u,c)).depth(r).xyz.mul(e)});function uG(i){const e=i.morphAttributes.position!==void 0,t=i.morphAttributes.normal!==void 0,n=i.morphAttributes.color!==void 0,r=i.morphAttributes.position||i.morphAttributes.normal||i.morphAttributes.color,o=r!==void 0?r.length:0;let a=QT.get(i);if(a===void 0||a.count!==o){let S=function(){w.dispose(),QT.delete(i),i.removeEventListener("dispose",S)};a!==void 0&&a.texture.dispose();const c=i.morphAttributes.position||[],u=i.morphAttributes.normal||[],d=i.morphAttributes.color||[];let p=0;e===!0&&(p=1),t===!0&&(p=2),n===!0&&(p=3);let m=i.attributes.position.count*p,y=1;const x=4096;m>x&&(y=Math.ceil(m/x),m=x);const v=new Float32Array(m*y*4*o),w=new al(v,m,y,o);w.type=Si,w.needsUpdate=!0;const M=p*4;for(let C=0;C<o;C++){const N=c[C],I=u[C],U=d[C],F=m*y*4*C;for(let k=0;k<N.count;k++){const G=k*M;e===!0&&(xa.fromBufferAttribute(N,k),v[F+G+0]=xa.x,v[F+G+1]=xa.y,v[F+G+2]=xa.z,v[F+G+3]=0),t===!0&&(xa.fromBufferAttribute(I,k),v[F+G+4]=xa.x,v[F+G+5]=xa.y,v[F+G+6]=xa.z,v[F+G+7]=0),n===!0&&(xa.fromBufferAttribute(U,k),v[F+G+8]=xa.x,v[F+G+9]=xa.y,v[F+G+10]=xa.z,v[F+G+11]=U.itemSize===4?xa.w:1)}}a={count:o,texture:w,stride:p,size:new ze(m,y)},QT.set(i,a),i.addEventListener("dispose",S)}return a}class hG extends Xt{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=rn(1),this.updateType=Xn.OBJECT}setup(e){const{geometry:t}=e,n=t.morphAttributes.position!==void 0,r=t.hasAttribute("normal")&&t.morphAttributes.normal!==void 0,o=t.morphAttributes.position||t.morphAttributes.normal||t.morphAttributes.color,a=o!==void 0?o.length:0,{texture:c,stride:u,size:d}=uG(t);n===!0&&bs.mulAssign(this.morphBaseInfluence),r===!0&&zo.mulAssign(this.morphBaseInfluence);const p=le(d.width);Ai(a,({i:m})=>{const y=q(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?y.assign(Ns(this.mesh.morphTexture,ar(le(m).add(1),le(Dc))).r):y.assign(Oi("morphTargetInfluences","float").element(m).toVar()),jt(y.notEqual(0),()=>{n===!0&&bs.addAssign(eP({bufferMap:c,influence:y,stride:u,width:p,depth:m,offset:le(0)})),r===!0&&zo.addAssign(eP({bufferMap:c,influence:y,stride:u,width:p,depth:m,offset:le(1)}))})})}update(){const e=this.morphBaseInfluence;this.mesh.geometry.morphTargetsRelative?e.value=1:e.value=1-this.mesh.morphTargetInfluences.reduce((t,n)=>t+n,0)}}const tP=Fn(hG).setParameterLength(1);class og extends Xt{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class dG extends og{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class fG extends dR{static get type(){return"LightingContextNode"}constructor(e,t=null,n=null,r=null){super(e),this.lightingModel=t,this.backdropNode=n,this.backdropAlphaNode=r,this._value=null}getContext(){const{backdropNode:e,backdropAlphaNode:t}=this,n=he().toVar("directDiffuse"),r=he().toVar("directSpecular"),o=he().toVar("indirectDiffuse"),a=he().toVar("indirectSpecular"),c={directDiffuse:n,directSpecular:r,indirectDiffuse:o,indirectSpecular:a};return{radiance:he().toVar("radiance"),irradiance:he().toVar("irradiance"),iblIrradiance:he().toVar("iblIrradiance"),ambientOcclusion:q(1).toVar("ambientOcclusion"),reflectedLight:c,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 nP=Fn(fG);class pG extends og{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}const ag=new ze;class Ov extends Ic{static get type(){return"ViewportTextureNode"}constructor(e=ah,t=null,n=null){let r=null;n===null?(r=new Ef,r.minFilter=Vs,n=r):r=n,super(n,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=r,this.isOutputTextureNode=!0,this.updateBeforeType=Xn.FRAME,this._cacheTextures=new WeakMap}getTextureForReference(e=null){let t,n;if(this.referenceNode?(t=this.referenceNode.defaultFramebuffer,n=this.referenceNode._cacheTextures):(t=this.defaultFramebuffer,n=this._cacheTextures),e===null)return t;if(n.has(e)===!1){const r=t.clone();n.set(e,r)}return n.get(e)}updateReference(e){const t=e.renderer.getRenderTarget();return this.value=this.getTextureForReference(t),this.value}updateBefore(e){const t=e.renderer,n=t.getRenderTarget();n===null?t.getDrawingBufferSize(ag):ag.set(n.width,n.height);const r=this.getTextureForReference(n);(r.image.width!==ag.width||r.image.height!==ag.height)&&(r.image.width=ag.width,r.image.height=ag.height,r.needsUpdate=!0);const o=r.generateMipmaps;r.generateMipmaps=this.generateMipmaps,t.copyFramebufferToTexture(r),r.generateMipmaps=o}clone(){const e=new this.constructor(this.uvNode,this.levelNode,this.value);return e.generateMipmaps=this.generateMipmaps,e}}const mG=Fn(Ov).setParameterLength(0,3),ew=Fn(Ov,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let Uv=null;class gG extends Ov{static get type(){return"ViewportDepthTextureNode"}constructor(e=ah,t=null){Uv===null&&(Uv=new Ys),super(e,t,Uv)}getTextureForReference(){return Uv}}const tw=Fn(gG).setParameterLength(0,2);class Vo extends Xt{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===Vo.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,n=this.valueNode;let r=null;if(t===Vo.DEPTH_BASE)n!==null&&(r=iP().assign(n));else if(t===Vo.DEPTH)e.isPerspectiveCamera?r=nw(Us.z,lh,ch):r=lg(Us.z,lh,ch);else if(t===Vo.LINEAR_DEPTH)if(n!==null)if(e.isPerspectiveCamera){const o=iw(n,lh,ch);r=lg(o,lh,ch)}else r=n;else r=lg(Us.z,lh,ch);return r}}Vo.DEPTH_BASE="depthBase",Vo.DEPTH="depth",Vo.LINEAR_DEPTH="linearDepth";const lg=(i,e,t)=>i.add(e).div(e.sub(t)),yG=(i,e,t)=>e.sub(t).mul(i).sub(e),nw=(i,e,t)=>e.add(i).mul(t).div(t.sub(e).mul(i)),iw=(i,e,t)=>e.mul(t).div(t.sub(e).mul(i).sub(t)),sw=(i,e,t)=>{e=e.max(1e-6).toVar();const n=Cc(i.negate().div(e)),r=Cc(t.div(e));return n.div(r)},_G=(i,e,t)=>{const n=i.mul(gv(t.div(e)));return q(Math.E).pow(n).mul(e).negate()},iP=Fn(Vo,Vo.DEPTH_BASE),rw=Ct(Vo,Vo.DEPTH),cg=Fn(Vo,Vo.LINEAR_DEPTH).setParameterLength(0,1),xG=cg(tw());rw.assign=i=>iP(i);class Za extends Xt{static get type(){return"ClippingNode"}constructor(e=Za.DEFAULT){super(),this.scope=e}setup(e){super.setup(e);const t=e.clippingContext,{intersectionPlanes:n,unionPlanes:r}=t;return this.hardwareClipping=e.material.hardwareClipping,this.scope===Za.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(n,r):this.scope===Za.HARDWARE?this.setupHardwareClipping(r,e):this.setupDefault(n,r)}setupAlphaToCoverage(e,t){return me(()=>{const n=q().toVar("distanceToPlane"),r=q().toVar("distanceToGradient"),o=q(1).toVar("clipOpacity"),a=t.length;if(this.hardwareClipping===!1&&a>0){const u=eo(t).setGroup(an);Ai(a,({i:d})=>{const p=u.element(d);n.assign(Us.dot(p.xyz).negate().add(p.w)),r.assign(n.fwidth().div(2)),o.mulAssign(ga(r.negate(),r,n))})}const c=e.length;if(c>0){const u=eo(e).setGroup(an),d=q(1).toVar("intersectionClipOpacity");Ai(c,({i:p})=>{const m=u.element(p);n.assign(Us.dot(m.xyz).negate().add(m.w)),r.assign(n.fwidth().div(2)),d.mulAssign(ga(r.negate(),r,n).oneMinus())}),o.mulAssign(d.oneMinus())}Ni.a.mulAssign(o),Ni.a.equal(0).discard()})()}setupDefault(e,t){return me(()=>{const n=t.length;if(this.hardwareClipping===!1&&n>0){const o=eo(t).setGroup(an);Ai(n,({i:a})=>{const c=o.element(a);Us.dot(c.xyz).greaterThan(c.w).discard()})}const r=e.length;if(r>0){const o=eo(e).setGroup(an),a=$a(!0).toVar("clipped");Ai(r,({i:c})=>{const u=o.element(c);a.assign(Us.dot(u.xyz).greaterThan(u.w).and(a))}),a.discard()}})()}setupHardwareClipping(e,t){const n=e.length;return t.enableHardwareClipping(n),me(()=>{const r=eo(e).setGroup(an),o=oh(t.getClipDistance());Ai(n,({i:a})=>{const c=r.element(a),u=Us.dot(c.xyz).sub(c.w).negate();o.element(a).assign(u)})})()}}Za.ALPHA_TO_COVERAGE="alphaToCoverage",Za.DEFAULT="default",Za.HARDWARE="hardware";const vG=()=>new Za,bG=()=>new Za(Za.ALPHA_TO_COVERAGE),SG=()=>new Za(Za.HARDWARE),MG=.05,sP=me(([i])=>El(Bn(1e4,yo(Bn(17,i.x).add(Bn(.1,i.y)))).mul(Js(.1,qi(yo(Bn(13,i.y).add(i.x))))))),rP=me(([i])=>sP(lt(sP(i.xy),i.z))),TG=me(([i])=>{const e=vs(Nc(hT(i.xyz)),Nc(dT(i.xyz))),t=q(1).div(q(MG).mul(e)).toVar("pixScale"),n=lt(Qm(Rc(Cc(t))),Qm(yv(Cc(t)))),r=lt(rP(Rc(n.x.mul(i.xyz))),rP(Rc(n.y.mul(i.xyz)))),o=El(Cc(t)),a=Js(Bn(o.oneMinus(),r.x),Bn(o,r.y)),c=ko(o,o.oneMinus()),u=he(a.mul(a).div(Bn(2,c).mul(ui(1,c))),a.sub(Bn(.5,c)).div(ui(1,c)),ui(1,ui(1,a).mul(ui(1,a)).div(Bn(2,c).mul(ui(1,c))))),d=a.lessThan(c.oneMinus()).select(a.lessThan(c).select(u.x,u.y),u.z);return Rl(d,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class wG extends zR{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),n=e.hasGeometryAttribute(t);let r;return n===!0?r=super.generate(e):r=e.generateConst(this.nodeType,new gn(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const oP=(i=0)=>new wG(i),aP=me(([i,e])=>ko(1,i.oneMinus().div(e)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),lP=me(([i,e])=>ko(i.div(e.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),cP=me(([i,e])=>i.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),uP=me(([i,e])=>oi(i.mul(2).mul(e),i.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),xv(.5,i))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),AG=me(([i,e])=>{const t=e.a.add(i.a.mul(e.a.oneMinus()));return zt(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"}]}),hP=me(([i])=>zt(i.rgb.mul(i.a),i.a),{color:"vec4",return:"vec4"}),EG=me(([i])=>(jt(i.a.equal(0),()=>zt(0)),zt(i.rgb.div(i.a),i.a)),{color:"vec4",return:"vec4"}),CG=(...i)=>(Ie('TSL: "burn" has been renamed. Use "blendBurn" instead.'),aP(i)),RG=(...i)=>(Ie('TSL: "dodge" has been renamed. Use "blendDodge" instead.'),lP(i)),NG=(...i)=>(Ie('TSL: "screen" has been renamed. Use "blendScreen" instead.'),cP(i)),PG=(...i)=>(Ie('TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),uP(i));class Ss extends Ds{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,this.contextNode=null,Object.defineProperty(this,"shadowPositionNode",{get:()=>this.receivedShadowPositionNode,set:e=>{Ie('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 n=this[t];n&&n.isNode===!0&&e.push({property:t,childNode:n})}return e}customProgramCacheKey(){const e=[];for(const{property:t,childNode:n}of this._getNodeChildren())e.push(jm(t.slice(0,-4)),n.getCacheKey());return this.type+Kf(e)}build(e){this.setup(e)}setupObserver(e){return new tz(e)}setup(e){e.context.setupNormal=()=>eg(this.setupNormal(e),"NORMAL","vec3"),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,n=t.getRenderTarget();t.contextNode.isContextNode===!0?e.context=wi(wi({},e.context),t.contextNode.getFlowContextData()):Be('NodeMaterial: "renderer.contextNode" must be an instance of `context()`.'),this.contextNode!==null&&(this.contextNode.isContextNode===!0?e.context=wi(wi({},e.context),this.contextNode.getFlowContextData()):Be('NodeMaterial: "material.contextNode" must be an instance of `context()`.')),e.addStack();const r=eg(this.setupVertex(e),"VERTEX"),o=this.vertexNode||r;e.stack.outputNode=o,this.setupHardwareClipping(e),this.geometryNode!==null&&(e.stack.outputNode=e.stack.outputNode.bypass(this.geometryNode)),e.addFlow("vertex",e.removeStack()),e.addStack();let a;const c=this.setupClipping(e);if((this.depthWrite===!0||this.depthTest===!0)&&(n!==null?n.depthBuffer===!0&&this.setupDepth(e):t.depth===!0&&this.setupDepth(e)),this.fragmentNode===null){this.setupDiffuseColor(e),this.setupVariants(e);const u=this.setupLighting(e);c!==null&&e.stack.addToStack(c);const d=zt(u,Ni.a).max(0);a=this.setupOutput(e,d),Jm.assign(a);const p=this.outputNode!==null;if(p&&(a=this.outputNode),e.context.getOutput&&(a=e.context.getOutput(a,e)),n!==null){const m=t.getMRT(),y=this.mrtNode;m!==null?(p&&Jm.assign(a),a=m,y!==null&&(a=m.merge(y))):y!==null&&(a=y)}}else{let u=this.fragmentNode;u.isOutputStructNode!==!0&&(u=zt(u)),a=this.setupOutput(e,u)}e.stack.outputNode=a,e.addFlow("fragment",e.removeStack()),e.observer=this.setupObserver(e)}setupClipping(e){if(e.clippingContext===null)return null;const{unionPlanes:t,intersectionPlanes:n}=e.clippingContext;let r=null;if(t.length>0||n.length>0){const o=e.renderer.currentSamples;this.alphaToCoverage&&o>1?r=bG():e.stack.addToStack(vG())}return r}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(SG()),this.hardwareClipping=!0)}setupDepth(e){const{renderer:t,camera:n}=e;let r=this.depthNode;if(r===null){const o=t.getMRT();o&&o.has("depth")?r=o.get("depth"):t.logarithmicDepthBuffer===!0&&(n.isPerspectiveCamera?r=sw(Us.z,lh,ch):r=lg(Us.z,lh,ch))}r!==null&&rw.assign(r).toStack()}setupPositionView(){return Lc.mul(bs).xyz}setupModelViewProjection(){return xo.mul(Us)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),HN}setupPosition(e){const{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&tP(t).toStack(),t.isSkinnedMesh===!0&&JN(t).toStack(),this.displacementMap){const r=uh("displacementMap","texture"),o=uh("displacementScale","float"),a=uh("displacementBias","float");bs.addAssign(zo.normalize().mul(r.x.mul(o).add(a)))}return t.isBatchedMesh&&YN(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&jN(t).toStack(),this.positionNode!==null&&bs.assign(eg(this.positionNode,"POSITION","vec3")),bs}setupDiffuseColor(e){const{object:t,geometry:n}=e;this.maskNode!==null&&$a(this.maskNode).not().discard();let r=this.colorNode?zt(this.colorNode):Lv;this.vertexColors===!0&&n.hasAttribute("color")&&(r=r.mul(oP())),t.instanceColor&&(r=fa("vec3","vInstanceColor").mul(r)),t.isBatchedMesh&&t._colorsTexture&&(r=fa("vec3","vBatchColor").mul(r)),Ni.assign(r);const o=this.opacityNode?q(this.opacityNode):Dv;Ni.a.assign(Ni.a.mul(o));let a=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(a=this.alphaTestNode!==null?q(this.alphaTestNode):_N,this.alphaToCoverage===!0?(Ni.a=ga(a,a.add(pT(Ni.a)),Ni.a),Ni.a.lessThanEqual(0).discard()):Ni.a.lessThanEqual(a).discard()),this.alphaHash===!0&&Ni.a.lessThan(TG(bs)).discard(),e.isOpaque()&&Ni.a.assign(1)}setupVariants(){}setupOutgoingLight(){return this.lights===!0?he(0):Ni.rgb}setupNormal(){return this.normalNode?he(this.normalNode):wN}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?uh("envMap","cubeTexture"):uh("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new pG(JT)),t}setupLights(e){const t=[],n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);const r=this.setupLightMap(e);r&&r.isLightingNode&&t.push(r);let o=this.aoNode;o===null&&e.material.aoMap&&(o=WN),e.context.getAO&&(o=e.context.getAO(o,e)),o&&t.push(new dG(o));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:n,backdropAlphaNode:r,emissiveNode:o}=this,c=this.lights===!0||this.lightsNode!==null?this.setupLights(e):null;let u=this.setupOutgoingLight(e);if(c&&c.getScope().hasLights){const d=this.setupLightingModel(e)||null;u=nP(c,d,n,r)}else n!==null&&(u=he(r!==null?oi(u,n,r):n));return(o&&o.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(KM.assign(he(o||vN)),u=u.add(KM)),u}setupFog(e,t){const n=e.fogNode;return n&&(Jm.assign(t),t=zt(n.toVar())),t}setupPremultipliedAlpha(e,t){return hP(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 n in e){const r=e[n];this[n]===void 0&&(this[n]=r,r&&r.clone&&(this[n]=r.clone()))}const t=Object.getOwnPropertyDescriptors(e.constructor.prototype);for(const n in t)Object.getOwnPropertyDescriptor(this.constructor.prototype,n)===void 0&&t[n].get!==void 0&&Object.defineProperty(this.constructor.prototype,n,t[n])}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{},nodes:{}});const n=Ds.prototype.toJSON.call(this,e);n.inputNodes={};for(const{property:o,childNode:a}of this._getNodeChildren())n.inputNodes[o]=a.toJSON(e).uuid;function r(o){const a=[];for(const c in o){const u=o[c];delete u.metadata,a.push(u)}return a}if(t){const o=r(e.textures),a=r(e.images),c=r(e.nodes);o.length>0&&(n.textures=o),a.length>0&&(n.images=a),c.length>0&&(n.nodes=c)}return n}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,this.contextNode=e.contextNode,super.copy(e)}}const IG=new js;class LG extends Ss{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(IG),this.setValues(e)}}const DG=new Cd;class FG extends Ss{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(DG),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?q(this.offsetNode):KT,t=this.dashScaleNode?q(this.dashScaleNode):jT,n=this.dashSizeNode?q(this.dashSizeNode):YT,r=this.gapSizeNode?q(this.gapSizeNode):ZT;rp.assign(n),py.assign(r);const o=Pc(_o("lineDistance").mul(t));(e?o.add(e):o).mod(rp.add(py)).greaterThan(rp).discard()}}let kv=null;class BG extends Ov{static get type(){return"ViewportSharedTextureNode"}constructor(e=ah,t=null){kv===null&&(kv=new Ef),super(e,t,kv)}getTextureForReference(){return kv}updateReference(){return this}}const dP=Fn(BG).setParameterLength(0,2),OG=new Cd;class $Z extends null{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.isLine2NodeMaterial=!0,this.setDefaultValues(OG),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,n=this._useAlphaToCoverage,r=this.useColor,o=this._useDash,a=this._useWorldUnits,c=me(({start:d,end:p})=>{const m=xo.element(2).element(2),v=xo.element(3).element(2).mul(-.5).div(m).sub(d.z).div(p.z.sub(d.z));return zt(oi(d.xyz,p.xyz,v),p.w)}).setLayout({name:"trimSegment",type:"vec4",inputs:[{name:"start",type:"vec4"},{name:"end",type:"vec4"}]});this.vertexNode=me(()=>{const d=_o("instanceStart"),p=_o("instanceEnd"),m=zt(Lc.mul(zt(d,1))).toVar("start"),y=zt(Lc.mul(zt(p,1))).toVar("end");if(o){const U=this.dashScaleNode?q(this.dashScaleNode):jT,F=this.offsetNode?q(this.offsetNode):KT,k=_o("instanceDistanceStart"),G=_o("instanceDistanceEnd");let B=Wr.y.lessThan(.5).select(U.mul(k),U.mul(G));B=B.add(F),fa("float","lineDistance").assign(B)}a&&(fa("vec3","worldStart").assign(m.xyz),fa("vec3","worldEnd").assign(y.xyz));const x=ng.z.div(ng.w),v=xo.element(2).element(3).equal(-1);jt(v,()=>{jt(m.z.lessThan(0).and(y.z.greaterThan(0)),()=>{y.assign(c({start:m,end:y}))}).ElseIf(y.z.lessThan(0).and(m.z.greaterThanEqual(0)),()=>{m.assign(c({start:y,end:m}))})});const w=xo.mul(m),M=xo.mul(y),S=w.xyz.div(w.w),C=M.xyz.div(M.w),N=C.xy.sub(S.xy).toVar();N.x.assign(N.x.mul(x)),N.assign(N.normalize());const I=zt().toVar();if(a){const U=y.xyz.sub(m.xyz).normalize(),F=oi(m.xyz,y.xyz,.5).normalize(),k=U.cross(F).normalize(),G=U.cross(k),B=fa("vec4","worldPos");B.assign(Wr.y.lessThan(.5).select(m,y));const z=Bv.mul(.5);B.addAssign(zt(Wr.x.lessThan(0).select(k.mul(z),k.mul(z).negate()),0)),o||(B.addAssign(zt(Wr.y.lessThan(.5).select(U.mul(z).negate(),U.mul(z)),0)),B.addAssign(zt(G.mul(z),0)),jt(Wr.y.greaterThan(1).or(Wr.y.lessThan(0)),()=>{B.subAssign(zt(G.mul(2).mul(z),0))})),I.assign(xo.mul(B));const Q=he().toVar();Q.assign(Wr.y.lessThan(.5).select(S,C)),I.z.assign(Q.z.mul(I.w))}else{const U=lt(N.y,N.x.negate()).toVar("offset");N.x.assign(N.x.div(x)),U.x.assign(U.x.div(x)),U.assign(Wr.x.lessThan(0).select(U.negate(),U)),jt(Wr.y.lessThan(0),()=>{U.assign(U.sub(N))}).ElseIf(Wr.y.greaterThan(1),()=>{U.assign(U.add(N))}),U.assign(U.mul(Bv)),U.assign(U.div(ng.w.div(PT))),I.assign(Wr.y.lessThan(.5).select(w,M)),U.assign(U.mul(I.w)),I.assign(I.add(zt(U,0,0)))}return I})();const u=me(({p1:d,p2:p,p3:m,p4:y})=>{const x=d.sub(m),v=y.sub(m),w=p.sub(d),M=x.dot(v),S=v.dot(w),C=x.dot(w),N=v.dot(v),U=w.dot(w).mul(N).sub(S.mul(S)),k=M.mul(S).sub(C.mul(N)).div(U).clamp(),G=M.add(S.mul(k)).div(N).clamp();return lt(k,G)});if(this.colorNode=me(()=>{const d=Pi();if(o){const y=this.dashSizeNode?q(this.dashSizeNode):YT,x=this.gapSizeNode?q(this.gapSizeNode):ZT;rp.assign(y),py.assign(x);const v=fa("float","lineDistance");d.y.lessThan(-1).or(d.y.greaterThan(1)).discard(),v.mod(rp.add(py)).greaterThan(rp).discard()}const p=q(1).toVar("alpha");if(a){const y=fa("vec3","worldStart"),x=fa("vec3","worldEnd"),v=fa("vec4","worldPos").xyz.normalize().mul(1e5),w=x.sub(y),M=u({p1:y,p2:x,p3:he(0,0,0),p4:v}),S=y.add(w.mul(M.x)),C=v.mul(M.y),U=S.sub(C).length().div(Bv);if(!o)if(n&&t.currentSamples>0){const F=U.fwidth();p.assign(ga(F.negate().add(.5),F.add(.5),U).oneMinus())}else U.greaterThan(.5).discard()}else if(n&&t.currentSamples>0){const y=d.x,x=d.y.greaterThan(0).select(d.y.sub(1),d.y.add(1)),v=y.mul(y).add(x.mul(x)),w=q(v.fwidth()).toVar("dlen");jt(d.y.abs().greaterThan(1),()=>{p.assign(ga(w.oneMinus(),w.add(1),v).oneMinus())})}else jt(d.y.abs().greaterThan(1),()=>{const y=d.x,x=d.y.greaterThan(0).select(d.y.sub(1),d.y.add(1));y.mul(y).add(x.mul(x)).greaterThan(1).discard()});let m;if(this.lineColorNode)m=this.lineColorNode;else if(r){const y=_o("instanceColorStart"),x=_o("instanceColorEnd");m=Wr.y.lessThan(.5).select(y,x).mul(Lv)}else m=Lv;return zt(m,p)})(),this.transparent){const d=this.opacityNode?q(this.opacityNode):Dv;this.outputNode=zt(this.colorNode.rgb.mul(d).add(dP().rgb.mul(d.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 UG=new Mm;class kG extends Ss{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(UG),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?q(this.opacityNode):Dv;Ni.assign(Sv(zt(gN(mi),e),Pr))}}const ow=me(([i=FT])=>{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 lt(e,t)});class fP extends cr{constructor(e=1,t={}){super(e,t),this.isCubeRenderTarget=!0}fromEquirectangularTexture(e,t){const n=t.minFilter,r=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 o=new fl(5,5,5),a=ow(FT),c=new Ss;c.colorNode=_i(t,a,0),c.side=we,c.blending=ve;const u=new Ji(o,c),d=new Oa;d.add(u),t.minFilter===Vs&&(t.minFilter=Yn);const p=new B_(1,10,this),m=e.getMRT();return e.setMRT(null),p.update(e,d),e.setMRT(m),t.minFilter=n,t.currentGenerateMipmaps=r,u.geometry.dispose(),u.material.dispose(),this}}const Ty=new WeakMap;class zG extends _s{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=vo(null);const t=new nc;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=Xn.RENDER}updateBefore(e){const{renderer:t,material:n}=e,r=this.envNode;if(r.isTextureNode||r.isMaterialReferenceNode){const o=r.isTextureNode?r.value:n[r.property];if(o&&o.isTexture){const a=o.mapping;if(a===jc||a===Yc){if(Ty.has(o)){const c=Ty.get(o);mP(c,o.mapping),this._cubeTexture=c}else{const c=o.image;if(VG(c)){const u=new fP(c.height);u.fromEquirectangularTexture(t,o),mP(u.texture,o.mapping),this._cubeTexture=u.texture,Ty.set(o,u.texture),o.addEventListener("dispose",pP)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function VG(i){return i==null?!1:i.height>0}function pP(i){const e=i.target;e.removeEventListener("dispose",pP);const t=Ty.get(e);t!==void 0&&(Ty.delete(e),t.dispose())}function mP(i,e){e===jc?i.mapping=Cr:e===Yc&&(i.mapping=Xo)}const gP=Fn(zG).setParameterLength(1);class aw extends og{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=gP(this.envNode)}}class GG extends og{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=q(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class zv{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class yP extends zv{constructor(){super()}indirect({context:e}){const t=e.ambientOcclusion,n=e.reflectedLight,r=e.irradianceLightMap;n.indirectDiffuse.assign(zt(0)),r?n.indirectDiffuse.addAssign(r):n.indirectDiffuse.addAssign(zt(1,1,1,0)),n.indirectDiffuse.mulAssign(t),n.indirectDiffuse.mulAssign(Ni.rgb)}finish(e){const{material:t,context:n}=e,r=n.outgoingLight,o=e.context.environment;if(o)switch(t.combine){case Xc:r.rgb.assign(oi(r.rgb,r.rgb.mul(o.rgb),My.mul(Fv)));break;case Hb:r.rgb.assign(oi(r.rgb,o.rgb,My.mul(Fv)));break;case $b:r.rgb.addAssign(o.rgb.mul(My.mul(Fv)));break;default:Ie("BasicLightingModel: Unsupported .combine value:",t.combine);break}}}const WG=new Or;class HG extends Ss{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(WG),this.setValues(e)}setupNormal(){return ig(sg)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new aw(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new GG(JT)),t}setupOutgoingLight(){return Ni.rgb}setupLightingModel(){return new yP}}const ug=me(({f0:i,f90:e,dotVH:t})=>{const n=t.mul(-5.55473).sub(6.98316).mul(t).exp2();return i.mul(n.oneMinus()).add(e.mul(n))}),up=me(i=>i.diffuseColor.mul(1/Math.PI)),$G=()=>q(.25),qG=me(({dotNH:i})=>dv.mul(q(.5)).add(1).mul(q(1/Math.PI)).mul(i.pow(dv))),XG=me(({lightDirection:i})=>{const e=i.add(Bi).normalize(),t=mi.dot(e).clamp(),n=Bi.dot(e).clamp(),r=ug({f0:Gd,f90:1,dotVH:n}),o=$G(),a=qG({dotNH:t});return r.mul(o).mul(a)});class _P extends yP{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const o=mi.dot(e).clamp().mul(t);n.directDiffuse.addAssign(o.mul(up({diffuseColor:Ni.rgb}))),this.specular===!0&&n.directSpecular.addAssign(o.mul(XG({lightDirection:e})).mul(My))}indirect(e){const{ambientOcclusion:t,irradiance:n,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(n.mul(up({diffuseColor:Ni}))),r.indirectDiffuse.mulAssign(t)}}const jG=new Vf;class YG extends Ss{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(jG),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new aw(t):null}setupLightingModel(){return new _P(!1)}}const ZG=new C0;class KG extends Ss{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues(ZG),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new aw(t):null}setupLightingModel(){return new _P}setupVariants(){const e=(this.shininessNode?q(this.shininessNode):xN).max(1e-4);dv.assign(e);const t=this.specularNode||bN;Gd.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const xP=me(i=>{if(i.geometry.hasAttribute("normal")===!1)return q(0);const e=sg.dFdx().abs().max(sg.dFdy().abs());return e.x.max(e.y).max(e.z)}),lw=me(i=>{const{roughness:e}=i,t=xP();let n=e.max(.0525);return n=n.add(t),n=n.min(1),n}),vP=me(({alpha:i,dotNL:e,dotNV:t})=>{const n=i.pow2(),r=e.mul(n.add(n.oneMinus().mul(t.pow2())).sqrt()),o=t.mul(n.add(n.oneMinus().mul(e.pow2())).sqrt());return ma(.5,r.add(o).max(rT))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),JG=me(({alphaT:i,alphaB:e,dotTV:t,dotBV:n,dotTL:r,dotBL:o,dotNV:a,dotNL:c})=>{const u=c.mul(he(i.mul(t),e.mul(n),a).length()),d=a.mul(he(i.mul(r),e.mul(o),c).length());return ma(.5,u.add(d))}).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"}]}),bP=me(({alpha:i,dotNH:e})=>{const t=i.pow2(),n=e.pow2().mul(t.oneMinus()).oneMinus();return t.div(n.pow2()).mul(1/Math.PI)}).setLayout({name:"D_GGX",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNH",type:"float"}]}),QG=q(1/Math.PI),e4=me(({alphaT:i,alphaB:e,dotNH:t,dotTH:n,dotBH:r})=>{const o=i.mul(e),a=he(e.mul(n),i.mul(r),o.mul(t)),c=a.dot(a),u=o.div(c);return QG.mul(o.mul(u.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"}]}),cw=me(({lightDirection:i,f0:e,f90:t,roughness:n,f:r,normalView:o=mi,USE_IRIDESCENCE:a,USE_ANISOTROPY:c})=>{const u=n.pow2(),d=i.add(Bi).normalize(),p=o.dot(i).clamp(),m=o.dot(Bi).clamp(),y=o.dot(d).clamp(),x=Bi.dot(d).clamp();let v=ug({f0:e,f90:t,dotVH:x}),w,M;if(cy(a)&&(v=lv.mix(v,r)),cy(c)){const S=fy.dot(i),C=fy.dot(Bi),N=fy.dot(d),I=ip.dot(i),U=ip.dot(Bi),F=ip.dot(d);w=JG({alphaT:hv,alphaB:u,dotTV:C,dotBV:U,dotTL:S,dotBL:I,dotNV:m,dotNL:p}),M=e4({alphaT:hv,alphaB:u,dotNH:y,dotTH:N,dotBH:F})}else w=vP({alpha:u,dotNL:p,dotNV:m}),M=bP({alpha:u,dotNH:y});return v.mul(w).mul(M)}),t4=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let Fc=null;const wy=me(({roughness:i,dotNV:e})=>{Fc===null&&(Fc=new co(t4,16,16,Nr,Hi),Fc.name="DFG_LUT",Fc.minFilter=Yn,Fc.magFilter=Yn,Fc.wrapS=ki,Fc.wrapT=ki,Fc.generateMipmaps=!1,Fc.needsUpdate=!0);const t=lt(i,e);return _i(Fc,t).rg}),n4=me(({lightDirection:i,f0:e,f90:t,roughness:n,f:r,USE_IRIDESCENCE:o,USE_ANISOTROPY:a})=>{const c=cw({lightDirection:i,f0:e,f90:t,roughness:n,f:r,USE_IRIDESCENCE:o,USE_ANISOTROPY:a}),u=mi.dot(i).clamp(),d=mi.dot(Bi).clamp(),p=wy({roughness:n,dotNV:d}),m=wy({roughness:n,dotNV:u}),y=e.mul(p.x).add(t.mul(p.y)),x=e.mul(m.x).add(t.mul(m.y)),v=p.x.add(p.y),w=m.x.add(m.y),M=q(1).sub(v),S=q(1).sub(w),C=e.add(e.oneMinus().mul(.047619)),N=y.mul(x).mul(C).div(q(1).sub(M.mul(S).mul(C).mul(C)).add(rT)),I=M.mul(S),U=N.mul(I);return c.add(U)}),SP=me(i=>{const{dotNV:e,specularColor:t,specularF90:n,roughness:r}=i,o=wy({dotNV:e,roughness:r});return t.mul(o.x).add(n.mul(o.y))}),uw=me(({f:i,f90:e,dotVH:t})=>{const n=t.oneMinus().saturate(),r=n.mul(n),o=n.mul(r,r).clamp(0,.9999);return i.sub(he(e).mul(o)).div(o.oneMinus())}).setLayout({name:"Schlick_to_F0",type:"vec3",inputs:[{name:"f",type:"vec3"},{name:"f90",type:"float"},{name:"dotVH",type:"float"}]}),i4=me(({roughness:i,dotNH:e})=>{const t=i.pow2(),n=q(1).div(t),o=e.pow2().oneMinus().max(.0078125);return q(2).add(n).mul(o.pow(n.mul(.5))).div(2*Math.PI)}).setLayout({name:"D_Charlie",type:"float",inputs:[{name:"roughness",type:"float"},{name:"dotNH",type:"float"}]}),s4=me(({dotNV:i,dotNL:e})=>q(1).div(q(4).mul(e.add(i).sub(e.mul(i))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),r4=me(({lightDirection:i})=>{const e=i.add(Bi).normalize(),t=mi.dot(i).clamp(),n=mi.dot(Bi).clamp(),r=mi.dot(e).clamp(),o=i4({roughness:zd,dotNH:r}),a=s4({dotNV:n,dotNL:t});return pa.mul(o).mul(a)}),o4=me(({N:i,V:e,roughness:t})=>{const o=.0078125,a=i.dot(e).saturate(),c=lt(t,a.oneMinus().sqrt());return c.assign(c.mul(.984375).add(o)),c}).setLayout({name:"LTC_Uv",type:"vec2",inputs:[{name:"N",type:"vec3"},{name:"V",type:"vec3"},{name:"roughness",type:"float"}]}),MP=me(({f:i})=>{const e=i.length();return vs(e.mul(e).add(i.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),qd=me(({v1:i,v2:e})=>{const t=i.dot(e),n=t.abs().toVar(),r=n.mul(.0145206).add(.4965155).mul(n).add(.8543985).toVar(),o=n.add(4.1616724).mul(n).add(3.417594).toVar(),a=r.div(o),c=t.greaterThan(0).select(a,vs(t.mul(t).oneMinus(),1e-7).inverseSqrt().mul(.5).sub(a));return i.cross(e).mul(c)}).setLayout({name:"LTC_EdgeVectorFormFactor",type:"vec3",inputs:[{name:"v1",type:"vec3"},{name:"v2",type:"vec3"}]}),TP=me(({N:i,V:e,P:t,mInv:n,p0:r,p1:o,p2:a,p3:c})=>{const u=o.sub(r).toVar(),d=c.sub(r).toVar(),p=u.cross(d),m=he().toVar();return jt(p.dot(t.sub(r)).greaterThanEqual(0),()=>{const y=e.sub(i.mul(e.dot(i))).normalize(),x=i.cross(y).negate(),v=n.mul(Vr(y,x,i).transpose()).toVar(),w=v.mul(r.sub(t)).normalize().toVar(),M=v.mul(o.sub(t)).normalize().toVar(),S=v.mul(a.sub(t)).normalize().toVar(),C=v.mul(c.sub(t)).normalize().toVar(),N=he(0).toVar();N.addAssign(qd({v1:w,v2:M})),N.addAssign(qd({v1:M,v2:S})),N.addAssign(qd({v1:S,v2:C})),N.addAssign(qd({v1:C,v2:w})),m.assign(he(MP({f:N})))}),m}).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"}]}),a4=me(({P:i,p0:e,p1:t,p2:n,p3:r})=>{const o=t.sub(e).toVar(),a=r.sub(e).toVar(),c=o.cross(a),u=he().toVar();return jt(c.dot(i.sub(e)).greaterThanEqual(0),()=>{const d=e.sub(i).normalize().toVar(),p=t.sub(i).normalize().toVar(),m=n.sub(i).normalize().toVar(),y=r.sub(i).normalize().toVar(),x=he(0).toVar();x.addAssign(qd({v1:d,v2:p})),x.addAssign(qd({v1:p,v2:m})),x.addAssign(qd({v1:m,v2:y})),x.addAssign(qd({v1:y,v2:d})),u.assign(he(MP({f:x.abs()})))}),u}).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"}]}),Vv=1/6,wP=i=>Bn(Vv,Bn(i,Bn(i,i.negate().add(3)).sub(3)).add(1)),hw=i=>Bn(Vv,Bn(i,Bn(i,Bn(3,i).sub(6))).add(4)),AP=i=>Bn(Vv,Bn(i,Bn(i,Bn(-3,i).add(3)).add(3)).add(1)),dw=i=>Bn(Vv,Xa(i,3)),EP=i=>wP(i).add(hw(i)),CP=i=>AP(i).add(dw(i)),RP=i=>Js(-1,hw(i).div(wP(i).add(hw(i)))),NP=i=>Js(1,dw(i).div(AP(i).add(dw(i)))),PP=(i,e,t)=>{const n=i.uvNode,r=Bn(n,e.zw).add(.5),o=Rc(r),a=El(r),c=EP(a.x),u=CP(a.x),d=RP(a.x),p=NP(a.x),m=RP(a.y),y=NP(a.y),x=lt(o.x.add(d),o.y.add(m)).sub(.5).mul(e.xy),v=lt(o.x.add(p),o.y.add(m)).sub(.5).mul(e.xy),w=lt(o.x.add(d),o.y.add(y)).sub(.5).mul(e.xy),M=lt(o.x.add(p),o.y.add(y)).sub(.5).mul(e.xy),S=EP(a.y).mul(Js(c.mul(i.sample(x).level(t)),u.mul(i.sample(v).level(t)))),C=CP(a.y).mul(Js(c.mul(i.sample(w).level(t)),u.mul(i.sample(M).level(t))));return S.add(C)},fw=me(([i,e])=>{const t=lt(i.size(le(e))),n=lt(i.size(le(e.add(1)))),r=ma(1,t),o=ma(1,n),a=PP(i,zt(r,t),Rc(e)),c=PP(i,zt(o,n),yv(e));return El(e).mix(a,c)}),l4=me(([i,e])=>{const t=e.mul(CT(i));return fw(i,t)}),IP=me(([i,e,t,n,r])=>{const o=he(_T(e.negate(),go(i),ma(1,n))),a=he(Nc(r[0].xyz),Nc(r[1].xyz),Nc(r[2].xyz));return go(o).mul(t.mul(a))}).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"}]}),c4=me(([i,e])=>i.mul(Rl(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),u4=ew(),h4=ew(),LP=me(([i,e,t],{material:n})=>{const o=(n.side===we?u4:h4).sample(i),a=Cc(op.x).mul(c4(e,t));return fw(o,a)}),DP=me(([i,e,t])=>(jt(t.notEqual(0),()=>{const n=gv(e).negate().div(t);return oT(n.negate().mul(i))}),he(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),d4=me(([i,e,t,n,r,o,a,c,u,d,p,m,y,x,v])=>{let w,M;if(v){w=zt().toVar(),M=he().toVar();const U=p.sub(1).mul(v.mul(.025)),F=he(p.sub(U),p,p.add(U));Ai({start:0,end:3},({i:k})=>{const G=F.element(k),B=IP(i,e,m,G,c),z=a.add(B),Q=d.mul(u.mul(zt(z,1))),ye=lt(Q.xy.div(Q.w)).toVar();ye.addAssign(1),ye.divAssign(2),ye.assign(lt(ye.x,ye.y.oneMinus()));const _e=LP(ye,t,G);w.element(k).assign(_e.element(k)),w.a.addAssign(_e.a),M.element(k).assign(n.element(k).mul(DP(Nc(B),y,x).element(k)))}),w.a.divAssign(3)}else{const U=IP(i,e,m,p,c),F=a.add(U),k=d.mul(u.mul(zt(F,1))),G=lt(k.xy.div(k.w)).toVar();G.addAssign(1),G.divAssign(2),G.assign(lt(G.x,G.y.oneMinus())),w=LP(G,t,p),M=n.mul(DP(Nc(U),y,x))}const S=M.rgb.mul(w.rgb),C=i.dot(e).clamp(),N=he(SP({dotNV:C,specularColor:r,specularF90:o,roughness:t})),I=M.r.add(M.g,M.b).div(3);return zt(N.oneMinus().mul(S),w.a.oneMinus().mul(I).oneMinus())}),f4=Vr(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),p4=i=>{const e=i.sqrt();return he(1).add(e).div(he(1).sub(e))},FP=(i,e)=>i.sub(e).div(i.add(e)).pow2(),m4=(i,e)=>{const t=i.mul(2*Math.PI*1e-9),n=he(54856e-17,44201e-17,52481e-17),r=he(1681e3,1795300,2208400),o=he(43278e5,93046e5,66121e5),a=q(9747e-17*Math.sqrt(2*Math.PI*45282e5)).mul(t.mul(2239900).add(e.x).cos()).mul(t.pow2().mul(-45282e5).exp());let c=n.mul(o.mul(2*Math.PI).sqrt()).mul(r.mul(t).add(e).cos()).mul(t.pow2().negate().mul(o).exp());return c=he(c.x.add(a),c.y,c.z).div(10685e-11),f4.mul(c)},BP=me(({outsideIOR:i,eta2:e,cosTheta1:t,thinFilmThickness:n,baseF0:r})=>{const o=oi(i,e,ga(0,.03,n)),c=i.div(o).pow2().mul(t.pow2().oneMinus()).oneMinus();jt(c.lessThan(0),()=>he(1));const u=c.sqrt(),d=FP(o,i),p=ug({f0:d,f90:1,dotVH:t}),m=p.oneMinus(),y=o.lessThan(i).select(Math.PI,0),x=q(Math.PI).sub(y),v=p4(r.clamp(0,.9999)),w=FP(v,o.toVec3()),M=ug({f0:w,f90:1,dotVH:u}),S=he(v.x.lessThan(o).select(Math.PI,0),v.y.lessThan(o).select(Math.PI,0),v.z.lessThan(o).select(Math.PI,0)),C=o.mul(n,u,2),N=he(x).add(S),I=p.mul(M).clamp(1e-5,.9999),U=I.sqrt(),F=m.pow2().mul(M).div(he(1).sub(I)),G=p.add(F).toVar(),B=F.sub(m).toVar();return Ai({start:1,end:2,condition:"<=",name:"m"},({m:z})=>{B.mulAssign(U);const Q=m4(q(z).mul(C),q(z).mul(N)).mul(2);G.addAssign(B.mul(Q))}),G.max(he(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"}]}),Ay=me(({normal:i,viewDir:e,roughness:t})=>{const n=i.dot(e).saturate(),r=t.mul(t),o=t.add(.1).reciprocal(),a=q(-1.9362).add(t.mul(1.0678)).add(r.mul(.4573)).sub(o.mul(.8469)),c=q(-.6014).add(t.mul(.5538)).sub(r.mul(.467)).sub(o.mul(.1255));return a.mul(n).add(c).exp().saturate()}),pw=he(.04),mw=q(1);class OP extends zv{constructor(e=!1,t=!1,n=!1,r=!1,o=!1,a=!1){super(),this.clearcoat=e,this.sheen=t,this.iridescence=n,this.anisotropy=r,this.transmission=o,this.dispersion=a,this.clearcoatRadiance=null,this.clearcoatSpecularDirect=null,this.clearcoatSpecularIndirect=null,this.sheenSpecularDirect=null,this.sheenSpecularIndirect=null,this.iridescenceFresnel=null,this.iridescenceF0=null,this.iridescenceF0Dielectric=null,this.iridescenceF0Metallic=null}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=he().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=he().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=he().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=he().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=he().toVar("sheenSpecularIndirect")),this.iridescence===!0){const t=mi.dot(Bi).clamp(),n=BP({outsideIOR:q(1),eta2:cv,cosTheta1:t,thinFilmThickness:uv,baseF0:Gd}),r=BP({outsideIOR:q(1),eta2:cv,cosTheta1:t,thinFilmThickness:uv,baseF0:Ni.rgb});this.iridescenceFresnel=oi(n,r,th),this.iridescenceF0Dielectric=uw({f:n,f90:1,dotVH:t}),this.iridescenceF0Metallic=uw({f:r,f90:1,dotVH:t}),this.iridescenceF0=oi(this.iridescenceF0Dielectric,this.iridescenceF0Metallic,th)}if(this.transmission===!0){const t=_a,n=by.sub(_a).normalize(),r=$d,o=e.context;o.backdrop=d4(r,n,Ec,np,sp,Km,t,Ya,ya,xo,my,JM,eT,QM,this.dispersion?tT:null),o.backdropAlpha=fv,Ni.a.mulAssign(oi(1,o.backdrop.a,fv))}super.start(e)}computeMultiscattering(e,t,n,r,o=null){const a=mi.dot(Bi).clamp(),c=wy({roughness:Ec,dotNV:a}),u=o?lv.mix(r,o):r,d=u.mul(c.x).add(n.mul(c.y)),m=c.x.add(c.y).oneMinus(),y=u.add(u.oneMinus().mul(.047619)),x=d.mul(y).div(m.mul(y).oneMinus());e.addAssign(d),t.addAssign(x.mul(m))}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const o=mi.dot(e).clamp().mul(t).toVar();if(this.sheen===!0){this.sheenSpecularDirect.addAssign(o.mul(r4({lightDirection:e})));const a=Ay({normal:mi,viewDir:Bi,roughness:zd}),c=Ay({normal:mi,viewDir:e,roughness:zd}),u=pa.r.max(pa.g).max(pa.b).mul(a.max(c)).oneMinus();o.mulAssign(u)}if(this.clearcoat===!0){const c=lp.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(c.mul(cw({lightDirection:e,f0:pw,f90:mw,roughness:dy,normalView:lp})))}n.directDiffuse.addAssign(o.mul(up({diffuseColor:np}))),n.directSpecular.addAssign(o.mul(n4({lightDirection:e,f0:sp,f90:1,roughness:Ec,f:this.iridescenceFresnel,USE_IRIDESCENCE:this.iridescence,USE_ANISOTROPY:this.anisotropy})))}directRectArea({lightColor:e,lightPosition:t,halfWidth:n,halfHeight:r,reflectedLight:o,ltc_1:a,ltc_2:c}){const u=t.add(n).sub(r),d=t.sub(n).sub(r),p=t.sub(n).add(r),m=t.add(n).add(r),y=mi,x=Bi,v=Us.toVar(),w=o4({N:y,V:x,roughness:Ec}),M=a.sample(w).toVar(),S=c.sample(w).toVar(),C=Vr(he(M.x,0,M.y),he(0,1,0),he(M.z,0,M.w)).toVar(),N=sp.mul(S.x).add(sp.oneMinus().mul(S.y)).toVar();o.directSpecular.addAssign(e.mul(N).mul(TP({N:y,V:x,P:v,mInv:C,p0:u,p1:d,p2:p,p3:m}))),o.directDiffuse.addAssign(e.mul(np).mul(TP({N:y,V:x,P:v,mInv:Vr(1,0,0,0,1,0,0,0,1),p0:u,p1:d,p2:p,p3:m})))}indirect(e){this.indirectDiffuse(e),this.indirectSpecular(e),this.ambientOcclusion(e)}indirectDiffuse(e){const{irradiance:t,reflectedLight:n}=e.context,r=t.mul(up({diffuseColor:np})).toVar();if(this.sheen===!0){const o=Ay({normal:mi,viewDir:Bi,roughness:zd}),a=pa.r.max(pa.g).max(pa.b).mul(o).oneMinus();r.mulAssign(a)}n.indirectDiffuse.addAssign(r)}indirectSpecular(e){const{radiance:t,iblIrradiance:n,reflectedLight:r}=e.context;if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(n.mul(pa,Ay({normal:mi,viewDir:Bi,roughness:zd}))),this.clearcoat===!0){const M=lp.dot(Bi).clamp(),S=SP({dotNV:M,specularColor:pw,specularF90:mw,roughness:dy});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(S))}const o=he().toVar("singleScatteringDielectric"),a=he().toVar("multiScatteringDielectric"),c=he().toVar("singleScatteringMetallic"),u=he().toVar("multiScatteringMetallic");this.computeMultiscattering(o,a,Km,Gd,this.iridescenceF0Dielectric),this.computeMultiscattering(c,u,Km,Ni.rgb,this.iridescenceF0Metallic);const d=oi(o,c,th),p=oi(a,u,th),m=o.add(a),y=np.mul(m.oneMinus()),x=n.mul(1/Math.PI),v=t.mul(d).add(p.mul(x)).toVar(),w=y.mul(x).toVar();if(this.sheen===!0){const M=Ay({normal:mi,viewDir:Bi,roughness:zd}),S=pa.r.max(pa.g).max(pa.b).mul(M).oneMinus();v.mulAssign(S),w.mulAssign(S)}r.indirectSpecular.addAssign(v),r.indirectDiffuse.addAssign(w)}ambientOcclusion(e){const{ambientOcclusion:t,reflectedLight:n}=e.context,o=mi.dot(Bi).clamp().add(t),a=Ec.mul(-16).oneMinus().negate().exp2(),c=t.sub(o.pow(a).oneMinus()).clamp();this.clearcoat===!0&&this.clearcoatSpecularIndirect.mulAssign(t),this.sheen===!0&&this.sheenSpecularIndirect.mulAssign(t),n.indirectDiffuse.mulAssign(t),n.indirectSpecular.mulAssign(c)}finish({context:e}){const{outgoingLight:t}=e;if(this.clearcoat===!0){const n=lp.dot(Bi).clamp(),r=ug({dotVH:n,f0:pw,f90:mw}),o=t.mul(av.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(av));t.assign(o)}if(this.sheen===!0){const n=t.add(this.sheenSpecularDirect,this.sheenSpecularIndirect.mul(1/Math.PI));t.assign(n)}}}const UP=q(1),gw=q(-2),Gv=q(.8),yw=q(-1),Wv=q(.4),_w=q(2),Hv=q(.305),xw=q(3),kP=q(.21),g4=q(4),zP=q(4),y4=q(16),_4=me(([i])=>{const e=he(qi(i)).toVar(),t=q(-1).toVar();return jt(e.x.greaterThan(e.z),()=>{jt(e.x.greaterThan(e.y),()=>{t.assign(Gr(i.x.greaterThan(0),0,3))}).Else(()=>{t.assign(Gr(i.y.greaterThan(0),1,4))})}).Else(()=>{jt(e.z.greaterThan(e.y),()=>{t.assign(Gr(i.z.greaterThan(0),2,5))}).Else(()=>{t.assign(Gr(i.y.greaterThan(0),1,4))})}),t}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),x4=me(([i,e])=>{const t=lt().toVar();return jt(e.equal(0),()=>{t.assign(lt(i.z,i.y).div(qi(i.x)))}).ElseIf(e.equal(1),()=>{t.assign(lt(i.x.negate(),i.z.negate()).div(qi(i.y)))}).ElseIf(e.equal(2),()=>{t.assign(lt(i.x.negate(),i.y).div(qi(i.z)))}).ElseIf(e.equal(3),()=>{t.assign(lt(i.z.negate(),i.y).div(qi(i.x)))}).ElseIf(e.equal(4),()=>{t.assign(lt(i.x.negate(),i.z).div(qi(i.y)))}).Else(()=>{t.assign(lt(i.x,i.y).div(qi(i.z)))}),Bn(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),v4=me(([i])=>{const e=q(0).toVar();return jt(i.greaterThanEqual(Gv),()=>{e.assign(UP.sub(i).mul(yw.sub(gw)).div(UP.sub(Gv)).add(gw))}).ElseIf(i.greaterThanEqual(Wv),()=>{e.assign(Gv.sub(i).mul(_w.sub(yw)).div(Gv.sub(Wv)).add(yw))}).ElseIf(i.greaterThanEqual(Hv),()=>{e.assign(Wv.sub(i).mul(xw.sub(_w)).div(Wv.sub(Hv)).add(_w))}).ElseIf(i.greaterThanEqual(kP),()=>{e.assign(Hv.sub(i).mul(g4.sub(xw)).div(Hv.sub(kP)).add(xw))}).Else(()=>{e.assign(q(-2).mul(Cc(Bn(1.16,i))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),VP=me(([i,e])=>{const t=i.toVar();t.assign(Bn(2,t).sub(1));const n=he(t,1).toVar();return jt(e.equal(0),()=>{n.assign(n.zyx)}).ElseIf(e.equal(1),()=>{n.assign(n.xzy),n.xz.mulAssign(-1)}).ElseIf(e.equal(2),()=>{n.x.mulAssign(-1)}).ElseIf(e.equal(3),()=>{n.assign(n.zyx),n.xz.mulAssign(-1)}).ElseIf(e.equal(4),()=>{n.assign(n.xzy),n.xy.mulAssign(-1)}).ElseIf(e.equal(5),()=>{n.z.mulAssign(-1)}),n}).setLayout({name:"getDirection",type:"vec3",inputs:[{name:"uv",type:"vec2"},{name:"face",type:"float"}]}),GP=me(([i,e,t,n,r,o])=>{const a=q(t),c=he(e),u=Rl(v4(a),gw,o),d=El(u),p=Rc(u),m=he(Ey(i,c,p,n,r,o)).toVar();return jt(d.notEqual(0),()=>{const y=he(Ey(i,c,p.add(1),n,r,o)).toVar();m.assign(oi(m,y,d))}),m}),Ey=me(([i,e,t,n,r,o])=>{const a=q(t).toVar(),c=he(e),u=q(_4(c)).toVar(),d=q(vs(zP.sub(a),0)).toVar();a.assign(vs(a,zP));const p=q(Qm(a)).toVar(),m=lt(x4(c,u).mul(p.sub(2)).add(1)).toVar();return jt(u.greaterThan(2),()=>{m.y.addAssign(p),u.subAssign(3)}),m.x.addAssign(u.mul(p)),m.x.addAssign(d.mul(Bn(3,y4))),m.y.addAssign(Bn(4,Qm(o).sub(p))),m.x.mulAssign(n),m.y.mulAssign(r),i.sample(m).grad(lt(),lt())}),vw=me(({envMap:i,mipInt:e,outputDirection:t,theta:n,axis:r,CUBEUV_TEXEL_WIDTH:o,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:c})=>{const u=Cl(n),d=t.mul(u).add(r.cross(t).mul(yo(n))).add(r.mul(r.dot(t).mul(u.oneMinus())));return Ey(i,d,e,o,a,c)}),WP=me(({n:i,latitudinal:e,poleAxis:t,outputDirection:n,weights:r,samples:o,dTheta:a,mipInt:c,envMap:u,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:m})=>{const y=he(Gr(e,t,nh(t,n))).toVar();jt(y.equal(he(0)),()=>{y.assign(he(n.z,0,n.x.negate()))}),y.assign(go(y));const x=he().toVar();return x.addAssign(r.element(0).mul(vw({theta:0,axis:y,outputDirection:n,mipInt:c,envMap:u,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:m}))),Ai({start:le(1),end:i},({i:v})=>{jt(v.greaterThanEqual(o),()=>{QN()});const w=q(a.mul(q(v))).toVar();x.addAssign(r.element(v).mul(vw({theta:w.mul(-1),axis:y,outputDirection:n,mipInt:c,envMap:u,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:m}))),x.addAssign(r.element(v).mul(vw({theta:w,axis:y,outputDirection:n,mipInt:c,envMap:u,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:m})))}),zt(x,1)}),b4=me(([i])=>{const e=it(i).toVar();return e.assign(e.shiftLeft(it(16)).bitOr(e.shiftRight(it(16)))),e.assign(e.bitAnd(it(1431655765)).shiftLeft(it(1)).bitOr(e.bitAnd(it(2863311530)).shiftRight(it(1)))),e.assign(e.bitAnd(it(858993459)).shiftLeft(it(2)).bitOr(e.bitAnd(it(3435973836)).shiftRight(it(2)))),e.assign(e.bitAnd(it(252645135)).shiftLeft(it(4)).bitOr(e.bitAnd(it(4042322160)).shiftRight(it(4)))),e.assign(e.bitAnd(it(16711935)).shiftLeft(it(8)).bitOr(e.bitAnd(it(4278255360)).shiftRight(it(8)))),q(e).mul(23283064365386963e-26)}),S4=me(([i,e])=>lt(q(i).div(q(e)),b4(i))),M4=me(([i,e,t])=>{const n=he(e).toVar(),r=q(t),o=r.mul(r).toVar(),a=go(he(o.mul(n.x),o.mul(n.y),n.z)).toVar(),c=a.x.mul(a.x).add(a.y.mul(a.y)),u=Gr(c.greaterThan(0),he(a.y.negate(),a.x,0).div(Qr(c)),he(1,0,0)).toVar(),d=nh(a,u).toVar(),p=Qr(i.x),m=Bn(2,3.14159265359).mul(i.y),y=p.mul(Cl(m)).toVar(),x=p.mul(yo(m)).toVar(),v=Bn(.5,a.z.add(1));x.assign(v.oneMinus().mul(Qr(y.mul(y).oneMinus())).add(v.mul(x)));const w=u.mul(y).add(d.mul(x)).add(a.mul(Qr(vs(0,y.mul(y).add(x.mul(x)).oneMinus()))));return go(he(o.mul(w.x),o.mul(w.y),vs(0,w.z)))}),HP=me(({roughness:i,mipInt:e,envMap:t,N_immutable:n,GGX_SAMPLES:r,CUBEUV_TEXEL_WIDTH:o,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:c})=>{const u=he(n).toVar(),d=he(0).toVar(),p=q(0).toVar();return jt(i.lessThan(.001),()=>{d.assign(Ey(t,u,e,o,a,c))}).Else(()=>{const m=Gr(qi(u.z).lessThan(.999),he(0,0,1),he(1,0,0)),y=go(nh(m,u)).toVar(),x=nh(u,y).toVar();Ai({start:it(0),end:r},({i:v})=>{const w=S4(v,r),M=M4(w,he(0,0,1),i),S=go(y.mul(M.x).add(x.mul(M.y)).add(u.mul(M.z))),C=go(S.mul(qa(u,S).mul(2)).sub(u)),N=vs(qa(u,C),0);jt(N.greaterThan(0),()=>{const I=Ey(t,C,e,o,a,c);d.addAssign(I.mul(N)),p.addAssign(N)})}),jt(p.greaterThan(0),()=>{d.assign(d.div(p))})}),zt(d,1)}),Xd=4,$P=[.125,.215,.35,.446,.526,.582],hp=20,T4=512,Cy=new $u(-1,1,1,-1,0,1),w4=new Bs(90,1),qP=new It;let bw=null,Sw=0,Mw=0;const A4=new H,$v=new WeakMap,E4=[3,1,5,0,4,2],Tw=VP(Pi(),_o("faceIndex")).normalize(),qv=he(Tw.x,Tw.y,Tw.z);class C4{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,n=.1,r=100,o={}){const{size:a=256,position:c=A4,renderTarget:u=null}=o;if(this._setSize(a),this._hasInitialized===!1){Ie('PMREMGenerator: ".fromScene()" called before the backend is initialized. Try using "await renderer.init()" instead.');const p=u||this._allocateTarget();return o.renderTarget=p,this.fromSceneAsync(e,t,n,r,o),p}bw=this._renderer.getRenderTarget(),Sw=this._renderer.getActiveCubeFace(),Mw=this._renderer.getActiveMipmapLevel();const d=u||this._allocateTarget();return d.depthBuffer=!0,this._init(d),this._sceneToCubeUV(e,n,r,d,c),t>0&&this._blur(d,0,0,t),this._applyPMREM(d),this._cleanup(d),d}fromSceneAsync(a){return mn(this,arguments,function*(e,t=0,n=.1,r=100,o={}){return Ut('PMREMGenerator: ".fromSceneAsync()" is deprecated. Use "await renderer.init()" instead.'),yield this._renderer.init(),this.fromScene(e,t,n,r,o)})}fromEquirectangular(e,t=null){if(this._hasInitialized===!1){Ie('PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using "await renderer.init()" instead.'),this._setSizeFromTexture(e);const n=t||this._allocateTarget();return this.fromEquirectangularAsync(e,n),n}return this._fromTexture(e,t)}fromEquirectangularAsync(e,t=null){return mn(this,null,function*(){return Ut('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){Ie("PMREMGenerator: .fromCubemap() called before the backend is initialized. Try using .fromCubemapAsync() instead."),this._setSizeFromTexture(e);const n=t||this._allocateTarget();return this.fromCubemapAsync(e,t),n}return this._fromTexture(e,t)}fromCubemapAsync(e,t=null){return mn(this,null,function*(){return Ut('PMREMGenerator: ".fromCubemapAsync()" is deprecated. Use "await renderer.init()" instead.'),yield this._renderer.init(),this._fromTexture(e,t)})}compileCubemapShader(){return mn(this,null,function*(){this._cubemapMaterial===null&&(this._cubemapMaterial=jP(),yield this._compileMaterial(this._cubemapMaterial))})}compileEquirectangularShader(){return mn(this,null,function*(){this._equirectMaterial===null&&(this._equirectMaterial=YP(),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===Cr||e.mapping===Xo?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(bw,Sw,Mw),e.scissorTest=!1,hg(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),bw=this._renderer.getRenderTarget(),Sw=this._renderer.getActiveCubeFace(),Mw=this._renderer.getActiveMipmapLevel();const n=t||this._allocateTarget();return this._init(n),this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTarget(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize;return XP(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=XP(e.width,e.height);const{_lodMax:t}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=R4(t)),this._blurMaterial=N4(t,e.width,e.height),this._ggxMaterial=P4(t,e.width,e.height)}}_compileMaterial(e){return mn(this,null,function*(){const t=new Ji(new Gn,e);yield this._renderer.compile(t,Cy)})}_sceneToCubeUV(e,t,n,r,o){const a=w4;a.near=t,a.far=n;const c=[1,1,1,1,-1,1],u=[1,-1,1,-1,1,-1],d=this._renderer,p=d.autoClear;d.getClearColor(qP),d.autoClear=!1,this._backgroundBox===null&&(this._backgroundBox=new Ji(new fl,new Or({name:"PMREM.Background",side:we,depthWrite:!1,depthTest:!1})));const m=this._backgroundBox,y=m.material;let x=!1;const v=e.background;v?v.isColor&&(y.color.copy(v),e.background=null,x=!0):(y.color.copy(qP),x=!0),d.setRenderTarget(r),d.clear(),x&&d.render(m,a);for(let w=0;w<6;w++){const M=w%3;M===0?(a.up.set(0,c[w],0),a.position.set(o.x,o.y,o.z),a.lookAt(o.x+u[w],o.y,o.z)):M===1?(a.up.set(0,0,c[w]),a.position.set(o.x,o.y,o.z),a.lookAt(o.x,o.y+u[w],o.z)):(a.up.set(0,c[w],0),a.position.set(o.x,o.y,o.z),a.lookAt(o.x,o.y,o.z+u[w]));const S=this._cubeSize;hg(r,M*S,w>2?S:0,S,S),d.render(e,a)}d.autoClear=p,e.background=v}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===Cr||e.mapping===Xo;r?this._cubemapMaterial===null&&(this._cubemapMaterial=jP(e)):this._equirectMaterial===null&&(this._equirectMaterial=YP(e));const o=r?this._cubemapMaterial:this._equirectMaterial;o.fragmentNode.value=e;const a=this._lodMeshes[0];a.material=o;const c=this._cubeSize;hg(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(a,Cy)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodMeshes.length;for(let o=1;o<r;o++)this._applyGGXFilter(e,o-1,o);t.autoClear=n}_applyGGXFilter(e,t,n){const r=this._renderer,o=this._pingPongRenderTarget,a=this._ggxMaterial,c=this._lodMeshes[n];c.material=a;const u=$v.get(a),d=n/(this._lodMeshes.length-1),p=t/(this._lodMeshes.length-1),m=Math.sqrt(d*d-p*p),y=0+d*1.25,x=m*y,{_lodMax:v}=this,w=this._sizeLods[n],M=3*w*(n>v-Xd?n-v+Xd:0),S=4*(this._cubeSize-w);e.texture.frame=(e.texture.frame||0)+1,u.envMap.value=e.texture,u.roughness.value=x,u.mipInt.value=v-t,hg(o,M,S,3*w,2*w),r.setRenderTarget(o),r.render(c,Cy),o.texture.frame=(o.texture.frame||0)+1,u.envMap.value=o.texture,u.roughness.value=0,u.mipInt.value=v-n,hg(e,M,S,3*w,2*w),r.setRenderTarget(e),r.render(c,Cy)}_blur(e,t,n,r,o){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,r,"latitudinal",o),this._halfBlur(a,e,n,n,r,"longitudinal",o)}_halfBlur(e,t,n,r,o,a,c){const u=this._renderer,d=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Be("blur direction must be either latitudinal or longitudinal!");const p=3,m=this._lodMeshes[r];m.material=d;const y=$v.get(d),x=this._sizeLods[n]-1,v=isFinite(o)?Math.PI/(2*x):2*Math.PI/(2*hp-1),w=o/v,M=isFinite(o)?1+Math.floor(p*w):hp;M>hp&&Ie(`sigmaRadians, ${o}, is too large and will clip, as it requested ${M} samples when the maximum is set to ${hp}`);const S=[];let C=0;for(let k=0;k<hp;++k){const G=k/w,B=Math.exp(-G*G/2);S.push(B),k===0?C+=B:k<M&&(C+=2*B)}for(let k=0;k<S.length;k++)S[k]=S[k]/C;e.texture.frame=(e.texture.frame||0)+1,y.envMap.value=e.texture,y.samples.value=M,y.weights.array=S,y.latitudinal.value=a==="latitudinal"?1:0,c&&(y.poleAxis.value=c);const{_lodMax:N}=this;y.dTheta.value=v,y.mipInt.value=N-n;const I=this._sizeLods[r],U=3*I*(r>N-Xd?r-N+Xd:0),F=4*(this._cubeSize-I);hg(t,U,F,3*I,2*I),u.setRenderTarget(t),u.render(m,Cy)}}function R4(i){const e=[],t=[],n=[];let r=i;const o=i-Xd+1+$P.length;for(let a=0;a<o;a++){const c=Math.pow(2,r);e.push(c);let u=1/c;a>i-Xd?u=$P[a-i+Xd-1]:a===0&&(u=0),t.push(u);const d=1/(c-2),p=-d,m=1+d,y=[p,p,m,p,m,m,p,p,m,m,p,m],x=6,v=6,w=3,M=2,S=1,C=new Float32Array(w*v*x),N=new Float32Array(M*v*x),I=new Float32Array(S*v*x);for(let F=0;F<x;F++){const k=F%3*2/3-1,G=F>2?0:-1,B=[k,G,0,k+2/3,G,0,k+2/3,G+1,0,k,G,0,k+2/3,G+1,0,k,G+1,0],z=E4[F];C.set(B,w*v*z),N.set(y,M*v*z);const Q=[z,z,z,z,z,z];I.set(Q,S*v*z)}const U=new Gn;U.setAttribute("position",new $i(C,w)),U.setAttribute("uv",new $i(N,M)),U.setAttribute("faceIndex",new $i(I,S)),n.push(new Ji(U,null)),r>Xd&&r--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function XP(i,e){const t={magFilter:Yn,minFilter:Yn,generateMipmaps:!1,type:Hi,format:Ri,colorSpace:io},n=new Ws(i,e,t);return n.texture.mapping=Fl,n.texture.name="PMREM.cubeUv",n.texture.isPMREMTexture=!0,n.scissorTest=!0,n}function hg(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function Xv(i){const e=new Ss;return e.depthTest=!1,e.depthWrite=!1,e.blending=ve,e.name=`PMREM_${i}`,e}function N4(i,e,t){const n=eo(new Array(hp).fill(0)),r=rn(new H(0,1,0)),o=rn(0),a=q(hp),c=rn(0),u=rn(1),d=_i(),p=rn(0),m=q(1/e),y=q(1/t),x=q(i),v={n:a,latitudinal:c,weights:n,poleAxis:r,outputDirection:qv,dTheta:o,samples:u,envMap:d,mipInt:p,CUBEUV_TEXEL_WIDTH:m,CUBEUV_TEXEL_HEIGHT:y,CUBEUV_MAX_MIP:x},w=Xv("blur");return w.fragmentNode=WP(Mo(wi({},v),{latitudinal:c.equal(1)})),$v.set(w,v),w}function P4(i,e,t){const n=_i(),r=rn(0),o=rn(0),a=q(1/e),c=q(1/t),u=q(i),d={envMap:n,roughness:r,mipInt:o,CUBEUV_TEXEL_WIDTH:a,CUBEUV_TEXEL_HEIGHT:c,CUBEUV_MAX_MIP:u},p=Xv("ggx");return p.fragmentNode=HP(Mo(wi({},d),{N_immutable:qv,GGX_SAMPLES:it(T4)})),$v.set(p,d),p}function jP(i){const e=Xv("cubemap");return e.fragmentNode=vo(i,qv),e}function YP(i){const e=Xv("equirect");return e.fragmentNode=_i(i,ow(qv),0),e}const ZP=new WeakMap;function I4(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 L4(i,e,t){const n=D4(e);let r=n.get(i);if((r!==void 0?r.pmremVersion:-1)!==i.pmremVersion){const a=i.image;if(i.isCubeTexture)if(B4(a))r=t.fromCubemap(i,r);else return null;else if(O4(a))r=t.fromEquirectangular(i,r);else return null;r.pmremVersion=i.pmremVersion,n.set(i,r)}return r.texture}function D4(i){let e=ZP.get(i);return e===void 0&&(e=new WeakMap,ZP.set(i,e)),e}class F4 extends _s{static get type(){return"PMREMNode"}constructor(e,t=null,n=null){super("vec3"),this._value=e,this._pmrem=null,this.uvNode=t,this.levelNode=n,this._generator=null;const r=new fi;r.isRenderTargetTexture=!0,this._texture=_i(r),this._width=rn(0),this._height=rn(0),this._maxMip=rn(0),this.updateBeforeType=Xn.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=I4(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 n=t?t.pmremVersion:-1,r=this._value;n!==r.pmremVersion&&(r.isPMREMTexture===!0?t=r:t=L4(r,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new C4(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this,e)),t=kT.mul(he(t.x,t.y.negate(),t.z));let n=this.levelNode;return n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),GP(this._texture,t,n,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}}function B4(i){if(i==null)return!1;let e=0;const t=6;for(let n=0;n<t;n++)i[n]!==void 0&&e++;return e===t}function O4(i){return i==null?!1:i.height>0}const ww=Fn(F4).setParameterLength(1,3),KP=new WeakMap;class U4 extends og{static get type(){return"EnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){const{material:t}=e;let n=this.envNode;if(n.isTextureNode||n.isMaterialReferenceNode){const m=n.isTextureNode?n.value:t[n.property];let y=KP.get(m);y===void 0&&(y=ww(m),KP.set(m,y)),n=y}const o=t.useAnisotropy===!0||t.anisotropy>0?mN:mi,a=n.context(JP(Ec,o)).mul(Cv),c=n.context(k4($d)).mul(Math.PI).mul(Cv),u=tg(a),d=tg(c);e.context.radiance.addAssign(u),e.context.iblIrradiance.addAssign(d);const p=e.context.lightingModel.clearcoatRadiance;if(p){const m=n.context(JP(dy,lp)).mul(Cv),y=tg(m);p.addAssign(y)}}}const JP=(i,e)=>{let t=null;return{getUV:()=>(t===null&&(t=Bi.negate().reflect(e),t=gT(i).mix(t,e).normalize(),t=t.transformDirection(ya)),t),getTextureLevel:()=>i}},k4=i=>({getUV:()=>i,getTextureLevel:()=>q(1)}),z4=new E0;class QP extends Ss{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(z4),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new U4(t):null}setupLightingModel(){return new OP}setupSpecular(){const e=oi(he(.04),Ni.rgb,th);Gd.assign(he(.04)),sp.assign(e),Km.assign(1)}setupVariants(){const e=this.metalnessNode?q(this.metalnessNode):TN;th.assign(e);let t=this.roughnessNode?q(this.roughnessNode):MN;t=lw({roughness:t}),Ec.assign(t),this.setupSpecular(),np.assign(Ni.rgb.mul(e.oneMinus()))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const V4=new fc;class G4 extends QP{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(V4),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?q(this.iorNode):UN;my.assign(e),Gd.assign(ko(mT(my.sub(1).div(my.add(1))).mul(SN),he(1)).mul(XT)),sp.assign(oi(Gd,Ni.rgb,th)),Km.assign(oi(XT,1,th))}setupLightingModel(){return new OP(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const t=this.clearcoatNode?q(this.clearcoatNode):AN,n=this.clearcoatRoughnessNode?q(this.clearcoatRoughnessNode):EN;av.assign(t),dy.assign(lw({roughness:n}))}if(this.useSheen){const t=this.sheenNode?he(this.sheenNode):NN,n=this.sheenRoughnessNode?q(this.sheenRoughnessNode):PN;pa.assign(t),zd.assign(n)}if(this.useIridescence){const t=this.iridescenceNode?q(this.iridescenceNode):LN,n=this.iridescenceIORNode?q(this.iridescenceIORNode):DN,r=this.iridescenceThicknessNode?q(this.iridescenceThicknessNode):FN;lv.assign(t),cv.assign(n),uv.assign(r)}if(this.useAnisotropy){const t=(this.anisotropyNode?lt(this.anisotropyNode):IN).toVar();Vd.assign(t.length()),jt(Vd.equal(0),()=>{t.assign(lt(1,0))}).Else(()=>{t.divAssign(lt(Vd)),Vd.assign(Vd.saturate())}),hv.assign(Vd.pow2().mix(Ec.pow2(),1)),fy.assign(cp[0].mul(t.x).add(cp[1].mul(t.y))),ip.assign(cp[1].mul(t.x).sub(cp[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?q(this.transmissionNode):BN,n=this.thicknessNode?q(this.thicknessNode):ON,r=this.attenuationDistanceNode?q(this.attenuationDistanceNode):kN,o=this.attenuationColorNode?he(this.attenuationColorNode):zN;if(fv.assign(t),JM.assign(n),QM.assign(r),eT.assign(o),this.useDispersion){const a=this.dispersionNode?q(this.dispersionNode):GN;tT.assign(a)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?he(this.clearcoatNormalNode):CN}setup(e){e.context.setupClearcoatNormal=()=>eg(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 W4 extends null{constructor(e=!1,t=!1,n=!1,r=!1,o=!1,a=!1,c=!1){super(e,t,n,r,o,a),this.useSSS=c}direct({lightDirection:e,lightColor:t,reflectedLight:n},r){if(this.useSSS===!0){const o=r.material,{thicknessColorNode:a,thicknessDistortionNode:c,thicknessAmbientNode:u,thicknessAttenuationNode:d,thicknessPowerNode:p,thicknessScaleNode:m}=o,y=e.add(mi.mul(c)).normalize(),x=q(Bi.dot(y.negate()).saturate().pow(p).mul(m)),v=he(x.add(u).mul(a));n.directDiffuse.addAssign(v.mul(d.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:n},r)}}class qZ extends null{static get type(){return"MeshSSSNodeMaterial"}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=q(.1),this.thicknessAmbientNode=q(0),this.thicknessAttenuationNode=q(.1),this.thicknessPowerNode=q(2),this.thicknessScaleNode=q(10)}get useSSS(){return this.thicknessColorNode!==null}setupLightingModel(){return new W4(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 H4=me(({normal:i,lightDirection:e,builder:t})=>{const n=i.dot(e),r=lt(n.mul(.5).add(.5),0);if(t.material.gradientMap){const o=uh("gradientMap","texture").context({getUV:()=>r});return he(o.r)}else{const o=r.fwidth().mul(.5);return oi(he(.7),he(1),ga(q(.7).sub(o.x),q(.7).add(o.x),r.x))}});class $4 extends zv{direct({lightDirection:e,lightColor:t,reflectedLight:n},r){const o=H4({normal:Ev,lightDirection:e,builder:r}).mul(t);n.directDiffuse.addAssign(o.mul(up({diffuseColor:Ni.rgb})))}indirect(e){const{ambientOcclusion:t,irradiance:n,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(n.mul(up({diffuseColor:Ni}))),r.indirectDiffuse.mulAssign(t)}}const q4=new R0;class X4 extends Ss{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(q4),this.setValues(e)}setupLightingModel(){return new $4}}const eI=me(()=>{const i=he(Bi.z,0,Bi.x.negate()).normalize(),e=Bi.cross(i);return lt(i.dot(mi),e.dot(mi)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV"),j4=new CS;class Y4 extends Ss{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(j4),this.setValues(e)}setupVariants(e){const t=eI;let n;e.material.matcap?n=uh("matcap","texture").context({getUV:()=>t}):n=he(oi(.2,.8,t.y)),Ni.rgb.mulAssign(n.rgb)}}class Z4 extends _s{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:n}=this;if(this.getNodeType(e)==="vec2"){const o=t.cos(),a=t.sin();return ov(o,a,a.negate(),o).mul(n)}else{const o=t,a=kd(zt(1,0,0,0),zt(0,Cl(o.x),yo(o.x).negate(),0),zt(0,yo(o.x),Cl(o.x),0),zt(0,0,0,1)),c=kd(zt(Cl(o.y),0,yo(o.y),0),zt(0,1,0,0),zt(yo(o.y).negate(),0,Cl(o.y),0),zt(0,0,0,1)),u=kd(zt(Cl(o.z),yo(o.z).negate(),0,0),zt(yo(o.z),Cl(o.z),0,0),zt(0,0,1,0),zt(0,0,0,1));return a.mul(c).mul(u).mul(zt(n,1)).xyz}}}const Ry=Fn(Z4).setParameterLength(2),K4=new cd;class tI extends Ss{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(K4),this.setValues(e)}setupPositionView(e){const{object:t,camera:n}=e,{positionNode:r,rotationNode:o,scaleNode:a,sizeAttenuation:c}=this,u=Lc.mul(he(r||0));let d=lt(Ya[0].xyz.length(),Ya[1].xyz.length());a!==null&&(d=d.mul(lt(a))),n.isPerspectiveCamera&&c===!1&&(d=d.mul(u.z.negate()));let p=Wr.xy;if(t.center&&t.center.isVector2===!0){const x=qz("center","vec2",t);p=p.sub(x.sub(.5))}p=p.mul(d);const m=q(o||RN),y=Ry(p,m);return zt(u.xy.add(y),u.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 J4=new $_,Q4=new ze;class e5 extends tI{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(J4),this.setValues(e)}setupPositionView(){const{positionNode:e}=this;return Lc.mul(he(e||bs)).xyz}setupVertexSprite(e){const{material:t,camera:n}=e,{rotationNode:r,scaleNode:o,sizeNode:a,sizeAttenuation:c}=this;let u=super.setupVertex(e);if(t.isNodeMaterial!==!0)return u;let d=a!==null?lt(a):VN;d=d.mul(PT),n.isPerspectiveCamera&&c===!0&&(d=d.mul(t5.div(Us.z.negate()))),o&&o.isNode&&(d=d.mul(lt(o)));let p=Wr.xy;if(r&&r.isNode){const m=q(r);p=Ry(p,m)}return p=p.mul(d),p=p.div(IT.div(2)),p=p.mul(u.w),u=u.add(zt(p,0,0)),u}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 t5=rn(1).onFrameUpdate(function({renderer:i}){const e=i.getSize(Q4);this.value=.5*e.y});class n5 extends zv{constructor(){super(),this.shadowNode=q(1).toVar("shadowMask")}direct({lightNode:e}){e.shadowNode!==null&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){Ni.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(Ni.rgb)}}const i5=new ux;class s5 extends Ss{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(i5),this.setValues(e)}setupLightingModel(){return new n5}}const Ny=Al("vec3"),nI=Al("vec3"),iI=Al("vec3");class r5 extends null{constructor(){super()}start(e){const{material:t}=e,n=Al("vec3"),r=Al("vec3");jt(by.sub(_a).length().greaterThan(HR.mul(2)),()=>{n.assign(by),r.assign(_a)}).Else(()=>{n.assign(_a),r.assign(by)});const o=r.sub(n),a=rn("int").onRenderUpdate(({material:m})=>m.steps),c=o.length().div(a).toVar(),u=o.normalize().toVar(),d=q(0).toVar(),p=he(1).toVar();t.offsetNode&&d.addAssign(t.offsetNode.mul(c)),Ai(a,()=>{const m=n.add(u.mul(d)),y=ya.mul(zt(m,1)).xyz;t.depthNode!==null&&(nI.assign(cg(nw(y.z,lh,ch))),e.context.sceneDepthNode=cg(t.depthNode).toVar()),e.context.positionWorld=m,e.context.shadowPositionWorld=m,e.context.positionView=y,Ny.assign(0);let x;t.scatteringNode&&(x=t.scatteringNode({positionRay:m})),super.start(e),x&&Ny.mulAssign(x);const v=Ny.mul(.01).negate().mul(c).exp();p.mulAssign(v),d.addAssign(c)}),iI.addAssign(p.saturate().oneMinus())}scatteringLight(e,t){const n=t.context.sceneDepthNode;n?jt(n.greaterThanEqual(nI),()=>{Ny.addAssign(e)}):Ny.addAssign(e)}direct({lightNode:e,lightColor:t},n){if(e.light.distance===void 0)return;const r=t.xyz.toVar();r.mulAssign(e.shadowNode),this.scatteringLight(r,n)}directRectArea({lightColor:e,lightPosition:t,halfWidth:n,halfHeight:r},o){const a=t.add(n).sub(r),c=t.sub(n).sub(r),u=t.sub(n).add(r),d=t.add(n).add(r),p=o.context.positionView,m=e.xyz.mul(a4({P:p,p0:a,p1:c,p2:u,p3:d})).pow(1.5);this.scatteringLight(m,o)}finish(e){e.context.outgoingLight.assign(iI)}}class XZ 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 r5}}class o5{constructor(e,t,n){this.renderer=e,this.nodes=t,this.info=n,this._context=typeof self!="undefined"?self:null,this._animationLoop=null,this._requestId=null}start(){const e=(t,n)=>{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,n),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 Nl{constructor(){this.weakMaps={}}_getWeakMap(e){const t=e.length;let n=this.weakMaps[t];return n===void 0&&(n=new WeakMap,this.weakMaps[t]=n),n}get(e){let t=this._getWeakMap(e);for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return;return t.get(e[e.length-1])}set(e,t){let n=this._getWeakMap(e);for(let r=0;r<e.length-1;r++){const o=e[r];n.has(o)===!1&&n.set(o,new WeakMap),n=n.get(o)}return n.set(e[e.length-1],t),this}delete(e){let t=this._getWeakMap(e);for(let n=0;n<e.length-1;n++)if(t=t.get(e[n]),t===void 0)return!1;return t.delete(e[e.length-1])}}let a5=0;function l5(i){const e=Object.keys(i);let t=Object.getPrototypeOf(i);for(;t;){const n=Object.getOwnPropertyDescriptors(t);for(const r in n)if(n[r]!==void 0){const o=n[r];o&&typeof o.get=="function"&&e.push(r)}t=Object.getPrototypeOf(t)}return e}class c5{constructor(e,t,n,r,o,a,c,u,d,p){this.id=a5++,this._nodes=e,this._geometries=t,this.renderer=n,this.object=r,this.material=o,this.scene=a,this.camera=c,this.lightsNode=u,this.context=d,this.geometry=r.geometry,this.version=o.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=p,this.clippingContextCacheKey=p!==null?p.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)}getIndirectOffset(){return this._geometries.getIndirectOffset(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,n=[],r=new Set,o={};for(const a of e){let c;if(a.node&&a.node.attribute?c=a.node.attribute:(c=t.getAttribute(a.name),o[a.name]=c.version),c===void 0)continue;n.push(c);const u=c.isInterleavedBufferAttribute?c.data:c;r.add(u)}return this.attributes=n,this.attributesId=o,this.vertexBuffers=Array.from(r.values()),n}getVertexBuffers(){return this.vertexBuffers===null&&this.getAttributes(),this.vertexBuffers}getDrawParameters(){const{object:e,material:t,geometry:n,group:r,drawRange:o}=this,a=this.drawParams||(this.drawParams={vertexCount:0,firstVertex:0,instanceCount:0,firstInstance:0}),c=this.getIndex(),u=c!==null;let d=1;if(n.isInstancedBufferGeometry===!0?d=n.instanceCount:e.count!==void 0&&(d=Math.max(0,e.count)),d===0)return null;if(a.instanceCount=d,e.isBatchedMesh===!0)return a;let p=1;t.wireframe===!0&&!e.isPoints&&!e.isLineSegments&&!e.isLine&&!e.isLineLoop&&(p=2);let m=o.start*p,y=(o.start+o.count)*p;r!==null&&(m=Math.max(m,r.start*p),y=Math.min(y,(r.start+r.count)*p));const x=n.attributes.position;let v=1/0;u?v=c.count:x!=null&&(v=x.count),m=Math.max(m,0),y=Math.min(y,v);const w=y-m;return w<0||w===1/0?null:(a.vertexCount=w,a.firstVertex=m,a)}getGeometryCacheKey(){const{geometry:e}=this;let t="";for(const n of Object.keys(e.attributes).sort()){const r=e.attributes[n];t+=n+",",r.data&&(t+=r.data.stride+","),r.offset&&(t+=r.offset+","),r.itemSize&&(t+=r.itemSize+","),r.normalized&&(t+="n,")}for(const n of Object.keys(e.morphAttributes).sort()){const r=e.morphAttributes[n];t+="morph-"+n+",";for(let o=0,a=r.length;o<a;o++){const c=r[o];t+=c.id+","}}return e.index&&(t+="index,"),t}getMaterialCacheKey(){const{object:e,material:t,renderer:n}=this;let r=t.customProgramCacheKey();for(const o of l5(t)){if(/^(is[A-Z]|_)|^(visible|version|uuid|name|opacity|userData)$/.test(o))continue;const a=t[o];let c;if(a!==null){const u=typeof a;u==="number"?c=a!==0?"1":"0":u==="object"?(c="{",a.isTexture&&(c+=a.mapping,n.backend.isWebGPUBackend===!0&&(c+=a.magFilter,c+=a.minFilter,c+=a.wrapS,c+=a.wrapT,c+=a.wrapR)),c+="}"):c=String(a)}else c=String(a);r+=c+","}return r+=this.clippingContextCacheKey+",",e.geometry&&(r+=this.getGeometryCacheKey()),e.skeleton&&(r+=e.skeleton.bones.length+","),e.isBatchedMesh&&(r+=e._matricesTexture.uuid+",",e._colorsTexture!==null&&(r+=e._colorsTexture.uuid+",")),(e.isInstancedMesh||e.count>1||Array.isArray(e.morphTargetInfluences))&&(r+=e.uuid+","),r+=this.context.id+",",r+=e.receiveShadow+",",jm(r)}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 n=this.geometry.getAttribute(t);if(n===void 0||e[t]!==n.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=Ym(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=Ym(e,1)),e=Ym(e,this.camera.id,this.renderer.contextNode.id,this.renderer.contextNode.version),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.geometry.removeEventListener("dispose",this.onGeometryDispose),this.onDispose()}}const dp=[];class u5{constructor(e,t,n,r,o,a){this.renderer=e,this.nodes=t,this.geometries=n,this.pipelines=r,this.bindings=o,this.info=a,this.chainMaps={}}get(e,t,n,r,o,a,c,u){const d=this.getChainMap(u);dp[0]=e,dp[1]=t,dp[2]=a,dp[3]=o;let p=d.get(dp);return p===void 0?(p=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,n,r,o,a,c,u),d.set(dp,p)):(p.updateClipping(c),p.needsGeometryUpdate&&p.setGeometry(e.geometry),(p.version!==t.version||p.needsUpdate)&&(p.initialCacheKey!==p.getCacheKey()?(p.dispose(),p=this.get(e,t,n,r,o,a,c,u)):p.version=t.version)),dp.length=0,p}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new Nl)}dispose(){this.chainMaps={}}createRenderObject(e,t,n,r,o,a,c,u,d,p,m){const y=this.getChainMap(m),x=new c5(e,t,n,r,o,a,c,u,d,p);return x.onDispose=()=>{this.pipelines.delete(x),this.bindings.deleteForRender(x),this.nodes.delete(x),y.delete(x.getChainArray())},x}}class jd{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 Ka={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},Yd=16,h5=211,d5=212;class f5 extends jd{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 n=this.get(e);if(n.version===void 0)t===Ka.VERTEX?this.backend.createAttribute(e):t===Ka.INDEX?this.backend.createIndexAttribute(e):t===Ka.STORAGE?this.backend.createStorageAttribute(e):t===Ka.INDIRECT&&this.backend.createIndirectStorageAttribute(e),n.version=this._getBufferAttribute(e).version;else{const r=this._getBufferAttribute(e);(n.version<r.version||r.usage===Yh)&&(this.backend.updateAttribute(e),n.version=r.version)}}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}function sI(i){return i.index!==null?i.index.version:i.attributes.position.version}function rI(i){const e=[],t=i.index,n=i.attributes.position;if(t!==null){const o=t.array;for(let a=0,c=o.length;a<c;a+=3){const u=o[a+0],d=o[a+1],p=o[a+2];e.push(u,d,d,p,p,u)}}else{const o=n.array;for(let a=0,c=o.length/3-1;a<c;a+=3){const u=a+0,d=a+1,p=a+2;e.push(u,d,d,p,p,u)}}const r=new(M_(e)?fu:Kl)(e,1);return r.version=sI(i),r}class p5 extends jd{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,n=this.get(t);n.initialized=!0,this.info.memory.geometries++;const r=()=>{this.info.memory.geometries--;const o=t.index,a=e.getAttributes();o!==null&&this.attributes.delete(o);for(const u of a)this.attributes.delete(u);const c=this.wireframes.get(t);c!==void 0&&this.attributes.delete(c),t.removeEventListener("dispose",r),this._geometryDisposeListeners.delete(t)};t.addEventListener("dispose",r),this._geometryDisposeListeners.set(t,r)}updateAttributes(e){const t=e.getAttributes();for(const o of t)o.isStorageBufferAttribute||o.isStorageInstancedBufferAttribute?this.updateAttribute(o,Ka.STORAGE):this.updateAttribute(o,Ka.VERTEX);const n=this.getIndex(e);n!==null&&this.updateAttribute(n,Ka.INDEX);const r=e.geometry.indirect;r!==null&&this.updateAttribute(r,Ka.INDIRECT)}updateAttribute(e,t){const n=this.info.render.calls;e.isInterleavedBufferAttribute?this.attributeCall.get(e)===void 0?(this.attributes.update(e,t),this.attributeCall.set(e,n)):this.attributeCall.get(e.data)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e.data,n),this.attributeCall.set(e,n)):this.attributeCall.get(e)!==n&&(this.attributes.update(e,t),this.attributeCall.set(e,n))}getIndirect(e){return e.geometry.indirect}getIndirectOffset(e){return e.geometry.indirectOffset}getIndex(e){const{geometry:t,material:n}=e;let r=t.index;if(n.wireframe===!0){const o=this.wireframes;let a=o.get(t);a===void 0?(a=rI(t),o.set(t,a)):a.version!==sI(t)&&(this.attributes.delete(a),a=rI(t),o.set(t,a)),r=a}return r}dispose(){for(const[e,t]of this._geometryDisposeListeners.entries())e.removeEventListener("dispose",t);this._geometryDisposeListeners.clear()}}class m5{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,n){this.render.drawCalls++,e.isMesh||e.isSprite?this.render.triangles+=n*(t/3):e.isPoints?this.render.points+=n*t:e.isLineSegments?this.render.lines+=n*(t/2):e.isLine?this.render.lines+=n*(t-1):Be("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 oI{constructor(e){this.cacheKey=e,this.usedTimes=0}}class g5 extends oI{constructor(e,t,n){super(e),this.vertexProgram=t,this.fragmentProgram=n}}class y5 extends oI{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let _5=0;class Aw{constructor(e,t,n,r=null,o=null){this.id=_5++,this.code=e,this.stage=t,this.name=n,this.transforms=r,this.attributes=o,this.usedTimes=0}}class x5 extends jd{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:n}=this,r=this.get(e);if(this._needsComputeUpdate(e)){const o=r.pipeline;o&&(o.usedTimes--,o.computeProgram.usedTimes--);const a=this.nodes.getForCompute(e);let c=this.programs.compute.get(a.computeShader);c===void 0&&(o&&o.computeProgram.usedTimes===0&&this._releaseProgram(o.computeProgram),c=new Aw(a.computeShader,"compute",e.name,a.transforms,a.nodeAttributes),this.programs.compute.set(a.computeShader,c),n.createProgram(c));const u=this._getComputeCacheKey(e,c);let d=this.caches.get(u);d===void 0&&(o&&o.usedTimes===0&&this._releasePipeline(o),d=this._getComputePipeline(e,c,u,t)),d.usedTimes++,c.usedTimes++,r.version=e.version,r.pipeline=d}return r.pipeline}getForRender(e,t=null){const{backend:n}=this,r=this.get(e);if(this._needsRenderUpdate(e)){const o=r.pipeline;o&&(o.usedTimes--,o.vertexProgram.usedTimes--,o.fragmentProgram.usedTimes--);const a=e.getNodeBuilderState(),c=e.material?e.material.name:"";let u=this.programs.vertex.get(a.vertexShader);u===void 0&&(o&&o.vertexProgram.usedTimes===0&&this._releaseProgram(o.vertexProgram),u=new Aw(a.vertexShader,"vertex",c),this.programs.vertex.set(a.vertexShader,u),n.createProgram(u));let d=this.programs.fragment.get(a.fragmentShader);d===void 0&&(o&&o.fragmentProgram.usedTimes===0&&this._releaseProgram(o.fragmentProgram),d=new Aw(a.fragmentShader,"fragment",c),this.programs.fragment.set(a.fragmentShader,d),n.createProgram(d));const p=this._getRenderCacheKey(e,u,d);let m=this.caches.get(p);m===void 0?(o&&o.usedTimes===0&&this._releasePipeline(o),m=this._getRenderPipeline(e,u,d,p,t)):e.pipeline=m,m.usedTimes++,u.usedTimes++,d.usedTimes++,r.pipeline=m}return r.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,n,r){n=n||this._getComputeCacheKey(e,t);let o=this.caches.get(n);return o===void 0&&(o=new y5(n,t),this.caches.set(n,o),this.backend.createComputePipeline(o,r)),o}_getRenderPipeline(e,t,n,r,o){r=r||this._getRenderCacheKey(e,t,n);let a=this.caches.get(r);return a===void 0&&(a=new g5(r,t,n),this.caches.set(r,a),e.pipeline=a,this.backend.createRenderPipeline(e,o)),a}_getComputeCacheKey(e,t){return e.id+","+t.id}_getRenderCacheKey(e,t,n){return t.id+","+n.id+","+this.backend.getRenderCacheKey(e)}_releasePipeline(e){this.caches.delete(e.cacheKey)}_releaseProgram(e){const t=e.code,n=e.stage;this.programs[n].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 v5 extends jd{constructor(e,t,n,r,o,a){super(),this.backend=e,this.textures=n,this.pipelines=o,this.attributes=r,this.nodes=t,this.info=a,this.pipelines.bindings=this}getForRender(e){const t=e.getBindings();for(const n of t){const r=this.get(n);r.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),r.bindGroup=n)}return t}getForCompute(e){const t=this.nodes.getForCompute(e).bindings;for(const n of t){const r=this.get(n);r.bindGroup===void 0&&(this._init(n),this.backend.createBindings(n,t,0),r.bindGroup=n)}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 n of t)this.backend.deleteBindGroupData(n),this.delete(n)}deleteForRender(e){const t=e.getBindings();for(const n of t)this.backend.deleteBindGroupData(n),this.delete(n)}_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 n=t.attribute,r=n.isIndirectStorageBufferAttribute?Ka.INDIRECT:Ka.STORAGE;this.attributes.update(n,r)}}_update(e,t){const{backend:n}=this;let r=!1,o=!0,a=0,c=0;for(const u of e.bindings)if(this.nodes.updateGroup(u)!==!1){if(u.isStorageBuffer){const p=u.attribute,m=p.isIndirectStorageBufferAttribute?Ka.INDIRECT:Ka.STORAGE;this.attributes.update(p,m)}if(u.isUniformBuffer)u.update()&&n.updateBinding(u);else if(u.isSampledTexture){const p=u.update(),m=u.texture,y=this.textures.get(m);if(p&&(this.textures.updateTexture(m),u.generation!==y.generation&&(u.generation=y.generation,r=!0,o=!1)),n.get(m).externalTexture!==void 0||y.isDefaultTexture?o=!1:(a=a*10+m.id,c+=m.version),m.isStorageTexture===!0&&m.mipmapsAutoUpdate===!0){const v=this.get(m);u.store===!0?v.needsMipmap=!0:this.textures.needsMipmaps(m)&&v.needsMipmap===!0&&(this.backend.generateMipmaps(m),v.needsMipmap=!1)}}else if(u.isSampler&&u.update()){const m=this.textures.updateSampler(u.texture);u.samplerKey!==m&&(u.samplerKey=m,r=!0,o=!1)}}r===!0&&this.backend.updateBindings(e,t,o?a:0,c)}}function b5(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 aI(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 lI(i){return(i.transmission>0||i.transmissionNode&&i.transmissionNode.isNode)&&i.side===Ae&&i.forceSinglePass===!1}class S5{constructor(e,t,n){this.renderItems=[],this.renderItemsIndex=0,this.opaque=[],this.transparentDoublePass=[],this.transparent=[],this.bundles=[],this.lightsNode=e.getNode(t,n),this.lightsArray=[],this.scene=t,this.camera=n,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,n,r,o,a,c){let u=this.renderItems[this.renderItemsIndex];return u===void 0?(u={id:e.id,object:e,geometry:t,material:n,groupOrder:r,renderOrder:e.renderOrder,z:o,group:a,clippingContext:c},this.renderItems[this.renderItemsIndex]=u):(u.id=e.id,u.object=e,u.geometry=t,u.material=n,u.groupOrder=r,u.renderOrder=e.renderOrder,u.z=o,u.group=a,u.clippingContext=c),this.renderItemsIndex++,u}push(e,t,n,r,o,a,c){const u=this.getNextRenderItem(e,t,n,r,o,a,c);e.occlusionTest===!0&&this.occlusionQueryCount++,n.transparent===!0||n.transmission>0||n.transmissionNode&&n.transmissionNode.isNode||n.backdropNode&&n.backdropNode.isNode?(lI(n)&&this.transparentDoublePass.push(u),this.transparent.push(u)):this.opaque.push(u)}unshift(e,t,n,r,o,a,c){const u=this.getNextRenderItem(e,t,n,r,o,a,c);n.transparent===!0||n.transmission>0||n.transmissionNode&&n.transmissionNode.isNode||n.backdropNode&&n.backdropNode.isNode?(lI(n)&&this.transparentDoublePass.unshift(u),this.transparent.unshift(u)):this.opaque.unshift(u)}pushBundle(e){this.bundles.push(e)}pushLight(e){this.lightsArray.push(e)}sort(e,t){this.opaque.length>1&&this.opaque.sort(e||b5),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||aI),this.transparent.length>1&&this.transparent.sort(t||aI)}finish(){this.lightsNode.setLights(this.lightsArray);for(let e=this.renderItemsIndex,t=this.renderItems.length;e<t;e++){const n=this.renderItems[e];if(n.id===null)break;n.id=null,n.object=null,n.geometry=null,n.material=null,n.groupOrder=null,n.renderOrder=null,n.z=null,n.group=null,n.clippingContext=null}}}const Py=[];class M5{constructor(e){this.lighting=e,this.lists=new Nl}get(e,t){const n=this.lists;Py[0]=e,Py[1]=t;let r=n.get(Py);return r===void 0&&(r=new S5(this.lighting,e,t),n.set(Py,r)),Py.length=0,r}dispose(){this.lists=new Nl}}let T5=0;class w5{constructor(){this.id=T5++,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 gn,this.scissor=!1,this.scissorValue=new gn,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 cI(this)}}function cI(i){const{textures:e,activeCubeFace:t,activeMipmapLevel:n}=i,r=[t,n];for(const o of e)r.push(o.id);return Kf(r)}const dg=[],A5=new Oa,E5=new ld;class C5{constructor(){this.chainMaps={}}get(e,t,n=null,r=null){dg[0]=e,dg[1]=t,r!==null&&(dg[2]=r);let o;if(n===null)o="default";else{const u=n.texture.format;o=`${n.textures.length}:${u}:${n.samples}:${n.depthBuffer}:${n.stencilBuffer}`}const a=this._getChainMap(o);let c=a.get(dg);return c===void 0&&(c=new w5,a.set(dg,c)),dg.length=0,n!==null&&(c.sampleCount=n.samples===0?1:n.samples),c}getForClear(e=null){return this.get(A5,E5,e)}_getChainMap(e){return this.chainMaps[e]||(this.chainMaps[e]=new Nl)}dispose(){this.chainMaps={}}}const R5=new H;class N5 extends jd{constructor(e,t,n){super(),this.renderer=e,this.backend=t,this.info=n}updateRenderTarget(e,t=0){const n=this.get(e),r=e.samples===0?1:e.samples,o=n.depthTextureMips||(n.depthTextureMips={}),a=e.textures,c=this.getSize(a[0]),u=c.width>>t,d=c.height>>t;let p=e.depthTexture||o[t];const m=e.depthBuffer===!0||e.stencilBuffer===!0;let y=!1;p===void 0&&m&&(p=new Ys,p.format=e.stencilBuffer?Rr:tr,p.type=e.stencilBuffer?wo:yi,p.image.width=u,p.image.height=d,p.image.depth=c.depth,p.renderTarget=e,p.isArrayTexture=e.multiview===!0&&c.depth>1,o[t]=p),(n.width!==c.width||c.height!==n.height)&&(y=!0,p&&(p.needsUpdate=!0,p.image.width=u,p.image.height=d,p.image.depth=p.isArrayTexture?p.image.depth:1)),n.width=c.width,n.height=c.height,n.textures=a,n.depthTexture=p||null,n.depth=e.depthBuffer,n.stencil=e.stencilBuffer,n.renderTarget=e,n.sampleCount!==r&&(y=!0,p&&(p.needsUpdate=!0),n.sampleCount=r);const x={sampleCount:r};if(e.isXRRenderTarget!==!0){for(let v=0;v<a.length;v++){const w=a[v];y&&(w.needsUpdate=!0),this.updateTexture(w,x)}p&&this.updateTexture(p,x)}n.initialized!==!0&&(n.initialized=!0,n.onDispose=()=>{this._destroyRenderTarget(e)},e.addEventListener("dispose",n.onDispose))}updateTexture(e,t={}){const n=this.get(e);if(n.initialized===!0&&n.version===e.version)return;const r=e.isRenderTargetTexture||e.isDepthTexture||e.isFramebufferTexture,o=this.backend;if(r&&n.initialized===!0&&o.destroyTexture(e),e.isFramebufferTexture){const d=this.renderer.getRenderTarget();d?e.type=d.texture.type:e.type=Di}const{width:a,height:c,depth:u}=this.getSize(e);if(t.width=a,t.height=c,t.depth=u,t.needsMipmaps=this.needsMipmaps(e),t.levels=t.needsMipmaps?this.getMipLevels(e,a,c):1,e.isCubeTexture&&e.mipmaps.length>0&&t.levels++,r||e.isStorageTexture===!0||e.isExternalTexture===!0)o.createTexture(e,t),n.generation=e.version;else if(e.version>0){const d=e.image;if(d===void 0)Ie("Renderer: Texture marked for update but image is undefined.");else if(d.complete===!1)Ie("Renderer: Texture marked for update but image is incomplete.");else{if(e.images){const m=[];for(const y of e.images)m.push(y);t.images=m}else t.image=d;(n.isDefaultTexture===void 0||n.isDefaultTexture===!0)&&(o.createTexture(e,t),n.isDefaultTexture=!1,n.generation=e.version),e.source.dataReady===!0&&o.updateTexture(e,t);const p=e.isStorageTexture===!0&&e.mipmapsAutoUpdate===!1;t.needsMipmaps&&e.mipmaps.length===0&&!p&&o.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else o.createDefaultTexture(e),n.isDefaultTexture=!0,n.generation=e.version;n.initialized!==!0&&(n.initialized=!0,n.generation=e.version,this.info.memory.textures++,e.isVideoTexture&&xn.enabled===!0&&xn.getTransfer(e.colorSpace)!==$t&&Ie("WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace."),n.onDispose=()=>{this._destroyTexture(e)},e.addEventListener("dispose",n.onDispose)),n.version=e.version}updateSampler(e){return this.backend.updateSampler(e)}getSize(e,t=R5){let n=e.images?e.images[0]:e.image;return n?(n.image!==void 0&&(n=n.image),typeof HTMLVideoElement!="undefined"&&n instanceof HTMLVideoElement?(t.width=n.videoWidth||1,t.height=n.videoHeight||1,t.depth=1):typeof VideoFrame!="undefined"&&n instanceof VideoFrame?(t.width=n.displayWidth||1,t.height=n.displayHeight||1,t.depth=1):(t.width=n.width||1,t.height=n.height||1,t.depth=e.isCubeTexture?6:n.depth||1)):t.width=t.height=t.depth=1,t}getMipLevels(e,t,n){let r;return e.mipmaps.length>0?r=e.mipmaps.length:e.isCompressedTexture===!0?r=1:r=Math.floor(Math.log2(Math.max(t,n)))+1,r}needsMipmaps(e){return e.generateMipmaps===!0||e.mipmaps.length>0}_destroyRenderTarget(e){if(this.has(e)===!0){const t=this.get(e),n=t.textures,r=t.depthTexture;e.removeEventListener("dispose",t.onDispose);for(let o=0;o<n.length;o++)this._destroyTexture(n[o]);r&&this._destroyTexture(r),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 n=t.isDefaultTexture;this.backend.destroyTexture(e,n),this.delete(e),this.info.memory.textures--}}}class Ew extends It{constructor(e,t,n,r=1){super(e,t,n),this.a=r}set(e,t,n,r=1){return this.a=r,super.set(e,t,n)}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 uI extends Ti{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getMemberType(e,t){const n=this.getNodeType(e),r=e.getStructTypeNode(n);let o;return r!==null?o=r.getMemberType(e,t):(Be(`TSL: Member "${t}" not found in struct "${n}".`),o="float"),o}getHash(){return this.uuid}generate(){return this.name}}const P5=(i,e)=>new uI(i,e);class I5 extends Xt{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this._currentNode=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,t=this.nodes.length){return e.isNode!==!0?(Be("TSL: Invalid node added to stack."),this):(this.nodes.splice(t,0,e),this)}addToStackBefore(e){const t=this._currentNode?this.nodes.indexOf(this._currentNode):0;return this.addToStack(e,t)}If(e,t){const n=new Zm(t);return this._currentCond=Gr(e,n),this.addToStack(this._currentCond)}ElseIf(e,t){const n=new Zm(t),r=Gr(e,n);return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new Zm(e),this}Switch(e){return this._expressionNode=Nt(e),this}Case(...e){const t=[];if(e.length>=2)for(let c=0;c<e.length-1;c++)t.push(this._expressionNode.equal(Nt(e[c])));else Be("TSL: Invalid parameter length. Case() requires at least two parameters.");const n=e[e.length-1],r=new Zm(n);let o=t[0];for(let c=1;c<t.length;c++)o=o.or(t[c]);const a=Gr(o,r);return this._currentCond===null?(this._currentCond=a,this.addToStack(this._currentCond)):(this._currentCond.elseNode=a,this._currentCond=a,this)}Default(e){return this.Else(e),this}setup(e){const t=e.getNodeProperties(this);let n=0;for(const r of this.getChildren())r.isVarNode&&r.isIntent(e)&&r.isAssign(e)!==!0||(t["node"+n++]=r);return t.outputNode||null}get hasOutput(){return this.outputNode&&this.outputNode.isNode}build(e,...t){const n=$M(),r=e.buildStage;hy(this),e.setActiveStack(this);const o=d=>{if(this._currentNode=d,!(d.isVarNode&&d.isIntent(e)&&d.isAssign(e)!==!0)){if(r==="setup")d.build(e);else if(r==="analyze")d.build(e,this);else if(r==="generate"){const p=e.getDataFromNode(d,"any").stages,m=p&&p[e.shaderStage];if(d.isVarNode&&m&&m.length===1&&m[0]&&m[0].isStackNode)return;d.build(e,"void")}}},a=[...this.nodes];for(const d of a)o(d);this._currentNode=null;const c=this.nodes.filter(d=>a.indexOf(d)===-1);for(const d of c)o(d);let u;return this.hasOutput?u=this.outputNode.build(e,...t):u=super.build(e,...t),hy(n),e.removeActiveStack(this),u}}const jv=Fn(I5).setParameterLength(0,1);function L5(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 D5 extends Xt{static get type(){return"StructTypeNode"}constructor(e,t=null){super("struct"),this.membersLayout=L5(e),this.name=t,this.isStructLayoutNode=!0}getLength(){const e=Float32Array.BYTES_PER_ELEMENT;let t=1,n=0;for(const r of this.membersLayout){const o=r.type,a=QE(o),c=eC(o)/e;t=Math.max(t,c);const d=n%t%c;d!==0&&(n+=c-d),n+=a}return Math.ceil(n/t)*t}getMemberType(e,t){const n=this.membersLayout.find(r=>r.name===t);return n?n.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 F5 extends Xt{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),n=t.type,r=e.getPropertyName(t);return e.addLineFlowCode(`${r} = ${e.generateStruct(n,this.structTypeNode.membersLayout,this.values)}`,this),t.name}}const B5=(i,e=null)=>{const t=new D5(i,e),n=(...r)=>{let o=null;if(r.length>0)if(r[0].isNode){o={};const a=Object.keys(i);for(let c=0;c<r.length;c++)o[a[c]]=r[c]}else o=r[0];return new F5(t,o)};return n.layout=t,n.isStruct=!0,n};class hI extends Xt{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 n=this.members,r=[];for(let o=0;o<n.length;o++){const a="m"+o,c=n[o].getNodeType(e);r.push({name:a,type:c,index:o})}t.membersLayout=r,t.structType=e.getOutputStructTypeFromNode(this,t.membersLayout)}return t.structType.name}generate(e){const t=e.getOutputStructName(),n=this.members,r=t!==""?t+".":"";for(let o=0;o<n.length;o++){const a=n[o].build(e);e.addLineFlowCode(`${r}m${o} = ${a}`,this)}return t}}const O5=Fn(hI);function dI(i,e){for(let t=0;t<i.length;t++)if(i[t].name===e)return t;return-1}class U5 extends hI{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=wi(wi({},this.outputNodes),e.outputNodes);return fI(t)}setup(e){const t=this.outputNodes,n=e.renderer.getRenderTarget(),r=[],o=n.textures;for(const a in t){const c=dI(o,a);r[c]=zt(t[a])}return this.members=r,super.setup(e)}}const fI=Fn(U5);class Iy extends _s{static get type(){return"BitcastNode"}constructor(e,t,n=null){super(),this.valueNode=e,this.conversionType=t,this.inputType=n,this.isBitcastNode=!0}getNodeType(e){if(this.inputType!==null){const t=this.valueNode.getNodeType(e),n=e.getTypeLength(t);return e.getTypeFromLength(n,this.conversionType)}return this.conversionType}generate(e){const t=this.getNodeType(e);let n="";if(this.inputType!==null){const r=this.valueNode.getNodeType(e);n=e.getTypeLength(r)===1?this.inputType:e.changeComponentType(r,this.inputType)}else n=this.valueNode.getNodeType(e);return`${e.getBitcastMethod(t,n)}( ${this.valueNode.build(e,n)} )`}}const pI=pt(Iy).setParameterLength(2),k5=i=>new Iy(i,"int","float"),mI=i=>new Iy(i,"uint","float"),z5=i=>new Iy(i,"float","int"),V5=i=>new Iy(i,"float","uint"),Yv={};class va extends Re{static get type(){return"BitcountNode"}constructor(e,t){super(e,t),this.isBitcountNode=!0}_resolveElementType(e,t,n){n==="int"?t.assign(pI(e,"uint")):t.assign(e)}_returnDataNode(e){switch(e){case"uint":return it;case"int":return le;case"uvec2":return qM;case"uvec3":return tp;case"uvec4":return ZM;case"ivec2":return ar;case"ivec3":return XM;case"ivec4":return YM}}_createTrailingZerosBaseLayout(e,t){const n=this._returnDataNode(t);return me(([o])=>{const a=it(0);this._resolveElementType(o,a,t);const c=q(a.bitAnd(uT(a))),d=mI(c).shiftRight(23).sub(127);return n(d)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createLeadingZerosBaseLayout(e,t){const n=this._returnDataNode(t);return me(([o])=>{jt(o.equal(it(0)),()=>it(32));const a=it(0),c=it(0);return this._resolveElementType(o,a,t),jt(a.shiftRight(16).equal(0),()=>{c.addAssign(16),a.shiftLeftAssign(16)}),jt(a.shiftRight(24).equal(0),()=>{c.addAssign(8),a.shiftLeftAssign(8)}),jt(a.shiftRight(28).equal(0),()=>{c.addAssign(4),a.shiftLeftAssign(4)}),jt(a.shiftRight(30).equal(0),()=>{c.addAssign(2),a.shiftLeftAssign(2)}),jt(a.shiftRight(31).equal(0),()=>{c.addAssign(1)}),n(c)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createOneBitsBaseLayout(e,t){const n=this._returnDataNode(t);return me(([o])=>{const a=it(0);this._resolveElementType(o,a,t),a.assign(a.sub(a.shiftRight(it(1)).bitAnd(it(1431655765)))),a.assign(a.bitAnd(it(858993459)).add(a.shiftRight(it(2)).bitAnd(it(858993459))));const c=a.add(a.shiftRight(it(4))).bitAnd(it(252645135)).mul(it(16843009)).shiftRight(it(24));return n(c)}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}_createMainLayout(e,t,n,r){const o=this._returnDataNode(t);return me(([c])=>{if(n===1)return o(r(c));{const u=o(0),d=["x","y","z","w"];for(let p=0;p<n;p++){const m=d[p];u[m].assign(r(c[m]))}return u}}).setLayout({name:e,type:t,inputs:[{name:"value",type:t}]})}setup(e){const{method:t,aNode:n}=this,{renderer:r}=e;if(r.backend.isWebGPUBackend)return super.setup(e);const o=this.getInputType(e),a=e.getElementType(o),c=e.getTypeLength(o),u=`${t}_base_${a}`,d=`${t}_${o}`;let p=Yv[u];if(p===void 0){switch(t){case va.COUNT_LEADING_ZEROS:{p=this._createLeadingZerosBaseLayout(u,a);break}case va.COUNT_TRAILING_ZEROS:{p=this._createTrailingZerosBaseLayout(u,a);break}case va.COUNT_ONE_BITS:{p=this._createOneBitsBaseLayout(u,a);break}}Yv[u]=p}let m=Yv[d];return m===void 0&&(m=this._createMainLayout(d,o,c,p),Yv[d]=m),me(()=>m(n))()}}va.COUNT_TRAILING_ZEROS="countTrailingZeros",va.COUNT_LEADING_ZEROS="countLeadingZeros",va.COUNT_ONE_BITS="countOneBits";const G5=pt(va,va.COUNT_TRAILING_ZEROS).setParameterLength(1),W5=pt(va,va.COUNT_LEADING_ZEROS).setParameterLength(1),H5=pt(va,va.COUNT_ONE_BITS).setParameterLength(1),$5=me(([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/Cp(2,32))}),Cw=(i,e)=>Xa(Bn(4,i.mul(ui(1,i))),e),q5=(i,e)=>i.lessThan(.5)?Cw(i.mul(2),e).div(2):ui(1,Cw(Bn(ui(1,i),2),e).div(2)),X5=(i,e,t)=>Xa(ma(Xa(i,e),Js(Xa(i,e),Xa(ui(1,i),t))),1/e),j5=(i,e)=>yo(mv.mul(e.mul(i).sub(1))).div(mv.mul(e.mul(i).sub(1)));class Rw extends _s{static get type(){return"PackFloatNode"}constructor(e,t){super(),this.vectorNode=t,this.encoding=e,this.isPackFloatNode=!0}getNodeType(){return"uint"}generate(e){const t=this.vectorNode.getNodeType(e);return`${e.getFloatPackingMethod(this.encoding)}(${this.vectorNode.build(e,t)})`}}const Y5=pt(Rw,"snorm").setParameterLength(1),Z5=pt(Rw,"unorm").setParameterLength(1),K5=pt(Rw,"float16").setParameterLength(1);class Nw extends _s{static get type(){return"UnpackFloatNode"}constructor(e,t){super(),this.uintNode=t,this.encoding=e,this.isUnpackFloatNode=!0}getNodeType(){return"vec2"}generate(e){const t=this.uintNode.getNodeType(e);return`${e.getFloatUnpackingMethod(this.encoding)}(${this.uintNode.build(e,t)})`}}const J5=pt(Nw,"snorm").setParameterLength(1),Q5=pt(Nw,"unorm").setParameterLength(1),eW=pt(Nw,"float16").setParameterLength(1),dh=me(([i])=>i.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),tW=me(([i])=>he(dh(i.z.add(dh(i.y.mul(1)))),dh(i.z.add(dh(i.x.mul(1)))),dh(i.y.add(dh(i.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),nW=me(([i,e,t])=>{const n=he(i).toVar(),r=q(1.4).toVar(),o=q(0).toVar(),a=he(n).toVar();return Ai({start:q(0),end:q(3),type:"float",condition:"<="},()=>{const c=he(tW(a.mul(2))).toVar();n.addAssign(c.add(t.mul(q(.1).mul(e)))),a.mulAssign(1.8),r.mulAssign(1.5),n.mulAssign(1.2);const u=q(dh(n.z.add(dh(n.x.add(dh(n.y)))))).toVar();o.addAssign(u.div(r)),a.addAssign(.14)}),o}).setLayout({name:"triNoise3D",type:"float",inputs:[{name:"position",type:"vec3"},{name:"speed",type:"float"},{name:"time",type:"float"}]});class iW extends Xt{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 n=this._candidateFn;if(n===null){let r=null,o=-1;for(const a of this.functionNodes){const u=a.shaderNode.layout;if(u===null)throw new Error("FunctionOverloadingNode: FunctionNode must be a layout.");const d=u.inputs;if(t.length===d.length){let p=0;for(let m=0;m<t.length;m++){const y=t[m],x=d[m];y.getNodeType(e)===x.type&&p++}p>o&&(r=a,o=p)}}this._candidateFn=n=r}return n}setup(e){return this.getCandidateFn(e)(...this.parametersNodes)}}const sW=Fn(iW),Hr=i=>(...e)=>sW(i,...e),fg=rn(0).setGroup(an).onRenderUpdate(i=>i.time),rW=rn(0).setGroup(an).onRenderUpdate(i=>i.deltaTime),gI=rn(0,"uint").setGroup(an).onRenderUpdate(i=>i.frameId),oW=(i=fg)=>i.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),aW=(i=fg)=>i.fract().round(),lW=(i=fg)=>i.add(.5).fract().mul(2).sub(1).abs(),cW=(i=fg)=>i.fract();function uW(i,e=null){return ih(e,{getUV:i})}const hW=me(([i,e,t=lt(.5)])=>Ry(i.sub(t),e).add(t)),dW=me(([i,e,t=lt(.5)])=>{const n=i.sub(t),r=n.dot(n),a=r.mul(r).mul(e);return i.add(n.mul(a))}),fW=me(({position:i=null,horizontal:e=!0,vertical:t=!1})=>{let n;i!==null?(n=Ya.toVar(),n[3][0]=i.x,n[3][1]=i.y,n[3][2]=i.z):n=Ya;const r=ya.mul(n);return cy(e)&&(r[0][0]=Ya[0].length(),r[0][1]=0,r[0][2]=0),cy(t)&&(r[1][0]=0,r[1][1]=Ya[1].length(),r[1][2]=0),r[2][0]=0,r[2][1]=0,r[2][2]=1,xo.mul(r).mul(bs)}),pW=me(([i=null])=>{const e=cg();return cg(tw(i)).sub(e).lessThan(0).select(ah,i)});class mW extends Xt{static get type(){return"SpriteSheetUVNode"}constructor(e,t=Pi(),n=q(0)){super("vec2"),this.countNode=e,this.uvNode=t,this.frameNode=n}setup(){const{frameNode:e,uvNode:t,countNode:n}=this,{width:r,height:o}=n,a=e.mod(r.mul(o)).floor(),c=a.mod(r),u=o.sub(a.add(1).div(r).ceil()),d=n.reciprocal(),p=lt(c,u);return t.add(p).mul(d)}}const gW=Fn(mW).setParameterLength(3),yI=me(([i,e=null,t=null,n=q(1),r=bs,o=zo])=>{let a=o.abs().normalize();a=a.div(a.dot(he(1)));const c=r.yz.mul(n),u=r.zx.mul(n),d=r.xy.mul(n),p=i.value,m=e!==null?e.value:p,y=t!==null?t.value:p,x=_i(p,c).mul(a.x),v=_i(m,u).mul(a.y),w=_i(y,d).mul(a.z);return Js(x,v,w)}),yW=(...i)=>yI(...i),pg=new uo,fp=new H,mg=new H,Pw=new H,Ly=new Qt,Zv=new H(0,0,-1),Bc=new gn,Dy=new H,Kv=new H,Fy=new gn,Jv=new ze,Qv=new Ws,_W=ah.flipX();Qv.depthTexture=new Ys(1,1);let eb=!1;class Iw extends Ic{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||Qv.texture,_W),this._reflectorBaseNode=e.reflector||new xW(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=Nt(new Iw({defaultTexture:Qv.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 xW extends Xt{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:n=new Zi,resolutionScale:r=1,generateMipmaps:o=!1,bounces:a=!0,depth:c=!1,samples:u=0}=t;this.textureNode=e,this.target=n,this.resolutionScale=r,t.resolution!==void 0&&(Ut('ReflectorNode: The "resolution" parameter has been renamed to "resolutionScale".'),this.resolutionScale=t.resolution),this.generateMipmaps=o,this.bounces=a,this.depth=c,this.samples=u,this.updateBeforeType=a?Xn.RENDER:Xn.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){const n=this.resolutionScale;t.getDrawingBufferSize(Jv),e.setSize(Math.round(Jv.width*n),Math.round(Jv.height*n))}setup(e){return this._updateResolution(Qv,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 Ws(0,0,{type:Hi,samples:this.samples}),this.generateMipmaps===!0&&(t.texture.minFilter=nA,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new Ys),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&eb)return!1;eb=!0;const{scene:t,camera:n,renderer:r,material:o}=e,{target:a}=this,c=this.getVirtualCamera(n),u=this.getRenderTarget(c);r.getDrawingBufferSize(Jv),this._updateResolution(u,r),mg.setFromMatrixPosition(a.matrixWorld),Pw.setFromMatrixPosition(n.matrixWorld),Ly.extractRotation(a.matrixWorld),fp.set(0,0,1),fp.applyMatrix4(Ly),Dy.subVectors(mg,Pw);const d=Dy.dot(fp)>0;let p=!1;if(d===!0&&this.forceUpdate===!1){if(this.hasOutput===!1){eb=!1;return}p=!0}Dy.reflect(fp).negate(),Dy.add(mg),Ly.extractRotation(n.matrixWorld),Zv.set(0,0,-1),Zv.applyMatrix4(Ly),Zv.add(Pw),Kv.subVectors(mg,Zv),Kv.reflect(fp).negate(),Kv.add(mg),c.coordinateSystem=n.coordinateSystem,c.position.copy(Dy),c.up.set(0,1,0),c.up.applyMatrix4(Ly),c.up.reflect(fp),c.lookAt(Kv),c.near=n.near,c.far=n.far,c.updateMatrixWorld(),c.projectionMatrix.copy(n.projectionMatrix),pg.setFromNormalAndCoplanarPoint(fp,mg),pg.applyMatrix4(c.matrixWorldInverse),Bc.set(pg.normal.x,pg.normal.y,pg.normal.z,pg.constant);const m=c.projectionMatrix;Fy.x=(Math.sign(Bc.x)+m.elements[8])/m.elements[0],Fy.y=(Math.sign(Bc.y)+m.elements[9])/m.elements[5],Fy.z=-1,Fy.w=(1+m.elements[10])/m.elements[14],Bc.multiplyScalar(1/Bc.dot(Fy));const y=0;m.elements[2]=Bc.x,m.elements[6]=Bc.y,m.elements[10]=r.coordinateSystem===xr?Bc.z-y:Bc.z+1-y,m.elements[14]=Bc.w,this.textureNode.value=u.texture,this.depth===!0&&(this.textureNode.getDepthNode().value=u.depthTexture),o.visible=!1;const x=r.getRenderTarget(),v=r.getMRT(),w=r.autoClear;r.setMRT(null),r.setRenderTarget(u),r.autoClear=!0;const M=t.name;t.name=(t.name||"Scene")+" [ Reflector ]",p?(r.clear(),this.hasOutput=!1):(r.render(t,c),this.hasOutput=!0),t.name=M,r.setMRT(v),r.setRenderTarget(x),r.autoClear=w,o.visible=!0,eb=!1,this.forceUpdate=!1}get resolution(){return Ut('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale}set resolution(e){Ut('ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale=e}}const vW=i=>new Iw(i),Lw=new $u(-1,1,1,-1,0,1);class bW extends Gn{constructor(e=!1){super();const t=e===!1?[0,-1,0,1,2,1]:[0,2,0,0,2,0];this.setAttribute("position",new ht([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new ht(t,2))}}const SW=new bW;class By extends Ji{constructor(e=null){super(SW,e),this.camera=Lw,this.isQuadMesh=!0}renderAsync(e){return mn(this,null,function*(){Ut('QuadMesh: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),yield e.init(),e.render(this,Lw)})}render(e){e.render(this,Lw)}}const MW=new ze;class TW extends Ic{static get type(){return"RTTNode"}constructor(e,t=null,n=null,r={type:Hi}){const o=new Ws(t,n,r);super(o.texture,Pi()),this.isRTTNode=!0,this.node=e,this.width=t,this.height=n,this.pixelRatio=1,this.renderTarget=o,this.textureNeedsUpdate=!0,this.autoUpdate=!0,this._rttNode=null,this._quadMesh=new By(new Ss),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 n=e*this.pixelRatio,r=t*this.pixelRatio;this.renderTarget.setSize(n,r),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 r=e.getPixelRatio(),o=e.getSize(MW),a=Math.floor(o.width*r),c=Math.floor(o.height*r);(a!==this.renderTarget.width||c!==this.renderTarget.height)&&(this.renderTarget.setSize(a,c),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 n=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(n)}clone(){const e=new Ic(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const _I=(i,...e)=>Nt(new TW(Nt(i),...e)),wW=(i,...e)=>i.isSampleNode||i.isTextureNode?i:i.isPassNode?i.getTextureNode():_I(i,...e),gg=me(([i,e,t],n)=>{let r;n.renderer.coordinateSystem===xr?(i=lt(i.x,i.y.oneMinus()).mul(2).sub(1),r=zt(he(i,e),1)):r=zt(he(i.x,i.y.oneMinus(),e).mul(2).sub(1),1);const o=zt(t.mul(r));return o.xyz.div(o.w)}),AW=me(([i,e])=>{const t=e.mul(zt(i,1)),n=t.xy.div(t.w).mul(.5).add(.5).toVar();return lt(n.x,n.y.oneMinus())}),EW=me(([i,e,t])=>{const n=rh(Ns(e)),r=ar(i.mul(n)).toVar(),o=Ns(e,r).toVar(),a=Ns(e,r.sub(ar(2,0))).toVar(),c=Ns(e,r.sub(ar(1,0))).toVar(),u=Ns(e,r.add(ar(1,0))).toVar(),d=Ns(e,r.add(ar(2,0))).toVar(),p=Ns(e,r.add(ar(0,2))).toVar(),m=Ns(e,r.add(ar(0,1))).toVar(),y=Ns(e,r.sub(ar(0,1))).toVar(),x=Ns(e,r.sub(ar(0,2))).toVar(),v=qi(ui(q(2).mul(c).sub(a),o)).toVar(),w=qi(ui(q(2).mul(u).sub(d),o)).toVar(),M=qi(ui(q(2).mul(m).sub(p),o)).toVar(),S=qi(ui(q(2).mul(y).sub(x),o)).toVar(),C=gg(i,o,t).toVar(),N=v.lessThan(w).select(C.sub(gg(i.sub(lt(q(1).div(n.x),0)),c,t)),C.negate().add(gg(i.add(lt(q(1).div(n.x),0)),u,t))),I=M.lessThan(S).select(C.sub(gg(i.add(lt(0,q(1).div(n.y))),m,t)),C.negate().add(gg(i.sub(lt(0,q(1).div(n.y))),y,t)));return go(nh(N,I))}),Dw=me(([i])=>El(q(52.9829189).mul(El(qa(i,lt(.06711056,.00583715)))))).setLayout({name:"interleavedGradientNoise",type:"float",inputs:[{name:"position",type:"vec2"}]}),Pl=me(([i,e,t])=>{const n=q(2.399963229728653),r=Qr(q(i).add(.5).div(q(e))),o=q(i).mul(n).add(t);return lt(Cl(o),yo(o)).mul(r)}).setLayout({name:"vogelDiskSample",type:"vec2",inputs:[{name:"sampleIndex",type:"int"},{name:"samplesCount",type:"int"},{name:"phi",type:"float"}]});class CW extends Xt{static get type(){return"SampleNode"}constructor(e,t=null){super(),this.callback=e,this.uvNode=t,this.isSampleNode=!0}setup(){return this.sample(Pi())}sample(e){return this.callback(e)}}const RW=(i,e=null)=>new CW(i,Nt(e));class Go extends Xt{static get type(){return"EventNode"}constructor(e,t){super("void"),this.eventType=e,this.callback=t,e===Go.OBJECT?this.updateType=Xn.OBJECT:e===Go.MATERIAL?this.updateType=Xn.RENDER:e===Go.BEFORE_OBJECT?this.updateBeforeType=Xn.OBJECT:e===Go.BEFORE_MATERIAL&&(this.updateBeforeType=Xn.RENDER)}update(e){this.callback(e)}updateBefore(e){this.callback(e)}}Go.OBJECT="object",Go.MATERIAL="material",Go.BEFORE_OBJECT="beforeObject",Go.BEFORE_MATERIAL="beforeMaterial";const tb=(i,e)=>new Go(i,e).toStack(),NW=i=>tb(Go.OBJECT,i),PW=i=>tb(Go.MATERIAL,i),IW=i=>tb(Go.BEFORE_OBJECT,i),LW=i=>tb(Go.BEFORE_MATERIAL,i);class DW extends oa{constructor(e,t,n=Float32Array){const r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageInstancedBufferAttribute=!0}}class FW extends $i{constructor(e,t,n=Float32Array){const r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageBufferAttribute=!0}}const BW=(i,e="float")=>{let t,n;e.isStruct===!0?(t=e.layout.getLength(),n=oy("float")):(t=LM(e),n=oy(e));const r=new FW(i,t,n);return hh(r,e,i)},OW=(i,e="float")=>{let t,n;e.isStruct===!0?(t=e.layout.getLength(),n=oy("float")):(t=LM(e),n=oy(e));const r=new DW(i,t,n);return hh(r,e,i)};class UW extends Xt{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const kW=Ct(UW),Oy=new jr,Fw=new Qt;class Wo extends Xt{static get type(){return"SceneNode"}constructor(e=Wo.BACKGROUND_BLURRINESS,t=null){super(),this.scope=e,this.scene=t}setup(e){const t=this.scope,n=this.scene!==null?this.scene:e.scene;let r;return t===Wo.BACKGROUND_BLURRINESS?r=Oi("backgroundBlurriness","float",n):t===Wo.BACKGROUND_INTENSITY?r=Oi("backgroundIntensity","float",n):t===Wo.BACKGROUND_ROTATION?r=rn("mat4").setName("backgroundRotation").setGroup(an).onRenderUpdate(()=>{const o=n.background;return o!==null&&o.isTexture&&o.mapping!==_h?(Oy.copy(n.backgroundRotation),Oy.x*=-1,Oy.y*=-1,Oy.z*=-1,Fw.makeRotationFromEuler(Oy)):Fw.identity(),Fw}):Be("SceneNode: Unknown scope:",t),r}}Wo.BACKGROUND_BLURRINESS="backgroundBlurriness",Wo.BACKGROUND_INTENSITY="backgroundIntensity",Wo.BACKGROUND_ROTATION="backgroundRotation";const xI=Ct(Wo,Wo.BACKGROUND_BLURRINESS),Bw=Ct(Wo,Wo.BACKGROUND_INTENSITY),vI=Ct(Wo,Wo.BACKGROUND_ROTATION);class zW extends Ic{static get type(){return"StorageTextureNode"}constructor(e,t,n=null){super(e,t),this.storeNode=n,this.mipLevel=0,this.isStorageTextureNode=!0,this.access=zr.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 n;return this.storeNode!==null?n=this.generateStore(e):n=super.generate(e,t),n}toReadWrite(){return this.setAccess(zr.READ_WRITE)}toReadOnly(){return this.setAccess(zr.READ_ONLY)}toWriteOnly(){return this.setAccess(zr.WRITE_ONLY)}generateStore(e){const t=e.getNodeProperties(this),{uvNode:n,storeNode:r,depthNode:o}=t,a=super.generate(e,"property"),c=n.build(e,this.value.is3DTexture===!0?"uvec3":"uvec2"),u=r.build(e,"vec4"),d=o?o.build(e,"int"):null,p=e.generateTextureStore(e,a,c,d,u);e.addLineFlowCode(p,this)}clone(){const e=super.clone();return e.storeNode=this.storeNode,e.mipLevel=this.mipLevel,e}}const bI=Fn(zW).setParameterLength(1,3),VW=(i,e,t)=>{const n=bI(i,e,t);return t!==null&&n.toStack(),n},GW=me(({texture:i,uv:e})=>{const n=he().toVar();return jt(e.x.lessThan(1e-4),()=>{n.assign(he(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{n.assign(he(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{n.assign(he(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{n.assign(he(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{n.assign(he(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{n.assign(he(0,0,-1))}).Else(()=>{const o=i.sample(e.add(he(-.01,0,0))).r.sub(i.sample(e.add(he(.01,0,0))).r),a=i.sample(e.add(he(0,-.01,0))).r.sub(i.sample(e.add(he(0,.01,0))).r),c=i.sample(e.add(he(0,0,-.01))).r.sub(i.sample(e.add(he(0,0,.01))).r);n.assign(he(o,a,c))}),n.normalize()});class WW extends Ic{static get type(){return"Texture3DNode"}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return he(.5,.5,.5)}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return e.isFlipY()&&(n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(le(rh(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 GW({texture:this,uv:e})}}const nb=Fn(WW).setParameterLength(1,3),HW=(...i)=>nb(...i).setSampler(!1),$W=(i,e,t)=>nb(i,e).level(t);class qW extends Rv{static get type(){return"UserDataNode"}constructor(e,t,n=null){super(e,t,n),this.userData=n}updateReference(e){return this.reference=this.userData!==null?this.userData:e.object.userData,this.reference}}const XW=(i,e,t)=>new qW(i,e,t),SI=new WeakMap;class jW extends _s{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=Xn.OBJECT,this.updateAfterType=Xn.OBJECT,this.previousModelWorldMatrix=rn(new Qt),this.previousProjectionMatrix=rn(new Qt).setGroup(an),this.previousCameraViewMatrix=rn(new Qt)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:n}){const r=TI(n);this.previousModelWorldMatrix.value.copy(r);const o=MI(t);o.frameId!==e&&(o.frameId=e,o.previousProjectionMatrix===void 0?(o.previousProjectionMatrix=new Qt,o.previousCameraViewMatrix=new Qt,o.currentProjectionMatrix=new Qt,o.currentCameraViewMatrix=new Qt,o.previousProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),o.previousCameraViewMatrix.copy(t.matrixWorldInverse)):(o.previousProjectionMatrix.copy(o.currentProjectionMatrix),o.previousCameraViewMatrix.copy(o.currentCameraViewMatrix)),o.currentProjectionMatrix.copy(this.projectionMatrix||t.projectionMatrix),o.currentCameraViewMatrix.copy(t.matrixWorldInverse),this.previousProjectionMatrix.value.copy(o.previousProjectionMatrix),this.previousCameraViewMatrix.value.copy(o.previousCameraViewMatrix))}updateAfter({object:e}){TI(e).copy(e.matrixWorld)}setup(){const e=this.projectionMatrix===null?xo:rn(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),n=e.mul(Lc).mul(bs),r=this.previousProjectionMatrix.mul(t).mul(Av),o=n.xy.div(n.w),a=r.xy.div(r.w);return ui(o,a)}}function MI(i){let e=SI.get(i);return e===void 0&&(e={},SI.set(i,e)),e}function TI(i,e=0){const t=MI(i);let n=t[e];return n===void 0&&(t[e]=n=new Qt,t[e].copy(i.matrixWorld)),n}const YW=Ct(jW),ZW=me(([i])=>Ow(i.rgb)),KW=me(([i,e=q(1)])=>e.mix(Ow(i.rgb),i.rgb)),JW=me(([i,e=q(1)])=>{const t=Js(i.r,i.g,i.b).div(3),n=i.r.max(i.g.max(i.b)),r=n.sub(t).mul(e).mul(-3);return oi(i.rgb,n,r)}),QW=me(([i,e=q(1)])=>{const t=he(.57735,.57735,.57735),n=e.cos();return he(i.rgb.mul(n).add(t.cross(i.rgb).mul(e.sin()).add(t.mul(qa(t,i.rgb).mul(n.oneMinus())))))}),Ow=(i,e=he(xn.getLuminanceCoefficients(new H)))=>qa(i,e),e6=me(([i,e=he(1),t=he(0),n=he(1),r=q(1),o=he(xn.getLuminanceCoefficients(new H,io))])=>{const a=i.rgb.dot(he(o)),c=vs(i.rgb.mul(e).add(t),0).toVar(),u=c.pow(n).toVar();return jt(c.r.greaterThan(0),()=>{c.r.assign(u.r)}),jt(c.g.greaterThan(0),()=>{c.g.assign(u.g)}),jt(c.b.greaterThan(0),()=>{c.b.assign(u.b)}),c.assign(a.add(c.sub(a).mul(r))),zt(c.rgb,i.a)});class t6 extends _s{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 n6=Fn(t6).setParameterLength(2),ib=new ze;class wI extends Ic{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 AI extends wI{static get type(){return"PassMultipleTextureNode"}constructor(e,t,n=!1){super(e,null),this.textureName=t,this.previousTexture=n}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 Oc extends _s{static get type(){return"PassNode"}constructor(e,t,n,r={}){super("vec4"),this.scope=e,this.scene=t,this.camera=n,this.options=r,this._pixelRatio=1,this._width=1,this._height=1;const o=new Ys;o.isRenderTargetTexture=!0,o.name="depth";const a=new Ws(this._width*this._pixelRatio,this._height*this._pixelRatio,wi({type:Hi},r));a.texture.name="output",a.depthTexture=o,this.renderTarget=a,this.overrideMaterial=null,this.transparent=!0,this.opaque=!0,this.contextNode=null,this._contextNodeCache=null,this._textures={output:a.texture,depth:o},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=rn(0),this._cameraFar=rn(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 Ie("PassNode: .setResolution() is deprecated. Use .setResolutionScale() instead."),this.setResolutionScale(e)}getResolution(){return Ie("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 n=this._textures[e],r=this.renderTarget.textures.indexOf(n);this.renderTarget.textures[r]=t,this._textures[e]=t,this._previousTextures[e]=n,this._textureNodes[e].updateTexture(),this._previousTextureNodes[e].updateTexture()}}getTextureNode(e="output"){let t=this._textureNodes[e];return t===void 0&&(t=new AI(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=new AI(this,e,!0),t.updateTexture(),this._previousTextureNodes[e]=t),t}getViewZNode(e="depth"){let t=this._viewZNodes[e];if(t===void 0){const n=this._cameraNear,r=this._cameraFar;this._viewZNodes[e]=t=iw(this.getTextureNode(e),n,r)}return t}getLinearDepthNode(e="depth"){let t=this._linearDepthNodes[e];if(t===void 0){const n=this._cameraNear,r=this._cameraFar,o=this.getViewZNode(e);this._linearDepthNodes[e]=t=lg(o,n,r)}return t}compileAsync(e){return mn(this,null,function*(){const t=e.getRenderTarget(),n=e.getMRT();e.setRenderTarget(this.renderTarget),e.setMRT(this._mrt),yield e.compileAsync(this.scene,this.camera),e.setRenderTarget(t),e.setMRT(n)})}setup({renderer:e}){return this.renderTarget.samples=this.options.samples===void 0?e.samples:this.options.samples,this.renderTarget.texture.type=e.getOutputBufferType(),this.scope===Oc.COLOR?this.getTextureNode():this.getLinearDepthNode()}updateBefore(e){const{renderer:t}=e,{scene:n}=this;let r,o;const a=t.getOutputRenderTarget();a&&a.isXRRenderTarget===!0?(o=1,r=t.xr.getCamera(),t.xr.updateCamera(r),ib.set(a.width,a.height)):(r=this.camera,o=t.getPixelRatio(),t.getSize(ib)),this._pixelRatio=o,this.setSize(ib.width,ib.height);const c=t.getRenderTarget(),u=t.getMRT(),d=t.autoClear,p=t.transparent,m=t.opaque,y=r.layers.mask,x=t.contextNode,v=n.overrideMaterial;this._cameraNear.value=r.near,this._cameraFar.value=r.far,this._layers!==null&&(r.layers.mask=this._layers.mask);for(const M in this._previousTextures)this.toggleTexture(M);this.overrideMaterial!==null&&(n.overrideMaterial=this.overrideMaterial),t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.autoClear=!0,t.transparent=this.transparent,t.opaque=this.opaque,this.contextNode!==null&&((this._contextNodeCache===null||this._contextNodeCache.version!==this.version)&&(this._contextNodeCache={version:this.version,context:ih(wi(wi({},t.contextNode.getFlowContextData()),this.contextNode.getFlowContextData()))}),t.contextNode=this._contextNodeCache.context);const w=n.name;n.name=this.name?this.name:n.name,t.render(n,r),n.name=w,n.overrideMaterial=v,t.setRenderTarget(c),t.setMRT(u),t.autoClear=d,t.transparent=p,t.opaque=m,t.contextNode=x,r.layers.mask=y}setSize(e,t){this._width=e,this._height=t;const n=Math.floor(this._width*this._pixelRatio*this._resolutionScale),r=Math.floor(this._height*this._pixelRatio*this._resolutionScale);this.renderTarget.setSize(n,r),this._scissor!==null&&this.renderTarget.scissor.copy(this._scissor),this._viewport!==null&&this.renderTarget.viewport.copy(this._viewport)}setScissor(e,t,n,r){e===null?this._scissor=null:(this._scissor===null&&(this._scissor=new gn),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,n,r),this._scissor.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setViewport(e,t,n,r){e===null?this._viewport=null:(this._viewport===null&&(this._viewport=new gn),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,n,r),this._viewport.multiplyScalar(this._pixelRatio*this._resolutionScale).floor())}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}Oc.COLOR="color",Oc.DEPTH="depth";const i6=(i,e,t)=>new Oc(Oc.COLOR,i,e,t),s6=(i,e)=>new wI(i,e),r6=(i,e,t)=>new Oc(Oc.DEPTH,i,e,t);class o6 extends Oc{static get type(){return"ToonOutlinePassNode"}constructor(e,t,n,r,o){super(Oc.COLOR,e,t),this.colorNode=n,this.thicknessNode=r,this.alphaNode=o,this._materialCache=new WeakMap,this.name="Outline Pass"}updateBefore(e){const{renderer:t}=e,n=t.getRenderObjectFunction();t.setRenderObjectFunction((r,o,a,c,u,d,p,m)=>{if((u.isMeshToonMaterial||u.isMeshToonNodeMaterial)&&u.wireframe===!1){const y=this._getOutlineMaterial(u);t.renderObject(r,o,a,c,y,d,p,m)}t.renderObject(r,o,a,c,u,d,p,m)}),super.updateBefore(e),t.setRenderObjectFunction(n)}_createMaterial(){const e=new Ss;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=we;const t=zo.negate(),n=xo.mul(Lc),r=q(1),o=n.mul(zt(bs,1)),a=n.mul(zt(bs.add(t),1)),c=go(o.sub(a));return e.vertexNode=o.add(c.mul(this.thicknessNode).mul(o.w).mul(r)),e.colorNode=zt(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 a6=(i,e,t=new It(0,0,0),n=.003,r=1)=>Nt(new o6(i,e,Nt(t),Nt(n),Nt(r))),EI=me(([i,e])=>i.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),CI=me(([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"}]}),RI=me(([i,e])=>{i=i.mul(e),i=i.sub(.004).max(0);const t=i.mul(i.mul(6.2).add(.5)),n=i.mul(i.mul(6.2).add(1.7)).add(.06);return t.div(n).pow(2.2)}).setLayout({name:"cineonToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),l6=me(([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)}),NI=me(([i,e])=>{const t=Vr(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),n=Vr(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return i=i.mul(e).div(.6),i=t.mul(i),i=l6(i),i=n.mul(i),i.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),c6=Vr(he(1.6605,-.1246,-.0182),he(-.5876,1.1329,-.1006),he(-.0728,-.0083,1.1187)),u6=Vr(he(.6274,.0691,.0164),he(.3293,.9195,.088),he(.0433,.0113,.8956)),h6=me(([i])=>{const e=he(i).toVar(),t=he(e.mul(e)).toVar(),n=he(t.mul(t)).toVar();return q(15.5).mul(n.mul(t)).sub(Bn(40.14,n.mul(e))).add(Bn(31.96,n).sub(Bn(6.868,t.mul(e))).add(Bn(.4298,t).add(Bn(.1191,e).sub(.00232))))}),PI=me(([i,e])=>{const t=he(i).toVar(),n=Vr(he(.856627153315983,.137318972929847,.11189821299995),he(.0951212405381588,.761241990602591,.0767994186031903),he(.0482516061458583,.101439036467562,.811302368396859)),r=Vr(he(1.1271005818144368,-.1413297634984383,-.14132976349843826),he(-.11060664309660323,1.157823702216272,-.11060664309660294),he(-.016493938717834573,-.016493938717834257,1.2519364065950405)),o=q(-12.47393),a=q(4.026069);return t.mulAssign(e),t.assign(u6.mul(t)),t.assign(n.mul(t)),t.assign(vs(t,1e-10)),t.assign(Cc(t)),t.assign(t.sub(o).div(a.sub(o))),t.assign(Rl(t,0,1)),t.assign(h6(t)),t.assign(r.mul(t)),t.assign(Xa(vs(he(0),t),he(2.2))),t.assign(c6.mul(t)),t.assign(Rl(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),II=me(([i,e])=>{const t=q(.76),n=q(.15);i=i.mul(e);const r=ko(i.r,ko(i.g,i.b)),o=Gr(r.lessThan(.08),r.sub(Bn(6.25,r.mul(r))),.04);i.subAssign(o);const a=vs(i.r,vs(i.g,i.b));jt(a.lessThan(t),()=>i);const c=ui(1,t),u=ui(1,c.mul(c).div(a.add(c.sub(t))));i.mulAssign(u.div(a));const d=ui(1,ma(1,n.mul(a.sub(u)).add(1)));return oi(i,he(u),d)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class Ar extends Xt{static get type(){return"CodeNode"}constructor(e="",t=[],n=""){super("code"),this.isCodeNode=!0,this.global=!0,this.code=e,this.includes=t,this.language=n}setIncludes(e){return this.includes=e,this}getIncludes(){return this.includes}generate(e){const t=this.getIncludes(e);for(const r of t)r.build(e);const n=e.getCodeFromNode(this,this.getNodeType(e));return n.code=this.code,n.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 sb=Fn(Ar).setParameterLength(1,3),d6=(i,e)=>sb(i,e,"js"),f6=(i,e)=>sb(i,e,"wgsl"),p6=(i,e)=>sb(i,e,"glsl");class LI extends Ar{static get type(){return"FunctionNode"}constructor(e="",t=[],n=""){super(e,t,n)}getNodeType(e){return this.getNodeFunction(e).type}getMemberType(e,t){const n=this.getNodeType(e);return e.getStructTypeNode(n).getMemberType(e,t)}getInputs(e){return this.getNodeFunction(e).inputs}getNodeFunction(e){const t=e.getDataFromNode(this);let n=t.nodeFunction;return n===void 0&&(n=e.parser.parseFunction(this.code),t.nodeFunction=n),n}generate(e,t){super.generate(e);const n=this.getNodeFunction(e),r=n.name,o=n.type,a=e.getCodeFromNode(this,o);r!==""&&(a.name=r);const c=e.getPropertyName(a),u=this.getNodeFunction(e).getCode(c);return a.code=u+`
`,t==="property"?c:e.format(`${c}()`,o,t)}}const DI=(i,e=[],t="")=>{for(let o=0;o<e.length;o++){const a=e[o];typeof a=="function"&&(e[o]=a.functionNode)}const n=new LI(i,e,t),r=(...o)=>n.call(...o);return r.functionNode=n,r},m6=(i,e)=>DI(i,e,"glsl"),g6=(i,e)=>DI(i,e,"wgsl");class y6 extends Xt{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new Jo,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:q()}serialize(e){super.serialize(e),this.value!==null?this.inputType==="ArrayBuffer"?e.value=FM(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=BM(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 rb=Fn(y6).setParameterLength(1);class FI extends Map{get(e,t=null,...n){if(this.has(e))return super.get(e);if(t!==null){const r=t(...n);return this.set(e,r),r}}}class _6{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 ob=new FI;class x6 extends Xt{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new FI,this._output=rb(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 n=this._outputs;return n[e]===void 0?n[e]=rb(t):n[e].value=t,this}getOutput(e){return this._outputs[e]}getParameter(e){return this.parameters[e]}setParameter(e,t){const n=this.parameters;return t&&t.isScriptableNode?(this.deleteParameter(e),n[e]=t,n[e].getDefaultOutput().events.addEventListener("refresh",this.onRefresh)):t&&t.isScriptableValueNode?(this.deleteParameter(e),n[e]=t,n[e].events.addEventListener("refresh",this.onRefresh)):n[e]===void 0?(n[e]=rb(t),n[e].events.addEventListener("refresh",this.onRefresh)):n[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 r=this.getObject()[e];if(typeof r=="function")return r(...t)}callAsync(e,...t){return mn(this,null,function*(){const r=this.getObject()[e];if(typeof r=="function")return r.constructor.name==="AsyncFunction"?yield r(...t):r(...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=(d,p)=>this.setOutput(d,p),n=new _6(this),r=ob.get("THREE"),o=ob.get("TSL"),a=this.getMethod(),c=[n,this._local,ob,e,t,r,o];this._object=a(...c);const u=this._object.layout;if(u&&(u.cache===!1&&this._local.clear(),this._output.outputType=u.outputType||null,Array.isArray(u.elements)))for(const d of u.elements){const p=d.id||d.name;d.inputType&&(this.getParameter(p)===void 0&&this.setParameter(p,null),this.getParameter(p).inputType=d.inputType),d.outputType&&(this.getOutput(p)===void 0&&this.setOutput(p,null),this.getOutput(p).outputType=d.outputType)}return this._object}deserialize(e){super.deserialize(e);for(const t in this.parameters){let n=this.parameters[t];n.isScriptableNode&&(n=n.getDefaultOutput()),n.events.addEventListener("refresh",this.onRefresh)}}getLayout(){return this.getObject().layout}getDefaultOutputNode(){const e=this.getDefaultOutput().value;return e&&e.isNode?e:q()}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"],n=["layout","init","main","dispose"].join(", "),r="var "+n+`; var output = {};
`,o=`
return { ...output, `+n+" };",a=r+this.codeNode.code+o;return this._method=new Function(...e,a),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=[jm(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const n in this.parameters)t.push(this.parameters[n].getCacheKey(e));return Kf(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 v6=Fn(x6).setParameterLength(1,2);function BI(i){let e;const t=i.context.getViewZ;return t!==void 0&&(e=t(this)),(e||Us.z).negate()}const Uw=me(([i,e],t)=>{const n=BI(t);return ga(i,e,n)}),kw=me(([i],e)=>{const t=BI(e);return i.mul(i,t,t).negate().exp().oneMinus()}),Uy=me(([i,e])=>zt(e.toFloat().mix(Jm.rgb,i.toVec3()),Jm.a));function b6(i,e,t){return Ie('TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),Uy(i,Uw(e,t))}function S6(i,e){return Ie('TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),Uy(i,kw(e))}let pp=null,mp=null;class M6 extends Xt{static get type(){return"RangeNode"}constructor(e=q(),t=q()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=this.getConstNode(this.minNode),n=this.getConstNode(this.maxNode),r=e.getTypeLength(eh(t.value)),o=e.getTypeLength(eh(n.value));return r>o?r:o}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}getConstNode(e){let t=null;if(e.traverse(n=>{n.isConstNode===!0&&(t=n)}),t===null)throw new Error('THREE.TSL: No "ConstNode" found in node graph.');return t}setup(e){const t=e.object;let n=null;if(t.count>1){const r=this.getConstNode(this.minNode),o=this.getConstNode(this.maxNode),a=r.value,c=o.value,u=e.getTypeLength(eh(a)),d=e.getTypeLength(eh(c));pp=pp||new gn,mp=mp||new gn,pp.setScalar(0),mp.setScalar(0),u===1?pp.setScalar(a):a.isColor?pp.set(a.r,a.g,a.b,1):pp.set(a.x,a.y,a.z||0,a.w||0),d===1?mp.setScalar(c):c.isColor?mp.set(c.r,c.g,c.b,1):mp.set(c.x,c.y,c.z||0,c.w||0);const p=4,m=p*t.count,y=new Float32Array(m);for(let v=0;v<m;v++){const w=v%p,M=pp.getComponent(w),S=mp.getComponent(w);y[v]=Kh.lerp(M,S,Math.random())}const x=this.getNodeType(e);if(t.count<=4096)n=_y(y,"vec4",t.count).element(Dc).convert(x);else{const v=new oa(y,4);e.geometry.setAttribute("__range"+this.id,v),n=Tv(v).convert(x)}}else n=q(0);return n}}const T6=Fn(M6).setParameterLength(2);class w6 extends Xt{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 n=this.getBuiltinName(e),r=this.getNodeType(e);return e.shaderStage==="compute"?e.format(n,r,t):(Ie(`ComputeBuiltinNode: Compute built-in value ${n} can not be accessed in the ${e.shaderStage} stage`),e.generateConst(r))}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 ky=(i,e)=>new w6(i,e),A6=ky("numWorkgroups","uvec3"),E6=ky("workgroupId","uvec3"),C6=ky("globalId","uvec3"),R6=ky("localId","uvec3"),N6=ky("subgroupSize","uint");class P6 extends Xt{constructor(e){super(),this.scope=e}generate(e){const{scope:t}=this,{renderer:n}=e;n.backend.isWebGLBackend===!0?e.addFlowCode(` // ${t}Barrier
`):e.addLineFlowCode(`${t}Barrier()`,this)}}const zw=Fn(P6),I6=()=>zw("workgroup").toStack(),L6=()=>zw("storage").toStack(),D6=()=>zw("texture").toStack();class F6 extends Qf{constructor(e,t){super(e,t),this.isWorkgroupInfoElementNode=!0}generate(e,t){let n;const r=e.context.assign;if(n=super.generate(e),r!==!0){const o=this.getNodeType(e);n=e.format(n,o,t)}return n}}class B6 extends Xt{constructor(e,t,n=0){super(t),this.bufferType=t,this.bufferCount=n,this.isWorkgroupInfoNode=!0,this.elementType=t,this.scope=e,this.name=""}setName(e){return this.name=e,this}label(e){return Ie('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 new F6(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 O6=(i,e)=>new B6("Workgroup",i,e);class mr extends Xt{static get type(){return"AtomicFunctionNode"}constructor(e,t,n){super("uint"),this.method=e,this.pointerNode=t,this.valueNode=n,this.parents=!0}getInputType(e){return this.pointerNode.getNodeType(e)}getNodeType(e){return this.getInputType(e)}generate(e){const t=e.getNodeProperties(this),n=t.parents,r=this.method,o=this.getNodeType(e),a=this.getInputType(e),c=this.pointerNode,u=this.valueNode,d=[];d.push(`&${c.build(e,a)}`),u!==null&&d.push(u.build(e,a));const p=`${e.getMethod(r,o)}( ${d.join(", ")} )`;if(n?n.length===1&&n[0].isStackNode===!0:!1)e.addLineFlowCode(p,this);else return t.constNode===void 0&&(t.constNode=sh(p,o).toConst()),t.constNode.build(e)}}mr.ATOMIC_LOAD="atomicLoad",mr.ATOMIC_STORE="atomicStore",mr.ATOMIC_ADD="atomicAdd",mr.ATOMIC_SUB="atomicSub",mr.ATOMIC_MAX="atomicMax",mr.ATOMIC_MIN="atomicMin",mr.ATOMIC_AND="atomicAnd",mr.ATOMIC_OR="atomicOr",mr.ATOMIC_XOR="atomicXor";const U6=Fn(mr),Uc=(i,e,t)=>U6(i,e,t).toStack(),k6=i=>Uc(mr.ATOMIC_LOAD,i,null),z6=(i,e)=>Uc(mr.ATOMIC_STORE,i,e),V6=(i,e)=>Uc(mr.ATOMIC_ADD,i,e),G6=(i,e)=>Uc(mr.ATOMIC_SUB,i,e),W6=(i,e)=>Uc(mr.ATOMIC_MAX,i,e),H6=(i,e)=>Uc(mr.ATOMIC_MIN,i,e),$6=(i,e)=>Uc(mr.ATOMIC_AND,i,e),q6=(i,e)=>Uc(mr.ATOMIC_OR,i,e),X6=(i,e)=>Uc(mr.ATOMIC_XOR,i,e);class Dt extends _s{static get type(){return"SubgroupFunctionNode"}constructor(e,t=null,n=null){super(),this.method=e,this.aNode=t,this.bNode=n}getInputType(e){const t=this.aNode?this.aNode.getNodeType(e):null,n=this.bNode?this.bNode.getNodeType(e):null,r=e.isMatrix(t)?0:e.getTypeLength(t),o=e.isMatrix(n)?0:e.getTypeLength(n);return r>o?t:n}getNodeType(e){const t=this.method;return t===Dt.SUBGROUP_ELECT?"bool":t===Dt.SUBGROUP_BALLOT?"uvec4":this.getInputType(e)}generate(e,t){const n=this.method,r=this.getNodeType(e),o=this.getInputType(e),a=this.aNode,c=this.bNode,u=[];if(n===Dt.SUBGROUP_BROADCAST||n===Dt.SUBGROUP_SHUFFLE||n===Dt.QUAD_BROADCAST){const p=c.getNodeType(e);u.push(a.build(e,r),c.build(e,p==="float"?"int":r))}else n===Dt.SUBGROUP_SHUFFLE_XOR||n===Dt.SUBGROUP_SHUFFLE_DOWN||n===Dt.SUBGROUP_SHUFFLE_UP?u.push(a.build(e,r),c.build(e,"uint")):(a!==null&&u.push(a.build(e,o)),c!==null&&u.push(c.build(e,o)));const d=u.length===0?"()":`( ${u.join(", ")} )`;return e.format(`${e.getMethod(n,r)}${d}`,r,t)}serialize(e){super.serialize(e),e.method=this.method}deserialize(e){super.deserialize(e),this.method=e.method}}Dt.SUBGROUP_ELECT="subgroupElect",Dt.SUBGROUP_BALLOT="subgroupBallot",Dt.SUBGROUP_ADD="subgroupAdd",Dt.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd",Dt.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd",Dt.SUBGROUP_MUL="subgroupMul",Dt.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul",Dt.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul",Dt.SUBGROUP_AND="subgroupAnd",Dt.SUBGROUP_OR="subgroupOr",Dt.SUBGROUP_XOR="subgroupXor",Dt.SUBGROUP_MIN="subgroupMin",Dt.SUBGROUP_MAX="subgroupMax",Dt.SUBGROUP_ALL="subgroupAll",Dt.SUBGROUP_ANY="subgroupAny",Dt.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst",Dt.QUAD_SWAP_X="quadSwapX",Dt.QUAD_SWAP_Y="quadSwapY",Dt.QUAD_SWAP_DIAGONAL="quadSwapDiagonal",Dt.SUBGROUP_BROADCAST="subgroupBroadcast",Dt.SUBGROUP_SHUFFLE="subgroupShuffle",Dt.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor",Dt.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp",Dt.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown",Dt.QUAD_BROADCAST="quadBroadcast";const j6=pt(Dt,Dt.SUBGROUP_ELECT).setParameterLength(0),Y6=pt(Dt,Dt.SUBGROUP_BALLOT).setParameterLength(1),Z6=pt(Dt,Dt.SUBGROUP_ADD).setParameterLength(1),K6=pt(Dt,Dt.SUBGROUP_INCLUSIVE_ADD).setParameterLength(1),J6=pt(Dt,Dt.SUBGROUP_EXCLUSIVE_AND).setParameterLength(1),Q6=pt(Dt,Dt.SUBGROUP_MUL).setParameterLength(1),e8=pt(Dt,Dt.SUBGROUP_INCLUSIVE_MUL).setParameterLength(1),t8=pt(Dt,Dt.SUBGROUP_EXCLUSIVE_MUL).setParameterLength(1),n8=pt(Dt,Dt.SUBGROUP_AND).setParameterLength(1),i8=pt(Dt,Dt.SUBGROUP_OR).setParameterLength(1),s8=pt(Dt,Dt.SUBGROUP_XOR).setParameterLength(1),r8=pt(Dt,Dt.SUBGROUP_MIN).setParameterLength(1),o8=pt(Dt,Dt.SUBGROUP_MAX).setParameterLength(1),a8=pt(Dt,Dt.SUBGROUP_ALL).setParameterLength(0),l8=pt(Dt,Dt.SUBGROUP_ANY).setParameterLength(0),c8=pt(Dt,Dt.SUBGROUP_BROADCAST_FIRST).setParameterLength(2),u8=pt(Dt,Dt.QUAD_SWAP_X).setParameterLength(1),h8=pt(Dt,Dt.QUAD_SWAP_Y).setParameterLength(1),d8=pt(Dt,Dt.QUAD_SWAP_DIAGONAL).setParameterLength(1),f8=pt(Dt,Dt.SUBGROUP_BROADCAST).setParameterLength(2),p8=pt(Dt,Dt.SUBGROUP_SHUFFLE).setParameterLength(2),m8=pt(Dt,Dt.SUBGROUP_SHUFFLE_XOR).setParameterLength(2),g8=pt(Dt,Dt.SUBGROUP_SHUFFLE_UP).setParameterLength(2),y8=pt(Dt,Dt.SUBGROUP_SHUFFLE_DOWN).setParameterLength(2),_8=pt(Dt,Dt.QUAD_BROADCAST).setParameterLength(1);let ab;function lb(i){ab=ab||new WeakMap;let e=ab.get(i);return e===void 0&&ab.set(i,e={}),e}function cb(i){const e=lb(i);return e.shadowMatrix||(e.shadowMatrix=rn("mat4").setGroup(an).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 OI(i,e=_a){const t=cb(i).mul(e);return t.xyz.div(t.w)}function Vw(i){const e=lb(i);return e.position||(e.position=rn(new H).setGroup(an).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(i.matrixWorld)))}function UI(i){const e=lb(i);return e.targetPosition||(e.targetPosition=rn(new H).setGroup(an).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(i.target.matrixWorld)))}function Gw(i){const e=lb(i);return e.viewPosition||(e.viewPosition=rn(new H).setGroup(an).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new H,n.value.setFromMatrixPosition(i.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)}))}const Ww=i=>ya.transformDirection(Vw(i).sub(UI(i))),x8=i=>i.sort((e,t)=>e.id-t.id),v8=(i,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===i)return t;return null},Hw=new WeakMap,zy=[];class $w extends Xt{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=Al("vec3","totalDiffuse"),this.totalSpecularNode=Al("vec3","totalSpecular"),this.outgoingLightNode=Al("vec3","outgoingLight"),this._lights=[],this._lightNodes=null,this._lightNodesHash=null,this.global=!0}customCacheKey(){const e=this._lights;for(let n=0;n<e.length;n++){const r=e[n];if(zy.push(r.id),zy.push(r.castShadow?1:0),r.isSpotLight===!0){const o=r.map!==null?r.map.id:-1,a=r.colorNode?r.colorNode.getCacheKey():-1;zy.push(o,a)}}const t=Kf(zy);return zy.length=0,t}getHash(e){if(this._lightNodesHash===null){this._lightNodes===null&&this.setupLightsNode(e);const t=[];for(const n of this._lightNodes)t.push(n.getHash());this._lightNodesHash="lights-"+t.join(",")}return this._lightNodesHash}analyze(e){const t=e.getNodeProperties(this);for(const n of t.nodes)n.build(e);t.outputNode.build(e)}setupLightsNode(e){const t=[],n=this._lightNodes,r=x8(this._lights),o=e.renderer.library;for(const a of r)if(a.isNode)t.push(Nt(a));else{let c=null;if(n!==null&&(c=v8(a.id,n)),c===null){const u=o.getLightNodeClass(a.constructor);if(u===null){Ie(`LightsNode.setupNodeLights: Light node not found for ${a.constructor.name}`);continue}let d=null;Hw.has(a)?d=Hw.get(a):(d=new u(a),Hw.set(a,d)),t.push(d)}}this._lightNodes=t}setupDirectLight(e,t,n){const{lightingModel:r,reflectedLight:o}=e.context;r.direct(Mo(wi({},n),{lightNode:t,reflectedLight:o}),e)}setupDirectRectAreaLight(e,t,n){const{lightingModel:r,reflectedLight:o}=e.context;r.directRectArea(Mo(wi({},n),{lightNode:t,reflectedLight:o}),e)}setupLights(e,t){for(const n of t)n.build(e)}getLightNodes(e){return this._lightNodes===null&&this.setupLightsNode(e),this._lightNodes}setup(e){const t=e.lightsNode;e.lightsNode=this;let n=this.outgoingLightNode;const r=e.context,o=r.lightingModel,a=e.getNodeProperties(this);if(o){const{totalDiffuseNode:c,totalSpecularNode:u}=this;r.outgoingLight=n;const d=e.addStack();a.nodes=d.nodes,o.start(e);const{backdrop:p,backdropAlpha:m}=r,{directDiffuse:y,directSpecular:x,indirectDiffuse:v,indirectSpecular:w}=r.reflectedLight;let M=y.add(v);p!==null&&(m!==null?M=he(m.mix(M,p)):M=he(p)),c.assign(M),u.assign(x.add(w)),n.assign(c.add(u)),o.finish(e),n=n.bypass(e.removeStack())}else a.nodes=[];return e.lightsNode=t,n}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 b8=(i=[])=>new $w().setLights(i);class S8 extends Xt{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=Xn.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){qw.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||_a)}}const qw=Al("vec3","shadowPositionWorld");function Xw(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 It),e.clearAlpha=i.getClearAlpha(),e.autoClear=i.autoClear,e.scissorTest=i.getScissorTest(),e}function kI(i,e){return e=Xw(i,e),i.setMRT(null),i.setRenderObjectFunction(null),i.setClearColor(0,1),i.autoClear=!0,e}function zI(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 jw(i,e={}){return e.background=i.background,e.backgroundNode=i.backgroundNode,e.overrideMaterial=i.overrideMaterial,e}function VI(i,e){return e=jw(i,e),i.background=null,i.backgroundNode=null,i.overrideMaterial=null,e}function GI(i,e){i.background=e.background,i.backgroundNode=e.backgroundNode,i.overrideMaterial=e.overrideMaterial}function M8(i,e,t={}){return t=Xw(i,t),t=jw(e,t),t}function WI(i,e,t){return t=kI(i,t),t=VI(e,t),t}function HI(i,e,t){zI(i,t),GI(e,t)}var jZ=Object.freeze({__proto__:null,resetRendererAndSceneState:WI,resetRendererState:kI,resetSceneState:VI,restoreRendererAndSceneState:HI,restoreRendererState:zI,restoreSceneState:GI,saveRendererAndSceneState:M8,saveRendererState:Xw,saveSceneState:jw});const ub=new WeakMap,$I=me(({depthTexture:i,shadowCoord:e,depthLayer:t})=>{let n=_i(i,e.xy).setName("t_basic");return i.isArrayTexture&&(n=n.depth(t)),n.compare(e.z)}),qI=me(({depthTexture:i,shadowCoord:e,shadow:t,depthLayer:n})=>{const r=(p,m)=>{let y=_i(i,p);return i.isArrayTexture&&(y=y.depth(n)),y.compare(m)},o=Oi("mapSize","vec2",t).setGroup(an),a=Oi("radius","float",t).setGroup(an),c=lt(1).div(o),u=a.mul(c.x),d=Dw(ap.xy).mul(6.28318530718);return Js(r(e.xy.add(Pl(0,5,d).mul(u)),e.z),r(e.xy.add(Pl(1,5,d).mul(u)),e.z),r(e.xy.add(Pl(2,5,d).mul(u)),e.z),r(e.xy.add(Pl(3,5,d).mul(u)),e.z),r(e.xy.add(Pl(4,5,d).mul(u)),e.z)).mul(1/5)}),XI=me(({depthTexture:i,shadowCoord:e,shadow:t,depthLayer:n})=>{const r=(m,y)=>{let x=_i(i,m);return i.isArrayTexture&&(x=x.depth(n)),x.compare(y)},o=Oi("mapSize","vec2",t).setGroup(an),a=lt(1).div(o),c=a.x,u=a.y,d=e.xy,p=El(d.mul(o).add(.5));return d.subAssign(p.mul(a)),Js(r(d,e.z),r(d.add(lt(c,0)),e.z),r(d.add(lt(0,u)),e.z),r(d.add(a),e.z),oi(r(d.add(lt(c.negate(),0)),e.z),r(d.add(lt(c.mul(2),0)),e.z),p.x),oi(r(d.add(lt(c.negate(),u)),e.z),r(d.add(lt(c.mul(2),u)),e.z),p.x),oi(r(d.add(lt(0,u.negate())),e.z),r(d.add(lt(0,u.mul(2))),e.z),p.y),oi(r(d.add(lt(c,u.negate())),e.z),r(d.add(lt(c,u.mul(2))),e.z),p.y),oi(oi(r(d.add(lt(c.negate(),u.negate())),e.z),r(d.add(lt(c.mul(2),u.negate())),e.z),p.x),oi(r(d.add(lt(c.negate(),u.mul(2))),e.z),r(d.add(lt(c.mul(2),u.mul(2))),e.z),p.x),p.y)).mul(1/9)}),jI=me(({depthTexture:i,shadowCoord:e,depthLayer:t})=>{let n=_i(i).sample(e.xy);i.isArrayTexture&&(n=n.depth(t)),n=n.rg;const r=n.x,o=vs(1e-7,n.y.mul(n.y)),a=xv(e.z,r);jt(a.equal(1),()=>q(1));const c=e.z.sub(r);let u=o.div(o.add(c.mul(c)));return u=Rl(ui(u,.3).div(.65)),vs(a,u)}),T8=me(([i,e,t])=>{let n=_a.sub(i).length();return n=n.sub(e).div(t.sub(e)),n=n.saturate(),n}),w8=i=>{const e=i.shadow.camera,t=Oi("near","float",e).setGroup(an),n=Oi("far","float",e).setGroup(an),r=WR(i);return T8(r,t,n)},YI=i=>{let e=ub.get(i);if(e===void 0){const t=i.isPointLight?w8(i):null;e=new Ss,e.colorNode=zt(0,0,0,1),e.depthNode=t,e.isShadowPassMaterial=!0,e.name="ShadowMaterial",e.fog=!1,ub.set(i,e)}return e},ZI=i=>{const e=ub.get(i);e!==void 0&&(e.dispose(),ub.delete(i))},KI=new Nl,yg=[],JI=(i,e,t,n)=>{yg[0]=i,yg[1]=e;let r=KI.get(yg);return(r===void 0||r.shadowType!==t||r.useVelocity!==n)&&(r=(o,a,c,u,d,p,...m)=>{(o.castShadow===!0||o.receiveShadow&&t===oe)&&(n&&(DM(o).useVelocity=!0),o.onBeforeShadow(i,o,c,e.camera,u,a.overrideMaterial,p),i.renderObject(o,a,c,u,d,p,...m),o.onAfterShadow(i,o,c,e.camera,u,a.overrideMaterial,p))},r.shadowType=t,r.useVelocity=n,KI.set(yg,r)),yg[0]=null,yg[1]=null,r},A8=me(({samples:i,radius:e,size:t,shadowPass:n,depthLayer:r})=>{const o=q(0).toVar("meanVertical"),a=q(0).toVar("squareMeanVertical"),c=i.lessThanEqual(q(1)).select(q(0),q(2).div(i.sub(1))),u=i.lessThanEqual(q(1)).select(q(0),q(-1));Ai({start:le(0),end:le(i),type:"int",condition:"<"},({i:p})=>{const m=u.add(q(p).mul(c));let y=n.sample(Js(ap.xy,lt(0,m).mul(e)).div(t));n.value.isArrayTexture&&(y=y.depth(r)),y=y.x,o.addAssign(y),a.addAssign(y.mul(y))}),o.divAssign(i),a.divAssign(i);const d=Qr(a.sub(o.mul(o)).max(0));return lt(o,d)}),E8=me(({samples:i,radius:e,size:t,shadowPass:n,depthLayer:r})=>{const o=q(0).toVar("meanHorizontal"),a=q(0).toVar("squareMeanHorizontal"),c=i.lessThanEqual(q(1)).select(q(0),q(2).div(i.sub(1))),u=i.lessThanEqual(q(1)).select(q(0),q(-1));Ai({start:le(0),end:le(i),type:"int",condition:"<"},({i:p})=>{const m=u.add(q(p).mul(c));let y=n.sample(Js(ap.xy,lt(m,0).mul(e)).div(t));n.value.isArrayTexture&&(y=y.depth(r)),o.addAssign(y.x),a.addAssign(Js(y.y.mul(y.y),y.x.mul(y.x)))}),o.divAssign(i),a.divAssign(i);const d=Qr(a.sub(o.mul(o)).max(0));return lt(o,d)}),C8=[$I,qI,XI,jI];let Yw;const hb=new By;class QI extends S8{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:n,shadowCoord:r,shadow:o,depthLayer:a}){const c=r.x.greaterThanEqual(0).and(r.x.lessThanEqual(1)).and(r.y.greaterThanEqual(0)).and(r.y.lessThanEqual(1)).and(r.z.lessThanEqual(1)),u=t({depthTexture:n,shadowCoord:r,shadow:o,depthLayer:a});return c.select(u,q(1))}setupShadowCoord(e,t){const{shadow:n}=this,{renderer:r}=e,o=Oi("bias","float",n).setGroup(an);let a=t,c;if(n.camera.isOrthographicCamera||r.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),c=a.z,r.coordinateSystem===xr&&(c=c.mul(2).sub(1));else{const u=a.w;a=a.xy.div(u);const d=Oi("near","float",n.camera).setGroup(an),p=Oi("far","float",n.camera).setGroup(an);c=sw(u.negate(),d,p)}return a=he(a.x,a.y.oneMinus(),c.add(o)),a}getShadowFilterFn(e){return C8[e]}setupRenderTarget(e,t){const n=new Ys(e.mapSize.width,e.mapSize.height);n.name="ShadowDepthTexture",n.compareFunction=Vl;const r=t.createRenderTarget(e.mapSize.width,e.mapSize.height);return r.texture.name="ShadowMap",r.texture.type=e.mapType,r.depthTexture=n,{shadowMap:r,depthTexture:n}}setupShadow(e){const{renderer:t,camera:n}=e,{light:r,shadow:o}=this,a=t.shadowMap.type,{depthTexture:c,shadowMap:u}=this.setupRenderTarget(o,e);if(o.camera.coordinateSystem=n.coordinateSystem,o.camera.updateProjectionMatrix(),a===oe&&o.isPointLightShadow!==!0){c.compareFunction=null,u.depth>1?(u._vsmShadowMapVertical||(u._vsmShadowMapVertical=e.createRenderTarget(o.mapSize.width,o.mapSize.height,{format:Nr,type:Hi,depth:u.depth,depthBuffer:!1}),u._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=u._vsmShadowMapVertical,u._vsmShadowMapHorizontal||(u._vsmShadowMapHorizontal=e.createRenderTarget(o.mapSize.width,o.mapSize.height,{format:Nr,type:Hi,depth:u.depth,depthBuffer:!1}),u._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=u._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(o.mapSize.width,o.mapSize.height,{format:Nr,type:Hi,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(o.mapSize.width,o.mapSize.height,{format:Nr,type:Hi,depthBuffer:!1}));let N=_i(c);c.isArrayTexture&&(N=N.depth(this.depthLayer));let I=_i(this.vsmShadowMapVertical.texture);c.isArrayTexture&&(I=I.depth(this.depthLayer));const U=Oi("blurSamples","float",o).setGroup(an),F=Oi("radius","float",o).setGroup(an),k=Oi("mapSize","vec2",o).setGroup(an);let G=this.vsmMaterialVertical||(this.vsmMaterialVertical=new Ss);G.fragmentNode=A8({samples:U,radius:F,size:k,shadowPass:N,depthLayer:this.depthLayer}).context(e.getSharedContext()),G.name="VSMVertical",G=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new Ss),G.fragmentNode=E8({samples:U,radius:F,size:k,shadowPass:I,depthLayer:this.depthLayer}).context(e.getSharedContext()),G.name="VSMHorizontal"}const d=Oi("intensity","float",o).setGroup(an),p=Oi("normalBias","float",o).setGroup(an),m=cb(r).mul(qw.add($d.mul(p))),y=this.setupShadowCoord(e,m),x=o.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(x===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const v=a===oe&&o.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:c,w=this.setupShadowFilter(e,{filterFn:x,shadowTexture:u.texture,depthTexture:v,shadowCoord:y,shadow:o,depthLayer:this.depthLayer});let M;u.texture.isCubeTexture?M=vo(u.texture,y.xyz):(M=_i(u.texture,y),c.isArrayTexture&&(M=M.depth(this.depthLayer)));const S=oi(1,w.rgb.mix(M,1),d.mul(M.a)).toVar();this.shadowMap=u,this.shadow.map=u;const C=`${this.light.type} Shadow [ ${this.light.name||"ID: "+this.light.id} ]`;return S.toInspector(`${C} / Color`,()=>this.shadowMap.texture.isCubeTexture?vo(this.shadowMap.texture):_i(this.shadowMap.texture)).toInspector(`${C} / Depth`,()=>this.shadowMap.texture.isCubeTexture?vo(this.shadowMap.texture).r.oneMinus():Ns(this.shadowMap.depthTexture,Pi().mul(rh(_i(this.shadowMap.depthTexture)))).r.oneMinus())}setup(e){if(e.renderer.shadowMap.enabled!==!1)return me(()=>{const t=e.renderer.shadowMap.type;this._currentShadowType!==t&&(this._reset(),this._node=null);let n=this._node;return this.setupShadowPosition(e),n===null&&(this._node=n=this.setupShadow(e),this._currentShadowType=t),e.material.shadowNode&&Ie('NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(n=e.material.receivedShadowNode(n)),n})()}renderShadow(e){const{shadow:t,shadowMap:n,light:r}=this,{renderer:o,scene:a}=e;t.updateMatrices(r),n.setSize(t.mapSize.width,t.mapSize.height,n.depth);const c=a.name;a.name=`Shadow Map [ ${r.name||"ID: "+r.id} ]`,o.render(a,t.camera),a.name=c}updateShadow(e){const{shadowMap:t,light:n,shadow:r}=this,{renderer:o,scene:a,camera:c}=e,u=o.shadowMap.type,d=t.depthTexture.version;this._depthVersionCached=d;const p=r.camera.layers.mask;r.camera.layers.mask&4294967294||(r.camera.layers.mask=c.layers.mask);const m=o.getRenderObjectFunction(),y=o.getMRT(),x=y?y.has("velocity"):!1;Yw=WI(o,a,Yw),a.overrideMaterial=YI(n),o.setRenderObjectFunction(JI(o,r,u,x)),o.setClearColor(0,0),o.setRenderTarget(t),this.renderShadow(e),o.setRenderObjectFunction(m),u===oe&&r.isPointLightShadow!==!0&&this.vsmPass(o),r.camera.layers.mask=p,HI(o,a,Yw)}vsmPass(e){const{shadow:t}=this,n=this.shadowMap.depth;this.vsmShadowMapVertical.setSize(t.mapSize.width,t.mapSize.height,n),this.vsmShadowMapHorizontal.setSize(t.mapSize.width,t.mapSize.height,n),e.setRenderTarget(this.vsmShadowMapVertical),hb.material=this.vsmMaterialVertical,hb.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),hb.material=this.vsmMaterialHorizontal,hb.render(e)}dispose(){this._reset(),super.dispose()}_reset(){this._currentShadowType=null,ZI(this.light),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 n=t.needsUpdate||t.autoUpdate;n&&(this._cameraFrameId[e.camera]===e.frameId&&(n=!1),this._cameraFrameId[e.camera]=e.frameId),n&&(this.updateShadow(e),this.shadowMap.depthTexture.version===this._depthVersionCached&&(t.needsUpdate=!1))}}const e2=(i,e)=>new QI(i,e),R8=new It,t2=new Qt,Vy=new H,Zw=new H,N8=[new H(1,0,0),new H(-1,0,0),new H(0,-1,0),new H(0,1,0),new H(0,0,1),new H(0,0,-1)],P8=[new H(0,-1,0),new H(0,-1,0),new H(0,0,-1),new H(0,0,1),new H(0,-1,0),new H(0,-1,0)],I8=[new H(1,0,0),new H(-1,0,0),new H(0,1,0),new H(0,-1,0),new H(0,0,1),new H(0,0,-1)],L8=[new H(0,-1,0),new H(0,-1,0),new H(0,0,1),new H(0,0,-1),new H(0,-1,0),new H(0,-1,0)],n2=me(({depthTexture:i,bd3D:e,dp:t})=>vo(i,e).compare(t)),i2=me(({depthTexture:i,bd3D:e,dp:t,shadow:n})=>{const r=Oi("radius","float",n).setGroup(an),o=Oi("mapSize","vec2",n).setGroup(an),a=r.div(o.x),c=qi(e),u=go(nh(e,c.x.greaterThan(c.z).select(he(0,1,0),he(1,0,0)))),d=nh(e,u),p=Dw(ap.xy).mul(6.28318530718),m=Pl(0,5,p),y=Pl(1,5,p),x=Pl(2,5,p),v=Pl(3,5,p),w=Pl(4,5,p);return vo(i,e.add(u.mul(m.x).add(d.mul(m.y)).mul(a))).compare(t).add(vo(i,e.add(u.mul(y.x).add(d.mul(y.y)).mul(a))).compare(t)).add(vo(i,e.add(u.mul(x.x).add(d.mul(x.y)).mul(a))).compare(t)).add(vo(i,e.add(u.mul(v.x).add(d.mul(v.y)).mul(a))).compare(t)).add(vo(i,e.add(u.mul(w.x).add(d.mul(w.y)).mul(a))).compare(t)).mul(1/5)}),D8=me(({filterFn:i,depthTexture:e,shadowCoord:t,shadow:n})=>{const r=t.xyz.toVar(),o=r.length(),a=rn("float").setGroup(an).onRenderUpdate(()=>n.camera.near),c=rn("float").setGroup(an).onRenderUpdate(()=>n.camera.far),u=Oi("bias","float",n).setGroup(an),d=q(1).toVar();return jt(o.sub(c).lessThanEqual(0).and(o.sub(a).greaterThanEqual(0)),()=>{const p=o.sub(a).div(c.sub(a)).toVar();p.addAssign(u);const m=r.normalize();d.assign(i({depthTexture:e,bd3D:m,dp:p,shadow:n}))}),d});class F8 extends QI{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===te?n2:i2}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,depthTexture:n,shadowCoord:r,shadow:o}){return D8({filterFn:t,depthTexture:n,shadowCoord:r,shadow:o})}setupRenderTarget(e,t){const n=new Cf(e.mapSize.width);n.name="PointShadowDepthTexture",n.compareFunction=Vl;const r=t.createCubeRenderTarget(e.mapSize.width);return r.texture.name="PointShadowMap",r.depthTexture=n,{shadowMap:r,depthTexture:n}}renderShadow(e){const{shadow:t,shadowMap:n,light:r}=this,{renderer:o,scene:a}=e,c=t.camera,u=t.matrix,d=o.coordinateSystem===xr,p=d?N8:I8,m=d?P8:L8;n.setSize(t.mapSize.width,t.mapSize.width);const y=o.autoClear,x=o.getClearColor(R8),v=o.getClearAlpha();o.autoClear=!1,o.setClearColor(t.clearColor,t.clearAlpha);for(let w=0;w<6;w++){o.setRenderTarget(n,w),o.clear();const M=r.distance||c.far;M!==c.far&&(c.far=M,c.updateProjectionMatrix()),Vy.setFromMatrixPosition(r.matrixWorld),c.position.copy(Vy),Zw.copy(c.position),Zw.add(p[w]),c.up.copy(m[w]),c.lookAt(Zw),c.updateMatrixWorld(),u.makeTranslation(-Vy.x,-Vy.y,-Vy.z),t2.multiplyMatrices(c.projectionMatrix,c.matrixWorldInverse),t._frustum.setFromProjectionMatrix(t2,c.coordinateSystem,c.reversedDepth);const S=a.name;a.name=`Point Light Shadow [ ${r.name||"ID: "+r.id} ] - Face ${w+1}`,o.render(a,c),a.name=S}o.autoClear=y,o.setClearColor(x,v)}}const s2=(i,e)=>new F8(i,e);class gp extends og{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new It,this.colorNode=e&&e.colorNode||rn(this.color).setGroup(an),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=Xn.FRAME,e&&e.shadow&&(this._shadowDisposeListener=()=>{this.disposeShadow()},e.addEventListener("dispose",this._shadowDisposeListener))}dispose(){this._shadowDisposeListener&&this.light.removeEventListener("dispose",this._shadowDisposeListener),super.dispose()}disposeShadow(){this.shadowNode!==null&&(this.shadowNode.dispose(),this.shadowNode=null),this.shadowColorNode=null,this.baseColorNode!==null&&(this.colorNode=this.baseColorNode,this.baseColorNode=null)}getHash(){return this.light.uuid}getLightVector(e){return Gw(this.light).sub(e.context.positionView||Us)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return e2(this.light)}setupShadow(e){const{renderer:t}=e;if(t.shadowMap.enabled===!1)return;let n=this.shadowColorNode;if(n===null){const r=this.light.shadow.shadowNode;let o;r!==void 0?o=Nt(r):o=this.setupShadowNode(),this.shadowNode=o,this.shadowColorNode=n=this.colorNode.mul(o),this.baseColorNode=this.colorNode}e.context.getShadow&&(n=e.context.getShadow(this,e)),this.colorNode=n}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),n=this.setupDirectRectArea(e);t&&e.lightsNode.setupDirectLight(e,this,t),n&&e.lightsNode.setupDirectRectAreaLight(e,this,n)}update(){const{light:e}=this;this.color.copy(e.color).multiplyScalar(e.intensity)}}const Kw=me(({lightDistance:i,cutoffDistance:e,decayExponent:t})=>{const n=i.pow(t).max(.01).reciprocal();return e.greaterThan(0).select(n.mul(i.div(e).pow4().oneMinus().clamp().pow2()),n)}),r2=({color:i,lightVector:e,cutoffDistance:t,decayExponent:n})=>{const r=e.normalize(),o=e.length(),a=Kw({lightDistance:o,cutoffDistance:t,decayExponent:n}),c=i.mul(a);return{lightDirection:r,lightColor:c}};class B8 extends gp{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=rn(0).setGroup(an),this.decayExponentNode=rn(2).setGroup(an)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return s2(this.light)}setupDirect(e){return r2({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}const O8=me(([i=Pi()])=>{const e=i.mul(2),t=e.x.floor(),n=e.y.floor();return t.add(n).mod(2).sign()}),U8=me(([i=Pi()],{renderer:e,material:t})=>{const n=yT(i.mul(2).sub(1));let r;if(t.alphaToCoverage&&e.currentSamples>0){const o=q(n.fwidth()).toVar();r=ga(o.oneMinus(),o.add(1),n).oneMinus()}else r=Gr(n.greaterThan(1),0,1);return r}),Gy=me(([i,e,t])=>{const n=q(t).toVar(),r=q(e).toVar(),o=$a(i).toVar();return Gr(o,r,n)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),db=me(([i,e])=>{const t=$a(e).toVar(),n=q(i).toVar();return Gr(t,n.negate(),n)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),Qs=me(([i])=>{const e=q(i).toVar();return le(Rc(e))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),ds=me(([i,e])=>{const t=q(i).toVar();return e.assign(Qs(t)),t.sub(q(e))}),o2=Hr([me(([i,e,t,n,r,o])=>{const a=q(o).toVar(),c=q(r).toVar(),u=q(n).toVar(),d=q(t).toVar(),p=q(e).toVar(),m=q(i).toVar(),y=q(ui(1,c)).toVar();return ui(1,a).mul(m.mul(y).add(p.mul(c))).add(a.mul(d.mul(y).add(u.mul(c))))}).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"}]}),me(([i,e,t,n,r,o])=>{const a=q(o).toVar(),c=q(r).toVar(),u=he(n).toVar(),d=he(t).toVar(),p=he(e).toVar(),m=he(i).toVar(),y=q(ui(1,c)).toVar();return ui(1,a).mul(m.mul(y).add(p.mul(c))).add(a.mul(d.mul(y).add(u.mul(c))))}).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"}]})]),a2=Hr([me(([i,e,t,n,r,o,a,c,u,d,p])=>{const m=q(p).toVar(),y=q(d).toVar(),x=q(u).toVar(),v=q(c).toVar(),w=q(a).toVar(),M=q(o).toVar(),S=q(r).toVar(),C=q(n).toVar(),N=q(t).toVar(),I=q(e).toVar(),U=q(i).toVar(),F=q(ui(1,x)).toVar(),k=q(ui(1,y)).toVar();return q(ui(1,m)).toVar().mul(k.mul(U.mul(F).add(I.mul(x))).add(y.mul(N.mul(F).add(C.mul(x))))).add(m.mul(k.mul(S.mul(F).add(M.mul(x))).add(y.mul(w.mul(F).add(v.mul(x))))))}).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"}]}),me(([i,e,t,n,r,o,a,c,u,d,p])=>{const m=q(p).toVar(),y=q(d).toVar(),x=q(u).toVar(),v=he(c).toVar(),w=he(a).toVar(),M=he(o).toVar(),S=he(r).toVar(),C=he(n).toVar(),N=he(t).toVar(),I=he(e).toVar(),U=he(i).toVar(),F=q(ui(1,x)).toVar(),k=q(ui(1,y)).toVar();return q(ui(1,m)).toVar().mul(k.mul(U.mul(F).add(I.mul(x))).add(y.mul(N.mul(F).add(C.mul(x))))).add(m.mul(k.mul(S.mul(F).add(M.mul(x))).add(y.mul(w.mul(F).add(v.mul(x))))))}).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"}]})]),Er=Hr([me(([i,e,t])=>{const n=q(t).toVar(),r=q(e).toVar(),o=it(i).toVar(),a=it(o.bitAnd(it(7))).toVar(),c=q(Gy(a.lessThan(it(4)),r,n)).toVar(),u=q(Bn(2,Gy(a.lessThan(it(4)),n,r))).toVar();return db(c,$a(a.bitAnd(it(1)))).add(db(u,$a(a.bitAnd(it(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),me(([i,e,t,n])=>{const r=q(n).toVar(),o=q(t).toVar(),a=q(e).toVar(),c=it(i).toVar(),u=it(c.bitAnd(it(15))).toVar(),d=q(Gy(u.lessThan(it(8)),a,o)).toVar(),p=q(Gy(u.lessThan(it(4)),o,Gy(u.equal(it(12)).or(u.equal(it(14))),a,r))).toVar();return db(d,$a(u.bitAnd(it(1)))).add(db(p,$a(u.bitAnd(it(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"}]})]),Ja=Hr([me(([i,e,t])=>{const n=q(t).toVar(),r=q(e).toVar(),o=tp(i).toVar();return he(Er(o.x,r,n),Er(o.y,r,n),Er(o.z,r,n))}).setLayout({name:"mx_gradient_vec3_0",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"}]}),me(([i,e,t,n])=>{const r=q(n).toVar(),o=q(t).toVar(),a=q(e).toVar(),c=tp(i).toVar();return he(Er(c.x,a,o,r),Er(c.y,a,o,r),Er(c.z,a,o,r))}).setLayout({name:"mx_gradient_vec3_1",type:"vec3",inputs:[{name:"hash",type:"uvec3"},{name:"x",type:"float"},{name:"y",type:"float"},{name:"z",type:"float"}]})]),k8=me(([i])=>{const e=q(i).toVar();return Bn(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),z8=me(([i])=>{const e=q(i).toVar();return Bn(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),l2=Hr([k8,me(([i])=>{const e=he(i).toVar();return Bn(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),c2=Hr([z8,me(([i])=>{const e=he(i).toVar();return Bn(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),ba=me(([i,e])=>{const t=le(e).toVar(),n=it(i).toVar();return n.shiftLeft(t).bitOr(n.shiftRight(le(32).sub(t)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),u2=me(([i,e,t])=>{i.subAssign(t),i.bitXorAssign(ba(t,le(4))),t.addAssign(e),e.subAssign(i),e.bitXorAssign(ba(i,le(6))),i.addAssign(t),t.subAssign(e),t.bitXorAssign(ba(e,le(8))),e.addAssign(i),i.subAssign(t),i.bitXorAssign(ba(t,le(16))),t.addAssign(e),e.subAssign(i),e.bitXorAssign(ba(i,le(19))),i.addAssign(t),t.subAssign(e),t.bitXorAssign(ba(e,le(4))),e.addAssign(i)}),Wy=me(([i,e,t])=>{const n=it(t).toVar(),r=it(e).toVar(),o=it(i).toVar();return n.bitXorAssign(r),n.subAssign(ba(r,le(14))),o.bitXorAssign(n),o.subAssign(ba(n,le(11))),r.bitXorAssign(o),r.subAssign(ba(o,le(25))),n.bitXorAssign(r),n.subAssign(ba(r,le(16))),o.bitXorAssign(n),o.subAssign(ba(n,le(4))),r.bitXorAssign(o),r.subAssign(ba(o,le(14))),n.bitXorAssign(r),n.subAssign(ba(r,le(24))),n}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),to=me(([i])=>{const e=it(i).toVar();return q(e).div(q(it(le(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),kc=me(([i])=>{const e=q(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"}]}),Ui=Hr([me(([i])=>{const e=le(i).toVar(),t=it(it(1)).toVar(),n=it(it(le(3735928559)).add(t.shiftLeft(it(2))).add(it(13))).toVar();return Wy(n.add(it(e)),n,n)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),me(([i,e])=>{const t=le(e).toVar(),n=le(i).toVar(),r=it(it(2)).toVar(),o=it().toVar(),a=it().toVar(),c=it().toVar();return o.assign(a.assign(c.assign(it(le(3735928559)).add(r.shiftLeft(it(2))).add(it(13))))),o.addAssign(it(n)),a.addAssign(it(t)),Wy(o,a,c)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),me(([i,e,t])=>{const n=le(t).toVar(),r=le(e).toVar(),o=le(i).toVar(),a=it(it(3)).toVar(),c=it().toVar(),u=it().toVar(),d=it().toVar();return c.assign(u.assign(d.assign(it(le(3735928559)).add(a.shiftLeft(it(2))).add(it(13))))),c.addAssign(it(o)),u.addAssign(it(r)),d.addAssign(it(n)),Wy(c,u,d)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),me(([i,e,t,n])=>{const r=le(n).toVar(),o=le(t).toVar(),a=le(e).toVar(),c=le(i).toVar(),u=it(it(4)).toVar(),d=it().toVar(),p=it().toVar(),m=it().toVar();return d.assign(p.assign(m.assign(it(le(3735928559)).add(u.shiftLeft(it(2))).add(it(13))))),d.addAssign(it(c)),p.addAssign(it(a)),m.addAssign(it(o)),u2(d,p,m),d.addAssign(it(r)),Wy(d,p,m)}).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"}]}),me(([i,e,t,n,r])=>{const o=le(r).toVar(),a=le(n).toVar(),c=le(t).toVar(),u=le(e).toVar(),d=le(i).toVar(),p=it(it(5)).toVar(),m=it().toVar(),y=it().toVar(),x=it().toVar();return m.assign(y.assign(x.assign(it(le(3735928559)).add(p.shiftLeft(it(2))).add(it(13))))),m.addAssign(it(d)),y.addAssign(it(u)),x.addAssign(it(c)),u2(m,y,x),m.addAssign(it(a)),y.addAssign(it(o)),Wy(m,y,x)}).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"}]})]),Qa=Hr([me(([i,e])=>{const t=le(e).toVar(),n=le(i).toVar(),r=it(Ui(n,t)).toVar(),o=tp().toVar();return o.x.assign(r.bitAnd(le(255))),o.y.assign(r.shiftRight(le(8)).bitAnd(le(255))),o.z.assign(r.shiftRight(le(16)).bitAnd(le(255))),o}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),me(([i,e,t])=>{const n=le(t).toVar(),r=le(e).toVar(),o=le(i).toVar(),a=it(Ui(o,r,n)).toVar(),c=tp().toVar();return c.x.assign(a.bitAnd(le(255))),c.y.assign(a.shiftRight(le(8)).bitAnd(le(255))),c.z.assign(a.shiftRight(le(16)).bitAnd(le(255))),c}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]})]),Jw=Hr([me(([i])=>{const e=lt(i).toVar(),t=le().toVar(),n=le().toVar(),r=q(ds(e.x,t)).toVar(),o=q(ds(e.y,n)).toVar(),a=q(kc(r)).toVar(),c=q(kc(o)).toVar(),u=q(o2(Er(Ui(t,n),r,o),Er(Ui(t.add(le(1)),n),r.sub(1),o),Er(Ui(t,n.add(le(1))),r,o.sub(1)),Er(Ui(t.add(le(1)),n.add(le(1))),r.sub(1),o.sub(1)),a,c)).toVar();return l2(u)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),me(([i])=>{const e=he(i).toVar(),t=le().toVar(),n=le().toVar(),r=le().toVar(),o=q(ds(e.x,t)).toVar(),a=q(ds(e.y,n)).toVar(),c=q(ds(e.z,r)).toVar(),u=q(kc(o)).toVar(),d=q(kc(a)).toVar(),p=q(kc(c)).toVar(),m=q(a2(Er(Ui(t,n,r),o,a,c),Er(Ui(t.add(le(1)),n,r),o.sub(1),a,c),Er(Ui(t,n.add(le(1)),r),o,a.sub(1),c),Er(Ui(t.add(le(1)),n.add(le(1)),r),o.sub(1),a.sub(1),c),Er(Ui(t,n,r.add(le(1))),o,a,c.sub(1)),Er(Ui(t.add(le(1)),n,r.add(le(1))),o.sub(1),a,c.sub(1)),Er(Ui(t,n.add(le(1)),r.add(le(1))),o,a.sub(1),c.sub(1)),Er(Ui(t.add(le(1)),n.add(le(1)),r.add(le(1))),o.sub(1),a.sub(1),c.sub(1)),u,d,p)).toVar();return c2(m)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]})]),Hy=Hr([me(([i])=>{const e=lt(i).toVar(),t=le().toVar(),n=le().toVar(),r=q(ds(e.x,t)).toVar(),o=q(ds(e.y,n)).toVar(),a=q(kc(r)).toVar(),c=q(kc(o)).toVar(),u=he(o2(Ja(Qa(t,n),r,o),Ja(Qa(t.add(le(1)),n),r.sub(1),o),Ja(Qa(t,n.add(le(1))),r,o.sub(1)),Ja(Qa(t.add(le(1)),n.add(le(1))),r.sub(1),o.sub(1)),a,c)).toVar();return l2(u)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),me(([i])=>{const e=he(i).toVar(),t=le().toVar(),n=le().toVar(),r=le().toVar(),o=q(ds(e.x,t)).toVar(),a=q(ds(e.y,n)).toVar(),c=q(ds(e.z,r)).toVar(),u=q(kc(o)).toVar(),d=q(kc(a)).toVar(),p=q(kc(c)).toVar(),m=he(a2(Ja(Qa(t,n,r),o,a,c),Ja(Qa(t.add(le(1)),n,r),o.sub(1),a,c),Ja(Qa(t,n.add(le(1)),r),o,a.sub(1),c),Ja(Qa(t.add(le(1)),n.add(le(1)),r),o.sub(1),a.sub(1),c),Ja(Qa(t,n,r.add(le(1))),o,a,c.sub(1)),Ja(Qa(t.add(le(1)),n,r.add(le(1))),o.sub(1),a,c.sub(1)),Ja(Qa(t,n.add(le(1)),r.add(le(1))),o,a.sub(1),c.sub(1)),Ja(Qa(t.add(le(1)),n.add(le(1)),r.add(le(1))),o.sub(1),a.sub(1),c.sub(1)),u,d,p)).toVar();return c2(m)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]})]),V8=Hr([me(([i])=>{const e=q(i).toVar(),t=le(Qs(e)).toVar();return to(Ui(t))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),me(([i])=>{const e=lt(i).toVar(),t=le(Qs(e.x)).toVar(),n=le(Qs(e.y)).toVar();return to(Ui(t,n))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),me(([i])=>{const e=he(i).toVar(),t=le(Qs(e.x)).toVar(),n=le(Qs(e.y)).toVar(),r=le(Qs(e.z)).toVar();return to(Ui(t,n,r))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),me(([i])=>{const e=zt(i).toVar(),t=le(Qs(e.x)).toVar(),n=le(Qs(e.y)).toVar(),r=le(Qs(e.z)).toVar(),o=le(Qs(e.w)).toVar();return to(Ui(t,n,r,o))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),fb=Hr([me(([i])=>{const e=q(i).toVar(),t=le(Qs(e)).toVar();return he(to(Ui(t,le(0))),to(Ui(t,le(1))),to(Ui(t,le(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),me(([i])=>{const e=lt(i).toVar(),t=le(Qs(e.x)).toVar(),n=le(Qs(e.y)).toVar();return he(to(Ui(t,n,le(0))),to(Ui(t,n,le(1))),to(Ui(t,n,le(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),me(([i])=>{const e=he(i).toVar(),t=le(Qs(e.x)).toVar(),n=le(Qs(e.y)).toVar(),r=le(Qs(e.z)).toVar();return he(to(Ui(t,n,r,le(0))),to(Ui(t,n,r,le(1))),to(Ui(t,n,r,le(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),me(([i])=>{const e=zt(i).toVar(),t=le(Qs(e.x)).toVar(),n=le(Qs(e.y)).toVar(),r=le(Qs(e.z)).toVar(),o=le(Qs(e.w)).toVar();return he(to(Ui(t,n,r,o,le(0))),to(Ui(t,n,r,o,le(1))),to(Ui(t,n,r,o,le(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),pb=me(([i,e,t,n])=>{const r=q(n).toVar(),o=q(t).toVar(),a=le(e).toVar(),c=he(i).toVar(),u=q(0).toVar(),d=q(1).toVar();return Ai(a,()=>{u.addAssign(d.mul(Jw(c))),d.mulAssign(r),c.mulAssign(o)}),u}).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"}]}),mb=me(([i,e,t,n])=>{const r=q(n).toVar(),o=q(t).toVar(),a=le(e).toVar(),c=he(i).toVar(),u=he(0).toVar(),d=q(1).toVar();return Ai(a,()=>{u.addAssign(d.mul(Hy(c))),d.mulAssign(r),c.mulAssign(o)}),u}).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"}]}),G8=me(([i,e,t,n])=>{const r=q(n).toVar(),o=q(t).toVar(),a=le(e).toVar(),c=he(i).toVar();return lt(pb(c,a,o,r),pb(c.add(he(le(19),le(193),le(17))),a,o,r))}).setLayout({name:"mx_fractal_noise_vec2",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"octaves",type:"int"},{name:"lacunarity",type:"float"},{name:"diminish",type:"float"}]}),W8=me(([i,e,t,n])=>{const r=q(n).toVar(),o=q(t).toVar(),a=le(e).toVar(),c=he(i).toVar(),u=he(mb(c,a,o,r)).toVar(),d=q(pb(c.add(he(le(19),le(193),le(17))),a,o,r)).toVar();return zt(u,d)}).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"}]}),_g=Hr([me(([i,e,t,n,r,o,a])=>{const c=le(a).toVar(),u=q(o).toVar(),d=le(r).toVar(),p=le(n).toVar(),m=le(t).toVar(),y=le(e).toVar(),x=lt(i).toVar(),v=he(fb(lt(y.add(p),m.add(d)))).toVar(),w=lt(v.x,v.y).toVar();w.subAssign(.5),w.mulAssign(u),w.addAssign(.5);const M=lt(lt(q(y),q(m)).add(w)).toVar(),S=lt(M.sub(x)).toVar();return jt(c.equal(le(2)),()=>qi(S.x).add(qi(S.y))),jt(c.equal(le(3)),()=>vs(qi(S.x),qi(S.y))),qa(S,S)}).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"}]}),me(([i,e,t,n,r,o,a,c,u])=>{const d=le(u).toVar(),p=q(c).toVar(),m=le(a).toVar(),y=le(o).toVar(),x=le(r).toVar(),v=le(n).toVar(),w=le(t).toVar(),M=le(e).toVar(),S=he(i).toVar(),C=he(fb(he(M.add(x),w.add(y),v.add(m)))).toVar();C.subAssign(.5),C.mulAssign(p),C.addAssign(.5);const N=he(he(q(M),q(w),q(v)).add(C)).toVar(),I=he(N.sub(S)).toVar();return jt(d.equal(le(2)),()=>qi(I.x).add(qi(I.y)).add(qi(I.z))),jt(d.equal(le(3)),()=>vs(qi(I.x),qi(I.y),qi(I.z))),qa(I,I)}).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"}]})]),H8=me(([i,e,t])=>{const n=le(t).toVar(),r=q(e).toVar(),o=lt(i).toVar(),a=le().toVar(),c=le().toVar(),u=lt(ds(o.x,a),ds(o.y,c)).toVar(),d=q(1e6).toVar();return Ai({start:-1,end:le(1),name:"x",condition:"<="},({x:p})=>{Ai({start:-1,end:le(1),name:"y",condition:"<="},({y:m})=>{const y=q(_g(u,p,m,a,c,r,n)).toVar();d.assign(ko(d,y))})}),jt(n.equal(le(0)),()=>{d.assign(Qr(d))}),d}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),$8=me(([i,e,t])=>{const n=le(t).toVar(),r=q(e).toVar(),o=lt(i).toVar(),a=le().toVar(),c=le().toVar(),u=lt(ds(o.x,a),ds(o.y,c)).toVar(),d=lt(1e6,1e6).toVar();return Ai({start:-1,end:le(1),name:"x",condition:"<="},({x:p})=>{Ai({start:-1,end:le(1),name:"y",condition:"<="},({y:m})=>{const y=q(_g(u,p,m,a,c,r,n)).toVar();jt(y.lessThan(d.x),()=>{d.y.assign(d.x),d.x.assign(y)}).ElseIf(y.lessThan(d.y),()=>{d.y.assign(y)})})}),jt(n.equal(le(0)),()=>{d.assign(Qr(d))}),d}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),q8=me(([i,e,t])=>{const n=le(t).toVar(),r=q(e).toVar(),o=lt(i).toVar(),a=le().toVar(),c=le().toVar(),u=lt(ds(o.x,a),ds(o.y,c)).toVar(),d=he(1e6,1e6,1e6).toVar();return Ai({start:-1,end:le(1),name:"x",condition:"<="},({x:p})=>{Ai({start:-1,end:le(1),name:"y",condition:"<="},({y:m})=>{const y=q(_g(u,p,m,a,c,r,n)).toVar();jt(y.lessThan(d.x),()=>{d.z.assign(d.y),d.y.assign(d.x),d.x.assign(y)}).ElseIf(y.lessThan(d.y),()=>{d.z.assign(d.y),d.y.assign(y)}).ElseIf(y.lessThan(d.z),()=>{d.z.assign(y)})})}),jt(n.equal(le(0)),()=>{d.assign(Qr(d))}),d}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),X8=Hr([H8,me(([i,e,t])=>{const n=le(t).toVar(),r=q(e).toVar(),o=he(i).toVar(),a=le().toVar(),c=le().toVar(),u=le().toVar(),d=he(ds(o.x,a),ds(o.y,c),ds(o.z,u)).toVar(),p=q(1e6).toVar();return Ai({start:-1,end:le(1),name:"x",condition:"<="},({x:m})=>{Ai({start:-1,end:le(1),name:"y",condition:"<="},({y})=>{Ai({start:-1,end:le(1),name:"z",condition:"<="},({z:x})=>{const v=q(_g(d,m,y,x,a,c,u,r,n)).toVar();p.assign(ko(p,v))})})}),jt(n.equal(le(0)),()=>{p.assign(Qr(p))}),p}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),j8=Hr([$8,me(([i,e,t])=>{const n=le(t).toVar(),r=q(e).toVar(),o=he(i).toVar(),a=le().toVar(),c=le().toVar(),u=le().toVar(),d=he(ds(o.x,a),ds(o.y,c),ds(o.z,u)).toVar(),p=lt(1e6,1e6).toVar();return Ai({start:-1,end:le(1),name:"x",condition:"<="},({x:m})=>{Ai({start:-1,end:le(1),name:"y",condition:"<="},({y})=>{Ai({start:-1,end:le(1),name:"z",condition:"<="},({z:x})=>{const v=q(_g(d,m,y,x,a,c,u,r,n)).toVar();jt(v.lessThan(p.x),()=>{p.y.assign(p.x),p.x.assign(v)}).ElseIf(v.lessThan(p.y),()=>{p.y.assign(v)})})})}),jt(n.equal(le(0)),()=>{p.assign(Qr(p))}),p}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),Qw=Hr([q8,me(([i,e,t])=>{const n=le(t).toVar(),r=q(e).toVar(),o=he(i).toVar(),a=le().toVar(),c=le().toVar(),u=le().toVar(),d=he(ds(o.x,a),ds(o.y,c),ds(o.z,u)).toVar(),p=he(1e6,1e6,1e6).toVar();return Ai({start:-1,end:le(1),name:"x",condition:"<="},({x:m})=>{Ai({start:-1,end:le(1),name:"y",condition:"<="},({y})=>{Ai({start:-1,end:le(1),name:"z",condition:"<="},({z:x})=>{const v=q(_g(d,m,y,x,a,c,u,r,n)).toVar();jt(v.lessThan(p.x),()=>{p.z.assign(p.y),p.y.assign(p.x),p.x.assign(v)}).ElseIf(v.lessThan(p.y),()=>{p.z.assign(p.y),p.y.assign(v)}).ElseIf(v.lessThan(p.z),()=>{p.z.assign(v)})})})}),jt(n.equal(le(0)),()=>{p.assign(Qr(p))}),p}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),Y8=me(([i,e,t,n,r,o,a,c,u,d,p])=>{const m=le(i).toVar(),y=lt(e).toVar(),x=lt(t).toVar(),v=lt(n).toVar(),w=q(r).toVar(),M=q(o).toVar(),S=q(a).toVar(),C=$a(c).toVar(),N=le(u).toVar(),I=q(d).toVar(),U=q(p).toVar(),F=y.mul(x).add(v),k=q(0).toVar();return jt(m.equal(le(0)),()=>{k.assign(Hy(F))}),jt(m.equal(le(1)),()=>{k.assign(fb(F))}),jt(m.equal(le(2)),()=>{k.assign(Qw(F,w,le(0)))}),jt(m.equal(le(3)),()=>{k.assign(mb(he(F,0),N,I,U))}),k.assign(k.mul(S.sub(M)).add(M)),jt(C,()=>{k.assign(Rl(k,M,S))}),k}).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"}]}),Z8=me(([i,e,t,n,r,o,a,c,u,d,p])=>{const m=le(i).toVar(),y=he(e).toVar(),x=he(t).toVar(),v=he(n).toVar(),w=q(r).toVar(),M=q(o).toVar(),S=q(a).toVar(),C=$a(c).toVar(),N=le(u).toVar(),I=q(d).toVar(),U=q(p).toVar(),F=y.mul(x).add(v),k=q(0).toVar();return jt(m.equal(le(0)),()=>{k.assign(Hy(F))}),jt(m.equal(le(1)),()=>{k.assign(fb(F))}),jt(m.equal(le(2)),()=>{k.assign(Qw(F,w,le(0)))}),jt(m.equal(le(3)),()=>{k.assign(mb(F,N,I,U))}),k.assign(k.mul(S.sub(M)).add(M)),jt(C,()=>{k.assign(Rl(k,M,S))}),k}).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"}]}),K8=me(([i])=>{const e=i.y,t=i.z,n=he().toVar();return jt(e.lessThan(1e-4),()=>{n.assign(he(t,t,t))}).Else(()=>{let r=i.x;r=r.sub(Rc(r)).mul(6).toVar();const o=le(fT(r)),a=r.sub(q(o)),c=t.mul(e.oneMinus()),u=t.mul(e.mul(a).oneMinus()),d=t.mul(e.mul(a.oneMinus()).oneMinus());jt(o.equal(le(0)),()=>{n.assign(he(t,d,c))}).ElseIf(o.equal(le(1)),()=>{n.assign(he(u,t,c))}).ElseIf(o.equal(le(2)),()=>{n.assign(he(c,t,d))}).ElseIf(o.equal(le(3)),()=>{n.assign(he(c,u,t))}).ElseIf(o.equal(le(4)),()=>{n.assign(he(d,c,t))}).Else(()=>{n.assign(he(t,c,u))})}),n}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),J8=me(([i])=>{const e=he(i).toVar(),t=q(e.x).toVar(),n=q(e.y).toVar(),r=q(e.z).toVar(),o=q(ko(t,ko(n,r))).toVar(),a=q(vs(t,vs(n,r))).toVar(),c=q(a.sub(o)).toVar(),u=q().toVar(),d=q().toVar(),p=q().toVar();return p.assign(a),jt(a.greaterThan(0),()=>{d.assign(c.div(a))}).Else(()=>{d.assign(0)}),jt(d.lessThanEqual(0),()=>{u.assign(0)}).Else(()=>{jt(t.greaterThanEqual(a),()=>{u.assign(n.sub(r).div(c))}).ElseIf(n.greaterThanEqual(a),()=>{u.assign(Js(2,r.sub(t).div(c)))}).Else(()=>{u.assign(Js(4,t.sub(n).div(c)))}),u.mulAssign(1/6),jt(u.lessThan(0),()=>{u.addAssign(1)})}),he(u,d,p)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),Q8=me(([i])=>{const e=he(i).toVar(),t=jM(sT(e,he(.04045))).toVar(),n=he(e.div(12.92)).toVar(),r=he(Xa(vs(e.add(he(.055)),he(0)).div(1.055),he(2.4))).toVar();return oi(n,r,t)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),h2=(i,e)=>{i=q(i),e=q(e);const t=lt(e.dFdx(),e.dFdy()).length().mul(.7071067811865476);return ga(i.sub(t),i.add(t),e)},d2=(i,e,t,n)=>oi(i,e,t[n].clamp()),eH=(i,e,t=Pi())=>d2(i,e,t,"x"),tH=(i,e,t=Pi())=>d2(i,e,t,"y"),nH=(i,e,t,n,r=Pi())=>{const o=r.x.clamp(),a=r.y.clamp(),c=oi(i,e,o),u=oi(t,n,o);return oi(c,u,a)},f2=(i,e,t,n,r)=>oi(i,e,h2(t,n[r])),iH=(i,e,t,n=Pi())=>f2(i,e,t,n,"x"),sH=(i,e,t,n=Pi())=>f2(i,e,t,n,"y"),rH=(i=1,e=0,t=Pi())=>t.mul(i).add(e),oH=(i,e=1)=>(i=q(i),i.abs().pow(e).mul(i.sign())),aH=(i,e=1,t=.5)=>q(i).sub(t).mul(e).add(t),lH=(i=Pi(),e=1,t=0)=>Jw(i.convert("vec2|vec3")).mul(e).add(t),cH=(i=Pi(),e=1,t=0)=>Hy(i.convert("vec2|vec3")).mul(e).add(t),uH=(i=Pi(),e=1,t=0)=>(i=i.convert("vec2|vec3"),zt(Hy(i),Jw(i.add(lt(19,73)))).mul(e).add(t)),hH=(i,e=Pi(),t=lt(1,1),n=lt(0,0),r=1,o=0,a=1,c=!1,u=1,d=2,p=.5)=>Y8(i,e.convert("vec2|vec3"),t,n,r,o,a,c,u,d,p),dH=(i,e=Pi(),t=lt(1,1),n=lt(0,0),r=1,o=0,a=1,c=!1,u=1,d=2,p=.5)=>Z8(i,e.convert("vec2|vec3"),t,n,r,o,a,c,u,d,p),fH=(i=Pi(),e=1)=>X8(i.convert("vec2|vec3"),e,le(1)),pH=(i=Pi(),e=1)=>j8(i.convert("vec2|vec3"),e,le(1)),mH=(i=Pi(),e=1)=>Qw(i.convert("vec2|vec3"),e,le(1)),gH=(i=Pi())=>V8(i.convert("vec2|vec3")),yH=(i=Pi(),e=3,t=2,n=.5,r=1)=>pb(i,le(e),t,n).mul(r),_H=(i=Pi(),e=3,t=2,n=.5,r=1)=>G8(i,le(e),t,n).mul(r),xH=(i=Pi(),e=3,t=2,n=.5,r=1)=>mb(i,le(e),t,n).mul(r),vH=(i=Pi(),e=3,t=2,n=.5,r=1)=>W8(i,le(e),t,n).mul(r),bH=(i,e=q(0))=>Js(i,e),SH=(i,e=q(0))=>ui(i,e),MH=(i,e=q(1))=>Bn(i,e),TH=(i,e=q(1))=>ma(i,e),wH=(i,e=q(1))=>yy(i,e),AH=(i,e=q(1))=>Xa(i,e),EH=(i=q(0),e=q(1))=>_v(i,e),CH=()=>fg,RH=()=>gI,NH=(i,e=q(1))=>ui(e,i),PH=(i,e,t,n)=>i.greaterThan(e).mix(t,n),IH=(i,e,t,n)=>i.greaterThanEqual(e).mix(t,n),LH=(i,e,t,n)=>i.equal(e).mix(t,n),DH=(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},n=e.replace(/^out/,"").toLowerCase();if(t[n]!==void 0)return i.element(t[n])}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},FH=(i,e=lt(.5,.5),t=lt(1,1),n=q(0),r=lt(0,0))=>{let o=i;if(e&&(o=o.sub(e)),t&&(o=o.mul(t)),n){const a=n.mul(Math.PI/180),c=a.cos(),u=a.sin();o=lt(o.x.mul(c).sub(o.y.mul(u)),o.x.mul(u).add(o.y.mul(c)))}return e&&(o=o.add(e)),r&&(o=o.add(r)),o},BH=(i,e)=>{i=lt(i),e=q(e);const t=e.mul(Math.PI/180);return Ry(i,t)},OH=(i,e,t)=>{i=he(i),e=q(e),t=he(t);const n=e.mul(Math.PI/180),r=t.normalize(),o=n.cos(),a=n.sin(),c=q(1).sub(o);return i.mul(o).add(r.cross(i).mul(a)).add(r.mul(r.dot(i)).mul(c))},UH=(i,e)=>(i=he(i),e=q(e),qT(i,e)),kH=me(([i,e,t])=>{const n=go(i).toVar(),r=ui(q(.5).mul(e.sub(t)),_a).div(n).toVar(),o=ui(q(-.5).mul(e.sub(t)),_a).div(n).toVar(),a=he().toVar();a.x=n.x.greaterThan(q(0)).select(r.x,o.x),a.y=n.y.greaterThan(q(0)).select(r.y,o.y),a.z=n.z.greaterThan(q(0)).select(r.z,o.z);const c=ko(a.x,a.y,a.z).toVar();return _a.add(n.mul(c)).toVar().sub(t)}),p2=me(([i,e])=>{const t=i.x,n=i.y,r=i.z;let o=e.element(0).mul(.886227);return o=o.add(e.element(1).mul(2*.511664).mul(n)),o=o.add(e.element(2).mul(2*.511664).mul(r)),o=o.add(e.element(3).mul(2*.511664).mul(t)),o=o.add(e.element(4).mul(2*.429043).mul(t).mul(n)),o=o.add(e.element(5).mul(2*.429043).mul(n).mul(r)),o=o.add(e.element(6).mul(r.mul(r).mul(.743125).sub(.247708))),o=o.add(e.element(7).mul(2*.429043).mul(t).mul(r)),o=o.add(e.element(8).mul(.429043).mul(Bn(t,t).sub(Bn(n,n)))),o});var RK=Object.freeze({__proto__:null,BRDF_GGX:cw,BRDF_Lambert:up,BasicPointShadowFilter:n2,BasicShadowFilter:$I,Break:QN,Const:_R,Continue:cG,DFGLUT:wy,D_GGX:bP,Discard:BR,EPSILON:rT,F_Schlick:ug,Fn:me,HALF_PI:Oz,INFINITY:Dz,If:jt,Loop:Ai,NodeAccess:zr,NodeShaderStage:ay,NodeType:iz,NodeUpdateType:Xn,OnBeforeMaterialUpdate:LW,OnBeforeObjectUpdate:IW,OnMaterialUpdate:PW,OnObjectUpdate:NW,PCFShadowFilter:qI,PCFSoftShadowFilter:XI,PI:mv,PI2:Fz,PointShadowFilter:i2,Return:Qz,Schlick_to_F0:uw,ScriptableNodeResources:ob,ShaderNode:Zm,Stack:rv,Switch:wz,TBNViewMatrix:cp,TWO_PI:Bz,VSMShadowFilter:jI,V_GGX_SmithCorrelated:vP,Var:yR,VarIntent:xR,abs:qi,acesFilmicToneMapping:NI,acos:lT,add:Js,addMethodChaining:We,addNodeElement:iV,agxToneMapping:PI,all:GC,alphaT:hv,and:EC,anisotropy:Vd,anisotropyB:ip,anisotropyT:fy,any:WC,append:Rz,array:vC,arrayBuffer:Ez,asin:XC,assign:bC,atan:_v,atan2:hR,atomicAdd:V6,atomicAnd:$6,atomicFunc:Uc,atomicLoad:k6,atomicMax:W6,atomicMin:H6,atomicOr:q6,atomicStore:z6,atomicSub:G6,atomicXor:X6,attenuationColor:eT,attenuationDistance:QM,attribute:_o,attributeArray:BW,backgroundBlurriness:xI,backgroundIntensity:Bw,backgroundRotation:vI,batch:YN,bentNormalView:mN,billboarding:fW,bitAnd:PC,bitNot:IC,bitOr:LC,bitXor:DC,bitangentGeometry:GV,bitangentLocal:WV,bitangentView:fN,bitangentWorld:HV,bitcast:pI,blendBurn:aP,blendColor:AG,blendDodge:lP,blendOverlay:uP,blendScreen:cP,blur:WP,bool:$a,buffer:_y,bufferAttribute:TT,builtin:oh,builtinAOContext:mR,builtinShadowContext:pR,bumpMap:qT,burn:CG,bvec2:dC,bvec3:jM,bvec4:fC,bypass:IR,cache:PR,call:SC,cameraFar:ch,cameraIndex:Hd,cameraNear:lh,cameraNormalMatrix:_V,cameraPosition:by,cameraProjectionMatrix:xo,cameraProjectionMatrixInverse:gV,cameraViewMatrix:ya,cameraViewport:xV,cameraWorldMatrix:yV,cbrt:oR,cdl:e6,ceil:yv,checker:O8,cineonToneMapping:RI,clamp:Rl,clearcoat:av,clearcoatNormalView:lp,clearcoatRoughness:dy,code:sb,color:hC,colorSpaceToWorking:Sv,colorToDirection:qV,compute:NR,computeKernel:AT,computeSkinning:aG,context:ih,convert:mC,convertColorSpace:Hz,convertToTexture:wW,cos:Cl,countLeadingZeros:W5,countOneBits:H5,countTrailingZeros:G5,cross:nh,cubeTexture:vo,cubeTextureBase:zT,dFdx:hT,dFdy:dT,dashSize:rp,debug:OR,decrement:zC,decrementBefore:UC,defaultBuildStages:OM,defaultShaderStages:tC,defined:cy,degrees:$C,deltaTime:rW,densityFog:S6,densityFogFactor:kw,depth:rw,depthPass:r6,determinant:JC,difference:iR,diffuseColor:Ni,diffuseContribution:np,directPointLight:r2,directionToColor:gN,directionToFaceDirection:ig,dispersion:tT,disposeShadowMaterial:ZI,distance:nR,div:ma,dodge:RG,dot:qa,drawIndex:qN,dynamicBufferAttribute:Yz,element:pC,emissive:KM,equal:iT,equals:eR,equirectUV:ow,exp:oT,exp2:Qm,expression:sh,faceDirection:BT,faceForward:xT,faceforward:Uz,float:q,floatBitsToInt:k5,floatBitsToUint:mI,floor:Rc,fog:Uy,fract:El,frameGroup:_C,frameId:gI,frontFacing:XR,fwidth:pT,gain:q5,gapSize:py,getConstNodeType:uC,getCurrentStack:$M,getDirection:VP,getDistanceAttenuation:Kw,getGeometryRoughness:xP,getNormalFromDepth:EW,getParallaxCorrectNormal:kH,getRoughness:lw,getScreenPosition:AW,getShIrradianceAt:p2,getShadowMaterial:YI,getShadowRenderObjectFunction:JI,getTextureIndex:dI,getViewPosition:gg,ggxConvolution:HP,globalId:C6,glsl:p6,glslFn:m6,grayscale:ZW,greaterThan:sT,greaterThanEqual:AC,hash:$5,highpModelNormalViewMatrix:DT,highpModelViewMatrix:LT,hue:QW,increment:kC,incrementBefore:OC,inspector:kR,instance:sG,instanceIndex:Dc,instancedArray:OW,instancedBufferAttribute:Tv,instancedDynamicBufferAttribute:wT,instancedMesh:jN,int:le,intBitsToFloat:z5,interleavedGradientNoise:Dw,inverse:QC,inverseSqrt:aT,inversesqrt:kz,invocationLocalIndex:iG,invocationSubgroupIndex:nG,ior:my,iridescence:lv,iridescenceIOR:cv,iridescenceThickness:uv,isolate:tg,ivec2:ar,ivec3:XM,ivec4:YM,js:d6,label:gR,length:Nc,lengthSq:yT,lessThan:TC,lessThanEqual:wC,lightPosition:Vw,lightProjectionUV:OI,lightShadowMatrix:cb,lightTargetDirection:Ww,lightTargetPosition:UI,lightViewPosition:Gw,lightingContext:nP,lights:b8,linearDepth:cg,linearToneMapping:EI,localId:R6,log:gv,log2:Cc,logarithmicDepthToViewZ:_G,luminance:Ow,mat2:ov,mat3:Vr,mat4:kd,matcapUV:eI,materialAO:WN,materialAlphaTest:_N,materialAnisotropy:IN,materialAnisotropyVector:rg,materialAttenuationColor:zN,materialAttenuationDistance:kN,materialClearcoat:AN,materialClearcoatNormal:CN,materialClearcoatRoughness:EN,materialColor:Lv,materialDispersion:GN,materialEmissive:vN,materialEnvIntensity:Cv,materialEnvRotation:kT,materialIOR:UN,materialIridescence:LN,materialIridescenceIOR:DN,materialIridescenceThickness:FN,materialLightMap:JT,materialLineDashOffset:KT,materialLineDashSize:YT,materialLineGapSize:ZT,materialLineScale:jT,materialLineWidth:Bv,materialMetalness:TN,materialNormal:wN,materialOpacity:Dv,materialPointSize:VN,materialReference:uh,materialReflectivity:Fv,materialRefractionRatio:JR,materialRotation:RN,materialRoughness:MN,materialSheen:NN,materialSheenRoughness:PN,materialShininess:xN,materialSpecular:bN,materialSpecularColor:SN,materialSpecularIntensity:XT,materialSpecularStrength:My,materialThickness:ON,materialTransmission:BN,max:vs,maxMipLevel:CT,mediumpModelViewMatrix:qR,metalness:th,min:ko,mix:oi,mixElement:lR,mod:yy,modInt:VC,modelDirection:wV,modelNormalMatrix:$R,modelPosition:AV,modelRadius:HR,modelScale:EV,modelViewMatrix:Lc,modelViewPosition:CV,modelViewProjection:HN,modelWorldMatrix:Ya,modelWorldMatrixInverse:RV,morphReference:tP,mrt:fI,mul:Bn,mx_aastep:h2,mx_add:bH,mx_atan2:EH,mx_cell_noise_float:gH,mx_contrast:aH,mx_divide:TH,mx_fractal_noise_float:yH,mx_fractal_noise_vec2:_H,mx_fractal_noise_vec3:xH,mx_fractal_noise_vec4:vH,mx_frame:RH,mx_heighttonormal:UH,mx_hsvtorgb:K8,mx_ifequal:LH,mx_ifgreater:PH,mx_ifgreatereq:IH,mx_invert:NH,mx_modulo:wH,mx_multiply:MH,mx_noise_float:lH,mx_noise_vec3:cH,mx_noise_vec4:uH,mx_place2d:FH,mx_power:AH,mx_ramp4:nH,mx_ramplr:eH,mx_ramptb:tH,mx_rgbtohsv:J8,mx_rotate2d:BH,mx_rotate3d:OH,mx_safepower:oH,mx_separate:DH,mx_splitlr:iH,mx_splittb:sH,mx_srgb_texture_to_lin_rec709:Q8,mx_subtract:SH,mx_timer:CH,mx_transform_uv:rH,mx_unifiednoise2d:hH,mx_unifiednoise3d:dH,mx_worley_noise_float:fH,mx_worley_noise_vec2:pH,mx_worley_noise_vec3:mH,negate:uT,neutralToneMapping:II,nodeArray:ep,nodeImmutable:Ct,nodeObject:Nt,nodeObjectIntent:uy,nodeObjects:sv,nodeProxy:Fn,nodeProxyIntent:pt,normalFlat:jR,normalGeometry:Ev,normalLocal:zo,normalMap:$T,normalView:mi,normalViewGeometry:sg,normalWorld:$d,normalWorldGeometry:YR,normalize:go,not:RC,notEqual:MC,numWorkgroups:A6,objectDirection:vV,objectGroup:nT,objectPosition:WR,objectRadius:TV,objectScale:SV,objectViewPosition:MV,objectWorldMatrix:bV,oneMinus:jC,or:CC,orthographicDepthToViewZ:yG,oscSawtooth:cW,oscSine:oW,oscSquare:aW,oscTriangle:lW,output:Jm,outputStruct:O5,overlay:PG,overloadingFn:Hr,packHalf2x16:K5,packSnorm2x16:Y5,packUnorm2x16:Z5,parabola:Cw,parallaxDirection:pN,parallaxUV:$V,parameter:P5,pass:i6,passTexture:s6,pcurve:X5,perspectiveDepthToViewZ:iw,pmremTexture:ww,pointShadow:s2,pointUV:kW,pointWidth:Nz,positionGeometry:Wr,positionLocal:bs,positionPrevious:Av,positionView:Us,positionViewDirection:Bi,positionWorld:_a,positionWorldDirection:FT,posterize:n6,pow:Xa,pow2:mT,pow3:sR,pow4:gT,premultiplyAlpha:hP,property:Al,quadBroadcast:_8,quadSwapDiagonal:d8,quadSwapX:u8,quadSwapY:h8,radians:HC,rand:aR,range:T6,rangeFog:b6,rangeFogFactor:Uw,reciprocal:ZC,reference:Oi,referenceBuffer:VT,reflect:tR,reflectVector:tN,reflectView:QR,reflector:vW,refract:_T,refractVector:nN,refractView:eN,reinhardToneMapping:CI,remap:DR,remapClamp:FR,renderGroup:an,renderOutput:ET,rendererReference:wR,replaceDefaultUV:uW,rotate:Ry,rotateUV:hW,roughness:Ec,round:YC,rtt:_I,sRGBTransferEOTF:bR,sRGBTransferOETF:SR,sample:RW,sampler:cV,samplerComparison:uV,saturate:vv,saturation:KW,screen:NG,screenCoordinate:ap,screenDPR:PT,screenSize:op,screenUV:ah,scriptable:v6,scriptableValue:rb,select:Gr,setCurrentStack:hy,setName:vT,shaderStages:UM,shadow:e2,shadowPositionWorld:qw,shapeCircle:U8,sharedUniformGroup:pv,sheen:pa,sheenRoughness:zd,shiftLeft:FC,shiftRight:BC,shininess:dv,sign:cT,sin:yo,sinc:j5,skinning:JN,smoothstep:ga,smoothstepElement:cR,specularColor:Gd,specularColorBlended:sp,specularF90:Km,spherizeUV:dW,split:Cz,spritesheetUV:gW,sqrt:Qr,stack:jv,step:xv,stepElement:uR,storage:hh,storageBarrier:L6,storageObject:eG,storageTexture:bI,string:Az,struct:B5,sub:ui,subBuild:eg,subgroupAdd:Z6,subgroupAll:a8,subgroupAnd:n8,subgroupAny:l8,subgroupBallot:Y6,subgroupBroadcast:f8,subgroupBroadcastFirst:c8,subgroupElect:j6,subgroupExclusiveAdd:J6,subgroupExclusiveMul:t8,subgroupInclusiveAdd:K6,subgroupInclusiveMul:e8,subgroupIndex:tG,subgroupMax:o8,subgroupMin:r8,subgroupMul:Q6,subgroupOr:i8,subgroupShuffle:p8,subgroupShuffleDown:y8,subgroupShuffleUp:g8,subgroupShuffleXor:m8,subgroupSize:N6,subgroupXor:s8,tan:qC,tangentGeometry:Nv,tangentLocal:Sy,tangentView:Pv,tangentWorld:dN,texture:_i,texture3D:nb,texture3DLevel:$W,texture3DLoad:HW,textureBarrier:D6,textureBicubic:l4,textureBicubicLevel:fw,textureCubeUV:GP,textureLevel:lV,textureLoad:Ns,textureSize:rh,textureStore:VW,thickness:JM,time:fg,toneMapping:AR,toneMappingExposure:ER,toonOutlinePass:a6,transformDirection:rR,transformNormal:ZR,transformNormalToView:OT,transformedClearcoatNormalView:LV,transformedNormalView:PV,transformedNormalWorld:IV,transmission:fv,transpose:KC,triNoise3D:nW,triplanarTexture:yW,triplanarTextures:yI,trunc:fT,uint:it,uintBitsToFloat:V5,uniform:rn,uniformArray:eo,uniformCubeTexture:FV,uniformFlow:fR,uniformGroup:yC,uniformTexture:aV,unpackHalf2x16:eW,unpackNormal:HT,unpackSnorm2x16:J5,unpackUnorm2x16:Q5,unpremultiplyAlpha:EG,userData:XW,uv:Pi,uvec2:qM,uvec3:tp,uvec4:ZM,varying:Pc,varyingProperty:fa,vec2:lt,vec3:he,vec4:zt,vectorComponents:Jf,velocity:YW,vertexColor:oP,vertexIndex:$N,vertexStage:vR,vibrance:JW,viewZToLogarithmicDepth:sw,viewZToOrthographicDepth:lg,viewZToPerspectiveDepth:nw,viewport:ng,viewportCoordinate:VR,viewportDepthTexture:tw,viewportLinearDepth:xG,viewportMipTexture:ew,viewportResolution:mV,viewportSafeUV:pW,viewportSharedTexture:dP,viewportSize:IT,viewportTexture:mG,viewportUV:pV,vogelDiskSample:Pl,wgsl:f6,wgslFn:g6,workgroupArray:O6,workgroupBarrier:I6,workgroupId:E6,workingToColorSpace:MR,xor:NC});const Il=new Ew;class zH extends jd{constructor(e,t){super(),this.renderer=e,this.nodes=t}update(e,t,n){const r=this.renderer,o=this.nodes.getBackgroundNode(e)||e.background;let a=!1;if(o===null)r._clearColor.getRGB(Il),Il.a=r._clearColor.a;else if(o.isColor===!0)o.getRGB(Il),Il.a=1,a=!0;else if(o.isNode===!0){const u=this.get(e),d=o;Il.copy(r._clearColor);let p=u.backgroundMesh;if(p===void 0){let C=function(){o.removeEventListener("dispose",C),p.material.dispose(),p.geometry.dispose()};const y=zt(d).mul(Bw).context({getUV:()=>vI.mul(YR),getTextureLevel:()=>xI}),x=xo.element(3).element(3).equal(1),v=ma(1,xo.element(1).element(1)).mul(3),w=x.select(bs.mul(v),bs);let M=xo.mul(Lc.mul(zt(w,0)));M=M.setZ(M.w);const S=new Ss;S.name="Background.material",S.side=we,S.depthTest=!1,S.depthWrite=!1,S.allowOverride=!1,S.fog=!1,S.lights=!1,S.vertexNode=M,S.colorNode=y,u.backgroundMeshNode=y,u.backgroundMesh=p=new Ji(new ku(1,32,32),S),p.frustumCulled=!1,p.name="Background.mesh",o.addEventListener("dispose",C)}const m=d.getCacheKey();u.backgroundCacheKey!==m&&(u.backgroundMeshNode.node=zt(d).mul(Bw),u.backgroundMeshNode.needsUpdate=!0,p.material.needsUpdate=!0,u.backgroundCacheKey=m),t.unshift(p,p.geometry,p.material,0,0,null,null)}else Be("Renderer: Unsupported background configuration.",o);const c=r.xr.getEnvironmentBlendMode();if(c==="additive"?Il.set(0,0,0,1):c==="alpha-blend"&&Il.set(0,0,0,0),r.autoClear===!0||a===!0){const u=n.clearColorValue;u.r=Il.r,u.g=Il.g,u.b=Il.b,u.a=Il.a,(r.backend.isWebGLBackend===!0||r.alpha===!0)&&(u.r*=u.a,u.g*=u.a,u.b*=u.a),n.depthClearValue=r._clearDepth,n.stencilClearValue=r._clearStencil,n.clearColor=r.autoClearColor===!0,n.clearDepth=r.autoClearDepth===!0,n.clearStencil=r.autoClearStencil===!0}else n.clearColor=!1,n.clearDepth=!1,n.clearStencil=!1}}let VH=0;class e1{constructor(e="",t=[],n=0,r=[]){this.name=e,this.bindings=t,this.index=n,this.bindingsReference=r,this.id=VH++}}class GH{constructor(e,t,n,r,o,a,c,u,d,p=[]){this.vertexShader=e,this.fragmentShader=t,this.computeShader=n,this.transforms=p,this.nodeAttributes=r,this.bindings=o,this.updateNodes=a,this.updateBeforeNodes=c,this.updateAfterNodes=u,this.observer=d,this.usedTimes=0}createBindings(){const e=[];for(const t of this.bindings)if(t.bindings[0].groupNode.shared!==!0){const r=new e1(t.name,[],t.index,t.bindingsReference);e.push(r);for(const o of t.bindings)r.bindings.push(o.clone())}else e.push(t);return e}}class m2{constructor(e,t,n=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=n}}class WH{constructor(e,t,n){this.isNodeUniform=!0,this.name=e,this.type=t,this.node=n}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 g2{constructor(e,t,n=!1,r=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=n,this.count=r}}class HH extends g2{constructor(e,t,n=null,r=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=n,this.interpolationSampling=r}}class $H{constructor(e,t,n=""){this.name=e,this.type=t,this.code=n,Object.defineProperty(this,"isNodeCode",{value:!0})}}let qH=0;class t1{constructor(e=null){this.id=qH++,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 XH{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class Zd{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 jH extends Zd{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class YH extends Zd{constructor(e,t=new ze){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class ZH extends Zd{constructor(e,t=new H){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class KH extends Zd{constructor(e,t=new gn){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class JH extends Zd{constructor(e,t=new It){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class QH extends Zd{constructor(e,t=new vl){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class e9 extends Zd{constructor(e,t=new Nn){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class t9 extends Zd{constructor(e,t=new Qt){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class n9 extends jH{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class i9 extends YH{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class s9 extends ZH{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class r9 extends KH{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class o9 extends JH{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class a9 extends QH{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class l9 extends e9{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class c9 extends t9{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}let u9=0;const h9=new WeakMap,y2=new WeakMap,d9=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),gb=i=>/e/g.test(i)?String(i).replace(/\+/g,""):(i=Number(i),i+(i%1?"":".0"));class _2{constructor(e,t,n){this.object=e,this.material=e&&e.material||null,this.geometry=e&&e.geometry||null,this.renderer=t,this.parser=n,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=jv(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new t1,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:u9++})}isOpaque(){const e=this.material;return e.transparent===!1&&e.blending===Ue&&e.alphaToCoverage===!1}getBindGroupsCache(){let e=y2.get(this.renderer);return e===void 0&&(e=new Nl,y2.set(this.renderer,e)),e}createRenderTarget(e,t,n){return new Ws(e,t,n)}createCubeRenderTarget(e,t){return new fP(e,t)}includes(e){return this.nodes.includes(e)}getOutputStructName(){}_getBindGroup(e,t){const n=this.getBindGroupsCache(),r=[];let o=!0;for(const c of t)r.push(c),o=o&&c.groupNode.shared!==!0;let a;return o?(a=n.get(r),a===void 0&&(a=new e1(e,r,this.bindingsIndexes[e].group,r),n.set(r,a))):a=new e1(e,r,this.bindingsIndexes[e].group,r),a}getBindGroupArray(e,t){const n=this.bindings[t];let r=n[e];return r===void 0&&(this.bindingsIndexes[e]===void 0&&(this.bindingsIndexes[e]={binding:0,group:Object.keys(this.bindingsIndexes).length}),n[e]=r=[]),r}getBindings(){let e=this.bindGroups;if(e===null){const t={},n=this.bindings;for(const r of UM)for(const o in n[r]){const a=n[r][o];(t[o]||(t[o]=[])).push(...a)}e=[];for(const r in t){const o=t[r],a=this._getBindGroup(r,o);e.push(a)}this.bindGroups=e}return e}sortBindingGroups(){const e=this.getBindings();e.sort((t,n)=>t.bindings[0].groupNode.order-n.bindings[0].groupNode.order);for(let t=0;t<e.length;t++){const n=e[t];this.bindingsIndexes[n.name].group=t,n.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(),n=e.getUpdateAfterType();t!==Xn.NONE&&this.updateBeforeNodes.push(e),n!==Xn.NONE&&this.updateAfterNodes.push(e)}}get currentNode(){return this.chaining[this.chaining.length-1]}isFilteredTexture(e){return e.magFilter===Yn||e.magFilter===Zc||e.magFilter===Ra||e.magFilter===Vs||e.minFilter===Yn||e.minFilter===Zc||e.minFilter===Ra||e.minFilter===Vs}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(wi(wi({},this.context),e)),t}getSharedContext(){const e=wi({},this.context);return delete e.material,delete e.getUV,delete e.getOutput,delete e.getTextureLevel,delete e.getAO,delete e.getShadow,e}setCache(e){this.cache=e}getCache(){return this.cache}getCacheFromNode(e,t=!0){const n=this.getDataFromNode(e);return n.cache===void 0&&(n.cache=new t1(t?this.getCache():null)),n.cache}isAvailable(){return!1}getVertexIndex(){Ie("Abstract function.")}getInstanceIndex(){Ie("Abstract function.")}getDrawIndex(){Ie("Abstract function.")}getFrontFacing(){Ie("Abstract function.")}getFragCoord(){Ie("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(){Ie("Abstract function.")}generateTextureLod(){Ie("Abstract function.")}generateArrayDeclaration(e,t){return this.getType(e)+"[ "+t+" ]"}generateArray(e,t,n=null){let r=this.generateArrayDeclaration(e,t)+"( ";for(let o=0;o<t;o++){const a=n?n[o]:null;a!==null?r+=a.build(this,e):r+=this.generateConst(e),o<t-1&&(r+=", ")}return r+=" )",r}generateStruct(e,t,n=null){const r=[];for(const o of t){const{name:a,type:c}=o;n&&n[a]&&n[a].isNode?r.push(n[a].build(this,c)):r.push(this.generateConst(c))}return e+"( "+r.join(", ")+" )"}generateConst(e,t=null){if(t===null&&(e==="float"||e==="int"||e==="uint"?t=0:e==="bool"?t=!1:e==="color"?t=new It:e==="vec2"||e==="uvec2"||e==="ivec2"?t=new ze:e==="vec3"||e==="uvec3"||e==="ivec3"?t=new H:(e==="vec4"||e==="uvec4"||e==="ivec4")&&(t=new gn)),e==="float")return gb(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")}( ${gb(t.r)}, ${gb(t.g)}, ${gb(t.b)} )`;const n=this.getTypeLength(e),r=this.getComponentType(e),o=a=>this.generateConst(r,a);if(n===2)return`${this.getType(e)}( ${o(t.x)}, ${o(t.y)} )`;if(n===3)return`${this.getType(e)}( ${o(t.x)}, ${o(t.y)}, ${o(t.z)} )`;if(n===4&&e!=="mat2")return`${this.getType(e)}( ${o(t.x)}, ${o(t.y)}, ${o(t.z)}, ${o(t.w)} )`;if(n>=4&&t&&(t.isMatrix2||t.isMatrix3||t.isMatrix4))return`${this.getType(e)}( ${t.elements.map(o).join(", ")} )`;if(n>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 n=this.attributes;for(const o of n)if(o.name===e)return o;const r=new m2(e,t);return this.registerDeclaration(r),n.push(r),r}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===er)return"int";if(t===yi)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 n=IM(e);const r=t==="float"?"":t[0];return/mat2/.test(t)===!0&&(n=n.replace("vec","mat")),r+n}getTypeFromArray(e){return d9.get(e.constructor)}isInteger(e){return/int|uint|(i|u)vec/.test(e)}getTypeFromAttribute(e){let t=e;e.isInterleavedBufferAttribute&&(t=e.data);const n=t.array,r=e.itemSize,o=e.normalized;let a;return!(e instanceof $s)&&o!==!0&&(a=this.getTypeFromArray(n)),this.getTypeFromLength(r,a)}getTypeLength(e){const t=this.getVectorType(e),n=/vec([2-4])/.exec(t);return n!==null?Number(n[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=jv(this.stack);const e=$M();return this.stacks.push(e),hy(this.stack),this.stack}removeStack(){const e=this.stack;for(const t of e.nodes){const n=this.getDataFromNode(t);n.stack=e}return this.stack=e.parent,hy(this.stacks.pop()),e}getDataFromNode(e,t=this.shaderStage,n=null){n=n===null?e.isGlobal(this)?this.globalCache:this.cache:n;let r=n.getData(e);r===void 0&&(r={},n.setData(e,r)),r[t]===void 0&&(r[t]={});let o=r[t];const a=r.any?r.any.subBuilds:null,c=this.getClosestSubBuild(a);return c&&(o.subBuildsCache===void 0&&(o.subBuildsCache={}),o=o.subBuildsCache[c]||(o.subBuildsCache[c]={}),o.subBuilds=a),o}getNodeProperties(e,t="any"){const n=this.getDataFromNode(e,t);return n.properties||(n.properties={outputNode:null})}getBufferAttributeFromNode(e,t){const n=this.getDataFromNode(e,"vertex");let r=n.bufferAttribute;if(r===void 0){const o=this.uniforms.index++;r=new m2("nodeAttribute"+o,t,e),this.bufferAttributes.push(r),n.bufferAttribute=r}return r}getStructTypeNode(e,t=this.shaderStage){return this.types[t][e]||null}getStructTypeFromNode(e,t,n=null,r=this.shaderStage){const o=this.getDataFromNode(e,r,this.globalCache);let a=o.structType;if(a===void 0){const c=this.structs.index++;n===null&&(n="StructType"+c),a=new XH(n,t),this.structs[r].push(a),this.types[r][n]=e,o.structType=a}return a}getOutputStructTypeFromNode(e,t){const n=this.getStructTypeFromNode(e,t,"OutputType","fragment");return n.output=!0,n}getUniformFromNode(e,t,n=this.shaderStage,r=null){const o=this.getDataFromNode(e,n,this.globalCache);let a=o.uniform;if(a===void 0){const c=this.uniforms.index++;a=new WH(r||"nodeUniform"+c,t,e),this.uniforms[n].push(a),this.registerDeclaration(a),o.uniform=a}return a}getVarFromNode(e,t=null,n=e.getNodeType(this),r=this.shaderStage,o=!1){const a=this.getDataFromNode(e,r),c=this.getSubBuildProperty("variable",a.subBuilds);let u=a[c];if(u===void 0){const d=o?"_const":"_var",p=this.vars[r]||(this.vars[r]=[]),m=this.vars[d]||(this.vars[d]=0);t===null&&(t=(o?"nodeConst":"nodeVar")+m,this.vars[d]++),c!=="variable"&&(t=this.getSubBuildProperty(t,a.subBuilds));const y=e.getArrayCount(this);u=new g2(t,n,o,y),o||p.push(u),this.registerDeclaration(u),a[c]=u}return u}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,n=e.getNodeType(this),r=null,o=null){const a=this.getDataFromNode(e,"any"),c=this.getSubBuildProperty("varying",a.subBuilds);let u=a[c];if(u===void 0){const d=this.varyings,p=d.length;t===null&&(t="nodeVarying"+p),c!=="varying"&&(t=this.getSubBuildProperty(t,a.subBuilds)),u=new HH(t,n,r,o),d.push(u),this.registerDeclaration(u),a[c]=u}return u}registerDeclaration(e){const t=this.shaderStage,n=this.declarations[t]||(this.declarations[t]={}),r=this.getPropertyName(e);let o=1,a=r;for(;n[a]!==void 0;)a=r+"_"+o++;o>1&&(e.name=a,Ie(`TSL: Declaration name '${r}' of '${e.type}' already in use. Renamed to '${a}'.`)),n[a]=e}getCodeFromNode(e,t,n=this.shaderStage){const r=this.getDataFromNode(e);let o=r.code;if(o===void 0){const a=this.codes[n]||(this.codes[n]=[]),c=a.length;o=new $H("nodeCode"+c,t),a.push(o),r.code=o}return o}addFlowCodeHierarchy(e,t){const{flowCodes:n,flowCodeBlock:r}=this.getDataFromNode(e);let o=!0,a=t;for(;a;){if(r.get(a)===!0){o=!1;break}a=this.getDataFromNode(a).parentNodeBlock}if(o)for(const c of n)this.addLineFlowCode(c)}addLineFlowCodeBlock(e,t,n){const r=this.getDataFromNode(e),o=r.flowCodes||(r.flowCodes=[]),a=r.flowCodeBlock||(r.flowCodeBlock=new WeakMap);o.push(t),a.set(n,!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),n=this.flowChildNode(e,t);return this.flowsData.set(e,n),n}addInclude(e){this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(e)}buildFunctionNode(e){const t=new LI,n=this.currentFunctionNode;return this.currentFunctionNode=t,t.code=this.buildFunctionCode(e),this.currentFunctionNode=n,t}flowShaderNode(e){const t=e.layout,n={[Symbol.iterator](){let a=0;const c=Object.values(this);return{next:()=>({value:c[a],done:a++>=c.length})}}};for(const a of t.inputs)n[a.name]=new uI(a.type,a.name);e.layout=null;const r=e.call(n),o=this.flowStagesNode(r,t.type);return e.layout=t,o}flowBuildStage(e,t,n=null){const r=this.getBuildStage();this.setBuildStage(t);const o=e.build(this,n);return this.setBuildStage(r),o}flowStagesNode(e,t=null){const n=this.flow,r=this.vars,o=this.declarations,a=this.cache,c=this.buildStage,u=this.stack,d={code:""};this.flow=d,this.vars={},this.declarations={},this.cache=new t1,this.stack=jv();for(const p of OM)this.setBuildStage(p),d.result=e.build(this,t);return d.vars=this.getVars(this.shaderStage),this.flow=n,this.vars=r,this.declarations=o,this.cache=a,this.stack=u,this.setBuildStage(c),d}getFunctionOperator(){return null}buildFunctionCode(){Ie("Abstract function.")}flowChildNode(e,t=null){const n=this.flow,r={code:""};return this.flow=r,r.result=e.build(this,t),this.flow=n,r}flowNodeFromShaderStage(e,t,n=null,r=null){const o=this.tab,a=this.cache,c=this.shaderStage,u=this.context;this.setShaderStage(e);const d=wi({},this.context);delete d.nodeBlock,this.cache=this.globalCache,this.tab=" ",this.context=d;let p=null;if(this.buildStage==="generate"){const m=this.flowChildNode(t,n);r!==null&&(m.code+=`${this.tab+r} = ${m.result};
`),this.flowCode[e]=this.flowCode[e]+m.code,p=m}else p=t.build(this);return this.setShaderStage(c),this.cache=a,this.tab=o,this.context=u,p}getAttributesArray(){return this.attributes.concat(this.bufferAttributes)}getAttributes(){Ie("Abstract function.")}getVaryings(){Ie("Abstract function.")}getVar(e,t,n=null){return`${n!==null?this.generateArrayDeclaration(e,n):this.getType(e)} ${t}`}getVars(e){let t="";const n=this.vars[e];if(n!==void 0)for(const r of n)t+=`${this.getVar(r.type,r.name)}; `;return t}getUniforms(){Ie("Abstract function.")}getCodes(e){const t=this.codes[e];let n="";if(t!==void 0)for(const r of t)n+=r.code+`
`;return n}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(){Ie("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 n=this.subBuildLayers;for(let r=t.length-1;r>=0;r--){const o=t[r];if(n.includes(o))return o}return null}getSubBuildOutput(e){return this.getSubBuildProperty("outputNode",e)}getSubBuildProperty(e="",t=null){let n;t!==null?n=this.getClosestSubBuild(t):n=this.subBuildFn;let r;return n?r=e?n+"_"+e:n:r=e,r}build(){const{object:e,material:t,renderer:n}=this;if(t!==null){let r=n.library.fromMaterial(t);r===null&&(Be(`NodeMaterial: Material "${t.type}" is not compatible.`),r=new Ss),r.build(this)}else this.addFlow("compute",e);for(const r of OM){this.setBuildStage(r),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const o of UM){this.setShaderStage(o);const a=this.flowNodes[o];for(const c of a)r==="generate"?this.flowNode(c):c.build(this)}}return this.setBuildStage(null),this.setShaderStage(null),this.buildCode(),this.buildUpdateNodes(),this}getSharedDataFromNode(e){let t=h9.get(e);return t===void 0&&(t={}),t}getNodeUniform(e,t){const n=this.getSharedDataFromNode(e);let r=n.cache;if(r===void 0){if(t==="float"||t==="int"||t==="uint")r=new n9(e);else if(t==="vec2"||t==="ivec2"||t==="uvec2")r=new i9(e);else if(t==="vec3"||t==="ivec3"||t==="uvec3")r=new s9(e);else if(t==="vec4"||t==="ivec4"||t==="uvec4")r=new r9(e);else if(t==="color")r=new o9(e);else if(t==="mat2")r=new a9(e);else if(t==="mat3")r=new l9(e);else if(t==="mat4")r=new c9(e);else throw new Error(`Uniform "${t}" not implemented.`);n.cache=r}return r}format(e,t,n){if(t=this.getVectorType(t),n=this.getVectorType(n),t===n||n===null||this.isReference(n))return e;const r=this.getTypeLength(t),o=this.getTypeLength(n);return r===16&&o===9?`${this.getType(n)}( ${e}[ 0 ].xyz, ${e}[ 1 ].xyz, ${e}[ 2 ].xyz )`:r===9&&o===4?`${this.getType(n)}( ${e}[ 0 ].xy, ${e}[ 1 ].xy )`:r>4||o>4||o===0?e:r===o?`${this.getType(n)}( ${e} )`:r>o?(e=n==="bool"?`all( ${e} )`:`${e}.${"xyz".slice(0,o)}`,this.format(e,this.getTypeFromLength(o,this.getComponentType(t)),n)):o===4&&r>1?`${this.getType(n)}( ${this.format(e,t,"vec3")}, 1.0 )`:r===2?`${this.getType(n)}( ${this.format(e,t,"vec2")}, 0.0 )`:(r===1&&o>1&&t!==this.getComponentType(n)&&(e=`${this.getType(this.getComponentType(n))}( ${e} )`),`${this.getType(n)}( ${e} )`)}getSignature(){return`// Three.js r${xe} - Node System
`}}class x2{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 n=e.get(t);return n===void 0&&(n={renderId:0,frameId:0},e.set(t,n)),n}updateBeforeNode(e){const t=e.getUpdateBeforeType(),n=e.updateReference(this);if(t===Xn.FRAME){const r=this._getMaps(this.updateBeforeMap,n);if(r.frameId!==this.frameId){const o=r.frameId;r.frameId=this.frameId,e.updateBefore(this)===!1&&(r.frameId=o)}}else if(t===Xn.RENDER){const r=this._getMaps(this.updateBeforeMap,n);if(r.renderId!==this.renderId){const o=r.renderId;r.renderId=this.renderId,e.updateBefore(this)===!1&&(r.renderId=o)}}else t===Xn.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),n=e.updateReference(this);if(t===Xn.FRAME){const r=this._getMaps(this.updateAfterMap,n);r.frameId!==this.frameId&&e.updateAfter(this)!==!1&&(r.frameId=this.frameId)}else if(t===Xn.RENDER){const r=this._getMaps(this.updateAfterMap,n);r.renderId!==this.renderId&&e.updateAfter(this)!==!1&&(r.renderId=this.renderId)}else t===Xn.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),n=e.updateReference(this);if(t===Xn.FRAME){const r=this._getMaps(this.updateMap,n);r.frameId!==this.frameId&&e.update(this)!==!1&&(r.frameId=this.frameId)}else if(t===Xn.RENDER){const r=this._getMaps(this.updateMap,n);r.renderId!==this.renderId&&e.update(this)!==!1&&(r.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 n1{constructor(e,t,n=null,r="",o=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=o}}n1.isNodeFunctionInput=!0;class f9 extends gp{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:Ww(this.light),lightColor:e}}}const i1=new Qt,yb=new Qt;let $y=null;class p9 extends gp{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=rn(new H).setGroup(an),this.halfWidth=rn(new H).setGroup(an),this.updateType=Xn.RENDER}update(e){super.update(e);const{light:t}=this,n=e.camera.matrixWorldInverse;yb.identity(),i1.copy(t.matrixWorld),i1.premultiply(n),yb.extractRotation(i1),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(yb),this.halfHeight.value.applyMatrix4(yb)}setupDirectRectArea(e){let t,n;e.isAvailable("float32Filterable")?(t=_i($y.LTC_FLOAT_1),n=_i($y.LTC_FLOAT_2)):(t=_i($y.LTC_HALF_1),n=_i($y.LTC_HALF_2));const{colorNode:r,light:o}=this,a=Gw(o);return{lightColor:r,lightPosition:a,halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:n}}static setLTC(e){$y=e}}class s1 extends gp{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=rn(0).setGroup(an),this.penumbraCosNode=rn(0).setGroup(an),this.cutoffDistanceNode=rn(0).setGroup(an),this.decayExponentNode=rn(0).setGroup(an),this.colorNode=rn(this.color).setGroup(an)}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:n,penumbraCosNode:r}=this;return ga(n,r,t)}getLightCoord(e){const t=e.getNodeProperties(this);let n=t.projectionUV;return n===void 0&&(n=OI(this.light,e.context.positionWorld),t.projectionUV=n),n}setupDirect(e){const{colorNode:t,cutoffDistanceNode:n,decayExponentNode:r,light:o}=this,a=this.getLightVector(e),c=a.normalize(),u=c.dot(Ww(o)),d=this.getSpotAttenuation(e,u),p=a.length(),m=Kw({lightDistance:p,cutoffDistance:n,decayExponent:r});let y=t.mul(d).mul(m),x,v;return o.colorNode?(v=this.getLightCoord(e),x=o.colorNode(v)):o.map&&(v=this.getLightCoord(e),x=_i(o.map,v.xy).onRenderUpdate(()=>o.map)),x&&(y=v.mul(2).sub(1).abs().lessThan(1).all().select(y.mul(x),y)),{lightColor:y,lightDirection:c}}}class m9 extends s1{static get type(){return"IESSpotLightNode"}getSpotAttenuation(e,t){const n=this.light.iesMap;let r=null;if(n&&n.isTexture===!0){const o=t.acos().mul(1/Math.PI);r=_i(n,lt(o,0),0).r}else r=super.getSpotAttenuation(t);return r}}const g9=me(([i,e])=>{const t=i.abs().sub(e);return Nc(vs(t,0)).add(ko(vs(t.x,t.y),0))});class y9 extends s1{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 n=1;t.map!==null&&(n=t.map.width/t.map.height),t.shadow.aspect=n}else t.shadow.aspect=t.aspect}getSpotAttenuation(e){const t=q(0),n=this.penumbraCosNode,r=cb(this.light).mul(e.context.positionWorld||_a);return jt(r.w.greaterThan(0),()=>{const o=r.xyz.div(r.w),a=g9(o.xy.sub(lt(.5)),lt(.5)),c=ma(-1,ui(1,lT(n)).sub(1));t.assign(vv(a.mul(-2).mul(c)))}),t}}class _9 extends gp{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class x9 extends gp{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=Vw(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=rn(new It).setGroup(an)}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:n,lightDirectionNode:r}=this,a=$d.dot(r).mul(.5).add(.5),c=oi(n,t,a);e.context.irradiance.addAssign(c)}}class v9 extends gp{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let n=0;n<9;n++)t.push(new H);this.lightProbe=eo(t)}update(e){const{light:t}=this;super.update(e);for(let n=0;n<9;n++)this.lightProbe.array[n].copy(t.sh.coefficients[n]).multiplyScalar(t.intensity)}setup(e){const t=p2($d,this.lightProbe);e.context.irradiance.addAssign(t)}}class v2{parseFunction(){Ie("Abstract function.")}}class r1{constructor(e,t,n="",r=""){this.type=e,this.inputs=t,this.name=n,this.precision=r}getCode(){Ie("Abstract function.")}}r1.isNodeFunction=!0;const b9=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,S9=/[a-z_0-9]+/ig,b2="#pragma main",M9=i=>{i=i.trim();const e=i.indexOf(b2),t=e!==-1?i.slice(e+b2.length):i,n=t.match(b9);if(n!==null&&n.length===5){const r=n[4],o=[];let a=null;for(;(a=S9.exec(r))!==null;)o.push(a);const c=[];let u=0;for(;u<o.length;){const v=o[u][0]==="const";v===!0&&u++;let w=o[u][0];w==="in"||w==="out"||w==="inout"?u++:w="";const M=o[u++][0];let S=Number.parseInt(o[u][0]);Number.isNaN(S)===!1?u++:S=null;const C=o[u++][0];c.push(new n1(M,C,S,w,v))}const d=t.substring(n[0].length),p=n[3]!==void 0?n[3]:"",m=n[2],y=n[1]!==void 0?n[1]:"",x=e!==-1?i.slice(0,e):"";return{type:m,inputs:c,name:p,precision:y,inputsCode:r,blockCode:d,headerCode:x}}else throw new Error("FunctionNode: Function is not a GLSL code.")};class T9 extends r1{constructor(e){const{type:t,inputs:n,name:r,precision:o,inputsCode:a,blockCode:c,headerCode:u}=M9(e);super(t,n,r,o),this.inputsCode=a,this.blockCode=c,this.headerCode=u}getCode(e=this.name){let t;const n=this.blockCode;if(n!==""){const{type:r,inputsCode:o,headerCode:a,precision:c}=this;let u=`${r} ${e} ( ${o.trim()} )`;c!==""&&(u=`${c} ${u}`),t=a+u+n}else t="";return t}}class w9 extends v2{parseFunction(e){return new T9(e)}}const S2=new WeakMap,zc=[],Kd=[];class A9 extends jd{constructor(e,t){super(),this.renderer=e,this.backend=t,this.nodeFrame=new x2,this.nodeBuilderCache=new Map,this.callHashCache=new Nl,this.groupsData=new Nl,this.cacheLib={}}updateGroup(e){const t=e.groupNode,n=t.name;if(n===nT.name)return!0;if(n===an.name){const o=this.get(e),a=this.nodeFrame.renderId;return o.renderId!==a?(o.renderId=a,!0):!1}if(n===_C.name){const o=this.get(e),a=this.nodeFrame.frameId;return o.frameId!==a?(o.frameId=a,!0):!1}zc[0]=t,zc[1]=e;let r=this.groupsData.get(zc);return r===void 0&&this.groupsData.set(zc,r={}),zc.length=0,r.version!==t.version?(r.version=t.version,!0):!1}getForRenderCacheKey(e){return e.initialCacheKey}getForRender(e){const t=this.get(e);let n=t.nodeBuilderState;if(n===void 0){const{nodeBuilderCache:r}=this,o=this.getForRenderCacheKey(e);if(n=r.get(o),n===void 0){const a=u=>{const d=this.backend.createNodeBuilder(e.object,this.renderer);return d.scene=e.scene,d.material=u,d.camera=e.camera,d.context.material=u,d.lightsNode=e.lightsNode,d.environmentNode=this.getEnvironmentNode(e.scene),d.fogNode=this.getFogNode(e.scene),d.clippingContext=e.clippingContext,this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview&&d.enableMultiview(),d};let c=a(e.material);try{c.build()}catch(u){c=a(new Ss),c.build(),Be("TSL: "+u)}n=this._createNodeBuilderState(c),r.set(o,n)}n.usedTimes++,t.nodeBuilderState=n}return n}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 n=t.nodeBuilderState;if(n===void 0){const r=this.backend.createNodeBuilder(e,this.renderer);r.build(),n=this._createNodeBuilderState(r),t.nodeBuilderState=n}return n}_createNodeBuilderState(e){return new GH(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 n=this.get(e);n.environmentNode&&(t=n.environmentNode)}return t}getBackgroundNode(e){this.updateBackground(e);let t=null;if(e.backgroundNode&&e.backgroundNode.isNode)t=e.backgroundNode;else{const n=this.get(e);n.backgroundNode&&(t=n.backgroundNode)}return t}getFogNode(e){return this.updateFog(e),e.fogNode||this.get(e).fogNode||null}getCacheKey(e,t){zc[0]=e,zc[1]=t;const n=this.renderer.info.calls,r=this.callHashCache.get(zc)||{};if(r.callId!==n){const o=this.getEnvironmentNode(e),a=this.getFogNode(e);t&&Kd.push(t.getCacheKey(!0)),o&&Kd.push(o.getCacheKey()),a&&Kd.push(a.getCacheKey()),Kd.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),Kd.push(this.renderer.shadowMap.enabled?1:0),Kd.push(this.renderer.shadowMap.type),r.callId=n,r.cacheKey=Kf(Kd),this.callHashCache.set(zc,r),Kd.length=0}return zc.length=0,r.cacheKey}get isToneMappingState(){return!this.renderer.getRenderTarget()}updateBackground(e){const t=this.get(e),n=e.background;if(n){const r=e.backgroundBlurriness===0&&t.backgroundBlurriness>0||e.backgroundBlurriness>0&&t.backgroundBlurriness===0;if(t.background!==n||r){const o=this.getCacheNode("background",n,()=>{if(n.isCubeTexture===!0||n.mapping===jc||n.mapping===Yc||n.mapping===Fl){if(e.backgroundBlurriness>0||n.mapping===Fl)return ww(n);{let a;return n.isCubeTexture===!0?a=vo(n):a=_i(n),gP(a)}}else{if(n.isTexture===!0)return _i(n,ah.flipY()).setUpdateMatrix(!0);n.isColor!==!0&&Be("WebGPUNodes: Unsupported background configuration.",n)}},r);t.backgroundNode=o,t.background=n,t.backgroundBlurriness=e.backgroundBlurriness}}else t.backgroundNode&&(delete t.backgroundNode,delete t.background)}getCacheNode(e,t,n,r=!1){const o=this.cacheLib[e]||(this.cacheLib[e]=new WeakMap);let a=o.get(t);return(a===void 0||r)&&(a=n(),o.set(t,a)),a}updateFog(e){const t=this.get(e),n=e.fog;if(n){if(t.fog!==n){const r=this.getCacheNode("fog",n,()=>{if(n.isFogExp2){const o=Oi("color","color",n).setGroup(an),a=Oi("density","float",n).setGroup(an);return Uy(o,kw(a))}else if(n.isFog){const o=Oi("color","color",n).setGroup(an),a=Oi("near","float",n).setGroup(an),c=Oi("far","float",n).setGroup(an);return Uy(o,Uw(a,c))}else Be("Renderer: Unsupported fog configuration.",n)});t.fogNode=r,t.fog=n}}else delete t.fogNode,delete t.fog}updateEnvironment(e){const t=this.get(e),n=e.environment;if(n){if(t.environment!==n){const r=this.getCacheNode("environment",n,()=>{if(n.isCubeTexture===!0)return vo(n);if(n.isTexture===!0)return _i(n);Be("Nodes: Unsupported environment configuration.",n)});t.environmentNode=r,t.environment=n}}else t.environmentNode&&(delete t.environmentNode,delete t.environment)}getNodeFrame(e=this.renderer,t=null,n=null,r=null,o=null){const a=this.nodeFrame;return a.renderer=e,a.scene=t,a.object=n,a.camera=r,a.material=o,a}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 S2.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,n=this.getOutputCacheKey(),r=e.isArrayTexture?nb(e,he(ah,oh("gl_ViewID_OVR"))).renderOutput(t.toneMapping,t.currentColorSpace):_i(e,ah).renderOutput(t.toneMapping,t.currentColorSpace);return S2.set(e,n),r}updateBefore(e){const t=e.getNodeBuilderState();for(const n of t.updateBeforeNodes)this.getNodeFrameForRender(e).updateBeforeNode(n)}updateAfter(e){const t=e.getNodeBuilderState();for(const n of t.updateAfterNodes)this.getNodeFrameForRender(e).updateAfterNode(n)}updateForCompute(e){const t=this.getNodeFrame(),n=this.getForCompute(e);for(const r of n.updateNodes)t.updateNode(r)}updateForRender(e){const t=this.getNodeFrameForRender(e),n=e.getNodeBuilderState();for(const r of n.updateNodes)t.updateNode(r)}needsRefresh(e){const t=this.getNodeFrameForRender(e);return e.getMonitor().needsRefresh(e,t)}dispose(){super.dispose(),this.nodeFrame=new x2,this.nodeBuilderCache=new Map,this.cacheLib={}}}const o1=new uo;class _b{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new Nn,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,n){const r=e.length;for(let o=0;o<r;o++){o1.copy(e[o]).applyMatrix4(this.viewMatrix,this.viewNormalMatrix);const a=t[n+o],c=o1.normal;a.x=-c.x,a.y=-c.y,a.z=-c.z,a.w=o1.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 n=!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 r=t.clippingPlanes,o=r.length;let a,c;if(this.clipIntersection?(a=this.intersectionPlanes,c=e.intersectionPlanes.length):(a=this.unionPlanes,c=e.unionPlanes.length),a.length!==c+o){a.length=c+o;for(let u=0;u<o;u++)a[c+u]=new gn;n=!0}this.projectPlanes(r,a,c),n&&(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 _b(this),this.clippingGroupContexts.set(e,t)),t.update(this,e),t}get unionClippingCount(){return this.unionPlanes.length}}class E9{constructor(e,t){this.bundleGroup=e,this.camera=t}}const qy=[];class C9{constructor(){this.bundles=new Nl}get(e,t){const n=this.bundles;qy[0]=e,qy[1]=t;let r=n.get(qy);return r===void 0&&(r=new E9(e,t),n.set(qy,r)),qy.length=0,r}dispose(){this.bundles=new Nl}}class M2{constructor(){this.lightNodes=new WeakMap,this.materialNodes=new Map,this.toneMappingNodes=new Map}fromMaterial(e){if(e.isNodeMaterial)return e;let t=null;const n=this.getMaterialNodeClass(e.type);if(n!==null){t=new n;for(const r in e)t[r]=e[r]}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,n){if(n.has(t)){Ie(`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.`);n.set(t,e)}addClass(e,t,n){if(n.has(t)){Ie(`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.`);n.set(t,e)}}const R9=new $w,Xy=[];class N9 extends Nl{constructor(){super()}createNode(e=[]){return new $w().setLights(e)}getNode(e,t){if(e.isQuadMesh)return R9;Xy[0]=e,Xy[1]=t;let n=this.get(Xy);return n===void 0&&(n=this.createNode(),this.set(Xy,n)),Xy.length=0,n}}class jy extends Ws{constructor(e=1,t=1,n={}){super(e,t,n),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 T2=new H,w2=new H;class P9 extends Jo{constructor(e,t=!1){super(),this.enabled=!1,this.isPresenting=!1,this.cameraAutoUpdate=!0,this._renderer=e,this._cameraL=new Bs,this._cameraL.viewport=new gn,this._cameraR=new Bs,this._cameraR.viewport=new gn,this._cameras=[this._cameraL,this._cameraR],this._cameraXR=new xc,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=O9.bind(this),this._gl=null,this._currentAnimationContext=null,this._currentAnimationLoop=null,this._currentPixelRatio=null,this._currentSize=new ze,this._onSessionEvent=D9.bind(this),this._onSessionEnd=F9.bind(this),this._onInputSourcesChange=B9.bind(this),this._onAnimationFrame=U9.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&&Ie("XRManager: Cannot change framebuffer scale while presenting.")}getReferenceSpaceType(){return this._referenceSpaceType}setReferenceSpaceType(e){this._referenceSpaceType=e,this.isPresenting===!0&&Ie("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,n,r,o,a,c,u={}){const d=new Ed(e,t),p=new jy(o,a,{format:Ri,type:Di,depthTexture:new Ys(o,a,u.stencil?wo:yi,void 0,void 0,void 0,void 0,void 0,void 0,u.stencil?Rr:tr),stencilBuffer:u.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});p._autoAllocateDepthBuffer=!0;const m=new Or({color:16777215,side:Me});m.map=p.texture,m.map.offset.y=1,m.map.repeat.y=-1;const y=new Ji(d,m);y.position.copy(n),y.quaternion.copy(r);const x={type:"quad",width:e,height:t,translation:n,quaternion:r,pixelwidth:o,pixelheight:a,plane:y,material:m,rendercall:c,renderTarget:p};if(this._layers.push(x),this._session!==null){x.plane.material=new Or({color:16777215,side:Me}),x.plane.material.blending=ut,x.plane.material.blendEquation=nt,x.plane.material.blendSrc=Sn,x.plane.material.blendDst=Sn,x.xrlayer=this._createXRLayer(x);const v=this._session.renderState.layers;v.unshift(x.xrlayer),this._session.updateRenderState({layers:v})}else p.isXRRenderTarget=!1;return y}createCylinderLayer(e,t,n,r,o,a,c,u,d={}){const p=new Ur(e,e,e*t/n,64,64,!0,Math.PI-t/2,t),m=new jy(a,c,{format:Ri,type:Di,depthTexture:new Ys(a,c,d.stencil?wo:yi,void 0,void 0,void 0,void 0,void 0,void 0,d.stencil?Rr:tr),stencilBuffer:d.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});m._autoAllocateDepthBuffer=!0;const y=new Or({color:16777215,side:we});y.map=m.texture,y.map.offset.y=1,y.map.repeat.y=-1;const x=new Ji(p,y);x.position.copy(r),x.quaternion.copy(o);const v={type:"cylinder",radius:e,centralAngle:t,aspectratio:n,translation:r,quaternion:o,pixelwidth:a,pixelheight:c,plane:x,material:y,rendercall:u,renderTarget:m};if(this._layers.push(v),this._session!==null){v.plane.material=new Or({color:16777215,side:we}),v.plane.material.blending=ut,v.plane.material.blendEquation=nt,v.plane.material.blendSrc=Sn,v.plane.material.blendDst=Sn,v.xrlayer=this._createXRLayer(v);const w=this._session.renderState.layers;w.unshift(v.xrlayer),this._session.updateRenderState({layers:w})}else m.isXRRenderTarget=!1;return x}renderLayers(){const e=new H,t=new Gs,n=this._renderer,r=this.isPresenting,o=n.getOutputRenderTarget(),a=n._frameBufferTarget;this.isPresenting=!1;const c=new ze;n.getSize(c);const u=n._quad;for(const d of this._layers)if(d.renderTarget.isXRRenderTarget=this._session!==null,d.renderTarget._hasExternalTextures=d.renderTarget.isXRRenderTarget,d.renderTarget.isXRRenderTarget&&this._sessionUsesLayers){d.xrlayer.transform=new XRRigidTransform(d.plane.getWorldPosition(e),d.plane.getWorldQuaternion(t));const p=this._glBinding.getSubImage(d.xrlayer,this._xrFrame);n.backend.setXRRenderTargetTextures(d.renderTarget,p.colorTexture,void 0),n._setXRLayerSize(d.renderTarget.width,d.renderTarget.height),n.setOutputRenderTarget(d.renderTarget),n.setRenderTarget(null),n._frameBufferTarget=null,this._frameBufferTargets||(this._frameBufferTargets=new WeakMap);const{frameBufferTarget:m,quad:y}=this._frameBufferTargets.get(d.renderTarget)||{frameBufferTarget:null,quad:null};m?(n._frameBufferTarget=m,n._quad=y):(n._quad=new By(new Ss),this._frameBufferTargets.set(d.renderTarget,{frameBufferTarget:n._getFrameBufferTarget(),quad:n._quad})),d.rendercall(),n._frameBufferTarget=null}else n.setRenderTarget(d.renderTarget),d.rendercall();n.setRenderTarget(null),n.setOutputRenderTarget(o),n._frameBufferTarget=a,n._setXRLayerSize(c.x,c.y),n._quad=u,this.isPresenting=r}getSession(){return this._session}setSession(e){return mn(this,null,function*(){const t=this._renderer,n=t.backend;this._gl=t.getContext();const r=this._gl,o=r.getContextAttributes();if(this._session=e,e!==null){if(n.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 n.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 a=null,c=null,u=null;t.depth&&(u=t.stencil?r.DEPTH24_STENCIL8:r.DEPTH_COMPONENT24,a=t.stencil?Rr:tr,c=t.stencil?wo:yi);const d={colorFormat:r.RGBA8,depthFormat:u,scaleFactor:this._framebufferScaleFactor,clearOnAccess:!1};this._useMultiviewIfPossible&&t.hasFeature("OVR_multiview2")&&(d.textureType="texture-array",this._useMultiview=!0),this._glBinding=this.getBinding();const p=this._glBinding.createProjectionLayer(d),m=[p];this._glProjLayer=p,t.setPixelRatio(1),t._setXRLayerSize(p.textureWidth,p.textureHeight);const y=this._useMultiview?2:1,x=new Ys(p.textureWidth,p.textureHeight,c,void 0,void 0,void 0,void 0,void 0,void 0,a,y);if(this._xrRenderTarget=new jy(p.textureWidth,p.textureHeight,{format:Ri,type:Di,colorSpace:t.outputColorSpace,depthTexture:x,stencilBuffer:t.stencil,samples:o.antialias?4:0,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.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 v of this._layers)v.plane.material=new Or({color:16777215,side:v.type==="cylinder"?we:Me}),v.plane.material.blending=ut,v.plane.material.blendEquation=nt,v.plane.material.blendSrc=Sn,v.plane.material.blendDst=Sn,v.xrlayer=this._createXRLayer(v),m.unshift(v.xrlayer);e.updateRenderState({layers:m})}else{const a={antialias:t.currentSamples>0,alpha:!0,depth:t.depth,stencil:t.stencil,framebufferScaleFactor:this.getFramebufferScaleFactor()},c=new XRWebGLLayer(e,r,a);this._glBaseLayer=c,e.updateRenderState({baseLayer:c}),t.setPixelRatio(1),t._setXRLayerSize(c.framebufferWidth,c.framebufferHeight),this._xrRenderTarget=new jy(c.framebufferWidth,c.framebufferHeight,{format:Ri,type:Di,colorSpace:t.outputColorSpace,stencilBuffer:t.stencil,resolveDepthBuffer:c.ignoreDepthValues===!1,resolveStencilBuffer:c.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 n=e.near,r=e.far,o=this._cameraXR,a=this._cameraL,c=this._cameraR;o.near=c.near=a.near=n,o.far=c.far=a.far=r,o.isMultiViewCamera=this._useMultiview,(this._currentDepthNear!==o.near||this._currentDepthFar!==o.far)&&(t.updateRenderState({depthNear:o.near,depthFar:o.far}),this._currentDepthNear=o.near,this._currentDepthFar=o.far),o.layers.mask=e.layers.mask|6,a.layers.mask=o.layers.mask&3,c.layers.mask=o.layers.mask&5;const u=e.parent,d=o.cameras;A2(o,u);for(let p=0;p<d.length;p++)A2(d[p],u);d.length===2?I9(o,a,c):o.projectionMatrix.copy(a.projectionMatrix),L9(e,o,u)}_getController(e){let t=this._controllers[e];return t===void 0&&(t=new pl,this._controllers[e]=t),t}}function I9(i,e,t){T2.setFromMatrixPosition(e.matrixWorld),w2.setFromMatrixPosition(t.matrixWorld);const n=T2.distanceTo(w2),r=e.projectionMatrix.elements,o=t.projectionMatrix.elements,a=r[14]/(r[10]-1),c=r[14]/(r[10]+1),u=(r[9]+1)/r[5],d=(r[9]-1)/r[5],p=(r[8]-1)/r[0],m=(o[8]+1)/o[0],y=a*p,x=a*m,v=n/(-p+m),w=v*-p;if(e.matrixWorld.decompose(i.position,i.quaternion,i.scale),i.translateX(w),i.translateZ(v),i.matrixWorld.compose(i.position,i.quaternion,i.scale),i.matrixWorldInverse.copy(i.matrixWorld).invert(),r[10]===-1)i.projectionMatrix.copy(e.projectionMatrix),i.projectionMatrixInverse.copy(e.projectionMatrixInverse);else{const M=a+v,S=c+v,C=y-w,N=x+(n-w),I=u*c/S*M,U=d*c/S*M;i.projectionMatrix.makePerspective(C,N,I,U,M,S),i.projectionMatrixInverse.copy(i.projectionMatrix).invert()}}function A2(i,e){e===null?i.matrixWorld.copy(i.matrix):i.matrixWorld.multiplyMatrices(e.matrixWorld,i.matrix),i.matrixWorldInverse.copy(i.matrixWorld).invert()}function L9(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=ou*2*Math.atan(1/i.projectionMatrix.elements[5]),i.zoom=1)}function D9(i){const e=this._controllerInputSources.indexOf(i.inputSource);if(e===-1)return;const t=this._controllers[e];if(t!==void 0){const n=this.getReferenceSpace();t.update(i.inputSource,i.frame,n),t.dispatchEvent({type:i.type,data:i.inputSource})}}function F9(){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 n=this._controllerInputSources[t];n!==null&&(this._controllerInputSources[t]=null,this._controllers[t].disconnect(n))}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 jy(t.pixelwidth,t.pixelheight,{format:Ri,type:Di,depthTexture:new Ys(t.pixelwidth,t.pixelheight,t.stencilBuffer?wo:yi,void 0,void 0,void 0,void 0,void 0,void 0,t.stencilBuffer?Rr:tr),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 B9(i){const e=this._controllers,t=this._controllerInputSources;for(let n=0;n<i.removed.length;n++){const r=i.removed[n],o=t.indexOf(r);o>=0&&(t[o]=null,e[o].disconnect(r))}for(let n=0;n<i.added.length;n++){const r=i.added[n];let o=t.indexOf(r);if(o===-1){for(let c=0;c<e.length;c++)if(c>=t.length){t.push(r),o=c;break}else if(t[c]===null){t[c]=r,o=c;break}if(o===-1)break}const a=e[o];a&&a.connect(r)}}function O9(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 U9(i,e){if(e===void 0)return;const t=this._cameraXR,n=this._renderer,r=n.backend,o=this._glBaseLayer,a=this.getReferenceSpace(),c=e.getViewerPose(a);if(this._xrFrame=e,c!==null){const u=c.views;this._glBaseLayer!==null&&r.setXRTarget(o.framebuffer);let d=!1;u.length!==t.cameras.length&&(t.cameras.length=0,d=!0);for(let p=0;p<u.length;p++){const m=u[p];let y;if(this._supportsLayers===!0){const v=this._glBinding.getViewSubImage(this._glProjLayer,m);y=v.viewport,p===0&&r.setXRRenderTargetTextures(this._xrRenderTarget,v.colorTexture,this._glProjLayer.ignoreDepthValues&&!this._useMultiview?void 0:v.depthStencilTexture)}else y=o.getViewport(m);let x=this._cameras[p];x===void 0&&(x=new Bs,x.layers.enable(p),x.viewport=new gn,this._cameras[p]=x),x.matrix.fromArray(m.transform.matrix),x.matrix.decompose(x.position,x.quaternion,x.scale),x.projectionMatrix.fromArray(m.projectionMatrix),x.projectionMatrixInverse.copy(x.projectionMatrix).invert(),x.viewport.set(y.x,y.y,y.width,y.height),p===0&&(t.matrix.copy(x.matrix),t.matrix.decompose(t.position,t.quaternion,t.scale)),d===!0&&t.cameras.push(x)}n.setOutputRenderTarget(this._xrRenderTarget)}for(let u=0;u<this._controllers.length;u++){const d=this._controllerInputSources[u],p=this._controllers[u];d!==null&&p!==void 0&&p.update(d,e,a)}this._currentAnimationLoop&&this._currentAnimationLoop(i,e),e.detectedPlanes&&this.dispatchEvent({type:"planesdetected",data:e}),this._xrFrame=null}class k9 extends Jo{constructor(e){super(),this.domElement=e,this._pixelRatio=1,this._width=this.domElement.width,this._height=this.domElement.height,this._viewport=new gn(0,0,this._width,this._height),this._scissor=new gn(0,0,this._width,this._height),this._scissorTest=!1,this.colorTexture=new Ef,this.depthTexture=new Ys}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,n){this.xr&&this.xr.isPresenting||(this._width=e,this._height=t,this._pixelRatio=n,this.domElement.width=Math.floor(e*n),this.domElement.height=Math.floor(t*n),this.setViewport(0,0,e,t),this._dispatchResize())}setSize(e,t,n=!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),n===!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,n,r){const o=this._scissor;e.isVector4?o.copy(e):o.set(e,t,n,r)}getScissorTest(){return this._scissorTest}setScissorTest(e){this._scissorTest=e}getViewport(e){return e.copy(this._viewport)}setViewport(e,t,n,r,o=0,a=1){const c=this._viewport;e.isVector4?c.copy(e):c.set(e,t,n,r),c.minDepth=o,c.maxDepth=a}_dispatchResize(){this.dispatchEvent({type:"resize"})}dispose(){this.dispatchEvent({type:"dispose"})}}const E2=new Oa,xg=new ze,a1=new gn,l1=new Xs,c1=new Qp,xb=new Qt,fh=new gn;class z9{constructor(e,t={}){this.isRenderer=!0;const{logarithmicDepthBuffer:n=!1,alpha:r=!0,depth:o=!0,stencil:a=!1,antialias:c=!1,samples:u=0,getFallback:d=null,outputBufferType:p=Hi,multiview:m=!1}=t;this.backend=e,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.alpha=r,this.logarithmicDepthBuffer=n,this.outputColorSpace=Pr,this.toneMapping=yr,this.toneMappingExposure=1,this.sortObjects=!0,this.depth=o,this.stencil=a,this.info=new m5,this.contextNode=ih(),this.library=new M2,this.lighting=new N9,this._samples=u||c===!0?4:0,this._onCanvasTargetResize=this._onCanvasTargetResize.bind(this),this._canvasTarget=new k9(e.getDomElement()),this._canvasTarget.addEventListener("resize",this._onCanvasTargetResize),this._canvasTarget.isDefaultCanvasTarget=!0,this._inspector=new UR,this._inspector.setRenderer(this),this._getFallback=d,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 By(new Ss),this._quad.name="Output Color Transform",this._quad.material.name="outputColorTransform",this._currentRenderContext=null,this._opaqueSort=null,this._transparentSort=null,this._frameBufferTarget=null;const y=this.alpha===!0?0:1;this._clearColor=new Ew(0,0,0,y),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._outputBufferType=p,this._cacheShadowNodes=new WeakMap,this._initialized=!1,this._initPromise=null,this._compilationPromises=null,this.transparent=!0,this.opaque=!0,this.shadowMap={enabled:!1,type:ue},this.xr=new P9(this,m),this.debug={checkShaderErrors:!0,onShaderError:null,getShaderAsync:(x,v,w)=>mn(this,null,function*(){yield this.compileAsync(x,v);const M=this._renderLists.get(x,v),S=this._renderContexts.get(x,v,this._renderTarget,this._mrt),C=x.overrideMaterial||w.material,N=this._objects.get(w,C,x,v,M.lightsNode,S,S.clippingContext),{fragmentShader:I,vertexShader:U}=N.getNodeBuilderState();return{fragmentShader:I,vertexShader:U}})}}init(){return mn(this,null,function*(){return this._initPromise!==null?this._initPromise:(this._initPromise=new Promise((e,t)=>mn(this,null,function*(){let n=this.backend;try{yield n.init(this)}catch(r){if(this._getFallback!==null)try{this.backend=n=this._getFallback(r),yield n.init(this)}catch(o){t(o);return}else{t(r);return}}this._nodes=new A9(this,n),this._animation=new o5(this,this._nodes,this.info),this._attributes=new f5(n),this._background=new zH(this,this._nodes),this._geometries=new p5(this._attributes,this.info),this._textures=new N5(this,n,this.info),this._pipelines=new x5(n,this._nodes),this._bindings=new v5(n,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new u5(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new M5(this.lighting),this._bundles=new C9,this._renderContexts=new C5,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,n=null){return mn(this,null,function*(){if(this._isDeviceLost===!0)return;this._initialized===!1&&(yield this.init());const r=this._nodes.nodeFrame,o=r.renderId,a=this._currentRenderContext,c=this._currentRenderObjectFunction,u=this._compilationPromises,d=e.isScene===!0?e:E2;n===null&&(n=e);const p=this._renderTarget,m=this._renderContexts.get(n,t,p,this._mrt),y=this._activeMipmapLevel,x=[];this._currentRenderContext=m,this._currentRenderObjectFunction=this.renderObject,this._handleObjectFunction=this._createObjectPipeline,this._compilationPromises=x,r.renderId++,r.update(),m.depth=this.depth,m.stencil=this.stencil,m.clippingContext||(m.clippingContext=new _b),m.clippingContext.updateGlobal(d,t),d.onBeforeRender(this,e,t,p);const v=this._renderLists.get(e,t);if(v.begin(),this._projectObject(e,t,0,v,m.clippingContext),n!==e&&n.traverseVisible(function(N){N.isLight&&N.layers.test(t.layers)&&v.pushLight(N)}),v.finish(),p!==null){this._textures.updateRenderTarget(p,y);const N=this._textures.get(p);m.textures=N.textures,m.depthTexture=N.depthTexture}else m.textures=null,m.depthTexture=null;this._background.update(d,v,m);const w=v.opaque,M=v.transparent,S=v.transparentDoublePass,C=v.lightsNode;this.opaque===!0&&w.length>0&&this._renderObjects(w,t,d,C),this.transparent===!0&&M.length>0&&this._renderTransparents(M,S,t,d,C),r.renderId=o,this._currentRenderContext=a,this._currentRenderObjectFunction=c,this._compilationPromises=u,this._handleObjectFunction=this._renderObjectDirect,yield Promise.all(x)})}renderAsync(e,t){return mn(this,null,function*(){Ut('Renderer: "renderAsync()" has been deprecated. Use "render()" and "await renderer.init();" when creating the renderer.'),yield this.init(),this.render(e,t)})}waitForGPU(){return mn(this,null,function*(){Be("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){const t=this.contextNode.value;e===!0?(t.modelViewMatrix=LT,t.modelNormalViewMatrix=DT):this.highPrecision&&(delete t.modelViewMatrix,delete t.modelNormalViewMatrix)}get highPrecision(){const e=this.contextNode.value;return e.modelViewMatrix===LT&&e.modelNormalViewMatrix===DT}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getOutputBufferType(){return this._outputBufferType}getColorBufferType(){return Ut('Renderer: ".getColorBufferType()" has been renamed to ".getOutputBufferType()".'),this.getOutputBufferType()}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:
Message: ${e.message}`;e.reason&&(t+=`
Reason: ${e.reason}`),Be(t),this._isDeviceLost=!0}_renderBundle(e,t,n){const{bundleGroup:r,camera:o,renderList:a}=e,c=this._currentRenderContext,u=this._bundles.get(r,o),d=this.backend.get(u);d.renderContexts===void 0&&(d.renderContexts=new Set);const p=r.version!==d.version,m=d.renderContexts.has(c)===!1||p;if(d.renderContexts.add(c),m){this.backend.beginBundle(c),(d.renderObjects===void 0||p)&&(d.renderObjects=[]),this._currentRenderBundle=u;const{transparentDoublePass:y,transparent:x,opaque:v}=a;this.opaque===!0&&v.length>0&&this._renderObjects(v,o,t,n),this.transparent===!0&&x.length>0&&this._renderTransparents(x,y,o,t,n),this._currentRenderBundle=null,this.backend.finishBundle(c,u),d.version=r.version}else{const{renderObjects:y}=d;for(let x=0,v=y.length;x<v;x++){const w=y[x];this._nodes.needsRefresh(w)&&(this._nodes.updateBefore(w),this._nodes.updateForRender(w),this._bindings.updateForRender(w),this._nodes.updateAfter(w))}}this.backend.addBundle(c,u)}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,n=e!==yr,r=t!==xn.workingColorSpace;if(n===!1&&r===!1)return null;const{width:o,height:a}=this.getDrawingBufferSize(xg),{depth:c,stencil:u}=this;let d=this._frameBufferTarget;d===null&&(d=new Ws(o,a,{depthBuffer:c,stencilBuffer:u,type:this._outputBufferType,format:Ri,colorSpace:xn.workingColorSpace,generateMipmaps:!1,minFilter:Yn,magFilter:Yn,samples:this.samples}),d.isPostProcessingRenderTarget=!0,this._frameBufferTarget=d);const p=this.getOutputRenderTarget();d.depthBuffer=c,d.stencilBuffer=u,p!==null?d.setSize(p.width,p.height,p.depth):d.setSize(o,a,1);const m=this._canvasTarget;return d.viewport.copy(m._viewport),d.scissor.copy(m._scissor),d.viewport.multiplyScalar(m._pixelRatio),d.scissor.multiplyScalar(m._pixelRatio),d.scissorTest=m._scissorTest,d.multiview=p!==null?p.multiview:!1,d.resolveDepthBuffer=p!==null?p.resolveDepthBuffer:!0,d._autoAllocateDepthBuffer=p!==null?p._autoAllocateDepthBuffer:!1,d}_renderScene(e,t,n=!0){if(this._isDeviceLost===!0)return;const r=n?this._getFrameBufferTarget():null,o=this._nodes.nodeFrame,a=o.renderId,c=this._currentRenderContext,u=this._currentRenderObjectFunction,d=e.isScene===!0?e:E2,p=this._renderTarget||this._outputRenderTarget,m=this._activeCubeFace,y=this._activeMipmapLevel;let x;r!==null?(x=r,this.setRenderTarget(x)):x=p;const v=this._renderContexts.get(e,t,x,this._mrt);this._currentRenderContext=v,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,o.renderId=this.info.calls,this.backend.updateTimeStampUID(v),this.inspector.beginRender(this.backend.getTimestampUID(v),e,t,x);const w=this.coordinateSystem,M=this.xr;if(t.coordinateSystem!==w&&M.isPresenting===!1&&(t.coordinateSystem=w,t.updateProjectionMatrix(),t.isArrayCamera))for(const Te of t.cameras)Te.coordinateSystem=w,Te.updateProjectionMatrix();e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),M.enabled===!0&&M.isPresenting===!0&&(M.cameraAutoUpdate===!0&&M.updateCamera(t),t=M.getCamera());const S=this._canvasTarget;let C=S._viewport,N=S._scissor,I=S._pixelRatio;x!==null&&(C=x.viewport,N=x.scissor,I=1),this.getDrawingBufferSize(xg),a1.set(0,0,xg.width,xg.height);const U=C.minDepth===void 0?0:C.minDepth,F=C.maxDepth===void 0?1:C.maxDepth;v.viewportValue.copy(C).multiplyScalar(I).floor(),v.viewportValue.width>>=y,v.viewportValue.height>>=y,v.viewportValue.minDepth=U,v.viewportValue.maxDepth=F,v.viewport=v.viewportValue.equals(a1)===!1,v.scissorValue.copy(N).multiplyScalar(I).floor(),v.scissor=S._scissorTest&&v.scissorValue.equals(a1)===!1,v.scissorValue.width>>=y,v.scissorValue.height>>=y,v.clippingContext||(v.clippingContext=new _b),v.clippingContext.updateGlobal(d,t),d.onBeforeRender(this,e,t,x);const k=t.isArrayCamera?c1:l1;t.isArrayCamera||(xb.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),k.setFromProjectionMatrix(xb,t.coordinateSystem,t.reversedDepth));const G=this._renderLists.get(e,t);if(G.begin(),this._projectObject(e,t,0,G,v.clippingContext),G.finish(),this.sortObjects===!0&&G.sort(this._opaqueSort,this._transparentSort),x!==null){this._textures.updateRenderTarget(x,y);const Te=this._textures.get(x);v.textures=Te.textures,v.depthTexture=Te.depthTexture,v.width=Te.width,v.height=Te.height,v.renderTarget=x,v.depth=x.depthBuffer,v.stencil=x.stencilBuffer}else v.textures=null,v.depthTexture=null,v.width=xg.width,v.height=xg.height,v.depth=this.depth,v.stencil=this.stencil;v.width>>=y,v.height>>=y,v.activeCubeFace=m,v.activeMipmapLevel=y,v.occlusionQueryCount=G.occlusionQueryCount,v.scissorValue.max(fh.set(0,0,0,0)),v.scissorValue.x+v.scissorValue.width>v.width&&(v.scissorValue.width=Math.max(v.width-v.scissorValue.x,0)),v.scissorValue.y+v.scissorValue.height>v.height&&(v.scissorValue.height=Math.max(v.height-v.scissorValue.y,0)),this._background.update(d,G,v),v.camera=t,this.backend.beginRender(v);const{bundles:B,lightsNode:z,transparentDoublePass:Q,transparent:ye,opaque:_e}=G;return B.length>0&&this._renderBundles(B,d,z),this.opaque===!0&&_e.length>0&&this._renderObjects(_e,t,d,z),this.transparent===!0&&ye.length>0&&this._renderTransparents(ye,Q,t,d,z),this.backend.finishRender(v),o.renderId=a,this._currentRenderContext=c,this._currentRenderObjectFunction=u,r!==null&&(this.setRenderTarget(p,m,y),this._renderOutput(x)),d.onAfterRender(this,e,t,x),this.inspector.finishRender(this.backend.getTimestampUID(v)),v}_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 n=this.autoClear,r=this.xr.enabled;this.autoClear=!1,this.xr.enabled=!1,this._renderScene(t,t.camera,!1),this.autoClear=n,this.xr.enabled=r}getMaxAnisotropy(){return this.backend.getMaxAnisotropy()}getActiveCubeFace(){return this._activeCubeFace}getActiveMipmapLevel(){return this._activeMipmapLevel}setAnimationLoop(e){return mn(this,null,function*(){this._initialized===!1&&(yield this.init()),this._animation.setAnimationLoop(e)})}getAnimationLoop(){return this._animation.getAnimationLoop()}getArrayBufferAsync(e){return mn(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,n){this.xr&&this.xr.isPresenting||this._canvasTarget.setDrawingBufferSize(e,t,n)}setSize(e,t,n=!0){this.xr&&this.xr.isPresenting||this._canvasTarget.setSize(e,t,n)}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){return this._canvasTarget.getScissor(e)}setScissor(e,t,n,r){this._canvasTarget.setScissor(e,t,n,r)}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,n,r,o=0,a=1){this._canvasTarget.setViewport(e,t,n,r,o,a)}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,n=!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 r=this._renderTarget||this._getFrameBufferTarget();let o=null;if(r!==null){this._textures.updateRenderTarget(r);const a=this._textures.get(r);o=this._renderContexts.getForClear(r),o.textures=a.textures,o.depthTexture=a.depthTexture,o.width=a.width,o.height=a.height,o.renderTarget=r,o.depth=r.depthBuffer,o.stencil=r.stencilBuffer,o.clearColorValue=this.backend.getClearColor(),o.activeCubeFace=this.getActiveCubeFace(),o.activeMipmapLevel=this.getActiveMipmapLevel()}this.backend.clear(e,t,n,o),r!==null&&this._renderTarget===null&&this._renderOutput(r)}clearColor(){this.clear(!0,!1,!1)}clearDepth(){this.clear(!1,!0,!1)}clearStencil(){this.clear(!1,!1,!0)}clearAsync(e=!0,t=!0,n=!0){return mn(this,null,function*(){Ut('Renderer: "clearAsync()" has been deprecated. Use "clear()" and "await renderer.init();" when creating the renderer.'),yield this.init(),this.clear(e,t,n)})}clearColorAsync(){return mn(this,null,function*(){Ut('Renderer: "clearColorAsync()" has been deprecated. Use "clearColor()" and "await renderer.init();" when creating the renderer.'),this.clear(!0,!1,!1)})}clearDepthAsync(){return mn(this,null,function*(){Ut('Renderer: "clearDepthAsync()" has been deprecated. Use "clearDepth()" and "await renderer.init();" when creating the renderer.'),this.clear(!1,!0,!1)})}clearStencilAsync(){return mn(this,null,function*(){Ut('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!==yr,t=this.currentColorSpace!==xn.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:yr}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:xn.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,n=0){this._renderTarget=e,this._activeCubeFace=t,this._activeMipmapLevel=n}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 Ie("Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e,t);const n=this._nodes.nodeFrame,r=n.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,n.renderId=this.info.calls,this.backend.updateTimeStampUID(e),this.inspector.beginCompute(this.backend.getTimestampUID(e),e);const o=this.backend,a=this._pipelines,c=this._bindings,u=this._nodes,d=Array.isArray(e)?e:[e];if(d[0]===void 0||d[0].isComputeNode!==!0)throw new Error("THREE.Renderer: .compute() expects a ComputeNode.");o.beginCompute(e);for(const p of d){if(a.has(p)===!1){const x=()=>{p.removeEventListener("dispose",x),a.delete(p),c.deleteForCompute(p),u.delete(p)};p.addEventListener("dispose",x);const v=p.onInitFunction;v!==null&&v.call(p,{renderer:this})}u.updateForCompute(p),c.updateForCompute(p);const m=c.getForCompute(p),y=a.getForCompute(p,m);o.compute(e,p,m,y,t)}o.finishCompute(e),n.renderId=r,this.inspector.finishCompute(this.backend.getTimestampUID(e))}computeAsync(e,t=null){return mn(this,null,function*(){this._initialized===!1&&(yield this.init()),this.compute(e,t)})}hasFeatureAsync(e){return mn(this,null,function*(){return Ut('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 mn(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 mn(this,null,function*(){Ut('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=fh.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=fh.copy(t).floor();else{Be("Renderer.copyFramebufferToTexture: Invalid rectangle.");return}else t=fh.set(0,0,e.image.width,e.image.height);let n=this._currentRenderContext,r;n!==null?r=n.renderTarget:(r=this._renderTarget||this._getFrameBufferTarget(),r!==null&&(this._textures.updateRenderTarget(r),n=this._textures.get(r))),this._textures.updateTexture(e,{renderTarget:r}),this.backend.copyFramebufferToTexture(e,n,t),this._inspector.copyFramebufferToTexture(e)}copyTextureToTexture(e,t,n=null,r=null,o=0,a=0){this._textures.updateTexture(e),this._textures.updateTexture(t),this.backend.copyTextureToTexture(e,t,n,r,o,a),this._inspector.copyTextureToTexture(e,t)}readRenderTargetPixelsAsync(e,t,n,r,o,a=0,c=0){return mn(this,null,function*(){return this.backend.copyTextureToBuffer(e.textures[a],t,n,r,o,c)})}_projectObject(e,t,n,r,o){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder,e.isClippingGroup&&e.enabled&&(o=o.getGroupContext(e));else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)r.pushLight(e);else if(e.isSprite){const u=t.isArrayCamera?c1:l1;if(!e.frustumCulled||u.intersectsSprite(e,t)){this.sortObjects===!0&&fh.setFromMatrixPosition(e.matrixWorld).applyMatrix4(xb);const{geometry:d,material:p}=e;p.visible&&r.push(e,d,p,n,fh.z,null,o)}}else if(e.isLineLoop)Be("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 u=t.isArrayCamera?c1:l1;if(!e.frustumCulled||u.intersectsObject(e,t)){const{geometry:d,material:p}=e;if(this.sortObjects===!0&&(d.boundingSphere===null&&d.computeBoundingSphere(),fh.copy(d.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(xb)),Array.isArray(p)){const m=d.groups;for(let y=0,x=m.length;y<x;y++){const v=m[y],w=p[v.materialIndex];w&&w.visible&&r.push(e,d,w,n,fh.z,v,o)}}else p.visible&&r.push(e,d,p,n,fh.z,null,o)}}}if(e.isBundleGroup===!0&&this.backend.beginBundle!==void 0){const u=r;r=this._renderLists.get(e,t),r.begin(),u.pushBundle({bundleGroup:e,camera:t,renderList:r}),r.finish()}const c=e.children;for(let u=0,d=c.length;u<d;u++)this._projectObject(c[u],t,n,r,o)}_renderBundles(e,t,n){for(const r of e)this._renderBundle(r,t,n)}_renderTransparents(e,t,n,r,o){if(t.length>0){for(const{material:a}of t)a.side=we;this._renderObjects(t,n,r,o,"backSide");for(const{material:a}of t)a.side=Me;this._renderObjects(e,n,r,o);for(const{material:a}of t)a.side=Ae}else this._renderObjects(e,n,r,o)}_renderObjects(e,t,n,r,o=null){for(let a=0,c=e.length;a<c;a++){const{object:u,geometry:d,material:p,group:m,clippingContext:y}=e[a];this._currentRenderObjectFunction(u,n,t,d,p,m,r,y,o)}}_getShadowNodes(e){const t=e.version;let n=this._cacheShadowNodes.get(e);if(n===void 0||n.version!==t){const r=e.map!==null,o=e.colorNode&&e.colorNode.isNode,a=e.castShadowNode&&e.castShadowNode.isNode;let c=null,u=null,d=null;if(r||o||a){let p,m;a?(p=e.castShadowNode.rgb,m=e.castShadowNode.a):(p=he(0),m=q(1)),r&&(m=m.mul(Oi("map","texture",e).a)),o&&(m=m.mul(e.colorNode.a)),u=zt(p,m)}e.depthNode&&e.depthNode.isNode&&(d=e.depthNode),e.castShadowPositionNode&&e.castShadowPositionNode.isNode?c=e.castShadowPositionNode:e.positionNode&&e.positionNode.isNode&&(c=e.positionNode),n={version:t,colorNode:u,depthNode:d,positionNode:c},this._cacheShadowNodes.set(e,n)}return n}renderObject(e,t,n,r,o,a,c,u=null,d=null){let p=!1,m,y,x,v;if(e.onBeforeRender(this,t,n,r,o,a),o.allowOverride===!0&&t.overrideMaterial!==null){const w=t.overrideMaterial;if(p=!0,m=t.overrideMaterial.colorNode,y=t.overrideMaterial.depthNode,x=t.overrideMaterial.positionNode,v=t.overrideMaterial.side,o.positionNode&&o.positionNode.isNode&&(w.positionNode=o.positionNode),w.alphaTest=o.alphaTest,w.alphaMap=o.alphaMap,w.transparent=o.transparent||o.transmission>0||o.transmissionNode&&o.transmissionNode.isNode||o.backdropNode&&o.backdropNode.isNode,w.isShadowPassMaterial){const{colorNode:M,depthNode:S,positionNode:C}=this._getShadowNodes(o);w.side=o.shadowSide===null?o.side:o.shadowSide,M!==null&&(w.colorNode=M),S!==null&&(w.depthNode=S),C!==null&&(w.positionNode=C)}o=w}o.transparent===!0&&o.side===Ae&&o.forceSinglePass===!1?(o.side=we,this._handleObjectFunction(e,o,t,n,c,a,u,"backSide"),o.side=Me,this._handleObjectFunction(e,o,t,n,c,a,u,d),o.side=Ae):this._handleObjectFunction(e,o,t,n,c,a,u,d),p&&(t.overrideMaterial.colorNode=m,t.overrideMaterial.depthNode=y,t.overrideMaterial.positionNode=x,t.overrideMaterial.side=v),e.onAfterRender(this,t,n,r,o,a)}_renderObjectDirect(e,t,n,r,o,a,c,u){const d=this._objects.get(e,t,n,r,o,this._currentRenderContext,c,u);d.drawRange=e.geometry.drawRange,d.group=a;const p=this._nodes.needsRefresh(d);p&&(this._nodes.updateBefore(d),this._geometries.updateForRender(d),this._nodes.updateForRender(d),this._bindings.updateForRender(d)),this._pipelines.updateForRender(d),this._currentRenderBundle!==null&&(this.backend.get(this._currentRenderBundle).renderObjects.push(d),d.bundle=this._currentRenderBundle.bundleGroup),this.backend.draw(d,this.info),p&&this._nodes.updateAfter(d)}_createObjectPipeline(e,t,n,r,o,a,c,u){const d=this._objects.get(e,t,n,r,o,this._currentRenderContext,c,u);d.drawRange=e.geometry.drawRange,d.group=a,this._nodes.updateBefore(d),this._geometries.updateForRender(d),this._nodes.updateForRender(d),this._bindings.updateForRender(d),this._pipelines.getForRender(d,this._compilationPromises),this._nodes.updateAfter(d)}_onCanvasTargetResize(){this._initialized&&this.backend.updateSize()}get compile(){return this.compileAsync}}class C2{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}getVisibility(){return this.visibility}clone(){return Object.assign(new this.constructor,this)}}function V9(i){return i+(Yd-i%Yd)%Yd}class R2 extends C2{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t,this._updateRanges=[]}get updateRanges(){return this._updateRanges}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}get byteLength(){return V9(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}}class N2 extends R2{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let G9=0;class P2 extends N2{constructor(e,t){super("UniformBuffer_"+G9++,e?e.value:null),this.nodeUniform=e,this.groupNode=t,this.isNodeUniformBuffer=!0}set updateRanges(e){this.nodeUniform.updateRanges=e}get updateRanges(){return this.nodeUniform.updateRanges}addUpdateRange(e,t){this.nodeUniform.addUpdateRange(e,t)}clearUpdateRanges(){this.nodeUniform.clearUpdateRanges()}get buffer(){return this.nodeUniform.value}}class W9 extends N2{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 n=0,r=this.uniforms.length;n<r;n++){const o=this.uniforms[n],a=o.boundary,c=o.itemSize*e,u=t%Yd,d=u%a,p=u+d;t+=d,p!==0&&Yd-p<c&&(t+=Yd-p),o.offset=t/e,t+=c}return Math.ceil(t/Yd)*Yd}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);Be("WebGPUUniformsGroup: Unsupported uniform type.",e)}updateNumber(e){let t=!1;const n=this.values,r=e.getValue(),o=e.offset,a=e.getType();if(n[o]!==r){const c=this._getBufferForType(a);c[o]=n[o]=r,t=!0}return t}updateVector2(e){let t=!1;const n=this.values,r=e.getValue(),o=e.offset,a=e.getType();if(n[o+0]!==r.x||n[o+1]!==r.y){const c=this._getBufferForType(a);c[o+0]=n[o+0]=r.x,c[o+1]=n[o+1]=r.y,t=!0}return t}updateVector3(e){let t=!1;const n=this.values,r=e.getValue(),o=e.offset,a=e.getType();if(n[o+0]!==r.x||n[o+1]!==r.y||n[o+2]!==r.z){const c=this._getBufferForType(a);c[o+0]=n[o+0]=r.x,c[o+1]=n[o+1]=r.y,c[o+2]=n[o+2]=r.z,t=!0}return t}updateVector4(e){let t=!1;const n=this.values,r=e.getValue(),o=e.offset,a=e.getType();if(n[o+0]!==r.x||n[o+1]!==r.y||n[o+2]!==r.z||n[o+4]!==r.w){const c=this._getBufferForType(a);c[o+0]=n[o+0]=r.x,c[o+1]=n[o+1]=r.y,c[o+2]=n[o+2]=r.z,c[o+3]=n[o+3]=r.w,t=!0}return t}updateColor(e){let t=!1;const n=this.values,r=e.getValue(),o=e.offset;if(n[o+0]!==r.r||n[o+1]!==r.g||n[o+2]!==r.b){const a=this.buffer;a[o+0]=n[o+0]=r.r,a[o+1]=n[o+1]=r.g,a[o+2]=n[o+2]=r.b,t=!0}return t}updateMatrix3(e){let t=!1;const n=this.values,r=e.getValue().elements,o=e.offset;if(n[o+0]!==r[0]||n[o+1]!==r[1]||n[o+2]!==r[2]||n[o+4]!==r[3]||n[o+5]!==r[4]||n[o+6]!==r[5]||n[o+8]!==r[6]||n[o+9]!==r[7]||n[o+10]!==r[8]){const a=this.buffer;a[o+0]=n[o+0]=r[0],a[o+1]=n[o+1]=r[1],a[o+2]=n[o+2]=r[2],a[o+4]=n[o+4]=r[3],a[o+5]=n[o+5]=r[4],a[o+6]=n[o+6]=r[5],a[o+8]=n[o+8]=r[6],a[o+9]=n[o+9]=r[7],a[o+10]=n[o+10]=r[8],t=!0}return t}updateMatrix4(e){let t=!1;const n=this.values,r=e.getValue().elements,o=e.offset;return $9(n,r,o)===!1&&(this.buffer.set(r,o),H9(n,r,o),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 H9(i,e,t){for(let n=0,r=e.length;n<r;n++)i[t+n]=e[n]}function $9(i,e,t){for(let n=0,r=e.length;n<r;n++)if(i[t+n]!==e[n])return!1;return!0}let q9=0;class I2 extends W9{constructor(e,t){super(e),this.id=q9++,this.groupNode=t,this.isNodeUniformsGroup=!0}}class L2 extends C2{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 X9=0;class j9 extends L2{constructor(e,t){super(e,t),this.id=X9++,this.store=!1,this.mipLevel=0,this.isSampledTexture=!0}}class vb extends j9{constructor(e,t,n,r=null){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n,this.access=r}update(){const{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update()}}class D2 extends vb{constructor(e,t,n,r=null){super(e,t,n,r),this.isSampledCubeTexture=!0}}class u1 extends vb{constructor(e,t,n,r=null){super(e,t,n,r),this.isSampledTexture3D=!0}}const F2={bitcast_int_uint:new Ar("uint tsl_bitcast_int_to_uint ( int x ) { return floatBitsToUint( intBitsToFloat ( x ) ); }"),bitcast_uint_int:new Ar("uint tsl_bitcast_uint_to_int ( uint x ) { return floatBitsToInt( uintBitsToFloat ( x ) ); }")},Y9={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",floatpack_snorm_2x16:"packSnorm2x16",floatpack_unorm_2x16:"packUnorm2x16",floatpack_float16_2x16:"packHalf2x16",floatunpack_snorm_2x16:"unpackSnorm2x16",floatunpack_unorm_2x16:"unpackUnorm2x16",floatunpack_float16_2x16:"unpackHalf2x16"},Z9={low:"lowp",medium:"mediump",high:"highp"},B2={swizzleAssign:!0,storageBuffer:!1},O2={perspective:"smooth",linear:"noperspective"},U2={centroid:"centroid"},k2=`
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 K9 extends _2{constructor(e,t){super(e,t,new w9),this.uniformGroups={},this.transforms=[],this.extensions={},this.builtins={vertex:[],fragment:[],compute:[]}}needsToWorkingColorSpace(e){return e.isVideoTexture===!0&&e.colorSpace!==_r}_include(e){const t=F2[e];return t.build(this),this.addInclude(t),t}getMethod(e){return F2[e]!==void 0&&this._include(e),Y9[e]||e}getBitcastMethod(e,t){return this.getMethod(`bitcast_${t}_${e}`)}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}getTernary(e,t,n){return`${e} ? ${t} : ${n}`}getOutputStructName(){return""}buildFunctionCode(e){const t=e.layout,n=this.flowShaderNode(e),r=[];for(const a of t.inputs)r.push(this.getType(a.type)+" "+a.name);return`${this.getType(t.type)} ${t.name}( ${r.join(", ")} ) {
${n.vars}
${n.code}
return ${n.result};
}`}setupPBO(e){const t=e.value;if(t.pbo===void 0){const n=t.array,r=t.count*t.itemSize,{itemSize:o}=t,a=t.array.constructor.name.toLowerCase().includes("int");let c=a?Bl:Qc;o===2?c=a?xh:Nr:o===3?c=a?iA:tf:o===4&&(c=a?vh:Ri);const u={Float32Array:Si,Uint8Array:Di,Uint16Array:jo,Uint32Array:yi,Int8Array:Kc,Int16Array:Jc,Int32Array:er,Uint8ClampedArray:Di},d=Math.pow(2,Math.ceil(Math.log2(Math.sqrt(r/o))));let p=Math.ceil(r/o/d);d*p*o<r&&p++;const m=d*p*o,y=new n.constructor(m);y.set(n,0),t.array=y;const x=new co(t.array,d,p,c,u[t.array.constructor.name]||Si);x.needsUpdate=!0,x.isPBOTexture=!0;const v=new Ic(x,null,null);v.setPrecision("high"),t.pboNode=v,t.pbo=v.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:n}=e,r=t.value;if(this.renderer.backend.has(r)){const p=this.renderer.backend.get(r);p.pbo=r.pbo}const o=this.getUniformFromNode(r.pboNode,"texture",this.shaderStage,this.context.nodeName),a=this.getPropertyName(o);this.increaseUsage(n);const c=n.build(this,"uint"),u=this.getDataFromNode(e);let d=u.propertyName;if(d===void 0){const p=this.getVarFromNode(e);d=this.getPropertyName(p);const m=this.getDataFromNode(t);let y=m.propertySizeName;y===void 0&&(y=d+"Size",this.getVarFromNode(t,y,"uint"),this.addLineFlowCode(`${y} = uint( textureSize( ${a}, 0 ).x )`,e),m.propertySizeName=y);const{itemSize:x}=r,v="."+Jf.join("").slice(0,x),w=`ivec2(${c} % ${y}, ${c} / ${y})`,M=this.generateTextureLoad(null,a,w,"0",null,null);let S="vec4";r.pbo.type===yi?S="uvec4":r.pbo.type===er&&(S="ivec4"),this.addLineFlowCode(`${d} = ${S}(${M})${v}`,e),u.propertyName=d}return d}generateTextureLoad(e,t,n,r,o,a){r===null&&(r="0");let c;return o?a?c=`texelFetchOffset( ${t}, ivec3( ${n}, ${o} ), ${r}, ${a} )`:c=`texelFetch( ${t}, ivec3( ${n}, ${o} ), ${r} )`:a?c=`texelFetchOffset( ${t}, ${n}, ${r}, ${a} )`:c=`texelFetch( ${t}, ${n}, ${r} )`,e!==null&&e.isDepthTexture&&(c+=".x"),c}generateTexture(e,t,n,r,o){return r&&(n=`vec3( ${n}, ${r} )`),e.isDepthTexture?o?`textureOffset( ${t}, ${n}, ${o} ).x`:`texture( ${t}, ${n} ).x`:o?`textureOffset( ${t}, ${n}, ${o} )`:`texture( ${t}, ${n} )`}generateTextureLevel(e,t,n,r,o){return o?`textureLodOffset( ${t}, ${n}, ${r}, ${o} )`:`textureLod( ${t}, ${n}, ${r} )`}generateTextureBias(e,t,n,r,o){return o?`textureOffset( ${t}, ${n}, ${o}, ${r} )`:`texture( ${t}, ${n}, ${r} )`}generateTextureGrad(e,t,n,r,o){return o?`textureGradOffset( ${t}, ${n}, ${r[0]}, ${r[1]}, ${o} )`:`textureGrad( ${t}, ${n}, ${r[0]}, ${r[1]} )`}generateTextureCompare(e,t,n,r,o,a,c=this.shaderStage){if(c==="fragment")return e.isCubeTexture?`texture( ${t}, vec4( ${n}, ${r} ) )`:o?a?`textureOffset( ${t}, vec4( ${n}, ${o}, ${r} ), ${a} )`:`texture( ${t}, vec4( ${n}, ${o}, ${r} ) )`:a?`textureOffset( ${t}, vec3( ${n}, ${r} ), ${a} )`:`texture( ${t}, vec3( ${n}, ${r} ) )`;Be(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${c} shader.`)}getVars(e){const t=[],n=this.vars[e];if(n!==void 0)for(const r of n)t.push(`${this.getVar(r.type,r.name,r.count)};`);return t.join(`
`)}getUniforms(e){const t=this.uniforms[e],n=[],r={};for(const a of t){let c=null,u=!1;if(a.type==="texture"||a.type==="texture3D"){const p=a.node.value;let m="";(p.isDataTexture===!0||p.isData3DTexture===!0)&&(p.type===yi?m="u":p.type===er&&(m="i")),a.type==="texture3D"&&p.isArrayTexture===!1?c=`${m}sampler3D ${a.name};`:p.compareFunction?p.isArrayTexture===!0?c=`sampler2DArrayShadow ${a.name};`:c=`sampler2DShadow ${a.name};`:p.isArrayTexture===!0||p.isDataArrayTexture===!0||p.isCompressedArrayTexture===!0?c=`${m}sampler2DArray ${a.name};`:c=`${m}sampler2D ${a.name};`}else if(a.type==="cubeTexture")c=`samplerCube ${a.name};`;else if(a.type==="cubeDepthTexture")c=`samplerCubeShadow ${a.name};`;else if(a.type==="buffer"){const p=a.node,m=this.getType(p.bufferType),y=p.bufferCount,x=y>0?y:"";c=`${p.name} {
${m} ${a.name}[${x}];
};
`}else c=`${this.getVectorType(a.type)} ${this.getPropertyName(a,e)};`,u=!0;const d=a.node.precision;if(d!==null&&(c=Z9[d]+" "+c),u){c=" "+c;const p=a.groupNode.name;(r[p]||(r[p]=[])).push(c)}else c="uniform "+c,n.push(c)}let o="";for(const a in r){const c=r[a];o+=this._getGLSLUniformStruct(e+"_"+a,c.join(`
`))+`
`}return o+=n.join(`
`),o}getTypeFromAttribute(e){let t=super.getTypeFromAttribute(e);if(/^[iu]/.test(t)&&e.gpuType!==er){let n=e;e.isInterleavedBufferAttribute&&(n=e.data);const r=n.array;r instanceof Uint32Array||r instanceof Int32Array||(t=t.slice(1))}return t}getAttributes(e){let t="";if(e==="vertex"||e==="compute"){const n=this.getAttributesArray();let r=0;for(const o of n)t+=`layout( location = ${r++} ) in ${o.type} ${o.name};
`}return t}getStructMembers(e){const t=[];for(const n of e.members)t.push(` ${n.type} ${n.name};`);return t.join(`
`)}getStructs(e){const t=[],n=this.structs[e],r=[];for(const o of n)if(o.output)for(const a of o.members)r.push(`layout( location = ${a.index} ) out ${a.type} ${a.name};`);else{let a="struct "+o.name+` {
`;a+=this.getStructMembers(o),a+=`
};
`,t.push(a)}return r.length===0&&r.push("layout( location = 0 ) out vec4 fragColor;"),`
`+r.join(`
`)+`
`+t.join(`
`)}getVaryings(e){let t="";const n=this.varyings;if(e==="vertex"||e==="compute")for(const r of n){e==="compute"&&(r.needsInterpolation=!0);const o=this.getType(r.type);if(r.needsInterpolation)if(r.interpolationType){const a=O2[r.interpolationType]||r.interpolationType,c=U2[r.interpolationSampling]||"";t+=`${a} ${c} out ${o} ${r.name};
`}else{const a=o.includes("int")||o.includes("uv")||o.includes("iv")?"flat ":"";t+=`${a}out ${o} ${r.name};
`}else t+=`${o} ${r.name};
`}else if(e==="fragment"){for(const r of n)if(r.needsInterpolation){const o=this.getType(r.type);if(r.interpolationType){const a=O2[r.interpolationType]||r.interpolationType,c=U2[r.interpolationSampling]||"";t+=`${a} ${c} in ${o} ${r.name};
`}else{const a=o.includes("int")||o.includes("uv")||o.includes("iv")?"flat ":"";t+=`${a}in ${o} ${r.name};
`}}}for(const r of this.builtins[e])t+=`${r};
`;return t}getVertexIndex(){return"uint( gl_VertexID )"}getInstanceIndex(){return"uint( gl_InstanceID )"}getInvocationLocalIndex(){return`uint( gl_InstanceID ) % ${this.object.workgroupSize.reduce((n,r)=>n*r,1)}u`}getSubgroupSize(){Be("GLSLNodeBuilder: WebGLBackend does not support the subgroupSize node")}getInvocationSubgroupIndex(){Be("GLSLNodeBuilder: WebGLBackend does not support the invocationSubgroupIndex node")}getSubgroupIndex(){Be("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,n=this.shaderStage){const r=this.extensions[n]||(this.extensions[n]=new Map);r.has(e)===!1&&r.set(e,{name:e,behavior:t})}getExtensions(e){const t=[];if(e==="vertex"){const r=this.renderer.backend.extensions;this.object.isBatchedMesh&&r.has("WEBGL_multi_draw")&&this.enableExtension("GL_ANGLE_multi_draw","require",e)}const n=this.extensions[e];if(n!==void 0)for(const{name:r,behavior:o}of n.values())t.push(`#extension ${r} : ${o}`);return t.join(`
`)}getClipDistance(){return"gl_ClipDistance"}isAvailable(e){let t=B2[e];if(t===void 0){let n;switch(t=!1,e){case"float32Filterable":n="OES_texture_float_linear";break;case"clipDistance":n="WEBGL_clip_cull_distance";break}if(n!==void 0){const r=this.renderer.backend.extensions;r.has(n)&&(r.get(n),t=!0)}B2[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 n=0;n<e.length;n++){const r=e[n],o=this.getPropertyName(r.attributeNode);o&&(t+=`${r.varyingName} = ${o};
`)}return t}_getGLSLUniformStruct(e,t){return`
layout( std140 ) uniform ${e} {
${t}
};`}_getGLSLVertexCode(e){return`#version 300 es
${this.getSignature()}
// extensions
${e.extensions}
// precision
${k2}
// 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
${k2}
// 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 n=`// code
`;n+=this.flowCode[t];const r=this.flowNodes[t],o=r[r.length-1];for(const c of r){const u=this.getFlowData(c),d=c.name;d&&(n.length>0&&(n+=`
`),n+=` // flow -> ${d}
`),n+=`${u.code}
`,c===o&&t!=="compute"&&(n+=`// result
`,t==="vertex"?(n+="gl_Position = ",n+=`${u.result};`):t==="fragment"&&(c.outputNode.isOutputStructNode||(n+="fragColor = ",n+=`${u.result};`)))}const a=e[t];a.extensions=this.getExtensions(t),a.uniforms=this.getUniforms(t),a.attributes=this.getAttributes(t),a.varyings=this.getVaryings(t),a.vars=this.getVars(t),a.structs=this.getStructs(t),a.codes=this.getCodes(t),a.transforms=this.getTransforms(t),a.flow=n}this.material!==null?(this.vertexShader=this._getGLSLVertexCode(e.vertex),this.fragmentShader=this._getGLSLFragmentCode(e.fragment)):this.computeShader=this._getGLSLVertexCode(e.compute)}getUniformFromNode(e,t,n,r=null){const o=super.getUniformFromNode(e,t,n,r),a=this.getDataFromNode(e,n,this.globalCache);let c=a.uniformGPU;if(c===void 0){const u=e.groupNode,d=u.name,p=this.getBindGroupArray(d,n);if(t==="texture")c=new vb(o.name,o.node,u),p.push(c);else if(t==="cubeTexture"||t==="cubeDepthTexture")c=new D2(o.name,o.node,u),p.push(c);else if(t==="texture3D")c=new u1(o.name,o.node,u),p.push(c);else if(t==="buffer"){o.name=`buffer${e.id}`;const m=this.getSharedDataFromNode(e);let y=m.buffer;y===void 0&&(e.name=`NodeBuffer_${e.id}`,y=new P2(e,u),y.name=e.name,m.buffer=y),p.push(y),c=y}else{const m=this.uniformGroups[n]||(this.uniformGroups[n]={});let y=m[d];y===void 0&&(y=new I2(n+"_"+d,u),m[d]=y,p.push(y)),c=this.getNodeUniform(o,t),y.addUniform(c)}a.uniformGPU=c}return o}}let h1=null,vg=null;class z2{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={[ol.RENDER]:null,[ol.COMPUTE]:null},this.trackTimestamp=e.trackTimestamp===!0}init(e){return mn(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 mn(this,null,function*(){})}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}updateTimeStampUID(e){const t=this.get(e),n=this.renderer.info.frame;let r;e.isComputeNode===!0?r="c:"+this.renderer.info.compute.frameCalls:r="r:"+this.renderer.info.render.frameCalls,t.timestampUID=r+":"+e.id+":f"+n}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:")?ol.COMPUTE:ol.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 mn(this,null,function*(){if(!this.trackTimestamp){Ut("WebGPURenderer: Timestamp tracking is disabled.");return}const t=this.timestampQueryPool[e];if(!t)return;const n=yield t.resolveQueriesAsync();return this.renderer.info[e].timestamp=n,n})}getArrayBufferAsync(){return mn(this,null,function*(){})}hasFeatureAsync(){return mn(this,null,function*(){})}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return h1=h1||new ze,this.renderer.getDrawingBufferSize(h1)}setScissorTest(){}getClearColor(){const e=this.renderer;return vg=vg||new Ew,e.getClearColor(vg),vg.getRGB(vg),vg}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas!==void 0?this.parameters.canvas:Bg(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${xe} 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)}deleteBindGroupData(){}dispose(){}}let J9=0;class Q9{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 e${constructor(e){this.backend=e}createAttribute(e,t){const n=this.backend,{gl:r}=n,o=e.array,a=e.usage||r.STATIC_DRAW,c=e.isInterleavedBufferAttribute?e.data:e,u=n.get(c);let d=u.bufferGPU;d===void 0&&(d=this._createBuffer(r,t,o,a),u.bufferGPU=d,u.bufferType=t,u.version=c.version);let p;if(o instanceof Float32Array)p=r.FLOAT;else if(typeof Float16Array!="undefined"&&o instanceof Float16Array)p=r.HALF_FLOAT;else if(o instanceof Uint16Array)e.isFloat16BufferAttribute?p=r.HALF_FLOAT:p=r.UNSIGNED_SHORT;else if(o instanceof Int16Array)p=r.SHORT;else if(o instanceof Uint32Array)p=r.UNSIGNED_INT;else if(o instanceof Int32Array)p=r.INT;else if(o instanceof Int8Array)p=r.BYTE;else if(o instanceof Uint8Array)p=r.UNSIGNED_BYTE;else if(o instanceof Uint8ClampedArray)p=r.UNSIGNED_BYTE;else throw new Error("THREE.WebGLBackend: Unsupported buffer data format: "+o);let m={bufferGPU:d,bufferType:t,type:p,byteLength:o.byteLength,bytesPerElement:o.BYTES_PER_ELEMENT,version:e.version,pbo:e.pbo,isInteger:p===r.INT||p===r.UNSIGNED_INT||e.gpuType===er,id:J9++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const y=this._createBuffer(r,t,o,a);m=new Q9(m,y)}n.set(e,m)}updateAttribute(e){const t=this.backend,{gl:n}=t,r=e.array,o=e.isInterleavedBufferAttribute?e.data:e,a=t.get(o),c=a.bufferType,u=e.isInterleavedBufferAttribute?e.data.updateRanges:e.updateRanges;if(n.bindBuffer(c,a.bufferGPU),u.length===0)n.bufferSubData(c,0,r);else{for(let d=0,p=u.length;d<p;d++){const m=u[d];n.bufferSubData(c,m.start*r.BYTES_PER_ELEMENT,r,m.start,m.count)}o.clearUpdateRanges()}n.bindBuffer(c,null),a.version=o.version}destroyAttribute(e){const t=this.backend,{gl:n}=t;e.isInterleavedBufferAttribute&&t.delete(e.data);const r=t.get(e);n.deleteBuffer(r.bufferGPU),t.delete(e)}getArrayBufferAsync(e){return mn(this,null,function*(){const t=this.backend,{gl:n}=t,r=e.isInterleavedBufferAttribute?e.data:e,{bufferGPU:o}=t.get(r),a=e.array,c=a.byteLength;n.bindBuffer(n.COPY_READ_BUFFER,o);const u=n.createBuffer();n.bindBuffer(n.COPY_WRITE_BUFFER,u),n.bufferData(n.COPY_WRITE_BUFFER,c,n.STREAM_READ),n.copyBufferSubData(n.COPY_READ_BUFFER,n.COPY_WRITE_BUFFER,0,0,c),yield t.utils._clientWaitAsync();const d=new e.array.constructor(a.length);return n.bindBuffer(n.COPY_WRITE_BUFFER,u),n.getBufferSubData(n.COPY_WRITE_BUFFER,0,d),n.deleteBuffer(u),n.bindBuffer(n.COPY_READ_BUFFER,null),n.bindBuffer(n.COPY_WRITE_BUFFER,null),d.buffer})}_createBuffer(e,t,n,r){const o=e.createBuffer();return e.bindBuffer(t,o),e.bufferData(t,n,r),e.bindBuffer(t,null),o}}let d1,Yy;class t${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;d1={[nt]:e.FUNC_ADD,[tt]:e.FUNC_SUBTRACT,[at]:e.FUNC_REVERSE_SUBTRACT},Yy={[Sn]:e.ZERO,[Cn]:e.ONE,[Pn]:e.SRC_COLOR,[Rn]:e.SRC_ALPHA,[$n]:e.SRC_ALPHA_SATURATE,[gt]:e.DST_COLOR,[tn]:e.DST_ALPHA,[Rt]:e.ONE_MINUS_SRC_COLOR,[Jt]:e.ONE_MINUS_SRC_ALPHA,[hn]:e.ONE_MINUS_DST_COLOR,[xi]:e.ONE_MINUS_DST_ALPHA};const t=e.getParameter(e.SCISSOR_BOX),n=e.getParameter(e.VIEWPORT);this.currentScissor=new gn().fromArray(t),this.currentViewport=new gn().fromArray(n),this._tempVec4=new gn}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!==$?(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===J?t.cullFace(t.BACK):e===j?t.cullFace(t.FRONT):t.cullFace(t.FRONT_AND_BACK))):this.disable(t.CULL_FACE),this.currentCullFace=e}setLineWidth(e){const{currentLineWidth:t,gl:n}=this;e!==t&&(n.lineWidth(e),this.currentLineWidth=e)}setMRTBlending(e){const t=this.gl,n=this.backend.drawBuffersIndexedExt;if(n)for(let r=1;r<e.length;r++)n.blendFuncSeparateiOES(r,t.ONE,t.ZERO,t.ONE,t.ZERO)}setBlending(e,t,n,r,o,a,c,u){const{gl:d}=this;if(e===ve){this.currentBlendingEnabled===!0&&(this.disable(d.BLEND),this.currentBlendingEnabled=!1);return}if(this.currentBlendingEnabled===!1&&(this.enable(d.BLEND),this.currentBlendingEnabled=!0),e!==ut){if(e!==this.currentBlending||u!==this.currentPremultipledAlpha){if((this.currentBlendEquation!==nt||this.currentBlendEquationAlpha!==nt)&&(d.blendEquation(d.FUNC_ADD),this.currentBlendEquation=nt,this.currentBlendEquationAlpha=nt),u)switch(e){case Ue:d.blendFuncSeparate(d.ONE,d.ONE_MINUS_SRC_ALPHA,d.ONE,d.ONE_MINUS_SRC_ALPHA);break;case Je:d.blendFunc(d.ONE,d.ONE);break;case Ye:d.blendFuncSeparate(d.ZERO,d.ONE_MINUS_SRC_COLOR,d.ZERO,d.ONE);break;case Ke:d.blendFuncSeparate(d.DST_COLOR,d.ONE_MINUS_SRC_ALPHA,d.ZERO,d.ONE);break;default:Be("WebGLState: Invalid blending: ",e);break}else switch(e){case Ue:d.blendFuncSeparate(d.SRC_ALPHA,d.ONE_MINUS_SRC_ALPHA,d.ONE,d.ONE_MINUS_SRC_ALPHA);break;case Je:d.blendFuncSeparate(d.SRC_ALPHA,d.ONE,d.ONE,d.ONE);break;case Ye:Be("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Ke:Be("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Be("WebGLState: Invalid blending: ",e);break}this.currentBlendSrc=null,this.currentBlendDst=null,this.currentBlendSrcAlpha=null,this.currentBlendDstAlpha=null,this.currentBlending=e,this.currentPremultipledAlpha=u}return}o=o||t,a=a||n,c=c||r,(t!==this.currentBlendEquation||o!==this.currentBlendEquationAlpha)&&(d.blendEquationSeparate(d1[t],d1[o]),this.currentBlendEquation=t,this.currentBlendEquationAlpha=o),(n!==this.currentBlendSrc||r!==this.currentBlendDst||a!==this.currentBlendSrcAlpha||c!==this.currentBlendDstAlpha)&&(d.blendFuncSeparate(Yy[n],Yy[r],Yy[a],Yy[c]),this.currentBlendSrc=n,this.currentBlendDst=r,this.currentBlendSrcAlpha=a,this.currentBlendDstAlpha=c),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 nl:t.depthFunc(t.NEVER);break;case zn:t.depthFunc(t.ALWAYS);break;case Ci:t.depthFunc(t.LESS);break;case no:t.depthFunc(t.LEQUAL);break;case $c:t.depthFunc(t.EQUAL);break;case qc:t.depthFunc(t.GEQUAL);break;case Rp:t.depthFunc(t.GREATER);break;case Np:t.depthFunc(t.NOTEQUAL);break;default:t.depthFunc(t.LEQUAL)}this.currentDepthFunc=e}}scissor(e,t,n,r){const o=this._tempVec4.set(e,t,n,r);if(this.currentScissor.equals(o)===!1){const{gl:a}=this;a.scissor(o.x,o.y,o.z,o.w),this.currentScissor.copy(o)}}viewport(e,t,n,r){const o=this._tempVec4.set(e,t,n,r);if(this.currentViewport.equals(o)===!1){const{gl:a}=this;a.viewport(o.x,o.y,o.z,o.w),this.currentViewport.copy(o)}}setScissorTest(e){const t=this.gl;e?this.enable(t.SCISSOR_TEST):this.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,n){(this.currentStencilFunc!==e||this.currentStencilRef!==t||this.currentStencilFuncMask!==n)&&(this.gl.stencilFunc(e,t,n),this.currentStencilFunc=e,this.currentStencilRef=t,this.currentStencilFuncMask=n)}setStencilOp(e,t,n){(this.currentStencilFail!==e||this.currentStencilZFail!==t||this.currentStencilZPass!==n)&&(this.gl.stencilOp(e,t,n),this.currentStencilFail=e,this.currentStencilZFail=t,this.currentStencilZPass=n)}setMaterial(e,t,n){const{gl:r}=this;e.side===Ae?this.disable(r.CULL_FACE):this.enable(r.CULL_FACE);let o=e.side===we;t&&(o=!o),this.setFlipSided(o),e.blending===Ue&&e.transparent===!1?this.setBlending(ve):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 a=e.stencilWrite;if(this.setStencilTest(a),a&&(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(r.SAMPLE_ALPHA_TO_COVERAGE):this.disable(r.SAMPLE_ALPHA_TO_COVERAGE),n>0&&this.currentClippingPlanes!==n)for(let u=0;u<8;u++)u<n?this.enable(12288+u):this.disable(12288+u)}setPolygonOffset(e,t,n){const{gl:r}=this;e?(this.enable(r.POLYGON_OFFSET_FILL),(this.currentPolygonOffsetFactor!==t||this.currentPolygonOffsetUnits!==n)&&(r.polygonOffset(t,n),this.currentPolygonOffsetFactor=t,this.currentPolygonOffsetUnits=n)):this.disable(r.POLYGON_OFFSET_FILL)}useProgram(e){return this.currentProgram!==e?(this.gl.useProgram(e),this.currentProgram=e,!0):!1}setVertexState(e,t=null){const n=this.gl;return this.currentVAO!==e||this.currentIndex!==t?(n.bindVertexArray(e),t!==null&&n.bindBuffer(n.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:n,currentBoundFramebuffers:r}=this;return r[e]!==t?(n.bindFramebuffer(e,t),r[e]=t,e===n.DRAW_FRAMEBUFFER&&(r[n.FRAMEBUFFER]=t),e===n.FRAMEBUFFER&&(r[n.DRAW_FRAMEBUFFER]=t),!0):!1}drawBuffers(e,t){const{gl:n}=this;let r=[],o=!1;if(e.textures!==null){r=this.currentDrawbuffers.get(t),r===void 0&&(r=[],this.currentDrawbuffers.set(t,r));const a=e.textures;if(r.length!==a.length||r[0]!==n.COLOR_ATTACHMENT0){for(let c=0,u=a.length;c<u;c++)r[c]=n.COLOR_ATTACHMENT0+c;r.length=a.length,o=!0}}else r[0]!==n.BACK&&(r[0]=n.BACK,o=!0);o&&n.drawBuffers(r)}activeTexture(e){const{gl:t,currentTextureSlot:n,maxTextures:r}=this;e===void 0&&(e=t.TEXTURE0+r-1),n!==e&&(t.activeTexture(e),this.currentTextureSlot=e)}bindTexture(e,t,n){const{gl:r,currentTextureSlot:o,currentBoundTextures:a,maxTextures:c}=this;n===void 0&&(o===null?n=r.TEXTURE0+c-1:n=o);let u=a[n];u===void 0&&(u={type:void 0,texture:void 0},a[n]=u),(u.type!==e||u.texture!==t)&&(o!==n&&(r.activeTexture(n),this.currentTextureSlot=n),r.bindTexture(e,t),u.type=e,u.texture=t)}bindBufferBase(e,t,n){const{gl:r}=this,o=`${e}-${t}`;return this.currentBoundBufferBases[o]!==n?(r.bindBufferBase(e,t,n),this.currentBoundBufferBases[o]=n,!0):!1}unbindTexture(){const{gl:e,currentTextureSlot:t,currentBoundTextures:n}=this,r=n[t];r!==void 0&&r.type!==void 0&&(e.bindTexture(r.type,null),r.type=void 0,r.texture=void 0)}}class n${constructor(e){this.backend=e,this.gl=this.backend.gl,this.extensions=e.extensions}convert(e,t=_r){const{gl:n,extensions:r}=this;let o;const a=xn.getTransfer(t);if(e===Di)return n.UNSIGNED_BYTE;if(e===Ip)return n.UNSIGNED_SHORT_4_4_4_4;if(e===Lp)return n.UNSIGNED_SHORT_5_5_5_1;if(e===Dp)return n.UNSIGNED_INT_5_9_9_9_REV;if(e===Fp)return n.UNSIGNED_INT_10F_11F_11F_REV;if(e===Kc)return n.BYTE;if(e===Jc)return n.SHORT;if(e===jo)return n.UNSIGNED_SHORT;if(e===er)return n.INT;if(e===yi)return n.UNSIGNED_INT;if(e===Si)return n.FLOAT;if(e===Hi)return n.HALF_FLOAT;if(e===Rg)return n.ALPHA;if(e===tf)return n.RGB;if(e===Ri)return n.RGBA;if(e===tr)return n.DEPTH_COMPONENT;if(e===Rr)return n.DEPTH_STENCIL;if(e===Qc)return n.RED;if(e===Bl)return n.RED_INTEGER;if(e===Nr)return n.RG;if(e===xh)return n.RG_INTEGER;if(e===vh)return n.RGBA_INTEGER;if(e===Ol||e===Ul||e===kl||e===zl)if(a===$t)if(o=r.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(e===Ol)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(e===Ul)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(e===kl)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(e===zl)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=r.get("WEBGL_compressed_texture_s3tc"),o!==null){if(e===Ol)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===Ul)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===kl)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===zl)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(e===nf||e===sf||e===rf||e===of)if(o=r.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(e===nf)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===sf)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===rf)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===of)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(e===bh||e===Sh||e===Mh||e===Th||e===wh||e===eu||e===Ah)if(o=r.get("WEBGL_compressed_texture_etc"),o!==null){if(e===bh||e===Sh)return a===$t?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(e===Mh)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC;if(e===Th)return o.COMPRESSED_R11_EAC;if(e===wh)return o.COMPRESSED_SIGNED_R11_EAC;if(e===eu)return o.COMPRESSED_RG11_EAC;if(e===Ah)return o.COMPRESSED_SIGNED_RG11_EAC}else return null;if(e===Eh||e===Ch||e===Rh||e===Nh||e===Ph||e===Ih||e===Lh||e===Dh||e===Fh||e===Bh||e===Oh||e===Uh||e===kh||e===zh)if(o=r.get("WEBGL_compressed_texture_astc"),o!==null){if(e===Eh)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(e===Ch)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(e===Rh)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(e===Nh)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(e===Ph)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(e===Ih)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(e===Lh)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(e===Dh)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(e===Fh)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(e===Bh)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(e===Oh)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(e===Uh)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(e===kh)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(e===zh)return a===$t?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(e===Vh)if(o=r.get("EXT_texture_compression_bptc"),o!==null){if(e===Vh)return a===$t?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(e===Gh||e===Wh||e===tu||e===il)if(o=r.get("EXT_texture_compression_rgtc"),o!==null){if(e===Gh)return o.COMPRESSED_RED_RGTC1_EXT;if(e===Wh)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(e===tu)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(e===il)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return e===wo?n.UNSIGNED_INT_24_8:n[e]!==void 0?n[e]:null}_clientWaitAsync(){const{gl:e}=this,t=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);return e.flush(),new Promise((n,r)=>{function o(){const a=e.clientWaitSync(t,e.SYNC_FLUSH_COMMANDS_BIT,0);if(a===e.WAIT_FAILED){e.deleteSync(t),r();return}if(a===e.TIMEOUT_EXPIRED){requestAnimationFrame(o);return}e.deleteSync(t),n()}o()})}}let V2=!1,bb,f1,G2;class i${constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},this._srcFramebuffer=null,this._dstFramebuffer=null,V2===!1&&(this._init(),V2=!0)}_init(){const e=this.gl;bb={[Ea]:e.REPEAT,[ki]:e.CLAMP_TO_EDGE,[Ca]:e.MIRRORED_REPEAT},f1={[ni]:e.NEAREST,[Pp]:e.NEAREST_MIPMAP_NEAREST,[Ra]:e.NEAREST_MIPMAP_LINEAR,[Yn]:e.LINEAR,[Zc]:e.LINEAR_MIPMAP_NEAREST,[Vs]:e.LINEAR_MIPMAP_LINEAR},G2={[y_]:e.NEVER,[b_]:e.ALWAYS,[Vl]:e.LESS,[Bp]:e.LEQUAL,[__]:e.EQUAL,[Op]:e.GEQUAL,[x_]:e.GREATER,[v_]:e.NOTEQUAL}}getGLTextureType(e){const{gl:t}=this;let n;return e.isCubeTexture===!0?n=t.TEXTURE_CUBE_MAP:e.isArrayTexture===!0||e.isDataArrayTexture===!0||e.isCompressedArrayTexture===!0?n=t.TEXTURE_2D_ARRAY:e.isData3DTexture===!0?n=t.TEXTURE_3D:n=t.TEXTURE_2D,n}getInternalFormat(e,t,n,r,o=!1){const{gl:a,extensions:c}=this;if(e!==null){if(a[e]!==void 0)return a[e];Ie("WebGLBackend: Attempt to use non-existing WebGL internal format '"+e+"'")}let u=t;if(t===a.RED&&(n===a.FLOAT&&(u=a.R32F),n===a.HALF_FLOAT&&(u=a.R16F),n===a.UNSIGNED_BYTE&&(u=a.R8),n===a.UNSIGNED_SHORT&&(u=a.R16),n===a.UNSIGNED_INT&&(u=a.R32UI),n===a.BYTE&&(u=a.R8I),n===a.SHORT&&(u=a.R16I),n===a.INT&&(u=a.R32I)),t===a.RED_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.R8UI),n===a.UNSIGNED_SHORT&&(u=a.R16UI),n===a.UNSIGNED_INT&&(u=a.R32UI),n===a.BYTE&&(u=a.R8I),n===a.SHORT&&(u=a.R16I),n===a.INT&&(u=a.R32I)),t===a.RG&&(n===a.FLOAT&&(u=a.RG32F),n===a.HALF_FLOAT&&(u=a.RG16F),n===a.UNSIGNED_BYTE&&(u=a.RG8),n===a.UNSIGNED_SHORT&&(u=a.RG16),n===a.UNSIGNED_INT&&(u=a.RG32UI),n===a.BYTE&&(u=a.RG8I),n===a.SHORT&&(u=a.RG16I),n===a.INT&&(u=a.RG32I)),t===a.RG_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.RG8UI),n===a.UNSIGNED_SHORT&&(u=a.RG16UI),n===a.UNSIGNED_INT&&(u=a.RG32UI),n===a.BYTE&&(u=a.RG8I),n===a.SHORT&&(u=a.RG16I),n===a.INT&&(u=a.RG32I)),t===a.RGB){const d=o?cf:xn.getTransfer(r);n===a.FLOAT&&(u=a.RGB32F),n===a.HALF_FLOAT&&(u=a.RGB16F),n===a.UNSIGNED_BYTE&&(u=a.RGB8),n===a.UNSIGNED_SHORT&&(u=a.RGB16),n===a.UNSIGNED_INT&&(u=a.RGB32UI),n===a.BYTE&&(u=a.RGB8I),n===a.SHORT&&(u=a.RGB16I),n===a.INT&&(u=a.RGB32I),n===a.UNSIGNED_BYTE&&(u=d===$t?a.SRGB8:a.RGB8),n===a.UNSIGNED_SHORT_5_6_5&&(u=a.RGB565),n===a.UNSIGNED_SHORT_5_5_5_1&&(u=a.RGB5_A1),n===a.UNSIGNED_SHORT_4_4_4_4&&(u=a.RGB4),n===a.UNSIGNED_INT_5_9_9_9_REV&&(u=a.RGB9_E5),n===a.UNSIGNED_INT_10F_11F_11F_REV&&(u=a.R11F_G11F_B10F)}if(t===a.RGB_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.RGB8UI),n===a.UNSIGNED_SHORT&&(u=a.RGB16UI),n===a.UNSIGNED_INT&&(u=a.RGB32UI),n===a.BYTE&&(u=a.RGB8I),n===a.SHORT&&(u=a.RGB16I),n===a.INT&&(u=a.RGB32I)),t===a.RGBA){const d=o?cf:xn.getTransfer(r);n===a.FLOAT&&(u=a.RGBA32F),n===a.HALF_FLOAT&&(u=a.RGBA16F),n===a.UNSIGNED_BYTE&&(u=a.RGBA8),n===a.UNSIGNED_SHORT&&(u=a.RGBA16),n===a.UNSIGNED_INT&&(u=a.RGBA32UI),n===a.BYTE&&(u=a.RGBA8I),n===a.SHORT&&(u=a.RGBA16I),n===a.INT&&(u=a.RGBA32I),n===a.UNSIGNED_BYTE&&(u=d===$t?a.SRGB8_ALPHA8:a.RGBA8),n===a.UNSIGNED_SHORT_4_4_4_4&&(u=a.RGBA4),n===a.UNSIGNED_SHORT_5_5_5_1&&(u=a.RGB5_A1)}return t===a.RGBA_INTEGER&&(n===a.UNSIGNED_BYTE&&(u=a.RGBA8UI),n===a.UNSIGNED_SHORT&&(u=a.RGBA16UI),n===a.UNSIGNED_INT&&(u=a.RGBA32UI),n===a.BYTE&&(u=a.RGBA8I),n===a.SHORT&&(u=a.RGBA16I),n===a.INT&&(u=a.RGBA32I)),t===a.DEPTH_COMPONENT&&(n===a.UNSIGNED_SHORT&&(u=a.DEPTH_COMPONENT16),n===a.UNSIGNED_INT&&(u=a.DEPTH_COMPONENT24),n===a.FLOAT&&(u=a.DEPTH_COMPONENT32F)),t===a.DEPTH_STENCIL&&n===a.UNSIGNED_INT_24_8&&(u=a.DEPTH24_STENCIL8),(u===a.R16F||u===a.R32F||u===a.RG16F||u===a.RG32F||u===a.RGBA16F||u===a.RGBA32F)&&c.get("EXT_color_buffer_float"),u}setTextureParameters(e,t){const{gl:n,extensions:r,backend:o}=this,a=xn.getPrimaries(xn.workingColorSpace),c=t.colorSpace===_r?null:xn.getPrimaries(t.colorSpace),u=t.colorSpace===_r||a===c?n.NONE:n.BROWSER_DEFAULT_WEBGL;n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,t.flipY),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),n.pixelStorei(n.UNPACK_ALIGNMENT,t.unpackAlignment),n.pixelStorei(n.UNPACK_COLORSPACE_CONVERSION_WEBGL,u),n.texParameteri(e,n.TEXTURE_WRAP_S,bb[t.wrapS]),n.texParameteri(e,n.TEXTURE_WRAP_T,bb[t.wrapT]),(e===n.TEXTURE_3D||e===n.TEXTURE_2D_ARRAY)&&(t.isArrayTexture||n.texParameteri(e,n.TEXTURE_WRAP_R,bb[t.wrapR])),n.texParameteri(e,n.TEXTURE_MAG_FILTER,f1[t.magFilter]);const d=t.mipmaps!==void 0&&t.mipmaps.length>0,p=t.minFilter===Yn&&d?Vs:t.minFilter;if(n.texParameteri(e,n.TEXTURE_MIN_FILTER,f1[p]),t.compareFunction&&(n.texParameteri(e,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(e,n.TEXTURE_COMPARE_FUNC,G2[t.compareFunction])),r.has("EXT_texture_filter_anisotropic")===!0){if(t.magFilter===ni||t.minFilter!==Ra&&t.minFilter!==Vs||t.type===Si&&r.has("OES_texture_float_linear")===!1)return;if(t.anisotropy>1){const m=r.get("EXT_texture_filter_anisotropic");n.texParameterf(e,m.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(t.anisotropy,o.getMaxAnisotropy()))}}}createDefaultTexture(e){const{gl:t,backend:n,defaultTextures:r}=this,o=this.getGLTextureType(e);let a=r[o];a===void 0&&(a=t.createTexture(),n.state.bindTexture(o,a),t.texParameteri(o,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(o,t.TEXTURE_MAG_FILTER,t.NEAREST),r[o]=a),n.set(e,{textureGPU:a,glTextureType:o})}createTexture(e,t){const{gl:n,backend:r}=this,{levels:o,width:a,height:c,depth:u}=t,d=r.utils.convert(e.format,e.colorSpace),p=r.utils.convert(e.type),m=this.getInternalFormat(e.internalFormat,d,p,e.colorSpace,e.isVideoTexture),y=n.createTexture(),x=this.getGLTextureType(e);r.state.bindTexture(x,y),this.setTextureParameters(x,e),e.isArrayTexture||e.isDataArrayTexture||e.isCompressedArrayTexture?n.texStorage3D(n.TEXTURE_2D_ARRAY,o,m,a,c,u):e.isData3DTexture?n.texStorage3D(n.TEXTURE_3D,o,m,a,c,u):e.isVideoTexture||n.texStorage2D(x,o,m,a,c),r.set(e,{textureGPU:y,glTextureType:x,glFormat:d,glType:p,glInternalFormat:m})}copyBufferToTexture(e,t){const{gl:n,backend:r}=this,{textureGPU:o,glTextureType:a,glFormat:c,glType:u}=r.get(t),{width:d,height:p}=t.source.data;n.bindBuffer(n.PIXEL_UNPACK_BUFFER,e),r.state.bindTexture(a,o),n.pixelStorei(n.UNPACK_FLIP_Y_WEBGL,!1),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),n.texSubImage2D(a,0,0,0,d,p,c,u,0),n.bindBuffer(n.PIXEL_UNPACK_BUFFER,null),r.state.unbindTexture()}updateTexture(e,t){const{gl:n}=this,{width:r,height:o}=t,{textureGPU:a,glTextureType:c,glFormat:u,glType:d,glInternalFormat:p}=this.backend.get(e);if(!(e.isRenderTargetTexture||a===void 0))if(this.backend.state.bindTexture(c,a),this.setTextureParameters(c,e),e.isCompressedTexture){const m=e.mipmaps,y=t.image;for(let x=0;x<m.length;x++){const v=m[x];e.isCompressedArrayTexture?e.format!==n.RGBA?u!==null?n.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,x,0,0,0,v.width,v.height,y.depth,u,v.data):Ie("WebGLBackend: Attempt to load unsupported compressed texture format in .uploadTexture()"):n.texSubImage3D(n.TEXTURE_2D_ARRAY,x,0,0,0,v.width,v.height,y.depth,u,d,v.data):u!==null?n.compressedTexSubImage2D(n.TEXTURE_2D,x,0,0,v.width,v.height,u,v.data):Ie("WebGLBackend: Unsupported compressed texture format")}}else if(e.isCubeTexture){const m=t.images,y=e.mipmaps;for(let x=0;x<6;x++){const v=Sb(m[x]);n.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+x,0,0,0,r,o,u,d,v);for(let w=0;w<y.length;w++){const M=y[w],S=Sb(M.images[x]);n.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+x,w+1,0,0,S.width,S.height,u,d,S)}}}else if(e.isDataArrayTexture||e.isArrayTexture){const m=t.image;if(e.layerUpdates.size>0){const y=l(m.width,m.height,e.format,e.type);for(const x of e.layerUpdates){const v=m.data.subarray(x*y/m.data.BYTES_PER_ELEMENT,(x+1)*y/m.data.BYTES_PER_ELEMENT);n.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,x,m.width,m.height,1,u,d,v)}e.clearLayerUpdates()}else n.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,m.width,m.height,m.depth,u,d,m.data)}else if(e.isData3DTexture){const m=t.image;n.texSubImage3D(n.TEXTURE_3D,0,0,0,0,m.width,m.height,m.depth,u,d,m.data)}else if(e.isVideoTexture)e.update(),n.texImage2D(c,0,p,u,d,t.image);else{const m=e.mipmaps;if(m.length>0)for(let y=0,x=m.length;y<x;y++){const v=m[y],w=Sb(v);n.texSubImage2D(c,y,0,0,v.width,v.height,u,d,w)}else{const y=Sb(t.image);n.texSubImage2D(c,0,0,0,r,o,u,d,y)}}}generateMipmaps(e){const{gl:t,backend:n}=this,{textureGPU:r,glTextureType:o}=n.get(e);n.state.bindTexture(o,r),t.generateMipmap(o)}deallocateRenderBuffers(e){const{gl:t,backend:n}=this;if(e){const r=n.get(e);if(r.renderBufferStorageSetup=void 0,r.framebuffers){for(const o in r.framebuffers)t.deleteFramebuffer(r.framebuffers[o]);delete r.framebuffers}if(r.depthRenderbuffer&&(t.deleteRenderbuffer(r.depthRenderbuffer),delete r.depthRenderbuffer),r.stencilRenderbuffer&&(t.deleteRenderbuffer(r.stencilRenderbuffer),delete r.stencilRenderbuffer),r.msaaFrameBuffer&&(t.deleteFramebuffer(r.msaaFrameBuffer),delete r.msaaFrameBuffer),r.msaaRenderbuffers){for(let o=0;o<r.msaaRenderbuffers.length;o++)t.deleteRenderbuffer(r.msaaRenderbuffers[o]);delete r.msaaRenderbuffers}}}destroyTexture(e,t=!1){const{gl:n,backend:r}=this,{textureGPU:o,renderTarget:a}=r.get(e);this.deallocateRenderBuffers(a),t===!1&&n.deleteTexture(o),r.delete(e)}copyTextureToTexture(e,t,n=null,r=null,o=0,a=0){const{gl:c,backend:u}=this,{state:d}=this.backend,{textureGPU:p,glTextureType:m,glType:y,glFormat:x}=u.get(t);d.bindTexture(m,p);let v,w,M,S,C,N,I,U,F;const k=e.isCompressedTexture?e.mipmaps[a]:e.image;if(n!==null)v=n.max.x-n.min.x,w=n.max.y-n.min.y,M=n.isBox3?n.max.z-n.min.z:1,S=n.min.x,C=n.min.y,N=n.isBox3?n.min.z:0;else{const Pe=Math.pow(2,-o);v=Math.floor(k.width*Pe),w=Math.floor(k.height*Pe),e.isDataArrayTexture||e.isArrayTexture?M=k.depth:e.isData3DTexture?M=Math.floor(k.depth*Pe):M=1,S=0,C=0,N=0}r!==null?(I=r.x,U=r.y,F=r.z):(I=0,U=0,F=0),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,t.flipY),c.pixelStorei(c.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),c.pixelStorei(c.UNPACK_ALIGNMENT,t.unpackAlignment);const G=c.getParameter(c.UNPACK_ROW_LENGTH),B=c.getParameter(c.UNPACK_IMAGE_HEIGHT),z=c.getParameter(c.UNPACK_SKIP_PIXELS),Q=c.getParameter(c.UNPACK_SKIP_ROWS),ye=c.getParameter(c.UNPACK_SKIP_IMAGES);c.pixelStorei(c.UNPACK_ROW_LENGTH,k.width),c.pixelStorei(c.UNPACK_IMAGE_HEIGHT,k.height),c.pixelStorei(c.UNPACK_SKIP_PIXELS,S),c.pixelStorei(c.UNPACK_SKIP_ROWS,C),c.pixelStorei(c.UNPACK_SKIP_IMAGES,N);const _e=e.isDataArrayTexture||e.isData3DTexture||t.isArrayTexture,Te=t.isDataArrayTexture||t.isData3DTexture||t.isArrayTexture;if(e.isDepthTexture){const Pe=u.get(e),Ne=u.get(t),De=u.get(Pe.renderTarget),Qe=u.get(Ne.renderTarget),Mt=De.framebuffers[Pe.cacheKey],Tt=Qe.framebuffers[Ne.cacheKey];d.bindFramebuffer(c.READ_FRAMEBUFFER,Mt),d.bindFramebuffer(c.DRAW_FRAMEBUFFER,Tt);for(let Fe=0;Fe<M;Fe++)_e&&(c.framebufferTextureLayer(c.READ_FRAMEBUFFER,c.COLOR_ATTACHMENT0,Pe.textureGPU,o,N+Fe),c.framebufferTextureLayer(c.DRAW_FRAMEBUFFER,c.COLOR_ATTACHMENT0,p,a,F+Fe)),c.blitFramebuffer(S,C,v,w,I,U,v,w,c.DEPTH_BUFFER_BIT,c.NEAREST);d.bindFramebuffer(c.READ_FRAMEBUFFER,null),d.bindFramebuffer(c.DRAW_FRAMEBUFFER,null)}else if(o!==0||e.isRenderTargetTexture||u.has(e)){const Pe=u.get(e);this._srcFramebuffer===null&&(this._srcFramebuffer=c.createFramebuffer()),this._dstFramebuffer===null&&(this._dstFramebuffer=c.createFramebuffer()),d.bindFramebuffer(c.READ_FRAMEBUFFER,this._srcFramebuffer),d.bindFramebuffer(c.DRAW_FRAMEBUFFER,this._dstFramebuffer);for(let Ne=0;Ne<M;Ne++)_e?c.framebufferTextureLayer(c.READ_FRAMEBUFFER,c.COLOR_ATTACHMENT0,Pe.textureGPU,o,N+Ne):c.framebufferTexture2D(c.READ_FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,Pe.textureGPU,o),Te?c.framebufferTextureLayer(c.DRAW_FRAMEBUFFER,c.COLOR_ATTACHMENT0,p,a,F+Ne):c.framebufferTexture2D(c.DRAW_FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,p,a),o!==0?c.blitFramebuffer(S,C,v,w,I,U,v,w,c.COLOR_BUFFER_BIT,c.NEAREST):Te?c.copyTexSubImage3D(m,a,I,U,F+Ne,S,C,v,w):c.copyTexSubImage2D(m,a,I,U,S,C,v,w);d.bindFramebuffer(c.READ_FRAMEBUFFER,null),d.bindFramebuffer(c.DRAW_FRAMEBUFFER,null)}else Te?e.isDataTexture||e.isData3DTexture?c.texSubImage3D(m,a,I,U,F,v,w,M,x,y,k.data):t.isCompressedArrayTexture?c.compressedTexSubImage3D(m,a,I,U,F,v,w,M,x,k.data):c.texSubImage3D(m,a,I,U,F,v,w,M,x,y,k):e.isDataTexture?c.texSubImage2D(c.TEXTURE_2D,a,I,U,v,w,x,y,k.data):e.isCompressedTexture?c.compressedTexSubImage2D(c.TEXTURE_2D,a,I,U,k.width,k.height,x,k.data):c.texSubImage2D(c.TEXTURE_2D,a,I,U,v,w,x,y,k);c.pixelStorei(c.UNPACK_ROW_LENGTH,G),c.pixelStorei(c.UNPACK_IMAGE_HEIGHT,B),c.pixelStorei(c.UNPACK_SKIP_PIXELS,z),c.pixelStorei(c.UNPACK_SKIP_ROWS,Q),c.pixelStorei(c.UNPACK_SKIP_IMAGES,ye),a===0&&t.generateMipmaps&&c.generateMipmap(m),d.unbindTexture()}copyFramebufferToTexture(e,t,n){const{gl:r}=this,{state:o}=this.backend,{textureGPU:a}=this.backend.get(e),{x:c,y:u,z:d,w:p}=n,m=e.isDepthTexture===!0||t.renderTarget&&t.renderTarget.samples>0,y=t.renderTarget?t.renderTarget.height:this.backend.getDrawingBufferSize().y;if(m){const x=c!==0||u!==0;let v,w;if(e.isDepthTexture===!0?(v=r.DEPTH_BUFFER_BIT,w=r.DEPTH_ATTACHMENT,t.stencil&&(v|=r.STENCIL_BUFFER_BIT)):(v=r.COLOR_BUFFER_BIT,w=r.COLOR_ATTACHMENT0),x){const M=this.backend.get(t.renderTarget),S=M.framebuffers[t.getCacheKey()],C=M.msaaFrameBuffer;o.bindFramebuffer(r.DRAW_FRAMEBUFFER,S),o.bindFramebuffer(r.READ_FRAMEBUFFER,C);const N=y-u-p;r.blitFramebuffer(c,N,c+d,N+p,c,N,c+d,N+p,v,r.NEAREST),o.bindFramebuffer(r.READ_FRAMEBUFFER,S),o.bindTexture(r.TEXTURE_2D,a),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,c,N,d,p),o.unbindTexture()}else{const M=r.createFramebuffer();o.bindFramebuffer(r.DRAW_FRAMEBUFFER,M),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,w,r.TEXTURE_2D,a,0),r.blitFramebuffer(0,0,d,p,0,0,d,p,v,r.NEAREST),r.deleteFramebuffer(M)}}else o.bindTexture(r.TEXTURE_2D,a),r.copyTexSubImage2D(r.TEXTURE_2D,0,0,0,c,y-p-u,d,p),o.unbindTexture();e.generateMipmaps&&this.generateMipmaps(e),this.backend._setFramebuffer(t)}setupRenderBufferStorage(e,t,n,r=!1){const{gl:o}=this,a=t.renderTarget,{depthTexture:c,depthBuffer:u,stencilBuffer:d,width:p,height:m}=a;if(o.bindRenderbuffer(o.RENDERBUFFER,e),u&&!d){let y=o.DEPTH_COMPONENT24;r===!0?this.extensions.get("WEBGL_multisampled_render_to_texture").renderbufferStorageMultisampleEXT(o.RENDERBUFFER,a.samples,y,p,m):n>0?(c&&c.isDepthTexture&&c.type===o.FLOAT&&(y=o.DEPTH_COMPONENT32F),o.renderbufferStorageMultisample(o.RENDERBUFFER,n,y,p,m)):o.renderbufferStorage(o.RENDERBUFFER,y,p,m),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_ATTACHMENT,o.RENDERBUFFER,e)}else u&&d&&(n>0?o.renderbufferStorageMultisample(o.RENDERBUFFER,n,o.DEPTH24_STENCIL8,p,m):o.renderbufferStorage(o.RENDERBUFFER,o.DEPTH_STENCIL,p,m),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_STENCIL_ATTACHMENT,o.RENDERBUFFER,e));o.bindRenderbuffer(o.RENDERBUFFER,null)}copyTextureToBuffer(e,t,n,r,o,a){return mn(this,null,function*(){const{backend:c,gl:u}=this,{textureGPU:d,glFormat:p,glType:m}=this.backend.get(e),y=u.createFramebuffer();c.state.bindFramebuffer(u.READ_FRAMEBUFFER,y);const x=e.isCubeTexture?u.TEXTURE_CUBE_MAP_POSITIVE_X+a:u.TEXTURE_2D;u.framebufferTexture2D(u.READ_FRAMEBUFFER,u.COLOR_ATTACHMENT0,x,d,0);const v=this._getTypedArrayType(m),w=this._getBytesPerTexel(m,p),S=r*o*w,C=u.createBuffer();u.bindBuffer(u.PIXEL_PACK_BUFFER,C),u.bufferData(u.PIXEL_PACK_BUFFER,S,u.STREAM_READ),u.readPixels(t,n,r,o,p,m,0),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),yield c.utils._clientWaitAsync();const N=new v(S/v.BYTES_PER_ELEMENT);return u.bindBuffer(u.PIXEL_PACK_BUFFER,C),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,N),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),c.state.bindFramebuffer(u.READ_FRAMEBUFFER,null),u.deleteFramebuffer(y),N})}_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:n}=this;let r=0;if(e===n.UNSIGNED_BYTE&&(r=1),(e===n.UNSIGNED_SHORT_4_4_4_4||e===n.UNSIGNED_SHORT_5_5_5_1||e===n.UNSIGNED_SHORT_5_6_5||e===n.UNSIGNED_SHORT||e===n.HALF_FLOAT)&&(r=2),(e===n.UNSIGNED_INT||e===n.FLOAT)&&(r=4),t===n.RGBA)return r*4;if(t===n.RGB)return r*3;if(t===n.ALPHA)return r}dispose(){const{gl:e}=this;this._srcFramebuffer!==null&&e.deleteFramebuffer(this._srcFramebuffer),this._dstFramebuffer!==null&&e.deleteFramebuffer(this._dstFramebuffer)}}function Sb(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 s${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 r${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 n=t.get("EXT_texture_filter_anisotropic");this.maxAnisotropy=e.getParameter(n.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else this.maxAnisotropy=0;return this.maxAnisotropy}}const W2={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 o${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:n,mode:r,object:o,type:a,info:c,index:u}=this;u!==0?n.drawElements(r,t,a,e):n.drawArrays(r,e,t),c.update(o,t,1)}renderInstances(e,t,n){const{gl:r,mode:o,type:a,index:c,object:u,info:d}=this;n!==0&&(c!==0?r.drawElementsInstanced(o,t,a,e,n):r.drawArraysInstanced(o,e,t,n),d.update(u,t,n))}renderMultiDraw(e,t,n){const{extensions:r,mode:o,object:a,info:c}=this;if(n===0)return;const u=r.get("WEBGL_multi_draw");if(u===null)for(let d=0;d<n;d++)this.render(e[d],t[d]);else{this.index!==0?u.multiDrawElementsWEBGL(o,t,0,this.type,e,0,n):u.multiDrawArraysWEBGL(o,e,0,t,0,n);let d=0;for(let p=0;p<n;p++)d+=t[p];c.update(a,d,1)}}renderMultiDrawInstances(e,t,n,r){const{extensions:o,mode:a,object:c,info:u}=this;if(n===0)return;const d=o.get("WEBGL_multi_draw");if(d===null)for(let p=0;p<n;p++)this.renderInstances(e[p],t[p],r[p]);else{this.index!==0?d.multiDrawElementsInstancedWEBGL(a,t,0,this.type,e,0,r,0,n):d.multiDrawArraysInstancedWEBGL(a,e,0,t,0,r,0,n);let p=0;for(let m=0;m<n;m++)p+=t[m]*r[m];u.update(c,p,1)}}}class H2{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&&(Ie(`TimestampQueryPool: No timestamp available for uid ${e}.`),t=0),t}hasTimestamp(e){return this.timestamps.has(e)}allocateQueriesForContext(){}resolveQueriesAsync(){return mn(this,null,function*(){})}dispose(){}}class a$ extends H2{constructor(e,t,n=2048){if(super(n),this.gl=e,this.type=t,this.ext=e.getExtension("EXT_disjoint_timer_query_webgl2")||e.getExtension("EXT_disjoint_timer_query"),!this.ext){Ie("EXT_disjoint_timer_query not supported; timestamps will be disabled."),this.trackTimestamp=!1;return}this.queries=[];for(let r=0;r<this.maxQueries;r++)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 Ut(`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 n=this.queries[t];if(n)try{this.queryStates.get(t)==="inactive"&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,n),this.activeQuery=t,this.queryStates.set(t,"started"))}catch(r){Be("Error in beginQuery:",r),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(n){Be("Error in endQuery:",n),this.queryStates.set(t,"inactive"),this.activeQuery=null}}resolveQueriesAsync(){return mn(this,null,function*(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{const e=new Map;for(const[o,a]of this.queryOffsets)if(this.queryStates.get(a)==="ended"){const u=this.queries[a];e.set(o,this.resolveQuery(u))}if(e.size===0)return this.lastValue;const t={},n=[];for(const[o,a]of e){const c=o.match(/^(.*):f(\d+)$/),u=parseInt(c[2]);n.includes(u)===!1&&n.push(u),t[u]===void 0&&(t[u]=0);const d=yield a;this.timestamps.set(o,d),t[u]+=d}const r=t[n[n.length-1]];return this.lastValue=r,this.frames=n,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,r}catch(e){return Be("Error resolving queries:",e),this.lastValue}finally{this.pendingResolve=!1}})}resolveQuery(e){return mn(this,null,function*(){return new Promise(t=>{if(this.isDisposed){t(this.lastValue);return}let n,r=!1;const o=()=>{n&&(clearTimeout(n),n=null)},a=u=>{r||(r=!0,o(),t(u))},c=()=>{if(this.isDisposed){a(this.lastValue);return}try{if(this.gl.getParameter(this.ext.GPU_DISJOINT_EXT)){a(this.lastValue);return}if(!this.gl.getQueryParameter(e,this.gl.QUERY_RESULT_AVAILABLE)){n=setTimeout(c,1);return}const p=this.gl.getQueryParameter(e,this.gl.QUERY_RESULT);t(Number(p)/1e6)}catch(u){Be("Error checking query:",u),t(this.lastValue)}};c()})})}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 $2 extends z2{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,n={antialias:e.currentSamples>0,alpha:!0,depth:e.depth,stencil:e.stencil},r=t.context!==void 0?t.context:e.domElement.getContext("webgl2",n);function o(a){a.preventDefault();const c={api:"WebGL",message:a.statusMessage||"Unknown reason",reason:null,originalEvent:a};e.onDeviceLost(c)}this._onContextLost=o,e.domElement.addEventListener("webglcontextlost",o,!1),this.gl=r,this.extensions=new s$(this),this.capabilities=new r$(this),this.attributeUtils=new e$(this),this.textureUtils=new i$(this),this.bufferRenderer=new o$(this),this.state=new t$(this),this.utils=new n$(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"),this.drawBuffersIndexedExt=this.extensions.get("OES_draw_buffers_indexed")}get coordinateSystem(){return ws}getArrayBufferAsync(e){return mn(this,null,function*(){return yield this.attributeUtils.getArrayBufferAsync(e)})}makeXRCompatible(){return mn(this,null,function*(){this.gl.getContextAttributes().xrCompatible!==!0&&(yield this.gl.makeXRCompatible())})}setXRTarget(e){this._xrFramebuffer=e}setXRRenderTargetTextures(e,t,n=null){const r=this.gl;if(this.set(e.texture,{textureGPU:t,glInternalFormat:r.RGBA8}),n!==null){const o=e.stencilBuffer?r.DEPTH24_STENCIL8:r.DEPTH_COMPONENT24;this.set(e.depthTexture,{textureGPU:n,glInternalFormat:o}),this.extensions.has("WEBGL_multisampled_render_to_texture")===!0&&e._autoAllocateDepthBuffer===!0&&e.multiview===!1&&Ie("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 a$(this.gl,e,2048));const n=this.timestampQueryPool[e];n.allocateQueriesForContext(t)!==null&&n.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,n=this.get(e);if(e.viewport)this.updateViewport(e);else{const{width:o,height:a}=this.getDrawingBufferSize();t.viewport(0,0,o,a)}if(e.scissor){const{x:o,y:a,width:c,height:u}=e.scissorValue;t.scissor(o,e.height-u-a,c,u)}this.initTimestampQuery(ol.RENDER,this.getTimestampUID(e)),n.previousContext=this._currentContext,this._currentContext=e,this._setFramebuffer(e),this.clear(e.clearColor,e.clearDepth,e.clearStencil,e,!1);const r=e.occlusionQueryCount;r>0&&(n.currentOcclusionQueries=n.occlusionQueries,n.currentOcclusionQueryObjects=n.occlusionQueryObjects,n.lastOcclusionObject=null,n.occlusionQueries=new Array(r),n.occlusionQueryObjects=new Array(r),n.occlusionQueryIndex=0)}finishRender(e){const{gl:t,state:n}=this,r=this.get(e),o=r.previousContext;n.resetVertexState();const a=e.occlusionQueryCount;a>0&&(a>r.occlusionQueryIndex&&t.endQuery(t.ANY_SAMPLES_PASSED),this.resolveOccludedAsync(e));const c=e.textures;if(c!==null)for(let u=0;u<c.length;u++){const d=c[u];d.generateMipmaps&&this.generateMipmaps(d)}if(this._currentContext=o,this._resolveRenderTarget(e),o!==null)if(this._setFramebuffer(o),o.viewport)this.updateViewport(o);else{const{width:u,height:d}=this.getDrawingBufferSize();n.viewport(0,0,u,d)}this.prepareTimestampBuffer(ol.RENDER,this.getTimestampUID(e))}resolveOccludedAsync(e){const t=this.get(e),{currentOcclusionQueries:n,currentOcclusionQueryObjects:r}=t;if(n&&r){const o=new WeakSet,{gl:a}=this;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueries=null;const c=()=>{let u=0;for(let d=0;d<n.length;d++){const p=n[d];p!==null&&a.getQueryParameter(p,a.QUERY_RESULT_AVAILABLE)&&(a.getQueryParameter(p,a.QUERY_RESULT)===0&&o.add(r[d]),n[d]=null,a.deleteQuery(p),u++)}u<n.length?requestAnimationFrame(c):t.occluded=o};c()}}isOccluded(e,t){const n=this.get(e);return n.occluded&&n.occluded.has(t)}updateViewport(e){const{state:t}=this,{x:n,y:r,width:o,height:a}=e.viewportValue;t.viewport(n,e.height-a-r,o,a)}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,n,r=null,o=!0,a=!0){const{gl:c,renderer:u}=this;r===null&&(r={textures:null,clearColorValue:this.getClearColor()});let d=0;if(e&&(d|=c.COLOR_BUFFER_BIT),t&&(d|=c.DEPTH_BUFFER_BIT),n&&(d|=c.STENCIL_BUFFER_BIT),d!==0){let p;r.clearColorValue?p=r.clearColorValue:p=this.getClearColor();const m=u.getClearDepth(),y=u.getClearStencil();if(t&&this.state.setDepthMask(!0),r.textures===null)c.clearColor(p.r,p.g,p.b,p.a),c.clear(d);else{if(o&&this._setFramebuffer(r),e)for(let x=0;x<r.textures.length;x++)x===0?c.clearBufferfv(c.COLOR,x,[p.r,p.g,p.b,p.a]):c.clearBufferfv(c.COLOR,x,[0,0,0,1]);t&&n?c.clearBufferfi(c.DEPTH_STENCIL,0,m,y):t?c.clearBufferfv(c.DEPTH,0,[m]):n&&c.clearBufferiv(c.STENCIL,0,[y]),o&&a&&this._resolveRenderTarget(r)}}}beginCompute(e){const{state:t,gl:n}=this;t.bindFramebuffer(n.FRAMEBUFFER,null),this.initTimestampQuery(ol.COMPUTE,this.getTimestampUID(e))}compute(e,t,n,r,o=null){const{state:a,gl:c}=this;this.discard===!1&&(a.enable(c.RASTERIZER_DISCARD),this.discard=!0);const{programGPU:u,transformBuffers:d,attributes:p}=this.get(r),m=this._getVaoKey(p),y=this.vaoCache[m];y===void 0?this.vaoCache[m]=this._createVao(p):a.setVertexState(y),a.useProgram(u),this._bindUniforms(n);const x=this._getTransformFeedback(d);c.bindTransformFeedback(c.TRANSFORM_FEEDBACK,x),c.beginTransformFeedback(c.POINTS),o=o!==null?o:t.count,Array.isArray(o)?(Ut("WebGLBackend.compute(): The count parameter must be a single number, not an array."),o=o[0]):o&&typeof o=="object"&&o.isIndirectStorageBufferAttribute&&(Ut("WebGLBackend.compute(): The count parameter must be a single number, not IndirectStorageBufferAttribute"),o=t.count),p[0].isStorageInstancedBufferAttribute?c.drawArraysInstanced(c.POINTS,0,1,o):c.drawArrays(c.POINTS,0,o),c.endTransformFeedback(),c.bindTransformFeedback(c.TRANSFORM_FEEDBACK,null);for(let v=0;v<d.length;v++){const w=d[v];w.pbo&&this.has(w.pbo)&&this.textureUtils.copyBufferToTexture(w.transformBuffer,w.pbo),w.switchBuffers()}}finishCompute(e){const{state:t,gl:n}=this;this.discard=!1,t.disable(n.RASTERIZER_DISCARD),this.prepareTimestampBuffer(ol.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:n,material:r,context:o,hardwareClippingPlanes:a}=e,{programGPU:c}=this.get(n),{gl:u,state:d}=this,p=this.get(o),m=e.getDrawParameters();if(m===null)return;this._bindUniforms(e.getBindings());const y=t.isMesh&&t.matrixWorld.determinant()<0;d.setMaterial(r,y,a),o.textures!==null&&o.textures.length>1&&d.setMRTBlending(o.textures),d.useProgram(c);const x=e.getAttributes(),v=this.get(x);let w=v.vaoGPU;if(w===void 0){const G=this._getVaoKey(x);w=this.vaoCache[G],w===void 0&&(w=this._createVao(x),this.vaoCache[G]=w,v.vaoGPU=w)}const M=e.getIndex(),S=M!==null?this.get(M).bufferGPU:null;d.setVertexState(w,S);const C=p.lastOcclusionObject;if(C!==t&&C!==void 0){if(C!==null&&C.occlusionTest===!0&&(u.endQuery(u.ANY_SAMPLES_PASSED),p.occlusionQueryIndex++),t.occlusionTest===!0){const G=u.createQuery();u.beginQuery(u.ANY_SAMPLES_PASSED,G),p.occlusionQueries[p.occlusionQueryIndex]=G,p.occlusionQueryObjects[p.occlusionQueryIndex]=t}p.lastOcclusionObject=t}const N=this.bufferRenderer;t.isPoints?N.mode=u.POINTS:t.isLineSegments?N.mode=u.LINES:t.isLine?N.mode=u.LINE_STRIP:t.isLineLoop?N.mode=u.LINE_LOOP:r.wireframe===!0?(d.setLineWidth(r.wireframeLinewidth*this.renderer.getPixelRatio()),N.mode=u.LINES):N.mode=u.TRIANGLES;const{vertexCount:I,instanceCount:U}=m;let{firstVertex:F}=m;if(N.object=t,M!==null){F*=M.array.BYTES_PER_ELEMENT;const G=this.get(M);N.index=M.count,N.type=G.type}else N.index=0;const k=()=>{t.isBatchedMesh?t._multiDrawInstances!==null?(Ut("WebGLBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),N.renderMultiDrawInstances(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount,t._multiDrawInstances)):this.hasFeature("WEBGL_multi_draw")?N.renderMultiDraw(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount):Ut("WebGLBackend: WEBGL_multi_draw not supported."):U>1?N.renderInstances(F,I,U):N.render(F,I)};if(e.camera.isArrayCamera===!0&&e.camera.cameras.length>0&&e.camera.isMultiViewCamera===!1){const G=this.get(e.camera),B=e.camera.cameras,z=e.getBindingGroup("cameraIndex").bindings[0];if(G.indexesGPU===void 0||G.indexesGPU.length!==B.length){const Ne=new Uint32Array([0,0,0,0]),De=[];for(let Qe=0,Mt=B.length;Qe<Mt;Qe++){const Tt=u.createBuffer();Ne[0]=Qe,u.bindBuffer(u.UNIFORM_BUFFER,Tt),u.bufferData(u.UNIFORM_BUFFER,Ne,u.STATIC_DRAW),De.push(Tt)}G.indexesGPU=De}const Q=this.get(z),ye=this.renderer.getPixelRatio(),_e=this._currentContext.renderTarget,Te=this._isRenderCameraDepthArray(this._currentContext),Pe=this._currentContext.activeCubeFace;if(Te){const Ne=this.get(_e.depthTexture);if(Ne.clearedRenderId!==this.renderer._nodes.nodeFrame.renderId){Ne.clearedRenderId=this.renderer._nodes.nodeFrame.renderId;const{stencilBuffer:De}=_e;for(let Qe=0,Mt=B.length;Qe<Mt;Qe++)this.renderer._activeCubeFace=Qe,this._currentContext.activeCubeFace=Qe,this._setFramebuffer(this._currentContext),this.clear(!1,!0,De,this._currentContext,!1,!1);this.renderer._activeCubeFace=Pe,this._currentContext.activeCubeFace=Pe}}for(let Ne=0,De=B.length;Ne<De;Ne++){const Qe=B[Ne];if(t.layers.test(Qe.layers)){Te&&(this.renderer._activeCubeFace=Ne,this._currentContext.activeCubeFace=Ne,this._setFramebuffer(this._currentContext));const Mt=Qe.viewport;if(Mt!==void 0){const Tt=Mt.x*ye,Fe=Mt.y*ye,mt=Mt.width*ye,wt=Mt.height*ye;d.viewport(Math.floor(Tt),Math.floor(e.context.height-wt-Fe),Math.floor(mt),Math.floor(wt))}d.bindBufferBase(u.UNIFORM_BUFFER,Q.index,G.indexesGPU[Ne]),k()}this._currentContext.activeCubeFace=Pe,this.renderer._activeCubeFace=Pe}}else k()}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,n,r,o,a){return mn(this,null,function*(){return this.textureUtils.copyTextureToBuffer(e,t,n,r,o,a)})}updateSampler(){return""}createNodeBuilder(e,t){return new K9(e,t)}createProgram(e){const t=this.gl,{stage:n,code:r}=e,o=n==="fragment"?t.createShader(t.FRAGMENT_SHADER):t.createShader(t.VERTEX_SHADER);t.shaderSource(o,r),t.compileShader(o),this.set(e,{shaderGPU:o})}destroyProgram(e){this.delete(e)}createRenderPipeline(e,t){const n=this.gl,r=e.pipeline,{fragmentProgram:o,vertexProgram:a}=r,c=n.createProgram(),u=this.get(o).shaderGPU,d=this.get(a).shaderGPU;if(n.attachShader(c,u),n.attachShader(c,d),n.linkProgram(c),this.set(r,{programGPU:c,fragmentShader:u,vertexShader:d}),t!==null&&this.parallel){const p=new Promise(m=>{const y=this.parallel,x=()=>{n.getProgramParameter(c,y.COMPLETION_STATUS_KHR)?(this._completeCompile(e,r),m()):requestAnimationFrame(x)};x()});t.push(p);return}this._completeCompile(e,r)}_handleSource(e,t){const n=e.split(`
`),r=[],o=Math.max(t-6,0),a=Math.min(t+6,n.length);for(let c=o;c<a;c++){const u=c+1;r.push(`${u===t?">":" "} ${u}: ${n[c]}`)}return r.join(`
`)}_getShaderErrors(e,t,n){const r=e.getShaderParameter(t,e.COMPILE_STATUS),a=(e.getShaderInfoLog(t)||"").trim();if(r&&a==="")return"";const c=/ERROR: 0:(\d+)/.exec(a);if(c){const u=parseInt(c[1]);return n.toUpperCase()+`
`+a+`
`+this._handleSource(e.getShaderSource(t),u)}else return a}_logProgramError(e,t,n){if(this.renderer.debug.checkShaderErrors){const r=this.gl,a=(r.getProgramInfoLog(e)||"").trim();if(r.getProgramParameter(e,r.LINK_STATUS)===!1)if(typeof this.renderer.debug.onShaderError=="function")this.renderer.debug.onShaderError(r,e,n,t);else{const c=this._getShaderErrors(r,n,"vertex"),u=this._getShaderErrors(r,t,"fragment");Be("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(e,r.VALIDATE_STATUS)+`
Program Info Log: `+a+`
`+c+`
`+u)}else a!==""&&Ie("WebGLProgram: Program Info Log:",a)}}_completeCompile(e,t){const{state:n,gl:r}=this,o=this.get(t),{programGPU:a,fragmentShader:c,vertexShader:u}=o;r.getProgramParameter(a,r.LINK_STATUS)===!1&&this._logProgramError(a,c,u),n.useProgram(a);const d=e.getBindings();this._setupBindings(d,a),this.set(t,{programGPU:a})}createComputePipeline(e,t){const{state:n,gl:r}=this,o={stage:"fragment",code:`#version 300 es
precision highp float;
void main() {}`};this.createProgram(o);const{computeProgram:a}=e,c=r.createProgram(),u=this.get(o).shaderGPU,d=this.get(a).shaderGPU,p=a.transforms,m=[],y=[];for(let M=0;M<p.length;M++){const S=p[M];m.push(S.varyingName),y.push(S.attributeNode)}r.attachShader(c,u),r.attachShader(c,d),r.transformFeedbackVaryings(c,m,r.SEPARATE_ATTRIBS),r.linkProgram(c),r.getProgramParameter(c,r.LINK_STATUS)===!1&&this._logProgramError(c,u,d),n.useProgram(c),this._setupBindings(t,c);const x=a.attributes,v=[],w=[];for(let M=0;M<x.length;M++){const S=x[M].node.attribute;v.push(S),this.has(S)||this.attributeUtils.createAttribute(S,r.ARRAY_BUFFER)}for(let M=0;M<y.length;M++){const S=y[M].attribute;this.has(S)||this.attributeUtils.createAttribute(S,r.ARRAY_BUFFER);const C=this.get(S);w.push(C)}this.set(e,{programGPU:c,transformBuffers:w,attributes:v})}createBindings(e,t){if(this._knownBindings.has(t)===!1){this._knownBindings.add(t);let n=0,r=0;for(const o of t){this.set(o,{textures:r,uniformBuffers:n});for(const a of o.bindings)a.isUniformBuffer&&n++,a.isSampledTexture&&r++}}this.updateBindings(e,t)}updateBindings(e){const{gl:t}=this,n=this.get(e);let r=n.uniformBuffers,o=n.textures;for(const a of e.bindings){const c=this.get(a);if(a.isUniformsGroup||a.isUniformBuffer){const u=a.buffer;let{bufferGPU:d}=this.get(u);d===void 0?(d=t.createBuffer(),t.bindBuffer(t.UNIFORM_BUFFER,d),t.bufferData(t.UNIFORM_BUFFER,u.byteLength,t.DYNAMIC_DRAW),this.set(u,{bufferGPU:d})):t.bindBuffer(t.UNIFORM_BUFFER,d);const p=a.updateRanges;if(t.bindBuffer(t.UNIFORM_BUFFER,d),p.length===0)t.bufferData(t.UNIFORM_BUFFER,u,t.DYNAMIC_DRAW);else{const m=Mn(u),y=m?1:u.BYTES_PER_ELEMENT;for(let x=0,v=p.length;x<v;x++){const w=p[x],M=w.start*y,S=w.count*y,C=M*(m?u.BYTES_PER_ELEMENT:1);t.bufferSubData(t.UNIFORM_BUFFER,C,u,M,S)}}c.index=r++,c.bufferGPU=d,this.set(a,c)}else if(a.isSampledTexture){const{textureGPU:u,glTextureType:d}=this.get(a.texture);c.index=o++,c.textureGPU=u,c.glTextureType=d,this.set(a,c)}}}updateBinding(e){const t=this.gl;if(e.isUniformsGroup||e.isUniformBuffer){const r=this.get(e).bufferGPU,o=e.buffer,a=e.updateRanges;if(t.bindBuffer(t.UNIFORM_BUFFER,r),a.length===0)t.bufferData(t.UNIFORM_BUFFER,o,t.DYNAMIC_DRAW);else{const c=Mn(o),u=c?1:o.BYTES_PER_ELEMENT;for(let d=0,p=a.length;d<p;d++){const m=a[d],y=m.start*u,x=m.count*u,v=y*(c?o.BYTES_PER_ELEMENT:1);t.bufferSubData(t.UNIFORM_BUFFER,v,o,y,x)}}}}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(W2).filter(r=>W2[r]===e),n=this.extensions;for(let r=0;r<t.length;r++)if(n.has(t[r]))return!0;return!1}getMaxAnisotropy(){return this.capabilities.getMaxAnisotropy()}copyTextureToTexture(e,t,n=null,r=null,o=0,a=0){this.textureUtils.copyTextureToTexture(e,t,n,r,o,a)}copyFramebufferToTexture(e,t,n){this.textureUtils.copyFramebufferToTexture(e,t,n)}_setFramebuffer(e){const{gl:t,state:n}=this;let r=null;if(e.textures!==null){const o=e.renderTarget,a=this.get(o),{samples:c,depthBuffer:u,stencilBuffer:d}=o,p=o.isWebGLCubeRenderTarget===!0,m=o.isRenderTarget3D===!0,y=o.depth>1,x=o.isXRRenderTarget===!0,v=x===!0&&o._hasExternalTextures===!0;let w=a.msaaFrameBuffer,M=a.depthRenderbuffer;const S=this.extensions.get("WEBGL_multisampled_render_to_texture"),C=this.extensions.get("OVR_multiview2"),N=this._useMultisampledExtension(o),I=cI(e);let U;if(p?(a.cubeFramebuffers||(a.cubeFramebuffers={}),U=a.cubeFramebuffers[I]):x&&v===!1?U=this._xrFramebuffer:(a.framebuffers||(a.framebuffers={}),U=a.framebuffers[I]),U===void 0){U=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,U);const F=e.textures,k=[];if(p){a.cubeFramebuffers[I]=U;const{textureGPU:B}=this.get(F[0]),z=this.renderer._activeCubeFace,Q=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+z,B,Q)}else{a.framebuffers[I]=U;for(let B=0;B<F.length;B++){const z=F[B],Q=this.get(z);Q.renderTarget=e.renderTarget,Q.cacheKey=I;const ye=t.COLOR_ATTACHMENT0+B;if(o.multiview)C.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,ye,Q.textureGPU,0,c,0,2);else if(m||y){const _e=this.renderer._activeCubeFace,Te=this.renderer._activeMipmapLevel;t.framebufferTextureLayer(t.FRAMEBUFFER,ye,Q.textureGPU,Te,_e)}else if(N)S.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,ye,t.TEXTURE_2D,Q.textureGPU,0,c);else{const _e=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,ye,t.TEXTURE_2D,Q.textureGPU,_e)}}}const G=d?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(o._autoAllocateDepthBuffer===!0){const B=t.createRenderbuffer();this.textureUtils.setupRenderBufferStorage(B,e,0,N),a.xrDepthRenderbuffer=B,k.push(d?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT),t.bindRenderbuffer(t.RENDERBUFFER,B),t.framebufferRenderbuffer(t.FRAMEBUFFER,G,t.RENDERBUFFER,B)}else if(e.depthTexture!==null){k.push(d?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT);const B=this.get(e.depthTexture);if(B.renderTarget=e.renderTarget,B.cacheKey=I,o.multiview)C.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,G,B.textureGPU,0,c,0,2);else if(v&&N)S.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,G,t.TEXTURE_2D,B.textureGPU,0,c);else if(e.depthTexture.isArrayTexture){const z=this.renderer._activeCubeFace;t.framebufferTextureLayer(t.FRAMEBUFFER,G,B.textureGPU,0,z)}else if(e.depthTexture.isCubeTexture){const z=this.renderer._activeCubeFace;t.framebufferTexture2D(t.FRAMEBUFFER,G,t.TEXTURE_CUBE_MAP_POSITIVE_X+z,B.textureGPU,0)}else t.framebufferTexture2D(t.FRAMEBUFFER,G,t.TEXTURE_2D,B.textureGPU,0)}a.depthInvalidationArray=k}else{if(this._isRenderCameraDepthArray(e)){n.bindFramebuffer(t.FRAMEBUFFER,U);const k=this.renderer._activeCubeFace,G=this.get(e.depthTexture),B=d?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.framebufferTextureLayer(t.FRAMEBUFFER,B,G.textureGPU,0,k)}if((x||N||o.multiview)&&o._isOpaqueFramebuffer!==!0){n.bindFramebuffer(t.FRAMEBUFFER,U);const k=this.get(e.textures[0]);o.multiview?C.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,k.textureGPU,0,c,0,2):N?S.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,k.textureGPU,0,c):t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,k.textureGPU,0);const G=d?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(o._autoAllocateDepthBuffer===!0){const B=a.xrDepthRenderbuffer;t.bindRenderbuffer(t.RENDERBUFFER,B),t.framebufferRenderbuffer(t.FRAMEBUFFER,G,t.RENDERBUFFER,B)}else{const B=this.get(e.depthTexture);o.multiview?C.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,G,B.textureGPU,0,c,0,2):N?S.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,G,t.TEXTURE_2D,B.textureGPU,0,c):t.framebufferTexture2D(t.FRAMEBUFFER,G,t.TEXTURE_2D,B.textureGPU,0)}}}if(c>0&&N===!1&&!o.multiview){if(w===void 0){const F=[];w=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,w);const k=[],G=e.textures;for(let B=0;B<G.length;B++){k[B]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,k[B]),F.push(t.COLOR_ATTACHMENT0+B);const z=e.textures[B],Q=this.get(z);t.renderbufferStorageMultisample(t.RENDERBUFFER,c,Q.glInternalFormat,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+B,t.RENDERBUFFER,k[B])}if(t.bindRenderbuffer(t.RENDERBUFFER,null),a.msaaFrameBuffer=w,a.msaaRenderbuffers=k,u&&M===void 0){M=t.createRenderbuffer(),this.textureUtils.setupRenderBufferStorage(M,e,c),a.depthRenderbuffer=M;const B=d?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;F.push(B)}a.invalidationArray=F}r=a.msaaFrameBuffer}else r=U;n.drawBuffers(e,U)}n.bindFramebuffer(t.FRAMEBUFFER,r)}_getVaoKey(e){let t="";for(let n=0;n<e.length;n++){const r=this.get(e[n]);t+=":"+r.id}return t}_createVao(e){const{gl:t}=this,n=t.createVertexArray();t.bindVertexArray(n);for(let r=0;r<e.length;r++){const o=e[r],a=this.get(o);t.bindBuffer(t.ARRAY_BUFFER,a.bufferGPU),t.enableVertexAttribArray(r);let c,u;o.isInterleavedBufferAttribute===!0?(c=o.data.stride*a.bytesPerElement,u=o.offset*a.bytesPerElement):(c=0,u=0),a.isInteger?t.vertexAttribIPointer(r,o.itemSize,a.type,c,u):t.vertexAttribPointer(r,o.itemSize,a.type,o.normalized,c,u),o.isInstancedBufferAttribute&&!o.isInterleavedBufferAttribute?t.vertexAttribDivisor(r,o.meshPerAttribute):o.isInterleavedBufferAttribute&&o.data.isInstancedInterleavedBuffer&&t.vertexAttribDivisor(r,o.data.meshPerAttribute)}return t.bindBuffer(t.ARRAY_BUFFER,null),n}_getTransformFeedback(e){let t="";for(let o=0;o<e.length;o++)t+=":"+e[o].id;let n=this.transformFeedbackCache[t];if(n!==void 0)return n;const{gl:r}=this;n=r.createTransformFeedback(),r.bindTransformFeedback(r.TRANSFORM_FEEDBACK,n);for(let o=0;o<e.length;o++){const a=e[o];r.bindBufferBase(r.TRANSFORM_FEEDBACK_BUFFER,o,a.transformBuffer)}return r.bindTransformFeedback(r.TRANSFORM_FEEDBACK,null),this.transformFeedbackCache[t]=n,n}_setupBindings(e,t){const n=this.gl;for(const r of e)for(const o of r.bindings){const c=this.get(o).index;if(o.isUniformsGroup||o.isUniformBuffer){const u=n.getUniformBlockIndex(t,o.name);n.uniformBlockBinding(t,u,c)}else if(o.isSampledTexture){const u=n.getUniformLocation(t,o.name);n.uniform1i(u,c)}}}_bindUniforms(e){const{gl:t,state:n}=this;for(const r of e)for(const o of r.bindings){const a=this.get(o),c=a.index;o.isUniformsGroup||o.isUniformBuffer?n.bindBufferBase(t.UNIFORM_BUFFER,c,a.bufferGPU):o.isSampledTexture&&n.bindTexture(a.glTextureType,a.textureGPU,t.TEXTURE0+c)}}_resolveRenderTarget(e){const{gl:t,state:n}=this,r=e.renderTarget;if(e.textures!==null&&r){const o=this.get(r);if(r.samples>0&&this._useMultisampledExtension(r)===!1){const a=o.framebuffers[e.getCacheKey()];let c=t.COLOR_BUFFER_BIT;r.resolveDepthBuffer&&(r.depthBuffer&&(c|=t.DEPTH_BUFFER_BIT),r.stencilBuffer&&r.resolveStencilBuffer&&(c|=t.STENCIL_BUFFER_BIT));const u=o.msaaFrameBuffer,d=o.msaaRenderbuffers,p=e.textures,m=p.length>1;if(n.bindFramebuffer(t.READ_FRAMEBUFFER,u),n.bindFramebuffer(t.DRAW_FRAMEBUFFER,a),m)for(let y=0;y<p.length;y++)t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+y,t.RENDERBUFFER,null),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+y,t.TEXTURE_2D,null,0);for(let y=0;y<p.length;y++){if(m){const{textureGPU:x}=this.get(p[y]);t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.RENDERBUFFER,d[y]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,x,0)}if(e.scissor){const{x,y:v,width:w,height:M}=e.scissorValue,S=e.height-M-v;t.blitFramebuffer(x,S,x+w,S+M,x,S,x+w,S+M,c,t.NEAREST)}else t.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,c,t.NEAREST)}if(m)for(let y=0;y<p.length;y++){const{textureGPU:x}=this.get(p[y]);t.framebufferRenderbuffer(t.READ_FRAMEBUFFER,t.COLOR_ATTACHMENT0+y,t.RENDERBUFFER,d[y]),t.framebufferTexture2D(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0+y,t.TEXTURE_2D,x,0)}this._supportsInvalidateFramebuffer===!0&&t.invalidateFramebuffer(t.READ_FRAMEBUFFER,o.invalidationArray)}else if(r.resolveDepthBuffer===!1&&o.framebuffers){const a=o.framebuffers[e.getCacheKey()];n.bindFramebuffer(t.DRAW_FRAMEBUFFER,a),t.invalidateFramebuffer(t.DRAW_FRAMEBUFFER,o.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 bg={PointList:"point-list",LineList:"line-list",LineStrip:"line-strip",TriangleList:"triangle-list",TriangleStrip:"triangle-strip"},yp=typeof self!="undefined"?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},$r={Never:"never",Less:"less",Equal:"equal",LessEqual:"less-equal",Greater:"greater",NotEqual:"not-equal",GreaterEqual:"greater-equal",Always:"always"},bo={Store:"store"},Ii={Load:"load",Clear:"clear"},q2={CCW:"ccw",CW:"cw"},X2={None:"none",Back:"back"},Sg={Uint16:"uint16",Uint32:"uint32"},fe={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"},p1={ClampToEdge:"clamp-to-edge",Repeat:"repeat",MirrorRepeat:"mirror-repeat"},_p={Linear:"linear",Nearest:"nearest"},gi={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"},xp={Add:"add",Subtract:"subtract",ReverseSubtract:"reverse-subtract",Min:"min",Max:"max"},j2={None:0,All:15},Jd={Keep:"keep",Zero:"zero",Replace:"replace",Invert:"invert",IncrementClamp:"increment-clamp",DecrementClamp:"decrement-clamp",IncrementWrap:"increment-wrap",DecrementWrap:"decrement-wrap"},m1={Storage:"storage",ReadOnlyStorage:"read-only-storage"},g1={WriteOnly:"write-only",ReadOnly:"read-only",ReadWrite:"read-write"},Y2={NonFiltering:"non-filtering",Comparison:"comparison"},vp={Float:"float",UnfilterableFloat:"unfilterable-float",Depth:"depth",SInt:"sint",UInt:"uint"},Z2={TwoD:"2d",ThreeD:"3d"},lr={TwoD:"2d",TwoDArray:"2d-array",Cube:"cube",ThreeD:"3d"},l$={All:"all"},Mb={Vertex:"vertex",Instance:"instance"},y1={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"},K2={"texture-compression-s3tc":"texture-compression-bc","texture-compression-etc1":"texture-compression-etc2"};class c$ extends L2{constructor(e,t,n){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n}update(){const{textureNode:e}=this;return this.texture!==e.value?(this.texture=e.value,!0):super.update()}}class u$ extends R2{constructor(e,t){super(e,t?t.array:null),this.attribute=t,this.isStorageBuffer=!0}}let h$=0;class d$ extends u${constructor(e,t){super("StorageBuffer_"+h$++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:zr.READ_WRITE,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class f$ extends jd{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;
}
`,n=`
@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 );
}
`,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, vec2( vTex.x, 1.0 - vTex.y ) );
}
`;this.mipmapSampler=e.createSampler({minFilter:_p.Linear}),this.flipYSampler=e.createSampler({minFilter:_p.Nearest}),this.transferPipelines={},this.flipYPipelines={},this.mipmapVertexShaderModule=e.createShaderModule({label:"mipmapVertex",code:t}),this.mipmapFragmentShaderModule=e.createShaderModule({label:"mipmapFragment",code:n}),this.flipYFragmentShaderModule=e.createShaderModule({label:"flipYFragment",code:r})}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:bg.TriangleStrip,stripIndexFormat:Sg.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:bg.TriangleStrip,stripIndexFormat:Sg.Uint32},layout:"auto"}),this.flipYPipelines[e]=t),t}flipY(e,t,n=0){const r=t.format,{width:o,height:a}=t.size,c=this.getTransferPipeline(r),u=this.getFlipYPipeline(r),d=this.device.createTexture({size:{width:o,height:a,depthOrArrayLayers:1},format:r,usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.TEXTURE_BINDING}),p=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:lr.TwoD,baseArrayLayer:n}),m=d.createView({baseMipLevel:0,mipLevelCount:1,dimension:lr.TwoD,baseArrayLayer:0}),y=this.device.createCommandEncoder({}),x=(v,w,M)=>{const S=v.getBindGroupLayout(0),C=this.device.createBindGroup({layout:S,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:w}]}),N=y.beginRenderPass({colorAttachments:[{view:M,loadOp:Ii.Clear,storeOp:bo.Store,clearValue:[0,0,0,0]}]});N.setPipeline(v),N.setBindGroup(0,C),N.draw(4,1,0,0),N.end()};x(c,p,m),x(u,m,p),this.device.queue.submit([y.finish()]),d.destroy()}generateMipmaps(e,t,n=0,r=null){const o=this.get(e);o.layers===void 0&&(o.layers=[]);const a=o.layers[n]||this._mipmapCreateBundles(e,t,n),c=r||this.device.createCommandEncoder({label:"mipmapEncoder"});this._mipmapRunBundles(c,a),r===null&&this.device.queue.submit([c.finish()]),o.layers[n]=a}_mipmapCreateBundles(e,t,n){const r=this.getTransferPipeline(t.format),o=r.getBindGroupLayout(0);let a=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:lr.TwoD,baseArrayLayer:n});const c=[];for(let u=1;u<t.mipLevelCount;u++){const d=this.device.createBindGroup({layout:o,entries:[{binding:0,resource:this.mipmapSampler},{binding:1,resource:a}]}),p=e.createView({baseMipLevel:u,mipLevelCount:1,dimension:lr.TwoD,baseArrayLayer:n}),m={colorAttachments:[{view:p,loadOp:Ii.Clear,storeOp:bo.Store,clearValue:[0,0,0,0]}]},y=this.device.createRenderBundleEncoder({colorFormats:[t.format]});y.setPipeline(r),y.setBindGroup(0,d),y.draw(4,1,0,0),c.push({renderBundles:[y.finish()],passDescriptor:m}),a=p}return c}_mipmapRunBundles(e,t){const n=t.length;for(let r=0;r<n;r++){const o=t[r],a=e.beginRenderPass(o.passDescriptor);a.executeBundles(o.renderBundles),a.end()}}}const p$={[y_]:"never",[Vl]:"less",[__]:"equal",[Bp]:"less-equal",[x_]:"greater",[Op]:"greater-equal",[b_]:"always",[v_]:"not-equal"},m$=[0,1,3,2,4,5];class g${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,n=e.minFilter+"-"+e.magFilter+"-"+e.wrapS+"-"+e.wrapT+"-"+(e.wrapR||"0")+"-"+e.anisotropy+"-"+(e.compareFunction||0);let r=this._samplerCache.get(n);if(r===void 0){const a={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};a.magFilter===_p.Linear&&a.minFilter===_p.Linear&&a.mipmapFilter===_p.Linear&&(a.maxAnisotropy=e.anisotropy),e.isDepthTexture&&e.compareFunction!==null&&(a.compare=p$[e.compareFunction]),r={sampler:t.device.createSampler(a),usedTimes:0},this._samplerCache.set(n,r)}const o=t.get(e);if(o.sampler!==r.sampler){if(o.sampler!==void 0){const a=this._samplerCache.get(o.samplerKey);a.usedTimes--,a.usedTimes===0&&this._samplerCache.delete(o.samplerKey)}o.samplerKey=n,o.sampler=r.sampler,r.usedTimes++}return n}createDefaultTexture(e){let t;const n=_1(e);e.isCubeTexture?t=this._getDefaultCubeTextureGPU(n):t=this._getDefaultTextureGPU(n),this.backend.get(e).texture=t}createTexture(e,t={}){const n=this.backend,r=n.get(e);if(r.initialized)throw new Error("WebGPUTextureUtils: Texture already initialized.");if(e.isExternalTexture){r.texture=e.sourceTexture,r.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:o,height:a,depth:c,levels:u}=t;e.isFramebufferTexture&&(t.renderTarget?t.format=this.backend.utils.getCurrentColorFormat(t.renderTarget):t.format=this.backend.utils.getPreferredCanvasFormat());const d=this._getDimension(e),p=e.internalFormat||t.format||_1(e,n.device);r.format=p;const{samples:m,primarySamples:y,isMSAA:x}=n.utils.getTextureSampleData(e);let v=GPUTextureUsage.TEXTURE_BINDING|GPUTextureUsage.COPY_DST|GPUTextureUsage.COPY_SRC;e.isStorageTexture===!0&&(v|=GPUTextureUsage.STORAGE_BINDING),e.isCompressedTexture!==!0&&e.isCompressedArrayTexture!==!0&&p!==fe.RGB9E5UFloat&&(v|=GPUTextureUsage.RENDER_ATTACHMENT);const w={label:e.name,size:{width:o,height:a,depthOrArrayLayers:c},mipLevelCount:u,sampleCount:y,dimension:d,format:p,usage:v};if(p===void 0){Ie("WebGPURenderer: Texture format not supported."),this.createDefaultTexture(e);return}if(e.isCubeTexture&&(w.textureBindingViewDimension=lr.Cube),r.texture=n.device.createTexture(w),x){const M=Object.assign({},w);M.label=M.label+"-msaa",M.sampleCount=m,M.mipLevelCount=1,r.msaaTexture=n.device.createTexture(M)}r.initialized=!0,r.textureDescriptorGPU=w}destroyTexture(e,t=!1){const n=this.backend,r=n.get(e);r.texture!==void 0&&t===!1&&r.texture.destroy(),r.msaaTexture!==void 0&&r.msaaTexture.destroy(),n.delete(e)}generateMipmaps(e,t=null){const n=this.backend.get(e);if(e.isCubeTexture)for(let r=0;r<6;r++)this._generateMipmaps(n.texture,n.textureDescriptorGPU,r,t);else{const r=e.image.depth||1;for(let o=0;o<r;o++)this._generateMipmaps(n.texture,n.textureDescriptorGPU,o,t)}}getColorBuffer(){const e=this.backend,t=e.renderer.getCanvasTarget(),{width:n,height:r}=e.getDrawingBufferSize(),o=e.renderer.currentSamples,a=t.colorTexture,c=e.get(a);if(a.width===n&&a.height===r&&a.samples===o)return c.texture;let u=c.texture;return u&&u.destroy(),u=e.device.createTexture({label:"colorBuffer",size:{width:n,height:r,depthOrArrayLayers:1},sampleCount:e.utils.getSampleCount(e.renderer.currentSamples),format:e.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC}),a.source.width=n,a.source.height=r,a.samples=o,c.texture=u,u}getDepthBuffer(e=!0,t=!1){const n=this.backend,r=n.renderer.getCanvasTarget(),{width:o,height:a}=n.getDrawingBufferSize(),c=n.renderer.currentSamples,u=r.depthTexture;if(u.width===o&&u.height===a&&u.samples===c&&u.depth===e&&u.stencil===t)return n.get(u).texture;const d=n.get(u).texture;let p,m;if(t?(p=Rr,m=wo):e&&(p=tr,m=yi),d!==void 0){if(u.image.width===o&&u.image.height===a&&u.format===p&&u.type===m&&u.samples===c)return d;this.destroyTexture(u)}return u.name="depthBuffer",u.format=p,u.type=m,u.image.width=o,u.image.height=a,u.samples=c,this.createTexture(u,{width:o,height:a}),n.get(u).texture}updateTexture(e,t){const n=this.backend.get(e),r=e.mipmaps,{textureDescriptorGPU:o}=n;if(!(e.isRenderTargetTexture||o===void 0)){if(e.isDataTexture)if(r.length>0)for(let a=0,c=r.length;a<c;a++){const u=r[a];this._copyBufferToTexture(u,n.texture,o,0,e.flipY,0,a)}else this._copyBufferToTexture(t.image,n.texture,o,0,e.flipY);else if(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)for(let a=0;a<t.image.depth;a++)this._copyBufferToTexture(t.image,n.texture,o,a,e.flipY,a);else if(e.isCompressedTexture||e.isCompressedArrayTexture)this._copyCompressedBufferToTexture(e.mipmaps,n.texture,o);else if(e.isCubeTexture)this._copyCubeMapToTexture(e,n.texture,o);else if(r.length>0)for(let a=0,c=r.length;a<c;a++){const u=r[a];this._copyImageToTexture(u,n.texture,o,0,e.flipY,e.premultiplyAlpha,a)}else this._copyImageToTexture(t.image,n.texture,o,0,e.flipY,e.premultiplyAlpha);n.version=e.version}}copyTextureToBuffer(e,t,n,r,o,a){return mn(this,null,function*(){const c=this.backend.device,u=this.backend.get(e),d=u.texture,p=u.textureDescriptorGPU.format,m=this._getBytesPerTexel(p);let y=r*m;y=Math.ceil(y/256)*256;const x=c.createBuffer({size:(o-1)*y+r*m,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),v=c.createCommandEncoder();v.copyTextureToBuffer({texture:d,origin:{x:t,y:n,z:a}},{buffer:x,bytesPerRow:y},{width:r,height:o});const w=this._getTypedArrayType(p);c.queue.submit([v.finish()]),yield x.mapAsync(GPUMapMode.READ);const M=x.getMappedRange();return new w(M)})}dispose(){this._samplerCache.clear()}_getDefaultTextureGPU(e){let t=this.defaultTexture[e];if(t===void 0){const n=new fi;n.minFilter=ni,n.magFilter=ni,this.createTexture(n,{width:1,height:1,format:e}),this.defaultTexture[e]=t=n}return this.backend.get(t).texture}_getDefaultCubeTextureGPU(e){let t=this.defaultCubeTexture[e];if(t===void 0){const n=new nc;n.minFilter=ni,n.magFilter=ni,this.createTexture(n,{width:1,height:1,depth:6}),this.defaultCubeTexture[e]=t=n}return this.backend.get(t).texture}_copyCubeMapToTexture(e,t,n){const r=e.images,o=e.mipmaps;for(let a=0;a<6;a++){const c=r[a],u=e.flipY===!0?m$[a]:a;c.isDataTexture?this._copyBufferToTexture(c.image,t,n,u,e.flipY):this._copyImageToTexture(c,t,n,u,e.flipY,e.premultiplyAlpha);for(let d=0;d<o.length;d++){const m=o[d].images[a];m.isDataTexture?this._copyBufferToTexture(m.image,t,n,u,e.flipY,0,d+1):this._copyImageToTexture(m,t,n,u,e.flipY,e.premultiplyAlpha,d+1)}}}_copyImageToTexture(e,t,n,r,o,a,c=0){const u=this.backend.device,d=c>0?e.width:n.size.width,p=c>0?e.height:n.size.height;try{u.queue.copyExternalImageToTexture({source:e,flipY:o},{texture:t,mipLevel:c,origin:{x:0,y:0,z:r},premultipliedAlpha:a},{width:d,height:p,depthOrArrayLayers:1})}catch(m){}}_getPassUtils(){let e=this._passUtils;return e===null&&(this._passUtils=e=new f$(this.backend.device)),e}_generateMipmaps(e,t,n=0,r=null){this._getPassUtils().generateMipmaps(e,t,n,r)}_flipY(e,t,n=0){this._getPassUtils().flipY(e,t,n)}_copyBufferToTexture(e,t,n,r,o,a=0,c=0){const u=this.backend.device,d=e.data,p=this._getBytesPerTexel(n.format),m=e.width*p;u.queue.writeTexture({texture:t,mipLevel:c,origin:{x:0,y:0,z:r}},d,{offset:e.width*e.height*p*a,bytesPerRow:m},{width:e.width,height:e.height,depthOrArrayLayers:1}),o===!0&&this._flipY(t,n,r)}_copyCompressedBufferToTexture(e,t,n){const r=this.backend.device,o=this._getBlockData(n.format),a=n.size.depthOrArrayLayers>1;for(let c=0;c<e.length;c++){const u=e[c],d=u.width,p=u.height,m=a?n.size.depthOrArrayLayers:1,y=Math.ceil(d/o.width)*o.byteLength,x=y*Math.ceil(p/o.height);for(let v=0;v<m;v++)r.queue.writeTexture({texture:t,mipLevel:c,origin:{x:0,y:0,z:v}},u.data,{offset:v*x,bytesPerRow:y,rowsPerImage:Math.ceil(p/o.height)},{width:Math.ceil(d/o.width)*o.width,height:Math.ceil(p/o.height)*o.height,depthOrArrayLayers:1})}}_getBlockData(e){if(e===fe.BC1RGBAUnorm||e===fe.BC1RGBAUnormSRGB)return{byteLength:8,width:4,height:4};if(e===fe.BC2RGBAUnorm||e===fe.BC2RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===fe.BC3RGBAUnorm||e===fe.BC3RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===fe.BC4RUnorm||e===fe.BC4RSnorm)return{byteLength:8,width:4,height:4};if(e===fe.BC5RGUnorm||e===fe.BC5RGSnorm)return{byteLength:16,width:4,height:4};if(e===fe.BC6HRGBUFloat||e===fe.BC6HRGBFloat)return{byteLength:16,width:4,height:4};if(e===fe.BC7RGBAUnorm||e===fe.BC7RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===fe.ETC2RGB8Unorm||e===fe.ETC2RGB8UnormSRGB)return{byteLength:8,width:4,height:4};if(e===fe.ETC2RGB8A1Unorm||e===fe.ETC2RGB8A1UnormSRGB)return{byteLength:8,width:4,height:4};if(e===fe.ETC2RGBA8Unorm||e===fe.ETC2RGBA8UnormSRGB)return{byteLength:16,width:4,height:4};if(e===fe.EACR11Unorm)return{byteLength:8,width:4,height:4};if(e===fe.EACR11Snorm)return{byteLength:8,width:4,height:4};if(e===fe.EACRG11Unorm)return{byteLength:16,width:4,height:4};if(e===fe.EACRG11Snorm)return{byteLength:16,width:4,height:4};if(e===fe.ASTC4x4Unorm||e===fe.ASTC4x4UnormSRGB)return{byteLength:16,width:4,height:4};if(e===fe.ASTC5x4Unorm||e===fe.ASTC5x4UnormSRGB)return{byteLength:16,width:5,height:4};if(e===fe.ASTC5x5Unorm||e===fe.ASTC5x5UnormSRGB)return{byteLength:16,width:5,height:5};if(e===fe.ASTC6x5Unorm||e===fe.ASTC6x5UnormSRGB)return{byteLength:16,width:6,height:5};if(e===fe.ASTC6x6Unorm||e===fe.ASTC6x6UnormSRGB)return{byteLength:16,width:6,height:6};if(e===fe.ASTC8x5Unorm||e===fe.ASTC8x5UnormSRGB)return{byteLength:16,width:8,height:5};if(e===fe.ASTC8x6Unorm||e===fe.ASTC8x6UnormSRGB)return{byteLength:16,width:8,height:6};if(e===fe.ASTC8x8Unorm||e===fe.ASTC8x8UnormSRGB)return{byteLength:16,width:8,height:8};if(e===fe.ASTC10x5Unorm||e===fe.ASTC10x5UnormSRGB)return{byteLength:16,width:10,height:5};if(e===fe.ASTC10x6Unorm||e===fe.ASTC10x6UnormSRGB)return{byteLength:16,width:10,height:6};if(e===fe.ASTC10x8Unorm||e===fe.ASTC10x8UnormSRGB)return{byteLength:16,width:10,height:8};if(e===fe.ASTC10x10Unorm||e===fe.ASTC10x10UnormSRGB)return{byteLength:16,width:10,height:10};if(e===fe.ASTC12x10Unorm||e===fe.ASTC12x10UnormSRGB)return{byteLength:16,width:12,height:10};if(e===fe.ASTC12x12Unorm||e===fe.ASTC12x12UnormSRGB)return{byteLength:16,width:12,height:12}}_convertAddressMode(e){let t=p1.ClampToEdge;return e===Ea?t=p1.Repeat:e===Ca&&(t=p1.MirrorRepeat),t}_convertFilterMode(e){let t=_p.Linear;return(e===ni||e===Pp||e===Ra)&&(t=_p.Nearest),t}_getBytesPerTexel(e){if(e===fe.R8Unorm||e===fe.R8Snorm||e===fe.R8Uint||e===fe.R8Sint)return 1;if(e===fe.R16Uint||e===fe.R16Sint||e===fe.R16Float||e===fe.RG8Unorm||e===fe.RG8Snorm||e===fe.RG8Uint||e===fe.RG8Sint)return 2;if(e===fe.R32Uint||e===fe.R32Sint||e===fe.R32Float||e===fe.RG16Uint||e===fe.RG16Sint||e===fe.RG16Float||e===fe.RGBA8Unorm||e===fe.RGBA8UnormSRGB||e===fe.RGBA8Snorm||e===fe.RGBA8Uint||e===fe.RGBA8Sint||e===fe.BGRA8Unorm||e===fe.BGRA8UnormSRGB||e===fe.RGB9E5UFloat||e===fe.RGB10A2Unorm||e===fe.RG11B10UFloat||e===fe.Depth32Float||e===fe.Depth24Plus||e===fe.Depth24PlusStencil8||e===fe.Depth32FloatStencil8)return 4;if(e===fe.RG32Uint||e===fe.RG32Sint||e===fe.RG32Float||e===fe.RGBA16Uint||e===fe.RGBA16Sint||e===fe.RGBA16Float)return 8;if(e===fe.RGBA32Uint||e===fe.RGBA32Sint||e===fe.RGBA32Float)return 16}_getTypedArrayType(e){if(e===fe.R8Uint)return Uint8Array;if(e===fe.R8Sint)return Int8Array;if(e===fe.R8Unorm)return Uint8Array;if(e===fe.R8Snorm)return Int8Array;if(e===fe.RG8Uint)return Uint8Array;if(e===fe.RG8Sint)return Int8Array;if(e===fe.RG8Unorm)return Uint8Array;if(e===fe.RG8Snorm)return Int8Array;if(e===fe.RGBA8Uint)return Uint8Array;if(e===fe.RGBA8Sint)return Int8Array;if(e===fe.RGBA8Unorm||e===fe.RGBA8UnormSRGB)return Uint8Array;if(e===fe.RGBA8Snorm)return Int8Array;if(e===fe.R16Uint)return Uint16Array;if(e===fe.R16Sint)return Int16Array;if(e===fe.RG16Uint)return Uint16Array;if(e===fe.RG16Sint)return Int16Array;if(e===fe.RGBA16Uint)return Uint16Array;if(e===fe.RGBA16Sint)return Int16Array;if(e===fe.R16Float||e===fe.RG16Float||e===fe.RGBA16Float)return Uint16Array;if(e===fe.R32Uint)return Uint32Array;if(e===fe.R32Sint)return Int32Array;if(e===fe.R32Float)return Float32Array;if(e===fe.RG32Uint)return Uint32Array;if(e===fe.RG32Sint)return Int32Array;if(e===fe.RG32Float)return Float32Array;if(e===fe.RGBA32Uint)return Uint32Array;if(e===fe.RGBA32Sint)return Int32Array;if(e===fe.RGBA32Float)return Float32Array;if(e===fe.BGRA8Unorm||e===fe.BGRA8UnormSRGB)return Uint8Array;if(e===fe.RGB10A2Unorm||e===fe.RGB9E5UFloat||e===fe.RG11B10UFloat)return Uint32Array;if(e===fe.Depth32Float)return Float32Array;if(e===fe.Depth24Plus||e===fe.Depth24PlusStencil8)return Uint32Array;if(e===fe.Depth32FloatStencil8)return Float32Array}_getDimension(e){let t;return e.is3DTexture||e.isData3DTexture?t=Z2.ThreeD:t=Z2.TwoD,t}}function _1(i,e=null){const t=i.format,n=i.type,r=i.colorSpace,o=xn.getTransfer(r);let a;if(i.isCompressedTexture===!0||i.isCompressedArrayTexture===!0)switch(t){case Ol:case Ul:a=o===$t?fe.BC1RGBAUnormSRGB:fe.BC1RGBAUnorm;break;case kl:a=o===$t?fe.BC2RGBAUnormSRGB:fe.BC2RGBAUnorm;break;case zl:a=o===$t?fe.BC3RGBAUnormSRGB:fe.BC3RGBAUnorm;break;case Gh:a=fe.BC4RUnorm;break;case Wh:a=fe.BC4RSnorm;break;case tu:a=fe.BC5RGUnorm;break;case il:a=fe.BC5RGSnorm;break;case Vh:a=o===$t?fe.BC7RGBAUnormSRGB:fe.BC7RGBAUnorm;break;case Sh:case bh:a=o===$t?fe.ETC2RGB8UnormSRGB:fe.ETC2RGB8Unorm;break;case Mh:a=o===$t?fe.ETC2RGBA8UnormSRGB:fe.ETC2RGBA8Unorm;break;case Th:a=fe.EACR11Unorm;break;case wh:a=fe.EACR11Snorm;break;case eu:a=fe.EACRG11Unorm;break;case Ah:a=fe.EACRG11Snorm;break;case Eh:a=o===$t?fe.ASTC4x4UnormSRGB:fe.ASTC4x4Unorm;break;case Ch:a=o===$t?fe.ASTC5x4UnormSRGB:fe.ASTC5x4Unorm;break;case Rh:a=o===$t?fe.ASTC5x5UnormSRGB:fe.ASTC5x5Unorm;break;case Nh:a=o===$t?fe.ASTC6x5UnormSRGB:fe.ASTC6x5Unorm;break;case Ph:a=o===$t?fe.ASTC6x6UnormSRGB:fe.ASTC6x6Unorm;break;case Ih:a=o===$t?fe.ASTC8x5UnormSRGB:fe.ASTC8x5Unorm;break;case Lh:a=o===$t?fe.ASTC8x6UnormSRGB:fe.ASTC8x6Unorm;break;case Dh:a=o===$t?fe.ASTC8x8UnormSRGB:fe.ASTC8x8Unorm;break;case Fh:a=o===$t?fe.ASTC10x5UnormSRGB:fe.ASTC10x5Unorm;break;case Bh:a=o===$t?fe.ASTC10x6UnormSRGB:fe.ASTC10x6Unorm;break;case Oh:a=o===$t?fe.ASTC10x8UnormSRGB:fe.ASTC10x8Unorm;break;case Uh:a=o===$t?fe.ASTC10x10UnormSRGB:fe.ASTC10x10Unorm;break;case kh:a=o===$t?fe.ASTC12x10UnormSRGB:fe.ASTC12x10Unorm;break;case zh:a=o===$t?fe.ASTC12x12UnormSRGB:fe.ASTC12x12Unorm;break;case Ri:a=o===$t?fe.RGBA8UnormSRGB:fe.RGBA8Unorm;break;default:Be("WebGPURenderer: Unsupported texture format.",t)}else switch(t){case Ri:switch(n){case Kc:a=fe.RGBA8Snorm;break;case Jc:a=fe.RGBA16Sint;break;case jo:a=fe.RGBA16Uint;break;case yi:a=fe.RGBA32Uint;break;case er:a=fe.RGBA32Sint;break;case Di:a=o===$t?fe.RGBA8UnormSRGB:fe.RGBA8Unorm;break;case Hi:a=fe.RGBA16Float;break;case Si:a=fe.RGBA32Float;break;default:Be("WebGPURenderer: Unsupported texture type with RGBAFormat.",n)}break;case tf:switch(n){case Dp:a=fe.RGB9E5UFloat;break;case Fp:a=fe.RG11B10UFloat;break;default:Be("WebGPURenderer: Unsupported texture type with RGBFormat.",n)}break;case Qc:switch(n){case Kc:a=fe.R8Snorm;break;case Jc:a=fe.R16Sint;break;case jo:a=fe.R16Uint;break;case yi:a=fe.R32Uint;break;case er:a=fe.R32Sint;break;case Di:a=fe.R8Unorm;break;case Hi:a=fe.R16Float;break;case Si:a=fe.R32Float;break;default:Be("WebGPURenderer: Unsupported texture type with RedFormat.",n)}break;case Nr:switch(n){case Kc:a=fe.RG8Snorm;break;case Jc:a=fe.RG16Sint;break;case jo:a=fe.RG16Uint;break;case yi:a=fe.RG32Uint;break;case er:a=fe.RG32Sint;break;case Di:a=fe.RG8Unorm;break;case Hi:a=fe.RG16Float;break;case Si:a=fe.RG32Float;break;default:Be("WebGPURenderer: Unsupported texture type with RGFormat.",n)}break;case tr:switch(n){case jo:a=fe.Depth16Unorm;break;case yi:a=fe.Depth24Plus;break;case Si:a=fe.Depth32Float;break;default:Be("WebGPURenderer: Unsupported texture type with DepthFormat.",n)}break;case Rr:switch(n){case wo:a=fe.Depth24PlusStencil8;break;case Si:e&&e.features.has(y1.Depth32FloatStencil8)===!1&&Be('WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.'),a=fe.Depth32FloatStencil8;break;default:Be("WebGPURenderer: Unsupported texture type with DepthStencilFormat.",n)}break;case Bl:switch(n){case er:a=fe.R32Sint;break;case yi:a=fe.R32Uint;break;default:Be("WebGPURenderer: Unsupported texture type with RedIntegerFormat.",n)}break;case xh:switch(n){case er:a=fe.RG32Sint;break;case yi:a=fe.RG32Uint;break;default:Be("WebGPURenderer: Unsupported texture type with RGIntegerFormat.",n)}break;case vh:switch(n){case er:a=fe.RGBA32Sint;break;case yi:a=fe.RGBA32Uint;break;default:Be("WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.",n)}break;default:Be("WebGPURenderer: Unsupported texture format.",t)}return a}const y$=/^[fn]*\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)\s*[\-\>]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,_$=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/ig,J2={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"},x$=i=>{i=i.trim();const e=i.match(y$);if(e!==null&&e.length===4){const t=e[2],n=[];let r=null;for(;(r=_$.exec(t))!==null;)n.push({name:r[1],type:r[2]});const o=[];for(let p=0;p<n.length;p++){const{name:m,type:y}=n[p];let x=y;x.startsWith("ptr")?x="pointer":(x.startsWith("texture")&&(x=y.split("<")[0]),x=J2[x]),o.push(new n1(x,m))}const a=i.substring(e[0].length),c=e[3]||"void",u=e[1]!==void 0?e[1]:"";return{type:J2[c]||c,inputs:o,name:u,inputsCode:t,blockCode:a,outputType:c}}else throw new Error("FunctionNode: Function is not a WGSL code.")};class v$ extends r1{constructor(e){const{type:t,inputs:n,name:r,inputsCode:o,blockCode:a,outputType:c}=x$(e);super(t,n,r),this.inputsCode=o,this.blockCode=a,this.outputType=c}getCode(e=this.name){const t=this.outputType!=="void"?"-> "+this.outputType:"";return`fn ${e} ( ${this.inputsCode.trim()} ) ${t}`+this.blockCode}}class b$ extends v2{parseFunction(e){return new v$(e)}}const S$={[zr.READ_ONLY]:"read",[zr.WRITE_ONLY]:"write",[zr.READ_WRITE]:"read_write"},Q2={[Ea]:"repeat",[ki]:"clamp",[Ca]:"mirror"},Tb={vertex:yp.VERTEX,fragment:yp.FRAGMENT,compute:yp.COMPUTE},e3={instance:!0,swizzleAssign:!1,storageBuffer:!0},M$={"^^":"tsl_xor"},T$={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>"},t3={},Zy={tsl_xor:new Ar("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new Ar("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new Ar("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new Ar("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new Ar("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new Ar("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new Ar("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new Ar("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 Ar("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 Ar("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new Ar("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 Ar("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new Ar(`
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 );
}
`)},w$={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>",floatpack_snorm_2x16:"pack2x16snorm",floatpack_unorm_2x16:"pack2x16unorm",floatpack_float16_2x16:"pack2x16float",floatunpack_snorm_2x16:"unpack2x16snorm",floatunpack_unorm_2x16:"unpack2x16unorm",floatunpack_float16_2x16:"unpack2x16float"};let n3="";(typeof navigator!="undefined"&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(n3+=`diagnostic( off, derivative_uniformity );
`);class A$ extends _2{constructor(e,t){super(e,t,new b$),this.uniformGroups={},this.builtins={},this.directives={},this.scopedArrays=new Map}_generateTextureSample(e,t,n,r,o,a=this.shaderStage){return a==="fragment"?r?o?`textureSample( ${t}, ${t}_sampler, ${n}, ${r}, ${o} )`:`textureSample( ${t}, ${t}_sampler, ${n}, ${r} )`:o?`textureSample( ${t}, ${t}_sampler, ${n}, ${o} )`:`textureSample( ${t}, ${t}_sampler, ${n} )`:this.generateTextureSampleLevel(e,t,n,"0",r)}generateTextureSampleLevel(e,t,n,r,o,a){return this.isUnfilterable(e)===!1?a?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,a,r):this.generateTextureLod(e,t,n,o,a,r)}generateWrapFunction(e){const t=`tsl_coord_${Q2[e.wrapS]}S_${Q2[e.wrapT]}_${e.is3DTexture||e.isData3DTexture?"3d":"2d"}T`;let n=t3[t];if(n===void 0){const r=[],o=e.is3DTexture||e.isData3DTexture?"vec3f":"vec2f";let a=`fn ${t}( coord : ${o} ) -> ${o} {
return ${o}(
`;const c=(u,d)=>{u===Ea?(r.push(Zy.repeatWrapping_float),a+=` tsl_repeatWrapping_float( coord.${d} )`):u===ki?(r.push(Zy.clampWrapping_float),a+=` tsl_clampWrapping_float( coord.${d} )`):u===Ca?(r.push(Zy.mirrorWrapping_float),a+=` tsl_mirrorWrapping_float( coord.${d} )`):(a+=` coord.${d}`,Ie(`WebGPURenderer: Unsupported texture wrap type "${u}" for vertex shader.`))};c(e.wrapS,"x"),a+=`,
`,c(e.wrapT,"y"),(e.is3DTexture||e.isData3DTexture)&&(a+=`,
`,c(e.wrapR,"z")),a+=`
);
}
`,t3[t]=n=new Ar(a,r)}return n.build(this),t}generateArrayDeclaration(e,t){return`array< ${this.getType(e)}, ${t} >`}generateTextureDimension(e,t,n){const r=this.getDataFromNode(e,this.shaderStage,this.globalCache);r.dimensionsSnippet===void 0&&(r.dimensionsSnippet={});let o=r.dimensionsSnippet[n];if(r.dimensionsSnippet[n]===void 0){let a,c;const{primarySamples:u}=this.renderer.backend.utils.getTextureSampleData(e),d=u>1;e.is3DTexture||e.isData3DTexture?c="vec3<u32>":c="vec2<u32>",d||e.isStorageTexture?a=t:a=`${t}${n?`, u32( ${n} )`:""}`,o=new bv(new wv(`textureDimensions( ${a} )`,c)),r.dimensionsSnippet[n]=o,(e.isArrayTexture||e.isDataArrayTexture||e.is3DTexture||e.isData3DTexture)&&(r.arrayLayerCount=new bv(new wv(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(r.cubeFaceCount=new bv(new wv("6u","u32")))}return o.build(this)}generateFilteredTexture(e,t,n,r,o="0u"){this._include("biquadraticTexture");const a=this.generateWrapFunction(e),c=this.generateTextureDimension(e,t,o);return r&&(n=`${n} + vec2<f32>(${r}) / ${c}`),`tsl_biquadraticTexture( ${t}, ${a}( ${n} ), ${c}, u32( ${o} ) )`}generateTextureLod(e,t,n,r,o,a="0u"){const c=this.generateWrapFunction(e),u=this.generateTextureDimension(e,t,a),d=e.is3DTexture||e.isData3DTexture?"vec3":"vec2";o&&(n=`${n} + ${d}<f32>(${o}) / ${d}<f32>( ${u} )`);const p=`${d}<u32>( ${c}( ${n} ) * ${d}<f32>( ${u} ) )`;return this.generateTextureLoad(e,t,p,a,r,null)}generateTextureLoad(e,t,n,r,o,a){r===null&&(r="0u"),a&&(n=`${n} + ${a}`);let c;return o?c=`textureLoad( ${t}, ${n}, ${o}, u32( ${r} ) )`:(c=`textureLoad( ${t}, ${n}, u32( ${r} ) )`,this.renderer.backend.compatibilityMode&&e.isDepthTexture&&(c+=".x")),c}generateTextureStore(e,t,n,r,o){let a;return r?a=`textureStore( ${t}, ${n}, ${r}, ${o} )`:a=`textureStore( ${t}, ${n}, ${o} )`,a}isSampleCompare(e){return e.isDepthTexture===!0&&e.compareFunction!==null}isUnfilterable(e){return this.getComponentTypeFromTexture(e)!=="float"||!this.isAvailable("float32Filterable")&&e.isDataTexture===!0&&e.type===Si||this.isSampleCompare(e)===!1&&e.minFilter===ni&&e.magFilter===ni||this.renderer.backend.utils.getTextureSampleData(e).primarySamples>1}generateTexture(e,t,n,r,o,a=this.shaderStage){let c=null;return this.isUnfilterable(e)?c=this.generateTextureLod(e,t,n,r,o,"0",a):c=this._generateTextureSample(e,t,n,r,o,a),c}generateTextureGrad(e,t,n,r,o,a,c=this.shaderStage){if(c==="fragment")return a?`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${r[0]}, ${r[1]}, ${a} )`:`textureSampleGrad( ${t}, ${t}_sampler, ${n}, ${r[0]}, ${r[1]} )`;Be(`WebGPURenderer: THREE.TextureNode.gradient() does not support ${c} shader.`)}generateTextureCompare(e,t,n,r,o,a,c=this.shaderStage){if(c==="fragment")return e.isDepthTexture===!0&&e.isArrayTexture===!0?a?`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${o}, ${r}, ${a} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${o}, ${r} )`:a?`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${r}, ${a} )`:`textureSampleCompare( ${t}, ${t}_sampler, ${n}, ${r} )`;Be(`WebGPURenderer: THREE.DepthTexture.compareFunction() does not support ${c} shader.`)}generateTextureLevel(e,t,n,r,o,a){return this.isUnfilterable(e)===!1?a?`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r}, ${a} )`:`textureSampleLevel( ${t}, ${t}_sampler, ${n}, ${r} )`:this.isFilteredTexture(e)?this.generateFilteredTexture(e,t,n,a,r):this.generateTextureLod(e,t,n,o,a,r)}generateTextureBias(e,t,n,r,o,a,c=this.shaderStage){if(c==="fragment")return a?`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${r}, ${a} )`:`textureSampleBias( ${t}, ${t}_sampler, ${n}, ${r} )`;Be(`WebGPURenderer: THREE.TextureNode.biasNode does not support ${c} 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 n=e.name,r=e.type;return r==="texture"||r==="cubeTexture"||r==="cubeDepthTexture"||r==="storageTexture"||r==="texture3D"?n:r==="buffer"||r==="storageBuffer"||r==="indirectStorageBuffer"?this.isCustomStruct(e)?n:n+".value":e.groupNode.name+"."+n}return super.getPropertyName(e)}getOutputStructName(){return"output"}getFunctionOperator(e){const t=M$[e];return t!==void 0?(this._include(t),t):null}getNodeAccess(e,t){return t!=="compute"?e.isAtomic===!0?(Ie("WebGPURenderer: Atomic operations are only supported in compute shaders."),zr.READ_WRITE):zr.READ_ONLY:e.access}getStorageAccess(e,t){return S$[this.getNodeAccess(e,t)]}getUniformFromNode(e,t,n,r=null){const o=super.getUniformFromNode(e,t,n,r),a=this.getDataFromNode(e,n,this.globalCache);if(a.uniformGPU===void 0){let c;const u=e.groupNode,d=u.name,p=this.getBindGroupArray(d,n);if(t==="texture"||t==="cubeTexture"||t==="cubeDepthTexture"||t==="storageTexture"||t==="texture3D"){let m=null;const y=this.getNodeAccess(e,n);if(t==="texture"||t==="storageTexture"?e.value.is3DTexture===!0?m=new u1(o.name,o.node,u,y):m=new vb(o.name,o.node,u,y):t==="cubeTexture"||t==="cubeDepthTexture"?m=new D2(o.name,o.node,u,y):t==="texture3D"&&(m=new u1(o.name,o.node,u,y)),m.store=e.isStorageTextureNode===!0,m.mipLevel=m.store?e.mipLevel:0,m.setVisibility(Tb[n]),this.isUnfilterable(e.value)===!1&&m.store===!1){const x=new c$(`${o.name}_sampler`,o.node,u);x.setVisibility(Tb[n]),p.push(x,m),c=[x,m]}else p.push(m),c=[m]}else if(t==="buffer"||t==="storageBuffer"||t==="indirectStorageBuffer"){const m=this.getSharedDataFromNode(e);let y=m.buffer;if(y===void 0){const x=t==="buffer"?P2:d$;y=new x(e,u),m.buffer=y}y.setVisibility(y.getVisibility()|Tb[n]),p.push(y),c=y,o.name=r||"NodeBuffer_"+o.id}else{const m=this.uniformGroups[n]||(this.uniformGroups[n]={});let y=m[d];y===void 0&&(y=new I2(d,u),y.setVisibility(Tb[n]),m[d]=y,p.push(y)),c=this.getNodeUniform(o,t),y.addUniform(c)}a.uniformGPU=c}return o}getBuiltin(e,t,n,r=this.shaderStage){const o=this.builtins[r]||(this.builtins[r]=new Map);return o.has(e)===!1&&o.set(e,{name:e,property:t,type:n}),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,n=this.flowShaderNode(e),r=[];for(const a of t.inputs)r.push(a.name+" : "+this.getType(a.type));let o=`fn ${t.name}( ${r.join(", ")} ) -> ${this.getType(t.type)} {
${n.vars}
${n.code}
`;return n.result&&(o+=` return ${n.result};
`),o+=`
}
`,o}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=[],n=this.directives[e];if(n!==void 0)for(const r of n)t.push(`enable ${r};`);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=[],n=this.builtins[e];if(n!==void 0)for(const{name:r,property:o,type:a}of n.values())t.push(`@builtin( ${r} ) ${o} : ${a}`);return t.join(`,
`)}getScopedArray(e,t,n,r){return this.scopedArrays.has(e)===!1&&this.scopedArrays.set(e,{name:e,scope:t,bufferType:n,bufferCount:r}),e}getScopedArrays(e){if(e!=="compute")return;const t=[];for(const{name:n,scope:r,bufferType:o,bufferCount:a}of this.scopedArrays.values()){const c=this.getType(o);t.push(`var<${r}> ${n}: array< ${c}, ${a} >;`)}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 n=this.getBuiltins("attribute");n&&t.push(n);const r=this.getAttributesArray();for(let o=0,a=r.length;o<a;o++){const c=r[o],u=c.name,d=this.getType(c.type);t.push(`@location( ${o} ) ${u} : ${d}`)}}return t.join(`,
`)}getStructMembers(e){const t=[];for(const n of e.members){const r=e.output?"@location( "+n.index+" ) ":"";let o=this.getType(n.type);n.atomic&&(o="atomic< "+o+" >"),t.push(` ${r+n.name} : ${o}`)}return e.output&&t.push(` ${this.getBuiltins("output")}`),t.join(`,
`)}getStructs(e){let t="";const n=this.structs[e];if(n.length>0){const r=[];for(const o of n){let a=`struct ${o.name} {
`;a+=this.getStructMembers(o),a+=`
};`,r.push(a)}t=`
`+r.join(`
`)+`
`}return t}getVar(e,t,n=null){let r=`var ${t} : `;return n!==null?r+=this.generateArrayDeclaration(e,n):r+=this.getType(e),r}getVars(e){const t=[],n=this.vars[e];if(n!==void 0)for(const r of n)t.push(` ${this.getVar(r.type,r.name,r.count)};`);return`
${t.join(`
`)}
`}getVaryings(e){const t=[];if(e==="vertex"&&this.getBuiltin("position","Vertex","vec4<f32>","vertex"),e==="vertex"||e==="fragment"){const o=this.varyings,a=this.vars[e];for(let c=0;c<o.length;c++){const u=o[c];if(u.needsInterpolation){let d=`@location( ${c} )`;if(u.interpolationType){const p=u.interpolationSampling!==null?`, ${u.interpolationSampling} )`:" )";d+=` @interpolate( ${u.interpolationType}${p}`}else/^(int|uint|ivec|uvec)/.test(u.type)&&(d+=` @interpolate( ${this.renderer.backend.compatibilityMode?"flat, either":"flat"} )`);t.push(`${d} ${u.name} : ${this.getType(u.type)}`)}else e==="vertex"&&a.includes(u)===!1&&a.push(u)}}const n=this.getBuiltins(e);n&&t.push(n);const r=t.join(`,
`);return e==="vertex"?this._getWGSLStruct("VaryingsStruct"," "+r):r}isCustomStruct(e){const t=e.value,n=e.node,r=(t.isBufferAttribute||t.isInstancedBufferAttribute)&&n.structTypeNode!==null,o=n.value&&n.value.array&&typeof n.value.itemSize=="number"&&n.value.array.length>n.value.itemSize;return r&&!o}getUniforms(e){const t=this.uniforms[e],n=[],r=[],o=[],a={};for(const u of t){const d=u.groupNode.name,p=this.bindingsIndexes[d];if(u.type==="texture"||u.type==="cubeTexture"||u.type==="cubeDepthTexture"||u.type==="storageTexture"||u.type==="texture3D"){const m=u.node.value;this.isUnfilterable(m)===!1&&u.node.isStorageTextureNode!==!0&&(this.isSampleCompare(m)?n.push(`@binding( ${p.binding++} ) @group( ${p.group} ) var ${u.name}_sampler : sampler_comparison;`):n.push(`@binding( ${p.binding++} ) @group( ${p.group} ) var ${u.name}_sampler : sampler;`));let y,x="";const{primarySamples:v}=this.renderer.backend.utils.getTextureSampleData(m);if(v>1&&(x="_multisampled"),m.isCubeTexture===!0&&m.isDepthTexture===!0)y="texture_depth_cube";else if(m.isCubeTexture===!0)y="texture_cube<f32>";else if(m.isDepthTexture===!0)this.renderer.backend.compatibilityMode&&m.compareFunction===null?y=`texture${x}_2d<f32>`:y=`texture_depth${x}_2d${m.isArrayTexture===!0?"_array":""}`;else if(u.node.isStorageTextureNode===!0){const w=_1(m),M=this.getStorageAccess(u.node,e),S=u.node.value.is3DTexture,C=u.node.value.isArrayTexture;y=`texture_storage_${S?"3d":`2d${C?"_array":""}`}<${w}, ${M}>`}else if(m.isArrayTexture===!0||m.isDataArrayTexture===!0||m.isCompressedArrayTexture===!0)y="texture_2d_array<f32>";else if(m.is3DTexture===!0||m.isData3DTexture===!0)y="texture_3d<f32>";else{const w=this.getComponentTypeFromTexture(m).charAt(0);y=`texture${x}_2d<${w}32>`}n.push(`@binding( ${p.binding++} ) @group( ${p.group} ) var ${u.name} : ${y};`)}else if(u.type==="buffer"||u.type==="storageBuffer"||u.type==="indirectStorageBuffer"){const m=u.node,y=this.getType(m.getNodeType(this)),x=m.bufferCount,v=x>0&&u.type==="buffer"?", "+x:"",w=m.isStorageBufferNode?`storage, ${this.getStorageAccess(m,e)}`:"uniform";if(this.isCustomStruct(u))r.push(`@binding( ${p.binding++} ) @group( ${p.group} ) var<${w}> ${u.name} : ${y};`);else{const S=` value : array< ${m.isAtomic?`atomic<${y}>`:`${y}`}${v} >`;r.push(this._getWGSLStructBinding(u.name,S,w,p.binding++,p.group))}}else{const m=this.getType(this.getVectorType(u.type)),y=u.groupNode.name;(a[y]||(a[y]={index:p.binding++,id:p.group,snippets:[]})).snippets.push(` ${u.name} : ${m}`)}}for(const u in a){const d=a[u];o.push(this._getWGSLStructBinding(u,d.snippets.join(`,
`),"uniform",d.index,d.id))}return[...n,...r,...o].join(`
`)}buildCode(){const e=this.material!==null?{fragment:{},vertex:{}}:{compute:{}};this.sortBindingGroups();for(const t in e){this.shaderStage=t;const n=e[t];n.uniforms=this.getUniforms(t),n.attributes=this.getAttributes(t),n.varyings=this.getVaryings(t),n.structs=this.getStructs(t),n.vars=this.getVars(t),n.codes=this.getCodes(t),n.directives=this.getDirectives(t),n.scopedArrays=this.getScopedArrays(t);let r=`// code
`;r+=this.flowCode[t];const o=this.flowNodes[t],a=o[o.length-1],c=a.outputNode,u=c!==void 0&&c.isOutputStructNode===!0;for(const d of o){const p=this.getFlowData(d),m=d.name;if(m&&(r.length>0&&(r+=`
`),r+=` // flow -> ${m}
`),r+=`${p.code}
`,d===a&&t!=="compute"){if(r+=`// result
`,t==="vertex")r+=`varyings.Vertex = ${p.result};`;else if(t==="fragment")if(u)n.returnType=c.getNodeType(this),n.structs+="var<private> output : "+n.returnType+";",r+=`return ${p.result};`;else{let y=" @location(0) color: vec4<f32>";const x=this.getBuiltins("output");x&&(y+=`,
`+x),n.returnType="OutputStruct",n.structs+=this._getWGSLStruct("OutputStruct",y),n.structs+=`
var<private> output : OutputStruct;`,r+=`output.color = ${p.result};
return output;`}}}n.flow=r}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 n;return t!==null&&(n=this._getWGSLMethod(e+"_"+t)),n===void 0&&(n=this._getWGSLMethod(e)),n||e}getBitcastMethod(e){return`bitcast<${this.getType(e)}>`}getFloatPackingMethod(e){return this.getMethod(`floatpack_${e}_2x16`)}getFloatUnpackingMethod(e){return this.getMethod(`floatunpack_${e}_2x16`)}getTernary(e,t,n){return`select( ${n}, ${t}, ${e} )`}getType(e){return T$[e]||e}isAvailable(e){let t=e3[e];return t===void 0&&(e==="float32Filterable"?t=this.renderer.hasFeature("float32-filterable"):e==="clipDistance"&&(t=this.renderer.hasFeature("clip-distances")),e3[e]=t),t}_getWGSLMethod(e){return Zy[e]!==void 0&&this._include(e),w$[e]}_include(e){const t=Zy[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
${n3}
// 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[n,r,o]=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( ${n}, ${r}, ${o} )
fn main( ${e.attributes} ) {
// system
instanceIndex = globalId.x
+ globalId.y * ( ${n} * numWorkgroups.x )
+ globalId.z * ( ${n} * numWorkgroups.x ) * ( ${r} * numWorkgroups.y );
// vars
${e.vars}
// flow
${e.flow}
}
`}_getWGSLStruct(e,t){return`
struct ${e} {
${t}
};`}_getWGSLStructBinding(e,t,n,r=0,o=0){const a=e+"Struct";return`${this._getWGSLStruct(a,t)}
@binding( ${r} ) @group( ${o} )
var<${n}> ${e} : ${a};`}}class E${constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depthTexture!==null?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=fe.Depth24PlusStencil8:e.depth&&(t=fe.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 o=this.backend.renderer,a=o.getRenderTarget();t=a?a.samples:o.currentSamples}else e.renderTarget&&(t=e.renderTarget.samples);t=t||1;const n=t>1&&e.renderTarget!==null&&e.isDepthTexture!==!0&&e.isFramebufferTexture!==!0;return{samples:t,primarySamples:n?1:t,isMSAA:n}}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 bg.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return bg.LineList;if(e.isLine)return bg.LineStrip;if(e.isMesh)return bg.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 t=this.backend.parameters.outputType;if(t===void 0)return navigator.gpu.getPreferredCanvasFormat();if(t===Di)return fe.BGRA8Unorm;if(t===Hi)return fe.RGBA16Float;throw new Error("Unsupported output buffer type.")}}const i3=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"&&i3.set(Float16Array,["float16"]);const C$=new Map([[$s,["float16"]]]),R$=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class N${constructor(e){this.backend=e}createAttribute(e,t){const n=this._getBufferAttribute(e),r=this.backend,o=r.get(n);let a=o.buffer;if(a===void 0){const c=r.device;let u=n.array;if(e.normalized===!1){if(u.constructor===Int16Array||u.constructor===Int8Array)u=new Int32Array(u);else if((u.constructor===Uint16Array||u.constructor===Uint8Array)&&(u=new Uint32Array(u),t&GPUBufferUsage.INDEX))for(let m=0;m<u.length;m++)u[m]===65535&&(u[m]=4294967295)}if(n.array=u,(n.isStorageBufferAttribute||n.isStorageInstancedBufferAttribute)&&n.itemSize===3){u=new u.constructor(n.count*4);for(let m=0;m<n.count;m++)u.set(n.array.subarray(m*3,m*3+3),m*4);n.itemSize=4,n.array=u,o._force3to4BytesAlignment=!0}const d=u.byteLength,p=d+(4-d%4)%4;a=c.createBuffer({label:n.name,size:p,usage:t,mappedAtCreation:!0}),new u.constructor(a.getMappedRange()).set(u),a.unmap(),o.buffer=a}}updateAttribute(e){const t=this._getBufferAttribute(e),n=this.backend,r=n.device,o=n.get(t),a=n.get(t).buffer;let c=t.array;if(o._force3to4BytesAlignment===!0){c=new c.constructor(t.count*4);for(let d=0;d<t.count;d++)c.set(t.array.subarray(d*3,d*3+3),d*4);t.array=c}const u=t.updateRanges;if(u.length===0)r.queue.writeBuffer(a,0,c,0);else{const d=Mn(c),p=d?1:c.BYTES_PER_ELEMENT;for(let m=0,y=u.length;m<y;m++){const x=u[m];let v,w;if(o._force3to4BytesAlignment===!0){const S=Math.floor(x.start/3),C=Math.ceil(x.count/3);v=S*4*p,w=C*4*p}else v=x.start*p,w=x.count*p;const M=v*(d?c.BYTES_PER_ELEMENT:1);r.queue.writeBuffer(a,M,c,v,w)}t.clearUpdateRanges()}}createShaderVertexBuffers(e){const t=e.getAttributes(),n=new Map;for(let r=0;r<t.length;r++){const o=t[r],a=o.array.BYTES_PER_ELEMENT,c=this._getBufferAttribute(o);let u=n.get(c);if(u===void 0){let m,y;o.isInterleavedBufferAttribute===!0?(m=o.data.stride*a,y=o.data.isInstancedInterleavedBuffer?Mb.Instance:Mb.Vertex):(m=o.itemSize*a,y=o.isInstancedBufferAttribute?Mb.Instance:Mb.Vertex),o.normalized===!1&&(o.array.constructor===Int16Array||o.array.constructor===Uint16Array)&&(m=4),u={arrayStride:m,attributes:[],stepMode:y},n.set(c,u)}const d=this._getVertexFormat(o),p=o.isInterleavedBufferAttribute===!0?o.offset*a:0;u.attributes.push({shaderLocation:r,offset:p,format:d})}return Array.from(n.values())}destroyAttribute(e){const t=this.backend;t.get(this._getBufferAttribute(e)).buffer.destroy(),t.delete(e)}getArrayBufferAsync(e){return mn(this,null,function*(){const t=this.backend,n=t.device,o=t.get(this._getBufferAttribute(e)).buffer,a=o.size,c=n.createBuffer({label:`${e.name}_readback`,size:a,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ}),u=n.createCommandEncoder({label:`readback_encoder_${e.name}`});u.copyBufferToBuffer(o,0,c,0,a);const d=u.finish();n.queue.submit([d]),yield c.mapAsync(GPUMapMode.READ);const p=c.getMappedRange(),m=new e.array.constructor(p.slice(0));return c.unmap(),m.buffer})}_getVertexFormat(e){const{itemSize:t,normalized:n}=e,r=e.array.constructor,o=e.constructor;let a;if(t===1)a=R$.get(r);else{const u=(C$.get(o)||i3.get(r))[n?1:0];if(u){const d=r.BYTES_PER_ELEMENT*t,m=Math.floor((d+3)/4)*4/r.BYTES_PER_ELEMENT;if(m%1)throw new Error("THREE.WebGPUAttributeUtils: Bad vertex format item size.");a=`${u}x${m}`}}return a||Be("WebGPUAttributeUtils: Vertex format not supported yet."),a}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}class P${constructor(e){this.layoutGPU=e,this.usedTimes=0}}class I${constructor(e){this.backend=e,this._bindGroupLayoutCache=new Map}createBindingsLayout(e){const t=this.backend,n=t.device,r=t.get(e);if(r.layout)return r.layout.layoutGPU;const o=this._createLayoutEntries(e),a=JSON.stringify(o);let c=this._bindGroupLayoutCache.get(a);return c===void 0&&(c=new P$(n.createBindGroupLayout({entries:o})),this._bindGroupLayoutCache.set(a,c)),c.usedTimes++,r.layout=c,r.layoutKey=a,c.layoutGPU}createBindings(e,t,n,r=0){const{backend:o}=this,a=o.get(e),c=this.createBindingsLayout(e);let u;n>0&&(a.groups===void 0&&(a.groups=[],a.versions=[]),a.versions[n]===r&&(u=a.groups[n])),u===void 0&&(u=this.createBindGroup(e,c),n>0&&(a.groups[n]=u,a.versions[n]=r)),a.group=u}updateBinding(e){const t=this.backend,n=t.device,r=e.buffer,o=t.get(e).buffer,a=e.updateRanges;if(a.length===0)n.queue.writeBuffer(o,0,r,0);else{const c=Mn(r),u=c?1:r.BYTES_PER_ELEMENT;for(let d=0,p=a.length;d<p;d++){const m=a[d],y=m.start*u,x=m.count*u,v=y*(c?r.BYTES_PER_ELEMENT:1);n.queue.writeBuffer(o,v,r,y,x)}e.clearUpdateRanges()}}createBindGroupIndex(e,t){const r=this.backend.device,o=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,a=e[0],c=r.createBuffer({label:"bindingCameraIndex_"+a,size:16,usage:o});r.queue.writeBuffer(c,0,e,0);const u=[{binding:0,resource:{buffer:c}}];return r.createBindGroup({label:"bindGroupCameraIndex_"+a,layout:t,entries:u})}createBindGroup(e,t){const n=this.backend,r=n.device;let o=0;const a=[];for(const c of e.bindings){if(c.isUniformBuffer){const u=n.get(c);if(u.buffer===void 0){const d=c.byteLength,p=GPUBufferUsage.UNIFORM|GPUBufferUsage.COPY_DST,m=[];c.visibility&yp.VERTEX&&m.push("vertex"),c.visibility&yp.FRAGMENT&&m.push("fragment"),c.visibility&yp.COMPUTE&&m.push("compute");const y=`(${m.join(",")})`,x=r.createBuffer({label:`bindingBuffer${c.id}_${c.name}_${y}`,size:d,usage:p});u.buffer=x}a.push({binding:o,resource:{buffer:u.buffer}})}else if(c.isStorageBuffer){const u=n.get(c);if(u.buffer===void 0){const d=c.attribute;u.buffer=n.get(d).buffer}a.push({binding:o,resource:{buffer:u.buffer}})}else if(c.isSampledTexture){const u=n.get(c.texture);let d;if(u.externalTexture!==void 0)d=r.importExternalTexture({source:u.externalTexture});else{const p=c.store?1:u.texture.mipLevelCount,m=c.store?c.mipLevel:0;let y=`view-${u.texture.width}-${u.texture.height}`;if(u.texture.depthOrArrayLayers>1&&(y+=`-${u.texture.depthOrArrayLayers}`),y+=`-${p}-${m}`,d=u[y],d===void 0){const x=l$.All;let v;c.isSampledCubeTexture?v=lr.Cube:c.isSampledTexture3D?v=lr.ThreeD:c.texture.isArrayTexture||c.texture.isDataArrayTexture||c.texture.isCompressedArrayTexture?v=lr.TwoDArray:v=lr.TwoD,d=u[y]=u.texture.createView({aspect:x,dimension:v,mipLevelCount:p,baseMipLevel:m})}}a.push({binding:o,resource:d})}else if(c.isSampler){const u=n.get(c.texture);a.push({binding:o,resource:u.sampler})}o++}return r.createBindGroup({label:"bindGroup_"+e.name,layout:t,entries:a})}_createLayoutEntries(e){const t=[];let n=0;for(const r of e.bindings){const o=this.backend,a={binding:n,visibility:r.visibility};if(r.isUniformBuffer||r.isStorageBuffer){const c={};r.isStorageBuffer&&(r.visibility&yp.COMPUTE&&(r.access===zr.READ_WRITE||r.access===zr.WRITE_ONLY)?c.type=m1.Storage:c.type=m1.ReadOnlyStorage),a.buffer=c}else if(r.isSampledTexture&&r.store){const c={};c.format=this.backend.get(r.texture).texture.format;const u=r.access;u===zr.READ_WRITE?c.access=g1.ReadWrite:u===zr.WRITE_ONLY?c.access=g1.WriteOnly:c.access=g1.ReadOnly,r.texture.isArrayTexture?c.viewDimension=lr.TwoDArray:r.texture.is3DTexture&&(c.viewDimension=lr.ThreeD),a.storageTexture=c}else if(r.isSampledTexture){const c={},{primarySamples:u}=o.utils.getTextureSampleData(r.texture);if(u>1&&(c.multisampled=!0,r.texture.isDepthTexture||(c.sampleType=vp.UnfilterableFloat)),r.texture.isDepthTexture)o.compatibilityMode&&r.texture.compareFunction===null?c.sampleType=vp.UnfilterableFloat:c.sampleType=vp.Depth;else if(r.texture.isDataTexture||r.texture.isDataArrayTexture||r.texture.isData3DTexture){const d=r.texture.type;d===er?c.sampleType=vp.SInt:d===yi?c.sampleType=vp.UInt:d===Si&&(this.backend.hasFeature("float32-filterable")?c.sampleType=vp.Float:c.sampleType=vp.UnfilterableFloat)}r.isSampledCubeTexture?c.viewDimension=lr.Cube:r.texture.isArrayTexture||r.texture.isDataArrayTexture||r.texture.isCompressedArrayTexture?c.viewDimension=lr.TwoDArray:r.isSampledTexture3D&&(c.viewDimension=lr.ThreeD),a.texture=c}else if(r.isSampler){const c={};r.texture.isDepthTexture&&(r.texture.compareFunction!==null?c.type=Y2.Comparison:o.compatibilityMode&&(c.type=Y2.NonFiltering)),a.sampler=c}else Be(`WebGPUBindingUtils: Unsupported binding "${r}".`);t.push(a),n++}return t}deleteBindGroupData(e){const{backend:t}=this,n=t.get(e);n.layout&&(n.layout.usedTimes--,n.layout.usedTimes===0&&this._bindGroupLayoutCache.delete(n.layoutKey),n.layout=void 0,n.layoutKey=void 0)}dispose(){this._bindGroupLayoutCache.clear()}}class L${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:n,material:r,geometry:o,pipeline:a}=e,{vertexProgram:c,fragmentProgram:u}=a,d=this.backend,p=d.device,m=d.utils,y=d.get(a),x=[];for(const _e of e.getBindings()){const Te=d.get(_e),{layoutGPU:Pe}=Te.layout;x.push(Pe)}const v=d.attributeUtils.createShaderVertexBuffers(e);let w;r.blending!==ve&&(r.blending!==Ue||r.transparent!==!1)&&(w=this._getBlending(r));let M={};r.stencilWrite===!0&&(M={compare:this._getStencilCompare(r),failOp:this._getStencilOperation(r.stencilFail),depthFailOp:this._getStencilOperation(r.stencilZFail),passOp:this._getStencilOperation(r.stencilZPass)});const S=this._getColorWriteMask(r),C=[];if(e.context.textures!==null){const _e=e.context.textures;for(let Te=0;Te<_e.length;Te++){const Pe=m.getTextureFormatGPU(_e[Te]);Te===0?C.push({format:Pe,blend:w,writeMask:S}):C.push({format:Pe,writeMask:S})}}else{const _e=m.getCurrentColorFormat(e.context);C.push({format:_e,blend:w,writeMask:S})}const N=d.get(c).module,I=d.get(u).module,U=this._getPrimitiveState(n,o,r),F=this._getDepthCompare(r),k=m.getCurrentDepthStencilFormat(e.context),G=this._getSampleCount(e.context),B={label:`renderPipeline_${r.name||r.type}_${r.id}`,vertex:Object.assign({},N,{buffers:v}),fragment:Object.assign({},I,{targets:C}),primitive:U,multisample:{count:G,alphaToCoverageEnabled:r.alphaToCoverage&&G>1},layout:p.createPipelineLayout({bindGroupLayouts:x})},z={},Q=e.context.depth,ye=e.context.stencil;if((Q===!0||ye===!0)&&(Q===!0&&(z.format=k,z.depthWriteEnabled=r.depthWrite,z.depthCompare=F),ye===!0&&(z.stencilFront=M,z.stencilBack={},z.stencilReadMask=r.stencilFuncMask,z.stencilWriteMask=r.stencilWriteMask),r.polygonOffset===!0&&(z.depthBias=r.polygonOffsetUnits,z.depthBiasSlopeScale=r.polygonOffsetFactor,z.depthBiasClamp=0),B.depthStencil=z),p.pushErrorScope("validation"),t===null)y.pipeline=p.createRenderPipeline(B),p.popErrorScope().then(_e=>{_e!==null&&(y.error=!0,Be(_e.message))});else{const _e=new Promise(Te=>mn(this,null,function*(){try{y.pipeline=yield p.createRenderPipelineAsync(B)}catch(Ne){}const Pe=yield p.popErrorScope();Pe!==null&&(y.error=!0,Be(Pe.message)),Te()}));t.push(_e)}}createBundleEncoder(e,t="renderBundleEncoder"){const n=this.backend,{utils:r,device:o}=n,a=r.getCurrentDepthStencilFormat(e),c=r.getCurrentColorFormats(e),u=this._getSampleCount(e),d={label:t,colorFormats:c,depthStencilFormat:a,sampleCount:u};return o.createRenderBundleEncoder(d)}createComputePipeline(e,t){const n=this.backend,r=n.device,o=n.get(e.computeProgram).module,a=n.get(e),c=[];for(const u of t){const d=n.get(u),{layoutGPU:p}=d.layout;c.push(p)}a.pipeline=r.createComputePipeline({compute:o,layout:r.createPipelineLayout({bindGroupLayouts:c})})}_getBlending(e){let t,n;const r=e.blending,o=e.blendSrc,a=e.blendDst,c=e.blendEquation;if(r===ut){const u=e.blendSrcAlpha!==null?e.blendSrcAlpha:o,d=e.blendDstAlpha!==null?e.blendDstAlpha:a,p=e.blendEquationAlpha!==null?e.blendEquationAlpha:c;t={srcFactor:this._getBlendFactor(o),dstFactor:this._getBlendFactor(a),operation:this._getBlendOperation(c)},n={srcFactor:this._getBlendFactor(u),dstFactor:this._getBlendFactor(d),operation:this._getBlendOperation(p)}}else{const u=e.premultipliedAlpha,d=(p,m,y,x)=>{t={srcFactor:p,dstFactor:m,operation:xp.Add},n={srcFactor:y,dstFactor:x,operation:xp.Add}};if(u)switch(r){case Ue:d(gi.One,gi.OneMinusSrcAlpha,gi.One,gi.OneMinusSrcAlpha);break;case Je:d(gi.One,gi.One,gi.One,gi.One);break;case Ye:d(gi.Zero,gi.OneMinusSrc,gi.Zero,gi.One);break;case Ke:d(gi.Dst,gi.OneMinusSrcAlpha,gi.Zero,gi.One);break}else switch(r){case Ue:d(gi.SrcAlpha,gi.OneMinusSrcAlpha,gi.One,gi.OneMinusSrcAlpha);break;case Je:d(gi.SrcAlpha,gi.One,gi.One,gi.One);break;case Ye:Be("WebGPURenderer: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Ke:Be("WebGPURenderer: MultiplyBlending requires material.premultipliedAlpha = true");break}}if(t!==void 0&&n!==void 0)return{color:t,alpha:n};Be("WebGPURenderer: Invalid blending: ",r)}_getBlendFactor(e){let t;switch(e){case Sn:t=gi.Zero;break;case Cn:t=gi.One;break;case Pn:t=gi.Src;break;case Rt:t=gi.OneMinusSrc;break;case Rn:t=gi.SrcAlpha;break;case Jt:t=gi.OneMinusSrcAlpha;break;case gt:t=gi.Dst;break;case hn:t=gi.OneMinusDst;break;case tn:t=gi.DstAlpha;break;case xi:t=gi.OneMinusDstAlpha;break;case $n:t=gi.SrcAlphaSaturated;break;case h5:t=gi.Constant;break;case d5:t=gi.OneMinusConstant;break;default:Be("WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const n=e.stencilFunc;switch(n){case m_:t=$r.Never;break;case g_:t=$r.Always;break;case dA:t=$r.Less;break;case pA:t=$r.LessEqual;break;case fA:t=$r.Equal;break;case yA:t=$r.GreaterEqual;break;case mA:t=$r.Greater;break;case gA:t=$r.NotEqual;break;default:Be("WebGPURenderer: Invalid stencil function.",n)}return t}_getStencilOperation(e){let t;switch(e){case Xh:t=Jd.Keep;break;case rA:t=Jd.Zero;break;case oA:t=Jd.Replace;break;case hA:t=Jd.Invert;break;case aA:t=Jd.IncrementClamp;break;case lA:t=Jd.DecrementClamp;break;case cA:t=Jd.IncrementWrap;break;case uA:t=Jd.DecrementWrap;break;default:Be("WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case nt:t=xp.Add;break;case tt:t=xp.Subtract;break;case at:t=xp.ReverseSubtract;break;case _t:t=xp.Min;break;case un:t=xp.Max;break;default:Be("WebGPUPipelineUtils: Blend equation not supported.",e)}return t}_getPrimitiveState(e,t,n){const r={},o=this.backend.utils;r.topology=o.getPrimitiveTopology(e,n),t.index!==null&&e.isLine===!0&&e.isLineSegments!==!0&&(r.stripIndexFormat=t.index.array instanceof Uint16Array?Sg.Uint16:Sg.Uint32);let a=n.side===we;return e.isMesh&&e.matrixWorld.determinant()<0&&(a=!a),r.frontFace=a===!0?q2.CW:q2.CCW,r.cullMode=n.side===Ae?X2.None:X2.Back,r}_getColorWriteMask(e){return e.colorWrite===!0?j2.All:j2.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=$r.Always;else{const n=e.depthFunc;switch(n){case nl:t=$r.Never;break;case zn:t=$r.Always;break;case Ci:t=$r.Less;break;case no:t=$r.LessEqual;break;case $c:t=$r.Equal;break;case qc:t=$r.GreaterEqual;break;case Rp:t=$r.Greater;break;case Np:t=$r.NotEqual;break;default:Be("WebGPUPipelineUtils: Invalid depth function.",n)}}return t}}class D$ extends H2{constructor(e,t,n=2048){super(n),this.device=e,this.type=t,this.querySet=this.device.createQuerySet({type:"timestamp",count:this.maxQueries,label:`queryset_global_timestamp_${t}`});const r=this.maxQueries*8;this.resolveBuffer=this.device.createBuffer({label:`buffer_timestamp_resolve_${t}`,size:r,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.resultBuffer=this.device.createBuffer({label:`buffer_timestamp_result_${t}`,size:r,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ})}allocateQueriesForContext(e){if(!this.trackTimestamp||this.isDisposed)return null;if(this.currentQueryIndex+2>this.maxQueries)return Ut(`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 mn(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 mn(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,n=t*8;this.currentQueryIndex=0,this.queryOffsets.clear();const r=this.device.createCommandEncoder();r.resolveQuerySet(this.querySet,0,t,this.resolveBuffer,0),r.copyBufferToBuffer(this.resolveBuffer,0,this.resultBuffer,0,n);const o=r.finish();if(this.device.queue.submit([o]),this.resultBuffer.mapState!=="unmapped")return this.lastValue;if(yield this.resultBuffer.mapAsync(GPUMapMode.READ,0,n),this.isDisposed)return this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue;const a=new BigUint64Array(this.resultBuffer.getMappedRange(0,n)),c={},u=[];for(const[p,m]of e){const y=p.match(/^(.*):f(\d+)$/),x=parseInt(y[2]);u.includes(x)===!1&&u.push(x),c[x]===void 0&&(c[x]=0);const v=a[m],w=a[m+1],M=Number(w-v)/1e6;this.timestamps.set(p,M),c[x]+=M}const d=c[u[u.length-1]];return this.resultBuffer.unmap(),this.lastValue=d,this.frames=u,d}catch(e){return Be("Error resolving queries:",e),this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue}})}dispose(){return mn(this,null,function*(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{yield this.pendingResolve}catch(e){Be("Error waiting for pending resolve:",e)}if(this.resultBuffer&&this.resultBuffer.mapState==="mapped")try{this.resultBuffer.unmap()}catch(e){Be("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 x1 extends z2{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 E$(this),this.attributeUtils=new N$(this),this.bindingUtils=new I$(this),this.pipelineUtils=new L$(this),this.textureUtils=new g$(this),this.occludedResolveCache=new Map}init(e){return mn(this,null,function*(){yield IL(x1.prototype,this,"init").call(this,e);const t=this.parameters;let n;if(t.device===void 0){const r={powerPreference:t.powerPreference,featureLevel:t.compatibilityMode?"compatibility":void 0},o=typeof navigator!="undefined"?yield navigator.gpu.requestAdapter(r):null;if(o===null)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const a=Object.values(y1),c=[];for(const d of a)o.features.has(d)&&c.push(d);const u={requiredFeatures:c,requiredLimits:t.requiredLimits};n=yield o.requestDevice(u)}else n=t.device;n.lost.then(r=>{if(r.reason==="destroyed")return;const o={api:"WebGPU",message:r.message||"Unknown reason",reason:r.reason||null,originalEvent:r};e.onDeviceLost(o)}),this.device=n,this.trackTimestamp=this.trackTimestamp&&this.hasFeature(y1.TimestampQuery),this.updateSize()})}get context(){const e=this.renderer.getCanvasTarget(),t=this.get(e);let n=t.context;if(n===void 0){const r=this.parameters;e.isDefaultCanvasTarget===!0&&r.context!==void 0?n=r.context:n=e.domElement.getContext("webgpu"),"setAttribute"in e.domElement&&e.domElement.setAttribute("data-engine",`three.js r${xe} webgpu`);const o=r.alpha?"premultiplied":"opaque",a=r.outputType===Hi?"extended":"standard";n.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:o,toneMapping:{mode:a}}),t.context=n}return n}get coordinateSystem(){return xr}getArrayBufferAsync(e){return mn(this,null,function*(){return yield this.attributeUtils.getArrayBufferAsync(e)})}getContext(){return this.context}_getDefaultRenderPassDescriptor(){const e=this.renderer,t=e.getCanvasTarget(),n=this.get(t),r=e.currentSamples;let o=n.descriptor;if(o===void 0||n.samples!==r){o={colorAttachments:[{view:null}]},(e.depth===!0||e.stencil===!0)&&(o.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(e.depth,e.stencil).createView()});const c=o.colorAttachments[0];r>0?c.view=this.textureUtils.getColorBuffer().createView():c.resolveTarget=void 0,n.descriptor=o,n.samples=r}const a=o.colorAttachments[0];return r>0?a.resolveTarget=this.context.getCurrentTexture().createView():a.view=this.context.getCurrentTexture().createView(),o}_isRenderCameraDepthArray(e){return e.depthTexture&&e.depthTexture.image.depth>1&&e.camera.isArrayCamera}_getRenderPassDescriptor(e,t={}){const n=e.renderTarget,r=this.get(n);let o=r.descriptors;(o===void 0||r.width!==n.width||r.height!==n.height||r.samples!==n.samples)&&(o={},r.descriptors=o);const a=e.getCacheKey();let c=o[a];if(c===void 0){const d=e.textures,p=[];let m;const y=this._isRenderCameraDepthArray(e);for(let x=0;x<d.length;x++){const v=this.get(d[x]),w={label:`colorAttachment_${x}`,baseMipLevel:e.activeMipmapLevel,mipLevelCount:1,baseArrayLayer:e.activeCubeFace,arrayLayerCount:1,dimension:lr.TwoD};if(n.isRenderTarget3D)m=e.activeCubeFace,w.baseArrayLayer=0,w.dimension=lr.ThreeD,w.depthOrArrayLayers=d[x].image.depth;else if(n.isRenderTarget&&d[x].image.depth>1)if(y===!0){const M=e.camera.cameras;for(let S=0;S<M.length;S++){const C=Mo(wi({},w),{baseArrayLayer:S,arrayLayerCount:1,dimension:lr.TwoD}),N=v.texture.createView(C);p.push({view:N,resolveTarget:void 0,depthSlice:void 0})}}else w.dimension=lr.TwoDArray,w.depthOrArrayLayers=d[x].image.depth;if(y!==!0){const M=v.texture.createView(w);let S,C;v.msaaTexture!==void 0?(S=v.msaaTexture.createView(),C=M):(S=M,C=void 0),p.push({view:S,resolveTarget:C,depthSlice:m})}}if(c={textureViews:p},e.depth){const x=this.get(e.depthTexture),v={};(e.depthTexture.isArrayTexture||e.depthTexture.isCubeTexture)&&(v.dimension=lr.TwoD,v.arrayLayerCount=1,v.baseArrayLayer=e.activeCubeFace),c.depthStencilView=x.texture.createView(v)}o[a]=c,r.width=n.width,r.height=n.height,r.samples=n.samples,r.activeMipmapLevel=e.activeMipmapLevel,r.activeCubeFace=e.activeCubeFace}const u={colorAttachments:[]};for(let d=0;d<c.textureViews.length;d++){const p=c.textureViews[d];let m={r:0,g:0,b:0,a:1};d===0&&t.clearValue&&(m=t.clearValue),u.colorAttachments.push({view:p.view,depthSlice:p.depthSlice,resolveTarget:p.resolveTarget,loadOp:t.loadOp||Ii.Load,storeOp:t.storeOp||bo.Store,clearValue:m})}return c.depthStencilView&&(u.depthStencilAttachment={view:c.depthStencilView}),u}beginRender(e){const t=this.get(e),n=this.device,r=e.occlusionQueryCount;let o;r>0&&(t.currentOcclusionQuerySet&&t.currentOcclusionQuerySet.destroy(),t.currentOcclusionQueryBuffer&&t.currentOcclusionQueryBuffer.destroy(),t.currentOcclusionQuerySet=t.occlusionQuerySet,t.currentOcclusionQueryBuffer=t.occlusionQueryBuffer,t.currentOcclusionQueryObjects=t.occlusionQueryObjects,o=n.createQuerySet({type:"occlusion",count:r,label:`occlusionQuerySet_${e.id}`}),t.occlusionQuerySet=o,t.occlusionQueryIndex=0,t.occlusionQueryObjects=new Array(r),t.lastOcclusionObject=null);let a;e.textures===null?a=this._getDefaultRenderPassDescriptor():a=this._getRenderPassDescriptor(e,{loadOp:Ii.Load}),this.initTimestampQuery(ol.RENDER,this.getTimestampUID(e),a),a.occlusionQuerySet=o;const c=a.depthStencilAttachment;if(e.textures!==null){const d=a.colorAttachments;for(let p=0;p<d.length;p++){const m=d[p];e.clearColor?(m.clearValue=p===0?e.clearColorValue:{r:0,g:0,b:0,a:1},m.loadOp=Ii.Clear):m.loadOp=Ii.Load,m.storeOp=bo.Store}}else{const d=a.colorAttachments[0];e.clearColor?(d.clearValue=e.clearColorValue,d.loadOp=Ii.Clear):d.loadOp=Ii.Load,d.storeOp=bo.Store}e.depth&&(e.clearDepth?(c.depthClearValue=e.clearDepthValue,c.depthLoadOp=Ii.Clear):c.depthLoadOp=Ii.Load,c.depthStoreOp=bo.Store),e.stencil&&(e.clearStencil?(c.stencilClearValue=e.clearStencilValue,c.stencilLoadOp=Ii.Clear):c.stencilLoadOp=Ii.Load,c.stencilStoreOp=bo.Store);const u=n.createCommandEncoder({label:"renderContext_"+e.id});if(this._isRenderCameraDepthArray(e)===!0){const d=e.camera.cameras;!t.layerDescriptors||t.layerDescriptors.length!==d.length?this._createDepthLayerDescriptors(e,t,a,d):this._updateDepthLayerDescriptors(e,t,d),t.bundleEncoders=[],t.bundleSets=[];for(let p=0;p<d.length;p++){const m=this.pipelineUtils.createBundleEncoder(e,"renderBundleArrayCamera_"+p),y={attributes:{},bindingGroups:[],pipeline:null,index:null};t.bundleEncoders.push(m),t.bundleSets.push(y)}t.currentPass=null}else{const d=u.beginRenderPass(a);t.currentPass=d,e.viewport&&this.updateViewport(e),e.scissor&&this.updateScissor(e)}t.descriptor=a,t.encoder=u,t.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.renderBundles=[]}_createDepthLayerDescriptors(e,t,n,r){const o=n.depthStencilAttachment;t.layerDescriptors=[];const a=this.get(e.depthTexture);a.viewCache||(a.viewCache=[]);for(let c=0;c<r.length;c++){const u=Mo(wi({},n),{colorAttachments:[Mo(wi({},n.colorAttachments[0]),{view:n.colorAttachments[c].view})]});if(n.depthStencilAttachment){const d=c;a.viewCache[d]||(a.viewCache[d]=a.texture.createView({dimension:lr.TwoD,baseArrayLayer:c,arrayLayerCount:1})),u.depthStencilAttachment={view:a.viewCache[d],depthLoadOp:o.depthLoadOp||Ii.Clear,depthStoreOp:o.depthStoreOp||bo.Store,depthClearValue:o.depthClearValue||1},e.stencil&&(u.depthStencilAttachment.stencilLoadOp=o.stencilLoadOp,u.depthStencilAttachment.stencilStoreOp=o.stencilStoreOp,u.depthStencilAttachment.stencilClearValue=o.stencilClearValue)}else u.depthStencilAttachment=wi({},o);t.layerDescriptors.push(u)}}_updateDepthLayerDescriptors(e,t,n){for(let r=0;r<n.length;r++){const o=t.layerDescriptors[r];if(o.depthStencilAttachment){const a=o.depthStencilAttachment;e.depth&&(e.clearDepth?(a.depthClearValue=e.clearDepthValue,a.depthLoadOp=Ii.Clear):a.depthLoadOp=Ii.Load),e.stencil&&(e.clearStencil?(a.stencilClearValue=e.clearStencilValue,a.stencilLoadOp=Ii.Clear):a.stencilLoadOp=Ii.Load)}}}finishRender(e){const t=this.get(e),n=e.occlusionQueryCount;t.renderBundles.length>0&&t.currentPass.executeBundles(t.renderBundles),n>t.occlusionQueryIndex&&t.currentPass.endOcclusionQuery();const r=t.encoder;if(this._isRenderCameraDepthArray(e)===!0){const o=[];for(let a=0;a<t.bundleEncoders.length;a++){const c=t.bundleEncoders[a];o.push(c.finish())}for(let a=0;a<t.layerDescriptors.length;a++)if(a<o.length){const c=t.layerDescriptors[a],u=r.beginRenderPass(c);if(e.viewport){const{x:d,y:p,width:m,height:y,minDepth:x,maxDepth:v}=e.viewportValue;u.setViewport(d,p,m,y,x,v)}if(e.scissor){const{x:d,y:p,width:m,height:y}=e.scissorValue;u.setScissorRect(d,p,m,y)}u.executeBundles([o[a]]),u.end()}}else t.currentPass&&t.currentPass.end();if(n>0){const o=n*8;let a=this.occludedResolveCache.get(o);a===void 0&&(a=this.device.createBuffer({size:o,usage:GPUBufferUsage.QUERY_RESOLVE|GPUBufferUsage.COPY_SRC}),this.occludedResolveCache.set(o,a));const c=this.device.createBuffer({size:o,usage:GPUBufferUsage.COPY_DST|GPUBufferUsage.MAP_READ});t.encoder.resolveQuerySet(t.occlusionQuerySet,0,n,a,0),t.encoder.copyBufferToBuffer(a,0,c,0,o),t.occlusionQueryBuffer=c,this.resolveOccludedAsync(e)}if(this.device.queue.submit([t.encoder.finish()]),e.textures!==null){const o=e.textures;for(let a=0;a<o.length;a++){const c=o[a];c.generateMipmaps===!0&&this.textureUtils.generateMipmaps(c)}}}isOccluded(e,t){const n=this.get(e);return n.occluded&&n.occluded.has(t)}resolveOccludedAsync(e){return mn(this,null,function*(){const t=this.get(e),{currentOcclusionQueryBuffer:n,currentOcclusionQueryObjects:r}=t;if(n&&r){const o=new WeakSet;t.currentOcclusionQueryObjects=null,t.currentOcclusionQueryBuffer=null,yield n.mapAsync(GPUMapMode.READ);const a=n.getMappedRange(),c=new BigUint64Array(a);for(let u=0;u<r.length;u++)c[u]===BigInt(0)&&o.add(r[u]);n.destroy(),t.occluded=o}})}updateViewport(e){const{currentPass:t}=this.get(e),{x:n,y:r,width:o,height:a,minDepth:c,maxDepth:u}=e.viewportValue;t.setViewport(n,r,o,a,c,u)}updateScissor(e){const{currentPass:t}=this.get(e),{x:n,y:r,width:o,height:a}=e.scissorValue;t.setScissorRect(n,r,o,a)}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,n,r=null){const o=this.device,a=this.renderer;let c=[],u,d,p,m;if(e){const v=this.getClearColor();d={r:v.r,g:v.g,b:v.b,a:v.a}}if(r===null){p=a.depth,m=a.stencil;const v=this._getDefaultRenderPassDescriptor();if(e){c=v.colorAttachments;const w=c[0];w.clearValue=d,w.loadOp=Ii.Clear,w.storeOp=bo.Store}(p||m)&&(u=v.depthStencilAttachment)}else{p=r.depth,m=r.stencil;const v={loadOp:e?Ii.Clear:Ii.Load,clearValue:e?d:void 0};p&&(v.depthLoadOp=t?Ii.Clear:Ii.Load,v.depthClearValue=t?a.getClearDepth():void 0,v.depthStoreOp=bo.Store),m&&(v.stencilLoadOp=n?Ii.Clear:Ii.Load,v.stencilClearValue=n?a.getClearStencil():void 0,v.stencilStoreOp=bo.Store);const w=this._getRenderPassDescriptor(r,v);c=w.colorAttachments,u=w.depthStencilAttachment}p&&u&&(t?(u.depthLoadOp=Ii.Clear,u.depthClearValue=a.getClearDepth(),u.depthStoreOp=bo.Store):(u.depthLoadOp=Ii.Load,u.depthStoreOp=bo.Store)),m&&u&&(n?(u.stencilLoadOp=Ii.Clear,u.stencilClearValue=a.getClearStencil(),u.stencilStoreOp=bo.Store):(u.stencilLoadOp=Ii.Load,u.stencilStoreOp=bo.Store));const y=o.createCommandEncoder({label:"clear"});y.beginRenderPass({colorAttachments:c,depthStencilAttachment:u}).end(),o.queue.submit([y.finish()])}beginCompute(e){const t=this.get(e),n={label:"computeGroup_"+e.id};this.initTimestampQuery(ol.COMPUTE,this.getTimestampUID(e),n),t.cmdEncoderGPU=this.device.createCommandEncoder({label:"computeGroup_"+e.id}),t.passEncoderGPU=t.cmdEncoderGPU.beginComputePass(n)}compute(e,t,n,r,o=null){const a=this.get(t),{passEncoderGPU:c}=this.get(e),u=this.get(r).pipeline;this.pipelineUtils.setPipeline(c,u);for(let d=0,p=n.length;d<p;d++){const m=n[d],y=this.get(m);c.setBindGroup(d,y.group)}if(o===null&&(o=t.count),o&&typeof o=="object"&&o.isIndirectStorageBufferAttribute){const d=this.get(o).buffer;c.dispatchWorkgroupsIndirect(d,0);return}if(typeof o=="number"){const d=o;if(a.dispatchSize===void 0||a.count!==d){a.dispatchSize=[0,1,1],a.count=d;const p=t.workgroupSize;let m=p[0];for(let v=1;v<p.length;v++)m*=p[v];const y=Math.ceil(d/m),x=this.device.limits.maxComputeWorkgroupsPerDimension;o=[y,1,1],y>x&&(o[0]=Math.min(y,x),o[1]=Math.ceil(y/x)),a.dispatchSize=o}o=a.dispatchSize}c.dispatchWorkgroups(o[0],o[1]||1,o[2]||1)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}draw(e,t){const{object:n,material:r,context:o,pipeline:a}=e,c=e.getBindings(),u=this.get(o),d=this.get(a),p=d.pipeline;if(d.error===!0)return;const m=e.getIndex(),y=m!==null,x=e.getDrawParameters();if(x===null)return;const v=(M,S)=>{this.pipelineUtils.setPipeline(M,p),S.pipeline=p;const C=S.bindingGroups;for(let I=0,U=c.length;I<U;I++){const F=c[I],k=this.get(F);C[F.index]!==F.id&&(M.setBindGroup(F.index,k.group),C[F.index]=F.id)}if(y===!0&&S.index!==m){const I=this.get(m).buffer,U=m.array instanceof Uint16Array?Sg.Uint16:Sg.Uint32;M.setIndexBuffer(I,U),S.index=m}const N=e.getVertexBuffers();for(let I=0,U=N.length;I<U;I++){const F=N[I];if(S.attributes[I]!==F){const k=this.get(F).buffer;M.setVertexBuffer(I,k),S.attributes[I]=F}}o.stencil===!0&&r.stencilWrite===!0&&u.currentStencilRef!==r.stencilRef&&(M.setStencilReference(r.stencilRef),u.currentStencilRef=r.stencilRef)},w=(M,S)=>{if(v(M,S),n.isBatchedMesh===!0){const C=n._multiDrawStarts,N=n._multiDrawCounts,I=n._multiDrawCount,U=n._multiDrawInstances;U!==null&&Ut("WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");for(let F=0;F<I;F++){const k=U?U[F]:1,G=k>1?0:F;y===!0?M.drawIndexed(N[F],k,C[F]/m.array.BYTES_PER_ELEMENT,0,G):M.draw(N[F],k,C[F],G),t.update(n,N[F],k)}}else if(y===!0){const{vertexCount:C,instanceCount:N,firstVertex:I}=x,U=e.getIndirect();if(U!==null){const F=this.get(U).buffer,k=e.getIndirectOffset(),G=Array.isArray(k)?k:[k];for(let B=0;B<G.length;B++)M.drawIndexedIndirect(F,G[B])}else M.drawIndexed(C,N,I,0,0);t.update(n,C,N)}else{const{vertexCount:C,instanceCount:N,firstVertex:I}=x,U=e.getIndirect();if(U!==null){const F=this.get(U).buffer,k=e.getIndirectOffset(),G=Array.isArray(k)?k:[k];for(let B=0;B<G.length;B++)M.drawIndirect(F,G[B])}else M.draw(C,N,I,0);t.update(n,C,N)}};if(e.camera.isArrayCamera&&e.camera.cameras.length>0){const M=this.get(e.camera),S=e.camera.cameras,C=e.getBindingGroup("cameraIndex");if(M.indexesGPU===void 0||M.indexesGPU.length!==S.length){const I=this.get(C),U=[],F=new Uint32Array([0,0,0,0]);for(let k=0,G=S.length;k<G;k++){F[0]=k;const{layoutGPU:B}=I.layout,z=this.bindingUtils.createBindGroupIndex(F,B);U.push(z)}M.indexesGPU=U}const N=this.renderer.getPixelRatio();for(let I=0,U=S.length;I<U;I++){const F=S[I];if(n.layers.test(F.layers)){const k=F.viewport;let G=u.currentPass,B=u.currentSets;if(u.bundleEncoders){const z=u.bundleEncoders[I],Q=u.bundleSets[I];G=z,B=Q}k&&G.setViewport(Math.floor(k.x*N),Math.floor(k.y*N),Math.floor(k.width*N),Math.floor(k.height*N),o.viewportValue.minDepth,o.viewportValue.maxDepth),C&&M.indexesGPU&&(G.setBindGroup(C.index,M.indexesGPU[I]),B.bindingGroups[C.index]=C.id),w(G,B)}}}else if(u.currentPass){if(u.occlusionQuerySet!==void 0){const M=u.lastOcclusionObject;M!==n&&(M!==null&&M.occlusionTest===!0&&(u.currentPass.endOcclusionQuery(),u.occlusionQueryIndex++),n.occlusionTest===!0&&(u.currentPass.beginOcclusionQuery(u.occlusionQueryIndex),u.occlusionQueryObjects[u.occlusionQueryIndex]=n),u.lastOcclusionObject=n)}w(u.currentPass,u.currentSets)}}needsRenderUpdate(e){const t=this.get(e),{object:n,material:r}=e,o=this.utils,a=o.getSampleCountRenderContext(e.context),c=o.getCurrentColorSpace(e.context),u=o.getCurrentColorFormat(e.context),d=o.getCurrentDepthStencilFormat(e.context),p=o.getPrimitiveTopology(n,r);let m=!1;return(t.material!==r||t.materialVersion!==r.version||t.transparent!==r.transparent||t.blending!==r.blending||t.premultipliedAlpha!==r.premultipliedAlpha||t.blendSrc!==r.blendSrc||t.blendDst!==r.blendDst||t.blendEquation!==r.blendEquation||t.blendSrcAlpha!==r.blendSrcAlpha||t.blendDstAlpha!==r.blendDstAlpha||t.blendEquationAlpha!==r.blendEquationAlpha||t.colorWrite!==r.colorWrite||t.depthWrite!==r.depthWrite||t.depthTest!==r.depthTest||t.depthFunc!==r.depthFunc||t.stencilWrite!==r.stencilWrite||t.stencilFunc!==r.stencilFunc||t.stencilFail!==r.stencilFail||t.stencilZFail!==r.stencilZFail||t.stencilZPass!==r.stencilZPass||t.stencilFuncMask!==r.stencilFuncMask||t.stencilWriteMask!==r.stencilWriteMask||t.side!==r.side||t.alphaToCoverage!==r.alphaToCoverage||t.sampleCount!==a||t.colorSpace!==c||t.colorFormat!==u||t.depthStencilFormat!==d||t.primitiveTopology!==p||t.clippingContextCacheKey!==e.clippingContextCacheKey)&&(t.material=r,t.materialVersion=r.version,t.transparent=r.transparent,t.blending=r.blending,t.premultipliedAlpha=r.premultipliedAlpha,t.blendSrc=r.blendSrc,t.blendDst=r.blendDst,t.blendEquation=r.blendEquation,t.blendSrcAlpha=r.blendSrcAlpha,t.blendDstAlpha=r.blendDstAlpha,t.blendEquationAlpha=r.blendEquationAlpha,t.colorWrite=r.colorWrite,t.depthWrite=r.depthWrite,t.depthTest=r.depthTest,t.depthFunc=r.depthFunc,t.stencilWrite=r.stencilWrite,t.stencilFunc=r.stencilFunc,t.stencilFail=r.stencilFail,t.stencilZFail=r.stencilZFail,t.stencilZPass=r.stencilZPass,t.stencilFuncMask=r.stencilFuncMask,t.stencilWriteMask=r.stencilWriteMask,t.side=r.side,t.alphaToCoverage=r.alphaToCoverage,t.sampleCount=a,t.colorSpace=c,t.colorFormat=u,t.depthStencilFormat=d,t.primitiveTopology=p,t.clippingContextCacheKey=e.clippingContextCacheKey,m=!0),m}getRenderCacheKey(e){const{object:t,material:n}=e,r=this.utils,o=e.context,a=t.isMesh&&t.matrixWorld.determinant()<0;return[n.transparent,n.blending,n.premultipliedAlpha,n.blendSrc,n.blendDst,n.blendEquation,n.blendSrcAlpha,n.blendDstAlpha,n.blendEquationAlpha,n.colorWrite,n.depthWrite,n.depthTest,n.depthFunc,n.stencilWrite,n.stencilFunc,n.stencilFail,n.stencilZFail,n.stencilZPass,n.stencilFuncMask,n.stencilWriteMask,n.side,a,r.getSampleCountRenderContext(o),r.getCurrentColorSpace(o),r.getCurrentColorFormat(o),r.getCurrentDepthStencilFormat(o),r.getPrimitiveTopology(t,n),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,n,r,o,a){return mn(this,null,function*(){return this.textureUtils.copyTextureToBuffer(e,t,n,r,o,a)})}initTimestampQuery(e,t,n){if(!this.trackTimestamp)return;this.timestampQueryPool[e]||(this.timestampQueryPool[e]=new D$(this.device,e,2048));const r=this.timestampQueryPool[e],o=r.allocateQueriesForContext(t);n.timestampWrites={querySet:r.querySet,beginningOfPassWriteIndex:o,endOfPassWriteIndex:o+1}}createNodeBuilder(e,t){return new A$(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 n=this.get(e),o=n.currentPass.finish();this.get(t).bundleGPU=o,n.currentSets=n._currentSets,n.currentPass=n._currentPass}addBundle(e,t){this.get(e).renderBundles.push(this.get(t).bundleGPU)}createBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBindings(e,t,n,r){this.bindingUtils.createBindings(e,t,n,r)}updateBinding(e){this.bindingUtils.updateBinding(e)}deleteBindGroupData(e){this.bindingUtils.deleteBindGroupData(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 K2[e]!==void 0&&(e=K2[e]),this.device.features.has(e)}copyTextureToTexture(e,t,n=null,r=null,o=0,a=0){let c=0,u=0,d=0,p=0,m=0,y=0,x=e.image.width,v=e.image.height,w=1;n!==null&&(n.isBox3===!0?(p=n.min.x,m=n.min.y,y=n.min.z,x=n.max.x-n.min.x,v=n.max.y-n.min.y,w=n.max.z-n.min.z):(p=n.min.x,m=n.min.y,x=n.max.x-n.min.x,v=n.max.y-n.min.y,w=1)),r!==null&&(c=r.x,u=r.y,d=r.z||0);const M=this.device.createCommandEncoder({label:"copyTextureToTexture_"+e.id+"_"+t.id}),S=this.get(e).texture,C=this.get(t).texture;M.copyTextureToTexture({texture:S,mipLevel:o,origin:{x:p,y:m,z:y}},{texture:C,mipLevel:a,origin:{x:c,y:u,z:d}},[x,v,w]),this.device.queue.submit([M.finish()]),a===0&&t.generateMipmaps&&this.textureUtils.generateMipmaps(t)}copyFramebufferToTexture(e,t,n){const r=this.get(t);let o=null;t.renderTarget?e.isDepthTexture?o=this.get(t.depthTexture).texture:o=this.get(t.textures[0]).texture:e.isDepthTexture?o=this.textureUtils.getDepthBuffer(t.depth,t.stencil):o=this.context.getCurrentTexture();const a=this.get(e).texture;if(o.format!==a.format){Be("WebGPUBackend: copyFramebufferToTexture: Source and destination formats do not match.",o.format,a.format);return}let c;if(r.currentPass?(r.currentPass.end(),c=r.encoder):c=this.device.createCommandEncoder({label:"copyFramebufferToTexture_"+e.id}),c.copyTextureToTexture({texture:o,origin:[n.x,n.y,0]},{texture:a},[n.z,n.w]),e.generateMipmaps&&this.textureUtils.generateMipmaps(e,c),r.currentPass){const{descriptor:u}=r;for(let d=0;d<u.colorAttachments.length;d++)u.colorAttachments[d].loadOp=Ii.Load;t.depth&&(u.depthStencilAttachment.depthLoadOp=Ii.Load),t.stencil&&(u.depthStencilAttachment.stencilLoadOp=Ii.Load),r.currentPass=c.beginRenderPass(u),r.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.viewport&&this.updateViewport(t),t.scissor&&this.updateScissor(t)}else this.device.queue.submit([c.finish()])}dispose(){if(this.bindingUtils.dispose(),this.textureUtils.dispose(),this.occludedResolveCache){for(const e of this.occludedResolveCache.values())e.destroy();this.occludedResolveCache.clear()}if(this.timestampQueryPool)for(const e of Object.values(this.timestampQueryPool))e!==null&&e.dispose();this.parameters.device===void 0&&this.device!==null&&this.device.destroy()}}class F$ extends Pm{constructor(e,t,n,r,o,a){super(e,t,n,r,o,a),this.iesMap=null}copy(e,t){return super.copy(e,t),this.iesMap=e.iesMap,this}}class B$ extends Pm{constructor(e,t,n,r,o,a){super(e,t,n,r,o,a),this.aspect=null}copy(e,t){return super.copy(e,t),this.aspect=e.aspect,this}}class O$ extends M2{constructor(){super(),this.addMaterial(KG,"MeshPhongMaterial"),this.addMaterial(QP,"MeshStandardMaterial"),this.addMaterial(G4,"MeshPhysicalMaterial"),this.addMaterial(X4,"MeshToonMaterial"),this.addMaterial(HG,"MeshBasicMaterial"),this.addMaterial(YG,"MeshLambertMaterial"),this.addMaterial(kG,"MeshNormalMaterial"),this.addMaterial(Y4,"MeshMatcapMaterial"),this.addMaterial(LG,"LineBasicMaterial"),this.addMaterial(FG,"LineDashedMaterial"),this.addMaterial(e5,"PointsMaterial"),this.addMaterial(tI,"SpriteMaterial"),this.addMaterial(s5,"ShadowMaterial"),this.addLight(B8,bx),this.addLight(f9,Hf),this.addLight(p9,Sx),this.addLight(s1,Pm),this.addLight(_9,Im),this.addLight(x9,Id),this.addLight(v9,LS),this.addLight(m9,F$),this.addLight(y9,B$),this.addToneMapping(EI,o_),this.addToneMapping(CI,a_),this.addToneMapping(RI,l_),this.addToneMapping(NI,c_),this.addToneMapping(PI,u_),this.addToneMapping(II,h_)}}class U$ extends z9{constructor(e={}){let t;e.forceWebGL?t=$2:(t=x1,e.getFallback=()=>(Ie("WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new $2(e)));const n=new t(e);super(n,e),this.library=new O$,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}}class NK extends null{constructor(){super(),this.isBundleGroup=!0,this.type="BundleGroup",this.static=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}}class PK{constructor(e,t=zt(0,0,1,1)){this.renderer=e,this.outputNode=t,this.outputColorTransform=!0,this.needsUpdate=!0;const n=new Ss;n.name="PostProcessing",this._quadMesh=new By(n),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,n=e.outputColorSpace;e.toneMapping=NoToneMapping,e.outputColorSpace=ColorManagement.workingColorSpace;const r=e.xr.enabled;e.xr.enabled=!1,this._quadMesh.render(e),e.xr.enabled=r,e.toneMapping=t,e.outputColorSpace=n,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,n=e.outputColorSpace,r={postProcessing:this,onBeforePostProcessing:null,onAfterPostProcessing:null};let o=this.outputNode;this.outputColorTransform===!0?(o=o.context(r),o=ET(o,t,n)):(r.toneMapping=t,r.outputColorSpace=n,o=o.context(r)),this._context=r,this._quadMesh.material.fragmentNode=o,this._quadMesh.material.needsUpdate=!0,this.needsUpdate=!1}}renderAsync(){return mn(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 IK 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 LK extends null{constructor(e=1,t=1,n=1){super(),this.isArrayTexture=!1,this.image={width:e,height:t,depth:n},this.magFilter=LinearFilter,this.minFilter=LinearFilter,this.wrapR=ClampToEdgeWrapping,this.isStorageTexture=!0,this.is3DTexture=!0}setSize(e,t,n){(this.image.width!==e||this.image.height!==t||this.image.depth!==n)&&(this.image.width=e,this.image.height=t,this.image.depth=n,this.dispose())}}class DK extends null{constructor(e=1,t=1,n=1){super(),this.isArrayTexture=!0,this.image={width:e,height:t,depth:n},this.magFilter=LinearFilter,this.minFilter=LinearFilter,this.isStorageTexture=!0}setSize(e,t,n){(this.image.width!==e||this.image.height!==t||this.image.depth!==n)&&(this.image.width=e,this.image.height=t,this.image.depth=n,this.dispose())}}class FK extends null{constructor(e,t){super(e,t,Uint32Array),this.isIndirectStorageBufferAttribute=!0}}class k$ extends null{constructor(e){super(e),this.textures={},this.nodes={}}load(e,t,n,r){const o=new FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,a=>{try{t(this.parse(JSON.parse(a)))}catch(c){r?r(c):error(c),this.manager.itemError(e)}},n,r)}parseNodes(e){const t={};if(e!==void 0){for(const r of e){const{uuid:o,type:a}=r;t[o]=this.createNodeFromType(a),t[o].uuid=o}const n={nodes:t,textures:this.textures};for(const r of e)r.meta=n,t[r.uuid].deserialize(r),delete r.meta}return t}parse(e){const t=this.createNodeFromType(e.type);t.uuid=e.uuid;const r={nodes:this.parseNodes(e.nodes),textures:this.textures};return e.meta=r,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),q()):new this.nodes[e]}}class z$ extends null{constructor(e){super(e),this.nodes={},this.nodeMaterials={}}parse(e){const t=super.parse(e),n=this.nodes,r=e.inputNodes;for(const o in r){const a=r[o];t[o]=n[a]}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 BK 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 n=super.parse(e,t);return this._nodesJSON=null,n}parseNodes(e,t){if(e!==void 0){const n=new k$;return n.setNodes(this.nodes),n.setTextures(t),n.parseNodes(e)}return{}}parseMaterials(e,t){const n={};if(e!==void 0){const r=this.parseNodes(this._nodesJSON,t),o=new z$;o.setTextures(t),o.setNodes(r),o.setNodeMaterials(this.nodeMaterials);for(let a=0,c=e.length;a<c;a++){const u=e[a];n[u.uuid]=o.parse(u)}}return n}}class OK extends null{constructor(){super(),this.isClippingGroup=!0,this.clippingPlanes=[],this.enabled=!0,this.clipIntersection=!1,this.clipShadows=!1}}const v1={type:"change"},b1={type:"start"},S1={type:"end"},s3=1e-6,Li={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4},wb=new ze,Qd=new ze,V$=new H,Ab=new H,M1=new H,Mg=new Gs,r3=new H,Eb=new H,T1=new H,Cb=new H;class G$ extends zm{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:pe.ROTATE,MIDDLE:pe.DOLLY,RIGHT:pe.PAN},this.target=new H,this.state=Li.NONE,this.keyState=Li.NONE,this._lastPosition=new H,this._lastZoom=1,this._touchZoomDistanceStart=0,this._touchZoomDistanceEnd=0,this._lastAngle=0,this._eye=new H,this._movePrev=new ze,this._moveCurr=new ze,this._lastAxis=new H,this._zoomStart=new ze,this._zoomEnd=new ze,this._panStart=new ze,this._panEnd=new ze,this._pointers=[],this._pointerPositions={},this._onPointerMove=H$.bind(this),this._onPointerDown=W$.bind(this),this._onPointerUp=$$.bind(this),this._onPointerCancel=q$.bind(this),this._onContextMenu=Q$.bind(this),this._onMouseWheel=J$.bind(this),this._onKeyDown=j$.bind(this),this._onKeyUp=X$.bind(this),this._onTouchStart=e7.bind(this),this._onTouchMove=t7.bind(this),this._onTouchEnd=n7.bind(this),this._onMouseDown=Y$.bind(this),this._onMouseMove=Z$.bind(this),this._onMouseUp=K$.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.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.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)>s3&&(this.dispatchEvent(v1),this._lastPosition.copy(this.object.position))):this.object.isOrthographicCamera?(this.object.lookAt(this.target),(this._lastPosition.distanceToSquared(this.object.position)>s3||this._lastZoom!==this.object.zoom)&&(this.dispatchEvent(v1),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom)):console.warn("THREE.TrackballControls: Unsupported camera type.")}reset(){this.state=Li.NONE,this.keyState=Li.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(v1),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom}_panCamera(){if(Qd.copy(this._panEnd).sub(this._panStart),Qd.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;Qd.x*=e,Qd.y*=t}Qd.multiplyScalar(this._eye.length()*this.panSpeed),Ab.copy(this._eye).cross(this.object.up).setLength(Qd.x),Ab.add(V$.copy(this.object.up).setLength(Qd.y)),this.object.position.add(Ab),this.target.add(Ab),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(Qd.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}}_rotateCamera(){Cb.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0);let e=Cb.length();e?(this._eye.copy(this.object.position).sub(this.target),r3.copy(this._eye).normalize(),Eb.copy(this.object.up).normalize(),T1.crossVectors(Eb,r3).normalize(),Eb.setLength(this._moveCurr.y-this._movePrev.y),T1.setLength(this._moveCurr.x-this._movePrev.x),Cb.copy(Eb.add(T1)),M1.crossVectors(Cb,this._eye).normalize(),e*=this.rotateSpeed,Mg.setFromAxisAngle(M1,e),this._eye.applyQuaternion(Mg),this.object.up.applyQuaternion(Mg),this._lastAxis.copy(M1),this._lastAngle=e):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),Mg.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion(Mg),this.object.up.applyQuaternion(Mg)),this._movePrev.copy(this._moveCurr)}_zoomCamera(){let e;this.state===Li.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=Kh.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=Kh.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 wb.set((e-this.screen.left)/this.screen.width,(t-this.screen.top)/this.screen.height),wb}_getMouseOnCircle(e,t){return wb.set((e-this.screen.width*.5-this.screen.left)/(this.screen.width*.5),(this.screen.height+2*(this.screen.top-t))/this.screen.width),wb}_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 ze,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 W$(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i))}function H$(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function $$(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.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp)))}function q$(i){this._removePointer(i)}function X$(){this.enabled!==!1&&(this.keyState=Li.NONE,window.addEventListener("keydown",this._onKeyDown))}function j$(i){this.enabled!==!1&&(window.removeEventListener("keydown",this._onKeyDown),this.keyState===Li.NONE&&(i.code===this.keys[Li.ROTATE]&&!this.noRotate?this.keyState=Li.ROTATE:i.code===this.keys[Li.ZOOM]&&!this.noZoom?this.keyState=Li.ZOOM:i.code===this.keys[Li.PAN]&&!this.noPan&&(this.keyState=Li.PAN)))}function Y$(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 pe.DOLLY:this.state=Li.ZOOM;break;case pe.ROTATE:this.state=Li.ROTATE;break;case pe.PAN:this.state=Li.PAN;break;default:this.state=Li.NONE}const t=this.keyState!==Li.NONE?this.keyState:this.state;t===Li.ROTATE&&!this.noRotate?(this._moveCurr.copy(this._getMouseOnCircle(i.pageX,i.pageY)),this._movePrev.copy(this._moveCurr)):t===Li.ZOOM&&!this.noZoom?(this._zoomStart.copy(this._getMouseOnScreen(i.pageX,i.pageY)),this._zoomEnd.copy(this._zoomStart)):t===Li.PAN&&!this.noPan&&(this._panStart.copy(this._getMouseOnScreen(i.pageX,i.pageY)),this._panEnd.copy(this._panStart)),this.dispatchEvent(b1)}function Z$(i){const e=this.keyState!==Li.NONE?this.keyState:this.state;e===Li.ROTATE&&!this.noRotate?(this._movePrev.copy(this._moveCurr),this._moveCurr.copy(this._getMouseOnCircle(i.pageX,i.pageY))):e===Li.ZOOM&&!this.noZoom?this._zoomEnd.copy(this._getMouseOnScreen(i.pageX,i.pageY)):e===Li.PAN&&!this.noPan&&this._panEnd.copy(this._getMouseOnScreen(i.pageX,i.pageY))}function K$(){this.state=Li.NONE,this.dispatchEvent(S1)}function J$(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(b1),this.dispatchEvent(S1)}}function Q$(i){this.enabled!==!1&&i.preventDefault()}function e7(i){switch(this._trackPointer(i),this._pointers.length){case 1:this.state=Li.TOUCH_ROTATE,this._moveCurr.copy(this._getMouseOnCircle(this._pointers[0].pageX,this._pointers[0].pageY)),this._movePrev.copy(this._moveCurr);break;default:this.state=Li.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 n=(this._pointers[0].pageX+this._pointers[1].pageX)/2,r=(this._pointers[0].pageY+this._pointers[1].pageY)/2;this._panStart.copy(this._getMouseOnScreen(n,r)),this._panEnd.copy(this._panStart);break}this.dispatchEvent(b1)}function t7(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,n=i.pageY-e.y;this._touchZoomDistanceEnd=Math.sqrt(t*t+n*n);const r=(i.pageX+e.x)/2,o=(i.pageY+e.y)/2;this._panEnd.copy(this._getMouseOnScreen(r,o));break}}function n7(i){switch(this._pointers.length){case 0:this.state=Li.NONE;break;case 1:this.state=Li.TOUCH_ROTATE,this._moveCurr.copy(this._getMouseOnCircle(i.pageX,i.pageY)),this._movePrev.copy(this._moveCurr);break;case 2:this.state=Li.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(S1)}const o3={type:"change"},w1={type:"start"},a3={type:"end"},Rb=new nr,l3=new uo,i7=Math.cos(70*Kh.DEG2RAD),gr=new H,Ho=2*Math.PI,Xi={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},A1=1e-6;class s7 extends zm{constructor(e,t=null){super(e,t),this.state=Xi.NONE,this.target=new H,this.cursor=new H,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:pe.ROTATE,MIDDLE:pe.DOLLY,RIGHT:pe.PAN},this.touches={ONE:ce.ROTATE,TWO:ce.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new H,this._lastQuaternion=new Gs,this._lastTargetPosition=new H,this._quat=new Gs().setFromUnitVectors(e.up,new H(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new G0,this._sphericalDelta=new G0,this._scale=1,this._panOffset=new H,this._rotateStart=new ze,this._rotateEnd=new ze,this._rotateDelta=new ze,this._panStart=new ze,this._panEnd=new ze,this._panDelta=new ze,this._dollyStart=new ze,this._dollyEnd=new ze,this._dollyDelta=new ze,this._dollyDirection=new H,this._mouse=new ze,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=o7.bind(this),this._onPointerDown=r7.bind(this),this._onPointerUp=a7.bind(this),this._onContextMenu=p7.bind(this),this._onMouseWheel=u7.bind(this),this._onKeyDown=h7.bind(this),this._onTouchStart=d7.bind(this),this._onTouchMove=f7.bind(this),this._onMouseDown=l7.bind(this),this._onMouseMove=c7.bind(this),this._interceptControlDown=m7.bind(this),this._interceptControlUp=g7.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.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.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(o3),this.update(),this.state=Xi.NONE}update(e=null){const t=this.object.position;gr.copy(t).sub(this.target),gr.applyQuaternion(this._quat),this._spherical.setFromVector3(gr),this.autoRotate&&this.state===Xi.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 n=this.minAzimuthAngle,r=this.maxAzimuthAngle;isFinite(n)&&isFinite(r)&&(n<-Math.PI?n+=Ho:n>Math.PI&&(n-=Ho),r<-Math.PI?r+=Ho:r>Math.PI&&(r-=Ho),n<=r?this._spherical.theta=Math.max(n,Math.min(r,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+r)/2?Math.max(n,this._spherical.theta):Math.min(r,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 o=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),o=a!=this._spherical.radius}if(gr.setFromSpherical(this._spherical),gr.applyQuaternion(this._quatInverse),t.copy(this.target).add(gr),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 a=null;if(this.object.isPerspectiveCamera){const c=gr.length();a=this._clampDistance(c*this._scale);const u=c-a;this.object.position.addScaledVector(this._dollyDirection,u),this.object.updateMatrixWorld(),o=!!u}else if(this.object.isOrthographicCamera){const c=new H(this._mouse.x,this._mouse.y,0);c.unproject(this.object);const u=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),o=u!==this.object.zoom;const d=new H(this._mouse.x,this._mouse.y,0);d.unproject(this.object),this.object.position.sub(d).add(c),this.object.updateMatrixWorld(),a=gr.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Rb.origin.copy(this.object.position),Rb.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Rb.direction))<i7?this.object.lookAt(this.target):(l3.setFromNormalAndCoplanarPoint(this.object.up,this.target),Rb.intersectPlane(l3,this.target))))}else if(this.object.isOrthographicCamera){const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),a!==this.object.zoom&&(this.object.updateProjectionMatrix(),o=!0)}return this._scale=1,this._performCursorZoom=!1,o||this._lastPosition.distanceToSquared(this.object.position)>A1||8*(1-this._lastQuaternion.dot(this.object.quaternion))>A1||this._lastTargetPosition.distanceToSquared(this.target)>A1?(this.dispatchEvent(o3),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Ho/60*this.autoRotateSpeed*e:Ho/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){gr.setFromMatrixColumn(t,0),gr.multiplyScalar(-e),this._panOffset.add(gr)}_panUp(e,t){this.screenSpacePanning===!0?gr.setFromMatrixColumn(t,1):(gr.setFromMatrixColumn(t,0),gr.crossVectors(this.object.up,gr)),gr.multiplyScalar(e),this._panOffset.add(gr)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const r=this.object.position;gr.copy(r).sub(this.target);let o=gr.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*o/n.clientHeight,this.object.matrix),this._panUp(2*t*o/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.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 n=this.domElement.getBoundingClientRect(),r=e-n.left,o=t-n.top,a=n.width,c=n.height;this._mouse.x=r/a*2-1,this._mouse.y=-(o/c)*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(Ho*this._rotateDelta.x/t.clientHeight),this._rotateUp(Ho*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(Ho*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(-Ho*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(Ho*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(-Ho*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),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,o=Math.sqrt(n*n+r*r);this._dollyStart.set(0,o)}_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 n=this._getSecondPointerPosition(e),r=.5*(e.pageX+n.x),o=.5*(e.pageY+n.y);this._rotateEnd.set(r,o)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Ho*this._rotateDelta.x/t.clientHeight),this._rotateUp(Ho*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),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}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),n=e.pageX-t.x,r=e.pageY-t.y,o=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,o),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 a=(e.pageX+t.x)*.5,c=(e.pageY+t.y)*.5;this._updateZoomParameters(a,c)}_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 ze,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,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function r7(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.ownerDocument.addEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function o7(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function a7(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.ownerDocument.removeEventListener("pointermove",this._onPointerMove),this.domElement.ownerDocument.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(a3),this.state=Xi.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 l7(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 pe.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=Xi.DOLLY;break;case pe.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Xi.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Xi.ROTATE}break;case pe.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Xi.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Xi.PAN}break;default:this.state=Xi.NONE}this.state!==Xi.NONE&&this.dispatchEvent(w1)}function c7(i){switch(this.state){case Xi.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case Xi.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case Xi.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function u7(i){this.enabled===!1||this.enableZoom===!1||this.state!==Xi.NONE||(i.preventDefault(),this.dispatchEvent(w1),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(a3))}function h7(i){this.enabled!==!1&&this._handleKeyDown(i)}function d7(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case ce.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=Xi.TOUCH_ROTATE;break;case ce.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=Xi.TOUCH_PAN;break;default:this.state=Xi.NONE}break;case 2:switch(this.touches.TWO){case ce.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=Xi.TOUCH_DOLLY_PAN;break;case ce.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=Xi.TOUCH_DOLLY_ROTATE;break;default:this.state=Xi.NONE}break;default:this.state=Xi.NONE}this.state!==Xi.NONE&&this.dispatchEvent(w1)}function f7(i){switch(this._trackPointer(i),this.state){case Xi.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case Xi.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case Xi.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case Xi.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=Xi.NONE}}function p7(i){this.enabled!==!1&&i.preventDefault()}function m7(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function g7(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const y7={type:"change"},c3=1e-6,u3=new Gs;class _7 extends zm{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 H(0,0,0),this._rotationVector=new H(0,0,0),this._lastQuaternion=new Gs,this._lastPosition=new H,this._status=0,this._onKeyDown=x7.bind(this),this._onKeyUp=v7.bind(this),this._onPointerMove=S7.bind(this),this._onPointerDown=b7.bind(this),this._onPointerUp=M7.bind(this),this._onPointerCancel=T7.bind(this),this._onContextMenu=w7.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,n=e*this.movementSpeed,r=e*this.rollSpeed;t.translateX(this._moveVector.x*n),t.translateY(this._moveVector.y*n),t.translateZ(this._moveVector.z*n),u3.set(this._rotationVector.x*r,this._rotationVector.y*r,this._rotationVector.z*r,1).normalize(),t.quaternion.multiply(u3),(this._lastPosition.distanceToSquared(t.position)>c3||8*(1-this._lastQuaternion.dot(t.quaternion))>c3)&&(this.dispatchEvent(y7),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 x7(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 v7(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 b7(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 S7(i){if(this.enabled!==!1&&(!this.dragToLook||this._status>0)){const e=this._getContainerDimensions(),t=e.size[0]/2,n=e.size[1]/2;this._moveState.yawLeft=-(i.pageX-e.offset[0]-t)/t,this._moveState.pitchDown=(i.pageY-e.offset[1]-n)/n,this._updateRotationVector()}}function M7(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 T7(){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 w7(i){this.enabled!==!1&&i.preventDefault()}const A7={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 Nb{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 E7=new $u(-1,1,1,-1,0,1);class C7 extends Gn{constructor(){super(),this.setAttribute("position",new ht([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new ht([0,2,0,0,2,0],2))}}const R7=new C7;class N7{constructor(e){this._mesh=new Ji(R7,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,E7)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class P7 extends Nb{constructor(e,t="tDiffuse"){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof lo?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=Io.clone(e.uniforms),this.material=new lo({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 N7(this.material)}render(e,t,n){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=n.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 h3 extends Nb{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){const r=e.getContext(),o=e.state;o.buffers.color.setMask(!1),o.buffers.depth.setMask(!1),o.buffers.color.setLocked(!0),o.buffers.depth.setLocked(!0);let a,c;this.inverse?(a=0,c=1):(a=1,c=0),o.buffers.stencil.setTest(!0),o.buffers.stencil.setOp(r.REPLACE,r.REPLACE,r.REPLACE),o.buffers.stencil.setFunc(r.ALWAYS,a,4294967295),o.buffers.stencil.setClear(c),o.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),o.buffers.color.setLocked(!1),o.buffers.depth.setLocked(!1),o.buffers.color.setMask(!0),o.buffers.depth.setMask(!0),o.buffers.stencil.setLocked(!1),o.buffers.stencil.setFunc(r.EQUAL,1,4294967295),o.buffers.stencil.setOp(r.KEEP,r.KEEP,r.KEEP),o.buffers.stencil.setLocked(!0)}}class I7 extends Nb{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class L7{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const n=e.getSize(new ze);this._width=n.width,this._height=n.height,t=new qr(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Hi}),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 P7(A7),this.copyPass.material.blending=ve,this.clock=new xl}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 n=!1;for(let r=0,o=this.passes.length;r<o;r++){const a=this.passes[r];if(a.enabled!==!1){if(a.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(r),a.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),a.needsSwap){if(n){const c=this.renderer.getContext(),u=this.renderer.state.buffers.stencil;u.setFunc(c.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),u.setFunc(c.EQUAL,1,4294967295)}this.swapBuffers()}h3!==void 0&&(a instanceof h3?n=!0:a instanceof I7&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){const t=this.renderer.getSize(new ze);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 n=this._width*this._pixelRatio,r=this._height*this._pixelRatio;this.renderTarget1.setSize(n,r),this.renderTarget2.setSize(n,r);for(let o=0;o<this.passes.length;o++)this.passes[o].setSize(n,r)}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.copyPass.dispose()}}class D7 extends Nb{constructor(e,t,n=null,r=null,o=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=r,this.clearAlpha=o,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this.isRenderPass=!0,this._oldClearColor=new It}render(e,t,n){const r=e.autoClear;e.autoClear=!1;let o,a;this.overrideMaterial!==null&&(a=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(e.getClearColor(this._oldClearColor),e.setClearColor(this.clearColor,e.getClearAlpha())),this.clearAlpha!==null&&(o=e.getClearAlpha(),e.setClearAlpha(this.clearAlpha)),this.clearDepth==!0&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),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(o),this.overrideMaterial!==null&&(this.scene.overrideMaterial=a),e.autoClear=r}}var el=re(54476),F7=re(31226),B7=re(69168),O7=re(58289),d3=re(18773);function U7(i){try{return Function.toString.call(i).indexOf("[native code]")!==-1}catch(e){return typeof i=="function"}}var k7=re(75538);function z7(i,e,t){if((0,k7.Z)())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var r=new(i.bind.apply(i,n));return t&&(0,d3.Z)(r,t.prototype),r}function E1(i){var e=typeof Map=="function"?new Map:void 0;return E1=function(n){if(n===null||!U7(n))return n;if(typeof n!="function")throw new TypeError("Super expression must either be null or a function");if(e!==void 0){if(e.has(n))return e.get(n);e.set(n,r)}function r(){return z7(n,arguments,(0,O7.Z)(this).constructor)}return r.prototype=Object.create(n.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),(0,d3.Z)(r,n)},E1(i)}function f3(){var i;return i=arguments.length-1,i<0||arguments.length<=i?void 0:arguments[i]}function V7(i){return-i}function G7(i,e){return i+e}function W7(i,e){return i-e}function H7(i,e){return i*e}function $7(i,e){return i/e}function q7(){return Math.max.apply(Math,arguments)}function X7(){return Math.min.apply(Math,arguments)}function j7(){return Array.of.apply(Array,arguments)}var UK={symbols:{"*":{infix:{symbol:"*",f:H7,notation:"infix",precedence:4,rightToLeft:0,argCount:2},symbol:"*",regSymbol:"\\*"},"/":{infix:{symbol:"/",f:$7,notation:"infix",precedence:4,rightToLeft:0,argCount:2},symbol:"/",regSymbol:"/"},"+":{infix:{symbol:"+",f:G7,notation:"infix",precedence:2,rightToLeft:0,argCount:2},prefix:{symbol:"+",f:f3,notation:"prefix",precedence:3,rightToLeft:0,argCount:1},symbol:"+",regSymbol:"\\+"},"-":{infix:{symbol:"-",f:W7,notation:"infix",precedence:2,rightToLeft:0,argCount:2},prefix:{symbol:"-",f:V7,notation:"prefix",precedence:3,rightToLeft:0,argCount:1},symbol:"-",regSymbol:"-"},",":{infix:{symbol:",",f:j7,notation:"infix",precedence:1,rightToLeft:0,argCount:2},symbol:",",regSymbol:","},"(":{prefix:{symbol:"(",f:f3,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:X7,notation:"func",precedence:0,rightToLeft:0,argCount:1},symbol:"min",regSymbol:"min\\b"},max:{func:{symbol:"max",f:q7,notation:"func",precedence:0,rightToLeft:0,argCount:1},symbol:"max",regSymbol:"max\\b"}}},p3=null,kK={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 zK(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];var n=e[0],r=[],o;for(o=1;o<e.length;o+=1)r.push(e[o]);return r.forEach(function(a){n=n.replace(/%[a-z]/,a)}),n}var On=function(i){(0,B7.Z)(e,i);function e(t){var n;if(1)n=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 r,o,a;return(0,F7.Z)(n)}return e}(E1(Error)),m3=/((?!\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 Y7(i){var e={};return e.symbols=i?_extends({},p3.symbols,i.symbols):_extends({},p3.symbols),e}function g3(i,e){var t,n=i.pop();return e.push(n.f.apply(n,(t=[]).concat.apply(t,e.splice(-n.argCount)))),n.precedence}function Z7(i,e){var t=Y7(e),n,r=[t.symbols["("].prefix],o=[],a=new RegExp("\\d+(?:\\.\\d+)?|"+Object.keys(t.symbols).map(function(M){return t.symbols[M]}).sort(function(M,S){return S.symbol.length-M.symbol.length}).map(function(M){return M.regSymbol}).join("|")+"|(\\S)","g");a.lastIndex=0;var c=!1;do{n=a.exec(i);var u=n||[")",void 0],d=u[0],p=u[1],m=t.symbols[d],y=m&&!m.prefix&&!m.func,x=!m||!m.postfix&&!m.infix;if(p||(c?x:y))throw new On(37,n?n.index:i.length,i);if(c){var v=m.postfix||m.infix;do{var w=r[r.length-1];if((v.precedence-w.precedence||w.rightToLeft)>0)break}while(g3(r,o));c=v.notation==="postfix",v.symbol!==")"&&(r.push(v),c&&g3(r,o))}else if(m){if(r.push(m.prefix||m.func),m.func&&(n=a.exec(i),!n||n[0]!=="("))throw new On(38,n?n.index:i.length,i)}else o.push(+d),c=!0}while(n&&r.length);if(r.length)throw new On(39,n?n.index:i.length,i);if(n)throw new On(40,n?n.index:i.length,i);return o.pop()}function C1(i){return i.split("").reverse().join("")}function VK(i,e){var t=C1(i),n=t.match(m3);if(n&&!n.every(function(o){return o===n[0]}))throw new On(41);var r=C1(t.replace(m3,""));return""+Z7(r,e)+(n?C1(n[0]):"")}var K7=/--[\S]*/g;function GK(i,e){if(!i||!i.match(K7))throw new On(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 On(74)}function Ky(i){return i.charAt(0).toUpperCase()+i.slice(1)}var J7=null;function Q7(i,e){if(!i)return e.toLowerCase();var t=i.split("-");if(t.length>1)return t.splice(1,0,e),t.reduce(function(r,o){return""+r+Ky(o)});var n=i.replace(/([a-z])([A-Z])/g,"$1"+e+"$2");return i===n?""+i+e:n}function eq(i,e){for(var t={},n=0;n<e.length;n+=1)(e[n]||e[n]===0)&&(t[Q7(i,J7[n])]=e[n]);return t}function bp(i){for(var e=arguments.length,t=new Array(e>1?e-1:0),n=1;n<e;n++)t[n-1]=arguments[n];var r=t[0],o=t[1],a=o===void 0?r:o,c=t[2],u=c===void 0?r:c,d=t[3],p=d===void 0?a:d,m=[r,a,u,p];return eq(i,m)}function y3(i,e){return i.substr(-e.length)===e}var tq=/^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/;function _3(i){if(typeof i!="string")return i;var e=i.match(tq);return e?parseFloat(i):i}var nq=function(e){return function(t,n){n===void 0&&(n="16px");var r=t,o=n;if(typeof t=="string"){if(!y3(t,"px"))throw new On(69,e,t);r=_3(t)}if(typeof n=="string"){if(!y3(n,"px"))throw new On(70,e,n);o=_3(n)}if(typeof r=="string")throw new On(71,t,e);if(typeof o=="string")throw new On(72,n,e);return""+r/o+e}},x3=nq,WK=x3("em"),HK=null,iq=/^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/;function ph(i){if(typeof i!="string")return[i,""];var e=i.match(iq);return e?[parseFloat(i),e[2]]:[i,void 0]}function sq(i,e){if(typeof i!="object"||i===null)throw new On(75,typeof i);var t={};return Object.keys(i).forEach(function(n){typeof i[n]=="object"&&i[n]!==null?t[n]=sq(i[n],e):!e||e&&(e===n||e.indexOf(n)>=0)?t[n]=i[n]+" !important":t[n]=i[n]}),t}var v3={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 rq(i){return v3[i]}function $K(i,e,t){if(e===void 0&&(e="1em"),t===void 0&&(t=1.333),typeof i!="number")throw new On(42);if(typeof t=="string"&&!v3[t])throw new On(43);var n=typeof e=="string"?ph(e):[e,""],r=n[0],o=n[1],a=typeof t=="string"?rq(t):t;if(typeof r=="string")throw new On(44,e);return""+r*Math.pow(a,i)+(o||"")}var qK=x3("rem"),XK=null,R1=16;function b3(i){var e=ph(i);if(e[1]==="px")return parseFloat(i);if(e[1]==="%")return parseFloat(i)/100*R1;throw new On(78,e[1])}function oq(){if(typeof document!="undefined"&&document.documentElement!==null){var i=getComputedStyle(document.documentElement).fontSize;return i?b3(i):R1}return R1}function jK(i,e){var t=ph(i);if(t[1]!=="rem"&&t[1]!=="")throw new On(77,t[1]);var n=e?b3(e):oq();return t[0]*n+"px"}var aq={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 YK(i){return aq[i.toLowerCase().trim()]}var lq={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 ZK(i){return lq[i.toLowerCase().trim()]}var cq={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 KK(i){return cq[i.toLowerCase().trim()]}function S3(i,e,t,n){t===void 0&&(t="320px"),n===void 0&&(n="1200px");var r=ph(i),o=r[0],a=r[1],c=ph(e),u=c[0],d=c[1],p=ph(t),m=p[0],y=p[1],x=ph(n),v=x[0],w=x[1];if(typeof m!="number"||typeof v!="number"||!y||!w||y!==w)throw new On(47);if(typeof o!="number"||typeof u!="number"||a!==d)throw new On(48);if(a!==y||d!==w)throw new On(76);var M=(o-u)/(m-v),S=u-M*v;return"calc("+S.toFixed(2)+(a||"")+" + "+(100*M).toFixed(2)+"vw)"}function JK(i){var e;i===void 0&&(i="&");var t=i+"::after";return e={},e[t]={clear:"both",content:'""',display:"table"},e}function QK(i){return i===void 0&&(i=0),{position:"absolute",top:i,right:i,bottom:i,left:i}}function eJ(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 uq(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=hq(i))||e&&i&&typeof i.length=="number"){t&&(i=t);var n=0;return function(){return n>=i.length?{done:!0}:{done:!1,value:i[n++]}}}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 hq(i,e){if(i){if(typeof i=="string")return M3(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 M3(i,e)}}function M3(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=i[t];return n}function tJ(i,e,t){if(e===void 0&&(e="320px"),t===void 0&&(t="1200px"),!Array.isArray(i)&&typeof i!="object"||i===null)throw new On(49);if(Array.isArray(i)){for(var n={},r={},o=uq(i),a;!(a=o()).done;){var c,u,d=a.value;if(!d.prop||!d.fromSize||!d.toSize)throw new On(50);r[d.prop]=d.fromSize,n["@media (min-width: "+e+")"]=_extends({},n["@media (min-width: "+e+")"],(c={},c[d.prop]=S3(d.fromSize,d.toSize,e,t),c)),n["@media (min-width: "+t+")"]=_extends({},n["@media (min-width: "+t+")"],(u={},u[d.prop]=d.toSize,u))}return _extends({},r,n)}else{var p,m,y;if(!i.prop||!i.fromSize||!i.toSize)throw new On(51);return y={},y[i.prop]=i.fromSize,y["@media (min-width: "+e+")"]=(p={},p[i.prop]=S3(i.fromSize,i.toSize,e,t),p),y["@media (min-width: "+t+")"]=(m={},m[i.prop]=i.toSize,m),y}}var dq=/^\s*data:([a-z]+\/[a-z-]+(;[a-z-]+=[a-z-]+)?)?(;charset=[a-z0-9-]+)?(;base64)?,[a-z0-9!$&',()*+,;=\-._~:@/?%\s]*\s*$/i,fq={woff:"woff",woff2:"woff2",ttf:"truetype",otf:"opentype",eot:"embedded-opentype",svg:"svg",svgz:"svg"};function T3(i,e){return e?' format("'+fq[i]+'")':""}function pq(i){return!!i.replace(/\s+/g," ").match(dq)}function mq(i,e,t){if(pq(i))return'url("'+i+'")'+T3(e[0],t);var n=e.map(function(r){return'url("'+i+"."+r+'")'+T3(r,t)});return n.join(", ")}function gq(i){var e=i.map(function(t){return'local("'+t+'")'});return e.join(", ")}function yq(i,e,t,n){var r=[];return e&&r.push(gq(e)),i&&r.push(mq(i,t,n)),r.join(", ")}function nJ(i){var e=i.fontFamily,t=i.fontFilePath,n=i.fontStretch,r=i.fontStyle,o=i.fontVariant,a=i.fontWeight,c=i.fileFormats,u=c===void 0?["eot","woff2","woff","ttf","svg"]:c,d=i.formatHint,p=d===void 0?!1:d,m=i.localFonts,y=m===void 0?[e]:m,x=i.unicodeRange,v=i.fontDisplay,w=i.fontVariationSettings,M=i.fontFeatureSettings;if(!e)throw new On(55);if(!t&&!y)throw new On(52);if(y&&!Array.isArray(y))throw new On(53);if(!Array.isArray(u))throw new On(54);var S={"@font-face":{fontFamily:e,src:yq(t,y,u,p),unicodeRange:x,fontStretch:n,fontStyle:r,fontVariant:o,fontWeight:a,fontDisplay:v,fontVariationSettings:w,fontFeatureSettings:M}};return JSON.parse(JSON.stringify(S))}function iJ(){return{textIndent:"101%",overflow:"hidden",whiteSpace:"nowrap"}}function sJ(){return{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",whiteSpace:"nowrap",width:"1px"}}function _q(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 w3(i){for(var e="",t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];for(var o=0;o<i.length;o+=1)if(e+=i[o],o===n.length-1&&n[o]){var a=n.filter(function(c){return!!c});a.length>1?(e=e.slice(0,-1),e+=", "+n[o]):a.length===1&&(e+=""+n[o])}else n[o]&&(e+=n[o]+" ");return e.trim()}var A3;function rJ(i){var e=i.colorStops,t=i.fallback,n=i.toDirection,r=n===void 0?"":n;if(!e||e.length<2)throw new On(56);return{backgroundColor:t||e[0].replace(/,\s+/g,",").split(" ")[0].replace(/,(?=\S)/g,", "),backgroundImage:w3(A3||(A3=_taggedTemplateLiteralLoose(["linear-gradient(","",")"])),r,e.join(", ").replace(/,(?=\S)/g,", "))}}function oJ(){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 E3;function aJ(i){var e=i.colorStops,t=i.extent,n=t===void 0?"":t,r=i.fallback,o=i.position,a=o===void 0?"":o,c=i.shape,u=c===void 0?"":c;if(!e||e.length<2)throw new On(57);return{backgroundColor:r||e[0].split(" ")[0],backgroundImage:w3(E3||(E3=_taggedTemplateLiteralLoose(["radial-gradient(","","","",")"])),a,u,n,e.join(", "))}}function lJ(i,e,t,n,r){var o;if(t===void 0&&(t="png"),r===void 0&&(r="_2x"),!i)throw new On(58);var a=t.replace(/^\./,""),c=n?n+"."+a:""+i+r+"."+a;return o={backgroundImage:"url("+i+"."+a+")"},o[_q()]=_extends({backgroundImage:"url("+c+")"},e?{backgroundSize:e}:{}),o}var xq={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 vq(i){return xq[i]}function cJ(i){return vq(i)}var bq=function(e,t,n){var r=""+n[0]+(n[1]||""),o=""+n[0]/2+(n[1]||""),a=""+t[0]+(t[1]||""),c=""+t[0]/2+(t[1]||"");switch(e){case"top":return"0 "+o+" "+a+" "+o;case"topLeft":return r+" "+a+" 0 0";case"left":return c+" "+r+" "+c+" 0";case"bottomLeft":return r+" 0 0 "+a;case"bottom":return a+" "+o+" 0 "+o;case"bottomRight":return"0 0 "+r+" "+a;case"right":return c+" 0 "+c+" "+r;case"topRight":default:return"0 "+r+" "+a+" 0"}},Sq=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 On(59)}};function uJ(i){var e=i.pointingDirection,t=i.height,n=i.width,r=i.foregroundColor,o=i.backgroundColor,a=o===void 0?"transparent":o,c=ph(n),u=ph(t);if(isNaN(u[0])||isNaN(c[0]))throw new On(60);return _extends({width:"0",height:"0",borderColor:a},Sq(e,r),{borderStyle:"solid",borderWidth:bq(e,u,c)})}function hJ(i){i===void 0&&(i="break-word");var e=i==="break-word"?"break-all":i;return{overflowWrap:i,wordWrap:i,wordBreak:e}}function N1(i){return Math.round(i*255)}function Mq(i,e,t){return N1(i)+","+N1(e)+","+N1(t)}function Jy(i,e,t,n){if(n===void 0&&(n=Mq),e===0)return n(t,t,t);var r=(i%360+360)%360/60,o=(1-Math.abs(2*t-1))*e,a=o*(1-Math.abs(r%2-1)),c=0,u=0,d=0;r>=0&&r<1?(c=o,u=a):r>=1&&r<2?(c=a,u=o):r>=2&&r<3?(u=o,d=a):r>=3&&r<4?(u=a,d=o):r>=4&&r<5?(c=a,d=o):r>=5&&r<6&&(c=o,d=a);var p=t-o/2,m=c+p,y=u+p,x=d+p;return n(m,y,x)}var C3={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 Tq(i){if(typeof i!="string")return i;var e=i.toLowerCase();return C3[e]?"#"+C3[e]:i}var wq=/^#[a-fA-F0-9]{6}$/,Aq=/^#[a-fA-F0-9]{8}$/,Eq=/^#[a-fA-F0-9]{3}$/,Cq=/^#[a-fA-F0-9]{4}$/,P1=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,Rq=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,Nq=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,Pq=/^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 mh(i){if(typeof i!="string")throw new On(3);var e=Tq(i);if(e.match(wq))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(Aq)){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(Eq))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(Cq)){var n=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:n}}var r=P1.exec(e);if(r)return{red:parseInt(""+r[1],10),green:parseInt(""+r[2],10),blue:parseInt(""+r[3],10)};var o=Rq.exec(e.substring(0,50));if(o)return{red:parseInt(""+o[1],10),green:parseInt(""+o[2],10),blue:parseInt(""+o[3],10),alpha:parseFloat(""+o[4])>1?parseFloat(""+o[4])/100:parseFloat(""+o[4])};var a=Nq.exec(e);if(a){var c=parseInt(""+a[1],10),u=parseInt(""+a[2],10)/100,d=parseInt(""+a[3],10)/100,p="rgb("+Jy(c,u,d)+")",m=P1.exec(p);if(!m)throw new On(4,e,p);return{red:parseInt(""+m[1],10),green:parseInt(""+m[2],10),blue:parseInt(""+m[3],10)}}var y=Pq.exec(e.substring(0,50));if(y){var x=parseInt(""+y[1],10),v=parseInt(""+y[2],10)/100,w=parseInt(""+y[3],10)/100,M="rgb("+Jy(x,v,w)+")",S=P1.exec(M);if(!S)throw new On(4,e,M);return{red:parseInt(""+S[1],10),green:parseInt(""+S[2],10),blue:parseInt(""+S[3],10),alpha:parseFloat(""+y[4])>1?parseFloat(""+y[4])/100:parseFloat(""+y[4])}}throw new On(5)}function Iq(i){var e=i.red/255,t=i.green/255,n=i.blue/255,r=Math.max(e,t,n),o=Math.min(e,t,n),a=(r+o)/2;if(r===o)return i.alpha!==void 0?{hue:0,saturation:0,lightness:a,alpha:i.alpha}:{hue:0,saturation:0,lightness:a};var c,u=r-o,d=a>.5?u/(2-r-o):u/(r+o);switch(r){case e:c=(t-n)/u+(t<n?6:0);break;case t:c=(n-e)/u+2;break;default:c=(e-t)/u+4;break}return c*=60,i.alpha!==void 0?{hue:c,saturation:d,lightness:a,alpha:i.alpha}:{hue:c,saturation:d,lightness:a}}function Vc(i){return Iq(mh(i))}var Lq=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},I1=Lq;function Sp(i){var e=i.toString(16);return e.length===1?"0"+e:e}function L1(i){return Sp(Math.round(i*255))}function Dq(i,e,t){return I1("#"+L1(i)+L1(e)+L1(t))}function Pb(i,e,t){return Jy(i,e,t,Dq)}function R3(i,e,t){if(typeof i=="number"&&typeof e=="number"&&typeof t=="number")return Pb(i,e,t);if(typeof i=="object"&&e===void 0&&t===void 0)return Pb(i.hue,i.saturation,i.lightness);throw new On(1)}function N3(i,e,t,n){if(typeof i=="number"&&typeof e=="number"&&typeof t=="number"&&typeof n=="number")return n>=1?Pb(i,e,t):"rgba("+Jy(i,e,t)+","+n+")";if(typeof i=="object"&&e===void 0&&t===void 0&&n===void 0)return i.alpha>=1?Pb(i.hue,i.saturation,i.lightness):"rgba("+Jy(i.hue,i.saturation,i.lightness)+","+i.alpha+")";throw new On(2)}function Ib(i,e,t){if(typeof i=="number"&&typeof e=="number"&&typeof t=="number")return I1("#"+Sp(i)+Sp(e)+Sp(t));if(typeof i=="object"&&e===void 0&&t===void 0)return I1("#"+Sp(i.red)+Sp(i.green)+Sp(i.blue));throw new On(6)}function Qy(i,e,t,n){if(typeof i=="string"&&typeof e=="number"){var r=mh(i);return"rgba("+r.red+","+r.green+","+r.blue+","+e+")"}else{if(typeof i=="number"&&typeof e=="number"&&typeof t=="number"&&typeof n=="number")return n>=1?Ib(i,e,t):"rgba("+i+","+e+","+t+","+n+")";if(typeof i=="object"&&e===void 0&&t===void 0&&n===void 0)return i.alpha>=1?Ib(i.red,i.green,i.blue):"rgba("+i.red+","+i.green+","+i.blue+","+i.alpha+")"}throw new On(7)}var Fq=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&(typeof e.alpha!="number"||typeof e.alpha=="undefined")},Bq=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&typeof e.alpha=="number"},Oq=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&(typeof e.alpha!="number"||typeof e.alpha=="undefined")},Uq=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&typeof e.alpha=="number"};function Ll(i){if(typeof i!="object")throw new On(8);if(Bq(i))return Qy(i);if(Fq(i))return Ib(i);if(Uq(i))return N3(i);if(Oq(i))return R3(i);throw new On(8)}function P3(i,e,t){return function(){var r=t.concat(Array.prototype.slice.call(arguments));return r.length>=e?i.apply(this,r):P3(i,e,r)}}function Sa(i){return P3(i,i.length,[])}function kq(i,e){if(e==="transparent")return e;var t=Vc(e);return Ll((0,el.Z)({},t,{hue:t.hue+parseFloat(i)}))}var dJ=Sa(kq),fJ=null;function pJ(i){if(i==="transparent")return i;var e=Vc(i);return Ll(_extends({},e,{hue:(e.hue+180)%360}))}function Tg(i,e,t){return Math.max(i,Math.min(e,t))}function zq(i,e){if(e==="transparent")return e;var t=Vc(e);return Ll((0,el.Z)({},t,{lightness:Tg(0,1,t.lightness-parseFloat(i))}))}var mJ=Sa(zq),gJ=null;function Vq(i,e){if(e==="transparent")return e;var t=Vc(e);return Ll((0,el.Z)({},t,{saturation:Tg(0,1,t.saturation-parseFloat(i))}))}var yJ=Sa(Vq),_J=null;function D1(i){if(i==="transparent")return 0;var e=mh(i),t=Object.keys(e).map(function(a){var c=e[a]/255;return c<=.03928?c/12.92:Math.pow((c+.055)/1.055,2.4)}),n=t[0],r=t[1],o=t[2];return parseFloat((.2126*n+.7152*r+.0722*o).toFixed(3))}function I3(i,e){var t=D1(i),n=D1(e);return parseFloat((t>n?(t+.05)/(n+.05):(n+.05)/(t+.05)).toFixed(2))}function xJ(i){return i==="transparent"?i:Ll(_extends({},Vc(i),{saturation:0}))}function vJ(i){if(typeof i=="object"&&typeof i.hue=="number"&&typeof i.saturation=="number"&&typeof i.lightness=="number")return i.alpha&&typeof i.alpha=="number"?N3({hue:i.hue,saturation:i.saturation,lightness:i.lightness,alpha:i.alpha}):R3({hue:i.hue,saturation:i.saturation,lightness:i.lightness});throw new On(45)}function bJ(i){if(i==="transparent")return i;var e=mh(i);return Ll(_extends({},e,{red:255-e.red,green:255-e.green,blue:255-e.blue}))}function Gq(i,e){if(e==="transparent")return e;var t=Vc(e);return Ll((0,el.Z)({},t,{lightness:Tg(0,1,t.lightness+parseFloat(i))}))}var SJ=Sa(Gq),MJ=null;function TJ(i,e){var t=I3(i,e);return{AA:t>=4.5,AALarge:t>=3,AAA:t>=7,AAALarge:t>=4.5}}function Wq(i,e,t){if(e==="transparent")return t;if(t==="transparent")return e;if(i===0)return t;var n=mh(e),r=(0,el.Z)({},n,{alpha:typeof n.alpha=="number"?n.alpha:1}),o=mh(t),a=(0,el.Z)({},o,{alpha:typeof o.alpha=="number"?o.alpha:1}),c=r.alpha-a.alpha,u=parseFloat(i)*2-1,d=u*c===-1?u:u+c,p=1+u*c,m=(d/p+1)/2,y=1-m,x={red:Math.floor(r.red*m+a.red*y),green:Math.floor(r.green*m+a.green*y),blue:Math.floor(r.blue*m+a.blue*y),alpha:r.alpha*parseFloat(i)+a.alpha*(1-parseFloat(i))};return Qy(x)}var Hq=Sa(Wq),L3=Hq;function $q(i,e){if(e==="transparent")return e;var t=mh(e),n=typeof t.alpha=="number"?t.alpha:1,r=(0,el.Z)({},t,{alpha:Tg(0,1,(n*100+parseFloat(i)*100)/100)});return Qy(r)}var qq=Sa($q),Xq=qq,D3="#000",F3="#fff";function wJ(i,e,t,n){e===void 0&&(e=D3),t===void 0&&(t=F3),n===void 0&&(n=!0);var r=D1(i)>.179,o=r?e:t;return!n||I3(i,o)>=4.5?o:r?D3:F3}function AJ(i){if(typeof i=="object"&&typeof i.red=="number"&&typeof i.green=="number"&&typeof i.blue=="number")return typeof i.alpha=="number"?Qy({red:i.red,green:i.green,blue:i.blue,alpha:i.alpha}):Ib({red:i.red,green:i.green,blue:i.blue});throw new On(46)}function jq(i,e){if(e==="transparent")return e;var t=Vc(e);return Ll((0,el.Z)({},t,{saturation:Tg(0,1,t.saturation+parseFloat(i))}))}var EJ=Sa(jq),CJ=null;function Yq(i,e){return e==="transparent"?e:Ll((0,el.Z)({},Vc(e),{hue:parseFloat(i)}))}var RJ=Sa(Yq),NJ=null;function Zq(i,e){return e==="transparent"?e:Ll((0,el.Z)({},Vc(e),{lightness:parseFloat(i)}))}var PJ=Sa(Zq),IJ=null;function Kq(i,e){return e==="transparent"?e:Ll((0,el.Z)({},Vc(e),{saturation:parseFloat(i)}))}var LJ=Sa(Kq),DJ=null;function Jq(i,e){return e==="transparent"?e:L3(parseFloat(i),"rgb(0, 0, 0)",e)}var FJ=Sa(Jq),BJ=null;function Qq(i,e){return e==="transparent"?e:L3(parseFloat(i),"rgb(255, 255, 255)",e)}var OJ=Sa(Qq),UJ=null;function eX(i,e){if(e==="transparent")return e;var t=mh(e),n=typeof t.alpha=="number"?t.alpha:1,r=(0,el.Z)({},t,{alpha:Tg(0,1,+(n*100-parseFloat(i)*100).toFixed(2)/100)});return Qy(r)}var kJ=Sa(eX),zJ=null;function VJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];var n=Array.isArray(e[0]);if(!n&&e.length>8)throw new On(64);var r=e.map(function(o){if(n&&!Array.isArray(o)||!n&&Array.isArray(o))throw new On(65);if(Array.isArray(o)&&o.length>8)throw new On(66);return Array.isArray(o)?o.join(" "):o}).join(", ");return{animation:r}}function GJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return{backgroundImage:e.join(", ")}}function WJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return{background:e.join(", ")}}var tX=null;function HJ(i){for(var e=arguments.length,t=new Array(e>1?e-1:0),n=1;n<e;n++)t[n-1]=arguments[n];if(typeof i=="string"&&tX.indexOf(i)>=0){var r;return r={},r["border"+Ky(i)+"Width"]=t[0],r["border"+Ky(i)+"Style"]=t[1],r["border"+Ky(i)+"Color"]=t[2],r}else return t.unshift(i),{borderWidth:t[0],borderStyle:t[1],borderColor:t[2]}}function $J(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return bp.apply(void 0,["borderColor"].concat(e))}function qJ(i,e){var t=Ky(i);if(!e&&e!==0)throw new On(62);if(t==="Top"||t==="Bottom"){var n;return n={},n["border"+t+"RightRadius"]=e,n["border"+t+"LeftRadius"]=e,n}if(t==="Left"||t==="Right"){var r;return r={},r["borderTop"+t+"Radius"]=e,r["borderBottom"+t+"Radius"]=e,r}throw new On(63)}function XJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return bp.apply(void 0,["borderStyle"].concat(e))}function jJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return bp.apply(void 0,["borderWidth"].concat(e))}function B3(i,e){var t=e?":"+e:"";return i(t)}function O3(i,e,t){if(!e)throw new On(67);if(i.length===0)return B3(e,null);for(var n=[],r=0;r<i.length;r+=1){if(t&&t.indexOf(i[r])<0)throw new On(68);n.push(B3(e,i[r]))}return n=n.join(","),n}var nX=null;function iX(i){return"button"+i+`,
input[type="button"]`+i+`,
input[type="reset"]`+i+`,
input[type="submit"]`+i}function YJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return O3(e,iX,nX)}function ZJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return bp.apply(void 0,["margin"].concat(e))}function KJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return bp.apply(void 0,["padding"].concat(e))}var sX=null;function JJ(i){for(var e=arguments.length,t=new Array(e>1?e-1:0),n=1;n<e;n++)t[n-1]=arguments[n];return sX.indexOf(i)>=0&&i?_extends({},bp.apply(void 0,[""].concat(t)),{position:i}):bp.apply(void 0,["",i].concat(t))}function QJ(i,e){return e===void 0&&(e=i),{height:i,width:e}}var rX=null;function oX(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 eQ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return O3(e,oX,rX)}function tQ(){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 n=e[1];if(typeof n!="string")throw new On(61);var r=e[0].map(function(o){return o+" "+n}).join(", ");return{transition:r}}else return{transition:e.join(", ")}}var ef=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-ef.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?ef.Bounce.In(i*2)*.5:ef.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}}}}),wg=function(){return performance.now()},F1=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=[],n=0;n<arguments.length;n++)t[n]=arguments[n];for(var r=0,o=t;r<o.length;r++){var a=o[r];(e=a._group)===null||e===void 0||e.remove(a),a._group=this,this._tweens[a.getId()]=a,this._tweensAddedDuringUpdate[a.getId()]=a}},i.prototype.remove=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var n=0,r=e;n<r.length;n++){var o=r[n];o._group=void 0,delete this._tweens[o.getId()],delete this._tweensAddedDuringUpdate[o.getId()]}},i.prototype.allStopped=function(){return this.getAll().every(function(e){return!e.isPlaying()})},i.prototype.update=function(e,t){e===void 0&&(e=wg()),t===void 0&&(t=!0);var n=Object.keys(this._tweens);if(n.length!==0)for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var r=0;r<n.length;r++){var o=this._tweens[n[r]],a=!t;o&&o.update(e,a)===!1&&!t&&this.remove(o)}n=Object.keys(this._tweensAddedDuringUpdate)}},i}(),Mp={Linear:function(i,e){var t=i.length-1,n=t*e,r=Math.floor(n),o=Mp.Utils.Linear;return e<0?o(i[0],i[1],n):e>1?o(i[t],i[t-1],t-n):o(i[r],i[r+1>t?t:r+1],n-r)},Bezier:function(i,e){for(var t=0,n=i.length-1,r=Math.pow,o=Mp.Utils.Bernstein,a=0;a<=n;a++)t+=r(1-e,n-a)*r(e,a)*i[a]*o(n,a);return t},CatmullRom:function(i,e){var t=i.length-1,n=t*e,r=Math.floor(n),o=Mp.Utils.CatmullRom;return i[0]===i[t]?(e<0&&(r=Math.floor(n=t*(1+e))),o(i[(r-1+t)%t],i[r],i[(r+1)%t],i[(r+2)%t],n-r)):e<0?i[0]-(o(i[0],i[0],i[1],i[1],-n)-i[0]):e>1?i[t]-(o(i[t],i[t],i[t-1],i[t-1],n-t)-i[t]):o(i[r?r-1:0],i[r],i[t<r+1?t:r+1],i[t<r+2?t:r+2],n-r)},Utils:{Linear:function(i,e,t){return(e-i)*t+i},Bernstein:function(i,e){var t=Mp.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 n=e;n>1;n--)t*=n;return i[e]=t,t}}(),CatmullRom:function(i,e,t,n,r){var o=(t-i)*.5,a=(n-e)*.5,c=r*r,u=r*c;return(2*e-2*t+o+a)*u+(-3*e+3*t-2*o-a)*c+o*r+e}}},B1=function(){function i(){}return i.nextId=function(){return i._nextId++},i._nextId=0,i}(),O1=new F1,U1=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=ef.Linear.None,this._interpolationFunction=Mp.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=B1.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=O1,O1.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=wg()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}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 r={};for(var o in this._valuesEnd)r[o]=this._valuesEnd[o];this._valuesEnd=r}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,n,r,o){for(var a in n){var c=e[a],u=Array.isArray(c),d=u?"array":typeof c,p=!u&&Array.isArray(n[a]);if(!(d==="undefined"||d==="function")){if(p){var m=n[a];if(m.length===0)continue;for(var y=[c],x=0,v=m.length;x<v;x+=1){var w=this._handleRelativeValue(c,m[x]);if(isNaN(w)){p=!1,console.warn("Found invalid interpolation list. Skipping.");break}y.push(w)}p&&(n[a]=y)}if((d==="object"||u)&&c&&!p){t[a]=u?[]:{};var M=c;for(var S in M)t[a][S]=M[S];r[a]=u?[]:{};var m=n[a];if(!this._isDynamic){var C={};for(var S in m)C[S]=m[S];n[a]=m=C}this._setupProperties(M,t[a],m,r[a],o)}else(typeof t[a]=="undefined"||o)&&(t[a]=c),u||(t[a]*=1),p?r[a]=n[a].slice().reverse():r[a]=t[a]||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=wg()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this)},i.prototype.resume=function(e){return e===void 0&&(e=wg()),!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=ef.Linear.None),this._easingFunction=e,this},i.prototype.interpolation=function(e){return e===void 0&&(e=Mp.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 n=this,r;if(e===void 0&&(e=wg()),t===void 0&&(t=i.autoStartOnUpdate),this._isPaused)return!0;var o;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 a=e-this._startTime,c=this._duration+((r=this._repeatDelayTime)!==null&&r!==void 0?r:this._delayTime),u=this._duration+this._repeat*c,d=function(){if(n._duration===0||a>u)return 1;var w=Math.trunc(a/c),M=a-w*c,S=Math.min(M/n._duration,1);return S===0&&a===n._duration?1:S},p=d(),m=this._easingFunction(p);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,m),this._onUpdateCallback&&this._onUpdateCallback(this._object,p),this._duration===0||a>=this._duration)if(this._repeat>0){var y=Math.min(Math.trunc((a-this._duration)/c)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=y);for(o in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[o]=="string"&&(this._valuesStartRepeat[o]=this._valuesStartRepeat[o]+parseFloat(this._valuesEnd[o])),this._yoyo&&this._swapEndStartRepeatValues(o),this._valuesStart[o]=this._valuesStartRepeat[o];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=c*y,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var x=0,v=this._chainedTweens.length;x<v;x++)this._chainedTweens[x].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},i.prototype._updateProperties=function(e,t,n,r){for(var o in n)if(t[o]!==void 0){var a=t[o]||0,c=n[o],u=Array.isArray(e[o]),d=Array.isArray(c),p=!u&&d;p?e[o]=this._interpolationFunction(c,r):typeof c=="object"&&c?this._updateProperties(e[o],a,c,r):(c=this._handleRelativeValue(a,c),typeof c=="number"&&(e[o]=a+(c-a)*r))}},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],n=this._valuesEnd[e];typeof n=="string"?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(n):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},i.autoStartOnUpdate=!1,i}(),aX="25.0.0",lX=B1.nextId,Gc=O1,cX=Gc.getAll.bind(Gc),uX=Gc.removeAll.bind(Gc),hX=Gc.add.bind(Gc),dX=Gc.remove.bind(Gc),fX=Gc.update.bind(Gc),nQ={Easing:ef,Group:F1,Interpolation:Mp,now:wg,Sequence:B1,nextId:lX,Tween:U1,VERSION:aX,getAll:cX,removeAll:uX,add:hX,remove:dX,update:fX};function pX(){}function U3(i){return i==null?pX:function(){return this.querySelector(i)}}function mX(i){typeof i!="function"&&(i=U3(i));for(var e=this._groups,t=e.length,n=new Array(t),r=0;r<t;++r)for(var o=e[r],a=o.length,c=n[r]=new Array(a),u,d,p=0;p<a;++p)(u=o[p])&&(d=i.call(u,u.__data__,p,o))&&("__data__"in u&&(d.__data__=u.__data__),c[p]=d);return new Ma(n,this._parents)}function gX(i){return i==null?[]:Array.isArray(i)?i:Array.from(i)}function yX(){return[]}function _X(i){return i==null?yX:function(){return this.querySelectorAll(i)}}function xX(i){return function(){return gX(i.apply(this,arguments))}}function vX(i){typeof i=="function"?i=xX(i):i=_X(i);for(var e=this._groups,t=e.length,n=[],r=[],o=0;o<t;++o)for(var a=e[o],c=a.length,u,d=0;d<c;++d)(u=a[d])&&(n.push(i.call(u,u.__data__,d,a)),r.push(u));return new Ma(n,r)}function bX(i){return function(){return this.matches(i)}}function k3(i){return function(e){return e.matches(i)}}var SX=Array.prototype.find;function MX(i){return function(){return SX.call(this.children,i)}}function TX(){return this.firstElementChild}function wX(i){return this.select(i==null?TX:MX(typeof i=="function"?i:k3(i)))}var AX=Array.prototype.filter;function EX(){return Array.from(this.children)}function CX(i){return function(){return AX.call(this.children,i)}}function RX(i){return this.selectAll(i==null?EX:CX(typeof i=="function"?i:k3(i)))}function NX(i){typeof i!="function"&&(i=bX(i));for(var e=this._groups,t=e.length,n=new Array(t),r=0;r<t;++r)for(var o=e[r],a=o.length,c=n[r]=[],u,d=0;d<a;++d)(u=o[d])&&i.call(u,u.__data__,d,o)&&c.push(u);return new Ma(n,this._parents)}function z3(i){return new Array(i.length)}function PX(){return new Ma(this._enter||this._groups.map(z3),this._parents)}function Lb(i,e){this.ownerDocument=i.ownerDocument,this.namespaceURI=i.namespaceURI,this._next=null,this._parent=i,this.__data__=e}Lb.prototype={constructor:Lb,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 IX(i){return function(){return i}}function LX(i,e,t,n,r,o){for(var a=0,c,u=e.length,d=o.length;a<d;++a)(c=e[a])?(c.__data__=o[a],n[a]=c):t[a]=new Lb(i,o[a]);for(;a<u;++a)(c=e[a])&&(r[a]=c)}function DX(i,e,t,n,r,o,a){var c,u,d=new Map,p=e.length,m=o.length,y=new Array(p),x;for(c=0;c<p;++c)(u=e[c])&&(y[c]=x=a.call(u,u.__data__,c,e)+"",d.has(x)?r[c]=u:d.set(x,u));for(c=0;c<m;++c)x=a.call(i,o[c],c,o)+"",(u=d.get(x))?(n[c]=u,u.__data__=o[c],d.delete(x)):t[c]=new Lb(i,o[c]);for(c=0;c<p;++c)(u=e[c])&&d.get(y[c])===u&&(r[c]=u)}function FX(i){return i.__data__}function BX(i,e){if(!arguments.length)return Array.from(this,FX);var t=e?DX:LX,n=this._parents,r=this._groups;typeof i!="function"&&(i=IX(i));for(var o=r.length,a=new Array(o),c=new Array(o),u=new Array(o),d=0;d<o;++d){var p=n[d],m=r[d],y=m.length,x=OX(i.call(p,p&&p.__data__,d,n)),v=x.length,w=c[d]=new Array(v),M=a[d]=new Array(v),S=u[d]=new Array(y);t(p,m,w,M,S,x,e);for(var C=0,N=0,I,U;C<v;++C)if(I=w[C]){for(C>=N&&(N=C+1);!(U=M[N])&&++N<v;);I._next=U||null}}return a=new Ma(a,n),a._enter=c,a._exit=u,a}function OX(i){return typeof i=="object"&&"length"in i?i:Array.from(i)}function UX(){return new Ma(this._exit||this._groups.map(z3),this._parents)}function kX(i,e,t){var n=this.enter(),r=this,o=this.exit();return typeof i=="function"?(n=i(n),n&&(n=n.selection())):n=n.append(i+""),e!=null&&(r=e(r),r&&(r=r.selection())),t==null?o.remove():t(o),n&&r?n.merge(r).order():r}function zX(i){for(var e=i.selection?i.selection():i,t=this._groups,n=e._groups,r=t.length,o=n.length,a=Math.min(r,o),c=new Array(r),u=0;u<a;++u)for(var d=t[u],p=n[u],m=d.length,y=c[u]=new Array(m),x,v=0;v<m;++v)(x=d[v]||p[v])&&(y[v]=x);for(;u<r;++u)c[u]=t[u];return new Ma(c,this._parents)}function VX(){for(var i=this._groups,e=-1,t=i.length;++e<t;)for(var n=i[e],r=n.length-1,o=n[r],a;--r>=0;)(a=n[r])&&(o&&a.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(a,o),o=a);return this}function GX(i){i||(i=WX);function e(m,y){return m&&y?i(m.__data__,y.__data__):!m-!y}for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o){for(var a=t[o],c=a.length,u=r[o]=new Array(c),d,p=0;p<c;++p)(d=a[p])&&(u[p]=d);u.sort(e)}return new Ma(r,this._parents).order()}function WX(i,e){return i<e?-1:i>e?1:i>=e?0:NaN}function HX(){var i=arguments[0];return arguments[0]=this,i.apply(null,arguments),this}function $X(){return Array.from(this)}function qX(){for(var i=this._groups,e=0,t=i.length;e<t;++e)for(var n=i[e],r=0,o=n.length;r<o;++r){var a=n[r];if(a)return a}return null}function XX(){let i=0;for(const e of this)++i;return i}function jX(){return!this.node()}function YX(i){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,a=r.length,c;o<a;++o)(c=r[o])&&i.call(c,c.__data__,o,r);return this}var k1="http://www.w3.org/1999/xhtml",V3={svg:"http://www.w3.org/2000/svg",xhtml:k1,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function G3(i){var e=i+="",t=e.indexOf(":");return t>=0&&(e=i.slice(0,t))!=="xmlns"&&(i=i.slice(t+1)),V3.hasOwnProperty(e)?{space:V3[e],local:i}:i}function ZX(i){return function(){this.removeAttribute(i)}}function KX(i){return function(){this.removeAttributeNS(i.space,i.local)}}function JX(i,e){return function(){this.setAttribute(i,e)}}function QX(i,e){return function(){this.setAttributeNS(i.space,i.local,e)}}function ej(i,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(i):this.setAttribute(i,t)}}function tj(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 nj(i,e){var t=G3(i);if(arguments.length<2){var n=this.node();return t.local?n.getAttributeNS(t.space,t.local):n.getAttribute(t)}return this.each((e==null?t.local?KX:ZX:typeof e=="function"?t.local?tj:ej:t.local?QX:JX)(t,e))}function W3(i){return i.ownerDocument&&i.ownerDocument.defaultView||i.document&&i||i.defaultView}function ij(i){return function(){this.style.removeProperty(i)}}function sj(i,e,t){return function(){this.style.setProperty(i,e,t)}}function rj(i,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(i):this.style.setProperty(i,n,t)}}function oj(i,e,t){return arguments.length>1?this.each((e==null?ij:typeof e=="function"?rj:sj)(i,e,t==null?"":t)):aj(this.node(),i)}function aj(i,e){return i.style.getPropertyValue(e)||W3(i).getComputedStyle(i,null).getPropertyValue(e)}function lj(i){return function(){delete this[i]}}function cj(i,e){return function(){this[i]=e}}function uj(i,e){return function(){var t=e.apply(this,arguments);t==null?delete this[i]:this[i]=t}}function hj(i,e){return arguments.length>1?this.each((e==null?lj:typeof e=="function"?uj:cj)(i,e)):this.node()[i]}function H3(i){return i.trim().split(/^|\s+/)}function z1(i){return i.classList||new $3(i)}function $3(i){this._node=i,this._names=H3(i.getAttribute("class")||"")}$3.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 q3(i,e){for(var t=z1(i),n=-1,r=e.length;++n<r;)t.add(e[n])}function X3(i,e){for(var t=z1(i),n=-1,r=e.length;++n<r;)t.remove(e[n])}function dj(i){return function(){q3(this,i)}}function fj(i){return function(){X3(this,i)}}function pj(i,e){return function(){(e.apply(this,arguments)?q3:X3)(this,i)}}function mj(i,e){var t=H3(i+"");if(arguments.length<2){for(var n=z1(this.node()),r=-1,o=t.length;++r<o;)if(!n.contains(t[r]))return!1;return!0}return this.each((typeof e=="function"?pj:e?dj:fj)(t,e))}function gj(){this.textContent=""}function yj(i){return function(){this.textContent=i}}function _j(i){return function(){var e=i.apply(this,arguments);this.textContent=e==null?"":e}}function xj(i){return arguments.length?this.each(i==null?gj:(typeof i=="function"?_j:yj)(i)):this.node().textContent}function vj(){this.innerHTML=""}function bj(i){return function(){this.innerHTML=i}}function Sj(i){return function(){var e=i.apply(this,arguments);this.innerHTML=e==null?"":e}}function Mj(i){return arguments.length?this.each(i==null?vj:(typeof i=="function"?Sj:bj)(i)):this.node().innerHTML}function Tj(){this.nextSibling&&this.parentNode.appendChild(this)}function wj(){return this.each(Tj)}function Aj(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ej(){return this.each(Aj)}function Cj(i){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===k1&&e.documentElement.namespaceURI===k1?e.createElement(i):e.createElementNS(t,i)}}function Rj(i){return function(){return this.ownerDocument.createElementNS(i.space,i.local)}}function j3(i){var e=G3(i);return(e.local?Rj:Cj)(e)}function Nj(i){var e=typeof i=="function"?i:j3(i);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function Pj(){return null}function Ij(i,e){var t=typeof i=="function"?i:j3(i),n=e==null?Pj:typeof e=="function"?e:U3(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})}function Lj(){var i=this.parentNode;i&&i.removeChild(this)}function Dj(){return this.each(Lj)}function Fj(){var i=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(i,this.nextSibling):i}function Bj(){var i=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(i,this.nextSibling):i}function Oj(i){return this.select(i?Bj:Fj)}function Uj(i){return arguments.length?this.property("__data__",i):this.node().__data__}function kj(i){return function(e){i.call(this,e,this.__data__)}}function zj(i){return i.trim().split(/^|\s+/).map(function(e){var t="",n=e.indexOf(".");return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function Vj(i){return function(){var e=this.__on;if(e){for(var t=0,n=-1,r=e.length,o;t<r;++t)o=e[t],(!i.type||o.type===i.type)&&o.name===i.name?this.removeEventListener(o.type,o.listener,o.options):e[++n]=o;++n?e.length=n:delete this.__on}}}function Gj(i,e,t){return function(){var n=this.__on,r,o=kj(e);if(n){for(var a=0,c=n.length;a<c;++a)if((r=n[a]).type===i.type&&r.name===i.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=o,r.options=t),r.value=e;return}}this.addEventListener(i.type,o,t),r={type:i.type,name:i.name,value:e,listener:o,options:t},n?n.push(r):this.__on=[r]}}function Wj(i,e,t){var n=zj(i+""),r,o=n.length,a;if(arguments.length<2){var c=this.node().__on;if(c){for(var u=0,d=c.length,p;u<d;++u)for(r=0,p=c[u];r<o;++r)if((a=n[r]).type===p.type&&a.name===p.name)return p.value}return}for(c=e?Gj:Vj,r=0;r<o;++r)this.each(c(n[r],e,t));return this}function Y3(i,e,t){var n=W3(i),r=n.CustomEvent;typeof r=="function"?r=new r(e,t):(r=n.document.createEvent("Event"),t?(r.initEvent(e,t.bubbles,t.cancelable),r.detail=t.detail):r.initEvent(e,!1,!1)),i.dispatchEvent(r)}function Hj(i,e){return function(){return Y3(this,i,e)}}function $j(i,e){return function(){return Y3(this,i,e.apply(this,arguments))}}function qj(i,e){return this.each((typeof e=="function"?$j:Hj)(i,e))}function*Xj(){for(var i=this._groups,e=0,t=i.length;e<t;++e)for(var n=i[e],r=0,o=n.length,a;r<o;++r)(a=n[r])&&(yield a)}var Z3=[null];function Ma(i,e){this._groups=i,this._parents=e}function jj(){return new Ma([[document.documentElement]],Z3)}function Yj(){return this}Ma.prototype=jj.prototype={constructor:Ma,select:mX,selectAll:vX,selectChild:wX,selectChildren:RX,filter:NX,data:BX,enter:PX,exit:UX,join:kX,merge:zX,selection:Yj,order:VX,sort:GX,call:HX,nodes:$X,node:qX,size:XX,empty:jX,each:YX,attr:nj,style:oj,property:hj,classed:mj,text:xj,html:Mj,raise:wj,lower:Ej,append:Nj,insert:Ij,remove:Dj,clone:Oj,datum:Uj,on:Wj,dispatch:qj,[Symbol.iterator]:Xj};var iQ=null;function Zj(i){return typeof i=="string"?new Ma([[document.querySelector(i)]],[document.documentElement]):new Ma([[i]],Z3)}function Kj(i){let e;for(;e=i.sourceEvent;)i=e;return i}function Jj(i,e){if(i=Kj(i),e===void 0&&(e=i.currentTarget),e){var t=e.ownerSVGElement||e;if(t.createSVGPoint){var n=t.createSVGPoint();return n.x=i.clientX,n.y=i.clientY,n=n.matrixTransform(e.getScreenCTM().inverse()),[n.x,n.y]}if(e.getBoundingClientRect){var r=e.getBoundingClientRect();return[i.clientX-r.left-e.clientLeft,i.clientY-r.top-e.clientTop]}}return[i.pageX,i.pageY]}var e_,Ms,K3,J3,Tp,Q3,eL,tL,nL,V1,G1,W1,iL,t_={},sL=[],Qj=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,n_=Array.isArray;function Wc(i,e){for(var t in e)i[t]=e[t];return i}function H1(i){i&&i.parentNode&&i.parentNode.removeChild(i)}function eY(i,e,t){var n,r,o,a={};for(o in e)o=="key"?n=e[o]:o=="ref"?r=e[o]:a[o]=e[o];if(arguments.length>2&&(a.children=arguments.length>3?e_.call(arguments,2):t),typeof i=="function"&&i.defaultProps!=null)for(o in i.defaultProps)a[o]===void 0&&(a[o]=i.defaultProps[o]);return i_(i,a,n,r,null)}function i_(i,e,t,n,r){var o={type:i,props:e,key:t,ref:n,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:r==null?++K3:r,__i:-1,__u:0};return r==null&&Ms.vnode!=null&&Ms.vnode(o),o}function sQ(){return{current:null}}function Db(i){return i.children}function Fb(i,e){this.props=i,this.context=e}function Ag(i,e){if(e==null)return i.__?Ag(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"?Ag(i):null}function rL(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 rL(i)}}function $1(i){(!i.__d&&(i.__d=!0)&&Tp.push(i)&&!Bb.__r++||Q3!=Ms.debounceRendering)&&((Q3=Ms.debounceRendering)||eL)(Bb)}function Bb(){for(var i,e,t,n,r,o,a,c=1;Tp.length;)Tp.length>c&&Tp.sort(tL),i=Tp.shift(),c=Tp.length,i.__d&&(t=void 0,n=void 0,r=(n=(e=i).__v).__e,o=[],a=[],e.__P&&((t=Wc({},n)).__v=n.__v+1,Ms.vnode&&Ms.vnode(t),q1(e.__P,t,n,e.__n,e.__P.namespaceURI,32&n.__u?[r]:null,o,r==null?Ag(n):r,!!(32&n.__u),a),t.__v=n.__v,t.__.__k[t.__i]=t,uL(o,t,a),n.__e=n.__=null,t.__e!=r&&rL(t)));Bb.__r=0}function oL(i,e,t,n,r,o,a,c,u,d,p){var m,y,x,v,w,M,S,C=n&&n.__k||sL,N=e.length;for(u=tY(t,e,C,u,N),m=0;m<N;m++)(x=t.__k[m])!=null&&(y=x.__i==-1?t_:C[x.__i]||t_,x.__i=m,M=q1(i,x,y,r,o,a,c,u,d,p),v=x.__e,x.ref&&y.ref!=x.ref&&(y.ref&&j1(y.ref,null,x),p.push(x.ref,x.__c||v,x)),w==null&&v!=null&&(w=v),(S=!!(4&x.__u))||y.__k===x.__k?u=aL(x,u,i,S):typeof x.type=="function"&&M!==void 0?u=M:v&&(u=v.nextSibling),x.__u&=-7);return t.__e=w,u}function tY(i,e,t,n,r){var o,a,c,u,d,p=t.length,m=p,y=0;for(i.__k=new Array(r),o=0;o<r;o++)(a=e[o])!=null&&typeof a!="boolean"&&typeof a!="function"?(typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?a=i.__k[o]=i_(null,a,null,null,null):n_(a)?a=i.__k[o]=i_(Db,{children:a},null,null,null):a.constructor==null&&a.__b>0?a=i.__k[o]=i_(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):i.__k[o]=a,u=o+y,a.__=i,a.__b=i.__b+1,(d=a.__i=iY(a,t,u,m))!=-1&&(m--,(c=t[d])&&(c.__u|=2)),c==null||c.__v==null?(d==-1&&(r>p?y--:r<p&&y++),typeof a.type!="function"&&(a.__u|=4)):d!=u&&(d==u-1?y--:d==u+1?y++:(d>u?y--:y++,a.__u|=4))):i.__k[o]=null;if(m)for(o=0;o<p;o++)(c=t[o])!=null&&!(2&c.__u)&&(c.__e==n&&(n=Ag(c)),dL(c,c));return n}function aL(i,e,t,n){var r,o;if(typeof i.type=="function"){for(r=i.__k,o=0;r&&o<r.length;o++)r[o]&&(r[o].__=i,e=aL(r[o],e,t,n));return e}i.__e!=e&&(n&&(e&&i.type&&!e.parentNode&&(e=Ag(i)),t.insertBefore(i.__e,e||null)),e=i.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function nY(i,e){return e=e||[],i==null||typeof i=="boolean"||(n_(i)?i.some(function(t){nY(t,e)}):e.push(i)),e}function iY(i,e,t,n){var r,o,a,c=i.key,u=i.type,d=e[t],p=d!=null&&(2&d.__u)==0;if(d===null&&c==null||p&&c==d.key&&u==d.type)return t;if(n>(p?1:0)){for(r=t-1,o=t+1;r>=0||o<e.length;)if((d=e[a=r>=0?r--:o++])!=null&&!(2&d.__u)&&c==d.key&&u==d.type)return a}return-1}function lL(i,e,t){e[0]=="-"?i.setProperty(e,t==null?"":t):i[e]=t==null?"":typeof t!="number"||Qj.test(e)?t:t+"px"}function Ob(i,e,t,n,r){var o,a;e:if(e=="style")if(typeof t=="string")i.style.cssText=t;else{if(typeof n=="string"&&(i.style.cssText=n=""),n)for(e in n)t&&e in t||lL(i.style,e,"");if(t)for(e in t)n&&t[e]==n[e]||lL(i.style,e,t[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(nL,"$1")),a=e.toLowerCase(),e=a in i||e=="onFocusOut"||e=="onFocusIn"?a.slice(2):e.slice(2),i.l||(i.l={}),i.l[e+o]=t,t?n?t.u=n.u:(t.u=V1,i.addEventListener(e,o?W1:G1,o)):i.removeEventListener(e,o?W1:G1,o);else{if(r=="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(c){}typeof t=="function"||(t==null||t===!1&&e[4]!="-"?i.removeAttribute(e):i.setAttribute(e,e=="popover"&&t==1?"":t))}}function cL(i){return function(e){if(this.l){var t=this.l[e.type+i];if(e.t==null)e.t=V1++;else if(e.t<t.u)return;return t(Ms.event?Ms.event(e):e)}}}function q1(i,e,t,n,r,o,a,c,u,d){var p,m,y,x,v,w,M,S,C,N,I,U,F,k,G,B,z,Q=e.type;if(e.constructor!=null)return null;128&t.__u&&(u=!!(32&t.__u),o=[c=e.__e=t.__e]),(p=Ms.__b)&&p(e);e:if(typeof Q=="function")try{if(S=e.props,C="prototype"in Q&&Q.prototype.render,N=(p=Q.contextType)&&n[p.__c],I=p?N?N.props.value:p.__:n,t.__c?M=(m=e.__c=t.__c).__=m.__E:(C?e.__c=m=new Q(S,I):(e.__c=m=new Fb(S,I),m.constructor=Q,m.render=rY),N&&N.sub(m),m.state||(m.state={}),m.__n=n,y=m.__d=!0,m.__h=[],m._sb=[]),C&&m.__s==null&&(m.__s=m.state),C&&Q.getDerivedStateFromProps!=null&&(m.__s==m.state&&(m.__s=Wc({},m.__s)),Wc(m.__s,Q.getDerivedStateFromProps(S,m.__s))),x=m.props,v=m.state,m.__v=e,y)C&&Q.getDerivedStateFromProps==null&&m.componentWillMount!=null&&m.componentWillMount(),C&&m.componentDidMount!=null&&m.__h.push(m.componentDidMount);else{if(C&&Q.getDerivedStateFromProps==null&&S!==x&&m.componentWillReceiveProps!=null&&m.componentWillReceiveProps(S,I),e.__v==t.__v||!m.__e&&m.shouldComponentUpdate!=null&&m.shouldComponentUpdate(S,m.__s,I)===!1){for(e.__v!=t.__v&&(m.props=S,m.state=m.__s,m.__d=!1),e.__e=t.__e,e.__k=t.__k,e.__k.some(function(ye){ye&&(ye.__=e)}),U=0;U<m._sb.length;U++)m.__h.push(m._sb[U]);m._sb=[],m.__h.length&&a.push(m);break e}m.componentWillUpdate!=null&&m.componentWillUpdate(S,m.__s,I),C&&m.componentDidUpdate!=null&&m.__h.push(function(){m.componentDidUpdate(x,v,w)})}if(m.context=I,m.props=S,m.__P=i,m.__e=!1,F=Ms.__r,k=0,C){for(m.state=m.__s,m.__d=!1,F&&F(e),p=m.render(m.props,m.state,m.context),G=0;G<m._sb.length;G++)m.__h.push(m._sb[G]);m._sb=[]}else do m.__d=!1,F&&F(e),p=m.render(m.props,m.state,m.context),m.state=m.__s;while(m.__d&&++k<25);m.state=m.__s,m.getChildContext!=null&&(n=Wc(Wc({},n),m.getChildContext())),C&&!y&&m.getSnapshotBeforeUpdate!=null&&(w=m.getSnapshotBeforeUpdate(x,v)),B=p,p!=null&&p.type===Db&&p.key==null&&(B=hL(p.props.children)),c=oL(i,n_(B)?B:[B],e,t,n,r,o,a,c,u,d),m.base=e.__e,e.__u&=-161,m.__h.length&&a.push(m),M&&(m.__E=m.__=null)}catch(ye){if(e.__v=null,u||o!=null)if(ye.then){for(e.__u|=u?160:128;c&&c.nodeType==8&&c.nextSibling;)c=c.nextSibling;o[o.indexOf(c)]=null,e.__e=c}else{for(z=o.length;z--;)H1(o[z]);X1(e)}else e.__e=t.__e,e.__k=t.__k,ye.then||X1(e);Ms.__e(ye,e,t)}else o==null&&e.__v==t.__v?(e.__k=t.__k,e.__e=t.__e):c=e.__e=sY(t.__e,e,t,n,r,o,a,u,d);return(p=Ms.diffed)&&p(e),128&e.__u?void 0:c}function X1(i){i&&i.__c&&(i.__c.__e=!0),i&&i.__k&&i.__k.forEach(X1)}function uL(i,e,t){for(var n=0;n<t.length;n++)j1(t[n],t[++n],t[++n]);Ms.__c&&Ms.__c(e,i),i.some(function(r){try{i=r.__h,r.__h=[],i.some(function(o){o.call(r)})}catch(o){Ms.__e(o,r.__v)}})}function hL(i){return typeof i!="object"||i==null||i.__b&&i.__b>0?i:n_(i)?i.map(hL):Wc({},i)}function sY(i,e,t,n,r,o,a,c,u){var d,p,m,y,x,v,w,M=t.props||t_,S=e.props,C=e.type;if(C=="svg"?r="http://www.w3.org/2000/svg":C=="math"?r="http://www.w3.org/1998/Math/MathML":r||(r="http://www.w3.org/1999/xhtml"),o!=null){for(d=0;d<o.length;d++)if((x=o[d])&&"setAttribute"in x==!!C&&(C?x.localName==C:x.nodeType==3)){i=x,o[d]=null;break}}if(i==null){if(C==null)return document.createTextNode(S);i=document.createElementNS(r,C,S.is&&S),c&&(Ms.__m&&Ms.__m(e,o),c=!1),o=null}if(C==null)M===S||c&&i.data==S||(i.data=S);else{if(o=o&&e_.call(i.childNodes),!c&&o!=null)for(M={},d=0;d<i.attributes.length;d++)M[(x=i.attributes[d]).name]=x.value;for(d in M)if(x=M[d],d!="children"){if(d=="dangerouslySetInnerHTML")m=x;else if(!(d in S)){if(d=="value"&&"defaultValue"in S||d=="checked"&&"defaultChecked"in S)continue;Ob(i,d,null,x,r)}}for(d in S)x=S[d],d=="children"?y=x:d=="dangerouslySetInnerHTML"?p=x:d=="value"?v=x:d=="checked"?w=x:c&&typeof x!="function"||M[d]===x||Ob(i,d,x,M[d],r);if(p)c||m&&(p.__html==m.__html||p.__html==i.innerHTML)||(i.innerHTML=p.__html),e.__k=[];else if(m&&(i.innerHTML=""),oL(e.type=="template"?i.content:i,n_(y)?y:[y],e,t,n,C=="foreignObject"?"http://www.w3.org/1999/xhtml":r,o,a,o?o[0]:t.__k&&Ag(t,0),c,u),o!=null)for(d=o.length;d--;)H1(o[d]);c||(d="value",C=="progress"&&v==null?i.removeAttribute("value"):v!=null&&(v!==i[d]||C=="progress"&&!v||C=="option"&&v!=M[d])&&Ob(i,d,v,M[d],r),d="checked",w!=null&&w!=i[d]&&Ob(i,d,w,M[d],r))}return i}function j1(i,e,t){try{if(typeof i=="function"){var n=typeof i.__u=="function";n&&i.__u(),n&&e==null||(i.__u=i(e))}else i.current=e}catch(r){Ms.__e(r,t)}}function dL(i,e,t){var n,r;if(Ms.unmount&&Ms.unmount(i),(n=i.ref)&&(n.current&&n.current!=i.__e||j1(n,null,e)),(n=i.__c)!=null){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(o){Ms.__e(o,e)}n.base=n.__P=null}if(n=i.__k)for(r=0;r<n.length;r++)n[r]&&dL(n[r],e,t||typeof i.type!="function");t||H1(i.__e),i.__c=i.__=i.__e=void 0}function rY(i,e,t){return this.constructor(i,t)}function fL(i,e,t){var n,r,o,a;e==document&&(e=document.documentElement),Ms.__&&Ms.__(i,e),r=(n=typeof t=="function")?null:t&&t.__k||e.__k,o=[],a=[],q1(e,i=(!n&&t||e).__k=eY(Db,null,[i]),r||t_,t_,e.namespaceURI,!n&&t?[t]:r?null:e.firstChild?e_.call(e.childNodes):null,o,!n&&t?t:r?r.__e:e.firstChild,n,a),uL(o,i,a)}function oY(i,e){fL(i,e,oY)}function pL(i,e,t){var n,r,o,a,c=Wc({},i.props);for(o in i.type&&i.type.defaultProps&&(a=i.type.defaultProps),e)o=="key"?n=e[o]:o=="ref"?r=e[o]:c[o]=e[o]===void 0&&a!=null?a[o]:e[o];return arguments.length>2&&(c.children=arguments.length>3?e_.call(arguments,2):t),i_(i.type,c,n||i.key,r||i.ref,null)}function rQ(i){function e(t){var n,r;return this.getChildContext||(n=new Set,(r={})[e.__c]=this,this.getChildContext=function(){return r},this.componentWillUnmount=function(){n=null},this.shouldComponentUpdate=function(o){this.props.value!=o.value&&n.forEach(function(a){a.__e=!0,$1(a)})},this.sub=function(o){n.add(o);var a=o.componentWillUnmount;o.componentWillUnmount=function(){n&&n.delete(o),a&&a.call(o)}}),t.children}return e.__c="__cC"+iL++,e.__=i,e.Provider=e.__l=(e.Consumer=function(t,n){return t.children(n)}).contextType=e,e}e_=sL.slice,Ms={__e:function(i,e,t,n){for(var r,o,a;e=e.__;)if((r=e.__c)&&!r.__)try{if((o=r.constructor)&&o.getDerivedStateFromError!=null&&(r.setState(o.getDerivedStateFromError(i)),a=r.__d),r.componentDidCatch!=null&&(r.componentDidCatch(i,n||{}),a=r.__d),a)return r.__E=r}catch(c){i=c}throw i}},K3=0,J3=function(i){return i!=null&&i.constructor==null},Fb.prototype.setState=function(i,e){var t;t=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Wc({},this.state),typeof i=="function"&&(i=i(Wc({},t),this.props)),i&&Wc(t,i),i!=null&&this.__v&&(e&&this._sb.push(e),$1(this))},Fb.prototype.forceUpdate=function(i){this.__v&&(this.__e=!0,i&&this.__h.push(i),$1(this))},Fb.prototype.render=Db,Tp=[],eL=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,tL=function(i,e){return i.__v.__b-e.__v.__b},Bb.__r=0,nL=/(PointerCapture)$|Capture$/i,V1=0,G1=cL(!1),W1=cL(!0),iL=0;function mL(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t<e;t++)n[t]=i[t];return n}function aY(i){if(Array.isArray(i))return i}function lY(i,e,t){return(e=pY(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function cY(i,e){var t=i==null?null:typeof Symbol!="undefined"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,r,o,a,c=[],u=!0,d=!1;try{if(o=(t=t.call(i)).next,e!==0)for(;!(u=(n=o.call(t)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(p){d=!0,r=p}finally{try{if(!u&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(d)throw r}}return c}}function uY(){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 gL(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function hY(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?gL(Object(t),!0).forEach(function(n){lY(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):gL(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function dY(i,e){return aY(i)||cY(i,e)||mY(i,e)||uY()}function fY(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function pY(i){var e=fY(i,"string");return typeof e=="symbol"?e:e+""}function Ub(i){"@babel/helpers - typeof";return Ub=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},Ub(i)}function mY(i,e){if(i){if(typeof i=="string")return mL(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)?mL(i,e):void 0}}var Y1=function(e){if(Ub(e)!=="object")return e;var t=pL(e);if(t.props){var n;t.props=hY({},t.props),t!=null&&(n=t.props)!==null&&n!==void 0&&n.children&&(t.props.children=Array.isArray(t.props.children)?t.props.children.map(Y1):Y1(t.props.children))}return t},gY=function(e){return J3(pL(e))},yY=function(e,t){delete t.__k,fL(Y1(e),t)};function _Y(i,e){e===void 0&&(e={});var t=e.insertAt;if(typeof document!="undefined"){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i))}}var xY=`.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;
}
`;_Y(xY);var vY=Gx({props:{content:{default:!1},offsetX:{triggerUpdate:!1},offsetY:{triggerUpdate:!1}},init:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.style,o=r===void 0?{}:r,a=!!e&&Ub(e)==="object"&&!!e.node&&typeof e.node=="function",c=Zj(a?e.node():e);c.style("position")==="static"&&c.style("position","relative"),t.tooltipEl=c.append("div").attr("class","float-tooltip-kap"),Object.entries(o).forEach(function(d){var p=dY(d,2),m=p[0],y=p[1];return t.tooltipEl.style(m,y)}),t.tooltipEl.style("left","-10000px").style("display","none");var u="tooltip-".concat(Math.round(Math.random()*1e12));t.mouseInside=!1,c.on("mousemove.".concat(u),function(d){t.mouseInside=!0;var p=Jj(d),m=c.node(),y=m.offsetWidth,x=m.offsetHeight,v=[t.offsetX===null||t.offsetX===void 0?"-".concat(p[0]/y*100,"%"):typeof t.offsetX=="number"?"calc(-50% + ".concat(t.offsetX,"px)"):t.offsetX,t.offsetY===null||t.offsetY===void 0?x>130&&x-p[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",p[0]+"px").style("top",p[1]+"px").style("transform","translate(".concat(v.join(","),")")),t.content&&t.tooltipEl.style("display","inline")}),c.on("mouseover.".concat(u),function(){t.mouseInside=!0,t.content&&t.tooltipEl.style("display","inline")}),c.on("mouseout.".concat(u),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):gY(e.content)?(e.tooltipEl.text(""),yY(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 bY(i,e){e===void 0&&(e={});var t=e.insertAt;if(typeof document!="undefined"){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i))}}var SY=`.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;
}`;bY(SY);function Z1(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t<e;t++)n[t]=i[t];return n}function MY(i){if(Array.isArray(i))return i}function TY(i){if(Array.isArray(i))return Z1(i)}function wY(i,e,t){return(e=IY(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function AY(i){if(typeof Symbol!="undefined"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function EY(i,e){var t=i==null?null:typeof Symbol!="undefined"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var n,r,o,a,c=[],u=!0,d=!1;try{if(o=(t=t.call(i)).next,e!==0)for(;!(u=(n=o.call(t)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(p){d=!0,r=p}finally{try{if(!u&&t.return!=null&&(a=t.return(),Object(a)!==a))return}finally{if(d)throw r}}return c}}function CY(){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 RY(){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 NY(i,e){return MY(i)||EY(i,e)||yL(i,e)||CY()}function wp(i){return TY(i)||AY(i)||yL(i)||RY()}function PY(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function IY(i){var e=PY(i,"string");return typeof e=="symbol"?e:e+""}function yL(i,e){if(i){if(typeof i=="string")return Z1(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)?Z1(i,e):void 0}}var Ts=window.THREE?window.THREE:{WebGLRenderer:Qk,Scene:Oa,PerspectiveCamera:Bs,Raycaster:XS,SRGBColorSpace:Pr,TextureLoader:RS,Vector2:ze,Vector3:H,Box3:ns,Color:It,Mesh:Ji,SphereGeometry:ku,MeshBasicMaterial:Or,BackSide:we,Clock:xl},_L=Gx({props:{width:{default:window.innerWidth,onChange:function(e,t,n){isNaN(e)&&(t.width=n)}},height:{default:window.innerHeight,onChange:function(e,t,n){isNaN(e)&&(t.height=n)}},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(a){return a.render(e.scene,e.camera)});var t=+new Date;if(e.enablePointerInteraction&&t-e.lastRaycasterCheck>=e.pointerRaycasterThrottleMs){e.lastRaycasterCheck=t;var n=null;if(e.hoverDuringDrag||!e.isPointerDragging){var r=this.intersectingObjects(e.pointerPos.x,e.pointerPos.y);e.hoverOrderComparator&&r.sort(function(a,c){return e.hoverOrderComparator(a.object,c.object)});var o=r.find(function(a){return e.hoverFilter(a.object)})||null;n=o?o.object:null,e.intersection=o||null}n!==e.hoverObj&&(e.onHover(n,e.hoverObj,e.intersection),e.tooltip.content(n&&pi(e.tooltipContent)(n,e.intersection)||null),e.hoverObj=n)}e.tweenGroup.update()}return this},getPointerPos:function(e){var t=e.pointerPos,n=t.x,r=t.y;return{x:n,y:r}},cameraPosition:function(e,t,n,r){var o=e.camera;if(t&&e.initialised){var a=t,c=n||{x:0,y:0,z:0};if(!r)p(a),m(c);else{var u=Object.assign({},o.position),d=y();e.tweenGroup.add(new U1(u).to(a,r).easing(ef.Quadratic.Out).onUpdate(p).start()),e.tweenGroup.add(new U1(d).to(c,r/3).easing(ef.Quadratic.Out).onUpdate(m).start())}return this}return Object.assign({},o.position,{lookAt:y()});function p(x){var v=x.x,w=x.y,M=x.z;v!==void 0&&(o.position.x=v),w!==void 0&&(o.position.y=w),M!==void 0&&(o.position.z=M)}function m(x){var v=new Ts.Vector3(x.x,x.y,x.z);e.controls.enabled&&e.controls.target?e.controls.target=v:o.lookAt(v)}function y(){return Object.assign(new Ts.Vector3(0,0,-1e3).applyQuaternion(o.quaternion).add(o.position))}},zoomToFit:function(e){for(var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:10,r=arguments.length,o=new Array(r>3?r-3:0),a=3;a<r;a++)o[a-3]=arguments[a];return this.fitToBbox(this.getBbox.apply(this,o),t,n)},fitToBbox:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:10,o=e.camera;if(t){var a=new Ts.Vector3(0,0,0),c=Math.max.apply(Math,wp(Object.entries(t).map(function(x){var v=NY(x,2),w=v[0],M=v[1];return Math.max.apply(Math,wp(M.map(function(S){return Math.abs(a[w]-S)})))})))*2,u=(1-r*2/e.height)*o.fov,d=c/Math.atan(u*Math.PI/180),p=d/o.aspect,m=Math.max(d,p);if(m>0){var y=a.clone().sub(o.position).normalize().multiplyScalar(-m);this.cameraPosition(y,a,n)}}return this},getBbox:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){return!0},n=new Ts.Box3(new Ts.Vector3(0,0,0),new Ts.Vector3(0,0,0)),r=e.objects.filter(t);return r.length?(r.forEach(function(o){return n.expandByObject(o)}),Object.assign.apply(Object,wp(["x","y","z"].map(function(o){return wY({},o,[n.min[o],n.max[o]])})))):null},getScreenCoords:function(e,t,n,r){var o=new Ts.Vector3(t,n,r);return o.project(this.camera()),{x:(o.x+1)*e.width/2,y:-(o.y-1)*e.height/2}},getSceneCoords:function(e,t,n){var r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,o=new Ts.Vector2(t/e.width*2-1,-(n/e.height)*2+1),a=new Ts.Raycaster;return a.setFromCamera(o,e.camera),Object.assign({},a.ray.at(r,new Ts.Vector3))},intersectingObjects:function(e,t,n){var r=new Ts.Vector2(t/e.width*2-1,-(n/e.height)*2+1),o=new Ts.Raycaster;return o.params.Line.threshold=e.lineHoverPrecision,o.params.Points.threshold=e.pointsHoverPrecision,o.setFromCamera(r,e.camera),o.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 Ts.Scene,camera:new Ts.PerspectiveCamera,clock:new Ts.Clock,tweenGroup:new F1,lastRaycasterCheck:0}},init:function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=n.controlType,o=r===void 0?"trackball":r,a=n.useWebGPU,c=a===void 0?!1:a,u=n.rendererConfig,d=u===void 0?{}:u,p=n.extraRenderers,m=p===void 0?[]:p,y=n.waitForLoadComplete,x=y===void 0?!0:y;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"}[o]||"",t.navInfo.style.display=t.showNavInfo?null:"none",t.tooltip=new vY(t.container),t.pointerPos=new Ts.Vector2,t.pointerPos.x=-2,t.pointerPos.y=-2,["pointermove","pointerdown"].forEach(function(v){return t.container.addEventListener(v,function(w){if(v==="pointerdown"&&(t.isPointerPressed=!0),!t.isPointerDragging&&w.type==="pointermove"&&(w.pressure>0||t.isPointerPressed)&&(w.pointerType==="mouse"||w.movementX===void 0||[w.movementX,w.movementY].some(function(C){return Math.abs(C)>1}))&&(t.isPointerDragging=!0),t.enablePointerInteraction){var M=S(t.container);t.pointerPos.x=w.pageX-M.left,t.pointerPos.y=w.pageY-M.top}function S(C){var N=C.getBoundingClientRect(),I=window.pageXOffset||document.documentElement.scrollLeft,U=window.pageYOffset||document.documentElement.scrollTop;return{top:N.top+U,left:N.left+I}}},{passive:!0})}),t.container.addEventListener("pointerup",function(v){t.isPointerPressed&&(t.isPointerPressed=!1,!(t.isPointerDragging&&(t.isPointerDragging=!1,!t.clickAfterDrag))&&requestAnimationFrame(function(){v.button===0&&t.onClick(t.hoverObj||null,v,t.intersection),v.button===2&&t.onRightClick&&t.onRightClick(t.hoverObj||null,v,t.intersection)}))},{passive:!0,capture:!0}),t.container.addEventListener("contextmenu",function(v){t.onRightClick&&v.preventDefault()}),t.renderer=new(c?U$:Ts.WebGLRenderer)(Object.assign({antialias:!0,alpha:!0},d)),t.renderer.setPixelRatio(Math.min(2,window.devicePixelRatio)),t.container.appendChild(t.renderer.domElement),t.extraRenderers=m,t.extraRenderers.forEach(function(v){v.domElement.style.position="absolute",v.domElement.style.top="0px",v.domElement.style.pointerEvents="none",t.container.appendChild(v.domElement)}),t.postProcessingComposer=new L7(t.renderer),t.postProcessingComposer.addPass(new D7(t.scene,t.camera)),t.controls=new{trackball:G$,orbit:s7,fly:_7}[o](t.camera,t.renderer.domElement),o==="fly"&&(t.controls.movementSpeed=300,t.controls.rollSpeed=Math.PI/6,t.controls.dragToLook=!0),(o==="trackball"||o==="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(wp(t.extraRenderers)).forEach(function(v){return v.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 Ts.Mesh),t.skysphere.visible=!1,t.loadComplete=t.scene.visible=!x,window.scene=t.scene},update:function(e,t){if(e.width&&e.height&&(t.hasOwnProperty("width")||t.hasOwnProperty("height"))){var n,r=e.width,o=e.height;e.container.style.width="".concat(r,"px"),e.container.style.height="".concat(o,"px"),[e.renderer,e.postProcessingComposer].concat(wp(e.extraRenderers)).forEach(function(x){return x.setSize(r,o)}),e.camera.aspect=r/o;var a=e.viewOffset.slice(0,2);a.some(function(x){return x})&&(n=e.camera).setViewOffset.apply(n,[r,o].concat(wp(a),[r,o])),e.camera.updateProjectionMatrix()}if(t.hasOwnProperty("viewOffset")){var c,u=e.width,d=e.height,p=e.viewOffset.slice(0,2);p.some(function(x){return x})?(c=e.camera).setViewOffset.apply(c,[u,d].concat(wp(p),[u,d])):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 Ts.SphereGeometry(e.skyRadius)),t.hasOwnProperty("backgroundColor")){var m=mh(e.backgroundColor).alpha;m===void 0&&(m=1),e.renderer.setClearColor(new Ts.Color(Xq(1,e.backgroundColor)),m)}t.hasOwnProperty("backgroundImageUrl")&&(e.backgroundImageUrl?new Ts.TextureLoader().load(e.backgroundImageUrl,function(x){x.colorSpace=Ts.SRGBColorSpace,e.skysphere.material=new Ts.MeshBasicMaterial({map:x,side:Ts.BackSide}),e.skysphere.visible=!0,e.onBackgroundImageLoaded&&setTimeout(e.onBackgroundImageLoaded),!e.loadComplete&&y()}):(e.skysphere.visible=!1,e.skysphere.material.map=null,!e.loadComplete&&y())),t.hasOwnProperty("showNavInfo")&&(e.navInfo.style.display=e.showNavInfo?null:"none"),t.hasOwnProperty("lights")&&((t.lights||[]).forEach(function(x){return e.scene.remove(x)}),e.lights.forEach(function(x){return e.scene.add(x)})),t.hasOwnProperty("objects")&&((t.objects||[]).forEach(function(x){return e.scene.remove(x)}),e.objects.forEach(function(x){return e.scene.add(x)}));function y(){e.loadComplete=e.scene.visible=!0}}});function LY(i,e){e===void 0&&(e={});var t=e.insertAt;if(typeof document!="undefined"){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css",t==="top"&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=i:r.appendChild(document.createTextNode(i))}}var DY=`.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;
}`;LY(DY);function K1(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,n=Array(e);t<e;t++)n[t]=i[t];return n}function FY(i){if(Array.isArray(i))return K1(i)}function s_(i,e,t){return(e=kY(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function BY(i){if(typeof Symbol!="undefined"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function OY(){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 xL(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function kb(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?xL(Object(t),!0).forEach(function(n){s_(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):xL(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function zb(i){return FY(i)||BY(i)||zY(i)||OY()}function UY(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function kY(i){var e=UY(i,"string");return typeof e=="symbol"?e:e+""}function zY(i,e){if(i){if(typeof i=="string")return K1(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)?K1(i,e):void 0}}function vL(i,e){var t=new e;return t._destructor&&t._destructor(),{linkProp:function(r){return{default:t[r](),onChange:function(a,c){c[i][r](a)},triggerUpdate:!1}},linkMethod:function(r){return function(o){for(var a=o[i],c=arguments.length,u=new Array(c>1?c-1:0),d=1;d<c;d++)u[d-1]=arguments[d];var p=a[r].apply(a,u);return p===a?this:p}}}}var J1=window.THREE?window.THREE:{AmbientLight:Im,DirectionalLight:Hf,REVISION:xe},VY=170,bL=vL("forceGraph",ME),GY=Object.assign.apply(Object,zb(["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 s_({},i,bL.linkProp(i))}))),WY=Object.assign.apply(Object,zb(["refresh","getGraphBbox","d3Force","d3ReheatSimulation","emitParticle"].map(function(i){return s_({},i,bL.linkMethod(i))}))),Vb=vL("renderObjs",_L),HY=Object.assign.apply(Object,zb(["width","height","backgroundColor","showNavInfo","enablePointerInteraction"].map(function(i){return s_({},i,Vb.linkProp(i))}))),$Y=Object.assign.apply(Object,zb(["lights","cameraPosition","postProcessingComposer"].map(function(i){return s_({},i,Vb.linkMethod(i))})).concat([{graph2ScreenCoords:Vb.linkMethod("getScreenCoords"),screen2GraphCoords:Vb.linkMethod("getSceneCoords")}])),qY=Gx({props:kb(kb({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 n=t.renderObjs.controls();n&&(n.enabled=e,e&&n.domElement&&n.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}},GY),HY),methods:kb(kb({zoomToFit:function(e,t,n){for(var r,o=arguments.length,a=new Array(o>3?o-3:0),c=3;c<o;c++)a[c-3]=arguments[c];return e.renderObjs.fitToBbox((r=e.forceGraph).getGraphBbox.apply(r,a),t,n),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:[]})}},WY),$Y),stateInit:function(e){var t=e.controlType,n=e.rendererConfig,r=e.extraRenderers,o=new ME;return{forceGraph:o,renderObjs:_L({controlType:t,rendererConfig:n,extraRenderers:r}).objects([o]).lights([new J1.AmbientLight(13421772,Math.PI),new J1.DirectionalLight(16777215,.6*Math.PI)])}},init:function(e,t){e.innerHTML="",e.appendChild(t.container=document.createElement("div")),t.container.style.position="relative";var n=document.createElement("div");t.container.appendChild(n),t.renderObjs(n);var r=t.renderObjs.camera(),o=t.renderObjs.renderer(),a=t.renderObjs.controls();a.enabled=!!t.enableNavigationControls,t.lastSetCameraZ=r.position.z;var c;t.container.appendChild(c=document.createElement("div")),c.className="graph-info-msg",c.textContent="",t.forceGraph.onLoading(function(){c.textContent="Loading..."}).onFinishLoading(function(){c.textContent=""}).onUpdate(function(){t.graphData=t.forceGraph.graphData(),r.position.x===0&&r.position.y===0&&r.position.z===t.lastSetCameraZ&&t.graphData.nodes.length&&(r.lookAt(t.forceGraph.position),t.lastSetCameraZ=r.position.z=Math.cbrt(t.graphData.nodes.length)*VY)}).onFinishUpdate(function(){if(t._dragControls){var u=t.graphData.nodes.find(function(p){return p.__initialFixedPos&&!p.__disposeControlsAfterDrag});u?u.__disposeControlsAfterDrag=!0:t._dragControls.dispose(),t._dragControls=void 0}if(t.enableNodeDrag&&t.enablePointerInteraction&&t.forceEngine==="d3"){var d=t._dragControls=new se(t.graphData.nodes.map(function(p){return p.__threeObj}).filter(function(p){return p}),r,o.domElement);d.addEventListener("dragstart",function(p){var m=gh(p.object);if(m){a.enabled=!1,p.object.__initialPos=p.object.position.clone(),p.object.__prevPos=p.object.position.clone();var y=m.__data;!y.__initialFixedPos&&(y.__initialFixedPos={fx:y.fx,fy:y.fy,fz:y.fz}),!y.__initialPos&&(y.__initialPos={x:y.x,y:y.y,z:y.z}),["x","y","z"].forEach(function(x){return y["f".concat(x)]=y[x]}),o.domElement.classList.add("grabbable")}}),d.addEventListener("drag",function(p){var m=gh(p.object);if(m){if(!p.object.hasOwnProperty("__graphObjType")){var y=p.object.__initialPos,x=p.object.__prevPos,v=p.object.position;m.position.add(v.clone().sub(x)),x.copy(v),v.copy(y)}var w=m.__data,M=m.position,S={x:M.x-w.x,y:M.y-w.y,z:M.z-w.z};["x","y","z"].forEach(function(C){return w["f".concat(C)]=w[C]=M[C]}),t.forceGraph.d3AlphaTarget(.3).resetCountdown(),w.__dragged=!0,t.onNodeDrag(w,S)}}),d.addEventListener("dragend",function(p){var m=gh(p.object);if(m){delete p.object.__initialPos,delete p.object.__prevPos;var y=m.__data;y.__disposeControlsAfterDrag&&(d.dispose(),delete y.__disposeControlsAfterDrag);var x=y.__initialFixedPos,v=y.__initialPos,w={x:v.x-y.x,y:v.y-y.y,z:v.z-y.z};if(x&&(["x","y","z"].forEach(function(S){var C="f".concat(S);x[C]===void 0&&delete y[C]}),delete y.__initialFixedPos,delete y.__initialPos,y.__dragged&&(delete y.__dragged,t.onNodeDragEnd(y,w))),t.forceGraph.d3AlphaTarget(0).resetCountdown(),t.enableNavigationControls){var M;a.enabled=!0,a._status&&((M=a._onPointerCancel)===null||M===void 0||M.call(a)),a.domElement&&a.domElement.ownerDocument&&a.domElement.ownerDocument.dispatchEvent(new PointerEvent("pointerup",{pointerType:"touch"}))}o.domElement.classList.remove("grabbable")}})}}),J1.REVISION<155&&(t.renderObjs.renderer().useLegacyLights=!1),t.renderObjs.hoverOrderComparator(function(u,d){var p=gh(u);if(!p)return 1;var m=gh(d);if(!m)return-1;var y=function(v){return v.__graphObjType==="node"};return y(m)-y(p)}).tooltipContent(function(u){var d=gh(u);return d&&pi(t["".concat(d.__graphObjType,"Label")])(d.__data)||""}).hoverDuringDrag(!1).onHover(function(u){var d=gh(u);if(d!==t.hoverObj){var p=t.hoverObj?t.hoverObj.__graphObjType:null,m=t.hoverObj?t.hoverObj.__data:null,y=d?d.__graphObjType:null,x=d?d.__data:null;if(p&&p!==y){var v=t["on".concat(p==="node"?"Node":"Link","Hover")];v&&v(null,m)}if(y){var w=t["on".concat(y==="node"?"Node":"Link","Hover")];w&&w(x,p===y?m:null)}o.domElement.classList[(d&&t["on".concat(y==="node"?"Node":"Link","Click")]||!d&&t.onBackgroundClick)&&pi(t.showPointerCursor)(x)?"add":"remove"]("clickable"),t.hoverObj=d}}).clickAfterDrag(!1).onClick(function(u,d){var p=gh(u);if(p){var m=t["on".concat(p.__graphObjType==="node"?"Node":"Link","Click")];m&&m(p.__data,d)}else t.onBackgroundClick&&t.onBackgroundClick(d)}).onRightClick(function(u,d){var p=gh(u);if(p){var m=t["on".concat(p.__graphObjType==="node"?"Node":"Link","RightClick")];m&&m(p.__data,d)}else t.onBackgroundRightClick&&t.onBackgroundRightClick(d)}),this._animationCycle()}});function gh(i){for(var e=i;e&&!e.hasOwnProperty("__graphObjType");)e=e.parent;return e}},69168:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return pe}});var xe=re(18773);function pe(ce,$){ce.prototype=Object.create($.prototype),ce.prototype.constructor=ce,(0,xe.Z)(ce,$)}},27625:function(ot,Ve){"use strict";var re={value:()=>{}};function xe(){for(var j=0,K=arguments.length,te={},ue;j<K;++j){if(!(ue=arguments[j]+"")||ue in te||/[\s.]/.test(ue))throw new Error("illegal type: "+ue);te[ue]=[]}return new pe(te)}function pe(j){this._=j}function ce(j,K){return j.trim().split(/^|\s+/).map(function(te){var ue="",ge=te.indexOf(".");if(ge>=0&&(ue=te.slice(ge+1),te=te.slice(0,ge)),te&&!K.hasOwnProperty(te))throw new Error("unknown type: "+te);return{type:te,name:ue}})}pe.prototype=xe.prototype={constructor:pe,on:function(j,K){var te=this._,ue=ce(j+"",te),ge,oe=-1,Me=ue.length;if(arguments.length<2){for(;++oe<Me;)if((ge=(j=ue[oe]).type)&&(ge=$(te[ge],j.name)))return ge;return}if(K!=null&&typeof K!="function")throw new Error("invalid callback: "+K);for(;++oe<Me;)if(ge=(j=ue[oe]).type)te[ge]=J(te[ge],j.name,K);else if(K==null)for(ge in te)te[ge]=J(te[ge],j.name,null);return this},copy:function(){var j={},K=this._;for(var te in K)j[te]=K[te].slice();return new pe(j)},call:function(j,K){if((ge=arguments.length-2)>0)for(var te=new Array(ge),ue=0,ge,oe;ue<ge;++ue)te[ue]=arguments[ue+2];if(!this._.hasOwnProperty(j))throw new Error("unknown type: "+j);for(oe=this._[j],ue=0,ge=oe.length;ue<ge;++ue)oe[ue].value.apply(K,te)},apply:function(j,K,te){if(!this._.hasOwnProperty(j))throw new Error("unknown type: "+j);for(var ue=this._[j],ge=0,oe=ue.length;ge<oe;++ge)ue[ge].value.apply(K,te)}};function $(j,K){for(var te=0,ue=j.length,ge;te<ue;++te)if((ge=j[te]).name===K)return ge.value}function J(j,K,te){for(var ue=0,ge=j.length;ue<ge;++ue)if(j[ue].name===K){j[ue]=re,j=j.slice(0,ue).concat(j.slice(ue+1));break}return te!=null&&j.push({name:K,value:te}),j}Ve.Z=xe},14310:function(ot,Ve,re){"use strict";re.d(Ve,{H:function(){return ce},Z:function(){return xe}});function xe($){const J=+this._x.call(null,$);return pe(this.cover(J),J,$)}function pe($,J,j){if(isNaN(J))return $;var K,te=$._root,ue={data:j},ge=$._x0,oe=$._x1,Me,we,Ae,ve,Ue;if(!te)return $._root=ue,$;for(;te.length;)if((Ae=J>=(Me=(ge+oe)/2))?ge=Me:oe=Me,K=te,!(te=te[ve=+Ae]))return K[ve]=ue,$;if(we=+$._x.call(null,te.data),J===we)return ue.next=te,K?K[ve]=ue:$._root=ue,$;do K=K?K[ve]=new Array(2):$._root=new Array(2),(Ae=J>=(Me=(ge+oe)/2))?ge=Me:oe=Me;while((ve=+Ae)==(Ue=+(we>=Me)));return K[Ue]=te,K[ve]=ue,$}function ce($){Array.isArray($)||($=Array.from($));const J=$.length,j=new Float64Array(J);let K=1/0,te=-1/0;for(let ue=0,ge;ue<J;++ue)isNaN(ge=+this._x.call(null,$[ue]))||(j[ue]=ge,ge<K&&(K=ge),ge>te&&(te=ge));if(K>te)return this;this.cover(K).cover(te);for(let ue=0;ue<J;++ue)pe(this,j[ue],$[ue]);return this}},33662:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return Me}});var xe=re(14310),pe=re(63945),ce=re(27002),$=re(44508),J=re(79150),j=re(45632),K=re(30108),te=re(90820),ue=re(11706),ge=re(78017),oe=re(79387);function Me(Ue,Je){var Ye=new we(Je==null?oe.P:Je,NaN,NaN);return Ue==null?Ye:Ye.addAll(Ue)}function we(Ue,Je,Ye){this._x=Ue,this._x0=Je,this._x1=Ye,this._root=void 0}function Ae(Ue){for(var Je={data:Ue.data},Ye=Je;Ue=Ue.next;)Ye=Ye.next={data:Ue.data};return Je}var ve=Me.prototype=we.prototype;ve.copy=function(){var Ue=new we(this._x,this._x0,this._x1),Je=this._root,Ye,Ke;if(!Je)return Ue;if(!Je.length)return Ue._root=Ae(Je),Ue;for(Ye=[{source:Je,target:Ue._root=new Array(2)}];Je=Ye.pop();)for(var ut=0;ut<2;++ut)(Ke=Je.source[ut])&&(Ke.length?Ye.push({source:Ke,target:Je.target[ut]=new Array(2)}):Je.target[ut]=Ae(Ke));return Ue},ve.add=xe.Z,ve.addAll=xe.H,ve.cover=pe.Z,ve.data=ce.Z,ve.extent=$.Z,ve.find=J.Z,ve.remove=j.Z,ve.removeAll=j.x,ve.root=K.Z,ve.size=te.Z,ve.visit=ue.Z,ve.visitAfter=ge.Z,ve.x=oe.Z},63945:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return xe}});function xe(pe){if(isNaN(pe=+pe))return this;var ce=this._x0,$=this._x1;if(isNaN(ce))$=(ce=Math.floor(pe))+1;else{for(var J=$-ce||1,j=this._root,K,te;ce>pe||pe>=$;)switch(te=+(pe<ce),K=new Array(2),K[te]=j,j=K,J*=2,te){case 0:$=ce+J;break;case 1:ce=$-J;break}this._root&&this._root.length&&(this._root=j)}return this._x0=ce,this._x1=$,this}},27002:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return xe}});function xe(){var pe=[];return this.visit(function(ce){if(!ce.length)do pe.push(ce.data);while(ce=ce.next)}),pe}},44508:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return xe}});function xe(pe){return arguments.length?this.cover(+pe[0][0]).cover(+pe[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]}},79150:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return pe}});var xe=re(10253);function pe(ce,$){var J,j=this._x0,K,te,ue=this._x1,ge=[],oe=this._root,Me,we;for(oe&&ge.push(new xe.Z(oe,j,ue)),$==null?$=1/0:(j=ce-$,ue=ce+$);Me=ge.pop();)if(!(!(oe=Me.node)||(K=Me.x0)>ue||(te=Me.x1)<j))if(oe.length){var Ae=(K+te)/2;ge.push(new xe.Z(oe[1],Ae,te),new xe.Z(oe[0],K,Ae)),(we=+(ce>=Ae))&&(Me=ge[ge.length-1],ge[ge.length-1]=ge[ge.length-1-we],ge[ge.length-1-we]=Me)}else{var ve=Math.abs(ce-+this._x.call(null,oe.data));ve<$&&($=ve,j=ce-ve,ue=ce+ve,J=oe.data)}return J}},10253:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return xe}});function xe(pe,ce,$){this.node=pe,this.x0=ce,this.x1=$}},45632:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return xe},x:function(){return pe}});function xe(ce){if(isNaN(oe=+this._x.call(null,ce)))return this;var $,J=this._root,j,K,te,ue=this._x0,ge=this._x1,oe,Me,we,Ae,ve;if(!J)return this;if(J.length)for(;;){if((we=oe>=(Me=(ue+ge)/2))?ue=Me:ge=Me,$=J,!(J=J[Ae=+we]))return this;if(!J.length)break;$[Ae+1&1]&&(j=$,ve=Ae)}for(;J.data!==ce;)if(K=J,!(J=J.next))return this;return(te=J.next)&&delete J.next,K?(te?K.next=te:delete K.next,this):$?(te?$[Ae]=te:delete $[Ae],(J=$[0]||$[1])&&J===($[1]||$[0])&&!J.length&&(j?j[ve]=J:this._root=J),this):(this._root=te,this)}function pe(ce){for(var $=0,J=ce.length;$<J;++$)this.remove(ce[$]);return this}},30108:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return xe}});function xe(){return this._root}},90820:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return xe}});function xe(){var pe=0;return this.visit(function(ce){if(!ce.length)do++pe;while(ce=ce.next)}),pe}},11706:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return pe}});var xe=re(10253);function pe(ce){var $=[],J,j=this._root,K,te,ue;for(j&&$.push(new xe.Z(j,this._x0,this._x1));J=$.pop();)if(!ce(j=J.node,te=J.x0,ue=J.x1)&&j.length){var ge=(te+ue)/2;(K=j[1])&&$.push(new xe.Z(K,ge,ue)),(K=j[0])&&$.push(new xe.Z(K,te,ge))}return this}},78017:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return pe}});var xe=re(10253);function pe(ce){var $=[],J=[],j;for(this._root&&$.push(new xe.Z(this._root,this._x0,this._x1));j=$.pop();){var K=j.node;if(K.length){var te,ue=j.x0,ge=j.x1,oe=(ue+ge)/2;(te=K[0])&&$.push(new xe.Z(te,ue,oe)),(te=K[1])&&$.push(new xe.Z(te,oe,ge))}J.push(j)}for(;j=J.pop();)ce(j.node,j.x0,j.x1);return this}},79387:function(ot,Ve,re){"use strict";re.d(Ve,{P:function(){return xe},Z:function(){return pe}});function xe(ce){return ce[0]}function pe(ce){return arguments.length?(this._x=ce,this):this._x}},38192:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return xe}});function xe(pe,ce,$){var J,j=1;pe==null&&(pe=0),ce==null&&(ce=0),$==null&&($=0);function K(){var te,ue=J.length,ge,oe=0,Me=0,we=0;for(te=0;te<ue;++te)ge=J[te],oe+=ge.x||0,Me+=ge.y||0,we+=ge.z||0;for(oe=(oe/ue-pe)*j,Me=(Me/ue-ce)*j,we=(we/ue-$)*j,te=0;te<ue;++te)ge=J[te],oe&&(ge.x-=oe),Me&&(ge.y-=Me),we&&(ge.z-=we)}return K.initialize=function(te){J=te},K.x=function(te){return arguments.length?(pe=+te,K):pe},K.y=function(te){return arguments.length?(ce=+te,K):ce},K.z=function(te){return arguments.length?($=+te,K):$},K.strength=function(te){return arguments.length?(j=+te,K):j},K}},85320:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return xe}});function xe(pe){return function(){return pe}}},50277:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return xe}});function xe(pe){return(pe()-.5)*1e-6}},1076:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return $}});const xe=1664525,pe=1013904223,ce=4294967296;function $(){let J=1;return()=>(J=(xe*J+pe)%ce)/ce}},76633:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return J}});var xe=re(85320),pe=re(50277);function ce(j){return j.index}function $(j,K){var te=j.get(K);if(!te)throw new Error("node not found: "+K);return te}function J(j){var K=ce,te=Ye,ue,ge=(0,xe.Z)(30),oe,Me,we,Ae,ve,Ue,Je=1;j==null&&(j=[]);function Ye(at){return 1/Math.min(Ae[at.source.index],Ae[at.target.index])}function Ke(at){for(var _t=0,un=j.length;_t<Je;++_t)for(var Sn=0,Cn,Pn,Rt,Rn=0,Jt=0,tn=0,xi,gt;Sn<un;++Sn)Cn=j[Sn],Pn=Cn.source,Rt=Cn.target,Rn=Rt.x+Rt.vx-Pn.x-Pn.vx||(0,pe.Z)(Ue),we>1&&(Jt=Rt.y+Rt.vy-Pn.y-Pn.vy||(0,pe.Z)(Ue)),we>2&&(tn=Rt.z+Rt.vz-Pn.z-Pn.vz||(0,pe.Z)(Ue)),xi=Math.sqrt(Rn*Rn+Jt*Jt+tn*tn),xi=(xi-oe[Sn])/xi*at*ue[Sn],Rn*=xi,Jt*=xi,tn*=xi,Rt.vx-=Rn*(gt=ve[Sn]),we>1&&(Rt.vy-=Jt*gt),we>2&&(Rt.vz-=tn*gt),Pn.vx+=Rn*(gt=1-gt),we>1&&(Pn.vy+=Jt*gt),we>2&&(Pn.vz+=tn*gt)}function ut(){if(Me){var at,_t=Me.length,un=j.length,Sn=new Map(Me.map((Pn,Rt)=>[K(Pn,Rt,Me),Pn])),Cn;for(at=0,Ae=new Array(_t);at<un;++at)Cn=j[at],Cn.index=at,typeof Cn.source!="object"&&(Cn.source=$(Sn,Cn.source)),typeof Cn.target!="object"&&(Cn.target=$(Sn,Cn.target)),Ae[Cn.source.index]=(Ae[Cn.source.index]||0)+1,Ae[Cn.target.index]=(Ae[Cn.target.index]||0)+1;for(at=0,ve=new Array(un);at<un;++at)Cn=j[at],ve[at]=Ae[Cn.source.index]/(Ae[Cn.source.index]+Ae[Cn.target.index]);ue=new Array(un),nt(),oe=new Array(un),tt()}}function nt(){if(Me)for(var at=0,_t=j.length;at<_t;++at)ue[at]=+te(j[at],at,j)}function tt(){if(Me)for(var at=0,_t=j.length;at<_t;++at)oe[at]=+ge(j[at],at,j)}return Ke.initialize=function(at,..._t){Me=at,Ue=_t.find(un=>typeof un=="function")||Math.random,we=_t.find(un=>[1,2,3].includes(un))||2,ut()},Ke.links=function(at){return arguments.length?(j=at,ut(),Ke):j},Ke.id=function(at){return arguments.length?(K=at,Ke):K},Ke.iterations=function(at){return arguments.length?(Je=+at,Ke):Je},Ke.strength=function(at){return arguments.length?(te=typeof at=="function"?at:(0,xe.Z)(+at),nt(),Ke):te},Ke.distance=function(at){return arguments.length?(ge=typeof at=="function"?at:(0,xe.Z)(+at),tt(),Ke):ge},Ke}},61147:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return K}});var xe=re(33662),pe=re(14301),ce=re(7695),$=re(85320),J=re(50277),j=re(21668);function K(){var te,ue,ge,oe,Me,we=(0,$.Z)(-30),Ae,ve=1,Ue=1/0,Je=.81;function Ye(tt){var at,_t=te.length,un=(ue===1?(0,xe.Z)(te,j.x):ue===2?(0,pe.Z)(te,j.x,j.y):ue===3?(0,ce.Z)(te,j.x,j.y,j.z):null).visitAfter(ut);for(Me=tt,at=0;at<_t;++at)ge=te[at],un.visit(nt)}function Ke(){if(te){var tt,at=te.length,_t;for(Ae=new Array(at),tt=0;tt<at;++tt)_t=te[tt],Ae[_t.index]=+we(_t,tt,te)}}function ut(tt){var at=0,_t,un,Sn=0,Cn,Pn,Rt,Rn,Jt=tt.length;if(Jt){for(Cn=Pn=Rt=Rn=0;Rn<Jt;++Rn)(_t=tt[Rn])&&(un=Math.abs(_t.value))&&(at+=_t.value,Sn+=un,Cn+=un*(_t.x||0),Pn+=un*(_t.y||0),Rt+=un*(_t.z||0));at*=Math.sqrt(4/Jt),tt.x=Cn/Sn,ue>1&&(tt.y=Pn/Sn),ue>2&&(tt.z=Rt/Sn)}else{_t=tt,_t.x=_t.data.x,ue>1&&(_t.y=_t.data.y),ue>2&&(_t.z=_t.data.z);do at+=Ae[_t.data.index];while(_t=_t.next)}tt.value=at}function nt(tt,at,_t,un,Sn){if(!tt.value)return!0;var Cn=[_t,un,Sn][ue-1],Pn=tt.x-ge.x,Rt=ue>1?tt.y-ge.y:0,Rn=ue>2?tt.z-ge.z:0,Jt=Cn-at,tn=Pn*Pn+Rt*Rt+Rn*Rn;if(Jt*Jt/Je<tn)return tn<Ue&&(Pn===0&&(Pn=(0,J.Z)(oe),tn+=Pn*Pn),ue>1&&Rt===0&&(Rt=(0,J.Z)(oe),tn+=Rt*Rt),ue>2&&Rn===0&&(Rn=(0,J.Z)(oe),tn+=Rn*Rn),tn<ve&&(tn=Math.sqrt(ve*tn)),ge.vx+=Pn*tt.value*Me/tn,ue>1&&(ge.vy+=Rt*tt.value*Me/tn),ue>2&&(ge.vz+=Rn*tt.value*Me/tn)),!0;if(tt.length||tn>=Ue)return;(tt.data!==ge||tt.next)&&(Pn===0&&(Pn=(0,J.Z)(oe),tn+=Pn*Pn),ue>1&&Rt===0&&(Rt=(0,J.Z)(oe),tn+=Rt*Rt),ue>2&&Rn===0&&(Rn=(0,J.Z)(oe),tn+=Rn*Rn),tn<ve&&(tn=Math.sqrt(ve*tn)));do tt.data!==ge&&(Jt=Ae[tt.data.index]*Me/tn,ge.vx+=Pn*Jt,ue>1&&(ge.vy+=Rt*Jt),ue>2&&(ge.vz+=Rn*Jt));while(tt=tt.next)}return Ye.initialize=function(tt,...at){te=tt,oe=at.find(_t=>typeof _t=="function")||Math.random,ue=at.find(_t=>[1,2,3].includes(_t))||2,Ke()},Ye.strength=function(tt){return arguments.length?(we=typeof tt=="function"?tt:(0,$.Z)(+tt),Ke(),Ye):we},Ye.distanceMin=function(tt){return arguments.length?(ve=tt*tt,Ye):Math.sqrt(ve)},Ye.distanceMax=function(tt){return arguments.length?(Ue=tt*tt,Ye):Math.sqrt(Ue)},Ye.theta=function(tt){return arguments.length?(Je=tt*tt,Ye):Math.sqrt(Je)},Ye}},21668:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return oe},x:function(){return J},y:function(){return j},z:function(){return K}});var xe=re(27625),pe=re(83833),ce=re(1076),$=3;function J(Me){return Me.x}function j(Me){return Me.y}function K(Me){return Me.z}var te=10,ue=Math.PI*(3-Math.sqrt(5)),ge=Math.PI*20/(9+Math.sqrt(221));function oe(Me,we){we=we||2;var Ae=Math.min($,Math.max(1,Math.round(we))),ve,Ue=1,Je=.001,Ye=1-Math.pow(Je,1/300),Ke=0,ut=.6,nt=new Map,tt=(0,pe.HT)(un),at=(0,xe.Z)("tick","end"),_t=(0,ce.Z)();Me==null&&(Me=[]);function un(){Sn(),at.call("tick",ve),Ue<Je&&(tt.stop(),at.call("end",ve))}function Sn(Rt){var Rn,Jt=Me.length,tn;Rt===void 0&&(Rt=1);for(var xi=0;xi<Rt;++xi)for(Ue+=(Ke-Ue)*Ye,nt.forEach(function(gt){gt(Ue)}),Rn=0;Rn<Jt;++Rn)tn=Me[Rn],tn.fx==null?tn.x+=tn.vx*=ut:(tn.x=tn.fx,tn.vx=0),Ae>1&&(tn.fy==null?tn.y+=tn.vy*=ut:(tn.y=tn.fy,tn.vy=0)),Ae>2&&(tn.fz==null?tn.z+=tn.vz*=ut:(tn.z=tn.fz,tn.vz=0));return ve}function Cn(){for(var Rt=0,Rn=Me.length,Jt;Rt<Rn;++Rt){if(Jt=Me[Rt],Jt.index=Rt,Jt.fx!=null&&(Jt.x=Jt.fx),Jt.fy!=null&&(Jt.y=Jt.fy),Jt.fz!=null&&(Jt.z=Jt.fz),isNaN(Jt.x)||Ae>1&&isNaN(Jt.y)||Ae>2&&isNaN(Jt.z)){var tn=te*(Ae>2?Math.cbrt(.5+Rt):Ae>1?Math.sqrt(.5+Rt):Rt),xi=Rt*ue,gt=Rt*ge;Ae===1?Jt.x=tn:Ae===2?(Jt.x=tn*Math.cos(xi),Jt.y=tn*Math.sin(xi)):(Jt.x=tn*Math.sin(xi)*Math.cos(gt),Jt.y=tn*Math.cos(xi),Jt.z=tn*Math.sin(xi)*Math.sin(gt))}(isNaN(Jt.vx)||Ae>1&&isNaN(Jt.vy)||Ae>2&&isNaN(Jt.vz))&&(Jt.vx=0,Ae>1&&(Jt.vy=0),Ae>2&&(Jt.vz=0))}}function Pn(Rt){return Rt.initialize&&Rt.initialize(Me,_t,Ae),Rt}return Cn(),ve={tick:Sn,restart:function(){return tt.restart(un),ve},stop:function(){return tt.stop(),ve},numDimensions:function(Rt){return arguments.length?(Ae=Math.min($,Math.max(1,Math.round(Rt))),nt.forEach(Pn),ve):Ae},nodes:function(Rt){return arguments.length?(Me=Rt,Cn(),nt.forEach(Pn),ve):Me},alpha:function(Rt){return arguments.length?(Ue=+Rt,ve):Ue},alphaMin:function(Rt){return arguments.length?(Je=+Rt,ve):Je},alphaDecay:function(Rt){return arguments.length?(Ye=+Rt,ve):+Ye},alphaTarget:function(Rt){return arguments.length?(Ke=+Rt,ve):Ke},velocityDecay:function(Rt){return arguments.length?(ut=1-Rt,ve):1-ut},randomSource:function(Rt){return arguments.length?(_t=Rt,nt.forEach(Pn),ve):_t},force:function(Rt,Rn){return arguments.length>1?(Rn==null?nt.delete(Rt):nt.set(Rt,Pn(Rn)),ve):nt.get(Rt)},find:function(){var Rt=Array.prototype.slice.call(arguments),Rn=Rt.shift()||0,Jt=(Ae>1?Rt.shift():null)||0,tn=(Ae>2?Rt.shift():null)||0,xi=Rt.shift()||1/0,gt=0,hn=Me.length,$n,Yi,To,Aa,Dl,nl;for(xi*=xi,gt=0;gt<hn;++gt)Dl=Me[gt],$n=Rn-Dl.x,Yi=Jt-(Dl.y||0),To=tn-(Dl.z||0),Aa=$n*$n+Yi*Yi+To*To,Aa<xi&&(nl=Dl,xi=Aa);return nl},on:function(Rt,Rn){return arguments.length>1?(at.on(Rt,Rn),ve):at.on(Rt)}}}},12713:function(ot,Ve,re){"use strict";re.d(Ve,{H:function(){return ce},Z:function(){return xe}});function xe($){const J=+this._x.call(null,$),j=+this._y.call(null,$),K=+this._z.call(null,$);return pe(this.cover(J,j,K),J,j,K,$)}function pe($,J,j,K,te){if(isNaN(J)||isNaN(j)||isNaN(K))return $;var ue,ge=$._root,oe={data:te},Me=$._x0,we=$._y0,Ae=$._z0,ve=$._x1,Ue=$._y1,Je=$._z1,Ye,Ke,ut,nt,tt,at,_t,un,Sn,Cn,Pn;if(!ge)return $._root=oe,$;for(;ge.length;)if((_t=J>=(Ye=(Me+ve)/2))?Me=Ye:ve=Ye,(un=j>=(Ke=(we+Ue)/2))?we=Ke:Ue=Ke,(Sn=K>=(ut=(Ae+Je)/2))?Ae=ut:Je=ut,ue=ge,!(ge=ge[Cn=Sn<<2|un<<1|_t]))return ue[Cn]=oe,$;if(nt=+$._x.call(null,ge.data),tt=+$._y.call(null,ge.data),at=+$._z.call(null,ge.data),J===nt&&j===tt&&K===at)return oe.next=ge,ue?ue[Cn]=oe:$._root=oe,$;do ue=ue?ue[Cn]=new Array(8):$._root=new Array(8),(_t=J>=(Ye=(Me+ve)/2))?Me=Ye:ve=Ye,(un=j>=(Ke=(we+Ue)/2))?we=Ke:Ue=Ke,(Sn=K>=(ut=(Ae+Je)/2))?Ae=ut:Je=ut;while((Cn=Sn<<2|un<<1|_t)===(Pn=(at>=ut)<<2|(tt>=Ke)<<1|nt>=Ye));return ue[Pn]=ge,ue[Cn]=oe,$}function ce($){Array.isArray($)||($=Array.from($));const J=$.length,j=new Float64Array(J),K=new Float64Array(J),te=new Float64Array(J);let ue=1/0,ge=1/0,oe=1/0,Me=-1/0,we=-1/0,Ae=-1/0;for(let ve=0,Ue,Je,Ye,Ke;ve<J;++ve)isNaN(Je=+this._x.call(null,Ue=$[ve]))||isNaN(Ye=+this._y.call(null,Ue))||isNaN(Ke=+this._z.call(null,Ue))||(j[ve]=Je,K[ve]=Ye,te[ve]=Ke,Je<ue&&(ue=Je),Je>Me&&(Me=Je),Ye<ge&&(ge=Ye),Ye>we&&(we=Ye),Ke<oe&&(oe=Ke),Ke>Ae&&(Ae=Ke));if(ue>Me||ge>we||oe>Ae)return this;this.cover(ue,ge,oe).cover(Me,we,Ae);for(let ve=0;ve<J;++ve)pe(this,j[ve],K[ve],te[ve],$[ve]);return this}},17646:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return xe}});function xe(pe,ce,$){if(isNaN(pe=+pe)||isNaN(ce=+ce)||isNaN($=+$))return this;var J=this._x0,j=this._y0,K=this._z0,te=this._x1,ue=this._y1,ge=this._z1;if(isNaN(J))te=(J=Math.floor(pe))+1,ue=(j=Math.floor(ce))+1,ge=(K=Math.floor($))+1;else{for(var oe=te-J||1,Me=this._root,we,Ae;J>pe||pe>=te||j>ce||ce>=ue||K>$||$>=ge;)switch(Ae=($<K)<<2|(ce<j)<<1|pe<J,we=new Array(8),we[Ae]=Me,Me=we,oe*=2,Ae){case 0:te=J+oe,ue=j+oe,ge=K+oe;break;case 1:J=te-oe,ue=j+oe,ge=K+oe;break;case 2:te=J+oe,j=ue-oe,ge=K+oe;break;case 3:J=te-oe,j=ue-oe,ge=K+oe;break;case 4:te=J+oe,ue=j+oe,K=ge-oe;break;case 5:J=te-oe,ue=j+oe,K=ge-oe;break;case 6:te=J+oe,j=ue-oe,K=ge-oe;break;case 7:J=te-oe,j=ue-oe,K=ge-oe;break}this._root&&this._root.length&&(this._root=Me)}return this._x0=J,this._y0=j,this._z0=K,this._x1=te,this._y1=ue,this._z1=ge,this}},39894:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return xe}});function xe(){var pe=[];return this.visit(function(ce){if(!ce.length)do pe.push(ce.data);while(ce=ce.next)}),pe}},56033:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return xe}});function xe(pe){return arguments.length?this.cover(+pe[0][0],+pe[0][1],+pe[0][2]).cover(+pe[1][0],+pe[1][1],+pe[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]}},77480:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return pe}});var xe=re(26805);function pe(ce,$,J,j){var K,te=this._x0,ue=this._y0,ge=this._z0,oe,Me,we,Ae,ve,Ue,Je=this._x1,Ye=this._y1,Ke=this._z1,ut=[],nt=this._root,tt,at;for(nt&&ut.push(new xe.Z(nt,te,ue,ge,Je,Ye,Ke)),j==null?j=1/0:(te=ce-j,ue=$-j,ge=J-j,Je=ce+j,Ye=$+j,Ke=J+j,j*=j);tt=ut.pop();)if(!(!(nt=tt.node)||(oe=tt.x0)>Je||(Me=tt.y0)>Ye||(we=tt.z0)>Ke||(Ae=tt.x1)<te||(ve=tt.y1)<ue||(Ue=tt.z1)<ge))if(nt.length){var _t=(oe+Ae)/2,un=(Me+ve)/2,Sn=(we+Ue)/2;ut.push(new xe.Z(nt[7],_t,un,Sn,Ae,ve,Ue),new xe.Z(nt[6],oe,un,Sn,_t,ve,Ue),new xe.Z(nt[5],_t,Me,Sn,Ae,un,Ue),new xe.Z(nt[4],oe,Me,Sn,_t,un,Ue),new xe.Z(nt[3],_t,un,we,Ae,ve,Sn),new xe.Z(nt[2],oe,un,we,_t,ve,Sn),new xe.Z(nt[1],_t,Me,we,Ae,un,Sn),new xe.Z(nt[0],oe,Me,we,_t,un,Sn)),(at=(J>=Sn)<<2|($>=un)<<1|ce>=_t)&&(tt=ut[ut.length-1],ut[ut.length-1]=ut[ut.length-1-at],ut[ut.length-1-at]=tt)}else{var Cn=ce-+this._x.call(null,nt.data),Pn=$-+this._y.call(null,nt.data),Rt=J-+this._z.call(null,nt.data),Rn=Cn*Cn+Pn*Pn+Rt*Rt;if(Rn<j){var Jt=Math.sqrt(j=Rn);te=ce-Jt,ue=$-Jt,ge=J-Jt,Je=ce+Jt,Ye=$+Jt,Ke=J+Jt,K=nt.data}}return K}},72096:function(ot,Ve,re){"use strict";re.d(Ve,{r:function(){return pe}});const xe=(ce,$,J,j,K,te)=>Math.sqrt(Cp(ce-j,2)+Cp($-K,2)+Cp(J-te,2));function pe(ce,$,J,j){const K=[],te=ce-j,ue=$-j,ge=J-j,oe=ce+j,Me=$+j,we=J+j;return this.visit((Ae,ve,Ue,Je,Ye,Ke,ut)=>{if(!Ae.length)do{const nt=Ae.data;xe(ce,$,J,this._x(nt),this._y(nt),this._z(nt))<=j&&K.push(nt)}while(Ae=Ae.next);return ve>oe||Ue>Me||Je>we||Ye<te||Ke<ue||ut<ge}),K}},26805:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return xe}});function xe(pe,ce,$,J,j,K,te){this.node=pe,this.x0=ce,this.y0=$,this.z0=J,this.x1=j,this.y1=K,this.z1=te}},7695:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return ve}});var xe=re(12713),pe=re(17646),ce=re(39894),$=re(56033),J=re(77480),j=re(72096),K=re(36989),te=re(10325),ue=re(15902),ge=re(12027),oe=re(66612),Me=re(14763),we=re(94009),Ae=re(68889);function ve(Ke,ut,nt,tt){var at=new Ue(ut==null?Me.P:ut,nt==null?we.q:nt,tt==null?Ae.i:tt,NaN,NaN,NaN,NaN,NaN,NaN);return Ke==null?at:at.addAll(Ke)}function Ue(Ke,ut,nt,tt,at,_t,un,Sn,Cn){this._x=Ke,this._y=ut,this._z=nt,this._x0=tt,this._y0=at,this._z0=_t,this._x1=un,this._y1=Sn,this._z1=Cn,this._root=void 0}function Je(Ke){for(var ut={data:Ke.data},nt=ut;Ke=Ke.next;)nt=nt.next={data:Ke.data};return ut}var Ye=ve.prototype=Ue.prototype;Ye.copy=function(){var Ke=new Ue(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),ut=this._root,nt,tt;if(!ut)return Ke;if(!ut.length)return Ke._root=Je(ut),Ke;for(nt=[{source:ut,target:Ke._root=new Array(8)}];ut=nt.pop();)for(var at=0;at<8;++at)(tt=ut.source[at])&&(tt.length?nt.push({source:tt,target:ut.target[at]=new Array(8)}):ut.target[at]=Je(tt));return Ke},Ye.add=xe.Z,Ye.addAll=xe.H,Ye.cover=pe.Z,Ye.data=ce.Z,Ye.extent=$.Z,Ye.find=J.Z,Ye.findAllWithinRadius=j.r,Ye.remove=K.Z,Ye.removeAll=K.x,Ye.root=te.Z,Ye.size=ue.Z,Ye.visit=ge.Z,Ye.visitAfter=oe.Z,Ye.x=Me.Z,Ye.y=we.Z,Ye.z=Ae.Z},36989:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return xe},x:function(){return pe}});function xe(ce){if(isNaN(ve=+this._x.call(null,ce))||isNaN(Ue=+this._y.call(null,ce))||isNaN(Je=+this._z.call(null,ce)))return this;var $,J=this._root,j,K,te,ue=this._x0,ge=this._y0,oe=this._z0,Me=this._x1,we=this._y1,Ae=this._z1,ve,Ue,Je,Ye,Ke,ut,nt,tt,at,_t,un;if(!J)return this;if(J.length)for(;;){if((nt=ve>=(Ye=(ue+Me)/2))?ue=Ye:Me=Ye,(tt=Ue>=(Ke=(ge+we)/2))?ge=Ke:we=Ke,(at=Je>=(ut=(oe+Ae)/2))?oe=ut:Ae=ut,$=J,!(J=J[_t=at<<2|tt<<1|nt]))return this;if(!J.length)break;($[_t+1&7]||$[_t+2&7]||$[_t+3&7]||$[_t+4&7]||$[_t+5&7]||$[_t+6&7]||$[_t+7&7])&&(j=$,un=_t)}for(;J.data!==ce;)if(K=J,!(J=J.next))return this;return(te=J.next)&&delete J.next,K?(te?K.next=te:delete K.next,this):$?(te?$[_t]=te:delete $[_t],(J=$[0]||$[1]||$[2]||$[3]||$[4]||$[5]||$[6]||$[7])&&J===($[7]||$[6]||$[5]||$[4]||$[3]||$[2]||$[1]||$[0])&&!J.length&&(j?j[un]=J:this._root=J),this):(this._root=te,this)}function pe(ce){for(var $=0,J=ce.length;$<J;++$)this.remove(ce[$]);return this}},10325:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return xe}});function xe(){return this._root}},15902:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return xe}});function xe(){var pe=0;return this.visit(function(ce){if(!ce.length)do++pe;while(ce=ce.next)}),pe}},12027:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return pe}});var xe=re(26805);function pe(ce){var $=[],J,j=this._root,K,te,ue,ge,oe,Me,we;for(j&&$.push(new xe.Z(j,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));J=$.pop();)if(!ce(j=J.node,te=J.x0,ue=J.y0,ge=J.z0,oe=J.x1,Me=J.y1,we=J.z1)&&j.length){var Ae=(te+oe)/2,ve=(ue+Me)/2,Ue=(ge+we)/2;(K=j[7])&&$.push(new xe.Z(K,Ae,ve,Ue,oe,Me,we)),(K=j[6])&&$.push(new xe.Z(K,te,ve,Ue,Ae,Me,we)),(K=j[5])&&$.push(new xe.Z(K,Ae,ue,Ue,oe,ve,we)),(K=j[4])&&$.push(new xe.Z(K,te,ue,Ue,Ae,ve,we)),(K=j[3])&&$.push(new xe.Z(K,Ae,ve,ge,oe,Me,Ue)),(K=j[2])&&$.push(new xe.Z(K,te,ve,ge,Ae,Me,Ue)),(K=j[1])&&$.push(new xe.Z(K,Ae,ue,ge,oe,ve,Ue)),(K=j[0])&&$.push(new xe.Z(K,te,ue,ge,Ae,ve,Ue))}return this}},66612:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return pe}});var xe=re(26805);function pe(ce){var $=[],J=[],j;for(this._root&&$.push(new xe.Z(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));j=$.pop();){var K=j.node;if(K.length){var te,ue=j.x0,ge=j.y0,oe=j.z0,Me=j.x1,we=j.y1,Ae=j.z1,ve=(ue+Me)/2,Ue=(ge+we)/2,Je=(oe+Ae)/2;(te=K[0])&&$.push(new xe.Z(te,ue,ge,oe,ve,Ue,Je)),(te=K[1])&&$.push(new xe.Z(te,ve,ge,oe,Me,Ue,Je)),(te=K[2])&&$.push(new xe.Z(te,ue,Ue,oe,ve,we,Je)),(te=K[3])&&$.push(new xe.Z(te,ve,Ue,oe,Me,we,Je)),(te=K[4])&&$.push(new xe.Z(te,ue,ge,Je,ve,Ue,Ae)),(te=K[5])&&$.push(new xe.Z(te,ve,ge,Je,Me,Ue,Ae)),(te=K[6])&&$.push(new xe.Z(te,ue,Ue,Je,ve,we,Ae)),(te=K[7])&&$.push(new xe.Z(te,ve,Ue,Je,Me,we,Ae))}J.push(j)}for(;j=J.pop();)ce(j.node,j.x0,j.y0,j.z0,j.x1,j.y1,j.z1);return this}},14763:function(ot,Ve,re){"use strict";re.d(Ve,{P:function(){return xe},Z:function(){return pe}});function xe(ce){return ce[0]}function pe(ce){return arguments.length?(this._x=ce,this):this._x}},94009:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return pe},q:function(){return xe}});function xe(ce){return ce[1]}function pe(ce){return arguments.length?(this._y=ce,this):this._y}},68889:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return pe},i:function(){return xe}});function xe(ce){return ce[2]}function pe(ce){return arguments.length?(this._z=ce,this):this._z}},60272:function(ot,Ve,re){"use strict";re.d(Ve,{H:function(){return ce},Z:function(){return xe}});function xe($){const J=+this._x.call(null,$),j=+this._y.call(null,$);return pe(this.cover(J,j),J,j,$)}function pe($,J,j,K){if(isNaN(J)||isNaN(j))return $;var te,ue=$._root,ge={data:K},oe=$._x0,Me=$._y0,we=$._x1,Ae=$._y1,ve,Ue,Je,Ye,Ke,ut,nt,tt;if(!ue)return $._root=ge,$;for(;ue.length;)if((Ke=J>=(ve=(oe+we)/2))?oe=ve:we=ve,(ut=j>=(Ue=(Me+Ae)/2))?Me=Ue:Ae=Ue,te=ue,!(ue=ue[nt=ut<<1|Ke]))return te[nt]=ge,$;if(Je=+$._x.call(null,ue.data),Ye=+$._y.call(null,ue.data),J===Je&&j===Ye)return ge.next=ue,te?te[nt]=ge:$._root=ge,$;do te=te?te[nt]=new Array(4):$._root=new Array(4),(Ke=J>=(ve=(oe+we)/2))?oe=ve:we=ve,(ut=j>=(Ue=(Me+Ae)/2))?Me=Ue:Ae=Ue;while((nt=ut<<1|Ke)===(tt=(Ye>=Ue)<<1|Je>=ve));return te[tt]=ue,te[nt]=ge,$}function ce($){var J,j,K=$.length,te,ue,ge=new Array(K),oe=new Array(K),Me=1/0,we=1/0,Ae=-1/0,ve=-1/0;for(j=0;j<K;++j)isNaN(te=+this._x.call(null,J=$[j]))||isNaN(ue=+this._y.call(null,J))||(ge[j]=te,oe[j]=ue,te<Me&&(Me=te),te>Ae&&(Ae=te),ue<we&&(we=ue),ue>ve&&(ve=ue));if(Me>Ae||we>ve)return this;for(this.cover(Me,we).cover(Ae,ve),j=0;j<K;++j)pe(this,ge[j],oe[j],$[j]);return this}},51097:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return xe}});function xe(pe,ce){if(isNaN(pe=+pe)||isNaN(ce=+ce))return this;var $=this._x0,J=this._y0,j=this._x1,K=this._y1;if(isNaN($))j=($=Math.floor(pe))+1,K=(J=Math.floor(ce))+1;else{for(var te=j-$||1,ue=this._root,ge,oe;$>pe||pe>=j||J>ce||ce>=K;)switch(oe=(ce<J)<<1|pe<$,ge=new Array(4),ge[oe]=ue,ue=ge,te*=2,oe){case 0:j=$+te,K=J+te;break;case 1:$=j-te,K=J+te;break;case 2:j=$+te,J=K-te;break;case 3:$=j-te,J=K-te;break}this._root&&this._root.length&&(this._root=ue)}return this._x0=$,this._y0=J,this._x1=j,this._y1=K,this}},58007:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return xe}});function xe(){var pe=[];return this.visit(function(ce){if(!ce.length)do pe.push(ce.data);while(ce=ce.next)}),pe}},12070:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return xe}});function xe(pe){return arguments.length?this.cover(+pe[0][0],+pe[0][1]).cover(+pe[1][0],+pe[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}},47064:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return pe}});var xe=re(44213);function pe(ce,$,J){var j,K=this._x0,te=this._y0,ue,ge,oe,Me,we=this._x1,Ae=this._y1,ve=[],Ue=this._root,Je,Ye;for(Ue&&ve.push(new xe.Z(Ue,K,te,we,Ae)),J==null?J=1/0:(K=ce-J,te=$-J,we=ce+J,Ae=$+J,J*=J);Je=ve.pop();)if(!(!(Ue=Je.node)||(ue=Je.x0)>we||(ge=Je.y0)>Ae||(oe=Je.x1)<K||(Me=Je.y1)<te))if(Ue.length){var Ke=(ue+oe)/2,ut=(ge+Me)/2;ve.push(new xe.Z(Ue[3],Ke,ut,oe,Me),new xe.Z(Ue[2],ue,ut,Ke,Me),new xe.Z(Ue[1],Ke,ge,oe,ut),new xe.Z(Ue[0],ue,ge,Ke,ut)),(Ye=($>=ut)<<1|ce>=Ke)&&(Je=ve[ve.length-1],ve[ve.length-1]=ve[ve.length-1-Ye],ve[ve.length-1-Ye]=Je)}else{var nt=ce-+this._x.call(null,Ue.data),tt=$-+this._y.call(null,Ue.data),at=nt*nt+tt*tt;if(at<J){var _t=Math.sqrt(J=at);K=ce-_t,te=$-_t,we=ce+_t,Ae=$+_t,j=Ue.data}}return j}},44213:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return xe}});function xe(pe,ce,$,J,j){this.node=pe,this.x0=ce,this.y0=$,this.x1=J,this.y1=j}},14301:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return we}});var xe=re(60272),pe=re(51097),ce=re(58007),$=re(12070),J=re(47064),j=re(88866),K=re(10864),te=re(68984),ue=re(3715),ge=re(73607),oe=re(56570),Me=re(30992);function we(Je,Ye,Ke){var ut=new Ae(Ye==null?oe.P:Ye,Ke==null?Me.q:Ke,NaN,NaN,NaN,NaN);return Je==null?ut:ut.addAll(Je)}function Ae(Je,Ye,Ke,ut,nt,tt){this._x=Je,this._y=Ye,this._x0=Ke,this._y0=ut,this._x1=nt,this._y1=tt,this._root=void 0}function ve(Je){for(var Ye={data:Je.data},Ke=Ye;Je=Je.next;)Ke=Ke.next={data:Je.data};return Ye}var Ue=we.prototype=Ae.prototype;Ue.copy=function(){var Je=new Ae(this._x,this._y,this._x0,this._y0,this._x1,this._y1),Ye=this._root,Ke,ut;if(!Ye)return Je;if(!Ye.length)return Je._root=ve(Ye),Je;for(Ke=[{source:Ye,target:Je._root=new Array(4)}];Ye=Ke.pop();)for(var nt=0;nt<4;++nt)(ut=Ye.source[nt])&&(ut.length?Ke.push({source:ut,target:Ye.target[nt]=new Array(4)}):Ye.target[nt]=ve(ut));return Je},Ue.add=xe.Z,Ue.addAll=xe.H,Ue.cover=pe.Z,Ue.data=ce.Z,Ue.extent=$.Z,Ue.find=J.Z,Ue.remove=j.Z,Ue.removeAll=j.x,Ue.root=K.Z,Ue.size=te.Z,Ue.visit=ue.Z,Ue.visitAfter=ge.Z,Ue.x=oe.Z,Ue.y=Me.Z},88866:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return xe},x:function(){return pe}});function xe(ce){if(isNaN(we=+this._x.call(null,ce))||isNaN(Ae=+this._y.call(null,ce)))return this;var $,J=this._root,j,K,te,ue=this._x0,ge=this._y0,oe=this._x1,Me=this._y1,we,Ae,ve,Ue,Je,Ye,Ke,ut;if(!J)return this;if(J.length)for(;;){if((Je=we>=(ve=(ue+oe)/2))?ue=ve:oe=ve,(Ye=Ae>=(Ue=(ge+Me)/2))?ge=Ue:Me=Ue,$=J,!(J=J[Ke=Ye<<1|Je]))return this;if(!J.length)break;($[Ke+1&3]||$[Ke+2&3]||$[Ke+3&3])&&(j=$,ut=Ke)}for(;J.data!==ce;)if(K=J,!(J=J.next))return this;return(te=J.next)&&delete J.next,K?(te?K.next=te:delete K.next,this):$?(te?$[Ke]=te:delete $[Ke],(J=$[0]||$[1]||$[2]||$[3])&&J===($[3]||$[2]||$[1]||$[0])&&!J.length&&(j?j[ut]=J:this._root=J),this):(this._root=te,this)}function pe(ce){for(var $=0,J=ce.length;$<J;++$)this.remove(ce[$]);return this}},10864:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return xe}});function xe(){return this._root}},68984:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return xe}});function xe(){var pe=0;return this.visit(function(ce){if(!ce.length)do++pe;while(ce=ce.next)}),pe}},3715:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return pe}});var xe=re(44213);function pe(ce){var $=[],J,j=this._root,K,te,ue,ge,oe;for(j&&$.push(new xe.Z(j,this._x0,this._y0,this._x1,this._y1));J=$.pop();)if(!ce(j=J.node,te=J.x0,ue=J.y0,ge=J.x1,oe=J.y1)&&j.length){var Me=(te+ge)/2,we=(ue+oe)/2;(K=j[3])&&$.push(new xe.Z(K,Me,we,ge,oe)),(K=j[2])&&$.push(new xe.Z(K,te,we,Me,oe)),(K=j[1])&&$.push(new xe.Z(K,Me,ue,ge,we)),(K=j[0])&&$.push(new xe.Z(K,te,ue,Me,we))}return this}},73607:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return pe}});var xe=re(44213);function pe(ce){var $=[],J=[],j;for(this._root&&$.push(new xe.Z(this._root,this._x0,this._y0,this._x1,this._y1));j=$.pop();){var K=j.node;if(K.length){var te,ue=j.x0,ge=j.y0,oe=j.x1,Me=j.y1,we=(ue+oe)/2,Ae=(ge+Me)/2;(te=K[0])&&$.push(new xe.Z(te,ue,ge,we,Ae)),(te=K[1])&&$.push(new xe.Z(te,we,ge,oe,Ae)),(te=K[2])&&$.push(new xe.Z(te,ue,Ae,we,Me)),(te=K[3])&&$.push(new xe.Z(te,we,Ae,oe,Me))}J.push(j)}for(;j=J.pop();)ce(j.node,j.x0,j.y0,j.x1,j.y1);return this}},56570:function(ot,Ve,re){"use strict";re.d(Ve,{P:function(){return xe},Z:function(){return pe}});function xe(ce){return ce[0]}function pe(ce){return arguments.length?(this._x=ce,this):this._x}},30992:function(ot,Ve,re){"use strict";re.d(Ve,{Z:function(){return pe},q:function(){return xe}});function xe(ce){return ce[1]}function pe(ce){return arguments.length?(this._y=ce,this):this._y}},83833:function(ot,Ve,re){"use strict";re.d(Ve,{HT:function(){return ve}});var xe=0,pe=0,ce=0,$=1e3,J,j,K=0,te=0,ue=0,ge=typeof performance=="object"&&performance.now?performance:Date,oe=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(nt){setTimeout(nt,17)};function Me(){return te||(oe(we),te=ge.now()+ue)}function we(){te=0}function Ae(){this._call=this._time=this._next=null}Ae.prototype=ve.prototype={constructor:Ae,restart:function(nt,tt,at){if(typeof nt!="function")throw new TypeError("callback is not a function");at=(at==null?Me():+at)+(tt==null?0:+tt),!this._next&&j!==this&&(j?j._next=this:J=this,j=this),this._call=nt,this._time=at,ut()},stop:function(){this._call&&(this._call=null,this._time=1/0,ut())}};function ve(nt,tt,at){var _t=new Ae;return _t.restart(nt,tt,at),_t}function Ue(){Me(),++xe;for(var nt=J,tt;nt;)(tt=te-nt._time)>=0&&nt._call.call(void 0,tt),nt=nt._next;--xe}function Je(){te=(K=ge.now())+ue,xe=pe=0;try{Ue()}finally{xe=0,Ke(),te=0}}function Ye(){var nt=ge.now(),tt=nt-K;tt>$&&(ue-=tt,K=nt)}function Ke(){for(var nt,tt=J,at,_t=1/0;tt;)tt._call?(_t>tt._time&&(_t=tt._time),nt=tt,tt=tt._next):(at=tt._next,tt._next=null,tt=nt?nt._next=at:J=at);j=nt,ut(_t)}function ut(nt){if(!xe){pe&&(pe=clearTimeout(pe));var tt=nt-te;tt>24?(nt<1/0&&(pe=setTimeout(Je,nt-ge.now()-ue)),ce&&(ce=clearInterval(ce))):(ce||(K=ge.now(),ce=setInterval(Ye,$)),xe=1,oe(Je))}}},51910:function(ot,Ve,re){"use strict";re.d(Ve,{KI_:function(){return Ao},Kj0:function(){return dl},ROQ:function(){return fS},TlE:function(){return Ki},ZAu:function(){return xu},ehD:function(){return Ae},jyi:function(){return ud},u9r:function(){return ht},vBJ:function(){return Zl},xeV:function(){return Qg},xo$:function(){return Uf},xoR:function(){return bm}});const xe="181",pe={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},ce={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},$=0,J=1,j=2,K=3,te=0,ue=1,ge=2,oe=3,Me=0,we=1,Ae=2,ve=0,Ue=1,Je=2,Ye=3,Ke=4,ut=5,nt=100,tt=101,at=102,_t=103,un=104,Sn=200,Cn=201,Pn=202,Rt=203,Rn=204,Jt=205,tn=206,xi=207,gt=208,hn=209,$n=210,Yi=211,To=212,Aa=213,Dl=214,nl=0,zn=1,Ci=2,no=3,$c=4,qc=5,Rp=6,Np=7,Xc=0,Hb=1,$b=2,yr=0,o_=1,a_=2,l_=3,c_=4,qb=5,u_=6,h_=7,Cg="attached",Xb="detached",_h=300,Cr=301,Xo=302,jc=303,Yc=304,Fl=306,Ea=1e3,ki=1001,Ca=1002,ni=1003,Pp=1004,LL=1004,Ra=1005,DL=1005,Yn=1006,Zc=1007,FL=1007,Vs=1008,nA=1008,Di=1009,Kc=1010,Jc=1011,jo=1012,er=1013,yi=1014,Si=1015,Hi=1016,Ip=1017,Lp=1018,wo=1020,Dp=35902,Fp=35899,Rg=1021,tf=1022,Ri=1023,tr=1026,Rr=1027,Qc=1028,Bl=1029,Nr=1030,xh=1031,iA=1032,vh=1033,Ol=33776,Ul=33777,kl=33778,zl=33779,nf=35840,sf=35841,rf=35842,of=35843,bh=36196,Sh=37492,Mh=37496,Th=37808,wh=37809,eu=37810,Ah=37811,Eh=37812,Ch=37813,Rh=37814,Nh=37815,Ph=37816,Ih=37817,Lh=37818,Dh=37819,Fh=37820,Bh=37821,Oh=36492,Uh=36494,kh=36495,zh=36283,Vh=36284,Ng=36285,Pg=36286,Gh=2200,Wh=2201,tu=2202,il=2300,Ig=2301,Lg=2302,Hh=2400,sl=2401,$h=2402,af=2500,nu=2501,lf=0,Dg=1,d_=2,f_=3200,BL=3201,OL=3202,UL=3203,qh=0,kL=1,jb="",Ao="srgb",Yo="srgb-linear",Fg="linear",_r="srgb",Pr=0,io=7680,cf=7681,$t=7682,p_=7683,Yb=34055,sA=34056,rA=5386,Xh=512,oA=513,aA=514,lA=515,cA=516,uA=517,hA=518,m_=519,dA=512,fA=513,pA=514,mA=515,gA=516,yA=517,g_=518,y_=519,Vl=35044,__=35048,Bp=35040,x_=35045,v_=35049,Op=35041,b_=35046,jh=35050,Yh=35042,zL="100",VL="300 es",rl=2e3,Up=2001,GL={COMPUTE:"compute",RENDER:"render"},WL={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},HL={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"};function _A(E){for(let s=E.length-1;s>=0;--s)if(E[s]>=65535)return!0;return!1}const S_={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function ws(E,s){return new S_[E](s)}function xr(E){return document.createElementNS("http://www.w3.org/1999/xhtml",E)}function ol(){const E=xr("canvas");return E.style.display="block",E}const Zb={};let iu=null;function M_(E){iu=E}function xA(){return iu}function su(...E){const s="THREE."+E.shift();iu?iu("log",s,...E):console.log(s,...E)}function Mn(...E){const s="THREE."+E.shift();iu?iu("warn",s,...E):console.warn(s,...E)}function ci(...E){const s="THREE."+E.shift();iu?iu("error",s,...E):console.error(s,...E)}function Bg(...E){const s=E.join(" ");s in Zb||(Zb[s]=!0,Mn(...E))}function Kb(E,s,l){return new Promise(function(h,f){function g(){switch(E.clientWaitSync(s,E.SYNC_FLUSH_COMMANDS_BIT,0)){case E.WAIT_FAILED:f();break;case E.TIMEOUT_EXPIRED:setTimeout(g,l);break;default:h()}}setTimeout(g,l)})}class Zo{addEventListener(s,l){this._listeners===void 0&&(this._listeners={});const h=this._listeners;h[s]===void 0&&(h[s]=[]),h[s].indexOf(l)===-1&&h[s].push(l)}hasEventListener(s,l){const h=this._listeners;return h===void 0?!1:h[s]!==void 0&&h[s].indexOf(l)!==-1}removeEventListener(s,l){const h=this._listeners;if(h===void 0)return;const f=h[s];if(f!==void 0){const g=f.indexOf(l);g!==-1&&f.splice(g,1)}}dispatchEvent(s){const l=this._listeners;if(l===void 0)return;const h=l[s.type];if(h!==void 0){s.target=this;const f=h.slice(0);for(let g=0,_=f.length;g<_;g++)f[g].call(this,s);s.target=null}}}const Ir=["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 Jb=1234567;const Ko=Math.PI/180,Ie=180/Math.PI;function Be(){const E=Math.random()*4294967295|0,s=Math.random()*4294967295|0,l=Math.random()*4294967295|0,h=Math.random()*4294967295|0;return(Ir[E&255]+Ir[E>>8&255]+Ir[E>>16&255]+Ir[E>>24&255]+"-"+Ir[s&255]+Ir[s>>8&255]+"-"+Ir[s>>16&15|64]+Ir[s>>24&255]+"-"+Ir[l&63|128]+Ir[l>>8&255]+"-"+Ir[l>>16&255]+Ir[l>>24&255]+Ir[h&255]+Ir[h>>8&255]+Ir[h>>16&255]+Ir[h>>24&255]).toLowerCase()}function Ut(E,s,l){return Math.max(s,Math.min(l,E))}function Og(E,s){return(E%s+s)%s}function Jo(E,s,l,h,f){return h+(E-s)*(f-h)/(l-s)}function vr(E,s,l){return E!==s?(l-E)/(s-E):0}function Zh(E,s,l){return(1-l)*E+l*s}function ru(E,s,l,h){return Zh(E,s,1-Math.exp(-l*h))}function ou(E,s=1){return s-Math.abs(Og(E,s*2)-s)}function so(E,s,l){return E<=s?0:E>=l?1:(E=(E-s)/(l-s),E*E*(3-2*E))}function Vn(E,s,l){return E<=s?0:E>=l?1:(E=(E-s)/(l-s),E*E*E*(E*(E*6-15)+10))}function Ug(E,s){return E+Math.floor(Math.random()*(s-E+1))}function Qb(E,s){return E+Math.random()*(s-E)}function eS(E){return E*(.5-Math.random())}function uf(E){E!==void 0&&(Jb=E);let s=Jb+=1831565813;return s=Math.imul(s^s>>>15,s|1),s^=s+Math.imul(s^s>>>7,s|61),((s^s>>>14)>>>0)/4294967296}function tS(E){return E*Ko}function nS(E){return E*Ie}function iS(E){return(E&E-1)===0&&E!==0}function sS(E){return Math.pow(2,Math.ceil(Math.log(E)/Math.LN2))}function rS(E){return Math.pow(2,Math.floor(Math.log(E)/Math.LN2))}function oS(E,s,l,h,f){const g=Math.cos,_=Math.sin,b=g(l/2),T=_(l/2),A=g((s+h)/2),R=_((s+h)/2),P=g((s-h)/2),L=_((s-h)/2),D=g((h-s)/2),O=_((h-s)/2);switch(f){case"XYX":E.set(b*R,T*P,T*L,b*A);break;case"YZY":E.set(T*L,b*R,T*P,b*A);break;case"ZXZ":E.set(T*P,T*L,b*R,b*A);break;case"XZX":E.set(b*R,T*O,T*D,b*A);break;case"YXY":E.set(T*D,b*R,T*O,b*A);break;case"ZYZ":E.set(T*O,T*D,b*R,b*A);break;default:Mn("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+f)}}function Lr(E,s){switch(s.constructor){case Float32Array:return E;case Uint32Array:return E/4294967295;case Uint16Array:return E/65535;case Uint8Array:return E/255;case Int32Array:return Math.max(E/2147483647,-1);case Int16Array:return Math.max(E/32767,-1);case Int8Array:return Math.max(E/127,-1);default:throw new Error("Invalid component type.")}}function Qn(E,s){switch(s.constructor){case Float32Array:return E;case Uint32Array:return Math.round(E*4294967295);case Uint16Array:return Math.round(E*65535);case Uint8Array:return Math.round(E*255);case Int32Array:return Math.round(E*2147483647);case Int16Array:return Math.round(E*32767);case Int8Array:return Math.round(E*127);default:throw new Error("Invalid component type.")}}const vA={DEG2RAD:Ko,RAD2DEG:Ie,generateUUID:Be,clamp:Ut,euclideanModulo:Og,mapLinear:Jo,inverseLerp:vr,lerp:Zh,damp:ru,pingpong:ou,smoothstep:so,smootherstep:Vn,randInt:Ug,randFloat:Qb,randFloatSpread:eS,seededRandom:uf,degToRad:tS,radToDeg:nS,isPowerOfTwo:iS,ceilPowerOfTwo:sS,floorPowerOfTwo:rS,setQuaternionFromProperEuler:oS,normalize:Qn,denormalize:Lr};class St{constructor(s=0,l=0){St.prototype.isVector2=!0,this.x=s,this.y=l}get width(){return this.x}set width(s){this.x=s}get height(){return this.y}set height(s){this.y=s}set(s,l){return this.x=s,this.y=l,this}setScalar(s){return this.x=s,this.y=s,this}setX(s){return this.x=s,this}setY(s){return this.y=s,this}setComponent(s,l){switch(s){case 0:this.x=l;break;case 1:this.y=l;break;default:throw new Error("index is out of range: "+s)}return this}getComponent(s){switch(s){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+s)}}clone(){return new this.constructor(this.x,this.y)}copy(s){return this.x=s.x,this.y=s.y,this}add(s){return this.x+=s.x,this.y+=s.y,this}addScalar(s){return this.x+=s,this.y+=s,this}addVectors(s,l){return this.x=s.x+l.x,this.y=s.y+l.y,this}addScaledVector(s,l){return this.x+=s.x*l,this.y+=s.y*l,this}sub(s){return this.x-=s.x,this.y-=s.y,this}subScalar(s){return this.x-=s,this.y-=s,this}subVectors(s,l){return this.x=s.x-l.x,this.y=s.y-l.y,this}multiply(s){return this.x*=s.x,this.y*=s.y,this}multiplyScalar(s){return this.x*=s,this.y*=s,this}divide(s){return this.x/=s.x,this.y/=s.y,this}divideScalar(s){return this.multiplyScalar(1/s)}applyMatrix3(s){const l=this.x,h=this.y,f=s.elements;return this.x=f[0]*l+f[3]*h+f[6],this.y=f[1]*l+f[4]*h+f[7],this}min(s){return this.x=Math.min(this.x,s.x),this.y=Math.min(this.y,s.y),this}max(s){return this.x=Math.max(this.x,s.x),this.y=Math.max(this.y,s.y),this}clamp(s,l){return this.x=Ut(this.x,s.x,l.x),this.y=Ut(this.y,s.y,l.y),this}clampScalar(s,l){return this.x=Ut(this.x,s,l),this.y=Ut(this.y,s,l),this}clampLength(s,l){const h=this.length();return this.divideScalar(h||1).multiplyScalar(Ut(h,s,l))}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(s){return this.x*s.x+this.y*s.y}cross(s){return this.x*s.y-this.y*s.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(s){const l=Math.sqrt(this.lengthSq()*s.lengthSq());if(l===0)return Math.PI/2;const h=this.dot(s)/l;return Math.acos(Ut(h,-1,1))}distanceTo(s){return Math.sqrt(this.distanceToSquared(s))}distanceToSquared(s){const l=this.x-s.x,h=this.y-s.y;return l*l+h*h}manhattanDistanceTo(s){return Math.abs(this.x-s.x)+Math.abs(this.y-s.y)}setLength(s){return this.normalize().multiplyScalar(s)}lerp(s,l){return this.x+=(s.x-this.x)*l,this.y+=(s.y-this.y)*l,this}lerpVectors(s,l,h){return this.x=s.x+(l.x-s.x)*h,this.y=s.y+(l.y-s.y)*h,this}equals(s){return s.x===this.x&&s.y===this.y}fromArray(s,l=0){return this.x=s[l],this.y=s[l+1],this}toArray(s=[],l=0){return s[l]=this.x,s[l+1]=this.y,s}fromBufferAttribute(s,l){return this.x=s.getX(l),this.y=s.getY(l),this}rotateAround(s,l){const h=Math.cos(l),f=Math.sin(l),g=this.x-s.x,_=this.y-s.y;return this.x=g*h-_*f+s.x,this.y=g*f+_*h+s.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class ro{constructor(s=0,l=0,h=0,f=1){this.isQuaternion=!0,this._x=s,this._y=l,this._z=h,this._w=f}static slerpFlat(s,l,h,f,g,_,b){let T=h[f+0],A=h[f+1],R=h[f+2],P=h[f+3],L=g[_+0],D=g[_+1],O=g[_+2],W=g[_+3];if(b<=0){s[l+0]=T,s[l+1]=A,s[l+2]=R,s[l+3]=P;return}if(b>=1){s[l+0]=L,s[l+1]=D,s[l+2]=O,s[l+3]=W;return}if(P!==W||T!==L||A!==D||R!==O){let Z=T*L+A*D+R*O+P*W;Z<0&&(L=-L,D=-D,O=-O,W=-W,Z=-Z);let Y=1-b;if(Z<.9995){const ie=Math.acos(Z),se=Math.sin(ie);Y=Math.sin(Y*ie)/se,b=Math.sin(b*ie)/se,T=T*Y+L*b,A=A*Y+D*b,R=R*Y+O*b,P=P*Y+W*b}else{T=T*Y+L*b,A=A*Y+D*b,R=R*Y+O*b,P=P*Y+W*b;const ie=1/Math.sqrt(T*T+A*A+R*R+P*P);T*=ie,A*=ie,R*=ie,P*=ie}}s[l]=T,s[l+1]=A,s[l+2]=R,s[l+3]=P}static multiplyQuaternionsFlat(s,l,h,f,g,_){const b=h[f],T=h[f+1],A=h[f+2],R=h[f+3],P=g[_],L=g[_+1],D=g[_+2],O=g[_+3];return s[l]=b*O+R*P+T*D-A*L,s[l+1]=T*O+R*L+A*P-b*D,s[l+2]=A*O+R*D+b*L-T*P,s[l+3]=R*O-b*P-T*L-A*D,s}get x(){return this._x}set x(s){this._x=s,this._onChangeCallback()}get y(){return this._y}set y(s){this._y=s,this._onChangeCallback()}get z(){return this._z}set z(s){this._z=s,this._onChangeCallback()}get w(){return this._w}set w(s){this._w=s,this._onChangeCallback()}set(s,l,h,f){return this._x=s,this._y=l,this._z=h,this._w=f,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(s){return this._x=s.x,this._y=s.y,this._z=s.z,this._w=s.w,this._onChangeCallback(),this}setFromEuler(s,l=!0){const h=s._x,f=s._y,g=s._z,_=s._order,b=Math.cos,T=Math.sin,A=b(h/2),R=b(f/2),P=b(g/2),L=T(h/2),D=T(f/2),O=T(g/2);switch(_){case"XYZ":this._x=L*R*P+A*D*O,this._y=A*D*P-L*R*O,this._z=A*R*O+L*D*P,this._w=A*R*P-L*D*O;break;case"YXZ":this._x=L*R*P+A*D*O,this._y=A*D*P-L*R*O,this._z=A*R*O-L*D*P,this._w=A*R*P+L*D*O;break;case"ZXY":this._x=L*R*P-A*D*O,this._y=A*D*P+L*R*O,this._z=A*R*O+L*D*P,this._w=A*R*P-L*D*O;break;case"ZYX":this._x=L*R*P-A*D*O,this._y=A*D*P+L*R*O,this._z=A*R*O-L*D*P,this._w=A*R*P+L*D*O;break;case"YZX":this._x=L*R*P+A*D*O,this._y=A*D*P+L*R*O,this._z=A*R*O-L*D*P,this._w=A*R*P-L*D*O;break;case"XZY":this._x=L*R*P-A*D*O,this._y=A*D*P-L*R*O,this._z=A*R*O+L*D*P,this._w=A*R*P+L*D*O;break;default:Mn("Quaternion: .setFromEuler() encountered an unknown order: "+_)}return l===!0&&this._onChangeCallback(),this}setFromAxisAngle(s,l){const h=l/2,f=Math.sin(h);return this._x=s.x*f,this._y=s.y*f,this._z=s.z*f,this._w=Math.cos(h),this._onChangeCallback(),this}setFromRotationMatrix(s){const l=s.elements,h=l[0],f=l[4],g=l[8],_=l[1],b=l[5],T=l[9],A=l[2],R=l[6],P=l[10],L=h+b+P;if(L>0){const D=.5/Math.sqrt(L+1);this._w=.25/D,this._x=(R-T)*D,this._y=(g-A)*D,this._z=(_-f)*D}else if(h>b&&h>P){const D=2*Math.sqrt(1+h-b-P);this._w=(R-T)/D,this._x=.25*D,this._y=(f+_)/D,this._z=(g+A)/D}else if(b>P){const D=2*Math.sqrt(1+b-h-P);this._w=(g-A)/D,this._x=(f+_)/D,this._y=.25*D,this._z=(T+R)/D}else{const D=2*Math.sqrt(1+P-h-b);this._w=(_-f)/D,this._x=(g+A)/D,this._y=(T+R)/D,this._z=.25*D}return this._onChangeCallback(),this}setFromUnitVectors(s,l){let h=s.dot(l)+1;return h<1e-8?(h=0,Math.abs(s.x)>Math.abs(s.z)?(this._x=-s.y,this._y=s.x,this._z=0,this._w=h):(this._x=0,this._y=-s.z,this._z=s.y,this._w=h)):(this._x=s.y*l.z-s.z*l.y,this._y=s.z*l.x-s.x*l.z,this._z=s.x*l.y-s.y*l.x,this._w=h),this.normalize()}angleTo(s){return 2*Math.acos(Math.abs(Ut(this.dot(s),-1,1)))}rotateTowards(s,l){const h=this.angleTo(s);if(h===0)return this;const f=Math.min(1,l/h);return this.slerp(s,f),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(s){return this._x*s._x+this._y*s._y+this._z*s._z+this._w*s._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 s=this.length();return s===0?(this._x=0,this._y=0,this._z=0,this._w=1):(s=1/s,this._x=this._x*s,this._y=this._y*s,this._z=this._z*s,this._w=this._w*s),this._onChangeCallback(),this}multiply(s){return this.multiplyQuaternions(this,s)}premultiply(s){return this.multiplyQuaternions(s,this)}multiplyQuaternions(s,l){const h=s._x,f=s._y,g=s._z,_=s._w,b=l._x,T=l._y,A=l._z,R=l._w;return this._x=h*R+_*b+f*A-g*T,this._y=f*R+_*T+g*b-h*A,this._z=g*R+_*A+h*T-f*b,this._w=_*R-h*b-f*T-g*A,this._onChangeCallback(),this}slerp(s,l){if(l<=0)return this;if(l>=1)return this.copy(s);let h=s._x,f=s._y,g=s._z,_=s._w,b=this.dot(s);b<0&&(h=-h,f=-f,g=-g,_=-_,b=-b);let T=1-l;if(b<.9995){const A=Math.acos(b),R=Math.sin(A);T=Math.sin(T*A)/R,l=Math.sin(l*A)/R,this._x=this._x*T+h*l,this._y=this._y*T+f*l,this._z=this._z*T+g*l,this._w=this._w*T+_*l,this._onChangeCallback()}else this._x=this._x*T+h*l,this._y=this._y*T+f*l,this._z=this._z*T+g*l,this._w=this._w*T+_*l,this.normalize();return this}slerpQuaternions(s,l,h){return this.copy(s).slerp(l,h)}random(){const s=2*Math.PI*Math.random(),l=2*Math.PI*Math.random(),h=Math.random(),f=Math.sqrt(1-h),g=Math.sqrt(h);return this.set(f*Math.sin(s),f*Math.cos(s),g*Math.sin(l),g*Math.cos(l))}equals(s){return s._x===this._x&&s._y===this._y&&s._z===this._z&&s._w===this._w}fromArray(s,l=0){return this._x=s[l],this._y=s[l+1],this._z=s[l+2],this._w=s[l+3],this._onChangeCallback(),this}toArray(s=[],l=0){return s[l]=this._x,s[l+1]=this._y,s[l+2]=this._z,s[l+3]=this._w,s}fromBufferAttribute(s,l){return this._x=s.getX(l),this._y=s.getY(l),this._z=s.getZ(l),this._w=s.getW(l),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(s){return this._onChangeCallback=s,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class ae{constructor(s=0,l=0,h=0){ae.prototype.isVector3=!0,this.x=s,this.y=l,this.z=h}set(s,l,h){return h===void 0&&(h=this.z),this.x=s,this.y=l,this.z=h,this}setScalar(s){return this.x=s,this.y=s,this.z=s,this}setX(s){return this.x=s,this}setY(s){return this.y=s,this}setZ(s){return this.z=s,this}setComponent(s,l){switch(s){case 0:this.x=l;break;case 1:this.y=l;break;case 2:this.z=l;break;default:throw new Error("index is out of range: "+s)}return this}getComponent(s){switch(s){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+s)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(s){return this.x=s.x,this.y=s.y,this.z=s.z,this}add(s){return this.x+=s.x,this.y+=s.y,this.z+=s.z,this}addScalar(s){return this.x+=s,this.y+=s,this.z+=s,this}addVectors(s,l){return this.x=s.x+l.x,this.y=s.y+l.y,this.z=s.z+l.z,this}addScaledVector(s,l){return this.x+=s.x*l,this.y+=s.y*l,this.z+=s.z*l,this}sub(s){return this.x-=s.x,this.y-=s.y,this.z-=s.z,this}subScalar(s){return this.x-=s,this.y-=s,this.z-=s,this}subVectors(s,l){return this.x=s.x-l.x,this.y=s.y-l.y,this.z=s.z-l.z,this}multiply(s){return this.x*=s.x,this.y*=s.y,this.z*=s.z,this}multiplyScalar(s){return this.x*=s,this.y*=s,this.z*=s,this}multiplyVectors(s,l){return this.x=s.x*l.x,this.y=s.y*l.y,this.z=s.z*l.z,this}applyEuler(s){return this.applyQuaternion(T_.setFromEuler(s))}applyAxisAngle(s,l){return this.applyQuaternion(T_.setFromAxisAngle(s,l))}applyMatrix3(s){const l=this.x,h=this.y,f=this.z,g=s.elements;return this.x=g[0]*l+g[3]*h+g[6]*f,this.y=g[1]*l+g[4]*h+g[7]*f,this.z=g[2]*l+g[5]*h+g[8]*f,this}applyNormalMatrix(s){return this.applyMatrix3(s).normalize()}applyMatrix4(s){const l=this.x,h=this.y,f=this.z,g=s.elements,_=1/(g[3]*l+g[7]*h+g[11]*f+g[15]);return this.x=(g[0]*l+g[4]*h+g[8]*f+g[12])*_,this.y=(g[1]*l+g[5]*h+g[9]*f+g[13])*_,this.z=(g[2]*l+g[6]*h+g[10]*f+g[14])*_,this}applyQuaternion(s){const l=this.x,h=this.y,f=this.z,g=s.x,_=s.y,b=s.z,T=s.w,A=2*(_*f-b*h),R=2*(b*l-g*f),P=2*(g*h-_*l);return this.x=l+T*A+_*P-b*R,this.y=h+T*R+b*A-g*P,this.z=f+T*P+g*R-_*A,this}project(s){return this.applyMatrix4(s.matrixWorldInverse).applyMatrix4(s.projectionMatrix)}unproject(s){return this.applyMatrix4(s.projectionMatrixInverse).applyMatrix4(s.matrixWorld)}transformDirection(s){const l=this.x,h=this.y,f=this.z,g=s.elements;return this.x=g[0]*l+g[4]*h+g[8]*f,this.y=g[1]*l+g[5]*h+g[9]*f,this.z=g[2]*l+g[6]*h+g[10]*f,this.normalize()}divide(s){return this.x/=s.x,this.y/=s.y,this.z/=s.z,this}divideScalar(s){return this.multiplyScalar(1/s)}min(s){return this.x=Math.min(this.x,s.x),this.y=Math.min(this.y,s.y),this.z=Math.min(this.z,s.z),this}max(s){return this.x=Math.max(this.x,s.x),this.y=Math.max(this.y,s.y),this.z=Math.max(this.z,s.z),this}clamp(s,l){return this.x=Ut(this.x,s.x,l.x),this.y=Ut(this.y,s.y,l.y),this.z=Ut(this.z,s.z,l.z),this}clampScalar(s,l){return this.x=Ut(this.x,s,l),this.y=Ut(this.y,s,l),this.z=Ut(this.z,s,l),this}clampLength(s,l){const h=this.length();return this.divideScalar(h||1).multiplyScalar(Ut(h,s,l))}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(s){return this.x*s.x+this.y*s.y+this.z*s.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(s){return this.normalize().multiplyScalar(s)}lerp(s,l){return this.x+=(s.x-this.x)*l,this.y+=(s.y-this.y)*l,this.z+=(s.z-this.z)*l,this}lerpVectors(s,l,h){return this.x=s.x+(l.x-s.x)*h,this.y=s.y+(l.y-s.y)*h,this.z=s.z+(l.z-s.z)*h,this}cross(s){return this.crossVectors(this,s)}crossVectors(s,l){const h=s.x,f=s.y,g=s.z,_=l.x,b=l.y,T=l.z;return this.x=f*T-g*b,this.y=g*_-h*T,this.z=h*b-f*_,this}projectOnVector(s){const l=s.lengthSq();if(l===0)return this.set(0,0,0);const h=s.dot(this)/l;return this.copy(s).multiplyScalar(h)}projectOnPlane(s){return kg.copy(this).projectOnVector(s),this.sub(kg)}reflect(s){return this.sub(kg.copy(s).multiplyScalar(2*this.dot(s)))}angleTo(s){const l=Math.sqrt(this.lengthSq()*s.lengthSq());if(l===0)return Math.PI/2;const h=this.dot(s)/l;return Math.acos(Ut(h,-1,1))}distanceTo(s){return Math.sqrt(this.distanceToSquared(s))}distanceToSquared(s){const l=this.x-s.x,h=this.y-s.y,f=this.z-s.z;return l*l+h*h+f*f}manhattanDistanceTo(s){return Math.abs(this.x-s.x)+Math.abs(this.y-s.y)+Math.abs(this.z-s.z)}setFromSpherical(s){return this.setFromSphericalCoords(s.radius,s.phi,s.theta)}setFromSphericalCoords(s,l,h){const f=Math.sin(l)*s;return this.x=f*Math.sin(h),this.y=Math.cos(l)*s,this.z=f*Math.cos(h),this}setFromCylindrical(s){return this.setFromCylindricalCoords(s.radius,s.theta,s.y)}setFromCylindricalCoords(s,l,h){return this.x=s*Math.sin(l),this.y=h,this.z=s*Math.cos(l),this}setFromMatrixPosition(s){const l=s.elements;return this.x=l[12],this.y=l[13],this.z=l[14],this}setFromMatrixScale(s){const l=this.setFromMatrixColumn(s,0).length(),h=this.setFromMatrixColumn(s,1).length(),f=this.setFromMatrixColumn(s,2).length();return this.x=l,this.y=h,this.z=f,this}setFromMatrixColumn(s,l){return this.fromArray(s.elements,l*4)}setFromMatrix3Column(s,l){return this.fromArray(s.elements,l*3)}setFromEuler(s){return this.x=s._x,this.y=s._y,this.z=s._z,this}setFromColor(s){return this.x=s.r,this.y=s.g,this.z=s.b,this}equals(s){return s.x===this.x&&s.y===this.y&&s.z===this.z}fromArray(s,l=0){return this.x=s[l],this.y=s[l+1],this.z=s[l+2],this}toArray(s=[],l=0){return s[l]=this.x,s[l+1]=this.y,s[l+2]=this.z,s}fromBufferAttribute(s,l){return this.x=s.getX(l),this.y=s.getY(l),this.z=s.getZ(l),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const s=Math.random()*Math.PI*2,l=Math.random()*2-1,h=Math.sqrt(1-l*l);return this.x=h*Math.cos(s),this.y=l,this.z=h*Math.sin(s),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const kg=new ae,T_=new ro;class ts{constructor(s,l,h,f,g,_,b,T,A){ts.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],s!==void 0&&this.set(s,l,h,f,g,_,b,T,A)}set(s,l,h,f,g,_,b,T,A){const R=this.elements;return R[0]=s,R[1]=f,R[2]=b,R[3]=l,R[4]=g,R[5]=T,R[6]=h,R[7]=_,R[8]=A,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(s){const l=this.elements,h=s.elements;return l[0]=h[0],l[1]=h[1],l[2]=h[2],l[3]=h[3],l[4]=h[4],l[5]=h[5],l[6]=h[6],l[7]=h[7],l[8]=h[8],this}extractBasis(s,l,h){return s.setFromMatrix3Column(this,0),l.setFromMatrix3Column(this,1),h.setFromMatrix3Column(this,2),this}setFromMatrix4(s){const l=s.elements;return this.set(l[0],l[4],l[8],l[1],l[5],l[9],l[2],l[6],l[10]),this}multiply(s){return this.multiplyMatrices(this,s)}premultiply(s){return this.multiplyMatrices(s,this)}multiplyMatrices(s,l){const h=s.elements,f=l.elements,g=this.elements,_=h[0],b=h[3],T=h[6],A=h[1],R=h[4],P=h[7],L=h[2],D=h[5],O=h[8],W=f[0],Z=f[3],Y=f[6],ie=f[1],se=f[4],de=f[7],ke=f[2],$e=f[5],et=f[8];return g[0]=_*W+b*ie+T*ke,g[3]=_*Z+b*se+T*$e,g[6]=_*Y+b*de+T*et,g[1]=A*W+R*ie+P*ke,g[4]=A*Z+R*se+P*$e,g[7]=A*Y+R*de+P*et,g[2]=L*W+D*ie+O*ke,g[5]=L*Z+D*se+O*$e,g[8]=L*Y+D*de+O*et,this}multiplyScalar(s){const l=this.elements;return l[0]*=s,l[3]*=s,l[6]*=s,l[1]*=s,l[4]*=s,l[7]*=s,l[2]*=s,l[5]*=s,l[8]*=s,this}determinant(){const s=this.elements,l=s[0],h=s[1],f=s[2],g=s[3],_=s[4],b=s[5],T=s[6],A=s[7],R=s[8];return l*_*R-l*b*A-h*g*R+h*b*T+f*g*A-f*_*T}invert(){const s=this.elements,l=s[0],h=s[1],f=s[2],g=s[3],_=s[4],b=s[5],T=s[6],A=s[7],R=s[8],P=R*_-b*A,L=b*T-R*g,D=A*g-_*T,O=l*P+h*L+f*D;if(O===0)return this.set(0,0,0,0,0,0,0,0,0);const W=1/O;return s[0]=P*W,s[1]=(f*A-R*h)*W,s[2]=(b*h-f*_)*W,s[3]=L*W,s[4]=(R*l-f*T)*W,s[5]=(f*g-b*l)*W,s[6]=D*W,s[7]=(h*T-A*l)*W,s[8]=(_*l-h*g)*W,this}transpose(){let s;const l=this.elements;return s=l[1],l[1]=l[3],l[3]=s,s=l[2],l[2]=l[6],l[6]=s,s=l[5],l[5]=l[7],l[7]=s,this}getNormalMatrix(s){return this.setFromMatrix4(s).invert().transpose()}transposeIntoArray(s){const l=this.elements;return s[0]=l[0],s[1]=l[3],s[2]=l[6],s[3]=l[1],s[4]=l[4],s[5]=l[7],s[6]=l[2],s[7]=l[5],s[8]=l[8],this}setUvTransform(s,l,h,f,g,_,b){const T=Math.cos(g),A=Math.sin(g);return this.set(h*T,h*A,-h*(T*_+A*b)+_+s,-f*A,f*T,-f*(-A*_+T*b)+b+l,0,0,1),this}scale(s,l){return this.premultiply(Jn.makeScale(s,l)),this}rotate(s){return this.premultiply(Jn.makeRotation(-s)),this}translate(s,l){return this.premultiply(Jn.makeTranslation(s,l)),this}makeTranslation(s,l){return s.isVector2?this.set(1,0,s.x,0,1,s.y,0,0,1):this.set(1,0,s,0,1,l,0,0,1),this}makeRotation(s){const l=Math.cos(s),h=Math.sin(s);return this.set(l,-h,0,h,l,0,0,0,1),this}makeScale(s,l){return this.set(s,0,0,0,l,0,0,0,1),this}equals(s){const l=this.elements,h=s.elements;for(let f=0;f<9;f++)if(l[f]!==h[f])return!1;return!0}fromArray(s,l=0){for(let h=0;h<9;h++)this.elements[h]=s[h+l];return this}toArray(s=[],l=0){const h=this.elements;return s[l]=h[0],s[l+1]=h[1],s[l+2]=h[2],s[l+3]=h[3],s[l+4]=h[4],s[l+5]=h[5],s[l+6]=h[6],s[l+7]=h[7],s[l+8]=h[8],s}clone(){return new this.constructor().fromArray(this.elements)}}const Jn=new ts,Kh=new ts().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ze=new ts().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Gs(){const E={enabled:!0,workingColorSpace:Yo,spaces:{},convert:function(f,g,_){return this.enabled===!1||g===_||!g||!_||(this.spaces[g].transfer===_r&&(f.r=Qo(f.r),f.g=Qo(f.g),f.b=Qo(f.b)),this.spaces[g].primaries!==this.spaces[_].primaries&&(f.applyMatrix3(this.spaces[g].toXYZ),f.applyMatrix3(this.spaces[_].fromXYZ)),this.spaces[_].transfer===_r&&(f.r=au(f.r),f.g=au(f.g),f.b=au(f.b))),f},workingToColorSpace:function(f,g){return this.convert(f,this.workingColorSpace,g)},colorSpaceToWorking:function(f,g){return this.convert(f,g,this.workingColorSpace)},getPrimaries:function(f){return this.spaces[f].primaries},getTransfer:function(f){return f===jb?Fg:this.spaces[f].transfer},getToneMappingMode:function(f){return this.spaces[f].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(f,g=this.workingColorSpace){return f.fromArray(this.spaces[g].luminanceCoefficients)},define:function(f){Object.assign(this.spaces,f)},_getMatrix:function(f,g,_){return f.copy(this.spaces[g].toXYZ).multiply(this.spaces[_].fromXYZ)},_getDrawingBufferColorSpace:function(f){return this.spaces[f].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(f=this.workingColorSpace){return this.spaces[f].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(f,g){return Bg("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),E.workingToColorSpace(f,g)},toWorkingColorSpace:function(f,g){return Bg("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),E.colorSpaceToWorking(f,g)}},s=[.64,.33,.3,.6,.15,.06],l=[.2126,.7152,.0722],h=[.3127,.329];return E.define({[Yo]:{primaries:s,whitePoint:h,transfer:Fg,toXYZ:Kh,fromXYZ:ze,luminanceCoefficients:l,workingColorSpaceConfig:{unpackColorSpace:Ao},outputColorSpaceConfig:{drawingBufferColorSpace:Ao}},[Ao]:{primaries:s,whitePoint:h,transfer:_r,toXYZ:Kh,fromXYZ:ze,luminanceCoefficients:l,outputColorSpaceConfig:{drawingBufferColorSpace:Ao}}}),E}const H=Gs();function Qo(E){return E<.04045?E*.0773993808:Math.pow(E*.9478672986+.0521327014,2.4)}function au(E){return E<.0031308?E*12.92:1.055*Math.pow(E,.41666)-.055}let Nn;class zg{static getDataURL(s,l="image/png"){if(/^data:/i.test(s.src)||typeof HTMLCanvasElement=="undefined")return s.src;let h;if(s instanceof HTMLCanvasElement)h=s;else{Nn===void 0&&(Nn=xr("canvas")),Nn.width=s.width,Nn.height=s.height;const f=Nn.getContext("2d");s instanceof ImageData?f.putImageData(s,0,0):f.drawImage(s,0,0,s.width,s.height),h=Nn}return h.toDataURL(l)}static sRGBToLinear(s){if(typeof HTMLImageElement!="undefined"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&s instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&s instanceof ImageBitmap){const l=xr("canvas");l.width=s.width,l.height=s.height;const h=l.getContext("2d");h.drawImage(s,0,0,s.width,s.height);const f=h.getImageData(0,0,s.width,s.height),g=f.data;for(let _=0;_<g.length;_++)g[_]=Qo(g[_]/255)*255;return h.putImageData(f,0,0),l}else if(s.data){const l=s.data.slice(0);for(let h=0;h<l.length;h++)l instanceof Uint8Array||l instanceof Uint8ClampedArray?l[h]=Math.floor(Qo(l[h]/255)*255):l[h]=Qo(l[h]);return{data:l,width:s.width,height:s.height}}else return Mn("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),s}}let w_=0;class Gl{constructor(s=null){this.isSource=!0,Object.defineProperty(this,"id",{value:w_++}),this.uuid=Be(),this.data=s,this.dataReady=!0,this.version=0}getSize(s){const l=this.data;return typeof HTMLVideoElement!="undefined"&&l instanceof HTMLVideoElement?s.set(l.videoWidth,l.videoHeight,0):l instanceof VideoFrame?s.set(l.displayHeight,l.displayWidth,0):l!==null?s.set(l.width,l.height,l.depth||0):s.set(0,0,0),s}set needsUpdate(s){s===!0&&this.version++}toJSON(s){const l=s===void 0||typeof s=="string";if(!l&&s.images[this.uuid]!==void 0)return s.images[this.uuid];const h={uuid:this.uuid,url:""},f=this.data;if(f!==null){let g;if(Array.isArray(f)){g=[];for(let _=0,b=f.length;_<b;_++)f[_].isDataTexture?g.push(Vg(f[_].image)):g.push(Vg(f[_]))}else g=Vg(f);h.url=g}return l||(s.images[this.uuid]=h),h}}function Vg(E){return typeof HTMLImageElement!="undefined"&&E instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&E instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&E instanceof ImageBitmap?zg.getDataURL(E):E.data?{data:Array.from(E.data),width:E.width,height:E.height,type:E.data.constructor.name}:(Mn("Texture: Unable to serialize Texture."),{})}let xn=0;const ea=new ae;class br extends Zo{constructor(s=br.DEFAULT_IMAGE,l=br.DEFAULT_MAPPING,h=ki,f=ki,g=Yn,_=Vs,b=Ri,T=Di,A=br.DEFAULT_ANISOTROPY,R=jb){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:xn++}),this.uuid=Be(),this.name="",this.source=new Gl(s),this.mipmaps=[],this.mapping=l,this.channel=0,this.wrapS=h,this.wrapT=f,this.magFilter=g,this.minFilter=_,this.anisotropy=A,this.format=b,this.internalFormat=null,this.type=T,this.offset=new St(0,0),this.repeat=new St(1,1),this.center=new St(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ts,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=R,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(s&&s.depth&&s.depth>1),this.pmremVersion=0}get width(){return this.source.getSize(ea).x}get height(){return this.source.getSize(ea).y}get depth(){return this.source.getSize(ea).z}get image(){return this.source.data}set image(s=null){this.source.data=s}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(s,l){this.updateRanges.push({start:s,count:l})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(s){return this.name=s.name,this.source=s.source,this.mipmaps=s.mipmaps.slice(0),this.mapping=s.mapping,this.channel=s.channel,this.wrapS=s.wrapS,this.wrapT=s.wrapT,this.magFilter=s.magFilter,this.minFilter=s.minFilter,this.anisotropy=s.anisotropy,this.format=s.format,this.internalFormat=s.internalFormat,this.type=s.type,this.offset.copy(s.offset),this.repeat.copy(s.repeat),this.center.copy(s.center),this.rotation=s.rotation,this.matrixAutoUpdate=s.matrixAutoUpdate,this.matrix.copy(s.matrix),this.generateMipmaps=s.generateMipmaps,this.premultiplyAlpha=s.premultiplyAlpha,this.flipY=s.flipY,this.unpackAlignment=s.unpackAlignment,this.colorSpace=s.colorSpace,this.renderTarget=s.renderTarget,this.isRenderTargetTexture=s.isRenderTargetTexture,this.isArrayTexture=s.isArrayTexture,this.userData=JSON.parse(JSON.stringify(s.userData)),this.needsUpdate=!0,this}setValues(s){for(const l in s){const h=s[l];if(h===void 0){Mn(`Texture.setValues(): parameter '${l}' has value of undefined.`);continue}const f=this[l];if(f===void 0){Mn(`Texture.setValues(): property '${l}' does not exist.`);continue}f&&h&&f.isVector2&&h.isVector2||f&&h&&f.isVector3&&h.isVector3||f&&h&&f.isMatrix3&&h.isMatrix3?f.copy(h):this[l]=h}}toJSON(s){const l=s===void 0||typeof s=="string";if(!l&&s.textures[this.uuid]!==void 0)return s.textures[this.uuid];const h={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(s).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&&(h.userData=this.userData),l||(s.textures[this.uuid]=h),h}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(s){if(this.mapping!==_h)return s;if(s.applyMatrix3(this.matrix),s.x<0||s.x>1)switch(this.wrapS){case Ea:s.x=s.x-Math.floor(s.x);break;case ki:s.x=s.x<0?0:1;break;case Ca:Math.abs(Math.floor(s.x)%2)===1?s.x=Math.ceil(s.x)-s.x:s.x=s.x-Math.floor(s.x);break}if(s.y<0||s.y>1)switch(this.wrapT){case Ea:s.y=s.y-Math.floor(s.y);break;case ki:s.y=s.y<0?0:1;break;case Ca:Math.abs(Math.floor(s.y)%2)===1?s.y=Math.ceil(s.y)-s.y:s.y=s.y-Math.floor(s.y);break}return this.flipY&&(s.y=1-s.y),s}set needsUpdate(s){s===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(s){s===!0&&this.pmremVersion++}}br.DEFAULT_IMAGE=null,br.DEFAULT_MAPPING=_h,br.DEFAULT_ANISOTROPY=1;class as{constructor(s=0,l=0,h=0,f=1){as.prototype.isVector4=!0,this.x=s,this.y=l,this.z=h,this.w=f}get width(){return this.z}set width(s){this.z=s}get height(){return this.w}set height(s){this.w=s}set(s,l,h,f){return this.x=s,this.y=l,this.z=h,this.w=f,this}setScalar(s){return this.x=s,this.y=s,this.z=s,this.w=s,this}setX(s){return this.x=s,this}setY(s){return this.y=s,this}setZ(s){return this.z=s,this}setW(s){return this.w=s,this}setComponent(s,l){switch(s){case 0:this.x=l;break;case 1:this.y=l;break;case 2:this.z=l;break;case 3:this.w=l;break;default:throw new Error("index is out of range: "+s)}return this}getComponent(s){switch(s){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: "+s)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(s){return this.x=s.x,this.y=s.y,this.z=s.z,this.w=s.w!==void 0?s.w:1,this}add(s){return this.x+=s.x,this.y+=s.y,this.z+=s.z,this.w+=s.w,this}addScalar(s){return this.x+=s,this.y+=s,this.z+=s,this.w+=s,this}addVectors(s,l){return this.x=s.x+l.x,this.y=s.y+l.y,this.z=s.z+l.z,this.w=s.w+l.w,this}addScaledVector(s,l){return this.x+=s.x*l,this.y+=s.y*l,this.z+=s.z*l,this.w+=s.w*l,this}sub(s){return this.x-=s.x,this.y-=s.y,this.z-=s.z,this.w-=s.w,this}subScalar(s){return this.x-=s,this.y-=s,this.z-=s,this.w-=s,this}subVectors(s,l){return this.x=s.x-l.x,this.y=s.y-l.y,this.z=s.z-l.z,this.w=s.w-l.w,this}multiply(s){return this.x*=s.x,this.y*=s.y,this.z*=s.z,this.w*=s.w,this}multiplyScalar(s){return this.x*=s,this.y*=s,this.z*=s,this.w*=s,this}applyMatrix4(s){const l=this.x,h=this.y,f=this.z,g=this.w,_=s.elements;return this.x=_[0]*l+_[4]*h+_[8]*f+_[12]*g,this.y=_[1]*l+_[5]*h+_[9]*f+_[13]*g,this.z=_[2]*l+_[6]*h+_[10]*f+_[14]*g,this.w=_[3]*l+_[7]*h+_[11]*f+_[15]*g,this}divide(s){return this.x/=s.x,this.y/=s.y,this.z/=s.z,this.w/=s.w,this}divideScalar(s){return this.multiplyScalar(1/s)}setAxisAngleFromQuaternion(s){this.w=2*Math.acos(s.w);const l=Math.sqrt(1-s.w*s.w);return l<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=s.x/l,this.y=s.y/l,this.z=s.z/l),this}setAxisAngleFromRotationMatrix(s){let l,h,f,g;const T=s.elements,A=T[0],R=T[4],P=T[8],L=T[1],D=T[5],O=T[9],W=T[2],Z=T[6],Y=T[10];if(Math.abs(R-L)<.01&&Math.abs(P-W)<.01&&Math.abs(O-Z)<.01){if(Math.abs(R+L)<.1&&Math.abs(P+W)<.1&&Math.abs(O+Z)<.1&&Math.abs(A+D+Y-3)<.1)return this.set(1,0,0,0),this;l=Math.PI;const se=(A+1)/2,de=(D+1)/2,ke=(Y+1)/2,$e=(R+L)/4,et=(P+W)/4,qe=(O+Z)/4;return se>de&&se>ke?se<.01?(h=0,f=.707106781,g=.707106781):(h=Math.sqrt(se),f=$e/h,g=et/h):de>ke?de<.01?(h=.707106781,f=0,g=.707106781):(f=Math.sqrt(de),h=$e/f,g=qe/f):ke<.01?(h=.707106781,f=.707106781,g=0):(g=Math.sqrt(ke),h=et/g,f=qe/g),this.set(h,f,g,l),this}let ie=Math.sqrt((Z-O)*(Z-O)+(P-W)*(P-W)+(L-R)*(L-R));return Math.abs(ie)<.001&&(ie=1),this.x=(Z-O)/ie,this.y=(P-W)/ie,this.z=(L-R)/ie,this.w=Math.acos((A+D+Y-1)/2),this}setFromMatrixPosition(s){const l=s.elements;return this.x=l[12],this.y=l[13],this.z=l[14],this.w=l[15],this}min(s){return this.x=Math.min(this.x,s.x),this.y=Math.min(this.y,s.y),this.z=Math.min(this.z,s.z),this.w=Math.min(this.w,s.w),this}max(s){return this.x=Math.max(this.x,s.x),this.y=Math.max(this.y,s.y),this.z=Math.max(this.z,s.z),this.w=Math.max(this.w,s.w),this}clamp(s,l){return this.x=Ut(this.x,s.x,l.x),this.y=Ut(this.y,s.y,l.y),this.z=Ut(this.z,s.z,l.z),this.w=Ut(this.w,s.w,l.w),this}clampScalar(s,l){return this.x=Ut(this.x,s,l),this.y=Ut(this.y,s,l),this.z=Ut(this.z,s,l),this.w=Ut(this.w,s,l),this}clampLength(s,l){const h=this.length();return this.divideScalar(h||1).multiplyScalar(Ut(h,s,l))}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(s){return this.x*s.x+this.y*s.y+this.z*s.z+this.w*s.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(s){return this.normalize().multiplyScalar(s)}lerp(s,l){return this.x+=(s.x-this.x)*l,this.y+=(s.y-this.y)*l,this.z+=(s.z-this.z)*l,this.w+=(s.w-this.w)*l,this}lerpVectors(s,l,h){return this.x=s.x+(l.x-s.x)*h,this.y=s.y+(l.y-s.y)*h,this.z=s.z+(l.z-s.z)*h,this.w=s.w+(l.w-s.w)*h,this}equals(s){return s.x===this.x&&s.y===this.y&&s.z===this.z&&s.w===this.w}fromArray(s,l=0){return this.x=s[l],this.y=s[l+1],this.z=s[l+2],this.w=s[l+3],this}toArray(s=[],l=0){return s[l]=this.x,s[l+1]=this.y,s[l+2]=this.z,s[l+3]=this.w,s}fromBufferAttribute(s,l){return this.x=s.getX(l),this.y=s.getY(l),this.z=s.getZ(l),this.w=s.getW(l),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 bA extends null{constructor(s=1,l=1,h={}){super(),h=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Yn,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1},h),this.isRenderTarget=!0,this.width=s,this.height=l,this.depth=h.depth,this.scissor=new as(0,0,s,l),this.scissorTest=!1,this.viewport=new as(0,0,s,l);const f={width:s,height:l,depth:h.depth},g=new br(f);this.textures=[];const _=h.count;for(let b=0;b<_;b++)this.textures[b]=g.clone(),this.textures[b].isRenderTargetTexture=!0,this.textures[b].renderTarget=this;this._setTextureOptions(h),this.depthBuffer=h.depthBuffer,this.stencilBuffer=h.stencilBuffer,this.resolveDepthBuffer=h.resolveDepthBuffer,this.resolveStencilBuffer=h.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=h.depthTexture,this.samples=h.samples,this.multiview=h.multiview}_setTextureOptions(s={}){const l={minFilter:Yn,generateMipmaps:!1,flipY:!1,internalFormat:null};s.mapping!==void 0&&(l.mapping=s.mapping),s.wrapS!==void 0&&(l.wrapS=s.wrapS),s.wrapT!==void 0&&(l.wrapT=s.wrapT),s.wrapR!==void 0&&(l.wrapR=s.wrapR),s.magFilter!==void 0&&(l.magFilter=s.magFilter),s.minFilter!==void 0&&(l.minFilter=s.minFilter),s.format!==void 0&&(l.format=s.format),s.type!==void 0&&(l.type=s.type),s.anisotropy!==void 0&&(l.anisotropy=s.anisotropy),s.colorSpace!==void 0&&(l.colorSpace=s.colorSpace),s.flipY!==void 0&&(l.flipY=s.flipY),s.generateMipmaps!==void 0&&(l.generateMipmaps=s.generateMipmaps),s.internalFormat!==void 0&&(l.internalFormat=s.internalFormat);for(let h=0;h<this.textures.length;h++)this.textures[h].setValues(l)}get texture(){return this.textures[0]}set texture(s){this.textures[0]=s}set depthTexture(s){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),s!==null&&(s.renderTarget=this),this._depthTexture=s}get depthTexture(){return this._depthTexture}setSize(s,l,h=1){if(this.width!==s||this.height!==l||this.depth!==h){this.width=s,this.height=l,this.depth=h;for(let f=0,g=this.textures.length;f<g;f++)this.textures[f].image.width=s,this.textures[f].image.height=l,this.textures[f].image.depth=h,this.textures[f].isData3DTexture!==!0&&(this.textures[f].isArrayTexture=this.textures[f].image.depth>1);this.dispose()}this.viewport.set(0,0,s,l),this.scissor.set(0,0,s,l)}clone(){return new this.constructor().copy(this)}copy(s){this.width=s.width,this.height=s.height,this.depth=s.depth,this.scissor.copy(s.scissor),this.scissorTest=s.scissorTest,this.viewport.copy(s.viewport),this.textures.length=0;for(let l=0,h=s.textures.length;l<h;l++){this.textures[l]=s.textures[l].clone(),this.textures[l].isRenderTargetTexture=!0,this.textures[l].renderTarget=this;const f=Object.assign({},s.textures[l].image);this.textures[l].source=new Gl(f)}return this.depthBuffer=s.depthBuffer,this.stencilBuffer=s.stencilBuffer,this.resolveDepthBuffer=s.resolveDepthBuffer,this.resolveStencilBuffer=s.resolveStencilBuffer,s.depthTexture!==null&&(this.depthTexture=s.depthTexture.clone()),this.samples=s.samples,this}dispose(){this.dispatchEvent({type:"dispose"})}}class SA extends null{constructor(s=1,l=1,h={}){super(s,l,h),this.isWebGLRenderTarget=!0}}class lu extends null{constructor(s=null,l=1,h=1,f=1){super(null),this.isDataArrayTexture=!0,this.image={data:s,width:l,height:h,depth:f},this.magFilter=ni,this.minFilter=ni,this.wrapR=ki,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(s){this.layerUpdates.add(s)}clearLayerUpdates(){this.layerUpdates.clear()}}class A_ extends null{constructor(s=1,l=1,h=1,f={}){super(s,l,f),this.isWebGLArrayRenderTarget=!0,this.depth=h,this.texture=new lu(null,s,l,h),this._setTextureOptions(f),this.texture.isRenderTargetTexture=!0}}class E_ extends null{constructor(s=null,l=1,h=1,f=1){super(null),this.isData3DTexture=!0,this.image={data:s,width:l,height:h,depth:f},this.magFilter=ni,this.minFilter=ni,this.wrapR=ki,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class C_ extends null{constructor(s=1,l=1,h=1,f={}){super(s,l,f),this.isWebGL3DRenderTarget=!0,this.depth=h,this.texture=new E_(null,s,l,h),this._setTextureOptions(f),this.texture.isRenderTargetTexture=!0}}class fi{constructor(s=new ae(1/0,1/0,1/0),l=new ae(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=s,this.max=l}set(s,l){return this.min.copy(s),this.max.copy(l),this}setFromArray(s){this.makeEmpty();for(let l=0,h=s.length;l<h;l+=3)this.expandByPoint(Ws.fromArray(s,l));return this}setFromBufferAttribute(s){this.makeEmpty();for(let l=0,h=s.count;l<h;l++)this.expandByPoint(Ws.fromBufferAttribute(s,l));return this}setFromPoints(s){this.makeEmpty();for(let l=0,h=s.length;l<h;l++)this.expandByPoint(s[l]);return this}setFromCenterAndSize(s,l){const h=Ws.copy(l).multiplyScalar(.5);return this.min.copy(s).sub(h),this.max.copy(s).add(h),this}setFromObject(s,l=!1){return this.makeEmpty(),this.expandByObject(s,l)}clone(){return new this.constructor().copy(this)}copy(s){return this.min.copy(s.min),this.max.copy(s.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(s){return this.isEmpty()?s.set(0,0,0):s.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(s){return this.isEmpty()?s.set(0,0,0):s.subVectors(this.max,this.min)}expandByPoint(s){return this.min.min(s),this.max.max(s),this}expandByVector(s){return this.min.sub(s),this.max.add(s),this}expandByScalar(s){return this.min.addScalar(-s),this.max.addScalar(s),this}expandByObject(s,l=!1){s.updateWorldMatrix(!1,!1);const h=s.geometry;if(h!==void 0){const g=h.getAttribute("position");if(l===!0&&g!==void 0&&s.isInstancedMesh!==!0)for(let _=0,b=g.count;_<b;_++)s.isMesh===!0?s.getVertexPosition(_,Ws):Ws.fromBufferAttribute(g,_),Ws.applyMatrix4(s.matrixWorld),this.expandByPoint(Ws);else s.boundingBox!==void 0?(s.boundingBox===null&&s.computeBoundingBox(),qr.copy(s.boundingBox)):(h.boundingBox===null&&h.computeBoundingBox(),qr.copy(h.boundingBox)),qr.applyMatrix4(s.matrixWorld),this.union(qr)}const f=s.children;for(let g=0,_=f.length;g<_;g++)this.expandByObject(f[g],l);return this}containsPoint(s){return s.x>=this.min.x&&s.x<=this.max.x&&s.y>=this.min.y&&s.y<=this.max.y&&s.z>=this.min.z&&s.z<=this.max.z}containsBox(s){return this.min.x<=s.min.x&&s.max.x<=this.max.x&&this.min.y<=s.min.y&&s.max.y<=this.max.y&&this.min.z<=s.min.z&&s.max.z<=this.max.z}getParameter(s,l){return l.set((s.x-this.min.x)/(this.max.x-this.min.x),(s.y-this.min.y)/(this.max.y-this.min.y),(s.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(s){return s.max.x>=this.min.x&&s.min.x<=this.max.x&&s.max.y>=this.min.y&&s.min.y<=this.max.y&&s.max.z>=this.min.z&&s.min.z<=this.max.z}intersectsSphere(s){return this.clampPoint(s.center,Ws),Ws.distanceToSquared(s.center)<=s.radius*s.radius}intersectsPlane(s){let l,h;return s.normal.x>0?(l=s.normal.x*this.min.x,h=s.normal.x*this.max.x):(l=s.normal.x*this.max.x,h=s.normal.x*this.min.x),s.normal.y>0?(l+=s.normal.y*this.min.y,h+=s.normal.y*this.max.y):(l+=s.normal.y*this.max.y,h+=s.normal.y*this.min.y),s.normal.z>0?(l+=s.normal.z*this.min.z,h+=s.normal.z*this.max.z):(l+=s.normal.z*this.max.z,h+=s.normal.z*this.min.z),l<=-s.constant&&h>=-s.constant}intersectsTriangle(s){if(this.isEmpty())return!1;this.getCenter(Fr),uu.subVectors(this.max,Fr),al.subVectors(s.a,Fr),hf.subVectors(s.b,Fr),Wl.subVectors(s.c,Fr),cu.subVectors(hf,al),ns.subVectors(Wl,hf),Dr.subVectors(al,Wl);let l=[0,-cu.z,cu.y,0,-ns.z,ns.y,0,-Dr.z,Dr.y,cu.z,0,-cu.x,ns.z,0,-ns.x,Dr.z,0,-Dr.x,-cu.y,cu.x,0,-ns.y,ns.x,0,-Dr.y,Dr.x,0];return!Hl(l,al,hf,Wl,uu)||(l=[1,0,0,0,1,0,0,0,1],!Hl(l,al,hf,Wl,uu))?!1:(ll.crossVectors(cu,ns),l=[ll.x,ll.y,ll.z],Hl(l,al,hf,Wl,uu))}clampPoint(s,l){return l.copy(s).clamp(this.min,this.max)}distanceToPoint(s){return this.clampPoint(s,Ws).distanceTo(s)}getBoundingSphere(s){return this.isEmpty()?s.makeEmpty():(this.getCenter(s.center),s.radius=this.getSize(Ws).length()*.5),s}intersect(s){return this.min.max(s.min),this.max.min(s.max),this.isEmpty()&&this.makeEmpty(),this}union(s){return this.min.min(s.min),this.max.max(s.max),this}applyMatrix4(s){return this.isEmpty()?this:(gn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(s),gn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(s),gn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(s),gn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(s),gn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(s),gn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(s),gn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(s),gn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(s),this.setFromPoints(gn),this)}translate(s){return this.min.add(s),this.max.add(s),this}equals(s){return s.min.equals(this.min)&&s.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(s){return this.min.fromArray(s.min),this.max.fromArray(s.max),this}}const gn=[new ae,new ae,new ae,new ae,new ae,new ae,new ae,new ae],Ws=new ae,qr=new fi,al=new ae,hf=new ae,Wl=new ae,cu=new ae,ns=new ae,Dr=new ae,Fr=new ae,uu=new ae,ll=new ae,Eo=new ae;function Hl(E,s,l,h,f){for(let g=0,_=E.length-3;g<=_;g+=3){Eo.fromArray(E,g);const b=f.x*Math.abs(Eo.x)+f.y*Math.abs(Eo.y)+f.z*Math.abs(Eo.z),T=s.dot(Eo),A=l.dot(Eo),R=h.dot(Eo);if(Math.max(-Math.max(T,A,R),Math.min(T,A,R))>b)return!1}return!0}const $l=new fi,Co=new ae,cl=new ae;class Ps{constructor(s=new ae,l=-1){this.isSphere=!0,this.center=s,this.radius=l}set(s,l){return this.center.copy(s),this.radius=l,this}setFromPoints(s,l){const h=this.center;l!==void 0?h.copy(l):$l.setFromPoints(s).getCenter(h);let f=0;for(let g=0,_=s.length;g<_;g++)f=Math.max(f,h.distanceToSquared(s[g]));return this.radius=Math.sqrt(f),this}copy(s){return this.center.copy(s.center),this.radius=s.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(s){return s.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(s){return s.distanceTo(this.center)-this.radius}intersectsSphere(s){const l=this.radius+s.radius;return s.center.distanceToSquared(this.center)<=l*l}intersectsBox(s){return s.intersectsSphere(this)}intersectsPlane(s){return Math.abs(s.distanceToPoint(this.center))<=this.radius}clampPoint(s,l){const h=this.center.distanceToSquared(s);return l.copy(s),h>this.radius*this.radius&&(l.sub(this.center).normalize(),l.multiplyScalar(this.radius).add(this.center)),l}getBoundingBox(s){return this.isEmpty()?(s.makeEmpty(),s):(s.set(this.center,this.center),s.expandByScalar(this.radius),s)}applyMatrix4(s){return this.center.applyMatrix4(s),this.radius=this.radius*s.getMaxScaleOnAxis(),this}translate(s){return this.center.add(s),this}expandByPoint(s){if(this.isEmpty())return this.center.copy(s),this.radius=0,this;Co.subVectors(s,this.center);const l=Co.lengthSq();if(l>this.radius*this.radius){const h=Math.sqrt(l),f=(h-this.radius)*.5;this.center.addScaledVector(Co,f/h),this.radius+=f}return this}union(s){return s.isEmpty()?this:this.isEmpty()?(this.copy(s),this):(this.center.equals(s.center)===!0?this.radius=Math.max(this.radius,s.radius):(cl.subVectors(s.center,this.center).setLength(s.radius),this.expandByPoint(Co.copy(s.center).add(cl)),this.expandByPoint(Co.copy(s.center).sub(cl))),this)}equals(s){return s.center.equals(this.center)&&s.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(s){return this.radius=s.radius,this.center.fromArray(s.center),this}}const Ro=new ae,Jh=new ae,Na=new ae,Pa=new ae,Gg=new ae,ql=new ae,df=new ae;class As{constructor(s=new ae,l=new ae(0,0,-1)){this.origin=s,this.direction=l}set(s,l){return this.origin.copy(s),this.direction.copy(l),this}copy(s){return this.origin.copy(s.origin),this.direction.copy(s.direction),this}at(s,l){return l.copy(this.origin).addScaledVector(this.direction,s)}lookAt(s){return this.direction.copy(s).sub(this.origin).normalize(),this}recast(s){return this.origin.copy(this.at(s,Ro)),this}closestPointToPoint(s,l){l.subVectors(s,this.origin);const h=l.dot(this.direction);return h<0?l.copy(this.origin):l.copy(this.origin).addScaledVector(this.direction,h)}distanceToPoint(s){return Math.sqrt(this.distanceSqToPoint(s))}distanceSqToPoint(s){const l=Ro.subVectors(s,this.origin).dot(this.direction);return l<0?this.origin.distanceToSquared(s):(Ro.copy(this.origin).addScaledVector(this.direction,l),Ro.distanceToSquared(s))}distanceSqToSegment(s,l,h,f){Jh.copy(s).add(l).multiplyScalar(.5),Na.copy(l).sub(s).normalize(),Pa.copy(this.origin).sub(Jh);const g=s.distanceTo(l)*.5,_=-this.direction.dot(Na),b=Pa.dot(this.direction),T=-Pa.dot(Na),A=Pa.lengthSq(),R=Math.abs(1-_*_);let P,L,D,O;if(R>0)if(P=_*T-b,L=_*b-T,O=g*R,P>=0)if(L>=-O)if(L<=O){const W=1/R;P*=W,L*=W,D=P*(P+_*L+2*b)+L*(_*P+L+2*T)+A}else L=g,P=Math.max(0,-(_*L+b)),D=-P*P+L*(L+2*T)+A;else L=-g,P=Math.max(0,-(_*L+b)),D=-P*P+L*(L+2*T)+A;else L<=-O?(P=Math.max(0,-(-_*g+b)),L=P>0?-g:Math.min(Math.max(-g,-T),g),D=-P*P+L*(L+2*T)+A):L<=O?(P=0,L=Math.min(Math.max(-g,-T),g),D=L*(L+2*T)+A):(P=Math.max(0,-(_*g+b)),L=P>0?g:Math.min(Math.max(-g,-T),g),D=-P*P+L*(L+2*T)+A);else L=_>0?-g:g,P=Math.max(0,-(_*L+b)),D=-P*P+L*(L+2*T)+A;return h&&h.copy(this.origin).addScaledVector(this.direction,P),f&&f.copy(Jh).addScaledVector(Na,L),D}intersectSphere(s,l){Ro.subVectors(s.center,this.origin);const h=Ro.dot(this.direction),f=Ro.dot(Ro)-h*h,g=s.radius*s.radius;if(f>g)return null;const _=Math.sqrt(g-f),b=h-_,T=h+_;return T<0?null:b<0?this.at(T,l):this.at(b,l)}intersectsSphere(s){return s.radius<0?!1:this.distanceSqToPoint(s.center)<=s.radius*s.radius}distanceToPlane(s){const l=s.normal.dot(this.direction);if(l===0)return s.distanceToPoint(this.origin)===0?0:null;const h=-(this.origin.dot(s.normal)+s.constant)/l;return h>=0?h:null}intersectPlane(s,l){const h=this.distanceToPlane(s);return h===null?null:this.at(h,l)}intersectsPlane(s){const l=s.distanceToPoint(this.origin);return l===0||s.normal.dot(this.direction)*l<0}intersectBox(s,l){let h,f,g,_,b,T;const A=1/this.direction.x,R=1/this.direction.y,P=1/this.direction.z,L=this.origin;return A>=0?(h=(s.min.x-L.x)*A,f=(s.max.x-L.x)*A):(h=(s.max.x-L.x)*A,f=(s.min.x-L.x)*A),R>=0?(g=(s.min.y-L.y)*R,_=(s.max.y-L.y)*R):(g=(s.max.y-L.y)*R,_=(s.min.y-L.y)*R),h>_||g>f||((g>h||isNaN(h))&&(h=g),(_<f||isNaN(f))&&(f=_),P>=0?(b=(s.min.z-L.z)*P,T=(s.max.z-L.z)*P):(b=(s.max.z-L.z)*P,T=(s.min.z-L.z)*P),h>T||b>f)||((b>h||h!==h)&&(h=b),(T<f||f!==f)&&(f=T),f<0)?null:this.at(h>=0?h:f,l)}intersectsBox(s){return this.intersectBox(s,Ro)!==null}intersectTriangle(s,l,h,f,g){Gg.subVectors(l,s),ql.subVectors(h,s),df.crossVectors(Gg,ql);let _=this.direction.dot(df),b;if(_>0){if(f)return null;b=1}else if(_<0)b=-1,_=-_;else return null;Pa.subVectors(this.origin,s);const T=b*this.direction.dot(ql.crossVectors(Pa,ql));if(T<0)return null;const A=b*this.direction.dot(Gg.cross(Pa));if(A<0||T+A>_)return null;const R=-b*Pa.dot(df);return R<0?null:this.at(R/_,g)}applyMatrix4(s){return this.origin.applyMatrix4(s),this.direction.transformDirection(s),this}equals(s){return s.origin.equals(this.origin)&&s.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Dn{constructor(s,l,h,f,g,_,b,T,A,R,P,L,D,O,W,Z){Dn.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],s!==void 0&&this.set(s,l,h,f,g,_,b,T,A,R,P,L,D,O,W,Z)}set(s,l,h,f,g,_,b,T,A,R,P,L,D,O,W,Z){const Y=this.elements;return Y[0]=s,Y[4]=l,Y[8]=h,Y[12]=f,Y[1]=g,Y[5]=_,Y[9]=b,Y[13]=T,Y[2]=A,Y[6]=R,Y[10]=P,Y[14]=L,Y[3]=D,Y[7]=O,Y[11]=W,Y[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 Dn().fromArray(this.elements)}copy(s){const l=this.elements,h=s.elements;return l[0]=h[0],l[1]=h[1],l[2]=h[2],l[3]=h[3],l[4]=h[4],l[5]=h[5],l[6]=h[6],l[7]=h[7],l[8]=h[8],l[9]=h[9],l[10]=h[10],l[11]=h[11],l[12]=h[12],l[13]=h[13],l[14]=h[14],l[15]=h[15],this}copyPosition(s){const l=this.elements,h=s.elements;return l[12]=h[12],l[13]=h[13],l[14]=h[14],this}setFromMatrix3(s){const l=s.elements;return this.set(l[0],l[3],l[6],0,l[1],l[4],l[7],0,l[2],l[5],l[8],0,0,0,0,1),this}extractBasis(s,l,h){return s.setFromMatrixColumn(this,0),l.setFromMatrixColumn(this,1),h.setFromMatrixColumn(this,2),this}makeBasis(s,l,h){return this.set(s.x,l.x,h.x,0,s.y,l.y,h.y,0,s.z,l.z,h.z,0,0,0,0,1),this}extractRotation(s){const l=this.elements,h=s.elements,f=1/Xl.setFromMatrixColumn(s,0).length(),g=1/Xl.setFromMatrixColumn(s,1).length(),_=1/Xl.setFromMatrixColumn(s,2).length();return l[0]=h[0]*f,l[1]=h[1]*f,l[2]=h[2]*f,l[3]=0,l[4]=h[4]*g,l[5]=h[5]*g,l[6]=h[6]*g,l[7]=0,l[8]=h[8]*_,l[9]=h[9]*_,l[10]=h[10]*_,l[11]=0,l[12]=0,l[13]=0,l[14]=0,l[15]=1,this}makeRotationFromEuler(s){const l=this.elements,h=s.x,f=s.y,g=s.z,_=Math.cos(h),b=Math.sin(h),T=Math.cos(f),A=Math.sin(f),R=Math.cos(g),P=Math.sin(g);if(s.order==="XYZ"){const L=_*R,D=_*P,O=b*R,W=b*P;l[0]=T*R,l[4]=-T*P,l[8]=A,l[1]=D+O*A,l[5]=L-W*A,l[9]=-b*T,l[2]=W-L*A,l[6]=O+D*A,l[10]=_*T}else if(s.order==="YXZ"){const L=T*R,D=T*P,O=A*R,W=A*P;l[0]=L+W*b,l[4]=O*b-D,l[8]=_*A,l[1]=_*P,l[5]=_*R,l[9]=-b,l[2]=D*b-O,l[6]=W+L*b,l[10]=_*T}else if(s.order==="ZXY"){const L=T*R,D=T*P,O=A*R,W=A*P;l[0]=L-W*b,l[4]=-_*P,l[8]=O+D*b,l[1]=D+O*b,l[5]=_*R,l[9]=W-L*b,l[2]=-_*A,l[6]=b,l[10]=_*T}else if(s.order==="ZYX"){const L=_*R,D=_*P,O=b*R,W=b*P;l[0]=T*R,l[4]=O*A-D,l[8]=L*A+W,l[1]=T*P,l[5]=W*A+L,l[9]=D*A-O,l[2]=-A,l[6]=b*T,l[10]=_*T}else if(s.order==="YZX"){const L=_*T,D=_*A,O=b*T,W=b*A;l[0]=T*R,l[4]=W-L*P,l[8]=O*P+D,l[1]=P,l[5]=_*R,l[9]=-b*R,l[2]=-A*R,l[6]=D*P+O,l[10]=L-W*P}else if(s.order==="XZY"){const L=_*T,D=_*A,O=b*T,W=b*A;l[0]=T*R,l[4]=-P,l[8]=A*R,l[1]=L*P+W,l[5]=_*R,l[9]=D*P-O,l[2]=O*P-D,l[6]=b*R,l[10]=W*P+L}return l[3]=0,l[7]=0,l[11]=0,l[12]=0,l[13]=0,l[14]=0,l[15]=1,this}makeRotationFromQuaternion(s){return this.compose(jl,s,Wg)}lookAt(s,l,h){const f=this.elements;return nr.subVectors(s,l),nr.lengthSq()===0&&(nr.z=1),nr.normalize(),ta.crossVectors(h,nr),ta.lengthSq()===0&&(Math.abs(h.z)===1?nr.x+=1e-4:nr.z+=1e-4,nr.normalize(),ta.crossVectors(h,nr)),ta.normalize(),Qh.crossVectors(nr,ta),f[0]=ta.x,f[4]=Qh.x,f[8]=nr.x,f[1]=ta.y,f[5]=Qh.y,f[9]=nr.y,f[2]=ta.z,f[6]=Qh.z,f[10]=nr.z,this}multiply(s){return this.multiplyMatrices(this,s)}premultiply(s){return this.multiplyMatrices(s,this)}multiplyMatrices(s,l){const h=s.elements,f=l.elements,g=this.elements,_=h[0],b=h[4],T=h[8],A=h[12],R=h[1],P=h[5],L=h[9],D=h[13],O=h[2],W=h[6],Z=h[10],Y=h[14],ie=h[3],se=h[7],de=h[11],ke=h[15],$e=f[0],et=f[4],qe=f[8],xt=f[12],Et=f[1],_n=f[5],ei=f[9],ii=f[13],zi=f[2],Fi=f[6],Zs=f[10],dr=f[14],ca=f[3],gs=f[7],Os=f[11],us=f[15];return g[0]=_*$e+b*Et+T*zi+A*ca,g[4]=_*et+b*_n+T*Fi+A*gs,g[8]=_*qe+b*ei+T*Zs+A*Os,g[12]=_*xt+b*ii+T*dr+A*us,g[1]=R*$e+P*Et+L*zi+D*ca,g[5]=R*et+P*_n+L*Fi+D*gs,g[9]=R*qe+P*ei+L*Zs+D*Os,g[13]=R*xt+P*ii+L*dr+D*us,g[2]=O*$e+W*Et+Z*zi+Y*ca,g[6]=O*et+W*_n+Z*Fi+Y*gs,g[10]=O*qe+W*ei+Z*Zs+Y*Os,g[14]=O*xt+W*ii+Z*dr+Y*us,g[3]=ie*$e+se*Et+de*zi+ke*ca,g[7]=ie*et+se*_n+de*Fi+ke*gs,g[11]=ie*qe+se*ei+de*Zs+ke*Os,g[15]=ie*xt+se*ii+de*dr+ke*us,this}multiplyScalar(s){const l=this.elements;return l[0]*=s,l[4]*=s,l[8]*=s,l[12]*=s,l[1]*=s,l[5]*=s,l[9]*=s,l[13]*=s,l[2]*=s,l[6]*=s,l[10]*=s,l[14]*=s,l[3]*=s,l[7]*=s,l[11]*=s,l[15]*=s,this}determinant(){const s=this.elements,l=s[0],h=s[4],f=s[8],g=s[12],_=s[1],b=s[5],T=s[9],A=s[13],R=s[2],P=s[6],L=s[10],D=s[14],O=s[3],W=s[7],Z=s[11],Y=s[15];return O*(+g*T*P-f*A*P-g*b*L+h*A*L+f*b*D-h*T*D)+W*(+l*T*D-l*A*L+g*_*L-f*_*D+f*A*R-g*T*R)+Z*(+l*A*P-l*b*D-g*_*P+h*_*D+g*b*R-h*A*R)+Y*(-f*b*R-l*T*P+l*b*L+f*_*P-h*_*L+h*T*R)}transpose(){const s=this.elements;let l;return l=s[1],s[1]=s[4],s[4]=l,l=s[2],s[2]=s[8],s[8]=l,l=s[6],s[6]=s[9],s[9]=l,l=s[3],s[3]=s[12],s[12]=l,l=s[7],s[7]=s[13],s[13]=l,l=s[11],s[11]=s[14],s[14]=l,this}setPosition(s,l,h){const f=this.elements;return s.isVector3?(f[12]=s.x,f[13]=s.y,f[14]=s.z):(f[12]=s,f[13]=l,f[14]=h),this}invert(){const s=this.elements,l=s[0],h=s[1],f=s[2],g=s[3],_=s[4],b=s[5],T=s[6],A=s[7],R=s[8],P=s[9],L=s[10],D=s[11],O=s[12],W=s[13],Z=s[14],Y=s[15],ie=P*Z*A-W*L*A+W*T*D-b*Z*D-P*T*Y+b*L*Y,se=O*L*A-R*Z*A-O*T*D+_*Z*D+R*T*Y-_*L*Y,de=R*W*A-O*P*A+O*b*D-_*W*D-R*b*Y+_*P*Y,ke=O*P*T-R*W*T-O*b*L+_*W*L+R*b*Z-_*P*Z,$e=l*ie+h*se+f*de+g*ke;if($e===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const et=1/$e;return s[0]=ie*et,s[1]=(W*L*g-P*Z*g-W*f*D+h*Z*D+P*f*Y-h*L*Y)*et,s[2]=(b*Z*g-W*T*g+W*f*A-h*Z*A-b*f*Y+h*T*Y)*et,s[3]=(P*T*g-b*L*g-P*f*A+h*L*A+b*f*D-h*T*D)*et,s[4]=se*et,s[5]=(R*Z*g-O*L*g+O*f*D-l*Z*D-R*f*Y+l*L*Y)*et,s[6]=(O*T*g-_*Z*g-O*f*A+l*Z*A+_*f*Y-l*T*Y)*et,s[7]=(_*L*g-R*T*g+R*f*A-l*L*A-_*f*D+l*T*D)*et,s[8]=de*et,s[9]=(O*P*g-R*W*g-O*h*D+l*W*D+R*h*Y-l*P*Y)*et,s[10]=(_*W*g-O*b*g+O*h*A-l*W*A-_*h*Y+l*b*Y)*et,s[11]=(R*b*g-_*P*g-R*h*A+l*P*A+_*h*D-l*b*D)*et,s[12]=ke*et,s[13]=(R*W*f-O*P*f+O*h*L-l*W*L-R*h*Z+l*P*Z)*et,s[14]=(O*b*f-_*W*f-O*h*T+l*W*T+_*h*Z-l*b*Z)*et,s[15]=(_*P*f-R*b*f+R*h*T-l*P*T-_*h*L+l*b*L)*et,this}scale(s){const l=this.elements,h=s.x,f=s.y,g=s.z;return l[0]*=h,l[4]*=f,l[8]*=g,l[1]*=h,l[5]*=f,l[9]*=g,l[2]*=h,l[6]*=f,l[10]*=g,l[3]*=h,l[7]*=f,l[11]*=g,this}getMaxScaleOnAxis(){const s=this.elements,l=s[0]*s[0]+s[1]*s[1]+s[2]*s[2],h=s[4]*s[4]+s[5]*s[5]+s[6]*s[6],f=s[8]*s[8]+s[9]*s[9]+s[10]*s[10];return Math.sqrt(Math.max(l,h,f))}makeTranslation(s,l,h){return s.isVector3?this.set(1,0,0,s.x,0,1,0,s.y,0,0,1,s.z,0,0,0,1):this.set(1,0,0,s,0,1,0,l,0,0,1,h,0,0,0,1),this}makeRotationX(s){const l=Math.cos(s),h=Math.sin(s);return this.set(1,0,0,0,0,l,-h,0,0,h,l,0,0,0,0,1),this}makeRotationY(s){const l=Math.cos(s),h=Math.sin(s);return this.set(l,0,h,0,0,1,0,0,-h,0,l,0,0,0,0,1),this}makeRotationZ(s){const l=Math.cos(s),h=Math.sin(s);return this.set(l,-h,0,0,h,l,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(s,l){const h=Math.cos(l),f=Math.sin(l),g=1-h,_=s.x,b=s.y,T=s.z,A=g*_,R=g*b;return this.set(A*_+h,A*b-f*T,A*T+f*b,0,A*b+f*T,R*b+h,R*T-f*_,0,A*T-f*b,R*T+f*_,g*T*T+h,0,0,0,0,1),this}makeScale(s,l,h){return this.set(s,0,0,0,0,l,0,0,0,0,h,0,0,0,0,1),this}makeShear(s,l,h,f,g,_){return this.set(1,h,g,0,s,1,_,0,l,f,1,0,0,0,0,1),this}compose(s,l,h){const f=this.elements,g=l._x,_=l._y,b=l._z,T=l._w,A=g+g,R=_+_,P=b+b,L=g*A,D=g*R,O=g*P,W=_*R,Z=_*P,Y=b*P,ie=T*A,se=T*R,de=T*P,ke=h.x,$e=h.y,et=h.z;return f[0]=(1-(W+Y))*ke,f[1]=(D+de)*ke,f[2]=(O-se)*ke,f[3]=0,f[4]=(D-de)*$e,f[5]=(1-(L+Y))*$e,f[6]=(Z+ie)*$e,f[7]=0,f[8]=(O+se)*et,f[9]=(Z-ie)*et,f[10]=(1-(L+W))*et,f[11]=0,f[12]=s.x,f[13]=s.y,f[14]=s.z,f[15]=1,this}decompose(s,l,h){const f=this.elements;let g=Xl.set(f[0],f[1],f[2]).length();const _=Xl.set(f[4],f[5],f[6]).length(),b=Xl.set(f[8],f[9],f[10]).length();this.determinant()<0&&(g=-g),s.x=f[12],s.y=f[13],s.z=f[14],Xr.copy(this);const A=1/g,R=1/_,P=1/b;return Xr.elements[0]*=A,Xr.elements[1]*=A,Xr.elements[2]*=A,Xr.elements[4]*=R,Xr.elements[5]*=R,Xr.elements[6]*=R,Xr.elements[8]*=P,Xr.elements[9]*=P,Xr.elements[10]*=P,l.setFromRotationMatrix(Xr),h.x=g,h.y=_,h.z=b,this}makePerspective(s,l,h,f,g,_,b=rl,T=!1){const A=this.elements,R=2*g/(l-s),P=2*g/(h-f),L=(l+s)/(l-s),D=(h+f)/(h-f);let O,W;if(T)O=g/(_-g),W=_*g/(_-g);else if(b===rl)O=-(_+g)/(_-g),W=-2*_*g/(_-g);else if(b===Up)O=-_/(_-g),W=-_*g/(_-g);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+b);return A[0]=R,A[4]=0,A[8]=L,A[12]=0,A[1]=0,A[5]=P,A[9]=D,A[13]=0,A[2]=0,A[6]=0,A[10]=O,A[14]=W,A[3]=0,A[7]=0,A[11]=-1,A[15]=0,this}makeOrthographic(s,l,h,f,g,_,b=rl,T=!1){const A=this.elements,R=2/(l-s),P=2/(h-f),L=-(l+s)/(l-s),D=-(h+f)/(h-f);let O,W;if(T)O=1/(_-g),W=_/(_-g);else if(b===rl)O=-2/(_-g),W=-(_+g)/(_-g);else if(b===Up)O=-1/(_-g),W=-g/(_-g);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+b);return A[0]=R,A[4]=0,A[8]=0,A[12]=L,A[1]=0,A[5]=P,A[9]=0,A[13]=D,A[2]=0,A[6]=0,A[10]=O,A[14]=W,A[3]=0,A[7]=0,A[11]=0,A[15]=1,this}equals(s){const l=this.elements,h=s.elements;for(let f=0;f<16;f++)if(l[f]!==h[f])return!1;return!0}fromArray(s,l=0){for(let h=0;h<16;h++)this.elements[h]=s[h+l];return this}toArray(s=[],l=0){const h=this.elements;return s[l]=h[0],s[l+1]=h[1],s[l+2]=h[2],s[l+3]=h[3],s[l+4]=h[4],s[l+5]=h[5],s[l+6]=h[6],s[l+7]=h[7],s[l+8]=h[8],s[l+9]=h[9],s[l+10]=h[10],s[l+11]=h[11],s[l+12]=h[12],s[l+13]=h[13],s[l+14]=h[14],s[l+15]=h[15],s}}const Xl=new ae,Xr=new Dn,jl=new ae(0,0,0),Wg=new ae(1,1,1),ta=new ae,Qh=new ae,nr=new ae,Qt=new Dn,hu=new ro;class Is{constructor(s=0,l=0,h=0,f=Is.DEFAULT_ORDER){this.isEuler=!0,this._x=s,this._y=l,this._z=h,this._order=f}get x(){return this._x}set x(s){this._x=s,this._onChangeCallback()}get y(){return this._y}set y(s){this._y=s,this._onChangeCallback()}get z(){return this._z}set z(s){this._z=s,this._onChangeCallback()}get order(){return this._order}set order(s){this._order=s,this._onChangeCallback()}set(s,l,h,f=this._order){return this._x=s,this._y=l,this._z=h,this._order=f,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(s){return this._x=s._x,this._y=s._y,this._z=s._z,this._order=s._order,this._onChangeCallback(),this}setFromRotationMatrix(s,l=this._order,h=!0){const f=s.elements,g=f[0],_=f[4],b=f[8],T=f[1],A=f[5],R=f[9],P=f[2],L=f[6],D=f[10];switch(l){case"XYZ":this._y=Math.asin(Ut(b,-1,1)),Math.abs(b)<.9999999?(this._x=Math.atan2(-R,D),this._z=Math.atan2(-_,g)):(this._x=Math.atan2(L,A),this._z=0);break;case"YXZ":this._x=Math.asin(-Ut(R,-1,1)),Math.abs(R)<.9999999?(this._y=Math.atan2(b,D),this._z=Math.atan2(T,A)):(this._y=Math.atan2(-P,g),this._z=0);break;case"ZXY":this._x=Math.asin(Ut(L,-1,1)),Math.abs(L)<.9999999?(this._y=Math.atan2(-P,D),this._z=Math.atan2(-_,A)):(this._y=0,this._z=Math.atan2(T,g));break;case"ZYX":this._y=Math.asin(-Ut(P,-1,1)),Math.abs(P)<.9999999?(this._x=Math.atan2(L,D),this._z=Math.atan2(T,g)):(this._x=0,this._z=Math.atan2(-_,A));break;case"YZX":this._z=Math.asin(Ut(T,-1,1)),Math.abs(T)<.9999999?(this._x=Math.atan2(-R,A),this._y=Math.atan2(-P,g)):(this._x=0,this._y=Math.atan2(b,D));break;case"XZY":this._z=Math.asin(-Ut(_,-1,1)),Math.abs(_)<.9999999?(this._x=Math.atan2(L,A),this._y=Math.atan2(b,g)):(this._x=Math.atan2(-R,D),this._y=0);break;default:Mn("Euler: .setFromRotationMatrix() encountered an unknown order: "+l)}return this._order=l,h===!0&&this._onChangeCallback(),this}setFromQuaternion(s,l,h){return Qt.makeRotationFromQuaternion(s),this.setFromRotationMatrix(Qt,l,h)}setFromVector3(s,l=this._order){return this.set(s.x,s.y,s.z,l)}reorder(s){return hu.setFromEuler(this),this.setFromQuaternion(hu,s)}equals(s){return s._x===this._x&&s._y===this._y&&s._z===this._z&&s._order===this._order}fromArray(s){return this._x=s[0],this._y=s[1],this._z=s[2],s[3]!==void 0&&(this._order=s[3]),this._onChangeCallback(),this}toArray(s=[],l=0){return s[l]=this._x,s[l+1]=this._y,s[l+2]=this._z,s[l+3]=this._order,s}_onChange(s){return this._onChangeCallback=s,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Is.DEFAULT_ORDER="XYZ";class R_{constructor(){this.mask=1}set(s){this.mask=(1<<s|0)>>>0}enable(s){this.mask|=1<<s|0}enableAll(){this.mask=-1}toggle(s){this.mask^=1<<s|0}disable(s){this.mask&=~(1<<s|0)}disableAll(){this.mask=0}test(s){return(this.mask&s.mask)!==0}isEnabled(s){return(this.mask&(1<<s|0))!==0}}let aS=0;const ul=new ae,hl=new ro,Es=new Dn,ff=new ae,ed=new ae,jr=new ae,Hg=new ro,N_=new ae(1,0,0),$g=new ae(0,1,0),du=new ae(0,0,1),Ia={type:"added"},kp={type:"removed"},La={type:"childadded",child:null},qg={type:"childremoved",child:null};class Hs extends Zo{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:aS++}),this.uuid=Be(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Hs.DEFAULT_UP.clone();const s=new ae,l=new Is,h=new ro,f=new ae(1,1,1);function g(){h.setFromEuler(l,!1)}function _(){l.setFromQuaternion(h,void 0,!1)}l._onChange(g),h._onChange(_),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:s},rotation:{configurable:!0,enumerable:!0,value:l},quaternion:{configurable:!0,enumerable:!0,value:h},scale:{configurable:!0,enumerable:!0,value:f},modelViewMatrix:{value:new Dn},normalMatrix:{value:new ts}}),this.matrix=new Dn,this.matrixWorld=new Dn,this.matrixAutoUpdate=Hs.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Hs.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new R_,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(s){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(s),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(s){return this.quaternion.premultiply(s),this}setRotationFromAxisAngle(s,l){this.quaternion.setFromAxisAngle(s,l)}setRotationFromEuler(s){this.quaternion.setFromEuler(s,!0)}setRotationFromMatrix(s){this.quaternion.setFromRotationMatrix(s)}setRotationFromQuaternion(s){this.quaternion.copy(s)}rotateOnAxis(s,l){return hl.setFromAxisAngle(s,l),this.quaternion.multiply(hl),this}rotateOnWorldAxis(s,l){return hl.setFromAxisAngle(s,l),this.quaternion.premultiply(hl),this}rotateX(s){return this.rotateOnAxis(N_,s)}rotateY(s){return this.rotateOnAxis($g,s)}rotateZ(s){return this.rotateOnAxis(du,s)}translateOnAxis(s,l){return ul.copy(s).applyQuaternion(this.quaternion),this.position.add(ul.multiplyScalar(l)),this}translateX(s){return this.translateOnAxis(N_,s)}translateY(s){return this.translateOnAxis($g,s)}translateZ(s){return this.translateOnAxis(du,s)}localToWorld(s){return this.updateWorldMatrix(!0,!1),s.applyMatrix4(this.matrixWorld)}worldToLocal(s){return this.updateWorldMatrix(!0,!1),s.applyMatrix4(Es.copy(this.matrixWorld).invert())}lookAt(s,l,h){s.isVector3?ff.copy(s):ff.set(s,l,h);const f=this.parent;this.updateWorldMatrix(!0,!1),ed.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Es.lookAt(ed,ff,this.up):Es.lookAt(ff,ed,this.up),this.quaternion.setFromRotationMatrix(Es),f&&(Es.extractRotation(f.matrixWorld),hl.setFromRotationMatrix(Es),this.quaternion.premultiply(hl.invert()))}add(s){if(arguments.length>1){for(let l=0;l<arguments.length;l++)this.add(arguments[l]);return this}return s===this?(ci("Object3D.add: object can't be added as a child of itself.",s),this):(s&&s.isObject3D?(s.removeFromParent(),s.parent=this,this.children.push(s),s.dispatchEvent(Ia),La.child=s,this.dispatchEvent(La),La.child=null):ci("Object3D.add: object not an instance of THREE.Object3D.",s),this)}remove(s){if(arguments.length>1){for(let h=0;h<arguments.length;h++)this.remove(arguments[h]);return this}const l=this.children.indexOf(s);return l!==-1&&(s.parent=null,this.children.splice(l,1),s.dispatchEvent(kp),qg.child=s,this.dispatchEvent(qg),qg.child=null),this}removeFromParent(){const s=this.parent;return s!==null&&s.remove(this),this}clear(){return this.remove(...this.children)}attach(s){return this.updateWorldMatrix(!0,!1),Es.copy(this.matrixWorld).invert(),s.parent!==null&&(s.parent.updateWorldMatrix(!0,!1),Es.multiply(s.parent.matrixWorld)),s.applyMatrix4(Es),s.removeFromParent(),s.parent=this,this.children.push(s),s.updateWorldMatrix(!1,!0),s.dispatchEvent(Ia),La.child=s,this.dispatchEvent(La),La.child=null,this}getObjectById(s){return this.getObjectByProperty("id",s)}getObjectByName(s){return this.getObjectByProperty("name",s)}getObjectByProperty(s,l){if(this[s]===l)return this;for(let h=0,f=this.children.length;h<f;h++){const _=this.children[h].getObjectByProperty(s,l);if(_!==void 0)return _}}getObjectsByProperty(s,l,h=[]){this[s]===l&&h.push(this);const f=this.children;for(let g=0,_=f.length;g<_;g++)f[g].getObjectsByProperty(s,l,h);return h}getWorldPosition(s){return this.updateWorldMatrix(!0,!1),s.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(s){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ed,s,jr),s}getWorldScale(s){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ed,Hg,s),s}getWorldDirection(s){this.updateWorldMatrix(!0,!1);const l=this.matrixWorld.elements;return s.set(l[8],l[9],l[10]).normalize()}raycast(){}traverse(s){s(this);const l=this.children;for(let h=0,f=l.length;h<f;h++)l[h].traverse(s)}traverseVisible(s){if(this.visible===!1)return;s(this);const l=this.children;for(let h=0,f=l.length;h<f;h++)l[h].traverseVisible(s)}traverseAncestors(s){const l=this.parent;l!==null&&(s(l),l.traverseAncestors(s))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(s){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||s)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,s=!0);const l=this.children;for(let h=0,f=l.length;h<f;h++)l[h].updateMatrixWorld(s)}updateWorldMatrix(s,l){const h=this.parent;if(s===!0&&h!==null&&h.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)),l===!0){const f=this.children;for(let g=0,_=f.length;g<_;g++)f[g].updateWorldMatrix(!1,!0)}}toJSON(s){const l=s===void 0||typeof s=="string",h={};l&&(s={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},h.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const f={};f.uuid=this.uuid,f.type=this.type,this.name!==""&&(f.name=this.name),this.castShadow===!0&&(f.castShadow=!0),this.receiveShadow===!0&&(f.receiveShadow=!0),this.visible===!1&&(f.visible=!1),this.frustumCulled===!1&&(f.frustumCulled=!1),this.renderOrder!==0&&(f.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(f.userData=this.userData),f.layers=this.layers.mask,f.matrix=this.matrix.toArray(),f.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(f.matrixAutoUpdate=!1),this.isInstancedMesh&&(f.type="InstancedMesh",f.count=this.count,f.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(f.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(f.type="BatchedMesh",f.perObjectFrustumCulled=this.perObjectFrustumCulled,f.sortObjects=this.sortObjects,f.drawRanges=this._drawRanges,f.reservedRanges=this._reservedRanges,f.geometryInfo=this._geometryInfo.map(b=>Mo(wi({},b),{boundingBox:b.boundingBox?b.boundingBox.toJSON():void 0,boundingSphere:b.boundingSphere?b.boundingSphere.toJSON():void 0})),f.instanceInfo=this._instanceInfo.map(b=>wi({},b)),f.availableInstanceIds=this._availableInstanceIds.slice(),f.availableGeometryIds=this._availableGeometryIds.slice(),f.nextIndexStart=this._nextIndexStart,f.nextVertexStart=this._nextVertexStart,f.geometryCount=this._geometryCount,f.maxInstanceCount=this._maxInstanceCount,f.maxVertexCount=this._maxVertexCount,f.maxIndexCount=this._maxIndexCount,f.geometryInitialized=this._geometryInitialized,f.matricesTexture=this._matricesTexture.toJSON(s),f.indirectTexture=this._indirectTexture.toJSON(s),this._colorsTexture!==null&&(f.colorsTexture=this._colorsTexture.toJSON(s)),this.boundingSphere!==null&&(f.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(f.boundingBox=this.boundingBox.toJSON()));function g(b,T){return b[T.uuid]===void 0&&(b[T.uuid]=T.toJSON(s)),T.uuid}if(this.isScene)this.background&&(this.background.isColor?f.background=this.background.toJSON():this.background.isTexture&&(f.background=this.background.toJSON(s).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(f.environment=this.environment.toJSON(s).uuid);else if(this.isMesh||this.isLine||this.isPoints){f.geometry=g(s.geometries,this.geometry);const b=this.geometry.parameters;if(b!==void 0&&b.shapes!==void 0){const T=b.shapes;if(Array.isArray(T))for(let A=0,R=T.length;A<R;A++){const P=T[A];g(s.shapes,P)}else g(s.shapes,T)}}if(this.isSkinnedMesh&&(f.bindMode=this.bindMode,f.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(g(s.skeletons,this.skeleton),f.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const b=[];for(let T=0,A=this.material.length;T<A;T++)b.push(g(s.materials,this.material[T]));f.material=b}else f.material=g(s.materials,this.material);if(this.children.length>0){f.children=[];for(let b=0;b<this.children.length;b++)f.children.push(this.children[b].toJSON(s).object)}if(this.animations.length>0){f.animations=[];for(let b=0;b<this.animations.length;b++){const T=this.animations[b];f.animations.push(g(s.animations,T))}}if(l){const b=_(s.geometries),T=_(s.materials),A=_(s.textures),R=_(s.images),P=_(s.shapes),L=_(s.skeletons),D=_(s.animations),O=_(s.nodes);b.length>0&&(h.geometries=b),T.length>0&&(h.materials=T),A.length>0&&(h.textures=A),R.length>0&&(h.images=R),P.length>0&&(h.shapes=P),L.length>0&&(h.skeletons=L),D.length>0&&(h.animations=D),O.length>0&&(h.nodes=O)}return h.object=f,h;function _(b){const T=[];for(const A in b){const R=b[A];delete R.metadata,T.push(R)}return T}}clone(s){return new this.constructor().copy(this,s)}copy(s,l=!0){if(this.name=s.name,this.up.copy(s.up),this.position.copy(s.position),this.rotation.order=s.rotation.order,this.quaternion.copy(s.quaternion),this.scale.copy(s.scale),this.matrix.copy(s.matrix),this.matrixWorld.copy(s.matrixWorld),this.matrixAutoUpdate=s.matrixAutoUpdate,this.matrixWorldAutoUpdate=s.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=s.matrixWorldNeedsUpdate,this.layers.mask=s.layers.mask,this.visible=s.visible,this.castShadow=s.castShadow,this.receiveShadow=s.receiveShadow,this.frustumCulled=s.frustumCulled,this.renderOrder=s.renderOrder,this.animations=s.animations.slice(),this.userData=JSON.parse(JSON.stringify(s.userData)),l===!0)for(let h=0;h<s.children.length;h++){const f=s.children[h];this.add(f.clone())}return this}}Hs.DEFAULT_UP=new ae(0,1,0),Hs.DEFAULT_MATRIX_AUTO_UPDATE=!0,Hs.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const No=new ae,Da=new ae,zp=new ae,Fa=new ae,td=new ae,na=new ae,Vp=new ae,Zi=new ae,oo=new ae,ia=new ae,pf=new as,sa=new as,Yl=new as;class ir{constructor(s=new ae,l=new ae,h=new ae){this.a=s,this.b=l,this.c=h}static getNormal(s,l,h,f){f.subVectors(h,l),No.subVectors(s,l),f.cross(No);const g=f.lengthSq();return g>0?f.multiplyScalar(1/Math.sqrt(g)):f.set(0,0,0)}static getBarycoord(s,l,h,f,g){No.subVectors(f,l),Da.subVectors(h,l),zp.subVectors(s,l);const _=No.dot(No),b=No.dot(Da),T=No.dot(zp),A=Da.dot(Da),R=Da.dot(zp),P=_*A-b*b;if(P===0)return g.set(0,0,0),null;const L=1/P,D=(A*T-b*R)*L,O=(_*R-b*T)*L;return g.set(1-D-O,O,D)}static containsPoint(s,l,h,f){return this.getBarycoord(s,l,h,f,Fa)===null?!1:Fa.x>=0&&Fa.y>=0&&Fa.x+Fa.y<=1}static getInterpolation(s,l,h,f,g,_,b,T){return this.getBarycoord(s,l,h,f,Fa)===null?(T.x=0,T.y=0,"z"in T&&(T.z=0),"w"in T&&(T.w=0),null):(T.setScalar(0),T.addScaledVector(g,Fa.x),T.addScaledVector(_,Fa.y),T.addScaledVector(b,Fa.z),T)}static getInterpolatedAttribute(s,l,h,f,g,_){return pf.setScalar(0),sa.setScalar(0),Yl.setScalar(0),pf.fromBufferAttribute(s,l),sa.fromBufferAttribute(s,h),Yl.fromBufferAttribute(s,f),_.setScalar(0),_.addScaledVector(pf,g.x),_.addScaledVector(sa,g.y),_.addScaledVector(Yl,g.z),_}static isFrontFacing(s,l,h,f){return No.subVectors(h,l),Da.subVectors(s,l),No.cross(Da).dot(f)<0}set(s,l,h){return this.a.copy(s),this.b.copy(l),this.c.copy(h),this}setFromPointsAndIndices(s,l,h,f){return this.a.copy(s[l]),this.b.copy(s[h]),this.c.copy(s[f]),this}setFromAttributeAndIndices(s,l,h,f){return this.a.fromBufferAttribute(s,l),this.b.fromBufferAttribute(s,h),this.c.fromBufferAttribute(s,f),this}clone(){return new this.constructor().copy(this)}copy(s){return this.a.copy(s.a),this.b.copy(s.b),this.c.copy(s.c),this}getArea(){return No.subVectors(this.c,this.b),Da.subVectors(this.a,this.b),No.cross(Da).length()*.5}getMidpoint(s){return s.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(s){return ir.getNormal(this.a,this.b,this.c,s)}getPlane(s){return s.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(s,l){return ir.getBarycoord(s,this.a,this.b,this.c,l)}getInterpolation(s,l,h,f,g){return ir.getInterpolation(s,this.a,this.b,this.c,l,h,f,g)}containsPoint(s){return ir.containsPoint(s,this.a,this.b,this.c)}isFrontFacing(s){return ir.isFrontFacing(this.a,this.b,this.c,s)}intersectsBox(s){return s.intersectsTriangle(this)}closestPointToPoint(s,l){const h=this.a,f=this.b,g=this.c;let _,b;td.subVectors(f,h),na.subVectors(g,h),Zi.subVectors(s,h);const T=td.dot(Zi),A=na.dot(Zi);if(T<=0&&A<=0)return l.copy(h);oo.subVectors(s,f);const R=td.dot(oo),P=na.dot(oo);if(R>=0&&P<=R)return l.copy(f);const L=T*P-R*A;if(L<=0&&T>=0&&R<=0)return _=T/(T-R),l.copy(h).addScaledVector(td,_);ia.subVectors(s,g);const D=td.dot(ia),O=na.dot(ia);if(O>=0&&D<=O)return l.copy(g);const W=D*A-T*O;if(W<=0&&A>=0&&O<=0)return b=A/(A-O),l.copy(h).addScaledVector(na,b);const Z=R*O-D*P;if(Z<=0&&P-R>=0&&D-O>=0)return Vp.subVectors(g,f),b=(P-R)/(P-R+(D-O)),l.copy(f).addScaledVector(Vp,b);const Y=1/(Z+W+L);return _=W*Y,b=L*Y,l.copy(h).addScaledVector(td,_).addScaledVector(na,b)}equals(s){return s.a.equals(this.a)&&s.b.equals(this.b)&&s.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},Ba={h:0,s:0,l:0},nd={h:0,s:0,l:0};function mf(E,s,l){return l<0&&(l+=1),l>1&&(l-=1),l<1/6?E+(s-E)*6*l:l<1/2?s:l<2/3?E+(s-E)*6*(2/3-l):E}class Zn{constructor(s,l,h){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(s,l,h)}set(s,l,h){if(l===void 0&&h===void 0){const f=s;f&&f.isColor?this.copy(f):typeof f=="number"?this.setHex(f):typeof f=="string"&&this.setStyle(f)}else this.setRGB(s,l,h);return this}setScalar(s){return this.r=s,this.g=s,this.b=s,this}setHex(s,l=Ao){return s=Math.floor(s),this.r=(s>>16&255)/255,this.g=(s>>8&255)/255,this.b=(s&255)/255,H.colorSpaceToWorking(this,l),this}setRGB(s,l,h,f=H.workingColorSpace){return this.r=s,this.g=l,this.b=h,H.colorSpaceToWorking(this,f),this}setHSL(s,l,h,f=H.workingColorSpace){if(s=Og(s,1),l=Ut(l,0,1),h=Ut(h,0,1),l===0)this.r=this.g=this.b=h;else{const g=h<=.5?h*(1+l):h+l-h*l,_=2*h-g;this.r=mf(_,g,s+1/3),this.g=mf(_,g,s),this.b=mf(_,g,s-1/3)}return H.colorSpaceToWorking(this,f),this}setStyle(s,l=Ao){function h(g){g!==void 0&&parseFloat(g)<1&&Mn("Color: Alpha component of "+s+" will be ignored.")}let f;if(f=/^(\w+)\(([^\)]*)\)/.exec(s)){let g;const _=f[1],b=f[2];switch(_){case"rgb":case"rgba":if(g=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(b))return h(g[4]),this.setRGB(Math.min(255,parseInt(g[1],10))/255,Math.min(255,parseInt(g[2],10))/255,Math.min(255,parseInt(g[3],10))/255,l);if(g=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(b))return h(g[4]),this.setRGB(Math.min(100,parseInt(g[1],10))/100,Math.min(100,parseInt(g[2],10))/100,Math.min(100,parseInt(g[3],10))/100,l);break;case"hsl":case"hsla":if(g=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(b))return h(g[4]),this.setHSL(parseFloat(g[1])/360,parseFloat(g[2])/100,parseFloat(g[3])/100,l);break;default:Mn("Color: Unknown color model "+s)}}else if(f=/^\#([A-Fa-f\d]+)$/.exec(s)){const g=f[1],_=g.length;if(_===3)return this.setRGB(parseInt(g.charAt(0),16)/15,parseInt(g.charAt(1),16)/15,parseInt(g.charAt(2),16)/15,l);if(_===6)return this.setHex(parseInt(g,16),l);Mn("Color: Invalid hex color "+s)}else if(s&&s.length>0)return this.setColorName(s,l);return this}setColorName(s,l=Ao){const h=Xg[s.toLowerCase()];return h!==void 0?this.setHex(h,l):Mn("Color: Unknown color "+s),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(s){return this.r=s.r,this.g=s.g,this.b=s.b,this}copySRGBToLinear(s){return this.r=Qo(s.r),this.g=Qo(s.g),this.b=Qo(s.b),this}copyLinearToSRGB(s){return this.r=au(s.r),this.g=au(s.g),this.b=au(s.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(s=Ao){return H.workingToColorSpace(sr.copy(this),s),Math.round(Ut(sr.r*255,0,255))*65536+Math.round(Ut(sr.g*255,0,255))*256+Math.round(Ut(sr.b*255,0,255))}getHexString(s=Ao){return("000000"+this.getHex(s).toString(16)).slice(-6)}getHSL(s,l=H.workingColorSpace){H.workingToColorSpace(sr.copy(this),l);const h=sr.r,f=sr.g,g=sr.b,_=Math.max(h,f,g),b=Math.min(h,f,g);let T,A;const R=(b+_)/2;if(b===_)T=0,A=0;else{const P=_-b;switch(A=R<=.5?P/(_+b):P/(2-_-b),_){case h:T=(f-g)/P+(f<g?6:0);break;case f:T=(g-h)/P+2;break;case g:T=(h-f)/P+4;break}T/=6}return s.h=T,s.s=A,s.l=R,s}getRGB(s,l=H.workingColorSpace){return H.workingToColorSpace(sr.copy(this),l),s.r=sr.r,s.g=sr.g,s.b=sr.b,s}getStyle(s=Ao){H.workingToColorSpace(sr.copy(this),s);const l=sr.r,h=sr.g,f=sr.b;return s!==Ao?`color(${s} ${l.toFixed(3)} ${h.toFixed(3)} ${f.toFixed(3)})`:`rgb(${Math.round(l*255)},${Math.round(h*255)},${Math.round(f*255)})`}offsetHSL(s,l,h){return this.getHSL(Ba),this.setHSL(Ba.h+s,Ba.s+l,Ba.l+h)}add(s){return this.r+=s.r,this.g+=s.g,this.b+=s.b,this}addColors(s,l){return this.r=s.r+l.r,this.g=s.g+l.g,this.b=s.b+l.b,this}addScalar(s){return this.r+=s,this.g+=s,this.b+=s,this}sub(s){return this.r=Math.max(0,this.r-s.r),this.g=Math.max(0,this.g-s.g),this.b=Math.max(0,this.b-s.b),this}multiply(s){return this.r*=s.r,this.g*=s.g,this.b*=s.b,this}multiplyScalar(s){return this.r*=s,this.g*=s,this.b*=s,this}lerp(s,l){return this.r+=(s.r-this.r)*l,this.g+=(s.g-this.g)*l,this.b+=(s.b-this.b)*l,this}lerpColors(s,l,h){return this.r=s.r+(l.r-s.r)*h,this.g=s.g+(l.g-s.g)*h,this.b=s.b+(l.b-s.b)*h,this}lerpHSL(s,l){this.getHSL(Ba),s.getHSL(nd);const h=Zh(Ba.h,nd.h,l),f=Zh(Ba.s,nd.s,l),g=Zh(Ba.l,nd.l,l);return this.setHSL(h,f,g),this}setFromVector3(s){return this.r=s.x,this.g=s.y,this.b=s.z,this}applyMatrix3(s){const l=this.r,h=this.g,f=this.b,g=s.elements;return this.r=g[0]*l+g[3]*h+g[6]*f,this.g=g[1]*l+g[4]*h+g[7]*f,this.b=g[2]*l+g[5]*h+g[8]*f,this}equals(s){return s.r===this.r&&s.g===this.g&&s.b===this.b}fromArray(s,l=0){return this.r=s[l],this.g=s[l+1],this.b=s[l+2],this}toArray(s=[],l=0){return s[l]=this.r,s[l+1]=this.g,s[l+2]=this.b,s}fromBufferAttribute(s,l){return this.r=s.getX(l),this.g=s.getY(l),this.b=s.getZ(l),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const sr=new Zn;Zn.NAMES=Xg;let jg=0;class Sr extends Zo{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:jg++}),this.uuid=Be(),this.name="",this.type="Material",this.blending=Ue,this.side=Me,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Rn,this.blendDst=Jt,this.blendEquation=nt,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Zn(0,0,0),this.blendAlpha=0,this.depthFunc=no,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=m_,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=io,this.stencilZFail=io,this.stencilZPass=io,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(s){this._alphaTest>0!=s>0&&this.version++,this._alphaTest=s}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(s){if(s!==void 0)for(const l in s){const h=s[l];if(h===void 0){Mn(`Material: parameter '${l}' has value of undefined.`);continue}const f=this[l];if(f===void 0){Mn(`Material: '${l}' is not a property of THREE.${this.type}.`);continue}f&&f.isColor?f.set(h):f&&f.isVector3&&h&&h.isVector3?f.copy(h):this[l]=h}}toJSON(s){const l=s===void 0||typeof s=="string";l&&(s={textures:{},images:{}});const h={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};h.uuid=this.uuid,h.type=this.type,this.name!==""&&(h.name=this.name),this.color&&this.color.isColor&&(h.color=this.color.getHex()),this.roughness!==void 0&&(h.roughness=this.roughness),this.metalness!==void 0&&(h.metalness=this.metalness),this.sheen!==void 0&&(h.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(h.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(h.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(h.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(h.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(h.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(h.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(h.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(h.shininess=this.shininess),this.clearcoat!==void 0&&(h.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(h.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(h.clearcoatMap=this.clearcoatMap.toJSON(s).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(h.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(s).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(h.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(s).uuid,h.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(h.sheenColorMap=this.sheenColorMap.toJSON(s).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(h.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(s).uuid),this.dispersion!==void 0&&(h.dispersion=this.dispersion),this.iridescence!==void 0&&(h.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(h.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(h.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(h.iridescenceMap=this.iridescenceMap.toJSON(s).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(h.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(s).uuid),this.anisotropy!==void 0&&(h.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(h.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(h.anisotropyMap=this.anisotropyMap.toJSON(s).uuid),this.map&&this.map.isTexture&&(h.map=this.map.toJSON(s).uuid),this.matcap&&this.matcap.isTexture&&(h.matcap=this.matcap.toJSON(s).uuid),this.alphaMap&&this.alphaMap.isTexture&&(h.alphaMap=this.alphaMap.toJSON(s).uuid),this.lightMap&&this.lightMap.isTexture&&(h.lightMap=this.lightMap.toJSON(s).uuid,h.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(h.aoMap=this.aoMap.toJSON(s).uuid,h.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(h.bumpMap=this.bumpMap.toJSON(s).uuid,h.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(h.normalMap=this.normalMap.toJSON(s).uuid,h.normalMapType=this.normalMapType,h.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(h.displacementMap=this.displacementMap.toJSON(s).uuid,h.displacementScale=this.displacementScale,h.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(h.roughnessMap=this.roughnessMap.toJSON(s).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(h.metalnessMap=this.metalnessMap.toJSON(s).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(h.emissiveMap=this.emissiveMap.toJSON(s).uuid),this.specularMap&&this.specularMap.isTexture&&(h.specularMap=this.specularMap.toJSON(s).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(h.specularIntensityMap=this.specularIntensityMap.toJSON(s).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(h.specularColorMap=this.specularColorMap.toJSON(s).uuid),this.envMap&&this.envMap.isTexture&&(h.envMap=this.envMap.toJSON(s).uuid,this.combine!==void 0&&(h.combine=this.combine)),this.envMapRotation!==void 0&&(h.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(h.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(h.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(h.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(h.gradientMap=this.gradientMap.toJSON(s).uuid),this.transmission!==void 0&&(h.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(h.transmissionMap=this.transmissionMap.toJSON(s).uuid),this.thickness!==void 0&&(h.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(h.thicknessMap=this.thicknessMap.toJSON(s).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(h.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(h.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(h.size=this.size),this.shadowSide!==null&&(h.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(h.sizeAttenuation=this.sizeAttenuation),this.blending!==Ue&&(h.blending=this.blending),this.side!==Me&&(h.side=this.side),this.vertexColors===!0&&(h.vertexColors=!0),this.opacity<1&&(h.opacity=this.opacity),this.transparent===!0&&(h.transparent=!0),this.blendSrc!==Rn&&(h.blendSrc=this.blendSrc),this.blendDst!==Jt&&(h.blendDst=this.blendDst),this.blendEquation!==nt&&(h.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(h.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(h.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(h.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(h.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(h.blendAlpha=this.blendAlpha),this.depthFunc!==no&&(h.depthFunc=this.depthFunc),this.depthTest===!1&&(h.depthTest=this.depthTest),this.depthWrite===!1&&(h.depthWrite=this.depthWrite),this.colorWrite===!1&&(h.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(h.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==m_&&(h.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(h.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(h.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==io&&(h.stencilFail=this.stencilFail),this.stencilZFail!==io&&(h.stencilZFail=this.stencilZFail),this.stencilZPass!==io&&(h.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(h.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(h.rotation=this.rotation),this.polygonOffset===!0&&(h.polygonOffset=!0),this.polygonOffsetFactor!==0&&(h.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(h.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(h.linewidth=this.linewidth),this.dashSize!==void 0&&(h.dashSize=this.dashSize),this.gapSize!==void 0&&(h.gapSize=this.gapSize),this.scale!==void 0&&(h.scale=this.scale),this.dithering===!0&&(h.dithering=!0),this.alphaTest>0&&(h.alphaTest=this.alphaTest),this.alphaHash===!0&&(h.alphaHash=!0),this.alphaToCoverage===!0&&(h.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(h.premultipliedAlpha=!0),this.forceSinglePass===!0&&(h.forceSinglePass=!0),this.wireframe===!0&&(h.wireframe=!0),this.wireframeLinewidth>1&&(h.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(h.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(h.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(h.flatShading=!0),this.visible===!1&&(h.visible=!1),this.toneMapped===!1&&(h.toneMapped=!1),this.fog===!1&&(h.fog=!1),Object.keys(this.userData).length>0&&(h.userData=this.userData);function f(g){const _=[];for(const b in g){const T=g[b];delete T.metadata,_.push(T)}return _}if(l){const g=f(s.textures),_=f(s.images);g.length>0&&(h.textures=g),_.length>0&&(h.images=_)}return h}clone(){return new this.constructor().copy(this)}copy(s){this.name=s.name,this.blending=s.blending,this.side=s.side,this.vertexColors=s.vertexColors,this.opacity=s.opacity,this.transparent=s.transparent,this.blendSrc=s.blendSrc,this.blendDst=s.blendDst,this.blendEquation=s.blendEquation,this.blendSrcAlpha=s.blendSrcAlpha,this.blendDstAlpha=s.blendDstAlpha,this.blendEquationAlpha=s.blendEquationAlpha,this.blendColor.copy(s.blendColor),this.blendAlpha=s.blendAlpha,this.depthFunc=s.depthFunc,this.depthTest=s.depthTest,this.depthWrite=s.depthWrite,this.stencilWriteMask=s.stencilWriteMask,this.stencilFunc=s.stencilFunc,this.stencilRef=s.stencilRef,this.stencilFuncMask=s.stencilFuncMask,this.stencilFail=s.stencilFail,this.stencilZFail=s.stencilZFail,this.stencilZPass=s.stencilZPass,this.stencilWrite=s.stencilWrite;const l=s.clippingPlanes;let h=null;if(l!==null){const f=l.length;h=new Array(f);for(let g=0;g!==f;++g)h[g]=l[g].clone()}return this.clippingPlanes=h,this.clipIntersection=s.clipIntersection,this.clipShadows=s.clipShadows,this.shadowSide=s.shadowSide,this.colorWrite=s.colorWrite,this.precision=s.precision,this.polygonOffset=s.polygonOffset,this.polygonOffsetFactor=s.polygonOffsetFactor,this.polygonOffsetUnits=s.polygonOffsetUnits,this.dithering=s.dithering,this.alphaTest=s.alphaTest,this.alphaHash=s.alphaHash,this.alphaToCoverage=s.alphaToCoverage,this.premultipliedAlpha=s.premultipliedAlpha,this.forceSinglePass=s.forceSinglePass,this.visible=s.visible,this.toneMapped=s.toneMapped,this.userData=JSON.parse(JSON.stringify(s.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(s){s===!0&&this.version++}}class Zl extends Sr{constructor(s){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Zn(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 Is,this.combine=Xc,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(s)}copy(s){return super.copy(s),this.color.copy(s.color),this.map=s.map,this.lightMap=s.lightMap,this.lightMapIntensity=s.lightMapIntensity,this.aoMap=s.aoMap,this.aoMapIntensity=s.aoMapIntensity,this.specularMap=s.specularMap,this.alphaMap=s.alphaMap,this.envMap=s.envMap,this.envMapRotation.copy(s.envMapRotation),this.combine=s.combine,this.reflectivity=s.reflectivity,this.refractionRatio=s.refractionRatio,this.wireframe=s.wireframe,this.wireframeLinewidth=s.wireframeLinewidth,this.wireframeLinecap=s.wireframeLinecap,this.wireframeLinejoin=s.wireframeLinejoin,this.fog=s.fog,this}}const Mr=null;function Yg(){const E=new ArrayBuffer(4),s=new Float32Array(E),l=new Uint32Array(E),h=new Uint32Array(512),f=new Uint32Array(512);for(let T=0;T<256;++T){const A=T-127;A<-27?(h[T]=0,h[T|256]=32768,f[T]=24,f[T|256]=24):A<-14?(h[T]=1024>>-A-14,h[T|256]=1024>>-A-14|32768,f[T]=-A-1,f[T|256]=-A-1):A<=15?(h[T]=A+15<<10,h[T|256]=A+15<<10|32768,f[T]=13,f[T|256]=13):A<128?(h[T]=31744,h[T|256]=64512,f[T]=24,f[T|256]=24):(h[T]=31744,h[T|256]=64512,f[T]=13,f[T|256]=13)}const g=new Uint32Array(2048),_=new Uint32Array(64),b=new Uint32Array(64);for(let T=1;T<1024;++T){let A=T<<13,R=0;for(;!(A&8388608);)A<<=1,R-=8388608;A&=-8388609,R+=947912704,g[T]=A|R}for(let T=1024;T<2048;++T)g[T]=939524096+(T-1024<<13);for(let T=1;T<31;++T)_[T]=T<<23;_[31]=1199570944,_[32]=2147483648;for(let T=33;T<63;++T)_[T]=2147483648+(T-32<<23);_[63]=3347054592;for(let T=1;T<64;++T)T!==32&&(b[T]=1024);return{floatView:s,uint32View:l,baseTable:h,shiftTable:f,mantissaTable:g,exponentTable:_,offsetTable:b}}function Tr(E){Math.abs(E)>65504&&Mn("DataUtils.toHalfFloat(): Value out of range."),E=Ut(E,-65504,65504),Mr.floatView[0]=E;const s=Mr.uint32View[0],l=s>>23&511;return Mr.baseTable[l]+((s&8388607)>>Mr.shiftTable[l])}function It(E){const s=E>>10;return Mr.uint32View[0]=Mr.mantissaTable[Mr.offsetTable[s]+(E&1023)]+Mr.exponentTable[s],Mr.floatView[0]}class Br{static toHalfFloat(s){return Tr(s)}static fromHalfFloat(s){return It(s)}}const Ls=new ae,Ds=new St;let Or=0;class Ki{constructor(s,l,h=!1){if(Array.isArray(s))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Or++}),this.name="",this.array=s,this.itemSize=l,this.count=s!==void 0?s.length/l:0,this.normalized=h,this.usage=Vl,this.updateRanges=[],this.gpuType=Si,this.version=0}onUploadCallback(){}set needsUpdate(s){s===!0&&this.version++}setUsage(s){return this.usage=s,this}addUpdateRange(s,l){this.updateRanges.push({start:s,count:l})}clearUpdateRanges(){this.updateRanges.length=0}copy(s){return this.name=s.name,this.array=new s.array.constructor(s.array),this.itemSize=s.itemSize,this.count=s.count,this.normalized=s.normalized,this.usage=s.usage,this.gpuType=s.gpuType,this}copyAt(s,l,h){s*=this.itemSize,h*=l.itemSize;for(let f=0,g=this.itemSize;f<g;f++)this.array[s+f]=l.array[h+f];return this}copyArray(s){return this.array.set(s),this}applyMatrix3(s){if(this.itemSize===2)for(let l=0,h=this.count;l<h;l++)Ds.fromBufferAttribute(this,l),Ds.applyMatrix3(s),this.setXY(l,Ds.x,Ds.y);else if(this.itemSize===3)for(let l=0,h=this.count;l<h;l++)Ls.fromBufferAttribute(this,l),Ls.applyMatrix3(s),this.setXYZ(l,Ls.x,Ls.y,Ls.z);return this}applyMatrix4(s){for(let l=0,h=this.count;l<h;l++)Ls.fromBufferAttribute(this,l),Ls.applyMatrix4(s),this.setXYZ(l,Ls.x,Ls.y,Ls.z);return this}applyNormalMatrix(s){for(let l=0,h=this.count;l<h;l++)Ls.fromBufferAttribute(this,l),Ls.applyNormalMatrix(s),this.setXYZ(l,Ls.x,Ls.y,Ls.z);return this}transformDirection(s){for(let l=0,h=this.count;l<h;l++)Ls.fromBufferAttribute(this,l),Ls.transformDirection(s),this.setXYZ(l,Ls.x,Ls.y,Ls.z);return this}set(s,l=0){return this.array.set(s,l),this}getComponent(s,l){let h=this.array[s*this.itemSize+l];return this.normalized&&(h=Lr(h,this.array)),h}setComponent(s,l,h){return this.normalized&&(h=Qn(h,this.array)),this.array[s*this.itemSize+l]=h,this}getX(s){let l=this.array[s*this.itemSize];return this.normalized&&(l=Lr(l,this.array)),l}setX(s,l){return this.normalized&&(l=Qn(l,this.array)),this.array[s*this.itemSize]=l,this}getY(s){let l=this.array[s*this.itemSize+1];return this.normalized&&(l=Lr(l,this.array)),l}setY(s,l){return this.normalized&&(l=Qn(l,this.array)),this.array[s*this.itemSize+1]=l,this}getZ(s){let l=this.array[s*this.itemSize+2];return this.normalized&&(l=Lr(l,this.array)),l}setZ(s,l){return this.normalized&&(l=Qn(l,this.array)),this.array[s*this.itemSize+2]=l,this}getW(s){let l=this.array[s*this.itemSize+3];return this.normalized&&(l=Lr(l,this.array)),l}setW(s,l){return this.normalized&&(l=Qn(l,this.array)),this.array[s*this.itemSize+3]=l,this}setXY(s,l,h){return s*=this.itemSize,this.normalized&&(l=Qn(l,this.array),h=Qn(h,this.array)),this.array[s+0]=l,this.array[s+1]=h,this}setXYZ(s,l,h,f){return s*=this.itemSize,this.normalized&&(l=Qn(l,this.array),h=Qn(h,this.array),f=Qn(f,this.array)),this.array[s+0]=l,this.array[s+1]=h,this.array[s+2]=f,this}setXYZW(s,l,h,f,g){return s*=this.itemSize,this.normalized&&(l=Qn(l,this.array),h=Qn(h,this.array),f=Qn(f,this.array),g=Qn(g,this.array)),this.array[s+0]=l,this.array[s+1]=h,this.array[s+2]=f,this.array[s+3]=g,this}onUpload(s){return this.onUploadCallback=s,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const s={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(s.name=this.name),this.usage!==Vl&&(s.usage=this.usage),s}}class MA extends null{constructor(s,l,h){super(new Int8Array(s),l,h)}}class ao extends null{constructor(s,l,h){super(new Uint8Array(s),l,h)}}class Gp extends null{constructor(s,l,h){super(new Uint8ClampedArray(s),l,h)}}class $L extends null{constructor(s,l,h){super(new Int16Array(s),l,h)}}class Fs extends Ki{constructor(s,l,h){super(new Uint16Array(s),l,h)}}class Zg extends null{constructor(s,l,h){super(new Int32Array(s),l,h)}}class lS extends Ki{constructor(s,l,h){super(new Uint32Array(s),l,h)}}class $i extends null{constructor(s,l,h){super(new Uint16Array(s),l,h),this.isFloat16BufferAttribute=!0}getX(s){let l=It(this.array[s*this.itemSize]);return this.normalized&&(l=Lr(l,this.array)),l}setX(s,l){return this.normalized&&(l=Qn(l,this.array)),this.array[s*this.itemSize]=Tr(l),this}getY(s){let l=It(this.array[s*this.itemSize+1]);return this.normalized&&(l=Lr(l,this.array)),l}setY(s,l){return this.normalized&&(l=Qn(l,this.array)),this.array[s*this.itemSize+1]=Tr(l),this}getZ(s){let l=It(this.array[s*this.itemSize+2]);return this.normalized&&(l=Lr(l,this.array)),l}setZ(s,l){return this.normalized&&(l=Qn(l,this.array)),this.array[s*this.itemSize+2]=Tr(l),this}getW(s){let l=It(this.array[s*this.itemSize+3]);return this.normalized&&(l=Lr(l,this.array)),l}setW(s,l){return this.normalized&&(l=Qn(l,this.array)),this.array[s*this.itemSize+3]=Tr(l),this}setXY(s,l,h){return s*=this.itemSize,this.normalized&&(l=Qn(l,this.array),h=Qn(h,this.array)),this.array[s+0]=Tr(l),this.array[s+1]=Tr(h),this}setXYZ(s,l,h,f){return s*=this.itemSize,this.normalized&&(l=Qn(l,this.array),h=Qn(h,this.array),f=Qn(f,this.array)),this.array[s+0]=Tr(l),this.array[s+1]=Tr(h),this.array[s+2]=Tr(f),this}setXYZW(s,l,h,f,g){return s*=this.itemSize,this.normalized&&(l=Qn(l,this.array),h=Qn(h,this.array),f=Qn(f,this.array),g=Qn(g,this.array)),this.array[s+0]=Tr(l),this.array[s+1]=Tr(h),this.array[s+2]=Tr(f),this.array[s+3]=Tr(g),this}}class cn extends Ki{constructor(s,l,h){super(new Float32Array(s),l,h)}}let TA=0;const ra=new Dn,P_=new Hs,Kl=new ae,Po=new fi,fu=new fi,$s=new ae;class ht extends Zo{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:TA++}),this.uuid=Be(),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(s){return Array.isArray(s)?this.index=new(_A(s)?lS:Fs)(s,1):this.index=s,this}setIndirect(s){return this.indirect=s,this}getIndirect(){return this.indirect}getAttribute(s){return this.attributes[s]}setAttribute(s,l){return this.attributes[s]=l,this}deleteAttribute(s){return delete this.attributes[s],this}hasAttribute(s){return this.attributes[s]!==void 0}addGroup(s,l,h=0){this.groups.push({start:s,count:l,materialIndex:h})}clearGroups(){this.groups=[]}setDrawRange(s,l){this.drawRange.start=s,this.drawRange.count=l}applyMatrix4(s){const l=this.attributes.position;l!==void 0&&(l.applyMatrix4(s),l.needsUpdate=!0);const h=this.attributes.normal;if(h!==void 0){const g=new ts().getNormalMatrix(s);h.applyNormalMatrix(g),h.needsUpdate=!0}const f=this.attributes.tangent;return f!==void 0&&(f.transformDirection(s),f.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(s){return ra.makeRotationFromQuaternion(s),this.applyMatrix4(ra),this}rotateX(s){return ra.makeRotationX(s),this.applyMatrix4(ra),this}rotateY(s){return ra.makeRotationY(s),this.applyMatrix4(ra),this}rotateZ(s){return ra.makeRotationZ(s),this.applyMatrix4(ra),this}translate(s,l,h){return ra.makeTranslation(s,l,h),this.applyMatrix4(ra),this}scale(s,l,h){return ra.makeScale(s,l,h),this.applyMatrix4(ra),this}lookAt(s){return P_.lookAt(s),P_.updateMatrix(),this.applyMatrix4(P_.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Kl).negate(),this.translate(Kl.x,Kl.y,Kl.z),this}setFromPoints(s){const l=this.getAttribute("position");if(l===void 0){const h=[];for(let f=0,g=s.length;f<g;f++){const _=s[f];h.push(_.x,_.y,_.z||0)}this.setAttribute("position",new cn(h,3))}else{const h=Math.min(s.length,l.count);for(let f=0;f<h;f++){const g=s[f];l.setXYZ(f,g.x,g.y,g.z||0)}s.length>l.count&&Mn("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),l.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new fi);const s=this.attributes.position,l=this.morphAttributes.position;if(s&&s.isGLBufferAttribute){ci("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new ae(-1/0,-1/0,-1/0),new ae(1/0,1/0,1/0));return}if(s!==void 0){if(this.boundingBox.setFromBufferAttribute(s),l)for(let h=0,f=l.length;h<f;h++){const g=l[h];Po.setFromBufferAttribute(g),this.morphTargetsRelative?($s.addVectors(this.boundingBox.min,Po.min),this.boundingBox.expandByPoint($s),$s.addVectors(this.boundingBox.max,Po.max),this.boundingBox.expandByPoint($s)):(this.boundingBox.expandByPoint(Po.min),this.boundingBox.expandByPoint(Po.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&ci('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 Ps);const s=this.attributes.position,l=this.morphAttributes.position;if(s&&s.isGLBufferAttribute){ci("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new ae,1/0);return}if(s){const h=this.boundingSphere.center;if(Po.setFromBufferAttribute(s),l)for(let g=0,_=l.length;g<_;g++){const b=l[g];fu.setFromBufferAttribute(b),this.morphTargetsRelative?($s.addVectors(Po.min,fu.min),Po.expandByPoint($s),$s.addVectors(Po.max,fu.max),Po.expandByPoint($s)):(Po.expandByPoint(fu.min),Po.expandByPoint(fu.max))}Po.getCenter(h);let f=0;for(let g=0,_=s.count;g<_;g++)$s.fromBufferAttribute(s,g),f=Math.max(f,h.distanceToSquared($s));if(l)for(let g=0,_=l.length;g<_;g++){const b=l[g],T=this.morphTargetsRelative;for(let A=0,R=b.count;A<R;A++)$s.fromBufferAttribute(b,A),T&&(Kl.fromBufferAttribute(s,A),$s.add(Kl)),f=Math.max(f,h.distanceToSquared($s))}this.boundingSphere.radius=Math.sqrt(f),isNaN(this.boundingSphere.radius)&&ci('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const s=this.index,l=this.attributes;if(s===null||l.position===void 0||l.normal===void 0||l.uv===void 0){ci("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const h=l.position,f=l.normal,g=l.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Ki(new Float32Array(4*h.count),4));const _=this.getAttribute("tangent"),b=[],T=[];for(let qe=0;qe<h.count;qe++)b[qe]=new ae,T[qe]=new ae;const A=new ae,R=new ae,P=new ae,L=new St,D=new St,O=new St,W=new ae,Z=new ae;function Y(qe,xt,Et){A.fromBufferAttribute(h,qe),R.fromBufferAttribute(h,xt),P.fromBufferAttribute(h,Et),L.fromBufferAttribute(g,qe),D.fromBufferAttribute(g,xt),O.fromBufferAttribute(g,Et),R.sub(A),P.sub(A),D.sub(L),O.sub(L);const _n=1/(D.x*O.y-O.x*D.y);isFinite(_n)&&(W.copy(R).multiplyScalar(O.y).addScaledVector(P,-D.y).multiplyScalar(_n),Z.copy(P).multiplyScalar(D.x).addScaledVector(R,-O.x).multiplyScalar(_n),b[qe].add(W),b[xt].add(W),b[Et].add(W),T[qe].add(Z),T[xt].add(Z),T[Et].add(Z))}let ie=this.groups;ie.length===0&&(ie=[{start:0,count:s.count}]);for(let qe=0,xt=ie.length;qe<xt;++qe){const Et=ie[qe],_n=Et.start,ei=Et.count;for(let ii=_n,zi=_n+ei;ii<zi;ii+=3)Y(s.getX(ii+0),s.getX(ii+1),s.getX(ii+2))}const se=new ae,de=new ae,ke=new ae,$e=new ae;function et(qe){ke.fromBufferAttribute(f,qe),$e.copy(ke);const xt=b[qe];se.copy(xt),se.sub(ke.multiplyScalar(ke.dot(xt))).normalize(),de.crossVectors($e,xt);const _n=de.dot(T[qe])<0?-1:1;_.setXYZW(qe,se.x,se.y,se.z,_n)}for(let qe=0,xt=ie.length;qe<xt;++qe){const Et=ie[qe],_n=Et.start,ei=Et.count;for(let ii=_n,zi=_n+ei;ii<zi;ii+=3)et(s.getX(ii+0)),et(s.getX(ii+1)),et(s.getX(ii+2))}}computeVertexNormals(){const s=this.index,l=this.getAttribute("position");if(l!==void 0){let h=this.getAttribute("normal");if(h===void 0)h=new Ki(new Float32Array(l.count*3),3),this.setAttribute("normal",h);else for(let L=0,D=h.count;L<D;L++)h.setXYZ(L,0,0,0);const f=new ae,g=new ae,_=new ae,b=new ae,T=new ae,A=new ae,R=new ae,P=new ae;if(s)for(let L=0,D=s.count;L<D;L+=3){const O=s.getX(L+0),W=s.getX(L+1),Z=s.getX(L+2);f.fromBufferAttribute(l,O),g.fromBufferAttribute(l,W),_.fromBufferAttribute(l,Z),R.subVectors(_,g),P.subVectors(f,g),R.cross(P),b.fromBufferAttribute(h,O),T.fromBufferAttribute(h,W),A.fromBufferAttribute(h,Z),b.add(R),T.add(R),A.add(R),h.setXYZ(O,b.x,b.y,b.z),h.setXYZ(W,T.x,T.y,T.z),h.setXYZ(Z,A.x,A.y,A.z)}else for(let L=0,D=l.count;L<D;L+=3)f.fromBufferAttribute(l,L+0),g.fromBufferAttribute(l,L+1),_.fromBufferAttribute(l,L+2),R.subVectors(_,g),P.subVectors(f,g),R.cross(P),h.setXYZ(L+0,R.x,R.y,R.z),h.setXYZ(L+1,R.x,R.y,R.z),h.setXYZ(L+2,R.x,R.y,R.z);this.normalizeNormals(),h.needsUpdate=!0}}normalizeNormals(){const s=this.attributes.normal;for(let l=0,h=s.count;l<h;l++)$s.fromBufferAttribute(s,l),$s.normalize(),s.setXYZ(l,$s.x,$s.y,$s.z)}toNonIndexed(){function s(b,T){const A=b.array,R=b.itemSize,P=b.normalized,L=new A.constructor(T.length*R);let D=0,O=0;for(let W=0,Z=T.length;W<Z;W++){b.isInterleavedBufferAttribute?D=T[W]*b.data.stride+b.offset:D=T[W]*R;for(let Y=0;Y<R;Y++)L[O++]=A[D++]}return new Ki(L,R,P)}if(this.index===null)return Mn("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const l=new ht,h=this.index.array,f=this.attributes;for(const b in f){const T=f[b],A=s(T,h);l.setAttribute(b,A)}const g=this.morphAttributes;for(const b in g){const T=[],A=g[b];for(let R=0,P=A.length;R<P;R++){const L=A[R],D=s(L,h);T.push(D)}l.morphAttributes[b]=T}l.morphTargetsRelative=this.morphTargetsRelative;const _=this.groups;for(let b=0,T=_.length;b<T;b++){const A=_[b];l.addGroup(A.start,A.count,A.materialIndex)}return l}toJSON(){const s={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),Object.keys(this.userData).length>0&&(s.userData=this.userData),this.parameters!==void 0){const T=this.parameters;for(const A in T)T[A]!==void 0&&(s[A]=T[A]);return s}s.data={attributes:{}};const l=this.index;l!==null&&(s.data.index={type:l.array.constructor.name,array:Array.prototype.slice.call(l.array)});const h=this.attributes;for(const T in h){const A=h[T];s.data.attributes[T]=A.toJSON(s.data)}const f={};let g=!1;for(const T in this.morphAttributes){const A=this.morphAttributes[T],R=[];for(let P=0,L=A.length;P<L;P++){const D=A[P];R.push(D.toJSON(s.data))}R.length>0&&(f[T]=R,g=!0)}g&&(s.data.morphAttributes=f,s.data.morphTargetsRelative=this.morphTargetsRelative);const _=this.groups;_.length>0&&(s.data.groups=JSON.parse(JSON.stringify(_)));const b=this.boundingSphere;return b!==null&&(s.data.boundingSphere=b.toJSON()),s}clone(){return new this.constructor().copy(this)}copy(s){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const l={};this.name=s.name;const h=s.index;h!==null&&this.setIndex(h.clone());const f=s.attributes;for(const A in f){const R=f[A];this.setAttribute(A,R.clone(l))}const g=s.morphAttributes;for(const A in g){const R=[],P=g[A];for(let L=0,D=P.length;L<D;L++)R.push(P[L].clone(l));this.morphAttributes[A]=R}this.morphTargetsRelative=s.morphTargetsRelative;const _=s.groups;for(let A=0,R=_.length;A<R;A++){const P=_[A];this.addGroup(P.start,P.count,P.materialIndex)}const b=s.boundingBox;b!==null&&(this.boundingBox=b.clone());const T=s.boundingSphere;return T!==null&&(this.boundingSphere=T.clone()),this.drawRange.start=s.drawRange.start,this.drawRange.count=s.drawRange.count,this.userData=s.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const I_=new Dn,rr=new As,id=new Ps,pu=new ae,wr=new ae,Jl=new ae,Cs=new ae,Gn=new ae,gf=new ae,Ql=new ae,mu=new ae;class dl extends Hs{constructor(s=new ht,l=new Zl){super(),this.isMesh=!0,this.type="Mesh",this.geometry=s,this.material=l,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(s,l){return super.copy(s,l),s.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=s.morphTargetInfluences.slice()),s.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},s.morphTargetDictionary)),this.material=Array.isArray(s.material)?s.material.slice():s.material,this.geometry=s.geometry,this}updateMorphTargets(){const l=this.geometry.morphAttributes,h=Object.keys(l);if(h.length>0){const f=l[h[0]];if(f!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let g=0,_=f.length;g<_;g++){const b=f[g].name||String(g);this.morphTargetInfluences.push(0),this.morphTargetDictionary[b]=g}}}}getVertexPosition(s,l){const h=this.geometry,f=h.attributes.position,g=h.morphAttributes.position,_=h.morphTargetsRelative;l.fromBufferAttribute(f,s);const b=this.morphTargetInfluences;if(g&&b){gf.set(0,0,0);for(let T=0,A=g.length;T<A;T++){const R=b[T],P=g[T];R!==0&&(Gn.fromBufferAttribute(P,s),_?gf.addScaledVector(Gn,R):gf.addScaledVector(Gn.sub(l),R))}l.add(gf)}return l}raycast(s,l){const h=this.geometry,f=this.material,g=this.matrixWorld;f!==void 0&&(h.boundingSphere===null&&h.computeBoundingSphere(),id.copy(h.boundingSphere),id.applyMatrix4(g),rr.copy(s.ray).recast(s.near),!(id.containsPoint(rr.origin)===!1&&(rr.intersectSphere(id,pu)===null||rr.origin.distanceToSquared(pu)>Cp(s.far-s.near,2)))&&(I_.copy(g).invert(),rr.copy(s.ray).applyMatrix4(I_),!(h.boundingBox!==null&&rr.intersectsBox(h.boundingBox)===!1)&&this._computeIntersections(s,l,rr)))}_computeIntersections(s,l,h){let f;const g=this.geometry,_=this.material,b=g.index,T=g.attributes.position,A=g.attributes.uv,R=g.attributes.uv1,P=g.attributes.normal,L=g.groups,D=g.drawRange;if(b!==null)if(Array.isArray(_))for(let O=0,W=L.length;O<W;O++){const Z=L[O],Y=_[Z.materialIndex],ie=Math.max(Z.start,D.start),se=Math.min(b.count,Math.min(Z.start+Z.count,D.start+D.count));for(let de=ie,ke=se;de<ke;de+=3){const $e=b.getX(de),et=b.getX(de+1),qe=b.getX(de+2);f=gu(this,Y,s,h,A,R,P,$e,et,qe),f&&(f.faceIndex=Math.floor(de/3),f.face.materialIndex=Z.materialIndex,l.push(f))}}else{const O=Math.max(0,D.start),W=Math.min(b.count,D.start+D.count);for(let Z=O,Y=W;Z<Y;Z+=3){const ie=b.getX(Z),se=b.getX(Z+1),de=b.getX(Z+2);f=gu(this,_,s,h,A,R,P,ie,se,de),f&&(f.faceIndex=Math.floor(Z/3),l.push(f))}}else if(T!==void 0)if(Array.isArray(_))for(let O=0,W=L.length;O<W;O++){const Z=L[O],Y=_[Z.materialIndex],ie=Math.max(Z.start,D.start),se=Math.min(T.count,Math.min(Z.start+Z.count,D.start+D.count));for(let de=ie,ke=se;de<ke;de+=3){const $e=de,et=de+1,qe=de+2;f=gu(this,Y,s,h,A,R,P,$e,et,qe),f&&(f.faceIndex=Math.floor(de/3),f.face.materialIndex=Z.materialIndex,l.push(f))}}else{const O=Math.max(0,D.start),W=Math.min(T.count,D.start+D.count);for(let Z=O,Y=W;Z<Y;Z+=3){const ie=Z,se=Z+1,de=Z+2;f=gu(this,_,s,h,A,R,P,ie,se,de),f&&(f.faceIndex=Math.floor(Z/3),l.push(f))}}}}function Wp(E,s,l,h,f,g,_,b){let T;if(s.side===we?T=h.intersectTriangle(_,g,f,!0,b):T=h.intersectTriangle(f,g,_,s.side===Me,b),T===null)return null;mu.copy(b),mu.applyMatrix4(E.matrixWorld);const A=l.ray.origin.distanceTo(mu);return A<l.near||A>l.far?null:{distance:A,point:mu.clone(),object:E}}function gu(E,s,l,h,f,g,_,b,T,A){E.getVertexPosition(b,wr),E.getVertexPosition(T,Jl),E.getVertexPosition(A,Cs);const R=Wp(E,s,l,h,wr,Jl,Cs,Ql);if(R){const P=new ae;ir.getBarycoord(Ql,wr,Jl,Cs,P),f&&(R.uv=ir.getInterpolatedAttribute(f,b,T,A,P,new St)),g&&(R.uv1=ir.getInterpolatedAttribute(g,b,T,A,P,new St)),_&&(R.normal=ir.getInterpolatedAttribute(_,b,T,A,P,new ae),R.normal.dot(h.direction)>0&&R.normal.multiplyScalar(-1));const L={a:b,b:T,c:A,normal:new ae,materialIndex:0};ir.getNormal(wr,Jl,Cs,L.normal),R.face=L,R.barycoord=P}return R}class yu extends ht{constructor(s=1,l=1,h=1,f=1,g=1,_=1){super(),this.type="BoxGeometry",this.parameters={width:s,height:l,depth:h,widthSegments:f,heightSegments:g,depthSegments:_};const b=this;f=Math.floor(f),g=Math.floor(g),_=Math.floor(_);const T=[],A=[],R=[],P=[];let L=0,D=0;O("z","y","x",-1,-1,h,l,s,_,g,0),O("z","y","x",1,-1,h,l,-s,_,g,1),O("x","z","y",1,1,s,h,l,f,_,2),O("x","z","y",1,-1,s,h,-l,f,_,3),O("x","y","z",1,-1,s,l,h,f,g,4),O("x","y","z",-1,-1,s,l,-h,f,g,5),this.setIndex(T),this.setAttribute("position",new cn(A,3)),this.setAttribute("normal",new cn(R,3)),this.setAttribute("uv",new cn(P,2));function O(W,Z,Y,ie,se,de,ke,$e,et,qe,xt){const Et=de/et,_n=ke/qe,ei=de/2,ii=ke/2,zi=$e/2,Fi=et+1,Zs=qe+1;let dr=0,ca=0;const gs=new ae;for(let Os=0;Os<Zs;Os++){const us=Os*_n-ii;for(let Uo=0;Uo<Fi;Uo++){const kr=Uo*Et-ei;gs[W]=kr*ie,gs[Z]=us*se,gs[Y]=zi,A.push(gs.x,gs.y,gs.z),gs[W]=0,gs[Z]=0,gs[Y]=$e>0?1:-1,R.push(gs.x,gs.y,gs.z),P.push(Uo/et),P.push(1-Os/qe),dr+=1}}for(let Os=0;Os<qe;Os++)for(let us=0;us<et;us++){const Uo=L+us+Fi*Os,kr=L+us+Fi*(Os+1),Bd=L+(us+1)+Fi*(Os+1),Xf=L+(us+1)+Fi*Os;T.push(Uo,kr,Xf),T.push(kr,Bd,Xf),ca+=6}b.addGroup(D,ca,xt),D+=ca,L+=dr}}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}static fromJSON(s){return new yu(s.width,s.height,s.depth,s.widthSegments,s.heightSegments,s.depthSegments)}}function sd(E){const s={};for(const l in E){s[l]={};for(const h in E[l]){const f=E[l][h];f&&(f.isColor||f.isMatrix3||f.isMatrix4||f.isVector2||f.isVector3||f.isVector4||f.isTexture||f.isQuaternion)?f.isRenderTargetTexture?(Mn("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),s[l][h]=null):s[l][h]=f.clone():Array.isArray(f)?s[l][h]=f.slice():s[l][h]=f}}return s}function Hp(E){const s={};for(let l=0;l<E.length;l++){const h=sd(E[l]);for(const f in h)s[f]=h[f]}return s}function L_(E){const s=[];for(let l=0;l<E.length;l++)s.push(E[l].clone());return s}function Kg(E){const s=E.getRenderTarget();return s===null?E.outputColorSpace:s.isXRRenderTarget===!0?s.texture.colorSpace:H.workingColorSpace}const Ji={clone:sd,merge:Hp};var cS=`void main() {
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
}`,$p=`void main() {
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
}`;class fl extends null{constructor(s){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=cS,this.fragmentShader=$p,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,s!==void 0&&this.setValues(s)}copy(s){return super.copy(s),this.fragmentShader=s.fragmentShader,this.vertexShader=s.vertexShader,this.uniforms=sd(s.uniforms),this.uniformsGroups=L_(s.uniformsGroups),this.defines=Object.assign({},s.defines),this.wireframe=s.wireframe,this.wireframeLinewidth=s.wireframeLinewidth,this.fog=s.fog,this.lights=s.lights,this.clipping=s.clipping,this.extensions=Object.assign({},s.extensions),this.glslVersion=s.glslVersion,this}toJSON(s){const l=super.toJSON(s);l.glslVersion=this.glslVersion,l.uniforms={};for(const f in this.uniforms){const _=this.uniforms[f].value;_&&_.isTexture?l.uniforms[f]={type:"t",value:_.toJSON(s).uuid}:_&&_.isColor?l.uniforms[f]={type:"c",value:_.getHex()}:_&&_.isVector2?l.uniforms[f]={type:"v2",value:_.toArray()}:_&&_.isVector3?l.uniforms[f]={type:"v3",value:_.toArray()}:_&&_.isVector4?l.uniforms[f]={type:"v4",value:_.toArray()}:_&&_.isMatrix3?l.uniforms[f]={type:"m3",value:_.toArray()}:_&&_.isMatrix4?l.uniforms[f]={type:"m4",value:_.toArray()}:l.uniforms[f]={value:_}}Object.keys(this.defines).length>0&&(l.defines=this.defines),l.vertexShader=this.vertexShader,l.fragmentShader=this.fragmentShader,l.lights=this.lights,l.clipping=this.clipping;const h={};for(const f in this.extensions)this.extensions[f]===!0&&(h[f]=!0);return Object.keys(h).length>0&&(l.extensions=h),l}}class rd extends Hs{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Dn,this.projectionMatrix=new Dn,this.projectionMatrixInverse=new Dn,this.coordinateSystem=rl,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(s,l){return super.copy(s,l),this.matrixWorldInverse.copy(s.matrixWorldInverse),this.projectionMatrix.copy(s.projectionMatrix),this.projectionMatrixInverse.copy(s.projectionMatrixInverse),this.coordinateSystem=s.coordinateSystem,this}getWorldDirection(s){return super.getWorldDirection(s).negate()}updateMatrixWorld(s){super.updateMatrixWorld(s),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(s,l){super.updateWorldMatrix(s,l),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const fs=new ae,D_=new St,Jg=new St;class Io extends null{constructor(s=50,l=1,h=.1,f=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=s,this.zoom=1,this.near=h,this.far=f,this.focus=10,this.aspect=l,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(s,l){return super.copy(s,l),this.fov=s.fov,this.zoom=s.zoom,this.near=s.near,this.far=s.far,this.focus=s.focus,this.aspect=s.aspect,this.view=s.view===null?null:Object.assign({},s.view),this.filmGauge=s.filmGauge,this.filmOffset=s.filmOffset,this}setFocalLength(s){const l=.5*this.getFilmHeight()/s;this.fov=Ie*2*Math.atan(l),this.updateProjectionMatrix()}getFocalLength(){const s=Math.tan(Ko*.5*this.fov);return .5*this.getFilmHeight()/s}getEffectiveFOV(){return Ie*2*Math.atan(Math.tan(Ko*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(s,l,h){fs.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),l.set(fs.x,fs.y).multiplyScalar(-s/fs.z),fs.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),h.set(fs.x,fs.y).multiplyScalar(-s/fs.z)}getViewSize(s,l){return this.getViewBounds(s,D_,Jg),l.subVectors(Jg,D_)}setViewOffset(s,l,h,f,g,_){this.aspect=s/l,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=s,this.view.fullHeight=l,this.view.offsetX=h,this.view.offsetY=f,this.view.width=g,this.view.height=_,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const s=this.near;let l=s*Math.tan(Ko*.5*this.fov)/this.zoom,h=2*l,f=this.aspect*h,g=-.5*f;const _=this.view;if(this.view!==null&&this.view.enabled){const T=_.fullWidth,A=_.fullHeight;g+=_.offsetX*f/T,l-=_.offsetY*h/A,f*=_.width/T,h*=_.height/A}const b=this.filmOffset;b!==0&&(g+=s*b/this.getFilmWidth()),this.projectionMatrix.makePerspective(g,g+f,l,l-h,s,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(s){const l=super.toJSON(s);return l.object.fov=this.fov,l.object.zoom=this.zoom,l.object.near=this.near,l.object.far=this.far,l.object.focus=this.focus,l.object.aspect=this.aspect,this.view!==null&&(l.object.view=Object.assign({},this.view)),l.object.filmGauge=this.filmGauge,l.object.filmOffset=this.filmOffset,l}}const od=null,ad=1;class lo extends null{constructor(s,l,h){super(),this.type="CubeCamera",this.renderTarget=h,this.coordinateSystem=null,this.activeMipmapLevel=0;const f=new Io(od,ad,s,l);f.layers=this.layers,this.add(f);const g=new Io(od,ad,s,l);g.layers=this.layers,this.add(g);const _=new Io(od,ad,s,l);_.layers=this.layers,this.add(_);const b=new Io(od,ad,s,l);b.layers=this.layers,this.add(b);const T=new Io(od,ad,s,l);T.layers=this.layers,this.add(T);const A=new Io(od,ad,s,l);A.layers=this.layers,this.add(A)}updateCoordinateSystem(){const s=this.coordinateSystem,l=this.children.concat(),[h,f,g,_,b,T]=l;for(const A of l)this.remove(A);if(s===rl)h.up.set(0,1,0),h.lookAt(1,0,0),f.up.set(0,1,0),f.lookAt(-1,0,0),g.up.set(0,0,-1),g.lookAt(0,1,0),_.up.set(0,0,1),_.lookAt(0,-1,0),b.up.set(0,1,0),b.lookAt(0,0,1),T.up.set(0,1,0),T.lookAt(0,0,-1);else if(s===Up)h.up.set(0,-1,0),h.lookAt(-1,0,0),f.up.set(0,-1,0),f.lookAt(1,0,0),g.up.set(0,0,1),g.lookAt(0,1,0),_.up.set(0,0,-1),_.lookAt(0,-1,0),b.up.set(0,-1,0),b.lookAt(0,0,1),T.up.set(0,-1,0),T.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+s);for(const A of l)this.add(A),A.updateMatrixWorld()}update(s,l){this.parent===null&&this.updateMatrixWorld();const{renderTarget:h,activeMipmapLevel:f}=this;this.coordinateSystem!==s.coordinateSystem&&(this.coordinateSystem=s.coordinateSystem,this.updateCoordinateSystem());const[g,_,b,T,A,R]=this.children,P=s.getRenderTarget(),L=s.getActiveCubeFace(),D=s.getActiveMipmapLevel(),O=s.xr.enabled;s.xr.enabled=!1;const W=h.texture.generateMipmaps;h.texture.generateMipmaps=!1,s.setRenderTarget(h,0,f),s.render(l,g),s.setRenderTarget(h,1,f),s.render(l,_),s.setRenderTarget(h,2,f),s.render(l,b),s.setRenderTarget(h,3,f),s.render(l,T),s.setRenderTarget(h,4,f),s.render(l,A),h.texture.generateMipmaps=W,s.setRenderTarget(h,5,f),s.render(l,R),s.setRenderTarget(P,L,D),s.xr.enabled=O,h.texture.needsPMREMUpdate=!0}}class ld extends null{constructor(s=[],l=Cr,h,f,g,_,b,T,A,R){super(s,l,h,f,g,_,b,T,A,R),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(s){this.image=s}}class _u extends null{constructor(s=1,l={}){super(s,s,l),this.isWebGLCubeRenderTarget=!0;const h={width:s,height:s,depth:1},f=[h,h,h,h,h,h];this.texture=new ld(f),this._setTextureOptions(l),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(s,l){this.texture.type=l.type,this.texture.colorSpace=l.colorSpace,this.texture.generateMipmaps=l.generateMipmaps,this.texture.minFilter=l.minFilter,this.texture.magFilter=l.magFilter;const h={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 );
}
`},f=new yu(5,5,5),g=new fl({name:"CubemapFromEquirect",uniforms:sd(h.uniforms),vertexShader:h.vertexShader,fragmentShader:h.fragmentShader,side:we,blending:ve});g.uniforms.tEquirect.value=l;const _=new dl(f,g),b=l.minFilter;return l.minFilter===Vs&&(l.minFilter=Yn),new lo(1,10,this).update(s,_),l.minFilter=b,_.geometry.dispose(),_.material.dispose(),this}clear(s,l=!0,h=!0,f=!0){const g=s.getRenderTarget();for(let _=0;_<6;_++)s.setRenderTarget(this,_),s.clear(l,h,f);s.setRenderTarget(g)}}class xu extends Hs{constructor(){super(),this.isGroup=!0,this.type="Group"}}const F_={type:"move"};class Bs{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new xu,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 xu,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new ae,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new ae),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new xu,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new ae,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new ae),this._grip}dispatchEvent(s){return this._targetRay!==null&&this._targetRay.dispatchEvent(s),this._grip!==null&&this._grip.dispatchEvent(s),this._hand!==null&&this._hand.dispatchEvent(s),this}connect(s){if(s&&s.hand){const l=this._hand;if(l)for(const h of s.hand.values())this._getHandJoint(l,h)}return this.dispatchEvent({type:"connected",data:s}),this}disconnect(s){return this.dispatchEvent({type:"disconnected",data:s}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(s,l,h){let f=null,g=null,_=null;const b=this._targetRay,T=this._grip,A=this._hand;if(s&&l.session.visibilityState!=="visible-blurred"){if(A&&s.hand){_=!0;for(const W of s.hand.values()){const Z=l.getJointPose(W,h),Y=this._getHandJoint(A,W);Z!==null&&(Y.matrix.fromArray(Z.transform.matrix),Y.matrix.decompose(Y.position,Y.rotation,Y.scale),Y.matrixWorldNeedsUpdate=!0,Y.jointRadius=Z.radius),Y.visible=Z!==null}const R=A.joints["index-finger-tip"],P=A.joints["thumb-tip"],L=R.position.distanceTo(P.position),D=.02,O=.005;A.inputState.pinching&&L>D+O?(A.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:s.handedness,target:this})):!A.inputState.pinching&&L<=D-O&&(A.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:s.handedness,target:this}))}else T!==null&&s.gripSpace&&(g=l.getPose(s.gripSpace,h),g!==null&&(T.matrix.fromArray(g.transform.matrix),T.matrix.decompose(T.position,T.rotation,T.scale),T.matrixWorldNeedsUpdate=!0,g.linearVelocity?(T.hasLinearVelocity=!0,T.linearVelocity.copy(g.linearVelocity)):T.hasLinearVelocity=!1,g.angularVelocity?(T.hasAngularVelocity=!0,T.angularVelocity.copy(g.angularVelocity)):T.hasAngularVelocity=!1));b!==null&&(f=l.getPose(s.targetRaySpace,h),f===null&&g!==null&&(f=g),f!==null&&(b.matrix.fromArray(f.transform.matrix),b.matrix.decompose(b.position,b.rotation,b.scale),b.matrixWorldNeedsUpdate=!0,f.linearVelocity?(b.hasLinearVelocity=!0,b.linearVelocity.copy(f.linearVelocity)):b.hasLinearVelocity=!1,f.angularVelocity?(b.hasAngularVelocity=!0,b.angularVelocity.copy(f.angularVelocity)):b.hasAngularVelocity=!1,this.dispatchEvent(F_)))}return b!==null&&(b.visible=f!==null),T!==null&&(T.visible=g!==null),A!==null&&(A.visible=_!==null),this}_getHandJoint(s,l){if(s.joints[l.jointName]===void 0){const h=new xu;h.matrixAutoUpdate=!1,h.visible=!1,s.joints[l.jointName]=h,s.add(h)}return s.joints[l.jointName]}}class ec{constructor(s,l=25e-5){this.isFogExp2=!0,this.name="",this.color=new Zn(s),this.density=l}clone(){return new ec(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class tc{constructor(s,l=1,h=1e3){this.isFog=!0,this.name="",this.color=new Zn(s),this.near=l,this.far=h}clone(){return new tc(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class B_ extends null{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 Is,this.environmentIntensity=1,this.environmentRotation=new Is,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(s,l){return super.copy(s,l),s.background!==null&&(this.background=s.background.clone()),s.environment!==null&&(this.environment=s.environment.clone()),s.fog!==null&&(this.fog=s.fog.clone()),this.backgroundBlurriness=s.backgroundBlurriness,this.backgroundIntensity=s.backgroundIntensity,this.backgroundRotation.copy(s.backgroundRotation),this.environmentIntensity=s.environmentIntensity,this.environmentRotation.copy(s.environmentRotation),s.overrideMaterial!==null&&(this.overrideMaterial=s.overrideMaterial.clone()),this.matrixAutoUpdate=s.matrixAutoUpdate,this}toJSON(s){const l=super.toJSON(s);return this.fog!==null&&(l.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(l.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(l.object.backgroundIntensity=this.backgroundIntensity),l.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(l.object.environmentIntensity=this.environmentIntensity),l.object.environmentRotation=this.environmentRotation.toArray(),l}}class nc{constructor(s,l){this.isInterleavedBuffer=!0,this.array=s,this.stride=l,this.count=s!==void 0?s.length/l:0,this.usage=Vl,this.updateRanges=[],this.version=0,this.uuid=Be()}onUploadCallback(){}set needsUpdate(s){s===!0&&this.version++}setUsage(s){return this.usage=s,this}addUpdateRange(s,l){this.updateRanges.push({start:s,count:l})}clearUpdateRanges(){this.updateRanges.length=0}copy(s){return this.array=new s.array.constructor(s.array),this.count=s.count,this.stride=s.stride,this.usage=s.usage,this}copyAt(s,l,h){s*=this.stride,h*=l.stride;for(let f=0,g=this.stride;f<g;f++)this.array[s+f]=l.array[h+f];return this}set(s,l=0){return this.array.set(s,l),this}clone(s){s.arrayBuffers===void 0&&(s.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Be()),s.arrayBuffers[this.array.buffer._uuid]===void 0&&(s.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const l=new this.array.constructor(s.arrayBuffers[this.array.buffer._uuid]),h=new this.constructor(l,this.stride);return h.setUsage(this.usage),h}onUpload(s){return this.onUploadCallback=s,this}toJSON(s){return s.arrayBuffers===void 0&&(s.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Be()),s.arrayBuffers[this.array.buffer._uuid]===void 0&&(s.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 cr=new ae;class Lo{constructor(s,l,h,f=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=s,this.itemSize=l,this.offset=h,this.normalized=f}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(s){this.data.needsUpdate=s}applyMatrix4(s){for(let l=0,h=this.data.count;l<h;l++)cr.fromBufferAttribute(this,l),cr.applyMatrix4(s),this.setXYZ(l,cr.x,cr.y,cr.z);return this}applyNormalMatrix(s){for(let l=0,h=this.count;l<h;l++)cr.fromBufferAttribute(this,l),cr.applyNormalMatrix(s),this.setXYZ(l,cr.x,cr.y,cr.z);return this}transformDirection(s){for(let l=0,h=this.count;l<h;l++)cr.fromBufferAttribute(this,l),cr.transformDirection(s),this.setXYZ(l,cr.x,cr.y,cr.z);return this}getComponent(s,l){let h=this.array[s*this.data.stride+this.offset+l];return this.normalized&&(h=Lr(h,this.array)),h}setComponent(s,l,h){return this.normalized&&(h=Qn(h,this.array)),this.data.array[s*this.data.stride+this.offset+l]=h,this}setX(s,l){return this.normalized&&(l=Qn(l,this.array)),this.data.array[s*this.data.stride+this.offset]=l,this}setY(s,l){return this.normalized&&(l=Qn(l,this.array)),this.data.array[s*this.data.stride+this.offset+1]=l,this}setZ(s,l){return this.normalized&&(l=Qn(l,this.array)),this.data.array[s*this.data.stride+this.offset+2]=l,this}setW(s,l){return this.normalized&&(l=Qn(l,this.array)),this.data.array[s*this.data.stride+this.offset+3]=l,this}getX(s){let l=this.data.array[s*this.data.stride+this.offset];return this.normalized&&(l=Lr(l,this.array)),l}getY(s){let l=this.data.array[s*this.data.stride+this.offset+1];return this.normalized&&(l=Lr(l,this.array)),l}getZ(s){let l=this.data.array[s*this.data.stride+this.offset+2];return this.normalized&&(l=Lr(l,this.array)),l}getW(s){let l=this.data.array[s*this.data.stride+this.offset+3];return this.normalized&&(l=Lr(l,this.array)),l}setXY(s,l,h){return s=s*this.data.stride+this.offset,this.normalized&&(l=Qn(l,this.array),h=Qn(h,this.array)),this.data.array[s+0]=l,this.data.array[s+1]=h,this}setXYZ(s,l,h,f){return s=s*this.data.stride+this.offset,this.normalized&&(l=Qn(l,this.array),h=Qn(h,this.array),f=Qn(f,this.array)),this.data.array[s+0]=l,this.data.array[s+1]=h,this.data.array[s+2]=f,this}setXYZW(s,l,h,f,g){return s=s*this.data.stride+this.offset,this.normalized&&(l=Qn(l,this.array),h=Qn(h,this.array),f=Qn(f,this.array),g=Qn(g,this.array)),this.data.array[s+0]=l,this.data.array[s+1]=h,this.data.array[s+2]=f,this.data.array[s+3]=g,this}clone(s){if(s===void 0){su("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const l=[];for(let h=0;h<this.count;h++){const f=h*this.data.stride+this.offset;for(let g=0;g<this.itemSize;g++)l.push(this.data.array[f+g])}return new Ki(new this.array.constructor(l),this.itemSize,this.normalized)}else return s.interleavedBuffers===void 0&&(s.interleavedBuffers={}),s.interleavedBuffers[this.data.uuid]===void 0&&(s.interleavedBuffers[this.data.uuid]=this.data.clone(s)),new Lo(s.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(s){if(s===void 0){su("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const l=[];for(let h=0;h<this.count;h++){const f=h*this.data.stride+this.offset;for(let g=0;g<this.itemSize;g++)l.push(this.data.array[f+g])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:l,normalized:this.normalized}}else return s.interleavedBuffers===void 0&&(s.interleavedBuffers={}),s.interleavedBuffers[this.data.uuid]===void 0&&(s.interleavedBuffers[this.data.uuid]=this.data.toJSON(s)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}class Qg extends Sr{constructor(s){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Zn(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(s)}copy(s){return super.copy(s),this.color.copy(s.color),this.map=s.map,this.alphaMap=s.alphaMap,this.rotation=s.rotation,this.sizeAttenuation=s.sizeAttenuation,this.fog=s.fog,this}}let pl;const vu=new ae,ic=new ae,Oa=new ae,ml=new St,qs=new St,sc=new Dn,cd=new ae,Ua=new ae,rc=new ae,bu=new St,oc=new St,Su=new St;class ud extends Hs{constructor(s=new Qg){if(super(),this.isSprite=!0,this.type="Sprite",pl===void 0){pl=new ht;const l=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),h=new nc(l,5);pl.setIndex([0,1,2,0,2,3]),pl.setAttribute("position",new Lo(h,3,0,!1)),pl.setAttribute("uv",new Lo(h,2,3,!1))}this.geometry=pl,this.material=s,this.center=new St(.5,.5),this.count=1}raycast(s,l){s.camera===null&&ci('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),ic.setFromMatrixScale(this.matrixWorld),sc.copy(s.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(s.camera.matrixWorldInverse,this.matrixWorld),Oa.setFromMatrixPosition(this.modelViewMatrix),s.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&ic.multiplyScalar(-Oa.z);const h=this.material.rotation;let f,g;h!==0&&(g=Math.cos(h),f=Math.sin(h));const _=this.center;yf(cd.set(-.5,-.5,0),Oa,_,ic,f,g),yf(Ua.set(.5,-.5,0),Oa,_,ic,f,g),yf(rc.set(.5,.5,0),Oa,_,ic,f,g),bu.set(0,0),oc.set(1,0),Su.set(1,1);let b=s.ray.intersectTriangle(cd,Ua,rc,!1,vu);if(b===null&&(yf(Ua.set(-.5,.5,0),Oa,_,ic,f,g),oc.set(0,1),b=s.ray.intersectTriangle(cd,rc,Ua,!1,vu),b===null))return;const T=s.ray.origin.distanceTo(vu);T<s.near||T>s.far||l.push({distance:T,point:vu.clone(),uv:ir.getInterpolation(vu,cd,Ua,rc,bu,oc,Su,new St),face:null,object:this})}copy(s,l){return super.copy(s,l),s.center!==void 0&&this.center.copy(s.center),this.material=s.material,this}}function yf(E,s,l,h,f,g){ml.subVectors(E,l).addScalar(.5).multiply(h),f!==void 0?(qs.x=g*ml.x-f*ml.y,qs.y=f*ml.x+g*ml.y):qs.copy(ml),E.copy(s),E.x+=qs.x,E.y+=qs.y,E.applyMatrix4(sc)}const Mu=new ae,hd=new ae;class qp extends null{constructor(){super(),this.isLOD=!0,this._currentLevel=0,this.type="LOD",Object.defineProperties(this,{levels:{enumerable:!0,value:[]}}),this.autoUpdate=!0}copy(s){super.copy(s,!1);const l=s.levels;for(let h=0,f=l.length;h<f;h++){const g=l[h];this.addLevel(g.object.clone(),g.distance,g.hysteresis)}return this.autoUpdate=s.autoUpdate,this}addLevel(s,l=0,h=0){l=Math.abs(l);const f=this.levels;let g;for(g=0;g<f.length&&!(l<f[g].distance);g++);return f.splice(g,0,{distance:l,hysteresis:h,object:s}),this.add(s),this}removeLevel(s){const l=this.levels;for(let h=0;h<l.length;h++)if(l[h].distance===s){const f=l.splice(h,1);return this.remove(f[0].object),!0}return!1}getCurrentLevel(){return this._currentLevel}getObjectForDistance(s){const l=this.levels;if(l.length>0){let h,f;for(h=1,f=l.length;h<f;h++){let g=l[h].distance;if(l[h].object.visible&&(g-=g*l[h].hysteresis),s<g)break}return l[h-1].object}return null}raycast(s,l){if(this.levels.length>0){Mu.setFromMatrixPosition(this.matrixWorld);const f=s.ray.origin.distanceTo(Mu);this.getObjectForDistance(f).raycast(s,l)}}update(s){const l=this.levels;if(l.length>1){Mu.setFromMatrixPosition(s.matrixWorld),hd.setFromMatrixPosition(this.matrixWorld);const h=Mu.distanceTo(hd)/s.zoom;l[0].object.visible=!0;let f,g;for(f=1,g=l.length;f<g;f++){let _=l[f].distance;if(l[f].object.visible&&(_-=_*l[f].hysteresis),h>=_)l[f-1].object.visible=!1,l[f].object.visible=!0;else break}for(this._currentLevel=f-1;f<g;f++)l[f].object.visible=!1}}toJSON(s){const l=super.toJSON(s);this.autoUpdate===!1&&(l.object.autoUpdate=!1),l.object.levels=[];const h=this.levels;for(let f=0,g=h.length;f<g;f++){const _=h[f];l.object.levels.push({object:_.object.uuid,distance:_.distance,hysteresis:_.hysteresis})}return l}}const e0=new ae,Xp=new as,t0=new as,uS=new ae,_f=new Dn,Tu=new ae,jp=new Ps,O_=new Dn,Yp=new As;class U_ extends null{constructor(s,l){super(s,l),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Cg,this.bindMatrix=new Dn,this.bindMatrixInverse=new Dn,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const s=this.geometry;this.boundingBox===null&&(this.boundingBox=new fi),this.boundingBox.makeEmpty();const l=s.getAttribute("position");for(let h=0;h<l.count;h++)this.getVertexPosition(h,Tu),this.boundingBox.expandByPoint(Tu)}computeBoundingSphere(){const s=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Ps),this.boundingSphere.makeEmpty();const l=s.getAttribute("position");for(let h=0;h<l.count;h++)this.getVertexPosition(h,Tu),this.boundingSphere.expandByPoint(Tu)}copy(s,l){return super.copy(s,l),this.bindMode=s.bindMode,this.bindMatrix.copy(s.bindMatrix),this.bindMatrixInverse.copy(s.bindMatrixInverse),this.skeleton=s.skeleton,s.boundingBox!==null&&(this.boundingBox=s.boundingBox.clone()),s.boundingSphere!==null&&(this.boundingSphere=s.boundingSphere.clone()),this}raycast(s,l){const h=this.material,f=this.matrixWorld;h!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),jp.copy(this.boundingSphere),jp.applyMatrix4(f),s.ray.intersectsSphere(jp)!==!1&&(O_.copy(f).invert(),Yp.copy(s.ray).applyMatrix4(O_),!(this.boundingBox!==null&&Yp.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(s,l,Yp)))}getVertexPosition(s,l){return super.getVertexPosition(s,l),this.applyBoneTransform(s,l),l}bind(s,l){this.skeleton=s,l===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),l=this.matrixWorld),this.bindMatrix.copy(l),this.bindMatrixInverse.copy(l).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const s=new as,l=this.geometry.attributes.skinWeight;for(let h=0,f=l.count;h<f;h++){s.fromBufferAttribute(l,h);const g=1/s.manhattanLength();g!==1/0?s.multiplyScalar(g):s.set(1,0,0,0),l.setXYZW(h,s.x,s.y,s.z,s.w)}}updateMatrixWorld(s){super.updateMatrixWorld(s),this.bindMode===Cg?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===Xb?this.bindMatrixInverse.copy(this.bindMatrix).invert():Mn("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(s,l){const h=this.skeleton,f=this.geometry;Xp.fromBufferAttribute(f.attributes.skinIndex,s),t0.fromBufferAttribute(f.attributes.skinWeight,s),e0.copy(l).applyMatrix4(this.bindMatrix),l.set(0,0,0);for(let g=0;g<4;g++){const _=t0.getComponent(g);if(_!==0){const b=Xp.getComponent(g);_f.multiplyMatrices(h.bones[b].matrixWorld,h.boneInverses[b]),l.addScaledVector(uS.copy(e0).applyMatrix4(_f),_)}}return l.applyMatrix4(this.bindMatrixInverse)}}class n0 extends null{constructor(){super(),this.isBone=!0,this.type="Bone"}}class gl extends null{constructor(s=null,l=1,h=1,f,g,_,b,T,A=ni,R=ni,P,L){super(null,_,b,T,A,R,f,g,P,L),this.isDataTexture=!0,this.image={data:s,width:l,height:h},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const i0=new Dn,Zp=new Dn;class xf{constructor(s=[],l=[]){this.uuid=Be(),this.bones=s.slice(0),this.boneInverses=l,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const s=this.bones,l=this.boneInverses;if(this.boneMatrices=new Float32Array(s.length*16),l.length===0)this.calculateInverses();else if(s.length!==l.length){Mn("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let h=0,f=this.bones.length;h<f;h++)this.boneInverses.push(new Dn)}}calculateInverses(){this.boneInverses.length=0;for(let s=0,l=this.bones.length;s<l;s++){const h=new Dn;this.bones[s]&&h.copy(this.bones[s].matrixWorld).invert(),this.boneInverses.push(h)}}pose(){for(let s=0,l=this.bones.length;s<l;s++){const h=this.bones[s];h&&h.matrixWorld.copy(this.boneInverses[s]).invert()}for(let s=0,l=this.bones.length;s<l;s++){const h=this.bones[s];h&&(h.parent&&h.parent.isBone?(h.matrix.copy(h.parent.matrixWorld).invert(),h.matrix.multiply(h.matrixWorld)):h.matrix.copy(h.matrixWorld),h.matrix.decompose(h.position,h.quaternion,h.scale))}}update(){const s=this.bones,l=this.boneInverses,h=this.boneMatrices,f=this.boneTexture;for(let g=0,_=s.length;g<_;g++){const b=s[g]?s[g].matrixWorld:Zp;i0.multiplyMatrices(b,l[g]),i0.toArray(h,g*16)}f!==null&&(f.needsUpdate=!0)}clone(){return new xf(this.bones,this.boneInverses)}computeBoneTexture(){let s=Math.sqrt(this.bones.length*4);s=Math.ceil(s/4)*4,s=Math.max(s,4);const l=new Float32Array(s*s*4);l.set(this.boneMatrices);const h=new gl(l,s,s,Ri,Si);return h.needsUpdate=!0,this.boneMatrices=l,this.boneTexture=h,this}getBoneByName(s){for(let l=0,h=this.bones.length;l<h;l++){const f=this.bones[l];if(f.name===s)return f}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(s,l){this.uuid=s.uuid;for(let h=0,f=s.bones.length;h<f;h++){const g=s.bones[h];let _=l[g];_===void 0&&(Mn("Skeleton: No bone found with UUID:",g),_=new n0),this.bones.push(_),this.boneInverses.push(new Dn().fromArray(s.boneInverses[h]))}return this.init(),this}toJSON(){const s={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};s.uuid=this.uuid;const l=this.bones,h=this.boneInverses;for(let f=0,g=l.length;f<g;f++){const _=l[f];s.bones.push(_.uuid);const b=h[f];s.boneInverses.push(b.toArray())}return s}}class dd extends null{constructor(s,l,h,f=1){super(s,l,h),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=f}copy(s){return super.copy(s),this.meshPerAttribute=s.meshPerAttribute,this}toJSON(){const s=super.toJSON();return s.meshPerAttribute=this.meshPerAttribute,s.isInstancedBufferAttribute=!0,s}}const ac=new Dn,k_=new Dn,vf=null,co=new fi,z_=new Dn,bf=new dl,wu=new Ps;class oa extends null{constructor(s,l,h){super(s,l),this.isInstancedMesh=!0,this.instanceMatrix=new dd(new Float32Array(h*16),16),this.instanceColor=null,this.morphTexture=null,this.count=h,this.boundingBox=null,this.boundingSphere=null;for(let f=0;f<h;f++)this.setMatrixAt(f,z_)}computeBoundingBox(){const s=this.geometry,l=this.count;this.boundingBox===null&&(this.boundingBox=new fi),s.boundingBox===null&&s.computeBoundingBox(),this.boundingBox.makeEmpty();for(let h=0;h<l;h++)this.getMatrixAt(h,ac),co.copy(s.boundingBox).applyMatrix4(ac),this.boundingBox.union(co)}computeBoundingSphere(){const s=this.geometry,l=this.count;this.boundingSphere===null&&(this.boundingSphere=new Ps),s.boundingSphere===null&&s.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let h=0;h<l;h++)this.getMatrixAt(h,ac),wu.copy(s.boundingSphere).applyMatrix4(ac),this.boundingSphere.union(wu)}copy(s,l){return super.copy(s,l),this.instanceMatrix.copy(s.instanceMatrix),s.morphTexture!==null&&(this.morphTexture=s.morphTexture.clone()),s.instanceColor!==null&&(this.instanceColor=s.instanceColor.clone()),this.count=s.count,s.boundingBox!==null&&(this.boundingBox=s.boundingBox.clone()),s.boundingSphere!==null&&(this.boundingSphere=s.boundingSphere.clone()),this}getColorAt(s,l){l.fromArray(this.instanceColor.array,s*3)}getMatrixAt(s,l){l.fromArray(this.instanceMatrix.array,s*16)}getMorphAt(s,l){const h=l.morphTargetInfluences,f=this.morphTexture.source.data.data,g=h.length+1,_=s*g+1;for(let b=0;b<h.length;b++)h[b]=f[_+b]}raycast(s,l){const h=this.matrixWorld,f=this.count;if(bf.geometry=this.geometry,bf.material=this.material,bf.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),wu.copy(this.boundingSphere),wu.applyMatrix4(h),s.ray.intersectsSphere(wu)!==!1))for(let g=0;g<f;g++){this.getMatrixAt(g,ac),k_.multiplyMatrices(h,ac),bf.matrixWorld=k_,bf.raycast(s,vf);for(let _=0,b=vf.length;_<b;_++){const T=vf[_];T.instanceId=g,T.object=this,l.push(T)}vf.length=0}}setColorAt(s,l){this.instanceColor===null&&(this.instanceColor=new dd(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),l.toArray(this.instanceColor.array,s*3)}setMatrixAt(s,l){l.toArray(this.instanceMatrix.array,s*16)}setMorphAt(s,l){const h=l.morphTargetInfluences,f=h.length+1;this.morphTexture===null&&(this.morphTexture=new gl(new Float32Array(f*this.count),f,this.count,Qc,Si));const g=this.morphTexture.source.data.data;let _=0;for(let A=0;A<h.length;A++)_+=h[A];const b=this.geometry.morphTargetsRelative?1:1-_,T=f*s;g[T]=b,g.set(h,T+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const lc=new ae,V_=new ae,Kp=new ts;class Au{constructor(s=new ae(1,0,0),l=0){this.isPlane=!0,this.normal=s,this.constant=l}set(s,l){return this.normal.copy(s),this.constant=l,this}setComponents(s,l,h,f){return this.normal.set(s,l,h),this.constant=f,this}setFromNormalAndCoplanarPoint(s,l){return this.normal.copy(s),this.constant=-l.dot(this.normal),this}setFromCoplanarPoints(s,l,h){const f=lc.subVectors(h,l).cross(V_.subVectors(s,l)).normalize();return this.setFromNormalAndCoplanarPoint(f,s),this}copy(s){return this.normal.copy(s.normal),this.constant=s.constant,this}normalize(){const s=1/this.normal.length();return this.normal.multiplyScalar(s),this.constant*=s,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(s){return this.normal.dot(s)+this.constant}distanceToSphere(s){return this.distanceToPoint(s.center)-s.radius}projectPoint(s,l){return l.copy(s).addScaledVector(this.normal,-this.distanceToPoint(s))}intersectLine(s,l){const h=s.delta(lc),f=this.normal.dot(h);if(f===0)return this.distanceToPoint(s.start)===0?l.copy(s.start):null;const g=-(s.start.dot(this.normal)+this.constant)/f;return g<0||g>1?null:l.copy(s.start).addScaledVector(h,g)}intersectsLine(s){const l=this.distanceToPoint(s.start),h=this.distanceToPoint(s.end);return l<0&&h>0||h<0&&l>0}intersectsBox(s){return s.intersectsPlane(this)}intersectsSphere(s){return s.intersectsPlane(this)}coplanarPoint(s){return s.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(s,l){const h=l||Kp.getNormalMatrix(s),f=this.coplanarPoint(lc).applyMatrix4(s),g=this.normal.applyMatrix3(h).normalize();return this.constant=-f.dot(g),this}translate(s){return this.constant-=s.dot(this.normal),this}equals(s){return s.normal.equals(this.normal)&&s.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Eu=new Ps,Sf=new St(.5,.5),cc=new ae;class s0{constructor(s=new Au,l=new Au,h=new Au,f=new Au,g=new Au,_=new Au){this.planes=[s,l,h,f,g,_]}set(s,l,h,f,g,_){const b=this.planes;return b[0].copy(s),b[1].copy(l),b[2].copy(h),b[3].copy(f),b[4].copy(g),b[5].copy(_),this}copy(s){const l=this.planes;for(let h=0;h<6;h++)l[h].copy(s.planes[h]);return this}setFromProjectionMatrix(s,l=rl,h=!1){const f=this.planes,g=s.elements,_=g[0],b=g[1],T=g[2],A=g[3],R=g[4],P=g[5],L=g[6],D=g[7],O=g[8],W=g[9],Z=g[10],Y=g[11],ie=g[12],se=g[13],de=g[14],ke=g[15];if(f[0].setComponents(A-_,D-R,Y-O,ke-ie).normalize(),f[1].setComponents(A+_,D+R,Y+O,ke+ie).normalize(),f[2].setComponents(A+b,D+P,Y+W,ke+se).normalize(),f[3].setComponents(A-b,D-P,Y-W,ke-se).normalize(),h)f[4].setComponents(T,L,Z,de).normalize(),f[5].setComponents(A-T,D-L,Y-Z,ke-de).normalize();else if(f[4].setComponents(A-T,D-L,Y-Z,ke-de).normalize(),l===rl)f[5].setComponents(A+T,D+L,Y+Z,ke+de).normalize();else if(l===Up)f[5].setComponents(T,L,Z,de).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+l);return this}intersectsObject(s){if(s.boundingSphere!==void 0)s.boundingSphere===null&&s.computeBoundingSphere(),Eu.copy(s.boundingSphere).applyMatrix4(s.matrixWorld);else{const l=s.geometry;l.boundingSphere===null&&l.computeBoundingSphere(),Eu.copy(l.boundingSphere).applyMatrix4(s.matrixWorld)}return this.intersectsSphere(Eu)}intersectsSprite(s){Eu.center.set(0,0,0);const l=Sf.distanceTo(s.center);return Eu.radius=.7071067811865476+l,Eu.applyMatrix4(s.matrixWorld),this.intersectsSphere(Eu)}intersectsSphere(s){const l=this.planes,h=s.center,f=-s.radius;for(let g=0;g<6;g++)if(l[g].distanceToPoint(h)<f)return!1;return!0}intersectsBox(s){const l=this.planes;for(let h=0;h<6;h++){const f=l[h];if(cc.x=f.normal.x>0?s.max.x:s.min.x,cc.y=f.normal.y>0?s.max.y:s.min.y,cc.z=f.normal.z>0?s.max.z:s.min.z,f.distanceToPoint(cc)<0)return!1}return!0}containsPoint(s){const l=this.planes;for(let h=0;h<6;h++)if(l[h].distanceToPoint(s)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}const Do=new Dn,ka=new s0;class r0{constructor(){this.coordinateSystem=rl}intersectsObject(s,l){if(!l.isArrayCamera||l.cameras.length===0)return!1;for(let h=0;h<l.cameras.length;h++){const f=l.cameras[h];if(Do.multiplyMatrices(f.projectionMatrix,f.matrixWorldInverse),ka.setFromProjectionMatrix(Do,f.coordinateSystem,f.reversedDepth),ka.intersectsObject(s))return!0}return!1}intersectsSprite(s,l){if(!l||!l.cameras||l.cameras.length===0)return!1;for(let h=0;h<l.cameras.length;h++){const f=l.cameras[h];if(Do.multiplyMatrices(f.projectionMatrix,f.matrixWorldInverse),ka.setFromProjectionMatrix(Do,f.coordinateSystem,f.reversedDepth),ka.intersectsSprite(s))return!0}return!1}intersectsSphere(s,l){if(!l||!l.cameras||l.cameras.length===0)return!1;for(let h=0;h<l.cameras.length;h++){const f=l.cameras[h];if(Do.multiplyMatrices(f.projectionMatrix,f.matrixWorldInverse),ka.setFromProjectionMatrix(Do,f.coordinateSystem,f.reversedDepth),ka.intersectsSphere(s))return!0}return!1}intersectsBox(s,l){if(!l||!l.cameras||l.cameras.length===0)return!1;for(let h=0;h<l.cameras.length;h++){const f=l.cameras[h];if(Do.multiplyMatrices(f.projectionMatrix,f.matrixWorldInverse),ka.setFromProjectionMatrix(Do,f.coordinateSystem,f.reversedDepth),ka.intersectsBox(s))return!0}return!1}containsPoint(s,l){if(!l||!l.cameras||l.cameras.length===0)return!1;for(let h=0;h<l.cameras.length;h++){const f=l.cameras[h];if(Do.multiplyMatrices(f.projectionMatrix,f.matrixWorldInverse),ka.setFromProjectionMatrix(Do,f.coordinateSystem,f.reversedDepth),ka.containsPoint(s))return!0}return!1}clone(){return new r0}}function uo(E,s){return E-s}function Cu(E,s){return E.z-s.z}function hS(E,s){return s.z-E.z}class Jp{constructor(){this.index=0,this.pool=[],this.list=[]}push(s,l,h,f){const g=this.pool,_=this.list;this.index>=g.length&&g.push({start:-1,count:-1,z:-1,index:-1});const b=g[this.index];_.push(b),this.index++,b.start=s,b.count=l,b.z=h,b.index=f}reset(){this.list.length=0,this.index=0}}const Xs=new Dn,za=new Zn(1,1,1),aa=new s0,Qp=new r0,fd=new fi,Ru=new Ps,Mf=new ae,G_=new ae,Yr=new ae,o0=new Jp,ur=new dl,em=null;function tm(E,s,l=0){const h=s.itemSize;if(E.isInterleavedBufferAttribute||E.array.constructor!==s.array.constructor){const f=E.count;for(let g=0;g<f;g++)for(let _=0;_<h;_++)s.setComponent(g+l,_,E.getComponent(g,_))}else s.array.set(E.array,l*h);s.needsUpdate=!0}function ho(E,s){if(E.constructor!==s.constructor){const l=Math.min(E.length,s.length);for(let h=0;h<l;h++)s[h]=E[h]}else{const l=Math.min(E.length,s.length);s.set(new E.constructor(E.buffer,0,l))}}class Tf extends null{constructor(s,l,h=l*2,f){super(new ht,f),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=s,this._maxVertexCount=l,this._maxIndexCount=h,this._multiDrawCounts=new Int32Array(s),this._multiDrawStarts=new Int32Array(s),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 s=Math.sqrt(this._maxInstanceCount*4);s=Math.ceil(s/4)*4,s=Math.max(s,4);const l=new Float32Array(s*s*4),h=new gl(l,s,s,Ri,Si);this._matricesTexture=h}_initIndirectTexture(){let s=Math.sqrt(this._maxInstanceCount);s=Math.ceil(s);const l=new Uint32Array(s*s),h=new gl(l,s,s,Bl,yi);this._indirectTexture=h}_initColorsTexture(){let s=Math.sqrt(this._maxInstanceCount);s=Math.ceil(s);const l=new Float32Array(s*s*4).fill(1),h=new gl(l,s,s,Ri,Si);h.colorSpace=H.workingColorSpace,this._colorsTexture=h}_initializeGeometry(s){const l=this.geometry,h=this._maxVertexCount,f=this._maxIndexCount;if(this._geometryInitialized===!1){for(const g in s.attributes){const _=s.getAttribute(g),{array:b,itemSize:T,normalized:A}=_,R=new b.constructor(h*T),P=new Ki(R,T,A);l.setAttribute(g,P)}if(s.getIndex()!==null){const g=h>65535?new Uint32Array(f):new Uint16Array(f);l.setIndex(new Ki(g,1))}this._geometryInitialized=!0}}_validateGeometry(s){const l=this.geometry;if(!!s.getIndex()!=!!l.getIndex())throw new Error('THREE.BatchedMesh: All geometries must consistently have "index".');for(const h in l.attributes){if(!s.hasAttribute(h))throw new Error(`THREE.BatchedMesh: Added geometry missing "${h}". All geometries must have consistent attributes.`);const f=s.getAttribute(h),g=l.getAttribute(h);if(f.itemSize!==g.itemSize||f.normalized!==g.normalized)throw new Error("THREE.BatchedMesh: All attributes must have a consistent itemSize and normalized value.")}}validateInstanceId(s){const l=this._instanceInfo;if(s<0||s>=l.length||l[s].active===!1)throw new Error(`THREE.BatchedMesh: Invalid instanceId ${s}. Instance is either out of range or has been deleted.`)}validateGeometryId(s){const l=this._geometryInfo;if(s<0||s>=l.length||l[s].active===!1)throw new Error(`THREE.BatchedMesh: Invalid geometryId ${s}. Geometry is either out of range or has been deleted.`)}setCustomSort(s){return this.customSort=s,this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new fi);const s=this.boundingBox,l=this._instanceInfo;s.makeEmpty();for(let h=0,f=l.length;h<f;h++){if(l[h].active===!1)continue;const g=l[h].geometryIndex;this.getMatrixAt(h,Xs),this.getBoundingBoxAt(g,fd).applyMatrix4(Xs),s.union(fd)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ps);const s=this.boundingSphere,l=this._instanceInfo;s.makeEmpty();for(let h=0,f=l.length;h<f;h++){if(l[h].active===!1)continue;const g=l[h].geometryIndex;this.getMatrixAt(h,Xs),this.getBoundingSphereAt(g,Ru).applyMatrix4(Xs),s.union(Ru)}}addInstance(s){if(this._instanceInfo.length>=this.maxInstanceCount&&this._availableInstanceIds.length===0)throw new Error("THREE.BatchedMesh: Maximum item count reached.");const h={visible:!0,active:!0,geometryIndex:s};let f=null;this._availableInstanceIds.length>0?(this._availableInstanceIds.sort(uo),f=this._availableInstanceIds.shift(),this._instanceInfo[f]=h):(f=this._instanceInfo.length,this._instanceInfo.push(h));const g=this._matricesTexture;Xs.identity().toArray(g.image.data,f*16),g.needsUpdate=!0;const _=this._colorsTexture;return _&&(za.toArray(_.image.data,f*4),_.needsUpdate=!0),this._visibilityChanged=!0,f}addGeometry(s,l=-1,h=-1){this._initializeGeometry(s),this._validateGeometry(s);const f={vertexStart:-1,vertexCount:-1,reservedVertexCount:-1,indexStart:-1,indexCount:-1,reservedIndexCount:-1,start:-1,count:-1,boundingBox:null,boundingSphere:null,active:!0},g=this._geometryInfo;f.vertexStart=this._nextVertexStart,f.reservedVertexCount=l===-1?s.getAttribute("position").count:l;const _=s.getIndex();if(_!==null&&(f.indexStart=this._nextIndexStart,f.reservedIndexCount=h===-1?_.count:h),f.indexStart!==-1&&f.indexStart+f.reservedIndexCount>this._maxIndexCount||f.vertexStart+f.reservedVertexCount>this._maxVertexCount)throw new Error("THREE.BatchedMesh: Reserved space request exceeds the maximum buffer size.");let T;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(uo),T=this._availableGeometryIds.shift(),g[T]=f):(T=this._geometryCount,this._geometryCount++,g.push(f)),this.setGeometryAt(T,s),this._nextIndexStart=f.indexStart+f.reservedIndexCount,this._nextVertexStart=f.vertexStart+f.reservedVertexCount,T}setGeometryAt(s,l){if(s>=this._geometryCount)throw new Error("THREE.BatchedMesh: Maximum geometry count reached.");this._validateGeometry(l);const h=this.geometry,f=h.getIndex()!==null,g=h.getIndex(),_=l.getIndex(),b=this._geometryInfo[s];if(f&&_.count>b.reservedIndexCount||l.attributes.position.count>b.reservedVertexCount)throw new Error("THREE.BatchedMesh: Reserved space not large enough for provided geometry.");const T=b.vertexStart,A=b.reservedVertexCount;b.vertexCount=l.getAttribute("position").count;for(const R in h.attributes){const P=l.getAttribute(R),L=h.getAttribute(R);tm(P,L,T);const D=P.itemSize;for(let O=P.count,W=A;O<W;O++){const Z=T+O;for(let Y=0;Y<D;Y++)L.setComponent(Z,Y,0)}L.needsUpdate=!0,L.addUpdateRange(T*D,A*D)}if(f){const R=b.indexStart,P=b.reservedIndexCount;b.indexCount=l.getIndex().count;for(let L=0;L<_.count;L++)g.setX(R+L,T+_.getX(L));for(let L=_.count,D=P;L<D;L++)g.setX(R+L,T);g.needsUpdate=!0,g.addUpdateRange(R,b.reservedIndexCount)}return b.start=f?b.indexStart:b.vertexStart,b.count=f?b.indexCount:b.vertexCount,b.boundingBox=null,l.boundingBox!==null&&(b.boundingBox=l.boundingBox.clone()),b.boundingSphere=null,l.boundingSphere!==null&&(b.boundingSphere=l.boundingSphere.clone()),this._visibilityChanged=!0,s}deleteGeometry(s){const l=this._geometryInfo;if(s>=l.length||l[s].active===!1)return this;const h=this._instanceInfo;for(let f=0,g=h.length;f<g;f++)h[f].active&&h[f].geometryIndex===s&&this.deleteInstance(f);return l[s].active=!1,this._availableGeometryIds.push(s),this._visibilityChanged=!0,this}deleteInstance(s){return this.validateInstanceId(s),this._instanceInfo[s].active=!1,this._availableInstanceIds.push(s),this._visibilityChanged=!0,this}optimize(){let s=0,l=0;const h=this._geometryInfo,f=h.map((_,b)=>b).sort((_,b)=>h[_].vertexStart-h[b].vertexStart),g=this.geometry;for(let _=0,b=h.length;_<b;_++){const T=f[_],A=h[T];if(A.active!==!1){if(g.index!==null){if(A.indexStart!==l){const{indexStart:R,vertexStart:P,reservedIndexCount:L}=A,D=g.index,O=D.array,W=s-P;for(let Z=R;Z<R+L;Z++)O[Z]=O[Z]+W;D.array.copyWithin(l,R,R+L),D.addUpdateRange(l,L),A.indexStart=l}l+=A.reservedIndexCount}if(A.vertexStart!==s){const{vertexStart:R,reservedVertexCount:P}=A,L=g.attributes;for(const D in L){const O=L[D],{array:W,itemSize:Z}=O;W.copyWithin(s*Z,R*Z,(R+P)*Z),O.addUpdateRange(s*Z,P*Z)}A.vertexStart=s}s+=A.reservedVertexCount,A.start=g.index?A.indexStart:A.vertexStart,this._nextIndexStart=g.index?A.indexStart+A.reservedIndexCount:0,this._nextVertexStart=A.vertexStart+A.reservedVertexCount}}return this}getBoundingBoxAt(s,l){if(s>=this._geometryCount)return null;const h=this.geometry,f=this._geometryInfo[s];if(f.boundingBox===null){const g=new fi,_=h.index,b=h.attributes.position;for(let T=f.start,A=f.start+f.count;T<A;T++){let R=T;_&&(R=_.getX(R)),g.expandByPoint(Mf.fromBufferAttribute(b,R))}f.boundingBox=g}return l.copy(f.boundingBox),l}getBoundingSphereAt(s,l){if(s>=this._geometryCount)return null;const h=this.geometry,f=this._geometryInfo[s];if(f.boundingSphere===null){const g=new Ps;this.getBoundingBoxAt(s,fd),fd.getCenter(g.center);const _=h.index,b=h.attributes.position;let T=0;for(let A=f.start,R=f.start+f.count;A<R;A++){let P=A;_&&(P=_.getX(P)),Mf.fromBufferAttribute(b,P),T=Math.max(T,g.center.distanceToSquared(Mf))}g.radius=Math.sqrt(T),f.boundingSphere=g}return l.copy(f.boundingSphere),l}setMatrixAt(s,l){this.validateInstanceId(s);const h=this._matricesTexture,f=this._matricesTexture.image.data;return l.toArray(f,s*16),h.needsUpdate=!0,this}getMatrixAt(s,l){return this.validateInstanceId(s),l.fromArray(this._matricesTexture.image.data,s*16)}setColorAt(s,l){return this.validateInstanceId(s),this._colorsTexture===null&&this._initColorsTexture(),l.toArray(this._colorsTexture.image.data,s*4),this._colorsTexture.needsUpdate=!0,this}getColorAt(s,l){return this.validateInstanceId(s),l.fromArray(this._colorsTexture.image.data,s*4)}setVisibleAt(s,l){return this.validateInstanceId(s),this._instanceInfo[s].visible===l?this:(this._instanceInfo[s].visible=l,this._visibilityChanged=!0,this)}getVisibleAt(s){return this.validateInstanceId(s),this._instanceInfo[s].visible}setGeometryIdAt(s,l){return this.validateInstanceId(s),this.validateGeometryId(l),this._instanceInfo[s].geometryIndex=l,this}getGeometryIdAt(s){return this.validateInstanceId(s),this._instanceInfo[s].geometryIndex}getGeometryRangeAt(s,l={}){this.validateGeometryId(s);const h=this._geometryInfo[s];return l.vertexStart=h.vertexStart,l.vertexCount=h.vertexCount,l.reservedVertexCount=h.reservedVertexCount,l.indexStart=h.indexStart,l.indexCount=h.indexCount,l.reservedIndexCount=h.reservedIndexCount,l.start=h.start,l.count=h.count,l}setInstanceCount(s){const l=this._availableInstanceIds,h=this._instanceInfo;for(l.sort(uo);l[l.length-1]===h.length-1;)h.pop(),l.pop();if(s<h.length)throw new Error(`BatchedMesh: Instance ids outside the range ${s} are being used. Cannot shrink instance count.`);const f=new Int32Array(s),g=new Int32Array(s);ho(this._multiDrawCounts,f),ho(this._multiDrawStarts,g),this._multiDrawCounts=f,this._multiDrawStarts=g,this._maxInstanceCount=s;const _=this._indirectTexture,b=this._matricesTexture,T=this._colorsTexture;_.dispose(),this._initIndirectTexture(),ho(_.image.data,this._indirectTexture.image.data),b.dispose(),this._initMatricesTexture(),ho(b.image.data,this._matricesTexture.image.data),T&&(T.dispose(),this._initColorsTexture(),ho(T.image.data,this._colorsTexture.image.data))}setGeometrySize(s,l){const h=[...this._geometryInfo].filter(b=>b.active);if(Math.max(...h.map(b=>b.vertexStart+b.reservedVertexCount))>s)throw new Error(`BatchedMesh: Geometry vertex values are being used outside the range ${l}. Cannot shrink further.`);if(this.geometry.index&&Math.max(...h.map(T=>T.indexStart+T.reservedIndexCount))>l)throw new Error(`BatchedMesh: Geometry index values are being used outside the range ${l}. Cannot shrink further.`);const g=this.geometry;g.dispose(),this._maxVertexCount=s,this._maxIndexCount=l,this._geometryInitialized&&(this._geometryInitialized=!1,this.geometry=new ht,this._initializeGeometry(g));const _=this.geometry;g.index&&ho(g.index.array,_.index.array);for(const b in g.attributes)ho(g.attributes[b].array,_.attributes[b].array)}raycast(s,l){const h=this._instanceInfo,f=this._geometryInfo,g=this.matrixWorld,_=this.geometry;ur.material=this.material,ur.geometry.index=_.index,ur.geometry.attributes=_.attributes,ur.geometry.boundingBox===null&&(ur.geometry.boundingBox=new fi),ur.geometry.boundingSphere===null&&(ur.geometry.boundingSphere=new Ps);for(let b=0,T=h.length;b<T;b++){if(!h[b].visible||!h[b].active)continue;const A=h[b].geometryIndex,R=f[A];ur.geometry.setDrawRange(R.start,R.count),this.getMatrixAt(b,ur.matrixWorld).premultiply(g),this.getBoundingBoxAt(A,ur.geometry.boundingBox),this.getBoundingSphereAt(A,ur.geometry.boundingSphere),ur.raycast(s,em);for(let P=0,L=em.length;P<L;P++){const D=em[P];D.object=this,D.batchId=b,l.push(D)}em.length=0}ur.material=null,ur.geometry.index=null,ur.geometry.attributes={},ur.geometry.setDrawRange(0,1/0)}copy(s){return super.copy(s),this.geometry=s.geometry.clone(),this.perObjectFrustumCulled=s.perObjectFrustumCulled,this.sortObjects=s.sortObjects,this.boundingBox=s.boundingBox!==null?s.boundingBox.clone():null,this.boundingSphere=s.boundingSphere!==null?s.boundingSphere.clone():null,this._geometryInfo=s._geometryInfo.map(l=>Mo(wi({},l),{boundingBox:l.boundingBox!==null?l.boundingBox.clone():null,boundingSphere:l.boundingSphere!==null?l.boundingSphere.clone():null})),this._instanceInfo=s._instanceInfo.map(l=>wi({},l)),this._availableInstanceIds=s._availableInstanceIds.slice(),this._availableGeometryIds=s._availableGeometryIds.slice(),this._nextIndexStart=s._nextIndexStart,this._nextVertexStart=s._nextVertexStart,this._geometryCount=s._geometryCount,this._maxInstanceCount=s._maxInstanceCount,this._maxVertexCount=s._maxVertexCount,this._maxIndexCount=s._maxIndexCount,this._geometryInitialized=s._geometryInitialized,this._multiDrawCounts=s._multiDrawCounts.slice(),this._multiDrawStarts=s._multiDrawStarts.slice(),this._indirectTexture=s._indirectTexture.clone(),this._indirectTexture.image.data=this._indirectTexture.image.data.slice(),this._matricesTexture=s._matricesTexture.clone(),this._matricesTexture.image.data=this._matricesTexture.image.data.slice(),this._colorsTexture!==null&&(this._colorsTexture=s._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(s,l,h,f,g){if(!this._visibilityChanged&&!this.perObjectFrustumCulled&&!this.sortObjects)return;const _=f.getIndex(),b=_===null?1:_.array.BYTES_PER_ELEMENT,T=this._instanceInfo,A=this._multiDrawStarts,R=this._multiDrawCounts,P=this._geometryInfo,L=this.perObjectFrustumCulled,D=this._indirectTexture,O=D.image.data,W=h.isArrayCamera?Qp:aa;L&&!h.isArrayCamera&&(Xs.multiplyMatrices(h.projectionMatrix,h.matrixWorldInverse).multiply(this.matrixWorld),aa.setFromProjectionMatrix(Xs,h.coordinateSystem,h.reversedDepth));let Z=0;if(this.sortObjects){Xs.copy(this.matrixWorld).invert(),Mf.setFromMatrixPosition(h.matrixWorld).applyMatrix4(Xs),G_.set(0,0,-1).transformDirection(h.matrixWorld).transformDirection(Xs);for(let se=0,de=T.length;se<de;se++)if(T[se].visible&&T[se].active){const ke=T[se].geometryIndex;this.getMatrixAt(se,Xs),this.getBoundingSphereAt(ke,Ru).applyMatrix4(Xs);let $e=!1;if(L&&($e=!W.intersectsSphere(Ru,h)),!$e){const et=P[ke],qe=Yr.subVectors(Ru.center,Mf).dot(G_);o0.push(et.start,et.count,qe,se)}}const Y=o0.list,ie=this.customSort;ie===null?Y.sort(g.transparent?hS:Cu):ie.call(this,Y,h);for(let se=0,de=Y.length;se<de;se++){const ke=Y[se];A[Z]=ke.start*b,R[Z]=ke.count,O[Z]=ke.index,Z++}o0.reset()}else for(let Y=0,ie=T.length;Y<ie;Y++)if(T[Y].visible&&T[Y].active){const se=T[Y].geometryIndex;let de=!1;if(L&&(this.getMatrixAt(Y,Xs),this.getBoundingSphereAt(se,Ru).applyMatrix4(Xs),de=!W.intersectsSphere(Ru,h)),!de){const ke=P[se];A[Z]=ke.start*b,R[Z]=ke.count,O[Z]=Y,Z++}}D.needsUpdate=!0,this._multiDrawCount=Z,this._visibilityChanged=!1}onBeforeShadow(s,l,h,f,g,_){this.onBeforeRender(s,null,f,g,_)}}class Zr extends null{constructor(s){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Zn(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(s)}copy(s){return super.copy(s),this.color.copy(s.color),this.map=s.map,this.linewidth=s.linewidth,this.linecap=s.linecap,this.linejoin=s.linejoin,this.fog=s.fog,this}}const nm=new ae,pd=new ae,hr=new Dn,uc=new As,im=new Ps,yl=new ae,W_=new ae;class js extends null{constructor(s=new ht,l=new Zr){super(),this.isLine=!0,this.type="Line",this.geometry=s,this.material=l,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(s,l){return super.copy(s,l),this.material=Array.isArray(s.material)?s.material.slice():s.material,this.geometry=s.geometry,this}computeLineDistances(){const s=this.geometry;if(s.index===null){const l=s.attributes.position,h=[0];for(let f=1,g=l.count;f<g;f++)nm.fromBufferAttribute(l,f-1),pd.fromBufferAttribute(l,f),h[f]=h[f-1],h[f]+=nm.distanceTo(pd);s.setAttribute("lineDistance",new cn(h,1))}else Mn("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(s,l){const h=this.geometry,f=this.matrixWorld,g=s.params.Line.threshold,_=h.drawRange;if(h.boundingSphere===null&&h.computeBoundingSphere(),im.copy(h.boundingSphere),im.applyMatrix4(f),im.radius+=g,s.ray.intersectsSphere(im)===!1)return;hr.copy(f).invert(),uc.copy(s.ray).applyMatrix4(hr);const b=g/((this.scale.x+this.scale.y+this.scale.z)/3),T=b*b,A=this.isLineSegments?2:1,R=h.index,L=h.attributes.position;if(R!==null){const D=Math.max(0,_.start),O=Math.min(R.count,_.start+_.count);for(let W=D,Z=O-1;W<Z;W+=A){const Y=R.getX(W),ie=R.getX(W+1),se=Nu(this,s,uc,T,Y,ie,W);se&&l.push(se)}if(this.isLineLoop){const W=R.getX(O-1),Z=R.getX(D),Y=Nu(this,s,uc,T,W,Z,O-1);Y&&l.push(Y)}}else{const D=Math.max(0,_.start),O=Math.min(L.count,_.start+_.count);for(let W=D,Z=O-1;W<Z;W+=A){const Y=Nu(this,s,uc,T,W,W+1,W);Y&&l.push(Y)}if(this.isLineLoop){const W=Nu(this,s,uc,T,O-1,D,O-1);W&&l.push(W)}}}updateMorphTargets(){const l=this.geometry.morphAttributes,h=Object.keys(l);if(h.length>0){const f=l[h[0]];if(f!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let g=0,_=f.length;g<_;g++){const b=f[g].name||String(g);this.morphTargetInfluences.push(0),this.morphTargetDictionary[b]=g}}}}}function Nu(E,s,l,h,f,g,_){const b=E.geometry.attributes.position;if(nm.fromBufferAttribute(b,f),pd.fromBufferAttribute(b,g),l.distanceSqToSegment(nm,pd,yl,W_)>h)return;yl.applyMatrix4(E.matrixWorld);const A=s.ray.origin.distanceTo(yl);if(!(A<s.near||A>s.far))return{distance:A,point:W_.clone().applyMatrix4(E.matrixWorld),index:_,face:null,faceIndex:null,barycoord:null,object:E}}const wf=new ae,a0=new ae;class md extends null{constructor(s,l){super(s,l),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const s=this.geometry;if(s.index===null){const l=s.attributes.position,h=[];for(let f=0,g=l.count;f<g;f+=2)wf.fromBufferAttribute(l,f),a0.fromBufferAttribute(l,f+1),h[f]=f===0?0:h[f-1],h[f+1]=h[f]+wf.distanceTo(a0);s.setAttribute("lineDistance",new cn(h,1))}else Mn("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class sm extends null{constructor(s,l){super(s,l),this.isLineLoop=!0,this.type="LineLoop"}}class rm extends null{constructor(s){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Zn(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(s)}copy(s){return super.copy(s),this.color.copy(s.color),this.map=s.map,this.alphaMap=s.alphaMap,this.size=s.size,this.sizeAttenuation=s.sizeAttenuation,this.fog=s.fog,this}}const l0=new Dn,Pu=new As,Iu=new Ps,Af=new ae;class H_ extends null{constructor(s=new ht,l=new rm){super(),this.isPoints=!0,this.type="Points",this.geometry=s,this.material=l,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(s,l){return super.copy(s,l),this.material=Array.isArray(s.material)?s.material.slice():s.material,this.geometry=s.geometry,this}raycast(s,l){const h=this.geometry,f=this.matrixWorld,g=s.params.Points.threshold,_=h.drawRange;if(h.boundingSphere===null&&h.computeBoundingSphere(),Iu.copy(h.boundingSphere),Iu.applyMatrix4(f),Iu.radius+=g,s.ray.intersectsSphere(Iu)===!1)return;l0.copy(f).invert(),Pu.copy(s.ray).applyMatrix4(l0);const b=g/((this.scale.x+this.scale.y+this.scale.z)/3),T=b*b,A=h.index,P=h.attributes.position;if(A!==null){const L=Math.max(0,_.start),D=Math.min(A.count,_.start+_.count);for(let O=L,W=D;O<W;O++){const Z=A.getX(O);Af.fromBufferAttribute(P,Z),c0(Af,Z,T,f,s,l,this)}}else{const L=Math.max(0,_.start),D=Math.min(P.count,_.start+_.count);for(let O=L,W=D;O<W;O++)Af.fromBufferAttribute(P,O),c0(Af,O,T,f,s,l,this)}}updateMorphTargets(){const l=this.geometry.morphAttributes,h=Object.keys(l);if(h.length>0){const f=l[h[0]];if(f!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let g=0,_=f.length;g<_;g++){const b=f[g].name||String(g);this.morphTargetInfluences.push(0),this.morphTargetDictionary[b]=g}}}}}function c0(E,s,l,h,f,g,_){const b=Pu.distanceSqToPoint(E);if(b<l){const T=new ae;Pu.closestPointToPoint(E,T),T.applyMatrix4(h);const A=f.ray.origin.distanceTo(T);if(A<f.near||A>f.far)return;g.push({distance:A,distanceToRay:Math.sqrt(b),point:T,index:s,face:null,faceIndex:null,barycoord:null,object:_})}}class wA extends null{constructor(s,l,h,f,g=Yn,_=Yn,b,T,A){super(s,l,h,f,g,_,b,T,A),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const R=this;function P(){R.needsUpdate=!0,R._requestVideoFrameCallbackId=s.requestVideoFrameCallback(P)}"requestVideoFrameCallback"in s&&(this._requestVideoFrameCallbackId=s.requestVideoFrameCallback(P))}clone(){return new this.constructor(this.image).copy(this)}update(){const s=this.image;"requestVideoFrameCallback"in s===!1&&s.readyState>=s.HAVE_CURRENT_DATA&&(this.needsUpdate=!0)}dispose(){this._requestVideoFrameCallbackId!==0&&(this.source.data.cancelVideoFrameCallback(this._requestVideoFrameCallbackId),this._requestVideoFrameCallbackId=0),super.dispose()}}class $_ extends null{constructor(s,l,h,f,g,_,b,T){super({},s,l,h,f,g,_,b,T),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(s){this.image=s,this.needsUpdate=!0}}class dS extends null{constructor(s,l){super({width:s,height:l}),this.isFramebufferTexture=!0,this.magFilter=ni,this.minFilter=ni,this.generateMipmaps=!1,this.needsUpdate=!0}}class u0 extends null{constructor(s,l,h,f,g,_,b,T,A,R,P,L){super(null,_,b,T,A,R,f,g,P,L),this.isCompressedTexture=!0,this.image={width:l,height:h},this.mipmaps=s,this.flipY=!1,this.generateMipmaps=!1}}class h0 extends null{constructor(s,l,h,f,g,_){super(s,l,h,g,_),this.isCompressedArrayTexture=!0,this.image.depth=f,this.wrapR=ki,this.layerUpdates=new Set}addLayerUpdate(s){this.layerUpdates.add(s)}clearLayerUpdates(){this.layerUpdates.clear()}}class d0 extends null{constructor(s,l,h){super(void 0,s[0].width,s[0].height,l,h,Cr),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=s}}class fS extends br{constructor(s,l,h,f,g,_,b,T,A){super(s,l,h,f,g,_,b,T,A),this.isCanvasTexture=!0,this.needsUpdate=!0}}class pS extends null{constructor(s,l,h=yi,f,g,_,b=ni,T=ni,A,R=tr,P=1){if(R!==tr&&R!==Rr)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const L={width:s,height:l,depth:P};super(L,f,g,_,b,T,R,h,A),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(s){return super.copy(s),this.source=new Gl(Object.assign({},s.image)),this.compareFunction=s.compareFunction,this}toJSON(s){const l=super.toJSON(s);return this.compareFunction!==null&&(l.compareFunction=this.compareFunction),l}}class qL extends null{constructor(s=null){super(),this.sourceTexture=s,this.isExternalTexture=!0}copy(s){return super.copy(s),this.sourceTexture=s.sourceTexture,this}}class q_ extends ht{constructor(s=1,l=1,h=4,f=8,g=1){super(),this.type="CapsuleGeometry",this.parameters={radius:s,height:l,capSegments:h,radialSegments:f,heightSegments:g},l=Math.max(0,l),h=Math.max(1,Math.floor(h)),f=Math.max(3,Math.floor(f)),g=Math.max(1,Math.floor(g));const _=[],b=[],T=[],A=[],R=l/2,P=Math.PI/2*s,L=l,D=2*P+L,O=h*2+g,W=f+1,Z=new ae,Y=new ae;for(let ie=0;ie<=O;ie++){let se=0,de=0,ke=0,$e=0;if(ie<=h){const xt=ie/h,Et=xt*Math.PI/2;de=-R-s*Math.cos(Et),ke=s*Math.sin(Et),$e=-s*Math.cos(Et),se=xt*P}else if(ie<=h+g){const xt=(ie-h)/g;de=-R+xt*l,ke=s,$e=0,se=P+xt*L}else{const xt=(ie-h-g)/h,Et=xt*Math.PI/2;de=R+s*Math.sin(Et),ke=s*Math.cos(Et),$e=s*Math.sin(Et),se=P+L+xt*P}const et=Math.max(0,Math.min(1,se/D));let qe=0;ie===0?qe=.5/f:ie===O&&(qe=-.5/f);for(let xt=0;xt<=f;xt++){const Et=xt/f,_n=Et*Math.PI*2,ei=Math.sin(_n),ii=Math.cos(_n);Y.x=-ke*ii,Y.y=de,Y.z=ke*ei,b.push(Y.x,Y.y,Y.z),Z.set(-ke*ii,$e,ke*ei),Z.normalize(),T.push(Z.x,Z.y,Z.z),A.push(Et+qe,et)}if(ie>0){const xt=(ie-1)*W;for(let Et=0;Et<f;Et++){const _n=xt+Et,ei=xt+Et+1,ii=ie*W+Et,zi=ie*W+Et+1;_.push(_n,ei,ii),_.push(ei,zi,ii)}}}this.setIndex(_),this.setAttribute("position",new cn(b,3)),this.setAttribute("normal",new cn(T,3)),this.setAttribute("uv",new cn(A,2))}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}static fromJSON(s){return new q_(s.radius,s.height,s.capSegments,s.radialSegments,s.heightSegments)}}class Ef extends ht{constructor(s=1,l=32,h=0,f=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:s,segments:l,thetaStart:h,thetaLength:f},l=Math.max(3,l);const g=[],_=[],b=[],T=[],A=new ae,R=new St;_.push(0,0,0),b.push(0,0,1),T.push(.5,.5);for(let P=0,L=3;P<=l;P++,L+=3){const D=h+P/l*f;A.x=s*Math.cos(D),A.y=s*Math.sin(D),_.push(A.x,A.y,A.z),b.push(0,0,1),R.x=(_[L]/s+1)/2,R.y=(_[L+1]/s+1)/2,T.push(R.x,R.y)}for(let P=1;P<=l;P++)g.push(P,P+1,0);this.setIndex(g),this.setAttribute("position",new cn(_,3)),this.setAttribute("normal",new cn(b,3)),this.setAttribute("uv",new cn(T,2))}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}static fromJSON(s){return new Ef(s.radius,s.segments,s.thetaStart,s.thetaLength)}}class om extends ht{constructor(s=1,l=1,h=1,f=32,g=1,_=!1,b=0,T=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:s,radiusBottom:l,height:h,radialSegments:f,heightSegments:g,openEnded:_,thetaStart:b,thetaLength:T};const A=this;f=Math.floor(f),g=Math.floor(g);const R=[],P=[],L=[],D=[];let O=0;const W=[],Z=h/2;let Y=0;ie(),_===!1&&(s>0&&se(!0),l>0&&se(!1)),this.setIndex(R),this.setAttribute("position",new cn(P,3)),this.setAttribute("normal",new cn(L,3)),this.setAttribute("uv",new cn(D,2));function ie(){const de=new ae,ke=new ae;let $e=0;const et=(l-s)/h;for(let qe=0;qe<=g;qe++){const xt=[],Et=qe/g,_n=Et*(l-s)+s;for(let ei=0;ei<=f;ei++){const ii=ei/f,zi=ii*T+b,Fi=Math.sin(zi),Zs=Math.cos(zi);ke.x=_n*Fi,ke.y=-Et*h+Z,ke.z=_n*Zs,P.push(ke.x,ke.y,ke.z),de.set(Fi,et,Zs).normalize(),L.push(de.x,de.y,de.z),D.push(ii,1-Et),xt.push(O++)}W.push(xt)}for(let qe=0;qe<f;qe++)for(let xt=0;xt<g;xt++){const Et=W[xt][qe],_n=W[xt+1][qe],ei=W[xt+1][qe+1],ii=W[xt][qe+1];(s>0||xt!==0)&&(R.push(Et,_n,ii),$e+=3),(l>0||xt!==g-1)&&(R.push(_n,ei,ii),$e+=3)}A.addGroup(Y,$e,0),Y+=$e}function se(de){const ke=O,$e=new St,et=new ae;let qe=0;const xt=de===!0?s:l,Et=de===!0?1:-1;for(let ei=1;ei<=f;ei++)P.push(0,Z*Et,0),L.push(0,Et,0),D.push(.5,.5),O++;const _n=O;for(let ei=0;ei<=f;ei++){const zi=ei/f*T+b,Fi=Math.cos(zi),Zs=Math.sin(zi);et.x=xt*Zs,et.y=Z*Et,et.z=xt*Fi,P.push(et.x,et.y,et.z),L.push(0,Et,0),$e.x=Fi*.5+.5,$e.y=Zs*.5*Et+.5,D.push($e.x,$e.y),O++}for(let ei=0;ei<f;ei++){const ii=ke+ei,zi=_n+ei;de===!0?R.push(zi,zi+1,ii):R.push(zi+1,zi,ii),qe+=3}A.addGroup(Y,qe,de===!0?1:2),Y+=qe}}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}static fromJSON(s){return new om(s.radiusTop,s.radiusBottom,s.height,s.radialSegments,s.heightSegments,s.openEnded,s.thetaStart,s.thetaLength)}}class f0 extends om{constructor(s=1,l=1,h=32,f=1,g=!1,_=0,b=Math.PI*2){super(0,s,l,h,f,g,_,b),this.type="ConeGeometry",this.parameters={radius:s,height:l,radialSegments:h,heightSegments:f,openEnded:g,thetaStart:_,thetaLength:b}}static fromJSON(s){return new f0(s.radius,s.height,s.radialSegments,s.heightSegments,s.openEnded,s.thetaStart,s.thetaLength)}}class gd extends ht{constructor(s=[],l=[],h=1,f=0){super(),this.type="PolyhedronGeometry",this.parameters={vertices:s,indices:l,radius:h,detail:f};const g=[],_=[];b(f),A(h),R(),this.setAttribute("position",new cn(g,3)),this.setAttribute("normal",new cn(g.slice(),3)),this.setAttribute("uv",new cn(_,2)),f===0?this.computeVertexNormals():this.normalizeNormals();function b(ie){const se=new ae,de=new ae,ke=new ae;for(let $e=0;$e<l.length;$e+=3)D(l[$e+0],se),D(l[$e+1],de),D(l[$e+2],ke),T(se,de,ke,ie)}function T(ie,se,de,ke){const $e=ke+1,et=[];for(let qe=0;qe<=$e;qe++){et[qe]=[];const xt=ie.clone().lerp(de,qe/$e),Et=se.clone().lerp(de,qe/$e),_n=$e-qe;for(let ei=0;ei<=_n;ei++)ei===0&&qe===$e?et[qe][ei]=xt:et[qe][ei]=xt.clone().lerp(Et,ei/_n)}for(let qe=0;qe<$e;qe++)for(let xt=0;xt<2*($e-qe)-1;xt++){const Et=Math.floor(xt/2);xt%2===0?(L(et[qe][Et+1]),L(et[qe+1][Et]),L(et[qe][Et])):(L(et[qe][Et+1]),L(et[qe+1][Et+1]),L(et[qe+1][Et]))}}function A(ie){const se=new ae;for(let de=0;de<g.length;de+=3)se.x=g[de+0],se.y=g[de+1],se.z=g[de+2],se.normalize().multiplyScalar(ie),g[de+0]=se.x,g[de+1]=se.y,g[de+2]=se.z}function R(){const ie=new ae;for(let se=0;se<g.length;se+=3){ie.x=g[se+0],ie.y=g[se+1],ie.z=g[se+2];const de=Z(ie)/2/Math.PI+.5,ke=Y(ie)/Math.PI+.5;_.push(de,1-ke)}O(),P()}function P(){for(let ie=0;ie<_.length;ie+=6){const se=_[ie+0],de=_[ie+2],ke=_[ie+4],$e=Math.max(se,de,ke),et=Math.min(se,de,ke);$e>.9&&et<.1&&(se<.2&&(_[ie+0]+=1),de<.2&&(_[ie+2]+=1),ke<.2&&(_[ie+4]+=1))}}function L(ie){g.push(ie.x,ie.y,ie.z)}function D(ie,se){const de=ie*3;se.x=s[de+0],se.y=s[de+1],se.z=s[de+2]}function O(){const ie=new ae,se=new ae,de=new ae,ke=new ae,$e=new St,et=new St,qe=new St;for(let xt=0,Et=0;xt<g.length;xt+=9,Et+=6){ie.set(g[xt+0],g[xt+1],g[xt+2]),se.set(g[xt+3],g[xt+4],g[xt+5]),de.set(g[xt+6],g[xt+7],g[xt+8]),$e.set(_[Et+0],_[Et+1]),et.set(_[Et+2],_[Et+3]),qe.set(_[Et+4],_[Et+5]),ke.copy(ie).add(se).add(de).divideScalar(3);const _n=Z(ke);W($e,Et+0,ie,_n),W(et,Et+2,se,_n),W(qe,Et+4,de,_n)}}function W(ie,se,de,ke){ke<0&&ie.x===1&&(_[se]=ie.x-1),de.x===0&&de.z===0&&(_[se]=ke/2/Math.PI+.5)}function Z(ie){return Math.atan2(ie.z,-ie.x)}function Y(ie){return Math.atan2(-ie.y,Math.sqrt(ie.x*ie.x+ie.z*ie.z))}}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}static fromJSON(s){return new gd(s.vertices,s.indices,s.radius,s.details)}}class X_ extends gd{constructor(s=1,l=0){const h=(1+Math.sqrt(5))/2,f=1/h,g=[-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,-f,-h,0,-f,h,0,f,-h,0,f,h,-f,-h,0,-f,h,0,f,-h,0,f,h,0,-h,0,-f,h,0,-f,-h,0,f,h,0,f],_=[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(g,_,s,l),this.type="DodecahedronGeometry",this.parameters={radius:s,detail:l}}static fromJSON(s){return new X_(s.radius,s.detail)}}const Ys=new ae,Cf=new ae,am=new ae,yd=new ir;class p0 extends ht{constructor(s=null,l=1){if(super(),this.type="EdgesGeometry",this.parameters={geometry:s,thresholdAngle:l},s!==null){const f=Math.pow(10,4),g=Math.cos(Ko*l),_=s.getIndex(),b=s.getAttribute("position"),T=_?_.count:b.count,A=[0,0,0],R=["a","b","c"],P=new Array(3),L={},D=[];for(let O=0;O<T;O+=3){_?(A[0]=_.getX(O),A[1]=_.getX(O+1),A[2]=_.getX(O+2)):(A[0]=O,A[1]=O+1,A[2]=O+2);const{a:W,b:Z,c:Y}=yd;if(W.fromBufferAttribute(b,A[0]),Z.fromBufferAttribute(b,A[1]),Y.fromBufferAttribute(b,A[2]),yd.getNormal(am),P[0]=`${Math.round(W.x*f)},${Math.round(W.y*f)},${Math.round(W.z*f)}`,P[1]=`${Math.round(Z.x*f)},${Math.round(Z.y*f)},${Math.round(Z.z*f)}`,P[2]=`${Math.round(Y.x*f)},${Math.round(Y.y*f)},${Math.round(Y.z*f)}`,!(P[0]===P[1]||P[1]===P[2]||P[2]===P[0]))for(let ie=0;ie<3;ie++){const se=(ie+1)%3,de=P[ie],ke=P[se],$e=yd[R[ie]],et=yd[R[se]],qe=`${de}_${ke}`,xt=`${ke}_${de}`;xt in L&&L[xt]?(am.dot(L[xt].normal)<=g&&(D.push($e.x,$e.y,$e.z),D.push(et.x,et.y,et.z)),L[xt]=null):qe in L||(L[qe]={index0:A[ie],index1:A[se],normal:am.clone()})}}for(const O in L)if(L[O]){const{index0:W,index1:Z}=L[O];Ys.fromBufferAttribute(b,W),Cf.fromBufferAttribute(b,Z),D.push(Ys.x,Ys.y,Ys.z),D.push(Cf.x,Cf.y,Cf.z)}this.setAttribute("position",new cn(D,3))}}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}}class Ur{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){Mn("Curve: .getPoint() not implemented.")}getPointAt(s,l){const h=this.getUtoTmapping(s);return this.getPoint(h,l)}getPoints(s=5){const l=[];for(let h=0;h<=s;h++)l.push(this.getPoint(h/s));return l}getSpacedPoints(s=5){const l=[];for(let h=0;h<=s;h++)l.push(this.getPointAt(h/s));return l}getLength(){const s=this.getLengths();return s[s.length-1]}getLengths(s=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===s+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const l=[];let h,f=this.getPoint(0),g=0;l.push(0);for(let _=1;_<=s;_++)h=this.getPoint(_/s),g+=h.distanceTo(f),l.push(g),f=h;return this.cacheArcLengths=l,l}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(s,l=null){const h=this.getLengths();let f=0;const g=h.length;let _;l?_=l:_=s*h[g-1];let b=0,T=g-1,A;for(;b<=T;)if(f=Math.floor(b+(T-b)/2),A=h[f]-_,A<0)b=f+1;else if(A>0)T=f-1;else{T=f;break}if(f=T,h[f]===_)return f/(g-1);const R=h[f],L=h[f+1]-R,D=(_-R)/L;return(f+D)/(g-1)}getTangent(s,l){let f=s-1e-4,g=s+1e-4;f<0&&(f=0),g>1&&(g=1);const _=this.getPoint(f),b=this.getPoint(g),T=l||(_.isVector2?new St:new ae);return T.copy(b).sub(_).normalize(),T}getTangentAt(s,l){const h=this.getUtoTmapping(s);return this.getTangent(h,l)}computeFrenetFrames(s,l=!1){const h=new ae,f=[],g=[],_=[],b=new ae,T=new Dn;for(let D=0;D<=s;D++){const O=D/s;f[D]=this.getTangentAt(O,new ae)}g[0]=new ae,_[0]=new ae;let A=Number.MAX_VALUE;const R=Math.abs(f[0].x),P=Math.abs(f[0].y),L=Math.abs(f[0].z);R<=A&&(A=R,h.set(1,0,0)),P<=A&&(A=P,h.set(0,1,0)),L<=A&&h.set(0,0,1),b.crossVectors(f[0],h).normalize(),g[0].crossVectors(f[0],b),_[0].crossVectors(f[0],g[0]);for(let D=1;D<=s;D++){if(g[D]=g[D-1].clone(),_[D]=_[D-1].clone(),b.crossVectors(f[D-1],f[D]),b.length()>Number.EPSILON){b.normalize();const O=Math.acos(Ut(f[D-1].dot(f[D]),-1,1));g[D].applyMatrix4(T.makeRotationAxis(b,O))}_[D].crossVectors(f[D],g[D])}if(l===!0){let D=Math.acos(Ut(g[0].dot(g[s]),-1,1));D/=s,f[0].dot(b.crossVectors(g[0],g[s]))>0&&(D=-D);for(let O=1;O<=s;O++)g[O].applyMatrix4(T.makeRotationAxis(f[O],D*O)),_[O].crossVectors(f[O],g[O])}return{tangents:f,normals:g,binormals:_}}clone(){return new this.constructor().copy(this)}copy(s){return this.arcLengthDivisions=s.arcLengthDivisions,this}toJSON(){const s={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return s.arcLengthDivisions=this.arcLengthDivisions,s.type=this.type,s}fromJSON(s){return this.arcLengthDivisions=s.arcLengthDivisions,this}}class Lu extends Ur{constructor(s=0,l=0,h=1,f=1,g=0,_=Math.PI*2,b=!1,T=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=s,this.aY=l,this.xRadius=h,this.yRadius=f,this.aStartAngle=g,this.aEndAngle=_,this.aClockwise=b,this.aRotation=T}getPoint(s,l=new St){const h=l,f=Math.PI*2;let g=this.aEndAngle-this.aStartAngle;const _=Math.abs(g)<Number.EPSILON;for(;g<0;)g+=f;for(;g>f;)g-=f;g<Number.EPSILON&&(_?g=0:g=f),this.aClockwise===!0&&!_&&(g===f?g=-f:g=g-f);const b=this.aStartAngle+s*g;let T=this.aX+this.xRadius*Math.cos(b),A=this.aY+this.yRadius*Math.sin(b);if(this.aRotation!==0){const R=Math.cos(this.aRotation),P=Math.sin(this.aRotation),L=T-this.aX,D=A-this.aY;T=L*R-D*P+this.aX,A=L*P+D*R+this.aY}return h.set(T,A)}copy(s){return super.copy(s),this.aX=s.aX,this.aY=s.aY,this.xRadius=s.xRadius,this.yRadius=s.yRadius,this.aStartAngle=s.aStartAngle,this.aEndAngle=s.aEndAngle,this.aClockwise=s.aClockwise,this.aRotation=s.aRotation,this}toJSON(){const s=super.toJSON();return s.aX=this.aX,s.aY=this.aY,s.xRadius=this.xRadius,s.yRadius=this.yRadius,s.aStartAngle=this.aStartAngle,s.aEndAngle=this.aEndAngle,s.aClockwise=this.aClockwise,s.aRotation=this.aRotation,s}fromJSON(s){return super.fromJSON(s),this.aX=s.aX,this.aY=s.aY,this.xRadius=s.xRadius,this.yRadius=s.yRadius,this.aStartAngle=s.aStartAngle,this.aEndAngle=s.aEndAngle,this.aClockwise=s.aClockwise,this.aRotation=s.aRotation,this}}class Du extends Lu{constructor(s,l,h,f,g,_){super(s,l,h,h,f,g,_),this.isArcCurve=!0,this.type="ArcCurve"}}function Rf(){let E=0,s=0,l=0,h=0;function f(g,_,b,T){E=g,s=b,l=-3*g+3*_-2*b-T,h=2*g-2*_+b+T}return{initCatmullRom:function(g,_,b,T,A){f(_,b,A*(b-g),A*(T-_))},initNonuniformCatmullRom:function(g,_,b,T,A,R,P){let L=(_-g)/A-(b-g)/(A+R)+(b-_)/R,D=(b-_)/R-(T-_)/(R+P)+(T-b)/P;L*=R,D*=R,f(_,b,L,D)},calc:function(g){const _=g*g,b=_*g;return E+s*g+l*_+h*b}}}const Fu=new ae,_d=new Rf,Nf=new Rf,xd=new Rf;class mS extends Ur{constructor(s=[],l=!1,h="centripetal",f=.5){super(),this.isCatmullRomCurve3=!0,this.type="CatmullRomCurve3",this.points=s,this.closed=l,this.curveType=h,this.tension=f}getPoint(s,l=new ae){const h=l,f=this.points,g=f.length,_=(g-(this.closed?0:1))*s;let b=Math.floor(_),T=_-b;this.closed?b+=b>0?0:(Math.floor(Math.abs(b)/g)+1)*g:T===0&&b===g-1&&(b=g-2,T=1);let A,R;this.closed||b>0?A=f[(b-1)%g]:(Fu.subVectors(f[0],f[1]).add(f[0]),A=Fu);const P=f[b%g],L=f[(b+1)%g];if(this.closed||b+2<g?R=f[(b+2)%g]:(Fu.subVectors(f[g-1],f[g-2]).add(f[g-1]),R=Fu),this.curveType==="centripetal"||this.curveType==="chordal"){const D=this.curveType==="chordal"?.5:.25;let O=Math.pow(A.distanceToSquared(P),D),W=Math.pow(P.distanceToSquared(L),D),Z=Math.pow(L.distanceToSquared(R),D);W<1e-4&&(W=1),O<1e-4&&(O=W),Z<1e-4&&(Z=W),_d.initNonuniformCatmullRom(A.x,P.x,L.x,R.x,O,W,Z),Nf.initNonuniformCatmullRom(A.y,P.y,L.y,R.y,O,W,Z),xd.initNonuniformCatmullRom(A.z,P.z,L.z,R.z,O,W,Z)}else this.curveType==="catmullrom"&&(_d.initCatmullRom(A.x,P.x,L.x,R.x,this.tension),Nf.initCatmullRom(A.y,P.y,L.y,R.y,this.tension),xd.initCatmullRom(A.z,P.z,L.z,R.z,this.tension));return h.set(_d.calc(T),Nf.calc(T),xd.calc(T)),h}copy(s){super.copy(s),this.points=[];for(let l=0,h=s.points.length;l<h;l++){const f=s.points[l];this.points.push(f.clone())}return this.closed=s.closed,this.curveType=s.curveType,this.tension=s.tension,this}toJSON(){const s=super.toJSON();s.points=[];for(let l=0,h=this.points.length;l<h;l++){const f=this.points[l];s.points.push(f.toArray())}return s.closed=this.closed,s.curveType=this.curveType,s.tension=this.tension,s}fromJSON(s){super.fromJSON(s),this.points=[];for(let l=0,h=s.points.length;l<h;l++){const f=s.points[l];this.points.push(new ae().fromArray(f))}return this.closed=s.closed,this.curveType=s.curveType,this.tension=s.tension,this}}function la(E,s,l,h,f){const g=(h-s)*.5,_=(f-l)*.5,b=E*E,T=E*b;return(2*l-2*h+g+_)*T+(-3*l+3*h-2*g-_)*b+g*E+l}function m0(E,s){const l=1-E;return l*l*s}function gS(E,s){return 2*(1-E)*E*s}function g0(E,s){return E*E*s}function hc(E,s,l,h){return m0(E,s)+gS(E,l)+g0(E,h)}function y0(E,s){const l=1-E;return l*l*l*s}function _0(E,s){const l=1-E;return 3*l*l*E*s}function x0(E,s){return 3*(1-E)*E*E*s}function yS(E,s){return E*E*E*s}function vd(E,s,l,h,f){return y0(E,s)+_0(E,l)+x0(E,h)+yS(E,f)}class j_ extends Ur{constructor(s=new St,l=new St,h=new St,f=new St){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=s,this.v1=l,this.v2=h,this.v3=f}getPoint(s,l=new St){const h=l,f=this.v0,g=this.v1,_=this.v2,b=this.v3;return h.set(vd(s,f.x,g.x,_.x,b.x),vd(s,f.y,g.y,_.y,b.y)),h}copy(s){return super.copy(s),this.v0.copy(s.v0),this.v1.copy(s.v1),this.v2.copy(s.v2),this.v3.copy(s.v3),this}toJSON(){const s=super.toJSON();return s.v0=this.v0.toArray(),s.v1=this.v1.toArray(),s.v2=this.v2.toArray(),s.v3=this.v3.toArray(),s}fromJSON(s){return super.fromJSON(s),this.v0.fromArray(s.v0),this.v1.fromArray(s.v1),this.v2.fromArray(s.v2),this.v3.fromArray(s.v3),this}}class _S extends Ur{constructor(s=new ae,l=new ae,h=new ae,f=new ae){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=s,this.v1=l,this.v2=h,this.v3=f}getPoint(s,l=new ae){const h=l,f=this.v0,g=this.v1,_=this.v2,b=this.v3;return h.set(vd(s,f.x,g.x,_.x,b.x),vd(s,f.y,g.y,_.y,b.y),vd(s,f.z,g.z,_.z,b.z)),h}copy(s){return super.copy(s),this.v0.copy(s.v0),this.v1.copy(s.v1),this.v2.copy(s.v2),this.v3.copy(s.v3),this}toJSON(){const s=super.toJSON();return s.v0=this.v0.toArray(),s.v1=this.v1.toArray(),s.v2=this.v2.toArray(),s.v3=this.v3.toArray(),s}fromJSON(s){return super.fromJSON(s),this.v0.fromArray(s.v0),this.v1.fromArray(s.v1),this.v2.fromArray(s.v2),this.v3.fromArray(s.v3),this}}class Y_ extends Ur{constructor(s=new St,l=new St){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=s,this.v2=l}getPoint(s,l=new St){const h=l;return s===1?h.copy(this.v2):(h.copy(this.v2).sub(this.v1),h.multiplyScalar(s).add(this.v1)),h}getPointAt(s,l){return this.getPoint(s,l)}getTangent(s,l=new St){return l.subVectors(this.v2,this.v1).normalize()}getTangentAt(s,l){return this.getTangent(s,l)}copy(s){return super.copy(s),this.v1.copy(s.v1),this.v2.copy(s.v2),this}toJSON(){const s=super.toJSON();return s.v1=this.v1.toArray(),s.v2=this.v2.toArray(),s}fromJSON(s){return super.fromJSON(s),this.v1.fromArray(s.v1),this.v2.fromArray(s.v2),this}}class Pf extends Ur{constructor(s=new ae,l=new ae){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=s,this.v2=l}getPoint(s,l=new ae){const h=l;return s===1?h.copy(this.v2):(h.copy(this.v2).sub(this.v1),h.multiplyScalar(s).add(this.v1)),h}getPointAt(s,l){return this.getPoint(s,l)}getTangent(s,l=new ae){return l.subVectors(this.v2,this.v1).normalize()}getTangentAt(s,l){return this.getTangent(s,l)}copy(s){return super.copy(s),this.v1.copy(s.v1),this.v2.copy(s.v2),this}toJSON(){const s=super.toJSON();return s.v1=this.v1.toArray(),s.v2=this.v2.toArray(),s}fromJSON(s){return super.fromJSON(s),this.v1.fromArray(s.v1),this.v2.fromArray(s.v2),this}}class Z_ extends Ur{constructor(s=new St,l=new St,h=new St){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=s,this.v1=l,this.v2=h}getPoint(s,l=new St){const h=l,f=this.v0,g=this.v1,_=this.v2;return h.set(hc(s,f.x,g.x,_.x),hc(s,f.y,g.y,_.y)),h}copy(s){return super.copy(s),this.v0.copy(s.v0),this.v1.copy(s.v1),this.v2.copy(s.v2),this}toJSON(){const s=super.toJSON();return s.v0=this.v0.toArray(),s.v1=this.v1.toArray(),s.v2=this.v2.toArray(),s}fromJSON(s){return super.fromJSON(s),this.v0.fromArray(s.v0),this.v1.fromArray(s.v1),this.v2.fromArray(s.v2),this}}class K_ extends Ur{constructor(s=new ae,l=new ae,h=new ae){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=s,this.v1=l,this.v2=h}getPoint(s,l=new ae){const h=l,f=this.v0,g=this.v1,_=this.v2;return h.set(hc(s,f.x,g.x,_.x),hc(s,f.y,g.y,_.y),hc(s,f.z,g.z,_.z)),h}copy(s){return super.copy(s),this.v0.copy(s.v0),this.v1.copy(s.v1),this.v2.copy(s.v2),this}toJSON(){const s=super.toJSON();return s.v0=this.v0.toArray(),s.v1=this.v1.toArray(),s.v2=this.v2.toArray(),s}fromJSON(s){return super.fromJSON(s),this.v0.fromArray(s.v0),this.v1.fromArray(s.v1),this.v2.fromArray(s.v2),this}}class J_ extends Ur{constructor(s=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=s}getPoint(s,l=new St){const h=l,f=this.points,g=(f.length-1)*s,_=Math.floor(g),b=g-_,T=f[_===0?_:_-1],A=f[_],R=f[_>f.length-2?f.length-1:_+1],P=f[_>f.length-3?f.length-1:_+2];return h.set(la(b,T.x,A.x,R.x,P.x),la(b,T.y,A.y,R.y,P.y)),h}copy(s){super.copy(s),this.points=[];for(let l=0,h=s.points.length;l<h;l++){const f=s.points[l];this.points.push(f.clone())}return this}toJSON(){const s=super.toJSON();s.points=[];for(let l=0,h=this.points.length;l<h;l++){const f=this.points[l];s.points.push(f.toArray())}return s}fromJSON(s){super.fromJSON(s),this.points=[];for(let l=0,h=s.points.length;l<h;l++){const f=s.points[l];this.points.push(new St().fromArray(f))}return this}}var lm=Object.freeze({__proto__:null,ArcCurve:Du,CatmullRomCurve3:mS,CubicBezierCurve:j_,CubicBezierCurve3:_S,EllipseCurve:Lu,LineCurve:Y_,LineCurve3:Pf,QuadraticBezierCurve:Z_,QuadraticBezierCurve3:K_,SplineCurve:J_});class If extends Ur{constructor(){super(),this.type="CurvePath",this.curves=[],this.autoClose=!1}add(s){this.curves.push(s)}closePath(){const s=this.curves[0].getPoint(0),l=this.curves[this.curves.length-1].getPoint(1);if(!s.equals(l)){const h=s.isVector2===!0?"LineCurve":"LineCurve3";this.curves.push(new lm[h](l,s))}return this}getPoint(s,l){const h=s*this.getLength(),f=this.getCurveLengths();let g=0;for(;g<f.length;){if(f[g]>=h){const _=f[g]-h,b=this.curves[g],T=b.getLength(),A=T===0?0:1-_/T;return b.getPointAt(A,l)}g++}return null}getLength(){const s=this.getCurveLengths();return s[s.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 s=[];let l=0;for(let h=0,f=this.curves.length;h<f;h++)l+=this.curves[h].getLength(),s.push(l);return this.cacheLengths=s,s}getSpacedPoints(s=40){const l=[];for(let h=0;h<=s;h++)l.push(this.getPoint(h/s));return this.autoClose&&l.push(l[0]),l}getPoints(s=12){const l=[];let h;for(let f=0,g=this.curves;f<g.length;f++){const _=g[f],b=_.isEllipseCurve?s*2:_.isLineCurve||_.isLineCurve3?1:_.isSplineCurve?s*_.points.length:s,T=_.getPoints(b);for(let A=0;A<T.length;A++){const R=T[A];h&&h.equals(R)||(l.push(R),h=R)}}return this.autoClose&&l.length>1&&!l[l.length-1].equals(l[0])&&l.push(l[0]),l}copy(s){super.copy(s),this.curves=[];for(let l=0,h=s.curves.length;l<h;l++){const f=s.curves[l];this.curves.push(f.clone())}return this.autoClose=s.autoClose,this}toJSON(){const s=super.toJSON();s.autoClose=this.autoClose,s.curves=[];for(let l=0,h=this.curves.length;l<h;l++){const f=this.curves[l];s.curves.push(f.toJSON())}return s}fromJSON(s){super.fromJSON(s),this.autoClose=s.autoClose,this.curves=[];for(let l=0,h=s.curves.length;l<h;l++){const f=s.curves[l];this.curves.push(new lm[f.type]().fromJSON(f))}return this}}class cm extends If{constructor(s){super(),this.type="Path",this.currentPoint=new St,s&&this.setFromPoints(s)}setFromPoints(s){this.moveTo(s[0].x,s[0].y);for(let l=1,h=s.length;l<h;l++)this.lineTo(s[l].x,s[l].y);return this}moveTo(s,l){return this.currentPoint.set(s,l),this}lineTo(s,l){const h=new Y_(this.currentPoint.clone(),new St(s,l));return this.curves.push(h),this.currentPoint.set(s,l),this}quadraticCurveTo(s,l,h,f){const g=new Z_(this.currentPoint.clone(),new St(s,l),new St(h,f));return this.curves.push(g),this.currentPoint.set(h,f),this}bezierCurveTo(s,l,h,f,g,_){const b=new j_(this.currentPoint.clone(),new St(s,l),new St(h,f),new St(g,_));return this.curves.push(b),this.currentPoint.set(g,_),this}splineThru(s){const l=[this.currentPoint.clone()].concat(s),h=new J_(l);return this.curves.push(h),this.currentPoint.copy(s[s.length-1]),this}arc(s,l,h,f,g,_){const b=this.currentPoint.x,T=this.currentPoint.y;return this.absarc(s+b,l+T,h,f,g,_),this}absarc(s,l,h,f,g,_){return this.absellipse(s,l,h,h,f,g,_),this}ellipse(s,l,h,f,g,_,b,T){const A=this.currentPoint.x,R=this.currentPoint.y;return this.absellipse(s+A,l+R,h,f,g,_,b,T),this}absellipse(s,l,h,f,g,_,b,T){const A=new Lu(s,l,h,f,g,_,b,T);if(this.curves.length>0){const P=A.getPoint(0);P.equals(this.currentPoint)||this.lineTo(P.x,P.y)}this.curves.push(A);const R=A.getPoint(1);return this.currentPoint.copy(R),this}copy(s){return super.copy(s),this.currentPoint.copy(s.currentPoint),this}toJSON(){const s=super.toJSON();return s.currentPoint=this.currentPoint.toArray(),s}fromJSON(s){return super.fromJSON(s),this.currentPoint.fromArray(s.currentPoint),this}}class Bu extends cm{constructor(s){super(s),this.uuid=Be(),this.type="Shape",this.holes=[]}getPointsHoles(s){const l=[];for(let h=0,f=this.holes.length;h<f;h++)l[h]=this.holes[h].getPoints(s);return l}extractPoints(s){return{shape:this.getPoints(s),holes:this.getPointsHoles(s)}}copy(s){super.copy(s),this.holes=[];for(let l=0,h=s.holes.length;l<h;l++){const f=s.holes[l];this.holes.push(f.clone())}return this}toJSON(){const s=super.toJSON();s.uuid=this.uuid,s.holes=[];for(let l=0,h=this.holes.length;l<h;l++){const f=this.holes[l];s.holes.push(f.toJSON())}return s}fromJSON(s){super.fromJSON(s),this.uuid=s.uuid,this.holes=[];for(let l=0,h=s.holes.length;l<h;l++){const f=s.holes[l];this.holes.push(new cm().fromJSON(f))}return this}}function Q_(E,s,l=2){const h=s&&s.length,f=h?s[0]*l:E.length;let g=ex(E,0,f,l,!0);const _=[];if(!g||g.next===g.prev)return _;let b,T,A;if(h&&(g=bd(E,s,g,l)),E.length>80*l){b=E[0],T=E[1];let R=b,P=T;for(let L=l;L<f;L+=l){const D=E[L],O=E[L+1];D<b&&(b=D),O<T&&(T=O),D>R&&(R=D),O>P&&(P=O)}A=Math.max(R-b,P-T),A=A!==0?32767/A:0}return Ou(g,_,l,b,T,A,0),_}function ex(E,s,l,h,f){let g;if(f===fm(E,s,l,h)>0)for(let _=s;_<l;_+=h)g=is(_/h|0,E[_],E[_+1],g);else for(let _=l-h;_>=s;_-=h)g=is(_/h|0,E[_],E[_+1],g);return g&&Sd(g,g.next)&&(Va(g),g=g.next),g}function dc(E,s){if(!E)return E;s||(s=E);let l=E,h;do if(h=!1,!l.steiner&&(Sd(l,l.next)||ls(l.prev,l,l.next)===0)){if(Va(l),l=s=l.prev,l===l.next)break;h=!0}else l=l.next;while(h||l!==s);return s}function Ou(E,s,l,h,f,g,_){if(!E)return;!_&&g&&bS(E,h,f,g);let b=E;for(;E.prev!==E.next;){const T=E.prev,A=E.next;if(g?um(E,h,f,g):tx(E)){s.push(T.i,E.i,A.i),Va(E),E=A.next,b=A.next;continue}if(E=A,E===b){_?_===1?(E=xS(dc(E),s),Ou(E,s,l,h,f,g,2)):_===2&&v0(E,s,l,h,f,g):Ou(dc(E),s,l,h,f,g,1);break}}}function tx(E){const s=E.prev,l=E,h=E.next;if(ls(s,l,h)>=0)return!1;const f=s.x,g=l.x,_=h.x,b=s.y,T=l.y,A=h.y,R=Math.min(f,g,_),P=Math.min(b,T,A),L=Math.max(f,g,_),D=Math.max(b,T,A);let O=h.next;for(;O!==s;){if(O.x>=R&&O.x<=L&&O.y>=P&&O.y<=D&&Df(f,b,g,T,_,A,O.x,O.y)&&ls(O.prev,O,O.next)>=0)return!1;O=O.next}return!0}function um(E,s,l,h){const f=E.prev,g=E,_=E.next;if(ls(f,g,_)>=0)return!1;const b=f.x,T=g.x,A=_.x,R=f.y,P=g.y,L=_.y,D=Math.min(b,T,A),O=Math.min(R,P,L),W=Math.max(b,T,A),Z=Math.max(R,P,L),Y=b0(D,O,s,l,h),ie=b0(W,Z,s,l,h);let se=E.prevZ,de=E.nextZ;for(;se&&se.z>=Y&&de&&de.z<=ie;){if(se.x>=D&&se.x<=W&&se.y>=O&&se.y<=Z&&se!==f&&se!==_&&Df(b,R,T,P,A,L,se.x,se.y)&&ls(se.prev,se,se.next)>=0||(se=se.prevZ,de.x>=D&&de.x<=W&&de.y>=O&&de.y<=Z&&de!==f&&de!==_&&Df(b,R,T,P,A,L,de.x,de.y)&&ls(de.prev,de,de.next)>=0))return!1;de=de.nextZ}for(;se&&se.z>=Y;){if(se.x>=D&&se.x<=W&&se.y>=O&&se.y<=Z&&se!==f&&se!==_&&Df(b,R,T,P,A,L,se.x,se.y)&&ls(se.prev,se,se.next)>=0)return!1;se=se.prevZ}for(;de&&de.z<=ie;){if(de.x>=D&&de.x<=W&&de.y>=O&&de.y<=Z&&de!==f&&de!==_&&Df(b,R,T,P,A,L,de.x,de.y)&&ls(de.prev,de,de.next)>=0)return!1;de=de.nextZ}return!0}function xS(E,s){let l=E;do{const h=l.prev,f=l.next.next;!Sd(h,f)&&sx(h,l,l.next,f)&&Td(h,f)&&Td(f,h)&&(s.push(h.i,l.i,f.i),Va(l),Va(l.next),l=E=f),l=l.next}while(l!==E);return dc(l)}function v0(E,s,l,h,f,g){let _=E;do{let b=_.next.next;for(;b!==_.prev;){if(_.i!==b.i&&TS(_,b)){let T=rx(_,b);_=dc(_,_.next),T=dc(T,T.next),Ou(_,s,l,h,f,g,0),Ou(T,s,l,h,f,g,0);return}b=b.next}_=_.next}while(_!==E)}function bd(E,s,l,h){const f=[];for(let g=0,_=s.length;g<_;g++){const b=s[g]*h,T=g<_-1?s[g+1]*h:E.length,A=ex(E,b,T,h,!1);A===A.next&&(A.steiner=!0),f.push(MS(A))}f.sort(vS);for(let g=0;g<f.length;g++)l=nx(f[g],l);return l}function vS(E,s){let l=E.x-s.x;if(l===0&&(l=E.y-s.y,l===0)){const h=(E.next.y-E.y)/(E.next.x-E.x),f=(s.next.y-s.y)/(s.next.x-s.x);l=h-f}return l}function nx(E,s){const l=Uu(E,s);if(!l)return s;const h=rx(l,E);return dc(h,h.next),dc(l,l.next)}function Uu(E,s){let l=s;const h=E.x,f=E.y;let g=-1/0,_;if(Sd(E,l))return l;do{if(Sd(E,l.next))return l.next;if(f<=l.y&&f>=l.next.y&&l.next.y!==l.y){const P=l.x+(f-l.y)*(l.next.x-l.x)/(l.next.y-l.y);if(P<=h&&P>g&&(g=P,_=l.x<l.next.x?l:l.next,P===h))return _}l=l.next}while(l!==s);if(!_)return null;const b=_,T=_.x,A=_.y;let R=1/0;l=_;do{if(h>=l.x&&l.x>=T&&h!==l.x&&ix(f<A?h:g,f,T,A,f<A?g:h,f,l.x,l.y)){const P=Math.abs(f-l.y)/(h-l.x);Td(l,E)&&(P<R||P===R&&(l.x>_.x||l.x===_.x&&Lf(_,l)))&&(_=l,R=P)}l=l.next}while(l!==b);return _}function Lf(E,s){return ls(E.prev,E,s.prev)<0&&ls(s.next,E,E.next)<0}function bS(E,s,l,h){let f=E;do f.z===0&&(f.z=b0(f.x,f.y,s,l,h)),f.prevZ=f.prev,f.nextZ=f.next,f=f.next;while(f!==E);f.prevZ.nextZ=null,f.prevZ=null,SS(f)}function SS(E){let s,l=1;do{let h=E,f;E=null;let g=null;for(s=0;h;){s++;let _=h,b=0;for(let A=0;A<l&&(b++,_=_.nextZ,!!_);A++);let T=l;for(;b>0||T>0&&_;)b!==0&&(T===0||!_||h.z<=_.z)?(f=h,h=h.nextZ,b--):(f=_,_=_.nextZ,T--),g?g.nextZ=f:E=f,f.prevZ=g,g=f;h=_}g.nextZ=null,l*=2}while(s>1);return E}function b0(E,s,l,h,f){return E=(E-l)*f|0,s=(s-h)*f|0,E=(E|E<<8)&16711935,E=(E|E<<4)&252645135,E=(E|E<<2)&858993459,E=(E|E<<1)&1431655765,s=(s|s<<8)&16711935,s=(s|s<<4)&252645135,s=(s|s<<2)&858993459,s=(s|s<<1)&1431655765,E|s<<1}function MS(E){let s=E,l=E;do(s.x<l.x||s.x===l.x&&s.y<l.y)&&(l=s),s=s.next;while(s!==E);return l}function ix(E,s,l,h,f,g,_,b){return(f-_)*(s-b)>=(E-_)*(g-b)&&(E-_)*(h-b)>=(l-_)*(s-b)&&(l-_)*(g-b)>=(f-_)*(h-b)}function Df(E,s,l,h,f,g,_,b){return!(E===_&&s===b)&&ix(E,s,l,h,f,g,_,b)}function TS(E,s){return E.next.i!==s.i&&E.prev.i!==s.i&&!wS(E,s)&&(Td(E,s)&&Td(s,E)&&Ff(E,s)&&(ls(E.prev,E,s.prev)||ls(E,s.prev,s))||Sd(E,s)&&ls(E.prev,E,E.next)>0&&ls(s.prev,s,s.next)>0)}function ls(E,s,l){return(s.y-E.y)*(l.x-s.x)-(s.x-E.x)*(l.y-s.y)}function Sd(E,s){return E.x===s.x&&E.y===s.y}function sx(E,s,l,h){const f=Md(ls(E,s,l)),g=Md(ls(E,s,h)),_=Md(ls(l,h,E)),b=Md(ls(l,h,s));return!!(f!==g&&_!==b||f===0&&hm(E,l,s)||g===0&&hm(E,h,s)||_===0&&hm(l,E,h)||b===0&&hm(l,s,h))}function hm(E,s,l){return s.x<=Math.max(E.x,l.x)&&s.x>=Math.min(E.x,l.x)&&s.y<=Math.max(E.y,l.y)&&s.y>=Math.min(E.y,l.y)}function Md(E){return E>0?1:E<0?-1:0}function wS(E,s){let l=E;do{if(l.i!==E.i&&l.next.i!==E.i&&l.i!==s.i&&l.next.i!==s.i&&sx(l,l.next,E,s))return!0;l=l.next}while(l!==E);return!1}function Td(E,s){return ls(E.prev,E,E.next)<0?ls(E,s,E.next)>=0&&ls(E,E.prev,s)>=0:ls(E,s,E.prev)<0||ls(E,E.next,s)<0}function Ff(E,s){let l=E,h=!1;const f=(E.x+s.x)/2,g=(E.y+s.y)/2;do l.y>g!=l.next.y>g&&l.next.y!==l.y&&f<(l.next.x-l.x)*(g-l.y)/(l.next.y-l.y)+l.x&&(h=!h),l=l.next;while(l!==E);return h}function rx(E,s){const l=dm(E.i,E.x,E.y),h=dm(s.i,s.x,s.y),f=E.next,g=s.prev;return E.next=s,s.prev=E,l.next=f,f.prev=l,h.next=l,l.prev=h,g.next=h,h.prev=g,h}function is(E,s,l,h){const f=dm(E,s,l);return h?(f.next=h.next,f.prev=h,h.next.prev=f,h.next=f):(f.prev=f,f.next=f),f}function Va(E){E.next.prev=E.prev,E.prev.next=E.next,E.prevZ&&(E.prevZ.nextZ=E.nextZ),E.nextZ&&(E.nextZ.prevZ=E.prevZ)}function dm(E,s,l){return{i:E,x:s,y:l,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function fm(E,s,l,h){let f=0;for(let g=s,_=l-h;g<l;g+=h)f+=(E[_]-E[g])*(E[g+1]+E[_+1]),_=g;return f}class pm{static triangulate(s,l,h=2){return Q_(s,l,h)}}class Ga{static area(s){const l=s.length;let h=0;for(let f=l-1,g=0;g<l;f=g++)h+=s[f].x*s[g].y-s[g].x*s[f].y;return h*.5}static isClockWise(s){return Ga.area(s)<0}static triangulateShape(s,l){const h=[],f=[],g=[];wd(s),ox(h,s);let _=s.length;l.forEach(wd);for(let T=0;T<l.length;T++)f.push(_),_+=l[T].length,ox(h,l[T]);const b=pm.triangulate(h,f);for(let T=0;T<b.length;T+=3)g.push(b.slice(T,T+3));return g}}function wd(E){const s=E.length;s>2&&E[s-1].equals(E[0])&&E.pop()}function ox(E,s){for(let l=0;l<s.length;l++)E.push(s[l].x),E.push(s[l].y)}class mm extends ht{constructor(s=new Bu([new St(.5,.5),new St(-.5,.5),new St(-.5,-.5),new St(.5,-.5)]),l={}){super(),this.type="ExtrudeGeometry",this.parameters={shapes:s,options:l},s=Array.isArray(s)?s:[s];const h=this,f=[],g=[];for(let b=0,T=s.length;b<T;b++){const A=s[b];_(A)}this.setAttribute("position",new cn(f,3)),this.setAttribute("uv",new cn(g,2)),this.computeVertexNormals();function _(b){const T=[],A=l.curveSegments!==void 0?l.curveSegments:12,R=l.steps!==void 0?l.steps:1,P=l.depth!==void 0?l.depth:1;let L=l.bevelEnabled!==void 0?l.bevelEnabled:!0,D=l.bevelThickness!==void 0?l.bevelThickness:.2,O=l.bevelSize!==void 0?l.bevelSize:D-.1,W=l.bevelOffset!==void 0?l.bevelOffset:0,Z=l.bevelSegments!==void 0?l.bevelSegments:3;const Y=l.extrudePath,ie=l.UVGenerator!==void 0?l.UVGenerator:ax;let se,de=!1,ke,$e,et,qe;Y&&(se=Y.getSpacedPoints(R),de=!0,L=!1,ke=Y.computeFrenetFrames(R,!1),$e=new ae,et=new ae,qe=new ae),L||(Z=0,D=0,O=0,W=0);const xt=b.extractPoints(A);let Et=xt.shape;const _n=xt.holes;if(!Ga.isClockWise(Et)){Et=Et.reverse();for(let Gt=0,sn=_n.length;Gt<sn;Gt++){const on=_n[Gt];Ga.isClockWise(on)&&(_n[Gt]=on.reverse())}}function ii(Gt){const on=10000000000000001e-36;let En=Gt[0];for(let Tn=1;Tn<=Gt.length;Tn++){const bi=Tn%Gt.length,si=Gt[bi],Vi=si.x-En.x,ss=si.y-En.y,Ks=Vi*Vi+ss*ss,po=Math.max(Math.abs(si.x),Math.abs(si.y),Math.abs(En.x),Math.abs(En.y)),ha=on*po*po;if(Ks<=ha){Gt.splice(bi,1),Tn--;continue}En=si}}ii(Et),_n.forEach(ii);const zi=_n.length,Fi=Et;for(let Gt=0;Gt<zi;Gt++){const sn=_n[Gt];Et=Et.concat(sn)}function Zs(Gt,sn,on){return sn||ci("ExtrudeGeometry: vec does not exist"),Gt.clone().addScaledVector(sn,on)}const dr=Et.length;function ca(Gt,sn,on){let En,Tn,bi;const si=Gt.x-sn.x,Vi=Gt.y-sn.y,ss=on.x-Gt.x,Ks=on.y-Gt.y,po=si*si+Vi*Vi,ha=si*Ks-Vi*ss;if(Math.abs(ha)>Number.EPSILON){const mo=Math.sqrt(po),Ox=Math.sqrt(ss*ss+Ks*Ks),Ux=sn.x-Vi/mo,kx=sn.y+si/mo,iM=on.x-Ks/Ox,sM=on.y+ss/Ox,zx=((iM-Ux)*Ks-(sM-kx)*ss)/(si*Ks-Vi*ss);En=Ux+si*zx-Gt.x,Tn=kx+Vi*zx-Gt.y;const Vx=En*En+Tn*Tn;if(Vx<=2)return new St(En,Tn);bi=Math.sqrt(Vx/2)}else{let mo=!1;si>Number.EPSILON?ss>Number.EPSILON&&(mo=!0):si<-Number.EPSILON?ss<-Number.EPSILON&&(mo=!0):Math.sign(Vi)===Math.sign(Ks)&&(mo=!0),mo?(En=-Vi,Tn=si,bi=Math.sqrt(po)):(En=si,Tn=Vi,bi=Math.sqrt(po/2))}return new St(En/bi,Tn/bi)}const gs=[];for(let Gt=0,sn=Fi.length,on=sn-1,En=Gt+1;Gt<sn;Gt++,on++,En++)on===sn&&(on=0),En===sn&&(En=0),gs[Gt]=ca(Fi[Gt],Fi[on],Fi[En]);const Os=[];let us,Uo=gs.concat();for(let Gt=0,sn=zi;Gt<sn;Gt++){const on=_n[Gt];us=[];for(let En=0,Tn=on.length,bi=Tn-1,si=En+1;En<Tn;En++,bi++,si++)bi===Tn&&(bi=0),si===Tn&&(si=0),us[En]=ca(on[En],on[bi],on[si]);Os.push(us),Uo=Uo.concat(us)}let kr;if(Z===0)kr=Ga.triangulateShape(Fi,_n);else{const Gt=[],sn=[];for(let on=0;on<Z;on++){const En=on/Z,Tn=D*Math.cos(En*Math.PI/2),bi=O*Math.sin(En*Math.PI/2)+W;for(let si=0,Vi=Fi.length;si<Vi;si++){const ss=Zs(Fi[si],gs[si],bi);bl(ss.x,ss.y,-Tn),En===0&&Gt.push(ss)}for(let si=0,Vi=zi;si<Vi;si++){const ss=_n[si];us=Os[si];const Ks=[];for(let po=0,ha=ss.length;po<ha;po++){const mo=Zs(ss[po],us[po],bi);bl(mo.x,mo.y,-Tn),En===0&&Ks.push(mo)}En===0&&sn.push(Ks)}}kr=Ga.triangulateShape(Gt,sn)}const Bd=kr.length,Xf=O+W;for(let Gt=0;Gt<dr;Gt++){const sn=L?Zs(Et[Gt],Uo[Gt],Xf):Et[Gt];de?(et.copy(ke.normals[0]).multiplyScalar(sn.x),$e.copy(ke.binormals[0]).multiplyScalar(sn.y),qe.copy(se[0]).add(et).add($e),bl(qe.x,qe.y,qe.z)):bl(sn.x,sn.y,0)}for(let Gt=1;Gt<=R;Gt++)for(let sn=0;sn<dr;sn++){const on=L?Zs(Et[sn],Uo[sn],Xf):Et[sn];de?(et.copy(ke.normals[Gt]).multiplyScalar(on.x),$e.copy(ke.binormals[Gt]).multiplyScalar(on.y),qe.copy(se[Gt]).add(et).add($e),bl(qe.x,qe.y,qe.z)):bl(on.x,on.y,P/R*Gt)}for(let Gt=Z-1;Gt>=0;Gt--){const sn=Gt/Z,on=D*Math.cos(sn*Math.PI/2),En=O*Math.sin(sn*Math.PI/2)+W;for(let Tn=0,bi=Fi.length;Tn<bi;Tn++){const si=Zs(Fi[Tn],gs[Tn],En);bl(si.x,si.y,P+on)}for(let Tn=0,bi=_n.length;Tn<bi;Tn++){const si=_n[Tn];us=Os[Tn];for(let Vi=0,ss=si.length;Vi<ss;Vi++){const Ks=Zs(si[Vi],us[Vi],En);de?bl(Ks.x,Ks.y+se[R-1].y,se[R-1].x+on):bl(Ks.x,Ks.y,P+on)}}}K0(),nM();function K0(){const Gt=f.length/3;if(L){let sn=0,on=dr*sn;for(let En=0;En<Bd;En++){const Tn=kr[En];Vm(Tn[2]+on,Tn[1]+on,Tn[0]+on)}sn=R+Z*2,on=dr*sn;for(let En=0;En<Bd;En++){const Tn=kr[En];Vm(Tn[0]+on,Tn[1]+on,Tn[2]+on)}}else{for(let sn=0;sn<Bd;sn++){const on=kr[sn];Vm(on[2],on[1],on[0])}for(let sn=0;sn<Bd;sn++){const on=kr[sn];Vm(on[0]+dr*R,on[1]+dr*R,on[2]+dr*R)}}h.addGroup(Gt,f.length/3-Gt,0)}function nM(){const Gt=f.length/3;let sn=0;Fx(Fi,sn),sn+=Fi.length;for(let on=0,En=_n.length;on<En;on++){const Tn=_n[on];Fx(Tn,sn),sn+=Tn.length}h.addGroup(Gt,f.length/3-Gt,1)}function Fx(Gt,sn){let on=Gt.length;for(;--on>=0;){const En=on;let Tn=on-1;Tn<0&&(Tn=Gt.length-1);for(let bi=0,si=R+Z*2;bi<si;bi++){const Vi=dr*bi,ss=dr*(bi+1),Ks=sn+En+Vi,po=sn+Tn+Vi,ha=sn+Tn+ss,mo=sn+En+ss;Bx(Ks,po,ha,mo)}}}function bl(Gt,sn,on){T.push(Gt),T.push(sn),T.push(on)}function Vm(Gt,sn,on){Sl(Gt),Sl(sn),Sl(on);const En=f.length/3,Tn=ie.generateTopUV(h,f,En-3,En-2,En-1);ua(Tn[0]),ua(Tn[1]),ua(Tn[2])}function Bx(Gt,sn,on,En){Sl(Gt),Sl(sn),Sl(En),Sl(sn),Sl(on),Sl(En);const Tn=f.length/3,bi=ie.generateSideWallUV(h,f,Tn-6,Tn-3,Tn-2,Tn-1);ua(bi[0]),ua(bi[1]),ua(bi[3]),ua(bi[1]),ua(bi[2]),ua(bi[3])}function Sl(Gt){f.push(T[Gt*3+0]),f.push(T[Gt*3+1]),f.push(T[Gt*3+2])}function ua(Gt){g.push(Gt.x),g.push(Gt.y)}}}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}toJSON(){const s=super.toJSON(),l=this.parameters.shapes,h=this.parameters.options;return Bf(l,h,s)}static fromJSON(s,l){const h=[];for(let g=0,_=s.shapes.length;g<_;g++){const b=l[s.shapes[g]];h.push(b)}const f=s.options.extrudePath;return f!==void 0&&(s.options.extrudePath=new lm[f.type]().fromJSON(f)),new mm(h,s.options)}}const ax={generateTopUV:function(E,s,l,h,f){const g=s[l*3],_=s[l*3+1],b=s[h*3],T=s[h*3+1],A=s[f*3],R=s[f*3+1];return[new St(g,_),new St(b,T),new St(A,R)]},generateSideWallUV:function(E,s,l,h,f,g){const _=s[l*3],b=s[l*3+1],T=s[l*3+2],A=s[h*3],R=s[h*3+1],P=s[h*3+2],L=s[f*3],D=s[f*3+1],O=s[f*3+2],W=s[g*3],Z=s[g*3+1],Y=s[g*3+2];return Math.abs(b-R)<Math.abs(_-A)?[new St(_,1-T),new St(A,1-P),new St(L,1-O),new St(W,1-Y)]:[new St(b,1-T),new St(R,1-P),new St(D,1-O),new St(Z,1-Y)]}};function Bf(E,s,l){if(l.shapes=[],Array.isArray(E))for(let h=0,f=E.length;h<f;h++){const g=E[h];l.shapes.push(g.uuid)}else l.shapes.push(E.uuid);return l.options=Object.assign({},s),s.extrudePath!==void 0&&(l.options.extrudePath=s.extrudePath.toJSON()),l}class Of extends gd{constructor(s=1,l=0){const h=(1+Math.sqrt(5))/2,f=[-1,h,0,1,h,0,-1,-h,0,1,-h,0,0,-1,h,0,1,h,0,-1,-h,0,1,-h,h,0,-1,h,0,1,-h,0,-1,-h,0,1],g=[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(f,g,s,l),this.type="IcosahedronGeometry",this.parameters={radius:s,detail:l}}static fromJSON(s){return new Of(s.radius,s.detail)}}class S0 extends ht{constructor(s=[new St(0,-.5),new St(.5,0),new St(0,.5)],l=12,h=0,f=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:s,segments:l,phiStart:h,phiLength:f},l=Math.floor(l),f=Ut(f,0,Math.PI*2);const g=[],_=[],b=[],T=[],A=[],R=1/l,P=new ae,L=new St,D=new ae,O=new ae,W=new ae;let Z=0,Y=0;for(let ie=0;ie<=s.length-1;ie++)switch(ie){case 0:Z=s[ie+1].x-s[ie].x,Y=s[ie+1].y-s[ie].y,D.x=Y*1,D.y=-Z,D.z=Y*0,W.copy(D),D.normalize(),T.push(D.x,D.y,D.z);break;case s.length-1:T.push(W.x,W.y,W.z);break;default:Z=s[ie+1].x-s[ie].x,Y=s[ie+1].y-s[ie].y,D.x=Y*1,D.y=-Z,D.z=Y*0,O.copy(D),D.x+=W.x,D.y+=W.y,D.z+=W.z,D.normalize(),T.push(D.x,D.y,D.z),W.copy(O)}for(let ie=0;ie<=l;ie++){const se=h+ie*R*f,de=Math.sin(se),ke=Math.cos(se);for(let $e=0;$e<=s.length-1;$e++){P.x=s[$e].x*de,P.y=s[$e].y,P.z=s[$e].x*ke,_.push(P.x,P.y,P.z),L.x=ie/l,L.y=$e/(s.length-1),b.push(L.x,L.y);const et=T[3*$e+0]*de,qe=T[3*$e+1],xt=T[3*$e+0]*ke;A.push(et,qe,xt)}}for(let ie=0;ie<l;ie++)for(let se=0;se<s.length-1;se++){const de=se+ie*s.length,ke=de,$e=de+s.length,et=de+s.length+1,qe=de+1;g.push(ke,$e,qe),g.push(et,qe,$e)}this.setIndex(g),this.setAttribute("position",new cn(_,3)),this.setAttribute("uv",new cn(b,2)),this.setAttribute("normal",new cn(A,3))}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}static fromJSON(s){return new S0(s.points,s.segments,s.phiStart,s.phiLength)}}class gm extends gd{constructor(s=1,l=0){const h=[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],f=[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(h,f,s,l),this.type="OctahedronGeometry",this.parameters={radius:s,detail:l}}static fromJSON(s){return new gm(s.radius,s.detail)}}class Fo extends ht{constructor(s=1,l=1,h=1,f=1){super(),this.type="PlaneGeometry",this.parameters={width:s,height:l,widthSegments:h,heightSegments:f};const g=s/2,_=l/2,b=Math.floor(h),T=Math.floor(f),A=b+1,R=T+1,P=s/b,L=l/T,D=[],O=[],W=[],Z=[];for(let Y=0;Y<R;Y++){const ie=Y*L-_;for(let se=0;se<A;se++){const de=se*P-g;O.push(de,-ie,0),W.push(0,0,1),Z.push(se/b),Z.push(1-Y/T)}}for(let Y=0;Y<T;Y++)for(let ie=0;ie<b;ie++){const se=ie+A*Y,de=ie+A*(Y+1),ke=ie+1+A*(Y+1),$e=ie+1+A*Y;D.push(se,de,$e),D.push(de,ke,$e)}this.setIndex(D),this.setAttribute("position",new cn(O,3)),this.setAttribute("normal",new cn(W,3)),this.setAttribute("uv",new cn(Z,2))}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}static fromJSON(s){return new Fo(s.width,s.height,s.widthSegments,s.heightSegments)}}class ym extends ht{constructor(s=.5,l=1,h=32,f=1,g=0,_=Math.PI*2){super(),this.type="RingGeometry",this.parameters={innerRadius:s,outerRadius:l,thetaSegments:h,phiSegments:f,thetaStart:g,thetaLength:_},h=Math.max(3,h),f=Math.max(1,f);const b=[],T=[],A=[],R=[];let P=s;const L=(l-s)/f,D=new ae,O=new St;for(let W=0;W<=f;W++){for(let Z=0;Z<=h;Z++){const Y=g+Z/h*_;D.x=P*Math.cos(Y),D.y=P*Math.sin(Y),T.push(D.x,D.y,D.z),A.push(0,0,1),O.x=(D.x/l+1)/2,O.y=(D.y/l+1)/2,R.push(O.x,O.y)}P+=L}for(let W=0;W<f;W++){const Z=W*(h+1);for(let Y=0;Y<h;Y++){const ie=Y+Z,se=ie,de=ie+h+1,ke=ie+h+2,$e=ie+1;b.push(se,de,$e),b.push(de,ke,$e)}}this.setIndex(b),this.setAttribute("position",new cn(T,3)),this.setAttribute("normal",new cn(A,3)),this.setAttribute("uv",new cn(R,2))}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}static fromJSON(s){return new ym(s.innerRadius,s.outerRadius,s.thetaSegments,s.phiSegments,s.thetaStart,s.thetaLength)}}class _m extends ht{constructor(s=new Bu([new St(0,.5),new St(-.5,-.5),new St(.5,-.5)]),l=12){super(),this.type="ShapeGeometry",this.parameters={shapes:s,curveSegments:l};const h=[],f=[],g=[],_=[];let b=0,T=0;if(Array.isArray(s)===!1)A(s);else for(let R=0;R<s.length;R++)A(s[R]),this.addGroup(b,T,R),b+=T,T=0;this.setIndex(h),this.setAttribute("position",new cn(f,3)),this.setAttribute("normal",new cn(g,3)),this.setAttribute("uv",new cn(_,2));function A(R){const P=f.length/3,L=R.extractPoints(l);let D=L.shape;const O=L.holes;Ga.isClockWise(D)===!1&&(D=D.reverse());for(let Z=0,Y=O.length;Z<Y;Z++){const ie=O[Z];Ga.isClockWise(ie)===!0&&(O[Z]=ie.reverse())}const W=Ga.triangulateShape(D,O);for(let Z=0,Y=O.length;Z<Y;Z++){const ie=O[Z];D=D.concat(ie)}for(let Z=0,Y=D.length;Z<Y;Z++){const ie=D[Z];f.push(ie.x,ie.y,0),g.push(0,0,1),_.push(ie.x,ie.y)}for(let Z=0,Y=W.length;Z<Y;Z++){const ie=W[Z],se=ie[0]+P,de=ie[1]+P,ke=ie[2]+P;h.push(se,de,ke),T+=3}}}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}toJSON(){const s=super.toJSON(),l=this.parameters.shapes;return M0(l,s)}static fromJSON(s,l){const h=[];for(let f=0,g=s.shapes.length;f<g;f++){const _=l[s.shapes[f]];h.push(_)}return new _m(h,s.curveSegments)}}function M0(E,s){if(s.shapes=[],Array.isArray(E))for(let l=0,h=E.length;l<h;l++){const f=E[l];s.shapes.push(f.uuid)}else s.shapes.push(E.uuid);return s}class Uf extends ht{constructor(s=1,l=32,h=16,f=0,g=Math.PI*2,_=0,b=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:s,widthSegments:l,heightSegments:h,phiStart:f,phiLength:g,thetaStart:_,thetaLength:b},l=Math.max(3,Math.floor(l)),h=Math.max(2,Math.floor(h));const T=Math.min(_+b,Math.PI);let A=0;const R=[],P=new ae,L=new ae,D=[],O=[],W=[],Z=[];for(let Y=0;Y<=h;Y++){const ie=[],se=Y/h;let de=0;Y===0&&_===0?de=.5/l:Y===h&&T===Math.PI&&(de=-.5/l);for(let ke=0;ke<=l;ke++){const $e=ke/l;P.x=-s*Math.cos(f+$e*g)*Math.sin(_+se*b),P.y=s*Math.cos(_+se*b),P.z=s*Math.sin(f+$e*g)*Math.sin(_+se*b),O.push(P.x,P.y,P.z),L.copy(P).normalize(),W.push(L.x,L.y,L.z),Z.push($e+de,1-se),ie.push(A++)}R.push(ie)}for(let Y=0;Y<h;Y++)for(let ie=0;ie<l;ie++){const se=R[Y][ie+1],de=R[Y][ie],ke=R[Y+1][ie],$e=R[Y+1][ie+1];(Y!==0||_>0)&&D.push(se,de,$e),(Y!==h-1||T<Math.PI)&&D.push(de,ke,$e)}this.setIndex(D),this.setAttribute("position",new cn(O,3)),this.setAttribute("normal",new cn(W,3)),this.setAttribute("uv",new cn(Z,2))}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}static fromJSON(s){return new Uf(s.radius,s.widthSegments,s.heightSegments,s.phiStart,s.phiLength,s.thetaStart,s.thetaLength)}}class T0 extends gd{constructor(s=1,l=0){const h=[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],f=[2,1,0,0,3,2,1,3,0,2,3,1];super(h,f,s,l),this.type="TetrahedronGeometry",this.parameters={radius:s,detail:l}}static fromJSON(s){return new T0(s.radius,s.detail)}}class kf extends ht{constructor(s=1,l=.4,h=12,f=48,g=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:s,tube:l,radialSegments:h,tubularSegments:f,arc:g},h=Math.floor(h),f=Math.floor(f);const _=[],b=[],T=[],A=[],R=new ae,P=new ae,L=new ae;for(let D=0;D<=h;D++)for(let O=0;O<=f;O++){const W=O/f*g,Z=D/h*Math.PI*2;P.x=(s+l*Math.cos(Z))*Math.cos(W),P.y=(s+l*Math.cos(Z))*Math.sin(W),P.z=l*Math.sin(Z),b.push(P.x,P.y,P.z),R.x=s*Math.cos(W),R.y=s*Math.sin(W),L.subVectors(P,R).normalize(),T.push(L.x,L.y,L.z),A.push(O/f),A.push(D/h)}for(let D=1;D<=h;D++)for(let O=1;O<=f;O++){const W=(f+1)*D+O-1,Z=(f+1)*(D-1)+O-1,Y=(f+1)*(D-1)+O,ie=(f+1)*D+O;_.push(W,Z,ie),_.push(Z,Y,ie)}this.setIndex(_),this.setAttribute("position",new cn(b,3)),this.setAttribute("normal",new cn(T,3)),this.setAttribute("uv",new cn(A,2))}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}static fromJSON(s){return new kf(s.radius,s.tube,s.radialSegments,s.tubularSegments,s.arc)}}class zf extends ht{constructor(s=1,l=.4,h=64,f=8,g=2,_=3){super(),this.type="TorusKnotGeometry",this.parameters={radius:s,tube:l,tubularSegments:h,radialSegments:f,p:g,q:_},h=Math.floor(h),f=Math.floor(f);const b=[],T=[],A=[],R=[],P=new ae,L=new ae,D=new ae,O=new ae,W=new ae,Z=new ae,Y=new ae;for(let se=0;se<=h;++se){const de=se/h*g*Math.PI*2;ie(de,g,_,s,D),ie(de+.01,g,_,s,O),Z.subVectors(O,D),Y.addVectors(O,D),W.crossVectors(Z,Y),Y.crossVectors(W,Z),W.normalize(),Y.normalize();for(let ke=0;ke<=f;++ke){const $e=ke/f*Math.PI*2,et=-l*Math.cos($e),qe=l*Math.sin($e);P.x=D.x+(et*Y.x+qe*W.x),P.y=D.y+(et*Y.y+qe*W.y),P.z=D.z+(et*Y.z+qe*W.z),T.push(P.x,P.y,P.z),L.subVectors(P,D).normalize(),A.push(L.x,L.y,L.z),R.push(se/h),R.push(ke/f)}}for(let se=1;se<=h;se++)for(let de=1;de<=f;de++){const ke=(f+1)*(se-1)+(de-1),$e=(f+1)*se+(de-1),et=(f+1)*se+de,qe=(f+1)*(se-1)+de;b.push(ke,$e,qe),b.push($e,et,qe)}this.setIndex(b),this.setAttribute("position",new cn(T,3)),this.setAttribute("normal",new cn(A,3)),this.setAttribute("uv",new cn(R,2));function ie(se,de,ke,$e,et){const qe=Math.cos(se),xt=Math.sin(se),Et=ke/de*se,_n=Math.cos(Et);et.x=$e*(2+_n)*.5*qe,et.y=$e*(2+_n)*xt*.5,et.z=$e*Math.sin(Et)*.5}}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}static fromJSON(s){return new zf(s.radius,s.tube,s.tubularSegments,s.radialSegments,s.p,s.q)}}class Ad extends ht{constructor(s=new K_(new ae(-1,-1,0),new ae(-1,1,0),new ae(1,1,0)),l=64,h=1,f=8,g=!1){super(),this.type="TubeGeometry",this.parameters={path:s,tubularSegments:l,radius:h,radialSegments:f,closed:g};const _=s.computeFrenetFrames(l,g);this.tangents=_.tangents,this.normals=_.normals,this.binormals=_.binormals;const b=new ae,T=new ae,A=new St;let R=new ae;const P=[],L=[],D=[],O=[];W(),this.setIndex(O),this.setAttribute("position",new cn(P,3)),this.setAttribute("normal",new cn(L,3)),this.setAttribute("uv",new cn(D,2));function W(){for(let se=0;se<l;se++)Z(se);Z(g===!1?l:0),ie(),Y()}function Z(se){R=s.getPointAt(se/l,R);const de=_.normals[se],ke=_.binormals[se];for(let $e=0;$e<=f;$e++){const et=$e/f*Math.PI*2,qe=Math.sin(et),xt=-Math.cos(et);T.x=xt*de.x+qe*ke.x,T.y=xt*de.y+qe*ke.y,T.z=xt*de.z+qe*ke.z,T.normalize(),L.push(T.x,T.y,T.z),b.x=R.x+h*T.x,b.y=R.y+h*T.y,b.z=R.z+h*T.z,P.push(b.x,b.y,b.z)}}function Y(){for(let se=1;se<=l;se++)for(let de=1;de<=f;de++){const ke=(f+1)*(se-1)+(de-1),$e=(f+1)*se+(de-1),et=(f+1)*se+de,qe=(f+1)*(se-1)+de;O.push(ke,$e,qe),O.push($e,et,qe)}}function ie(){for(let se=0;se<=l;se++)for(let de=0;de<=f;de++)A.x=se/l,A.y=de/f,D.push(A.x,A.y)}}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}toJSON(){const s=super.toJSON();return s.path=this.parameters.path.toJSON(),s}static fromJSON(s){return new Ad(new lm[s.path.type]().fromJSON(s.path),s.tubularSegments,s.radius,s.radialSegments,s.closed)}}class Ed extends ht{constructor(s=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:s},s!==null){const l=[],h=new Set,f=new ae,g=new ae;if(s.index!==null){const _=s.attributes.position,b=s.index;let T=s.groups;T.length===0&&(T=[{start:0,count:b.count,materialIndex:0}]);for(let A=0,R=T.length;A<R;++A){const P=T[A],L=P.start,D=P.count;for(let O=L,W=L+D;O<W;O+=3)for(let Z=0;Z<3;Z++){const Y=b.getX(O+Z),ie=b.getX(O+(Z+1)%3);f.fromBufferAttribute(_,Y),g.fromBufferAttribute(_,ie),xm(f,g,h)===!0&&(l.push(f.x,f.y,f.z),l.push(g.x,g.y,g.z))}}}else{const _=s.attributes.position;for(let b=0,T=_.count/3;b<T;b++)for(let A=0;A<3;A++){const R=3*b+A,P=3*b+(A+1)%3;f.fromBufferAttribute(_,R),g.fromBufferAttribute(_,P),xm(f,g,h)===!0&&(l.push(f.x,f.y,f.z),l.push(g.x,g.y,g.z))}}this.setAttribute("position",new cn(l,3))}}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}}function xm(E,s,l){const h=`${E.x},${E.y},${E.z}-${s.x},${s.y},${s.z}`,f=`${s.x},${s.y},${s.z}-${E.x},${E.y},${E.z}`;return l.has(h)===!0||l.has(f)===!0?!1:(l.add(h),l.add(f),!0)}var vm=Object.freeze({__proto__:null,BoxGeometry:yu,CapsuleGeometry:q_,CircleGeometry:Ef,ConeGeometry:f0,CylinderGeometry:om,DodecahedronGeometry:X_,EdgesGeometry:p0,ExtrudeGeometry:mm,IcosahedronGeometry:Of,LatheGeometry:S0,OctahedronGeometry:gm,PlaneGeometry:Fo,PolyhedronGeometry:gd,RingGeometry:ym,ShapeGeometry:_m,SphereGeometry:Uf,TetrahedronGeometry:T0,TorusGeometry:kf,TorusKnotGeometry:zf,TubeGeometry:Ad,WireframeGeometry:Ed});class AS extends null{constructor(s){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Zn(0),this.transparent=!0,this.fog=!0,this.setValues(s)}copy(s){return super.copy(s),this.color.copy(s.color),this.fog=s.fog,this}}class ku extends null{constructor(s){super(s),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class w0 extends null{constructor(s){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Zn(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 Zn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=qh,this.normalScale=new St(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 Is,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(s)}copy(s){return super.copy(s),this.defines={STANDARD:""},this.color.copy(s.color),this.roughness=s.roughness,this.metalness=s.metalness,this.map=s.map,this.lightMap=s.lightMap,this.lightMapIntensity=s.lightMapIntensity,this.aoMap=s.aoMap,this.aoMapIntensity=s.aoMapIntensity,this.emissive.copy(s.emissive),this.emissiveMap=s.emissiveMap,this.emissiveIntensity=s.emissiveIntensity,this.bumpMap=s.bumpMap,this.bumpScale=s.bumpScale,this.normalMap=s.normalMap,this.normalMapType=s.normalMapType,this.normalScale.copy(s.normalScale),this.displacementMap=s.displacementMap,this.displacementScale=s.displacementScale,this.displacementBias=s.displacementBias,this.roughnessMap=s.roughnessMap,this.metalnessMap=s.metalnessMap,this.alphaMap=s.alphaMap,this.envMap=s.envMap,this.envMapRotation.copy(s.envMapRotation),this.envMapIntensity=s.envMapIntensity,this.wireframe=s.wireframe,this.wireframeLinewidth=s.wireframeLinewidth,this.wireframeLinecap=s.wireframeLinecap,this.wireframeLinejoin=s.wireframeLinejoin,this.flatShading=s.flatShading,this.fog=s.fog,this}}class A0 extends null{constructor(s){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 St(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Ut(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(l){this.ior=(1+.4*l)/(1-.4*l)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new Zn(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 Zn(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Zn(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(s)}get anisotropy(){return this._anisotropy}set anisotropy(s){this._anisotropy>0!=s>0&&this.version++,this._anisotropy=s}get clearcoat(){return this._clearcoat}set clearcoat(s){this._clearcoat>0!=s>0&&this.version++,this._clearcoat=s}get iridescence(){return this._iridescence}set iridescence(s){this._iridescence>0!=s>0&&this.version++,this._iridescence=s}get dispersion(){return this._dispersion}set dispersion(s){this._dispersion>0!=s>0&&this.version++,this._dispersion=s}get sheen(){return this._sheen}set sheen(s){this._sheen>0!=s>0&&this.version++,this._sheen=s}get transmission(){return this._transmission}set transmission(s){this._transmission>0!=s>0&&this.version++,this._transmission=s}copy(s){return super.copy(s),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=s.anisotropy,this.anisotropyRotation=s.anisotropyRotation,this.anisotropyMap=s.anisotropyMap,this.clearcoat=s.clearcoat,this.clearcoatMap=s.clearcoatMap,this.clearcoatRoughness=s.clearcoatRoughness,this.clearcoatRoughnessMap=s.clearcoatRoughnessMap,this.clearcoatNormalMap=s.clearcoatNormalMap,this.clearcoatNormalScale.copy(s.clearcoatNormalScale),this.dispersion=s.dispersion,this.ior=s.ior,this.iridescence=s.iridescence,this.iridescenceMap=s.iridescenceMap,this.iridescenceIOR=s.iridescenceIOR,this.iridescenceThicknessRange=[...s.iridescenceThicknessRange],this.iridescenceThicknessMap=s.iridescenceThicknessMap,this.sheen=s.sheen,this.sheenColor.copy(s.sheenColor),this.sheenColorMap=s.sheenColorMap,this.sheenRoughness=s.sheenRoughness,this.sheenRoughnessMap=s.sheenRoughnessMap,this.transmission=s.transmission,this.transmissionMap=s.transmissionMap,this.thickness=s.thickness,this.thicknessMap=s.thicknessMap,this.attenuationDistance=s.attenuationDistance,this.attenuationColor.copy(s.attenuationColor),this.specularIntensity=s.specularIntensity,this.specularIntensityMap=s.specularIntensityMap,this.specularColor.copy(s.specularColor),this.specularColorMap=s.specularColorMap,this}}class bm extends Sr{constructor(s){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Zn(16777215),this.specular=new Zn(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Zn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=qh,this.normalScale=new St(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Is,this.combine=Xc,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(s)}copy(s){return super.copy(s),this.color.copy(s.color),this.specular.copy(s.specular),this.shininess=s.shininess,this.map=s.map,this.lightMap=s.lightMap,this.lightMapIntensity=s.lightMapIntensity,this.aoMap=s.aoMap,this.aoMapIntensity=s.aoMapIntensity,this.emissive.copy(s.emissive),this.emissiveMap=s.emissiveMap,this.emissiveIntensity=s.emissiveIntensity,this.bumpMap=s.bumpMap,this.bumpScale=s.bumpScale,this.normalMap=s.normalMap,this.normalMapType=s.normalMapType,this.normalScale.copy(s.normalScale),this.displacementMap=s.displacementMap,this.displacementScale=s.displacementScale,this.displacementBias=s.displacementBias,this.specularMap=s.specularMap,this.alphaMap=s.alphaMap,this.envMap=s.envMap,this.envMapRotation.copy(s.envMapRotation),this.combine=s.combine,this.reflectivity=s.reflectivity,this.refractionRatio=s.refractionRatio,this.wireframe=s.wireframe,this.wireframeLinewidth=s.wireframeLinewidth,this.wireframeLinecap=s.wireframeLinecap,this.wireframeLinejoin=s.wireframeLinejoin,this.flatShading=s.flatShading,this.fog=s.fog,this}}class Sm extends null{constructor(s){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Zn(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Zn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=qh,this.normalScale=new St(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(s)}copy(s){return super.copy(s),this.color.copy(s.color),this.map=s.map,this.gradientMap=s.gradientMap,this.lightMap=s.lightMap,this.lightMapIntensity=s.lightMapIntensity,this.aoMap=s.aoMap,this.aoMapIntensity=s.aoMapIntensity,this.emissive.copy(s.emissive),this.emissiveMap=s.emissiveMap,this.emissiveIntensity=s.emissiveIntensity,this.bumpMap=s.bumpMap,this.bumpScale=s.bumpScale,this.normalMap=s.normalMap,this.normalMapType=s.normalMapType,this.normalScale.copy(s.normalScale),this.displacementMap=s.displacementMap,this.displacementScale=s.displacementScale,this.displacementBias=s.displacementBias,this.alphaMap=s.alphaMap,this.wireframe=s.wireframe,this.wireframeLinewidth=s.wireframeLinewidth,this.wireframeLinecap=s.wireframeLinecap,this.wireframeLinejoin=s.wireframeLinejoin,this.fog=s.fog,this}}class ES extends null{constructor(s){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=qh,this.normalScale=new St(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.flatShading=!1,this.setValues(s)}copy(s){return super.copy(s),this.bumpMap=s.bumpMap,this.bumpScale=s.bumpScale,this.normalMap=s.normalMap,this.normalMapType=s.normalMapType,this.normalScale.copy(s.normalScale),this.displacementMap=s.displacementMap,this.displacementScale=s.displacementScale,this.displacementBias=s.displacementBias,this.wireframe=s.wireframe,this.wireframeLinewidth=s.wireframeLinewidth,this.flatShading=s.flatShading,this}}class lx extends null{constructor(s){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Zn(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Zn(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=qh,this.normalScale=new St(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Is,this.combine=Xc,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(s)}copy(s){return super.copy(s),this.color.copy(s.color),this.map=s.map,this.lightMap=s.lightMap,this.lightMapIntensity=s.lightMapIntensity,this.aoMap=s.aoMap,this.aoMapIntensity=s.aoMapIntensity,this.emissive.copy(s.emissive),this.emissiveMap=s.emissiveMap,this.emissiveIntensity=s.emissiveIntensity,this.bumpMap=s.bumpMap,this.bumpScale=s.bumpScale,this.normalMap=s.normalMap,this.normalMapType=s.normalMapType,this.normalScale.copy(s.normalScale),this.displacementMap=s.displacementMap,this.displacementScale=s.displacementScale,this.displacementBias=s.displacementBias,this.specularMap=s.specularMap,this.alphaMap=s.alphaMap,this.envMap=s.envMap,this.envMapRotation.copy(s.envMapRotation),this.combine=s.combine,this.reflectivity=s.reflectivity,this.refractionRatio=s.refractionRatio,this.wireframe=s.wireframe,this.wireframeLinewidth=s.wireframeLinewidth,this.wireframeLinecap=s.wireframeLinecap,this.wireframeLinejoin=s.wireframeLinejoin,this.flatShading=s.flatShading,this.fog=s.fog,this}}class cx extends null{constructor(s){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=f_,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(s)}copy(s){return super.copy(s),this.depthPacking=s.depthPacking,this.map=s.map,this.alphaMap=s.alphaMap,this.displacementMap=s.displacementMap,this.displacementScale=s.displacementScale,this.displacementBias=s.displacementBias,this.wireframe=s.wireframe,this.wireframeLinewidth=s.wireframeLinewidth,this}}class ux extends null{constructor(s){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(s)}copy(s){return super.copy(s),this.map=s.map,this.alphaMap=s.alphaMap,this.displacementMap=s.displacementMap,this.displacementScale=s.displacementScale,this.displacementBias=s.displacementBias,this}}class hx extends null{constructor(s){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Zn(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=qh,this.normalScale=new St(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(s)}copy(s){return super.copy(s),this.defines={MATCAP:""},this.color.copy(s.color),this.matcap=s.matcap,this.map=s.map,this.bumpMap=s.bumpMap,this.bumpScale=s.bumpScale,this.normalMap=s.normalMap,this.normalMapType=s.normalMapType,this.normalScale.copy(s.normalScale),this.displacementMap=s.displacementMap,this.displacementScale=s.displacementScale,this.displacementBias=s.displacementBias,this.alphaMap=s.alphaMap,this.wireframe=s.wireframe,this.wireframeLinewidth=s.wireframeLinewidth,this.flatShading=s.flatShading,this.fog=s.fog,this}}class E0 extends null{constructor(s){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(s)}copy(s){return super.copy(s),this.scale=s.scale,this.dashSize=s.dashSize,this.gapSize=s.gapSize,this}}function fc(E,s){return!E||E.constructor===s?E:typeof s.BYTES_PER_ELEMENT=="number"?new s(E):Array.prototype.slice.call(E)}function C0(E){return ArrayBuffer.isView(E)&&!(E instanceof DataView)}function R0(E){function s(f,g){return E[f]-E[g]}const l=E.length,h=new Array(l);for(let f=0;f!==l;++f)h[f]=f;return h.sort(s),h}function Mm(E,s,l){const h=E.length,f=new E.constructor(h);for(let g=0,_=0;_!==h;++g){const b=l[g]*s;for(let T=0;T!==s;++T)f[_++]=E[b+T]}return f}function Vf(E,s,l,h){let f=1,g=E[0];for(;g!==void 0&&g[h]===void 0;)g=E[f++];if(g===void 0)return;let _=g[h];if(_!==void 0)if(Array.isArray(_))do _=g[h],_!==void 0&&(s.push(g.time),l.push(..._)),g=E[f++];while(g!==void 0);else if(_.toArray!==void 0)do _=g[h],_!==void 0&&(s.push(g.time),_.toArray(l,l.length)),g=E[f++];while(g!==void 0);else do _=g[h],_!==void 0&&(s.push(g.time),l.push(_)),g=E[f++];while(g!==void 0)}function dx(E,s,l,h,f=30){const g=E.clone();g.name=s;const _=[];for(let T=0;T<g.tracks.length;++T){const A=g.tracks[T],R=A.getValueSize(),P=[],L=[];for(let D=0;D<A.times.length;++D){const O=A.times[D]*f;if(!(O<l||O>=h)){P.push(A.times[D]);for(let W=0;W<R;++W)L.push(A.values[D*R+W])}}P.length!==0&&(A.times=fc(P,A.times.constructor),A.values=fc(L,A.values.constructor),_.push(A))}g.tracks=_;let b=1/0;for(let T=0;T<g.tracks.length;++T)b>g.tracks[T].times[0]&&(b=g.tracks[T].times[0]);for(let T=0;T<g.tracks.length;++T)g.tracks[T].shift(-1*b);return g.resetDuration(),g}function fx(E,s=0,l=E,h=30){h<=0&&(h=30);const f=l.tracks.length,g=s/h;for(let _=0;_<f;++_){const b=l.tracks[_],T=b.ValueTypeName;if(T==="bool"||T==="string")continue;const A=E.tracks.find(function(Y){return Y.name===b.name&&Y.ValueTypeName===T});if(A===void 0)continue;let R=0;const P=b.getValueSize();b.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(R=P/3);let L=0;const D=A.getValueSize();A.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(L=D/3);const O=b.times.length-1;let W;if(g<=b.times[0]){const Y=R,ie=P-R;W=b.values.slice(Y,ie)}else if(g>=b.times[O]){const Y=O*P+R,ie=Y+P-R;W=b.values.slice(Y,ie)}else{const Y=b.createInterpolant(),ie=R,se=P-R;Y.evaluate(g),W=Y.resultBuffer.slice(ie,se)}T==="quaternion"&&new ro().fromArray(W).normalize().conjugate().toArray(W);const Z=A.times.length;for(let Y=0;Y<Z;++Y){const ie=Y*D+L;if(T==="quaternion")ro.multiplyQuaternionsFlat(A.values,ie,W,0,A.values,ie);else{const se=D-L*2;for(let de=0;de<se;++de)A.values[ie+de]-=W[de]}}}return E.blendMode=nu,E}class CS{static convertArray(s,l){return fc(s,l)}static isTypedArray(s){return C0(s)}static getKeyframeOrder(s){return R0(s)}static sortedArray(s,l,h){return Mm(s,l,h)}static flattenJSON(s,l,h,f){Vf(s,l,h,f)}static subclip(s,l,h,f,g=30){return dx(s,l,h,f,g)}static makeClipAdditive(s,l=0,h=s,f=30){return fx(s,l,h,f)}}class Cd{constructor(s,l,h,f){this.parameterPositions=s,this._cachedIndex=0,this.resultBuffer=f!==void 0?f:new l.constructor(h),this.sampleValues=l,this.valueSize=h,this.settings=null,this.DefaultSettings_={}}evaluate(s){const l=this.parameterPositions;let h=this._cachedIndex,f=l[h],g=l[h-1];e:{t:{let _;n:{i:if(!(s<f)){for(let b=h+2;;){if(f===void 0){if(s<g)break i;return h=l.length,this._cachedIndex=h,this.copySampleValue_(h-1)}if(h===b)break;if(g=f,f=l[++h],s<f)break t}_=l.length;break n}if(!(s>=g)){const b=l[1];s<b&&(h=2,g=b);for(let T=h-2;;){if(g===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(h===T)break;if(f=g,g=l[--h-1],s>=g)break t}_=h,h=0;break n}break e}for(;h<_;){const b=h+_>>>1;s<l[b]?_=b:h=b+1}if(f=l[h],g=l[h-1],g===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(f===void 0)return h=l.length,this._cachedIndex=h,this.copySampleValue_(h-1)}this._cachedIndex=h,this.intervalChanged_(h,g,f)}return this.interpolate_(h,g,s,f)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(s){const l=this.resultBuffer,h=this.sampleValues,f=this.valueSize,g=s*f;for(let _=0;_!==f;++_)l[_]=h[g+_];return l}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class zu extends Cd{constructor(s,l,h,f){super(s,l,h,f),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Hh,endingEnd:Hh}}intervalChanged_(s,l,h){const f=this.parameterPositions;let g=s-2,_=s+1,b=f[g],T=f[_];if(b===void 0)switch(this.getSettings_().endingStart){case sl:g=s,b=2*l-h;break;case $h:g=f.length-2,b=l+f[g]-f[g+1];break;default:g=s,b=h}if(T===void 0)switch(this.getSettings_().endingEnd){case sl:_=s,T=2*h-l;break;case $h:_=1,T=h+f[1]-f[0];break;default:_=s-1,T=l}const A=(h-l)*.5,R=this.valueSize;this._weightPrev=A/(l-b),this._weightNext=A/(T-h),this._offsetPrev=g*R,this._offsetNext=_*R}interpolate_(s,l,h,f){const g=this.resultBuffer,_=this.sampleValues,b=this.valueSize,T=s*b,A=T-b,R=this._offsetPrev,P=this._offsetNext,L=this._weightPrev,D=this._weightNext,O=(h-l)/(f-l),W=O*O,Z=W*O,Y=-L*Z+2*L*W-L*O,ie=(1+L)*Z+(-1.5-2*L)*W+(-.5+L)*O+1,se=(-1-D)*Z+(1.5+D)*W+.5*O,de=D*Z-D*W;for(let ke=0;ke!==b;++ke)g[ke]=Y*_[R+ke]+ie*_[A+ke]+se*_[T+ke]+de*_[P+ke];return g}}class N0 extends Cd{constructor(s,l,h,f){super(s,l,h,f)}interpolate_(s,l,h,f){const g=this.resultBuffer,_=this.sampleValues,b=this.valueSize,T=s*b,A=T-b,R=(h-l)/(f-l),P=1-R;for(let L=0;L!==b;++L)g[L]=_[A+L]*P+_[T+L]*R;return g}}class P0 extends Cd{constructor(s,l,h,f){super(s,l,h,f)}interpolate_(s){return this.copySampleValue_(s-1)}}class fo{constructor(s,l,h,f){if(s===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(l===void 0||l.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+s);this.name=s,this.times=fc(l,this.TimeBufferType),this.values=fc(h,this.ValueBufferType),this.setInterpolation(f||this.DefaultInterpolation)}static toJSON(s){const l=s.constructor;let h;if(l.toJSON!==this.toJSON)h=l.toJSON(s);else{h={name:s.name,times:fc(s.times,Array),values:fc(s.values,Array)};const f=s.getInterpolation();f!==s.DefaultInterpolation&&(h.interpolation=f)}return h.type=s.ValueTypeName,h}InterpolantFactoryMethodDiscrete(s){return new P0(this.times,this.values,this.getValueSize(),s)}InterpolantFactoryMethodLinear(s){return new N0(this.times,this.values,this.getValueSize(),s)}InterpolantFactoryMethodSmooth(s){return new zu(this.times,this.values,this.getValueSize(),s)}setInterpolation(s){let l;switch(s){case il:l=this.InterpolantFactoryMethodDiscrete;break;case Ig:l=this.InterpolantFactoryMethodLinear;break;case Lg:l=this.InterpolantFactoryMethodSmooth;break}if(l===void 0){const h="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(s!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(h);return Mn("KeyframeTrack:",h),this}return this.createInterpolant=l,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return il;case this.InterpolantFactoryMethodLinear:return Ig;case this.InterpolantFactoryMethodSmooth:return Lg}}getValueSize(){return this.values.length/this.times.length}shift(s){if(s!==0){const l=this.times;for(let h=0,f=l.length;h!==f;++h)l[h]+=s}return this}scale(s){if(s!==1){const l=this.times;for(let h=0,f=l.length;h!==f;++h)l[h]*=s}return this}trim(s,l){const h=this.times,f=h.length;let g=0,_=f-1;for(;g!==f&&h[g]<s;)++g;for(;_!==-1&&h[_]>l;)--_;if(++_,g!==0||_!==f){g>=_&&(_=Math.max(_,1),g=_-1);const b=this.getValueSize();this.times=h.slice(g,_),this.values=this.values.slice(g*b,_*b)}return this}validate(){let s=!0;const l=this.getValueSize();l-Math.floor(l)!==0&&(ci("KeyframeTrack: Invalid value size in track.",this),s=!1);const h=this.times,f=this.values,g=h.length;g===0&&(ci("KeyframeTrack: Track is empty.",this),s=!1);let _=null;for(let b=0;b!==g;b++){const T=h[b];if(typeof T=="number"&&isNaN(T)){ci("KeyframeTrack: Time is not a valid number.",this,b,T),s=!1;break}if(_!==null&&_>T){ci("KeyframeTrack: Out of order keys.",this,b,T,_),s=!1;break}_=T}if(f!==void 0&&C0(f))for(let b=0,T=f.length;b!==T;++b){const A=f[b];if(isNaN(A)){ci("KeyframeTrack: Value is not a valid number.",this,b,A),s=!1;break}}return s}optimize(){const s=this.times.slice(),l=this.values.slice(),h=this.getValueSize(),f=this.getInterpolation()===Lg,g=s.length-1;let _=1;for(let b=1;b<g;++b){let T=!1;const A=s[b],R=s[b+1];if(A!==R&&(b!==1||A!==s[0]))if(f)T=!0;else{const P=b*h,L=P-h,D=P+h;for(let O=0;O!==h;++O){const W=l[P+O];if(W!==l[L+O]||W!==l[D+O]){T=!0;break}}}if(T){if(b!==_){s[_]=s[b];const P=b*h,L=_*h;for(let D=0;D!==h;++D)l[L+D]=l[P+D]}++_}}if(g>0){s[_]=s[g];for(let b=g*h,T=_*h,A=0;A!==h;++A)l[T+A]=l[b+A];++_}return _!==s.length?(this.times=s.slice(0,_),this.values=l.slice(0,_*h)):(this.times=s,this.values=l),this}clone(){const s=this.times.slice(),l=this.values.slice(),h=this.constructor,f=new h(this.name,s,l);return f.createInterpolant=this.createInterpolant,f}}fo.prototype.ValueTypeName="",fo.prototype.TimeBufferType=Float32Array,fo.prototype.ValueBufferType=Float32Array,fo.prototype.DefaultInterpolation=Ig;class Rd extends fo{constructor(s,l,h){super(s,l,h)}}Rd.prototype.ValueTypeName="bool",Rd.prototype.ValueBufferType=Array,Rd.prototype.DefaultInterpolation=il,Rd.prototype.InterpolantFactoryMethodLinear=void 0,Rd.prototype.InterpolantFactoryMethodSmooth=void 0;class px extends fo{constructor(s,l,h,f){super(s,l,h,f)}}px.prototype.ValueTypeName="color";class I0 extends fo{constructor(s,l,h,f){super(s,l,h,f)}}I0.prototype.ValueTypeName="number";class Tm extends Cd{constructor(s,l,h,f){super(s,l,h,f)}interpolate_(s,l,h,f){const g=this.resultBuffer,_=this.sampleValues,b=this.valueSize,T=(h-l)/(f-l);let A=s*b;for(let R=A+b;A!==R;A+=4)ro.slerpFlat(g,0,_,A-b,_,A,T);return g}}class wm extends fo{constructor(s,l,h,f){super(s,l,h,f)}InterpolantFactoryMethodLinear(s){return new Tm(this.times,this.values,this.getValueSize(),s)}}wm.prototype.ValueTypeName="quaternion",wm.prototype.InterpolantFactoryMethodSmooth=void 0;class Vu extends fo{constructor(s,l,h){super(s,l,h)}}Vu.prototype.ValueTypeName="string",Vu.prototype.ValueBufferType=Array,Vu.prototype.DefaultInterpolation=il,Vu.prototype.InterpolantFactoryMethodLinear=void 0,Vu.prototype.InterpolantFactoryMethodSmooth=void 0;class Am extends fo{constructor(s,l,h,f){super(s,l,h,f)}}Am.prototype.ValueTypeName="vector";class Kr{constructor(s="",l=-1,h=[],f=af){this.name=s,this.tracks=h,this.duration=l,this.blendMode=f,this.uuid=Be(),this.userData={},this.duration<0&&this.resetDuration()}static parse(s){const l=[],h=s.tracks,f=1/(s.fps||1);for(let _=0,b=h.length;_!==b;++_)l.push(mx(h[_]).scale(f));const g=new this(s.name,s.duration,l,s.blendMode);return g.uuid=s.uuid,g.userData=JSON.parse(s.userData||"{}"),g}static toJSON(s){const l=[],h=s.tracks,f={name:s.name,duration:s.duration,tracks:l,uuid:s.uuid,blendMode:s.blendMode,userData:JSON.stringify(s.userData)};for(let g=0,_=h.length;g!==_;++g)l.push(fo.toJSON(h[g]));return f}static CreateFromMorphTargetSequence(s,l,h,f){const g=l.length,_=[];for(let b=0;b<g;b++){let T=[],A=[];T.push((b+g-1)%g,b,(b+1)%g),A.push(0,1,0);const R=R0(T);T=Mm(T,1,R),A=Mm(A,1,R),!f&&T[0]===0&&(T.push(g),A.push(A[0])),_.push(new I0(".morphTargetInfluences["+l[b].name+"]",T,A).scale(1/h))}return new this(s,-1,_)}static findByName(s,l){let h=s;if(!Array.isArray(s)){const f=s;h=f.geometry&&f.geometry.animations||f.animations}for(let f=0;f<h.length;f++)if(h[f].name===l)return h[f];return null}static CreateClipsFromMorphTargetSequences(s,l,h){const f={},g=/^([\w-]*?)([\d]+)$/;for(let b=0,T=s.length;b<T;b++){const A=s[b],R=A.name.match(g);if(R&&R.length>1){const P=R[1];let L=f[P];L||(f[P]=L=[]),L.push(A)}}const _=[];for(const b in f)_.push(this.CreateFromMorphTargetSequence(b,f[b],l,h));return _}static parseAnimation(s,l){if(Mn("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!s)return ci("AnimationClip: No animation in JSONLoader data."),null;const h=function(P,L,D,O,W){if(D.length!==0){const Z=[],Y=[];Vf(D,Z,Y,O),Z.length!==0&&W.push(new P(L,Z,Y))}},f=[],g=s.name||"default",_=s.fps||30,b=s.blendMode;let T=s.length||-1;const A=s.hierarchy||[];for(let P=0;P<A.length;P++){const L=A[P].keys;if(!(!L||L.length===0))if(L[0].morphTargets){const D={};let O;for(O=0;O<L.length;O++)if(L[O].morphTargets)for(let W=0;W<L[O].morphTargets.length;W++)D[L[O].morphTargets[W]]=-1;for(const W in D){const Z=[],Y=[];for(let ie=0;ie!==L[O].morphTargets.length;++ie){const se=L[O];Z.push(se.time),Y.push(se.morphTarget===W?1:0)}f.push(new I0(".morphTargetInfluence["+W+"]",Z,Y))}T=D.length*_}else{const D=".bones["+l[P].name+"]";h(Am,D+".position",L,"pos",f),h(wm,D+".quaternion",L,"rot",f),h(Am,D+".scale",L,"scl",f)}}return f.length===0?null:new this(g,T,f,b)}resetDuration(){const s=this.tracks;let l=0;for(let h=0,f=s.length;h!==f;++h){const g=this.tracks[h];l=Math.max(l,g.times[g.times.length-1])}return this.duration=l,this}trim(){for(let s=0;s<this.tracks.length;s++)this.tracks[s].trim(0,this.duration);return this}validate(){let s=!0;for(let l=0;l<this.tracks.length;l++)s=s&&this.tracks[l].validate();return s}optimize(){for(let s=0;s<this.tracks.length;s++)this.tracks[s].optimize();return this}clone(){const s=[];for(let h=0;h<this.tracks.length;h++)s.push(this.tracks[h].clone());const l=new this.constructor(this.name,this.duration,s,this.blendMode);return l.userData=JSON.parse(JSON.stringify(this.userData)),l}toJSON(){return this.constructor.toJSON(this)}}function Nd(E){switch(E.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return I0;case"vector":case"vector2":case"vector3":case"vector4":return Am;case"color":return px;case"quaternion":return wm;case"bool":case"boolean":return Rd;case"string":return Vu}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+E)}function mx(E){if(E.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const s=Nd(E.type);if(E.times===void 0){const l=[],h=[];Vf(E.keys,l,h,"value"),E.times=l,E.values=h}return s.parse!==void 0?s.parse(E):new s(E.name,E.times,E.values,E.interpolation)}const Bo={enabled:!1,files:{},add:function(E,s){this.enabled!==!1&&(this.files[E]=s)},get:function(E){if(this.enabled!==!1)return this.files[E]},remove:function(E){delete this.files[E]},clear:function(){this.files={}}};class gx{constructor(s,l,h){const f=this;let g=!1,_=0,b=0,T;const A=[];this.onStart=void 0,this.onLoad=s,this.onProgress=l,this.onError=h,this._abortController=null,this.itemStart=function(R){b++,g===!1&&f.onStart!==void 0&&f.onStart(R,_,b),g=!0},this.itemEnd=function(R){_++,f.onProgress!==void 0&&f.onProgress(R,_,b),_===b&&(g=!1,f.onLoad!==void 0&&f.onLoad())},this.itemError=function(R){f.onError!==void 0&&f.onError(R)},this.resolveURL=function(R){return T?T(R):R},this.setURLModifier=function(R){return T=R,this},this.addHandler=function(R,P){return A.push(R,P),this},this.removeHandler=function(R){const P=A.indexOf(R);return P!==-1&&A.splice(P,2),this},this.getHandler=function(R){for(let P=0,L=A.length;P<L;P+=2){const D=A[P],O=A[P+1];if(D.global&&(D.lastIndex=0),D.test(R))return O}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 Em=new gx;class Pd{constructor(s){this.manager=s!==void 0?s:Em,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(s,l){const h=this;return new Promise(function(f,g){h.load(s,f,l,g)})}parse(){}setCrossOrigin(s){return this.crossOrigin=s,this}setWithCredentials(s){return this.withCredentials=s,this}setPath(s){return this.path=s,this}setResourcePath(s){return this.resourcePath=s,this}setRequestHeader(s){return this.requestHeader=s,this}abort(){return this}}Pd.DEFAULT_MATERIAL_NAME="__DEFAULT";const Oo={};class Cm extends null{constructor(s,l){super(s),this.response=l}}class pc extends null{constructor(s){super(s),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(s,l,h,f){s===void 0&&(s=""),this.path!==void 0&&(s=this.path+s),s=this.manager.resolveURL(s);const g=Bo.get(`file:${s}`);if(g!==void 0)return this.manager.itemStart(s),setTimeout(()=>{l&&l(g),this.manager.itemEnd(s)},0),g;if(Oo[s]!==void 0){Oo[s].push({onLoad:l,onProgress:h,onError:f});return}Oo[s]=[],Oo[s].push({onLoad:l,onProgress:h,onError:f});const _=new Request(s,{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}),b=this.mimeType,T=this.responseType;fetch(_).then(A=>{if(A.status===200||A.status===0){if(A.status===0&&Mn("FileLoader: HTTP Status 0 received."),typeof ReadableStream=="undefined"||A.body===void 0||A.body.getReader===void 0)return A;const R=Oo[s],P=A.body.getReader(),L=A.headers.get("X-File-Size")||A.headers.get("Content-Length"),D=L?parseInt(L):0,O=D!==0;let W=0;const Z=new ReadableStream({start(Y){ie();function ie(){P.read().then(({done:se,value:de})=>{if(se)Y.close();else{W+=de.byteLength;const ke=new ProgressEvent("progress",{lengthComputable:O,loaded:W,total:D});for(let $e=0,et=R.length;$e<et;$e++){const qe=R[$e];qe.onProgress&&qe.onProgress(ke)}Y.enqueue(de),ie()}},se=>{Y.error(se)})}}});return new Response(Z)}else throw new Cm(`fetch for "${A.url}" responded with ${A.status}: ${A.statusText}`,A)}).then(A=>{switch(T){case"arraybuffer":return A.arrayBuffer();case"blob":return A.blob();case"document":return A.text().then(R=>new DOMParser().parseFromString(R,b));case"json":return A.json();default:if(b==="")return A.text();{const P=/charset="?([^;"\s]*)"?/i.exec(b),L=P&&P[1]?P[1].toLowerCase():void 0,D=new TextDecoder(L);return A.arrayBuffer().then(O=>D.decode(O))}}}).then(A=>{Bo.add(`file:${s}`,A);const R=Oo[s];delete Oo[s];for(let P=0,L=R.length;P<L;P++){const D=R[P];D.onLoad&&D.onLoad(A)}}).catch(A=>{const R=Oo[s];if(R===void 0)throw this.manager.itemError(s),A;delete Oo[s];for(let P=0,L=R.length;P<L;P++){const D=R[P];D.onError&&D.onError(A)}this.manager.itemError(s)}).finally(()=>{this.manager.itemEnd(s)}),this.manager.itemStart(s)}setResponseType(s){return this.responseType=s,this}setMimeType(s){return this.mimeType=s,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}class AA extends null{constructor(s){super(s)}load(s,l,h,f){const g=this,_=new pc(this.manager);_.setPath(this.path),_.setRequestHeader(this.requestHeader),_.setWithCredentials(this.withCredentials),_.load(s,function(b){try{l(g.parse(JSON.parse(b)))}catch(T){f?f(T):ci(T),g.manager.itemError(s)}},h,f)}parse(s){const l=[];for(let h=0;h<s.length;h++){const f=Kr.parse(s[h]);l.push(f)}return l}}class mc extends null{constructor(s){super(s)}load(s,l,h,f){const g=this,_=[],b=new u0,T=new pc(this.manager);T.setPath(this.path),T.setResponseType("arraybuffer"),T.setRequestHeader(this.requestHeader),T.setWithCredentials(g.withCredentials);let A=0;function R(P){T.load(s[P],function(L){const D=g.parse(L,!0);_[P]={width:D.width,height:D.height,format:D.format,mipmaps:D.mipmaps},A+=1,A===6&&(D.mipmapCount===1&&(b.minFilter=Yn),b.image=_,b.format=D.format,b.needsUpdate=!0,l&&l(b))},h,f)}if(Array.isArray(s))for(let P=0,L=s.length;P<L;++P)R(P);else T.load(s,function(P){const L=g.parse(P,!0);if(L.isCubemap){const D=L.mipmaps.length/L.mipmapCount;for(let O=0;O<D;O++){_[O]={mipmaps:[]};for(let W=0;W<L.mipmapCount;W++)_[O].mipmaps.push(L.mipmaps[O*L.mipmapCount+W]),_[O].format=L.format,_[O].width=L.width,_[O].height=L.height}b.image=_}else b.image.width=L.width,b.image.height=L.height,b.mipmaps=L.mipmaps;L.mipmapCount===1&&(b.minFilter=Yn),b.format=L.format,b.needsUpdate=!0,l&&l(b)},h,f);return b}}const Gu=new WeakMap;class Rm extends null{constructor(s){super(s)}load(s,l,h,f){this.path!==void 0&&(s=this.path+s),s=this.manager.resolveURL(s);const g=this,_=Bo.get(`image:${s}`);if(_!==void 0){if(_.complete===!0)g.manager.itemStart(s),setTimeout(function(){l&&l(_),g.manager.itemEnd(s)},0);else{let P=Gu.get(_);P===void 0&&(P=[],Gu.set(_,P)),P.push({onLoad:l,onError:f})}return _}const b=xr("img");function T(){R(),l&&l(this);const P=Gu.get(this)||[];for(let L=0;L<P.length;L++){const D=P[L];D.onLoad&&D.onLoad(this)}Gu.delete(this),g.manager.itemEnd(s)}function A(P){R(),f&&f(P),Bo.remove(`image:${s}`);const L=Gu.get(this)||[];for(let D=0;D<L.length;D++){const O=L[D];O.onError&&O.onError(P)}Gu.delete(this),g.manager.itemError(s),g.manager.itemEnd(s)}function R(){b.removeEventListener("load",T,!1),b.removeEventListener("error",A,!1)}return b.addEventListener("load",T,!1),b.addEventListener("error",A,!1),s.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(b.crossOrigin=this.crossOrigin),Bo.add(`image:${s}`,b),g.manager.itemStart(s),b.src=s,b}}class yx extends null{constructor(s){super(s)}load(s,l,h,f){const g=new ld;g.colorSpace=Ao;const _=new Rm(this.manager);_.setCrossOrigin(this.crossOrigin),_.setPath(this.path);let b=0;function T(A){_.load(s[A],function(R){g.images[A]=R,b++,b===6&&(g.needsUpdate=!0,l&&l(g))},void 0,f)}for(let A=0;A<s.length;++A)T(A);return g}}class gc extends null{constructor(s){super(s)}load(s,l,h,f){const g=this,_=new gl,b=new pc(this.manager);return b.setResponseType("arraybuffer"),b.setRequestHeader(this.requestHeader),b.setPath(this.path),b.setWithCredentials(g.withCredentials),b.load(s,function(T){let A;try{A=g.parse(T)}catch(R){if(f!==void 0)f(R);else{R(R);return}}A.image!==void 0?_.image=A.image:A.data!==void 0&&(_.image.width=A.width,_.image.height=A.height,_.image.data=A.data),_.wrapS=A.wrapS!==void 0?A.wrapS:ki,_.wrapT=A.wrapT!==void 0?A.wrapT:ki,_.magFilter=A.magFilter!==void 0?A.magFilter:Yn,_.minFilter=A.minFilter!==void 0?A.minFilter:Yn,_.anisotropy=A.anisotropy!==void 0?A.anisotropy:1,A.colorSpace!==void 0&&(_.colorSpace=A.colorSpace),A.flipY!==void 0&&(_.flipY=A.flipY),A.format!==void 0&&(_.format=A.format),A.type!==void 0&&(_.type=A.type),A.mipmaps!==void 0&&(_.mipmaps=A.mipmaps,_.minFilter=Vs),A.mipmapCount===1&&(_.minFilter=Yn),A.generateMipmaps!==void 0&&(_.generateMipmaps=A.generateMipmaps),_.needsUpdate=!0,l&&l(_,A)},h,f),_}}class EA extends null{constructor(s){super(s)}load(s,l,h,f){const g=new br,_=new Rm(this.manager);return _.setCrossOrigin(this.crossOrigin),_.setPath(this.path),_.load(s,function(b){g.image=b,g.needsUpdate=!0,l!==void 0&&l(g)},h,f),g}}class Wu extends null{constructor(s,l=1){super(),this.isLight=!0,this.type="Light",this.color=new Zn(s),this.intensity=l}dispose(){}copy(s,l){return super.copy(s,l),this.color.copy(s.color),this.intensity=s.intensity,this}toJSON(s){const l=super.toJSON(s);return l.object.color=this.color.getHex(),l.object.intensity=this.intensity,this.groundColor!==void 0&&(l.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(l.object.distance=this.distance),this.angle!==void 0&&(l.object.angle=this.angle),this.decay!==void 0&&(l.object.decay=this.decay),this.penumbra!==void 0&&(l.object.penumbra=this.penumbra),this.shadow!==void 0&&(l.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(l.object.target=this.target.uuid),l}}class CA extends null{constructor(s,l,h){super(s,h),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Hs.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Zn(l)}copy(s,l){return super.copy(s,l),this.groundColor.copy(s.groundColor),this}}const _x=new Dn,Hu=new ae,Gf=new ae;class XL{constructor(s){this.camera=s,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new St(512,512),this.mapType=Di,this.map=null,this.mapPass=null,this.matrix=new Dn,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new s0,this._frameExtents=new St(1,1),this._viewportCount=1,this._viewports=[new as(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(s){const l=this.camera,h=this.matrix;Hu.setFromMatrixPosition(s.matrixWorld),l.position.copy(Hu),Gf.setFromMatrixPosition(s.target.matrixWorld),l.lookAt(Gf),l.updateMatrixWorld(),_x.multiplyMatrices(l.projectionMatrix,l.matrixWorldInverse),this._frustum.setFromProjectionMatrix(_x,l.coordinateSystem,l.reversedDepth),l.reversedDepth?h.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):h.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),h.multiply(_x)}getViewport(s){return this._viewports[s]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(s){return this.camera=s.camera.clone(),this.intensity=s.intensity,this.bias=s.bias,this.radius=s.radius,this.autoUpdate=s.autoUpdate,this.needsUpdate=s.needsUpdate,this.normalBias=s.normalBias,this.blurSamples=s.blurSamples,this.mapSize.copy(s.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const s={};return this.intensity!==1&&(s.intensity=this.intensity),this.bias!==0&&(s.bias=this.bias),this.normalBias!==0&&(s.normalBias=this.normalBias),this.radius!==1&&(s.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(s.mapSize=this.mapSize.toArray()),s.camera=this.camera.toJSON(!1).object,delete s.camera.matrix,s}}class RA extends null{constructor(){super(new Io(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(s){const l=this.camera,h=Ie*2*s.angle*this.focus,f=this.mapSize.width/this.mapSize.height*this.aspect,g=s.distance||l.far;(h!==l.fov||f!==l.aspect||g!==l.far)&&(l.fov=h,l.aspect=f,l.far=g,l.updateProjectionMatrix()),super.updateMatrices(s)}copy(s){return super.copy(s),this.focus=s.focus,this}}class RS extends null{constructor(s,l,h=0,f=Math.PI/3,g=0,_=2){super(s,l),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Hs.DEFAULT_UP),this.updateMatrix(),this.target=new Hs,this.distance=h,this.angle=f,this.penumbra=g,this.decay=_,this.map=null,this.shadow=new RA}get power(){return this.intensity*Math.PI}set power(s){this.intensity=s/Math.PI}dispose(){this.shadow.dispose()}copy(s,l){return super.copy(s,l),this.distance=s.distance,this.angle=s.angle,this.penumbra=s.penumbra,this.decay=s.decay,this.target=s.target.clone(),this.shadow=s.shadow.clone(),this}}const yc=new Dn,Id=new ae,Wf=new ae;class xx extends null{constructor(){super(new Io(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new St(4,2),this._viewportCount=6,this._viewports=[new as(2,1,1,1),new as(0,1,1,1),new as(3,1,1,1),new as(1,1,1,1),new as(3,0,1,1),new as(1,0,1,1)],this._cubeDirections=[new ae(1,0,0),new ae(-1,0,0),new ae(0,0,1),new ae(0,0,-1),new ae(0,1,0),new ae(0,-1,0)],this._cubeUps=[new ae(0,1,0),new ae(0,1,0),new ae(0,1,0),new ae(0,1,0),new ae(0,0,1),new ae(0,0,-1)]}updateMatrices(s,l=0){const h=this.camera,f=this.matrix,g=s.distance||h.far;g!==h.far&&(h.far=g,h.updateProjectionMatrix()),Id.setFromMatrixPosition(s.matrixWorld),h.position.copy(Id),Wf.copy(h.position),Wf.add(this._cubeDirections[l]),h.up.copy(this._cubeUps[l]),h.lookAt(Wf),h.updateMatrixWorld(),f.makeTranslation(-Id.x,-Id.y,-Id.z),yc.multiplyMatrices(h.projectionMatrix,h.matrixWorldInverse),this._frustum.setFromProjectionMatrix(yc,h.coordinateSystem,h.reversedDepth)}}class vx extends null{constructor(s,l,h=0,f=2){super(s,l),this.isPointLight=!0,this.type="PointLight",this.distance=h,this.decay=f,this.shadow=new xx}get power(){return this.intensity*4*Math.PI}set power(s){this.intensity=s/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(s,l){return super.copy(s,l),this.distance=s.distance,this.decay=s.decay,this.shadow=s.shadow.clone(),this}}class Nm extends null{constructor(s=-1,l=1,h=1,f=-1,g=.1,_=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=s,this.right=l,this.top=h,this.bottom=f,this.near=g,this.far=_,this.updateProjectionMatrix()}copy(s,l){return super.copy(s,l),this.left=s.left,this.right=s.right,this.top=s.top,this.bottom=s.bottom,this.near=s.near,this.far=s.far,this.zoom=s.zoom,this.view=s.view===null?null:Object.assign({},s.view),this}setViewOffset(s,l,h,f,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=s,this.view.fullHeight=l,this.view.offsetX=h,this.view.offsetY=f,this.view.width=g,this.view.height=_,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const s=(this.right-this.left)/(2*this.zoom),l=(this.top-this.bottom)/(2*this.zoom),h=(this.right+this.left)/2,f=(this.top+this.bottom)/2;let g=h-s,_=h+s,b=f+l,T=f-l;if(this.view!==null&&this.view.enabled){const A=(this.right-this.left)/this.view.fullWidth/this.zoom,R=(this.top-this.bottom)/this.view.fullHeight/this.zoom;g+=A*this.view.offsetX,_=g+A*this.view.width,b-=R*this.view.offsetY,T=b-R*this.view.height}this.projectionMatrix.makeOrthographic(g,_,b,T,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(s){const l=super.toJSON(s);return l.object.zoom=this.zoom,l.object.left=this.left,l.object.right=this.right,l.object.top=this.top,l.object.bottom=this.bottom,l.object.near=this.near,l.object.far=this.far,this.view!==null&&(l.object.view=Object.assign({},this.view)),l}}class NS extends null{constructor(){super(new Nm(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Pm extends null{constructor(s,l){super(s,l),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Hs.DEFAULT_UP),this.updateMatrix(),this.target=new Hs,this.shadow=new NS}dispose(){this.shadow.dispose()}copy(s){return super.copy(s),this.target=s.target.clone(),this.shadow=s.shadow.clone(),this}}class PS extends null{constructor(s,l){super(s,l),this.isAmbientLight=!0,this.type="AmbientLight"}}class bx extends null{constructor(s,l,h=10,f=10){super(s,l),this.isRectAreaLight=!0,this.type="RectAreaLight",this.width=h,this.height=f}get power(){return this.intensity*this.width*this.height*Math.PI}set power(s){this.intensity=s/(this.width*this.height*Math.PI)}copy(s){return super.copy(s),this.width=s.width,this.height=s.height,this}toJSON(s){const l=super.toJSON(s);return l.object.width=this.width,l.object.height=this.height,l}}class $u{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let s=0;s<9;s++)this.coefficients.push(new ae)}set(s){for(let l=0;l<9;l++)this.coefficients[l].copy(s[l]);return this}zero(){for(let s=0;s<9;s++)this.coefficients[s].set(0,0,0);return this}getAt(s,l){const h=s.x,f=s.y,g=s.z,_=this.coefficients;return l.copy(_[0]).multiplyScalar(.282095),l.addScaledVector(_[1],.488603*f),l.addScaledVector(_[2],.488603*g),l.addScaledVector(_[3],.488603*h),l.addScaledVector(_[4],1.092548*(h*f)),l.addScaledVector(_[5],1.092548*(f*g)),l.addScaledVector(_[6],.315392*(3*g*g-1)),l.addScaledVector(_[7],1.092548*(h*g)),l.addScaledVector(_[8],.546274*(h*h-f*f)),l}getIrradianceAt(s,l){const h=s.x,f=s.y,g=s.z,_=this.coefficients;return l.copy(_[0]).multiplyScalar(.886227),l.addScaledVector(_[1],2*.511664*f),l.addScaledVector(_[2],2*.511664*g),l.addScaledVector(_[3],2*.511664*h),l.addScaledVector(_[4],2*.429043*h*f),l.addScaledVector(_[5],2*.429043*f*g),l.addScaledVector(_[6],.743125*g*g-.247708),l.addScaledVector(_[7],2*.429043*h*g),l.addScaledVector(_[8],.429043*(h*h-f*f)),l}add(s){for(let l=0;l<9;l++)this.coefficients[l].add(s.coefficients[l]);return this}addScaledSH(s,l){for(let h=0;h<9;h++)this.coefficients[h].addScaledVector(s.coefficients[h],l);return this}scale(s){for(let l=0;l<9;l++)this.coefficients[l].multiplyScalar(s);return this}lerp(s,l){for(let h=0;h<9;h++)this.coefficients[h].lerp(s.coefficients[h],l);return this}equals(s){for(let l=0;l<9;l++)if(!this.coefficients[l].equals(s.coefficients[l]))return!1;return!0}copy(s){return this.set(s.coefficients)}clone(){return new this.constructor().copy(this)}fromArray(s,l=0){const h=this.coefficients;for(let f=0;f<9;f++)h[f].fromArray(s,l+f*3);return this}toArray(s=[],l=0){const h=this.coefficients;for(let f=0;f<9;f++)h[f].toArray(s,l+f*3);return s}static getBasisAt(s,l){const h=s.x,f=s.y,g=s.z;l[0]=.282095,l[1]=.488603*f,l[2]=.488603*g,l[3]=.488603*h,l[4]=1.092548*h*f,l[5]=1.092548*f*g,l[6]=.315392*(3*g*g-1),l[7]=1.092548*h*g,l[8]=.546274*(h*h-f*f)}}class IS extends null{constructor(s=new $u,l=1){super(void 0,l),this.isLightProbe=!0,this.sh=s}copy(s){return super.copy(s),this.sh.copy(s.sh),this}fromJSON(s){return this.intensity=s.intensity,this.sh.fromArray(s.sh),this}toJSON(s){const l=super.toJSON(s);return l.object.sh=this.sh.toArray(),l}}class Hf extends null{constructor(s){super(s),this.textures={}}load(s,l,h,f){const g=this,_=new pc(g.manager);_.setPath(g.path),_.setRequestHeader(g.requestHeader),_.setWithCredentials(g.withCredentials),_.load(s,function(b){try{l(g.parse(JSON.parse(b)))}catch(T){f?f(T):ci(T),g.manager.itemError(s)}},h,f)}parse(s){const l=this.textures;function h(g){return l[g]===void 0&&Mn("MaterialLoader: Undefined texture",g),l[g]}const f=this.createMaterialFromType(s.type);if(s.uuid!==void 0&&(f.uuid=s.uuid),s.name!==void 0&&(f.name=s.name),s.color!==void 0&&f.color!==void 0&&f.color.setHex(s.color),s.roughness!==void 0&&(f.roughness=s.roughness),s.metalness!==void 0&&(f.metalness=s.metalness),s.sheen!==void 0&&(f.sheen=s.sheen),s.sheenColor!==void 0&&(f.sheenColor=new Zn().setHex(s.sheenColor)),s.sheenRoughness!==void 0&&(f.sheenRoughness=s.sheenRoughness),s.emissive!==void 0&&f.emissive!==void 0&&f.emissive.setHex(s.emissive),s.specular!==void 0&&f.specular!==void 0&&f.specular.setHex(s.specular),s.specularIntensity!==void 0&&(f.specularIntensity=s.specularIntensity),s.specularColor!==void 0&&f.specularColor!==void 0&&f.specularColor.setHex(s.specularColor),s.shininess!==void 0&&(f.shininess=s.shininess),s.clearcoat!==void 0&&(f.clearcoat=s.clearcoat),s.clearcoatRoughness!==void 0&&(f.clearcoatRoughness=s.clearcoatRoughness),s.dispersion!==void 0&&(f.dispersion=s.dispersion),s.iridescence!==void 0&&(f.iridescence=s.iridescence),s.iridescenceIOR!==void 0&&(f.iridescenceIOR=s.iridescenceIOR),s.iridescenceThicknessRange!==void 0&&(f.iridescenceThicknessRange=s.iridescenceThicknessRange),s.transmission!==void 0&&(f.transmission=s.transmission),s.thickness!==void 0&&(f.thickness=s.thickness),s.attenuationDistance!==void 0&&(f.attenuationDistance=s.attenuationDistance),s.attenuationColor!==void 0&&f.attenuationColor!==void 0&&f.attenuationColor.setHex(s.attenuationColor),s.anisotropy!==void 0&&(f.anisotropy=s.anisotropy),s.anisotropyRotation!==void 0&&(f.anisotropyRotation=s.anisotropyRotation),s.fog!==void 0&&(f.fog=s.fog),s.flatShading!==void 0&&(f.flatShading=s.flatShading),s.blending!==void 0&&(f.blending=s.blending),s.combine!==void 0&&(f.combine=s.combine),s.side!==void 0&&(f.side=s.side),s.shadowSide!==void 0&&(f.shadowSide=s.shadowSide),s.opacity!==void 0&&(f.opacity=s.opacity),s.transparent!==void 0&&(f.transparent=s.transparent),s.alphaTest!==void 0&&(f.alphaTest=s.alphaTest),s.alphaHash!==void 0&&(f.alphaHash=s.alphaHash),s.depthFunc!==void 0&&(f.depthFunc=s.depthFunc),s.depthTest!==void 0&&(f.depthTest=s.depthTest),s.depthWrite!==void 0&&(f.depthWrite=s.depthWrite),s.colorWrite!==void 0&&(f.colorWrite=s.colorWrite),s.blendSrc!==void 0&&(f.blendSrc=s.blendSrc),s.blendDst!==void 0&&(f.blendDst=s.blendDst),s.blendEquation!==void 0&&(f.blendEquation=s.blendEquation),s.blendSrcAlpha!==void 0&&(f.blendSrcAlpha=s.blendSrcAlpha),s.blendDstAlpha!==void 0&&(f.blendDstAlpha=s.blendDstAlpha),s.blendEquationAlpha!==void 0&&(f.blendEquationAlpha=s.blendEquationAlpha),s.blendColor!==void 0&&f.blendColor!==void 0&&f.blendColor.setHex(s.blendColor),s.blendAlpha!==void 0&&(f.blendAlpha=s.blendAlpha),s.stencilWriteMask!==void 0&&(f.stencilWriteMask=s.stencilWriteMask),s.stencilFunc!==void 0&&(f.stencilFunc=s.stencilFunc),s.stencilRef!==void 0&&(f.stencilRef=s.stencilRef),s.stencilFuncMask!==void 0&&(f.stencilFuncMask=s.stencilFuncMask),s.stencilFail!==void 0&&(f.stencilFail=s.stencilFail),s.stencilZFail!==void 0&&(f.stencilZFail=s.stencilZFail),s.stencilZPass!==void 0&&(f.stencilZPass=s.stencilZPass),s.stencilWrite!==void 0&&(f.stencilWrite=s.stencilWrite),s.wireframe!==void 0&&(f.wireframe=s.wireframe),s.wireframeLinewidth!==void 0&&(f.wireframeLinewidth=s.wireframeLinewidth),s.wireframeLinecap!==void 0&&(f.wireframeLinecap=s.wireframeLinecap),s.wireframeLinejoin!==void 0&&(f.wireframeLinejoin=s.wireframeLinejoin),s.rotation!==void 0&&(f.rotation=s.rotation),s.linewidth!==void 0&&(f.linewidth=s.linewidth),s.dashSize!==void 0&&(f.dashSize=s.dashSize),s.gapSize!==void 0&&(f.gapSize=s.gapSize),s.scale!==void 0&&(f.scale=s.scale),s.polygonOffset!==void 0&&(f.polygonOffset=s.polygonOffset),s.polygonOffsetFactor!==void 0&&(f.polygonOffsetFactor=s.polygonOffsetFactor),s.polygonOffsetUnits!==void 0&&(f.polygonOffsetUnits=s.polygonOffsetUnits),s.dithering!==void 0&&(f.dithering=s.dithering),s.alphaToCoverage!==void 0&&(f.alphaToCoverage=s.alphaToCoverage),s.premultipliedAlpha!==void 0&&(f.premultipliedAlpha=s.premultipliedAlpha),s.forceSinglePass!==void 0&&(f.forceSinglePass=s.forceSinglePass),s.visible!==void 0&&(f.visible=s.visible),s.toneMapped!==void 0&&(f.toneMapped=s.toneMapped),s.userData!==void 0&&(f.userData=s.userData),s.vertexColors!==void 0&&(typeof s.vertexColors=="number"?f.vertexColors=s.vertexColors>0:f.vertexColors=s.vertexColors),s.uniforms!==void 0)for(const g in s.uniforms){const _=s.uniforms[g];switch(f.uniforms[g]={},_.type){case"t":f.uniforms[g].value=h(_.value);break;case"c":f.uniforms[g].value=new Zn().setHex(_.value);break;case"v2":f.uniforms[g].value=new St().fromArray(_.value);break;case"v3":f.uniforms[g].value=new ae().fromArray(_.value);break;case"v4":f.uniforms[g].value=new as().fromArray(_.value);break;case"m3":f.uniforms[g].value=new ts().fromArray(_.value);break;case"m4":f.uniforms[g].value=new Dn().fromArray(_.value);break;default:f.uniforms[g].value=_.value}}if(s.defines!==void 0&&(f.defines=s.defines),s.vertexShader!==void 0&&(f.vertexShader=s.vertexShader),s.fragmentShader!==void 0&&(f.fragmentShader=s.fragmentShader),s.glslVersion!==void 0&&(f.glslVersion=s.glslVersion),s.extensions!==void 0)for(const g in s.extensions)f.extensions[g]=s.extensions[g];if(s.lights!==void 0&&(f.lights=s.lights),s.clipping!==void 0&&(f.clipping=s.clipping),s.size!==void 0&&(f.size=s.size),s.sizeAttenuation!==void 0&&(f.sizeAttenuation=s.sizeAttenuation),s.map!==void 0&&(f.map=h(s.map)),s.matcap!==void 0&&(f.matcap=h(s.matcap)),s.alphaMap!==void 0&&(f.alphaMap=h(s.alphaMap)),s.bumpMap!==void 0&&(f.bumpMap=h(s.bumpMap)),s.bumpScale!==void 0&&(f.bumpScale=s.bumpScale),s.normalMap!==void 0&&(f.normalMap=h(s.normalMap)),s.normalMapType!==void 0&&(f.normalMapType=s.normalMapType),s.normalScale!==void 0){let g=s.normalScale;Array.isArray(g)===!1&&(g=[g,g]),f.normalScale=new St().fromArray(g)}return s.displacementMap!==void 0&&(f.displacementMap=h(s.displacementMap)),s.displacementScale!==void 0&&(f.displacementScale=s.displacementScale),s.displacementBias!==void 0&&(f.displacementBias=s.displacementBias),s.roughnessMap!==void 0&&(f.roughnessMap=h(s.roughnessMap)),s.metalnessMap!==void 0&&(f.metalnessMap=h(s.metalnessMap)),s.emissiveMap!==void 0&&(f.emissiveMap=h(s.emissiveMap)),s.emissiveIntensity!==void 0&&(f.emissiveIntensity=s.emissiveIntensity),s.specularMap!==void 0&&(f.specularMap=h(s.specularMap)),s.specularIntensityMap!==void 0&&(f.specularIntensityMap=h(s.specularIntensityMap)),s.specularColorMap!==void 0&&(f.specularColorMap=h(s.specularColorMap)),s.envMap!==void 0&&(f.envMap=h(s.envMap)),s.envMapRotation!==void 0&&f.envMapRotation.fromArray(s.envMapRotation),s.envMapIntensity!==void 0&&(f.envMapIntensity=s.envMapIntensity),s.reflectivity!==void 0&&(f.reflectivity=s.reflectivity),s.refractionRatio!==void 0&&(f.refractionRatio=s.refractionRatio),s.lightMap!==void 0&&(f.lightMap=h(s.lightMap)),s.lightMapIntensity!==void 0&&(f.lightMapIntensity=s.lightMapIntensity),s.aoMap!==void 0&&(f.aoMap=h(s.aoMap)),s.aoMapIntensity!==void 0&&(f.aoMapIntensity=s.aoMapIntensity),s.gradientMap!==void 0&&(f.gradientMap=h(s.gradientMap)),s.clearcoatMap!==void 0&&(f.clearcoatMap=h(s.clearcoatMap)),s.clearcoatRoughnessMap!==void 0&&(f.clearcoatRoughnessMap=h(s.clearcoatRoughnessMap)),s.clearcoatNormalMap!==void 0&&(f.clearcoatNormalMap=h(s.clearcoatNormalMap)),s.clearcoatNormalScale!==void 0&&(f.clearcoatNormalScale=new St().fromArray(s.clearcoatNormalScale)),s.iridescenceMap!==void 0&&(f.iridescenceMap=h(s.iridescenceMap)),s.iridescenceThicknessMap!==void 0&&(f.iridescenceThicknessMap=h(s.iridescenceThicknessMap)),s.transmissionMap!==void 0&&(f.transmissionMap=h(s.transmissionMap)),s.thicknessMap!==void 0&&(f.thicknessMap=h(s.thicknessMap)),s.anisotropyMap!==void 0&&(f.anisotropyMap=h(s.anisotropyMap)),s.sheenColorMap!==void 0&&(f.sheenColorMap=h(s.sheenColorMap)),s.sheenRoughnessMap!==void 0&&(f.sheenRoughnessMap=h(s.sheenRoughnessMap)),f}setTextures(s){return this.textures=s,this}createMaterialFromType(s){return Hf.createMaterialFromType(s)}static createMaterialFromType(s){const l={ShadowMaterial:AS,SpriteMaterial:Qg,RawShaderMaterial:ku,ShaderMaterial:fl,PointsMaterial:rm,MeshPhysicalMaterial:A0,MeshStandardMaterial:w0,MeshPhongMaterial:bm,MeshToonMaterial:Sm,MeshNormalMaterial:ES,MeshLambertMaterial:lx,MeshDepthMaterial:cx,MeshDistanceMaterial:ux,MeshBasicMaterial:Zl,MeshMatcapMaterial:hx,LineDashedMaterial:E0,LineBasicMaterial:Zr,Material:Sr};return new l[s]}}class Im{static extractUrlBase(s){const l=s.lastIndexOf("/");return l===-1?"./":s.slice(0,l+1)}static resolveURL(s,l){return typeof s!="string"||s===""?"":(/^https?:\/\//i.test(l)&&/^\//.test(s)&&(l=l.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(s)||/^data:.*,.*$/i.test(s)||/^blob:.*$/i.test(s)?s:l+s)}}class Sx extends null{constructor(){super(),this.isInstancedBufferGeometry=!0,this.type="InstancedBufferGeometry",this.instanceCount=1/0}copy(s){return super.copy(s),this.instanceCount=s.instanceCount,this}toJSON(){const s=super.toJSON();return s.instanceCount=this.instanceCount,s.isInstancedBufferGeometry=!0,s}}class Mx extends null{constructor(s){super(s)}load(s,l,h,f){const g=this,_=new pc(g.manager);_.setPath(g.path),_.setRequestHeader(g.requestHeader),_.setWithCredentials(g.withCredentials),_.load(s,function(b){try{l(g.parse(JSON.parse(b)))}catch(T){f?f(T):ci(T),g.manager.itemError(s)}},h,f)}parse(s){const l={},h={};function f(D,O){if(l[O]!==void 0)return l[O];const Z=D.interleavedBuffers[O],Y=g(D,Z.buffer),ie=ws(Z.type,Y),se=new nc(ie,Z.stride);return se.uuid=Z.uuid,l[O]=se,se}function g(D,O){if(h[O]!==void 0)return h[O];const Z=D.arrayBuffers[O],Y=new Uint32Array(Z).buffer;return h[O]=Y,Y}const _=s.isInstancedBufferGeometry?new Sx:new ht,b=s.data.index;if(b!==void 0){const D=ws(b.type,b.array);_.setIndex(new Ki(D,1))}const T=s.data.attributes;for(const D in T){const O=T[D];let W;if(O.isInterleavedBufferAttribute){const Z=f(s.data,O.data);W=new Lo(Z,O.itemSize,O.offset,O.normalized)}else{const Z=ws(O.type,O.array),Y=O.isInstancedBufferAttribute?dd:Ki;W=new Y(Z,O.itemSize,O.normalized)}O.name!==void 0&&(W.name=O.name),O.usage!==void 0&&W.setUsage(O.usage),_.setAttribute(D,W)}const A=s.data.morphAttributes;if(A)for(const D in A){const O=A[D],W=[];for(let Z=0,Y=O.length;Z<Y;Z++){const ie=O[Z];let se;if(ie.isInterleavedBufferAttribute){const de=f(s.data,ie.data);se=new Lo(de,ie.itemSize,ie.offset,ie.normalized)}else{const de=ws(ie.type,ie.array);se=new Ki(de,ie.itemSize,ie.normalized)}ie.name!==void 0&&(se.name=ie.name),W.push(se)}_.morphAttributes[D]=W}s.data.morphTargetsRelative&&(_.morphTargetsRelative=!0);const P=s.data.groups||s.data.drawcalls||s.data.offsets;if(P!==void 0)for(let D=0,O=P.length;D!==O;++D){const W=P[D];_.addGroup(W.start,W.count,W.materialIndex)}const L=s.data.boundingSphere;return L!==void 0&&(_.boundingSphere=new Ps().fromJSON(L)),s.name&&(_.name=s.name),s.userData&&(_.userData=s.userData),_}}class LS extends null{constructor(s){super(s)}load(s,l,h,f){const g=this,_=this.path===""?Im.extractUrlBase(s):this.path;this.resourcePath=this.resourcePath||_;const b=new pc(this.manager);b.setPath(this.path),b.setRequestHeader(this.requestHeader),b.setWithCredentials(this.withCredentials),b.load(s,function(T){let A=null;try{A=JSON.parse(T)}catch(P){f!==void 0&&f(P),P("ObjectLoader: Can't parse "+s+".",P.message);return}const R=A.metadata;if(R===void 0||R.type===void 0||R.type.toLowerCase()==="geometry"){f!==void 0&&f(new Error("THREE.ObjectLoader: Can't load "+s)),ci("ObjectLoader: Can't load "+s);return}g.parse(A,l)},h,f)}loadAsync(s,l){return mn(this,null,function*(){const h=this,f=this.path===""?Im.extractUrlBase(s):this.path;this.resourcePath=this.resourcePath||f;const g=new pc(this.manager);g.setPath(this.path),g.setRequestHeader(this.requestHeader),g.setWithCredentials(this.withCredentials);const _=yield g.loadAsync(s,l),b=JSON.parse(_),T=b.metadata;if(T===void 0||T.type===void 0||T.type.toLowerCase()==="geometry")throw new Error("THREE.ObjectLoader: Can't load "+s);return yield h.parseAsync(b)})}parse(s,l){const h=this.parseAnimations(s.animations),f=this.parseShapes(s.shapes),g=this.parseGeometries(s.geometries,f),_=this.parseImages(s.images,function(){l!==void 0&&l(A)}),b=this.parseTextures(s.textures,_),T=this.parseMaterials(s.materials,b),A=this.parseObject(s.object,g,T,b,h),R=this.parseSkeletons(s.skeletons,A);if(this.bindSkeletons(A,R),this.bindLightTargets(A),l!==void 0){let P=!1;for(const L in _)if(_[L].data instanceof HTMLImageElement){P=!0;break}P===!1&&l(A)}return A}parseAsync(s){return mn(this,null,function*(){const l=this.parseAnimations(s.animations),h=this.parseShapes(s.shapes),f=this.parseGeometries(s.geometries,h),g=yield this.parseImagesAsync(s.images),_=this.parseTextures(s.textures,g),b=this.parseMaterials(s.materials,_),T=this.parseObject(s.object,f,b,_,l),A=this.parseSkeletons(s.skeletons,T);return this.bindSkeletons(T,A),this.bindLightTargets(T),T})}parseShapes(s){const l={};if(s!==void 0)for(let h=0,f=s.length;h<f;h++){const g=new Bu().fromJSON(s[h]);l[g.uuid]=g}return l}parseSkeletons(s,l){const h={},f={};if(l.traverse(function(g){g.isBone&&(f[g.uuid]=g)}),s!==void 0)for(let g=0,_=s.length;g<_;g++){const b=new xf().fromJSON(s[g],f);h[b.uuid]=b}return h}parseGeometries(s,l){const h={};if(s!==void 0){const f=new Mx;for(let g=0,_=s.length;g<_;g++){let b;const T=s[g];switch(T.type){case"BufferGeometry":case"InstancedBufferGeometry":b=f.parse(T);break;default:T.type in vm?b=vm[T.type].fromJSON(T,l):Mn(`ObjectLoader: Unsupported geometry type "${T.type}"`)}b.uuid=T.uuid,T.name!==void 0&&(b.name=T.name),T.userData!==void 0&&(b.userData=T.userData),h[T.uuid]=b}}return h}parseMaterials(s,l){const h={},f={};if(s!==void 0){const g=new Hf;g.setTextures(l);for(let _=0,b=s.length;_<b;_++){const T=s[_];h[T.uuid]===void 0&&(h[T.uuid]=g.parse(T)),f[T.uuid]=h[T.uuid]}}return f}parseAnimations(s){const l={};if(s!==void 0)for(let h=0;h<s.length;h++){const f=s[h],g=Kr.parse(f);l[g.uuid]=g}return l}parseImages(s,l){const h=this,f={};let g;function _(T){return h.manager.itemStart(T),g.load(T,function(){h.manager.itemEnd(T)},void 0,function(){h.manager.itemError(T),h.manager.itemEnd(T)})}function b(T){if(typeof T=="string"){const A=T,R=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(A)?A:h.resourcePath+A;return _(R)}else return T.data?{data:ws(T.type,T.data),width:T.width,height:T.height}:null}if(s!==void 0&&s.length>0){const T=new gx(l);g=new Rm(T),g.setCrossOrigin(this.crossOrigin);for(let A=0,R=s.length;A<R;A++){const P=s[A],L=P.url;if(Array.isArray(L)){const D=[];for(let O=0,W=L.length;O<W;O++){const Z=L[O],Y=b(Z);Y!==null&&(Y instanceof HTMLImageElement?D.push(Y):D.push(new gl(Y.data,Y.width,Y.height)))}f[P.uuid]=new Gl(D)}else{const D=b(P.url);f[P.uuid]=new Gl(D)}}}return f}parseImagesAsync(s){return mn(this,null,function*(){const l=this,h={};let f;function g(_){return mn(this,null,function*(){if(typeof _=="string"){const b=_,T=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(b)?b:l.resourcePath+b;return yield f.loadAsync(T)}else return _.data?{data:ws(_.type,_.data),width:_.width,height:_.height}:null})}if(s!==void 0&&s.length>0){f=new Rm(this.manager),f.setCrossOrigin(this.crossOrigin);for(let _=0,b=s.length;_<b;_++){const T=s[_],A=T.url;if(Array.isArray(A)){const R=[];for(let P=0,L=A.length;P<L;P++){const D=A[P],O=yield g(D);O!==null&&(O instanceof HTMLImageElement?R.push(O):R.push(new gl(O.data,O.width,O.height)))}h[T.uuid]=new Gl(R)}else{const R=yield g(T.url);h[T.uuid]=new Gl(R)}}}return h})}parseTextures(s,l){function h(g,_){return typeof g=="number"?g:(Mn("ObjectLoader.parseTexture: Constant should be in numeric form.",g),_[g])}const f={};if(s!==void 0)for(let g=0,_=s.length;g<_;g++){const b=s[g];b.image===void 0&&Mn('ObjectLoader: No "image" specified for',b.uuid),l[b.image]===void 0&&Mn("ObjectLoader: Undefined image",b.image);const T=l[b.image],A=T.data;let R;Array.isArray(A)?(R=new ld,A.length===6&&(R.needsUpdate=!0)):(A&&A.data?R=new gl:R=new br,A&&(R.needsUpdate=!0)),R.source=T,R.uuid=b.uuid,b.name!==void 0&&(R.name=b.name),b.mapping!==void 0&&(R.mapping=h(b.mapping,L0)),b.channel!==void 0&&(R.channel=b.channel),b.offset!==void 0&&R.offset.fromArray(b.offset),b.repeat!==void 0&&R.repeat.fromArray(b.repeat),b.center!==void 0&&R.center.fromArray(b.center),b.rotation!==void 0&&(R.rotation=b.rotation),b.wrap!==void 0&&(R.wrapS=h(b.wrap[0],D0),R.wrapT=h(b.wrap[1],D0)),b.format!==void 0&&(R.format=b.format),b.internalFormat!==void 0&&(R.internalFormat=b.internalFormat),b.type!==void 0&&(R.type=b.type),b.colorSpace!==void 0&&(R.colorSpace=b.colorSpace),b.minFilter!==void 0&&(R.minFilter=h(b.minFilter,Tx)),b.magFilter!==void 0&&(R.magFilter=h(b.magFilter,Tx)),b.anisotropy!==void 0&&(R.anisotropy=b.anisotropy),b.flipY!==void 0&&(R.flipY=b.flipY),b.generateMipmaps!==void 0&&(R.generateMipmaps=b.generateMipmaps),b.premultiplyAlpha!==void 0&&(R.premultiplyAlpha=b.premultiplyAlpha),b.unpackAlignment!==void 0&&(R.unpackAlignment=b.unpackAlignment),b.compareFunction!==void 0&&(R.compareFunction=b.compareFunction),b.userData!==void 0&&(R.userData=b.userData),f[b.uuid]=R}return f}parseObject(s,l,h,f,g){let _;function b(L){return l[L]===void 0&&Mn("ObjectLoader: Undefined geometry",L),l[L]}function T(L){if(L!==void 0){if(Array.isArray(L)){const D=[];for(let O=0,W=L.length;O<W;O++){const Z=L[O];h[Z]===void 0&&Mn("ObjectLoader: Undefined material",Z),D.push(h[Z])}return D}return h[L]===void 0&&Mn("ObjectLoader: Undefined material",L),h[L]}}function A(L){return f[L]===void 0&&Mn("ObjectLoader: Undefined texture",L),f[L]}let R,P;switch(s.type){case"Scene":_=new B_,s.background!==void 0&&(Number.isInteger(s.background)?_.background=new Zn(s.background):_.background=A(s.background)),s.environment!==void 0&&(_.environment=A(s.environment)),s.fog!==void 0&&(s.fog.type==="Fog"?_.fog=new tc(s.fog.color,s.fog.near,s.fog.far):s.fog.type==="FogExp2"&&(_.fog=new ec(s.fog.color,s.fog.density)),s.fog.name!==""&&(_.fog.name=s.fog.name)),s.backgroundBlurriness!==void 0&&(_.backgroundBlurriness=s.backgroundBlurriness),s.backgroundIntensity!==void 0&&(_.backgroundIntensity=s.backgroundIntensity),s.backgroundRotation!==void 0&&_.backgroundRotation.fromArray(s.backgroundRotation),s.environmentIntensity!==void 0&&(_.environmentIntensity=s.environmentIntensity),s.environmentRotation!==void 0&&_.environmentRotation.fromArray(s.environmentRotation);break;case"PerspectiveCamera":_=new Io(s.fov,s.aspect,s.near,s.far),s.focus!==void 0&&(_.focus=s.focus),s.zoom!==void 0&&(_.zoom=s.zoom),s.filmGauge!==void 0&&(_.filmGauge=s.filmGauge),s.filmOffset!==void 0&&(_.filmOffset=s.filmOffset),s.view!==void 0&&(_.view=Object.assign({},s.view));break;case"OrthographicCamera":_=new Nm(s.left,s.right,s.top,s.bottom,s.near,s.far),s.zoom!==void 0&&(_.zoom=s.zoom),s.view!==void 0&&(_.view=Object.assign({},s.view));break;case"AmbientLight":_=new PS(s.color,s.intensity);break;case"DirectionalLight":_=new Pm(s.color,s.intensity),_.target=s.target||"";break;case"PointLight":_=new vx(s.color,s.intensity,s.distance,s.decay);break;case"RectAreaLight":_=new bx(s.color,s.intensity,s.width,s.height);break;case"SpotLight":_=new RS(s.color,s.intensity,s.distance,s.angle,s.penumbra,s.decay),_.target=s.target||"";break;case"HemisphereLight":_=new CA(s.color,s.groundColor,s.intensity);break;case"LightProbe":_=new IS().fromJSON(s);break;case"SkinnedMesh":R=b(s.geometry),P=T(s.material),_=new U_(R,P),s.bindMode!==void 0&&(_.bindMode=s.bindMode),s.bindMatrix!==void 0&&_.bindMatrix.fromArray(s.bindMatrix),s.skeleton!==void 0&&(_.skeleton=s.skeleton);break;case"Mesh":R=b(s.geometry),P=T(s.material),_=new dl(R,P);break;case"InstancedMesh":R=b(s.geometry),P=T(s.material);const L=s.count,D=s.instanceMatrix,O=s.instanceColor;_=new oa(R,P,L),_.instanceMatrix=new dd(new Float32Array(D.array),16),O!==void 0&&(_.instanceColor=new dd(new Float32Array(O.array),O.itemSize));break;case"BatchedMesh":R=b(s.geometry),P=T(s.material),_=new Tf(s.maxInstanceCount,s.maxVertexCount,s.maxIndexCount,P),_.geometry=R,_.perObjectFrustumCulled=s.perObjectFrustumCulled,_.sortObjects=s.sortObjects,_._drawRanges=s.drawRanges,_._reservedRanges=s.reservedRanges,_._geometryInfo=s.geometryInfo.map(W=>{let Z=null,Y=null;return W.boundingBox!==void 0&&(Z=new fi().fromJSON(W.boundingBox)),W.boundingSphere!==void 0&&(Y=new Ps().fromJSON(W.boundingSphere)),Mo(wi({},W),{boundingBox:Z,boundingSphere:Y})}),_._instanceInfo=s.instanceInfo,_._availableInstanceIds=s._availableInstanceIds,_._availableGeometryIds=s._availableGeometryIds,_._nextIndexStart=s.nextIndexStart,_._nextVertexStart=s.nextVertexStart,_._geometryCount=s.geometryCount,_._maxInstanceCount=s.maxInstanceCount,_._maxVertexCount=s.maxVertexCount,_._maxIndexCount=s.maxIndexCount,_._geometryInitialized=s.geometryInitialized,_._matricesTexture=A(s.matricesTexture.uuid),_._indirectTexture=A(s.indirectTexture.uuid),s.colorsTexture!==void 0&&(_._colorsTexture=A(s.colorsTexture.uuid)),s.boundingSphere!==void 0&&(_.boundingSphere=new Ps().fromJSON(s.boundingSphere)),s.boundingBox!==void 0&&(_.boundingBox=new fi().fromJSON(s.boundingBox));break;case"LOD":_=new qp;break;case"Line":_=new js(b(s.geometry),T(s.material));break;case"LineLoop":_=new sm(b(s.geometry),T(s.material));break;case"LineSegments":_=new md(b(s.geometry),T(s.material));break;case"PointCloud":case"Points":_=new H_(b(s.geometry),T(s.material));break;case"Sprite":_=new ud(T(s.material));break;case"Group":_=new xu;break;case"Bone":_=new n0;break;default:_=new Hs}if(_.uuid=s.uuid,s.name!==void 0&&(_.name=s.name),s.matrix!==void 0?(_.matrix.fromArray(s.matrix),s.matrixAutoUpdate!==void 0&&(_.matrixAutoUpdate=s.matrixAutoUpdate),_.matrixAutoUpdate&&_.matrix.decompose(_.position,_.quaternion,_.scale)):(s.position!==void 0&&_.position.fromArray(s.position),s.rotation!==void 0&&_.rotation.fromArray(s.rotation),s.quaternion!==void 0&&_.quaternion.fromArray(s.quaternion),s.scale!==void 0&&_.scale.fromArray(s.scale)),s.up!==void 0&&_.up.fromArray(s.up),s.castShadow!==void 0&&(_.castShadow=s.castShadow),s.receiveShadow!==void 0&&(_.receiveShadow=s.receiveShadow),s.shadow&&(s.shadow.intensity!==void 0&&(_.shadow.intensity=s.shadow.intensity),s.shadow.bias!==void 0&&(_.shadow.bias=s.shadow.bias),s.shadow.normalBias!==void 0&&(_.shadow.normalBias=s.shadow.normalBias),s.shadow.radius!==void 0&&(_.shadow.radius=s.shadow.radius),s.shadow.mapSize!==void 0&&_.shadow.mapSize.fromArray(s.shadow.mapSize),s.shadow.camera!==void 0&&(_.shadow.camera=this.parseObject(s.shadow.camera))),s.visible!==void 0&&(_.visible=s.visible),s.frustumCulled!==void 0&&(_.frustumCulled=s.frustumCulled),s.renderOrder!==void 0&&(_.renderOrder=s.renderOrder),s.userData!==void 0&&(_.userData=s.userData),s.layers!==void 0&&(_.layers.mask=s.layers),s.children!==void 0){const L=s.children;for(let D=0;D<L.length;D++)_.add(this.parseObject(L[D],l,h,f,g))}if(s.animations!==void 0){const L=s.animations;for(let D=0;D<L.length;D++){const O=L[D];_.animations.push(g[O])}}if(s.type==="LOD"){s.autoUpdate!==void 0&&(_.autoUpdate=s.autoUpdate);const L=s.levels;for(let D=0;D<L.length;D++){const O=L[D],W=_.getObjectByProperty("uuid",O.object);W!==void 0&&_.addLevel(W,O.distance,O.hysteresis)}}return _}bindSkeletons(s,l){Object.keys(l).length!==0&&s.traverse(function(h){if(h.isSkinnedMesh===!0&&h.skeleton!==void 0){const f=l[h.skeleton];f===void 0?Mn("ObjectLoader: No skeleton found with UUID:",h.skeleton):h.bind(f,h.bindMatrix)}})}bindLightTargets(s){s.traverse(function(l){if(l.isDirectionalLight||l.isSpotLight){const h=l.target,f=s.getObjectByProperty("uuid",h);f!==void 0?l.target=f:l.target=new Hs}})}}const L0={UVMapping:_h,CubeReflectionMapping:Cr,CubeRefractionMapping:Xo,EquirectangularReflectionMapping:jc,EquirectangularRefractionMapping:Yc,CubeUVReflectionMapping:Fl},D0={RepeatWrapping:Ea,ClampToEdgeWrapping:ki,MirroredRepeatWrapping:Ca},Tx={NearestFilter:ni,NearestMipmapNearestFilter:Pp,NearestMipmapLinearFilter:Ra,LinearFilter:Yn,LinearMipmapNearestFilter:Zc,LinearMipmapLinearFilter:Vs},F0=new WeakMap;class jL extends null{constructor(s){super(s),this.isImageBitmapLoader=!0,typeof createImageBitmap=="undefined"&&Mn("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch=="undefined"&&Mn("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(s){return this.options=s,this}load(s,l,h,f){s===void 0&&(s=""),this.path!==void 0&&(s=this.path+s),s=this.manager.resolveURL(s);const g=this,_=Bo.get(`image-bitmap:${s}`);if(_!==void 0){if(g.manager.itemStart(s),_.then){_.then(A=>{if(F0.has(_)===!0)f&&f(F0.get(_)),g.manager.itemError(s),g.manager.itemEnd(s);else return l&&l(A),g.manager.itemEnd(s),A});return}return setTimeout(function(){l&&l(_),g.manager.itemEnd(s)},0),_}const b={};b.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",b.headers=this.requestHeader,b.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const T=fetch(s,b).then(function(A){return A.blob()}).then(function(A){return createImageBitmap(A,Object.assign(g.options,{colorSpaceConversion:"none"}))}).then(function(A){return Bo.add(`image-bitmap:${s}`,A),l&&l(A),g.manager.itemEnd(s),A}).catch(function(A){f&&f(A),F0.set(T,A),Bo.remove(`image-bitmap:${s}`),g.manager.itemError(s),g.manager.itemEnd(s)});Bo.add(`image-bitmap:${s}`,T),g.manager.itemStart(s)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let Lm;class B0{static getContext(){return Lm===void 0&&(Lm=new(window.AudioContext||window.webkitAudioContext)),Lm}static setContext(s){Lm=s}}class DS extends null{constructor(s){super(s)}load(s,l,h,f){const g=this,_=new pc(this.manager);_.setResponseType("arraybuffer"),_.setPath(this.path),_.setRequestHeader(this.requestHeader),_.setWithCredentials(this.withCredentials),_.load(s,function(T){try{const A=T.slice(0);B0.getContext().decodeAudioData(A,function(P){l(P)}).catch(b)}catch(A){b(A)}},h,f);function b(T){f?f(T):ci(T),g.manager.itemError(s)}}}const Dm=new Dn,FS=new Dn,Wa=new Dn;class BS{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new Io,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new Io,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(s){const l=this._cache;if(l.focus!==s.focus||l.fov!==s.fov||l.aspect!==s.aspect*this.aspect||l.near!==s.near||l.far!==s.far||l.zoom!==s.zoom||l.eyeSep!==this.eyeSep){l.focus=s.focus,l.fov=s.fov,l.aspect=s.aspect*this.aspect,l.near=s.near,l.far=s.far,l.zoom=s.zoom,l.eyeSep=this.eyeSep,Wa.copy(s.projectionMatrix);const f=l.eyeSep/2,g=f*l.near/l.focus,_=l.near*Math.tan(Ko*l.fov*.5)/l.zoom;let b,T;FS.elements[12]=-f,Dm.elements[12]=f,b=-_*l.aspect+g,T=_*l.aspect+g,Wa.elements[0]=2*l.near/(T-b),Wa.elements[8]=(T+b)/(T-b),this.cameraL.projectionMatrix.copy(Wa),b=-_*l.aspect-g,T=_*l.aspect-g,Wa.elements[0]=2*l.near/(T-b),Wa.elements[8]=(T+b)/(T-b),this.cameraR.projectionMatrix.copy(Wa)}this.cameraL.matrixWorld.copy(s.matrixWorld).multiply(FS),this.cameraR.matrixWorld.copy(s.matrixWorld).multiply(Dm)}}class YL extends null{constructor(s=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=s}}class wx{constructor(s=!0){this.autoStart=s,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 s=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const l=performance.now();s=(l-this.oldTime)/1e3,this.oldTime=l,this.elapsedTime+=s}return s}}const _c=new ae,_l=new ro,NA=new ae,xc=new ae,xl=new ae;class Ld extends null{constructor(){super(),this.type="AudioListener",this.context=B0.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new wx}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(s){return this.filter!==null?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination),this.filter=s,this.gain.connect(this.filter),this.filter.connect(this.context.destination),this}getMasterVolume(){return this.gain.gain.value}setMasterVolume(s){return this.gain.gain.setTargetAtTime(s,this.context.currentTime,.01),this}updateMatrixWorld(s){super.updateMatrixWorld(s);const l=this.context.listener;if(this.timeDelta=this._clock.getDelta(),this.matrixWorld.decompose(_c,_l,NA),xc.set(0,0,-1).applyQuaternion(_l),xl.set(0,1,0).applyQuaternion(_l),l.positionX){const h=this.context.currentTime+this.timeDelta;l.positionX.linearRampToValueAtTime(_c.x,h),l.positionY.linearRampToValueAtTime(_c.y,h),l.positionZ.linearRampToValueAtTime(_c.z,h),l.forwardX.linearRampToValueAtTime(xc.x,h),l.forwardY.linearRampToValueAtTime(xc.y,h),l.forwardZ.linearRampToValueAtTime(xc.z,h),l.upX.linearRampToValueAtTime(xl.x,h),l.upY.linearRampToValueAtTime(xl.y,h),l.upZ.linearRampToValueAtTime(xl.z,h)}else l.setPosition(_c.x,_c.y,_c.z),l.setOrientation(xc.x,xc.y,xc.z,xl.x,xl.y,xl.z)}}class Ax extends null{constructor(s){super(),this.type="Audio",this.listener=s,this.context=s.context,this.gain=this.context.createGain(),this.gain.connect(s.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(s){return this.hasPlaybackControl=!1,this.sourceType="audioNode",this.source=s,this.connect(),this}setMediaElementSource(s){return this.hasPlaybackControl=!1,this.sourceType="mediaNode",this.source=this.context.createMediaElementSource(s),this.connect(),this}setMediaStreamSource(s){return this.hasPlaybackControl=!1,this.sourceType="mediaStreamNode",this.source=this.context.createMediaStreamSource(s),this.connect(),this}setBuffer(s){return this.buffer=s,this.sourceType="buffer",this.autoplay&&this.play(),this}play(s=0){if(this.isPlaying===!0){Mn("Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){Mn("Audio: this Audio has no playback control.");return}this._startedAt=this.context.currentTime+s;const l=this.context.createBufferSource();return l.buffer=this.buffer,l.loop=this.loop,l.loopStart=this.loopStart,l.loopEnd=this.loopEnd,l.onended=this.onEnded.bind(this),l.start(this._startedAt,this._progress+this.offset,this.duration),this.isPlaying=!0,this.source=l,this.setDetune(this.detune),this.setPlaybackRate(this.playbackRate),this.connect()}pause(){if(this.hasPlaybackControl===!1){Mn("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(s=0){if(this.hasPlaybackControl===!1){Mn("Audio: this Audio has no playback control.");return}return this._progress=0,this.source!==null&&(this.source.stop(this.context.currentTime+s),this.source.onended=null),this.isPlaying=!1,this}connect(){if(this.filters.length>0){this.source.connect(this.filters[0]);for(let s=1,l=this.filters.length;s<l;s++)this.filters[s-1].connect(this.filters[s]);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 s=1,l=this.filters.length;s<l;s++)this.filters[s-1].disconnect(this.filters[s]);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(s){return s||(s=[]),this._connected===!0?(this.disconnect(),this.filters=s.slice(),this.connect()):this.filters=s.slice(),this}setDetune(s){return this.detune=s,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(s){return this.setFilters(s?[s]:[])}setPlaybackRate(s){if(this.hasPlaybackControl===!1){Mn("Audio: this Audio has no playback control.");return}return this.playbackRate=s,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?(Mn("Audio: this Audio has no playback control."),!1):this.loop}setLoop(s){if(this.hasPlaybackControl===!1){Mn("Audio: this Audio has no playback control.");return}return this.loop=s,this.isPlaying===!0&&(this.source.loop=this.loop),this}setLoopStart(s){return this.loopStart=s,this}setLoopEnd(s){return this.loopEnd=s,this}getVolume(){return this.gain.gain.value}setVolume(s){return this.gain.gain.setTargetAtTime(s,this.context.currentTime,.01),this}copy(s,l){return super.copy(s,l),s.sourceType!=="buffer"?(Mn("Audio: Audio source type cannot be copied."),this):(this.autoplay=s.autoplay,this.buffer=s.buffer,this.detune=s.detune,this.loop=s.loop,this.loopStart=s.loopStart,this.loopEnd=s.loopEnd,this.offset=s.offset,this.duration=s.duration,this.playbackRate=s.playbackRate,this.hasPlaybackControl=s.hasPlaybackControl,this.sourceType=s.sourceType,this.filters=s.filters.slice(),this)}clone(s){return new this.constructor(this.listener).copy(this,s)}}const qu=new ae,vc=new ro,Xu=new ae,Dd=new ae;class ZL extends null{constructor(s){super(s),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(s){return this.panner.refDistance=s,this}getRolloffFactor(){return this.panner.rolloffFactor}setRolloffFactor(s){return this.panner.rolloffFactor=s,this}getDistanceModel(){return this.panner.distanceModel}setDistanceModel(s){return this.panner.distanceModel=s,this}getMaxDistance(){return this.panner.maxDistance}setMaxDistance(s){return this.panner.maxDistance=s,this}setDirectionalCone(s,l,h){return this.panner.coneInnerAngle=s,this.panner.coneOuterAngle=l,this.panner.coneOuterGain=h,this}updateMatrixWorld(s){if(super.updateMatrixWorld(s),this.hasPlaybackControl===!0&&this.isPlaying===!1)return;this.matrixWorld.decompose(qu,vc,Xu),Dd.set(0,0,1).applyQuaternion(vc);const l=this.panner;if(l.positionX){const h=this.context.currentTime+this.listener.timeDelta;l.positionX.linearRampToValueAtTime(qu.x,h),l.positionY.linearRampToValueAtTime(qu.y,h),l.positionZ.linearRampToValueAtTime(qu.z,h),l.orientationX.linearRampToValueAtTime(Dd.x,h),l.orientationY.linearRampToValueAtTime(Dd.y,h),l.orientationZ.linearRampToValueAtTime(Dd.z,h)}else l.setPosition(qu.x,qu.y,qu.z),l.setOrientation(Dd.x,Dd.y,Dd.z)}}class Fd{constructor(s,l=2048){this.analyser=s.context.createAnalyser(),this.analyser.fftSize=l,this.data=new Uint8Array(this.analyser.frequencyBinCount),s.getOutput().connect(this.analyser)}getFrequencyData(){return this.analyser.getByteFrequencyData(this.data),this.data}getAverageFrequency(){let s=0;const l=this.getFrequencyData();for(let h=0;h<l.length;h++)s+=l[h];return s/l.length}}class Ex{constructor(s,l,h){this.binding=s,this.valueSize=h;let f,g,_;switch(l){case"quaternion":f=this._slerp,g=this._slerpAdditive,_=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(h*6),this._workIndex=5;break;case"string":case"bool":f=this._select,g=this._select,_=this._setAdditiveIdentityOther,this.buffer=new Array(h*5);break;default:f=this._lerp,g=this._lerpAdditive,_=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(h*5)}this._mixBufferRegion=f,this._mixBufferRegionAdditive=g,this._setIdentity=_,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(s,l){const h=this.buffer,f=this.valueSize,g=s*f+f;let _=this.cumulativeWeight;if(_===0){for(let b=0;b!==f;++b)h[g+b]=h[b];_=l}else{_+=l;const b=l/_;this._mixBufferRegion(h,g,0,b,f)}this.cumulativeWeight=_}accumulateAdditive(s){const l=this.buffer,h=this.valueSize,f=h*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(l,f,0,s,h),this.cumulativeWeightAdditive+=s}apply(s){const l=this.valueSize,h=this.buffer,f=s*l+l,g=this.cumulativeWeight,_=this.cumulativeWeightAdditive,b=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,g<1){const T=l*this._origIndex;this._mixBufferRegion(h,f,T,1-g,l)}_>0&&this._mixBufferRegionAdditive(h,f,this._addIndex*l,1,l);for(let T=l,A=l+l;T!==A;++T)if(h[T]!==h[T+l]){b.setValue(h,f);break}}saveOriginalState(){const s=this.binding,l=this.buffer,h=this.valueSize,f=h*this._origIndex;s.getValue(l,f);for(let g=h,_=f;g!==_;++g)l[g]=l[f+g%h];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const s=this.valueSize*3;this.binding.setValue(this.buffer,s)}_setAdditiveIdentityNumeric(){const s=this._addIndex*this.valueSize,l=s+this.valueSize;for(let h=s;h<l;h++)this.buffer[h]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const s=this._origIndex*this.valueSize,l=this._addIndex*this.valueSize;for(let h=0;h<this.valueSize;h++)this.buffer[l+h]=this.buffer[s+h]}_select(s,l,h,f,g){if(f>=.5)for(let _=0;_!==g;++_)s[l+_]=s[h+_]}_slerp(s,l,h,f){ro.slerpFlat(s,l,s,l,s,h,f)}_slerpAdditive(s,l,h,f,g){const _=this._workIndex*g;ro.multiplyQuaternionsFlat(s,_,s,l,s,h),ro.slerpFlat(s,l,s,l,s,_,f)}_lerp(s,l,h,f,g){const _=1-f;for(let b=0;b!==g;++b){const T=l+b;s[T]=s[T]*_+s[h+b]*f}}_lerpAdditive(s,l,h,f,g){for(let _=0;_!==g;++_){const b=l+_;s[b]=s[b]+s[h+_]*f}}}const O0="\\[\\]\\.:\\/",ju=new RegExp("["+O0+"]","g"),Cx="[^"+O0+"]",PA="[^"+O0.replace("\\.","")+"]",OS=/((?:WC+[\/:])*)/.source.replace("WC",Cx),U0=/(WCOD+)?/.source.replace("WCOD",PA),US=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Cx),k0=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Cx),kS=new RegExp("^"+OS+U0+US+k0+"$"),zS=["material","materials","bones","map"];class VS{constructor(s,l,h){const f=h||vi.parseTrackName(l);this._targetGroup=s,this._bindings=s.subscribe_(l,f)}getValue(s,l){this.bind();const h=this._targetGroup.nCachedObjects_,f=this._bindings[h];f!==void 0&&f.getValue(s,l)}setValue(s,l){const h=this._bindings;for(let f=this._targetGroup.nCachedObjects_,g=h.length;f!==g;++f)h[f].setValue(s,l)}bind(){const s=this._bindings;for(let l=this._targetGroup.nCachedObjects_,h=s.length;l!==h;++l)s[l].bind()}unbind(){const s=this._bindings;for(let l=this._targetGroup.nCachedObjects_,h=s.length;l!==h;++l)s[l].unbind()}}class vi{constructor(s,l,h){this.path=l,this.parsedPath=h||vi.parseTrackName(l),this.node=vi.findNode(s,this.parsedPath.nodeName),this.rootNode=s,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(s,l,h){return s&&s.isAnimationObjectGroup?new vi.Composite(s,l,h):new vi(s,l,h)}static sanitizeNodeName(s){return s.replace(/\s/g,"_").replace(ju,"")}static parseTrackName(s){const l=kS.exec(s);if(l===null)throw new Error("PropertyBinding: Cannot parse trackName: "+s);const h={nodeName:l[2],objectName:l[3],objectIndex:l[4],propertyName:l[5],propertyIndex:l[6]},f=h.nodeName&&h.nodeName.lastIndexOf(".");if(f!==void 0&&f!==-1){const g=h.nodeName.substring(f+1);zS.indexOf(g)!==-1&&(h.nodeName=h.nodeName.substring(0,f),h.objectName=g)}if(h.propertyName===null||h.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+s);return h}static findNode(s,l){if(l===void 0||l===""||l==="."||l===-1||l===s.name||l===s.uuid)return s;if(s.skeleton){const h=s.skeleton.getBoneByName(l);if(h!==void 0)return h}if(s.children){const h=function(g){for(let _=0;_<g.length;_++){const b=g[_];if(b.name===l||b.uuid===l)return b;const T=h(b.children);if(T)return T}return null},f=h(s.children);if(f)return f}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(s,l){s[l]=this.targetObject[this.propertyName]}_getValue_array(s,l){const h=this.resolvedProperty;for(let f=0,g=h.length;f!==g;++f)s[l++]=h[f]}_getValue_arrayElement(s,l){s[l]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(s,l){this.resolvedProperty.toArray(s,l)}_setValue_direct(s,l){this.targetObject[this.propertyName]=s[l]}_setValue_direct_setNeedsUpdate(s,l){this.targetObject[this.propertyName]=s[l],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(s,l){this.targetObject[this.propertyName]=s[l],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(s,l){const h=this.resolvedProperty;for(let f=0,g=h.length;f!==g;++f)h[f]=s[l++]}_setValue_array_setNeedsUpdate(s,l){const h=this.resolvedProperty;for(let f=0,g=h.length;f!==g;++f)h[f]=s[l++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(s,l){const h=this.resolvedProperty;for(let f=0,g=h.length;f!==g;++f)h[f]=s[l++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(s,l){this.resolvedProperty[this.propertyIndex]=s[l]}_setValue_arrayElement_setNeedsUpdate(s,l){this.resolvedProperty[this.propertyIndex]=s[l],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(s,l){this.resolvedProperty[this.propertyIndex]=s[l],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(s,l){this.resolvedProperty.fromArray(s,l)}_setValue_fromArray_setNeedsUpdate(s,l){this.resolvedProperty.fromArray(s,l),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(s,l){this.resolvedProperty.fromArray(s,l),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(s,l){this.bind(),this.getValue(s,l)}_setValue_unbound(s,l){this.bind(),this.setValue(s,l)}bind(){let s=this.node;const l=this.parsedPath,h=l.objectName,f=l.propertyName;let g=l.propertyIndex;if(s||(s=vi.findNode(this.rootNode,l.nodeName),this.node=s),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!s){Mn("PropertyBinding: No target node found for track: "+this.path+".");return}if(h){let A=l.objectIndex;switch(h){case"materials":if(!s.material){ci("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!s.material.materials){ci("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}s=s.material.materials;break;case"bones":if(!s.skeleton){ci("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}s=s.skeleton.bones;for(let R=0;R<s.length;R++)if(s[R].name===A){A=R;break}break;case"map":if("map"in s){s=s.map;break}if(!s.material){ci("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!s.material.map){ci("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}s=s.material.map;break;default:if(s[h]===void 0){ci("PropertyBinding: Can not bind to objectName of node undefined.",this);return}s=s[h]}if(A!==void 0){if(s[A]===void 0){ci("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,s);return}s=s[A]}}const _=s[f];if(_===void 0){const A=l.nodeName;ci("PropertyBinding: Trying to update property for track: "+A+"."+f+" but it wasn't found.",s);return}let b=this.Versioning.None;this.targetObject=s,s.isMaterial===!0?b=this.Versioning.NeedsUpdate:s.isObject3D===!0&&(b=this.Versioning.MatrixWorldNeedsUpdate);let T=this.BindingType.Direct;if(g!==void 0){if(f==="morphTargetInfluences"){if(!s.geometry){ci("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!s.geometry.morphAttributes){ci("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}s.morphTargetDictionary[g]!==void 0&&(g=s.morphTargetDictionary[g])}T=this.BindingType.ArrayElement,this.resolvedProperty=_,this.propertyIndex=g}else _.fromArray!==void 0&&_.toArray!==void 0?(T=this.BindingType.HasFromToArray,this.resolvedProperty=_):Array.isArray(_)?(T=this.BindingType.EntireArray,this.resolvedProperty=_):this.propertyName=f;this.getValue=this.GetterByBindingType[T],this.setValue=this.SetterByBindingTypeAndVersioning[T][b]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}vi.Composite=VS,vi.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},vi.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},vi.prototype.GetterByBindingType=[vi.prototype._getValue_direct,vi.prototype._getValue_array,vi.prototype._getValue_arrayElement,vi.prototype._getValue_toArray],vi.prototype.SetterByBindingTypeAndVersioning=[[vi.prototype._setValue_direct,vi.prototype._setValue_direct_setNeedsUpdate,vi.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[vi.prototype._setValue_array,vi.prototype._setValue_array_setNeedsUpdate,vi.prototype._setValue_array_setMatrixWorldNeedsUpdate],[vi.prototype._setValue_arrayElement,vi.prototype._setValue_arrayElement_setNeedsUpdate,vi.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[vi.prototype._setValue_fromArray,vi.prototype._setValue_fromArray_setNeedsUpdate,vi.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class IA{constructor(){this.isAnimationObjectGroup=!0,this.uuid=Be(),this._objects=Array.prototype.slice.call(arguments),this.nCachedObjects_=0;const s={};this._indicesByUUID=s;for(let h=0,f=arguments.length;h!==f;++h)s[arguments[h].uuid]=h;this._paths=[],this._parsedPaths=[],this._bindings=[],this._bindingsIndicesByPath={};const l=this;this.stats={objects:{get total(){return l._objects.length},get inUse(){return this.total-l.nCachedObjects_}},get bindingsPerObject(){return l._bindings.length}}}add(){const s=this._objects,l=this._indicesByUUID,h=this._paths,f=this._parsedPaths,g=this._bindings,_=g.length;let b,T=s.length,A=this.nCachedObjects_;for(let R=0,P=arguments.length;R!==P;++R){const L=arguments[R],D=L.uuid;let O=l[D];if(O===void 0){O=T++,l[D]=O,s.push(L);for(let W=0,Z=_;W!==Z;++W)g[W].push(new vi(L,h[W],f[W]))}else if(O<A){b=s[O];const W=--A,Z=s[W];l[Z.uuid]=O,s[O]=Z,l[D]=W,s[W]=L;for(let Y=0,ie=_;Y!==ie;++Y){const se=g[Y],de=se[W];let ke=se[O];se[O]=de,ke===void 0&&(ke=new vi(L,h[Y],f[Y])),se[W]=ke}}else s[O]!==b&&ci("AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=A}remove(){const s=this._objects,l=this._indicesByUUID,h=this._bindings,f=h.length;let g=this.nCachedObjects_;for(let _=0,b=arguments.length;_!==b;++_){const T=arguments[_],A=T.uuid,R=l[A];if(R!==void 0&&R>=g){const P=g++,L=s[P];l[L.uuid]=R,s[R]=L,l[A]=P,s[P]=T;for(let D=0,O=f;D!==O;++D){const W=h[D],Z=W[P],Y=W[R];W[R]=Z,W[P]=Y}}}this.nCachedObjects_=g}uncache(){const s=this._objects,l=this._indicesByUUID,h=this._bindings,f=h.length;let g=this.nCachedObjects_,_=s.length;for(let b=0,T=arguments.length;b!==T;++b){const A=arguments[b],R=A.uuid,P=l[R];if(P!==void 0)if(delete l[R],P<g){const L=--g,D=s[L],O=--_,W=s[O];l[D.uuid]=P,s[P]=D,l[W.uuid]=L,s[L]=W,s.pop();for(let Z=0,Y=f;Z!==Y;++Z){const ie=h[Z],se=ie[L],de=ie[O];ie[P]=se,ie[L]=de,ie.pop()}}else{const L=--_,D=s[L];L>0&&(l[D.uuid]=P),s[P]=D,s.pop();for(let O=0,W=f;O!==W;++O){const Z=h[O];Z[P]=Z[L],Z.pop()}}}this.nCachedObjects_=g}subscribe_(s,l){const h=this._bindingsIndicesByPath;let f=h[s];const g=this._bindings;if(f!==void 0)return g[f];const _=this._paths,b=this._parsedPaths,T=this._objects,A=T.length,R=this.nCachedObjects_,P=new Array(A);f=g.length,h[s]=f,_.push(s),b.push(l),g.push(P);for(let L=R,D=T.length;L!==D;++L){const O=T[L];P[L]=new vi(O,s,l)}return P}unsubscribe_(s){const l=this._bindingsIndicesByPath,h=l[s];if(h!==void 0){const f=this._paths,g=this._parsedPaths,_=this._bindings,b=_.length-1,T=_[b],A=s[b];l[A]=h,_[h]=T,_.pop(),g[h]=g[b],g.pop(),f[h]=f[b],f.pop()}}}class GS{constructor(s,l,h=null,f=l.blendMode){this._mixer=s,this._clip=l,this._localRoot=h,this.blendMode=f;const g=l.tracks,_=g.length,b=new Array(_),T={endingStart:Hh,endingEnd:Hh};for(let A=0;A!==_;++A){const R=g[A].createInterpolant(null);b[A]=R,R.settings=T}this._interpolantSettings=T,this._interpolants=b,this._propertyBindings=new Array(_),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Wh,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(s){return this._startTime=s,this}setLoop(s,l){return this.loop=s,this.repetitions=l,this}setEffectiveWeight(s){return this.weight=s,this._effectiveWeight=this.enabled?s:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(s){return this._scheduleFading(s,0,1)}fadeOut(s){return this._scheduleFading(s,1,0)}crossFadeFrom(s,l,h=!1){if(s.fadeOut(l),this.fadeIn(l),h===!0){const f=this._clip.duration,g=s._clip.duration,_=g/f,b=f/g;s.warp(1,_,l),this.warp(b,1,l)}return this}crossFadeTo(s,l,h=!1){return s.crossFadeFrom(this,l,h)}stopFading(){const s=this._weightInterpolant;return s!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(s)),this}setEffectiveTimeScale(s){return this.timeScale=s,this._effectiveTimeScale=this.paused?0:s,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(s){return this.timeScale=this._clip.duration/s,this.stopWarping()}syncWith(s){return this.time=s.time,this.timeScale=s.timeScale,this.stopWarping()}halt(s){return this.warp(this._effectiveTimeScale,0,s)}warp(s,l,h){const f=this._mixer,g=f.time,_=this.timeScale;let b=this._timeScaleInterpolant;b===null&&(b=f._lendControlInterpolant(),this._timeScaleInterpolant=b);const T=b.parameterPositions,A=b.sampleValues;return T[0]=g,T[1]=g+h,A[0]=s/_,A[1]=l/_,this}stopWarping(){const s=this._timeScaleInterpolant;return s!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(s)),this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(s,l,h,f){if(!this.enabled){this._updateWeight(s);return}const g=this._startTime;if(g!==null){const T=(s-g)*h;T<0||h===0?l=0:(this._startTime=null,l=h*T)}l*=this._updateTimeScale(s);const _=this._updateTime(l),b=this._updateWeight(s);if(b>0){const T=this._interpolants,A=this._propertyBindings;switch(this.blendMode){case nu:for(let R=0,P=T.length;R!==P;++R)T[R].evaluate(_),A[R].accumulateAdditive(b);break;case af:default:for(let R=0,P=T.length;R!==P;++R)T[R].evaluate(_),A[R].accumulate(f,b)}}}_updateWeight(s){let l=0;if(this.enabled){l=this.weight;const h=this._weightInterpolant;if(h!==null){const f=h.evaluate(s)[0];l*=f,s>h.parameterPositions[1]&&(this.stopFading(),f===0&&(this.enabled=!1))}}return this._effectiveWeight=l,l}_updateTimeScale(s){let l=0;if(!this.paused){l=this.timeScale;const h=this._timeScaleInterpolant;if(h!==null){const f=h.evaluate(s)[0];l*=f,s>h.parameterPositions[1]&&(this.stopWarping(),l===0?this.paused=!0:this.timeScale=l)}}return this._effectiveTimeScale=l,l}_updateTime(s){const l=this._clip.duration,h=this.loop;let f=this.time+s,g=this._loopCount;const _=h===tu;if(s===0)return g===-1?f:_&&(g&1)===1?l-f:f;if(h===Gh){g===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));e:{if(f>=l)f=l;else if(f<0)f=0;else{this.time=f;break e}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=f,this._mixer.dispatchEvent({type:"finished",action:this,direction:s<0?-1:1})}}else{if(g===-1&&(s>=0?(g=0,this._setEndings(!0,this.repetitions===0,_)):this._setEndings(this.repetitions===0,!0,_)),f>=l||f<0){const b=Math.floor(f/l);f-=l*b,g+=Math.abs(b);const T=this.repetitions-g;if(T<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,f=s>0?l:0,this.time=f,this._mixer.dispatchEvent({type:"finished",action:this,direction:s>0?1:-1});else{if(T===1){const A=s<0;this._setEndings(A,!A,_)}else this._setEndings(!1,!1,_);this._loopCount=g,this.time=f,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:b})}}else this.time=f;if(_&&(g&1)===1)return l-f}return f}_setEndings(s,l,h){const f=this._interpolantSettings;h?(f.endingStart=sl,f.endingEnd=sl):(s?f.endingStart=this.zeroSlopeAtStart?sl:Hh:f.endingStart=$h,l?f.endingEnd=this.zeroSlopeAtEnd?sl:Hh:f.endingEnd=$h)}_scheduleFading(s,l,h){const f=this._mixer,g=f.time;let _=this._weightInterpolant;_===null&&(_=f._lendControlInterpolant(),this._weightInterpolant=_);const b=_.parameterPositions,T=_.sampleValues;return b[0]=g,T[0]=l,b[1]=g+s,T[1]=h,this}}const WS=new Float32Array(1);class LA extends null{constructor(s){super(),this._root=s,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1}_bindAction(s,l){const h=s._localRoot||this._root,f=s._clip.tracks,g=f.length,_=s._propertyBindings,b=s._interpolants,T=h.uuid,A=this._bindingsByRootAndName;let R=A[T];R===void 0&&(R={},A[T]=R);for(let P=0;P!==g;++P){const L=f[P],D=L.name;let O=R[D];if(O!==void 0)++O.referenceCount,_[P]=O;else{if(O=_[P],O!==void 0){O._cacheIndex===null&&(++O.referenceCount,this._addInactiveBinding(O,T,D));continue}const W=l&&l._propertyBindings[P].binding.parsedPath;O=new Ex(vi.create(h,D,W),L.ValueTypeName,L.getValueSize()),++O.referenceCount,this._addInactiveBinding(O,T,D),_[P]=O}b[P].resultBuffer=O.buffer}}_activateAction(s){if(!this._isActiveAction(s)){if(s._cacheIndex===null){const h=(s._localRoot||this._root).uuid,f=s._clip.uuid,g=this._actionsByClip[f];this._bindAction(s,g&&g.knownActions[0]),this._addInactiveAction(s,f,h)}const l=s._propertyBindings;for(let h=0,f=l.length;h!==f;++h){const g=l[h];g.useCount++===0&&(this._lendBinding(g),g.saveOriginalState())}this._lendAction(s)}}_deactivateAction(s){if(this._isActiveAction(s)){const l=s._propertyBindings;for(let h=0,f=l.length;h!==f;++h){const g=l[h];--g.useCount===0&&(g.restoreOriginalState(),this._takeBackBinding(g))}this._takeBackAction(s)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const s=this;this.stats={actions:{get total(){return s._actions.length},get inUse(){return s._nActiveActions}},bindings:{get total(){return s._bindings.length},get inUse(){return s._nActiveBindings}},controlInterpolants:{get total(){return s._controlInterpolants.length},get inUse(){return s._nActiveControlInterpolants}}}}_isActiveAction(s){const l=s._cacheIndex;return l!==null&&l<this._nActiveActions}_addInactiveAction(s,l,h){const f=this._actions,g=this._actionsByClip;let _=g[l];if(_===void 0)_={knownActions:[s],actionByRoot:{}},s._byClipCacheIndex=0,g[l]=_;else{const b=_.knownActions;s._byClipCacheIndex=b.length,b.push(s)}s._cacheIndex=f.length,f.push(s),_.actionByRoot[h]=s}_removeInactiveAction(s){const l=this._actions,h=l[l.length-1],f=s._cacheIndex;h._cacheIndex=f,l[f]=h,l.pop(),s._cacheIndex=null;const g=s._clip.uuid,_=this._actionsByClip,b=_[g],T=b.knownActions,A=T[T.length-1],R=s._byClipCacheIndex;A._byClipCacheIndex=R,T[R]=A,T.pop(),s._byClipCacheIndex=null;const P=b.actionByRoot,L=(s._localRoot||this._root).uuid;delete P[L],T.length===0&&delete _[g],this._removeInactiveBindingsForAction(s)}_removeInactiveBindingsForAction(s){const l=s._propertyBindings;for(let h=0,f=l.length;h!==f;++h){const g=l[h];--g.referenceCount===0&&this._removeInactiveBinding(g)}}_lendAction(s){const l=this._actions,h=s._cacheIndex,f=this._nActiveActions++,g=l[f];s._cacheIndex=f,l[f]=s,g._cacheIndex=h,l[h]=g}_takeBackAction(s){const l=this._actions,h=s._cacheIndex,f=--this._nActiveActions,g=l[f];s._cacheIndex=f,l[f]=s,g._cacheIndex=h,l[h]=g}_addInactiveBinding(s,l,h){const f=this._bindingsByRootAndName,g=this._bindings;let _=f[l];_===void 0&&(_={},f[l]=_),_[h]=s,s._cacheIndex=g.length,g.push(s)}_removeInactiveBinding(s){const l=this._bindings,h=s.binding,f=h.rootNode.uuid,g=h.path,_=this._bindingsByRootAndName,b=_[f],T=l[l.length-1],A=s._cacheIndex;T._cacheIndex=A,l[A]=T,l.pop(),delete b[g],Object.keys(b).length===0&&delete _[f]}_lendBinding(s){const l=this._bindings,h=s._cacheIndex,f=this._nActiveBindings++,g=l[f];s._cacheIndex=f,l[f]=s,g._cacheIndex=h,l[h]=g}_takeBackBinding(s){const l=this._bindings,h=s._cacheIndex,f=--this._nActiveBindings,g=l[f];s._cacheIndex=f,l[f]=s,g._cacheIndex=h,l[h]=g}_lendControlInterpolant(){const s=this._controlInterpolants,l=this._nActiveControlInterpolants++;let h=s[l];return h===void 0&&(h=new N0(new Float32Array(2),new Float32Array(2),1,WS),h.__cacheIndex=l,s[l]=h),h}_takeBackControlInterpolant(s){const l=this._controlInterpolants,h=s.__cacheIndex,f=--this._nActiveControlInterpolants,g=l[f];s.__cacheIndex=f,l[f]=s,g.__cacheIndex=h,l[h]=g}clipAction(s,l,h){const f=l||this._root,g=f.uuid;let _=typeof s=="string"?Kr.findByName(f,s):s;const b=_!==null?_.uuid:s,T=this._actionsByClip[b];let A=null;if(h===void 0&&(_!==null?h=_.blendMode:h=af),T!==void 0){const P=T.actionByRoot[g];if(P!==void 0&&P.blendMode===h)return P;A=T.knownActions[0],_===null&&(_=A._clip)}if(_===null)return null;const R=new GS(this,_,l,h);return this._bindAction(R,A),this._addInactiveAction(R,b,g),R}existingAction(s,l){const h=l||this._root,f=h.uuid,g=typeof s=="string"?Kr.findByName(h,s):s,_=g?g.uuid:s,b=this._actionsByClip[_];return b!==void 0&&b.actionByRoot[f]||null}stopAllAction(){const s=this._actions,l=this._nActiveActions;for(let h=l-1;h>=0;--h)s[h].stop();return this}update(s){s*=this.timeScale;const l=this._actions,h=this._nActiveActions,f=this.time+=s,g=Math.sign(s),_=this._accuIndex^=1;for(let A=0;A!==h;++A)l[A]._update(f,s,g,_);const b=this._bindings,T=this._nActiveBindings;for(let A=0;A!==T;++A)b[A].apply(_);return this}setTime(s){this.time=0;for(let l=0;l<this._actions.length;l++)this._actions[l].time=0;return this.update(s)}getRoot(){return this._root}uncacheClip(s){const l=this._actions,h=s.uuid,f=this._actionsByClip,g=f[h];if(g!==void 0){const _=g.knownActions;for(let b=0,T=_.length;b!==T;++b){const A=_[b];this._deactivateAction(A);const R=A._cacheIndex,P=l[l.length-1];A._cacheIndex=null,A._byClipCacheIndex=null,P._cacheIndex=R,l[R]=P,l.pop(),this._removeInactiveBindingsForAction(A)}delete f[h]}}uncacheRoot(s){const l=s.uuid,h=this._actionsByClip;for(const _ in h){const b=h[_].actionByRoot,T=b[l];T!==void 0&&(this._deactivateAction(T),this._removeInactiveAction(T))}const f=this._bindingsByRootAndName,g=f[l];if(g!==void 0)for(const _ in g){const b=g[_];b.restoreOriginalState(),this._removeInactiveBinding(b)}}uncacheAction(s,l){const h=this.existingAction(s,l);h!==null&&(this._deactivateAction(h),this._removeInactiveAction(h))}}class Mi extends null{constructor(s=1,l=1,h=1,f={}){super(s,l,f),this.isRenderTarget3D=!0,this.depth=h,this.texture=new E_(null,s,l,h),this._setTextureOptions(f),this.texture.isRenderTargetTexture=!0}}class HS{constructor(s){this.value=s}clone(){return new HS(this.value.clone===void 0?this.value:this.value.clone())}}let $S=0;class DA extends null{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:$S++}),this.name="",this.usage=Vl,this.uniforms=[]}add(s){return this.uniforms.push(s),this}remove(s){const l=this.uniforms.indexOf(s);return l!==-1&&this.uniforms.splice(l,1),this}setName(s){return this.name=s,this}setUsage(s){return this.usage=s,this}dispose(){this.dispatchEvent({type:"dispose"})}copy(s){this.name=s.name,this.usage=s.usage;const l=s.uniforms;this.uniforms.length=0;for(let h=0,f=l.length;h<f;h++){const g=Array.isArray(l[h])?l[h]:[l[h]];for(let _=0;_<g.length;_++)this.uniforms.push(g[_].clone())}return this}clone(){return new this.constructor().copy(this)}}class KL extends null{constructor(s,l,h=1){super(s,l),this.isInstancedInterleavedBuffer=!0,this.meshPerAttribute=h}copy(s){return super.copy(s),this.meshPerAttribute=s.meshPerAttribute,this}clone(s){const l=super.clone(s);return l.meshPerAttribute=this.meshPerAttribute,l}toJSON(s){const l=super.toJSON(s);return l.isInstancedInterleavedBuffer=!0,l.meshPerAttribute=this.meshPerAttribute,l}}class JL{constructor(s,l,h,f,g,_=!1){this.isGLBufferAttribute=!0,this.name="",this.buffer=s,this.type=l,this.itemSize=h,this.elementSize=f,this.count=g,this.normalized=_,this.version=0}set needsUpdate(s){s===!0&&this.version++}setBuffer(s){return this.buffer=s,this}setType(s,l){return this.type=s,this.elementSize=l,this}setItemSize(s){return this.itemSize=s,this}setCount(s){return this.count=s,this}}const z0=new Dn;class FA{constructor(s,l,h=0,f=1/0){this.ray=new As(s,l),this.near=h,this.far=f,this.camera=null,this.layers=new R_,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(s,l){this.ray.set(s,l)}setFromCamera(s,l){l.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(l.matrixWorld),this.ray.direction.set(s.x,s.y,.5).unproject(l).sub(this.ray.origin).normalize(),this.camera=l):l.isOrthographicCamera?(this.ray.origin.set(s.x,s.y,(l.near+l.far)/(l.near-l.far)).unproject(l),this.ray.direction.set(0,0,-1).transformDirection(l.matrixWorld),this.camera=l):ci("Raycaster: Unsupported camera type: "+l.type)}setFromXRController(s){return z0.identity().extractRotation(s.matrixWorld),this.ray.origin.setFromMatrixPosition(s.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(z0),this}intersectObject(s,l=!0,h=[]){return V0(s,this,h,l),h.sort(qS),h}intersectObjects(s,l=!0,h=[]){for(let f=0,g=s.length;f<g;f++)V0(s[f],this,h,l);return h.sort(qS),h}}function qS(E,s){return E.distance-s.distance}function V0(E,s,l,h){let f=!0;if(E.layers.test(s.layers)&&E.raycast(s,l)===!1&&(f=!1),f===!0&&h===!0){const g=E.children;for(let _=0,b=g.length;_<b;_++)V0(g[_],s,l,!0)}}class QL{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(s){this._document=s,s.hidden!==void 0&&(this._pageVisibilityHandler=Rx.bind(this),s.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(s){return this._timescale=s,this}reset(){return this._currentTime=performance.now()-this._startTime,this}dispose(){this.disconnect()}update(s){return this._pageVisibilityHandler!==null&&this._document.hidden===!0?this._delta=0:(this._previousTime=this._currentTime,this._currentTime=(s!==void 0?s:performance.now())-this._startTime,this._delta=(this._currentTime-this._previousTime)*this._timescale,this._elapsed+=this._delta),this}}function Rx(){this._document.hidden===!1&&this.reset()}class XS{constructor(s=1,l=0,h=0){this.radius=s,this.phi=l,this.theta=h}set(s,l,h){return this.radius=s,this.phi=l,this.theta=h,this}copy(s){return this.radius=s.radius,this.phi=s.phi,this.theta=s.theta,this}makeSafe(){return this.phi=Ut(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(s){return this.setFromCartesianCoords(s.x,s.y,s.z)}setFromCartesianCoords(s,l,h){return this.radius=Math.sqrt(s*s+l*l+h*h),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(s,h),this.phi=Math.acos(Ut(l/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class jS{constructor(s=1,l=0,h=0){this.radius=s,this.theta=l,this.y=h}set(s,l,h){return this.radius=s,this.theta=l,this.y=h,this}copy(s){return this.radius=s.radius,this.theta=s.theta,this.y=s.y,this}setFromVector3(s){return this.setFromCartesianCoords(s.x,s.y,s.z)}setFromCartesianCoords(s,l,h){return this.radius=Math.sqrt(s*s+h*h),this.theta=Math.atan2(s,h),this.y=l,this}clone(){return new this.constructor().copy(this)}}class Fm{constructor(s,l,h,f){Fm.prototype.isMatrix2=!0,this.elements=[1,0,0,1],s!==void 0&&this.set(s,l,h,f)}identity(){return this.set(1,0,0,1),this}fromArray(s,l=0){for(let h=0;h<4;h++)this.elements[h]=s[h+l];return this}set(s,l,h,f){const g=this.elements;return g[0]=s,g[2]=l,g[1]=h,g[3]=f,this}}const YS=new St;class BA{constructor(s=new St(1/0,1/0),l=new St(-1/0,-1/0)){this.isBox2=!0,this.min=s,this.max=l}set(s,l){return this.min.copy(s),this.max.copy(l),this}setFromPoints(s){this.makeEmpty();for(let l=0,h=s.length;l<h;l++)this.expandByPoint(s[l]);return this}setFromCenterAndSize(s,l){const h=YS.copy(l).multiplyScalar(.5);return this.min.copy(s).sub(h),this.max.copy(s).add(h),this}clone(){return new this.constructor().copy(this)}copy(s){return this.min.copy(s.min),this.max.copy(s.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(s){return this.isEmpty()?s.set(0,0):s.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(s){return this.isEmpty()?s.set(0,0):s.subVectors(this.max,this.min)}expandByPoint(s){return this.min.min(s),this.max.max(s),this}expandByVector(s){return this.min.sub(s),this.max.add(s),this}expandByScalar(s){return this.min.addScalar(-s),this.max.addScalar(s),this}containsPoint(s){return s.x>=this.min.x&&s.x<=this.max.x&&s.y>=this.min.y&&s.y<=this.max.y}containsBox(s){return this.min.x<=s.min.x&&s.max.x<=this.max.x&&this.min.y<=s.min.y&&s.max.y<=this.max.y}getParameter(s,l){return l.set((s.x-this.min.x)/(this.max.x-this.min.x),(s.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(s){return s.max.x>=this.min.x&&s.min.x<=this.max.x&&s.max.y>=this.min.y&&s.min.y<=this.max.y}clampPoint(s,l){return l.copy(s).clamp(this.min,this.max)}distanceToPoint(s){return this.clampPoint(s,YS).distanceTo(s)}intersect(s){return this.min.max(s.min),this.max.min(s.max),this.isEmpty()&&this.makeEmpty(),this}union(s){return this.min.min(s.min),this.max.max(s.max),this}translate(s){return this.min.add(s),this.max.add(s),this}equals(s){return s.min.equals(this.min)&&s.max.equals(this.max)}}const G0=new ae,W0=new ae,vl=new ae,Yu=new ae,Nx=new ae,Px=new ae,Bm=new ae;class $f{constructor(s=new ae,l=new ae){this.start=s,this.end=l}set(s,l){return this.start.copy(s),this.end.copy(l),this}copy(s){return this.start.copy(s.start),this.end.copy(s.end),this}getCenter(s){return s.addVectors(this.start,this.end).multiplyScalar(.5)}delta(s){return s.subVectors(this.end,this.start)}distanceSq(){return this.start.distanceToSquared(this.end)}distance(){return this.start.distanceTo(this.end)}at(s,l){return this.delta(l).multiplyScalar(s).add(this.start)}closestPointToPointParameter(s,l){G0.subVectors(s,this.start),W0.subVectors(this.end,this.start);const h=W0.dot(W0);let g=W0.dot(G0)/h;return l&&(g=Ut(g,0,1)),g}closestPointToPoint(s,l,h){const f=this.closestPointToPointParameter(s,l);return this.delta(h).multiplyScalar(f).add(this.start)}distanceSqToLine3(s,l=Px,h=Bm){const f=10000000000000001e-32;let g,_;const b=this.start,T=s.start,A=this.end,R=s.end;vl.subVectors(A,b),Yu.subVectors(R,T),Nx.subVectors(b,T);const P=vl.dot(vl),L=Yu.dot(Yu),D=Yu.dot(Nx);if(P<=f&&L<=f)return l.copy(b),h.copy(T),l.sub(h),l.dot(l);if(P<=f)g=0,_=D/L,_=Ut(_,0,1);else{const O=vl.dot(Nx);if(L<=f)_=0,g=Ut(-O/P,0,1);else{const W=vl.dot(Yu),Z=P*L-W*W;Z!==0?g=Ut((W*D-O*L)/Z,0,1):g=0,_=(W*g+D)/L,_<0?(_=0,g=Ut(-O/P,0,1)):_>1&&(_=1,g=Ut((W-O)/P,0,1))}}return l.copy(b).add(vl.multiplyScalar(g)),h.copy(T).add(Yu.multiplyScalar(_)),l.sub(h),l.dot(l)}applyMatrix4(s){return this.start.applyMatrix4(s),this.end.applyMatrix4(s),this}equals(s){return s.start.equals(this.start)&&s.end.equals(this.end)}clone(){return new this.constructor().copy(this)}}const Zu=new ae;class Ix extends null{constructor(s,l){super(),this.light=s,this.matrixAutoUpdate=!1,this.color=l,this.type="SpotLightHelper";const h=new ht,f=[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 _=0,b=1,T=32;_<T;_++,b++){const A=_/T*Math.PI*2,R=b/T*Math.PI*2;f.push(Math.cos(A),Math.sin(A),1,Math.cos(R),Math.sin(R),1)}h.setAttribute("position",new cn(f,3));const g=new Zr({fog:!1,toneMapped:!1});this.cone=new md(h,g),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 s=this.light.distance?this.light.distance:1e3,l=s*Math.tan(this.light.angle);this.cone.scale.set(l,l,s),Zu.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Zu),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const bc=new ae,Om=new Dn,Lx=new Dn;class ZS extends null{constructor(s){const l=KS(s),h=new ht,f=[],g=[];for(let A=0;A<l.length;A++){const R=l[A];R.parent&&R.parent.isBone&&(f.push(0,0,0),f.push(0,0,0),g.push(0,0,0),g.push(0,0,0))}h.setAttribute("position",new cn(f,3)),h.setAttribute("color",new cn(g,3));const _=new Zr({vertexColors:!0,depthTest:!1,depthWrite:!1,toneMapped:!1,transparent:!0});super(h,_),this.isSkeletonHelper=!0,this.type="SkeletonHelper",this.root=s,this.bones=l,this.matrix=s.matrixWorld,this.matrixAutoUpdate=!1;const b=new Zn(255),T=new Zn(65280);this.setColors(b,T)}updateMatrixWorld(s){const l=this.bones,h=this.geometry,f=h.getAttribute("position");Lx.copy(this.root.matrixWorld).invert();for(let g=0,_=0;g<l.length;g++){const b=l[g];b.parent&&b.parent.isBone&&(Om.multiplyMatrices(Lx,b.matrixWorld),bc.setFromMatrixPosition(Om),f.setXYZ(_,bc.x,bc.y,bc.z),Om.multiplyMatrices(Lx,b.parent.matrixWorld),bc.setFromMatrixPosition(Om),f.setXYZ(_+1,bc.x,bc.y,bc.z),_+=2)}h.getAttribute("position").needsUpdate=!0,super.updateMatrixWorld(s)}setColors(s,l){const f=this.geometry.getAttribute("color");for(let g=0;g<f.count;g+=2)f.setXYZ(g,s.r,s.g,s.b),f.setXYZ(g+1,l.r,l.g,l.b);return f.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}function KS(E){const s=[];E.isBone===!0&&s.push(E);for(let l=0;l<E.children.length;l++)s.push(...KS(E.children[l]));return s}class Ku extends null{constructor(s,l,h){const f=new Uf(l,4,2),g=new Zl({wireframe:!0,fog:!1,toneMapped:!1});super(f,g),this.light=s,this.color=h,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 Um=new ae,km=new Zn,JS=new Zn;class QS extends null{constructor(s,l,h){super(),this.light=s,this.matrix=s.matrixWorld,this.matrixAutoUpdate=!1,this.color=h,this.type="HemisphereLightHelper";const f=new gm(l);f.rotateY(Math.PI*.5),this.material=new Zl({wireframe:!0,fog:!1,toneMapped:!1}),this.color===void 0&&(this.material.vertexColors=!0);const g=f.getAttribute("position"),_=new Float32Array(g.count*3);f.setAttribute("color",new Ki(_,3)),this.add(new dl(f,this.material)),this.update()}dispose(){this.children[0].geometry.dispose(),this.children[0].material.dispose()}update(){const s=this.children[0];if(this.color!==void 0)this.material.color.set(this.color);else{const l=s.geometry.getAttribute("color");km.copy(this.light.color),JS.copy(this.light.groundColor);for(let h=0,f=l.count;h<f;h++){const g=h<f/2?km:JS;l.setXYZ(h,g.r,g.g,g.b)}l.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),s.lookAt(Um.setFromMatrixPosition(this.light.matrixWorld).negate())}}class eD extends null{constructor(s=10,l=10,h=4473924,f=8947848){h=new Zn(h),f=new Zn(f);const g=l/2,_=s/l,b=s/2,T=[],A=[];for(let L=0,D=0,O=-b;L<=l;L++,O+=_){T.push(-b,0,O,b,0,O),T.push(O,0,-b,O,0,b);const W=L===g?h:f;W.toArray(A,D),D+=3,W.toArray(A,D),D+=3,W.toArray(A,D),D+=3,W.toArray(A,D),D+=3}const R=new ht;R.setAttribute("position",new cn(T,3)),R.setAttribute("color",new cn(A,3));const P=new Zr({vertexColors:!0,toneMapped:!1});super(R,P),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class OA extends null{constructor(s=10,l=16,h=8,f=64,g=4473924,_=8947848){g=new Zn(g),_=new Zn(_);const b=[],T=[];if(l>1)for(let P=0;P<l;P++){const L=P/l*(Math.PI*2),D=Math.sin(L)*s,O=Math.cos(L)*s;b.push(0,0,0),b.push(D,0,O);const W=P&1?g:_;T.push(W.r,W.g,W.b),T.push(W.r,W.g,W.b)}for(let P=0;P<h;P++){const L=P&1?g:_,D=s-s/h*P;for(let O=0;O<f;O++){let W=O/f*(Math.PI*2),Z=Math.sin(W)*D,Y=Math.cos(W)*D;b.push(Z,0,Y),T.push(L.r,L.g,L.b),W=(O+1)/f*(Math.PI*2),Z=Math.sin(W)*D,Y=Math.cos(W)*D,b.push(Z,0,Y),T.push(L.r,L.g,L.b)}}const A=new ht;A.setAttribute("position",new cn(b,3)),A.setAttribute("color",new cn(T,3));const R=new Zr({vertexColors:!0,toneMapped:!1});super(A,R),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const H0=new ae,qf=new ae,eM=new ae;class tD extends null{constructor(s,l,h){super(),this.light=s,this.matrix=s.matrixWorld,this.matrixAutoUpdate=!1,this.color=h,this.type="DirectionalLightHelper",l===void 0&&(l=1);let f=new ht;f.setAttribute("position",new cn([-l,l,0,l,l,0,l,-l,0,-l,-l,0,-l,l,0],3));const g=new Zr({fog:!1,toneMapped:!1});this.lightPlane=new js(f,g),this.add(this.lightPlane),f=new ht,f.setAttribute("position",new cn([0,0,0,0,0,1],3)),this.targetLine=new js(f,g),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),H0.setFromMatrixPosition(this.light.matrixWorld),qf.setFromMatrixPosition(this.light.target.matrixWorld),eM.subVectors(qf,H0),this.lightPlane.lookAt(qf),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(qf),this.targetLine.scale.z=eM.length()}}const $0=new ae,cs=new rd;class q0 extends null{constructor(s){const l=new ht,h=new Zr({color:16777215,vertexColors:!0,toneMapped:!1}),f=[],g=[],_={};b("n1","n2"),b("n2","n4"),b("n4","n3"),b("n3","n1"),b("f1","f2"),b("f2","f4"),b("f4","f3"),b("f3","f1"),b("n1","f1"),b("n2","f2"),b("n3","f3"),b("n4","f4"),b("p","n1"),b("p","n2"),b("p","n3"),b("p","n4"),b("u1","u2"),b("u2","u3"),b("u3","u1"),b("c","t"),b("p","c"),b("cn1","cn2"),b("cn3","cn4"),b("cf1","cf2"),b("cf3","cf4");function b(O,W){T(O),T(W)}function T(O){f.push(0,0,0),g.push(0,0,0),_[O]===void 0&&(_[O]=[]),_[O].push(f.length/3-1)}l.setAttribute("position",new cn(f,3)),l.setAttribute("color",new cn(g,3)),super(l,h),this.type="CameraHelper",this.camera=s,this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix(),this.matrix=s.matrixWorld,this.matrixAutoUpdate=!1,this.pointMap=_,this.update();const A=new Zn(16755200),R=new Zn(16711680),P=new Zn(43775),L=new Zn(16777215),D=new Zn(3355443);this.setColors(A,R,P,L,D)}setColors(s,l,h,f,g){const b=this.geometry.getAttribute("color");return b.setXYZ(0,s.r,s.g,s.b),b.setXYZ(1,s.r,s.g,s.b),b.setXYZ(2,s.r,s.g,s.b),b.setXYZ(3,s.r,s.g,s.b),b.setXYZ(4,s.r,s.g,s.b),b.setXYZ(5,s.r,s.g,s.b),b.setXYZ(6,s.r,s.g,s.b),b.setXYZ(7,s.r,s.g,s.b),b.setXYZ(8,s.r,s.g,s.b),b.setXYZ(9,s.r,s.g,s.b),b.setXYZ(10,s.r,s.g,s.b),b.setXYZ(11,s.r,s.g,s.b),b.setXYZ(12,s.r,s.g,s.b),b.setXYZ(13,s.r,s.g,s.b),b.setXYZ(14,s.r,s.g,s.b),b.setXYZ(15,s.r,s.g,s.b),b.setXYZ(16,s.r,s.g,s.b),b.setXYZ(17,s.r,s.g,s.b),b.setXYZ(18,s.r,s.g,s.b),b.setXYZ(19,s.r,s.g,s.b),b.setXYZ(20,s.r,s.g,s.b),b.setXYZ(21,s.r,s.g,s.b),b.setXYZ(22,s.r,s.g,s.b),b.setXYZ(23,s.r,s.g,s.b),b.setXYZ(24,l.r,l.g,l.b),b.setXYZ(25,l.r,l.g,l.b),b.setXYZ(26,l.r,l.g,l.b),b.setXYZ(27,l.r,l.g,l.b),b.setXYZ(28,l.r,l.g,l.b),b.setXYZ(29,l.r,l.g,l.b),b.setXYZ(30,l.r,l.g,l.b),b.setXYZ(31,l.r,l.g,l.b),b.setXYZ(32,h.r,h.g,h.b),b.setXYZ(33,h.r,h.g,h.b),b.setXYZ(34,h.r,h.g,h.b),b.setXYZ(35,h.r,h.g,h.b),b.setXYZ(36,h.r,h.g,h.b),b.setXYZ(37,h.r,h.g,h.b),b.setXYZ(38,f.r,f.g,f.b),b.setXYZ(39,f.r,f.g,f.b),b.setXYZ(40,g.r,g.g,g.b),b.setXYZ(41,g.r,g.g,g.b),b.setXYZ(42,g.r,g.g,g.b),b.setXYZ(43,g.r,g.g,g.b),b.setXYZ(44,g.r,g.g,g.b),b.setXYZ(45,g.r,g.g,g.b),b.setXYZ(46,g.r,g.g,g.b),b.setXYZ(47,g.r,g.g,g.b),b.setXYZ(48,g.r,g.g,g.b),b.setXYZ(49,g.r,g.g,g.b),b.needsUpdate=!0,this}update(){const s=this.geometry,l=this.pointMap,h=1,f=1;let g,_;if(cs.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),this.camera.reversedDepth===!0)g=1,_=0;else if(this.camera.coordinateSystem===rl)g=-1,_=1;else if(this.camera.coordinateSystem===Up)g=0,_=1;else throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);ps("c",l,s,cs,0,0,g),ps("t",l,s,cs,0,0,_),ps("n1",l,s,cs,-h,-f,g),ps("n2",l,s,cs,h,-f,g),ps("n3",l,s,cs,-h,f,g),ps("n4",l,s,cs,h,f,g),ps("f1",l,s,cs,-h,-f,_),ps("f2",l,s,cs,h,-f,_),ps("f3",l,s,cs,-h,f,_),ps("f4",l,s,cs,h,f,_),ps("u1",l,s,cs,h*.7,f*1.1,g),ps("u2",l,s,cs,-h*.7,f*1.1,g),ps("u3",l,s,cs,0,f*2,g),ps("cf1",l,s,cs,-h,0,_),ps("cf2",l,s,cs,h,0,_),ps("cf3",l,s,cs,0,-f,_),ps("cf4",l,s,cs,0,f,_),ps("cn1",l,s,cs,-h,0,g),ps("cn2",l,s,cs,h,0,g),ps("cn3",l,s,cs,0,-f,g),ps("cn4",l,s,cs,0,f,g),s.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function ps(E,s,l,h,f,g,_){$0.set(f,g,_).unproject(h);const b=s[E];if(b!==void 0){const T=l.getAttribute("position");for(let A=0,R=b.length;A<R;A++)T.setXYZ(b[A],$0.x,$0.y,$0.z)}}const X0=new fi;class j0 extends null{constructor(s,l=16776960){const h=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]),f=new Float32Array(8*3),g=new ht;g.setIndex(new Ki(h,1)),g.setAttribute("position",new Ki(f,3)),super(g,new Zr({color:l,toneMapped:!1})),this.object=s,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&X0.setFromObject(this.object),X0.isEmpty())return;const s=X0.min,l=X0.max,h=this.geometry.attributes.position,f=h.array;f[0]=l.x,f[1]=l.y,f[2]=l.z,f[3]=s.x,f[4]=l.y,f[5]=l.z,f[6]=s.x,f[7]=s.y,f[8]=l.z,f[9]=l.x,f[10]=s.y,f[11]=l.z,f[12]=l.x,f[13]=l.y,f[14]=s.z,f[15]=s.x,f[16]=l.y,f[17]=s.z,f[18]=s.x,f[19]=s.y,f[20]=s.z,f[21]=l.x,f[22]=s.y,f[23]=s.z,h.needsUpdate=!0,this.geometry.computeBoundingSphere()}setFromObject(s){return this.object=s,this.update(),this}copy(s,l){return super.copy(s,l),this.object=s.object,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class Rs extends null{constructor(s,l=16776960){const h=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]),f=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],g=new ht;g.setIndex(new Ki(h,1)),g.setAttribute("position",new cn(f,3)),super(g,new Zr({color:l,toneMapped:!1})),this.box=s,this.type="Box3Helper",this.geometry.computeBoundingSphere()}updateMatrixWorld(s){const l=this.box;l.isEmpty()||(l.getCenter(this.position),l.getSize(this.scale),this.scale.multiplyScalar(.5),super.updateMatrixWorld(s))}dispose(){this.geometry.dispose(),this.material.dispose()}}class nD extends null{constructor(s,l=1,h=16776960){const f=h,g=[1,-1,0,-1,1,0,-1,-1,0,1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],_=new ht;_.setAttribute("position",new cn(g,3)),_.computeBoundingSphere(),super(_,new Zr({color:f,toneMapped:!1})),this.type="PlaneHelper",this.plane=s,this.size=l;const b=[1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],T=new ht;T.setAttribute("position",new cn(b,3)),T.computeBoundingSphere(),this.add(new dl(T,new Zl({color:f,opacity:.2,transparent:!0,depthWrite:!1,toneMapped:!1})))}updateMatrixWorld(s){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(s)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}const ms=new ae;let Ju,Dx;class iD extends null{constructor(s=new ae(0,0,1),l=new ae(0,0,0),h=1,f=16776960,g=h*.2,_=g*.2){super(),this.type="ArrowHelper",Ju===void 0&&(Ju=new ht,Ju.setAttribute("position",new cn([0,0,0,0,1,0],3)),Dx=new f0(.5,1,5,1),Dx.translate(0,-.5,0)),this.position.copy(l),this.line=new js(Ju,new Zr({color:f,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new dl(Dx,new Zl({color:f,toneMapped:!1})),this.cone.matrixAutoUpdate=!1,this.add(this.cone),this.setDirection(s),this.setLength(h,g,_)}setDirection(s){if(s.y>.99999)this.quaternion.set(0,0,0,1);else if(s.y<-.99999)this.quaternion.set(1,0,0,0);else{ms.set(s.z,0,-s.x).normalize();const l=Math.acos(s.y);this.quaternion.setFromAxisAngle(ms,l)}}setLength(s,l=s*.2,h=l*.2){this.line.scale.set(1,Math.max(1e-4,s-l),1),this.line.updateMatrix(),this.cone.scale.set(h,l,h),this.cone.position.y=s,this.cone.updateMatrix()}setColor(s){this.line.material.color.set(s),this.cone.material.color.set(s)}copy(s){return super.copy(s,!1),this.line.copy(s.line),this.cone.copy(s.cone),this}dispose(){this.line.geometry.dispose(),this.line.material.dispose(),this.cone.geometry.dispose(),this.cone.material.dispose()}}class sD extends null{constructor(s=1){const l=[0,0,0,s,0,0,0,0,0,0,s,0,0,0,0,0,0,s],h=[1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],f=new ht;f.setAttribute("position",new cn(l,3)),f.setAttribute("color",new cn(h,3));const g=new Zr({vertexColors:!0,toneMapped:!1});super(f,g),this.type="AxesHelper"}setColors(s,l,h){const f=new Zn,g=this.geometry.attributes.color.array;return f.set(s),f.toArray(g,0),f.toArray(g,3),f.set(l),f.toArray(g,6),f.toArray(g,9),f.set(h),f.toArray(g,12),f.toArray(g,15),this.geometry.attributes.color.needsUpdate=!0,this}dispose(){this.geometry.dispose(),this.material.dispose()}}class tM{constructor(){this.type="ShapePath",this.color=new Zn,this.subPaths=[],this.currentPath=null}moveTo(s,l){return this.currentPath=new cm,this.subPaths.push(this.currentPath),this.currentPath.moveTo(s,l),this}lineTo(s,l){return this.currentPath.lineTo(s,l),this}quadraticCurveTo(s,l,h,f){return this.currentPath.quadraticCurveTo(s,l,h,f),this}bezierCurveTo(s,l,h,f,g,_){return this.currentPath.bezierCurveTo(s,l,h,f,g,_),this}splineThru(s){return this.currentPath.splineThru(s),this}toShapes(s){function l(Y){const ie=[];for(let se=0,de=Y.length;se<de;se++){const ke=Y[se],$e=new Bu;$e.curves=ke.curves,ie.push($e)}return ie}function h(Y,ie){const se=ie.length;let de=!1;for(let ke=se-1,$e=0;$e<se;ke=$e++){let et=ie[ke],qe=ie[$e],xt=qe.x-et.x,Et=qe.y-et.y;if(Math.abs(Et)>Number.EPSILON){if(Et<0&&(et=ie[$e],xt=-xt,qe=ie[ke],Et=-Et),Y.y<et.y||Y.y>qe.y)continue;if(Y.y===et.y){if(Y.x===et.x)return!0}else{const _n=Et*(Y.x-et.x)-xt*(Y.y-et.y);if(_n===0)return!0;if(_n<0)continue;de=!de}}else{if(Y.y!==et.y)continue;if(qe.x<=Y.x&&Y.x<=et.x||et.x<=Y.x&&Y.x<=qe.x)return!0}}return de}const f=Ga.isClockWise,g=this.subPaths;if(g.length===0)return[];let _,b,T;const A=[];if(g.length===1)return b=g[0],T=new Bu,T.curves=b.curves,A.push(T),A;let R=!f(g[0].getPoints());R=s?!R:R;const P=[],L=[];let D=[],O=0,W;L[O]=void 0,D[O]=[];for(let Y=0,ie=g.length;Y<ie;Y++)b=g[Y],W=b.getPoints(),_=f(W),_=s?!_:_,_?(!R&&L[O]&&O++,L[O]={s:new Bu,p:W},L[O].s.curves=b.curves,R&&O++,D[O]=[]):D[O].push({h:b,p:W[0]});if(!L[0])return l(g);if(L.length>1){let Y=!1,ie=0;for(let se=0,de=L.length;se<de;se++)P[se]=[];for(let se=0,de=L.length;se<de;se++){const ke=D[se];for(let $e=0;$e<ke.length;$e++){const et=ke[$e];let qe=!0;for(let xt=0;xt<L.length;xt++)h(et.p,L[xt].p)&&(se!==xt&&ie++,qe?(qe=!1,P[xt].push(et)):Y=!0);qe&&P[se].push(et)}}ie>0&&Y===!1&&(D=P)}let Z;for(let Y=0,ie=L.length;Y<ie;Y++){T=L[Y].s,A.push(T),Z=D[Y];for(let se=0,de=Z.length;se<de;se++)T.holes.push(Z[se].h)}return A}}class Y0 extends null{constructor(s,l=null){super(),this.object=s,this.domElement=l,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(s){if(s===void 0){Mn("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=s}disconnect(){}dispose(){}update(){}}function Z0(E,s){const l=E.image&&E.image.width?E.image.width/E.image.height:1;return l>s?(E.repeat.x=1,E.repeat.y=l/s,E.offset.x=0,E.offset.y=(1-E.repeat.y)/2):(E.repeat.x=s/l,E.repeat.y=1,E.offset.x=(1-E.repeat.x)/2,E.offset.y=0),E}function UA(E,s){const l=E.image&&E.image.width?E.image.width/E.image.height:1;return l>s?(E.repeat.x=s/l,E.repeat.y=1,E.offset.x=(1-E.repeat.x)/2,E.offset.y=0):(E.repeat.x=1,E.repeat.y=l/s,E.offset.x=0,E.offset.y=(1-E.repeat.y)/2),E}function kA(E){return E.repeat.x=1,E.repeat.y=1,E.offset.x=0,E.offset.y=0,E}function zA(E,s,l,h){const f=zm(h);switch(l){case Rg:return E*s;case Qc:return E*s/f.components*f.byteLength;case Bl:return E*s/f.components*f.byteLength;case Nr:return E*s*2/f.components*f.byteLength;case xh:return E*s*2/f.components*f.byteLength;case tf:return E*s*3/f.components*f.byteLength;case Ri:return E*s*4/f.components*f.byteLength;case vh:return E*s*4/f.components*f.byteLength;case Ol:case Ul:return Math.floor((E+3)/4)*Math.floor((s+3)/4)*8;case kl:case zl:return Math.floor((E+3)/4)*Math.floor((s+3)/4)*16;case sf:case of:return Math.max(E,16)*Math.max(s,8)/4;case nf:case rf:return Math.max(E,8)*Math.max(s,8)/2;case bh:case Sh:return Math.floor((E+3)/4)*Math.floor((s+3)/4)*8;case Mh:return Math.floor((E+3)/4)*Math.floor((s+3)/4)*16;case Th:return Math.floor((E+3)/4)*Math.floor((s+3)/4)*16;case wh:return Math.floor((E+4)/5)*Math.floor((s+3)/4)*16;case eu:return Math.floor((E+4)/5)*Math.floor((s+4)/5)*16;case Ah:return Math.floor((E+5)/6)*Math.floor((s+4)/5)*16;case Eh:return Math.floor((E+5)/6)*Math.floor((s+5)/6)*16;case Ch:return Math.floor((E+7)/8)*Math.floor((s+4)/5)*16;case Rh:return Math.floor((E+7)/8)*Math.floor((s+5)/6)*16;case Nh:return Math.floor((E+7)/8)*Math.floor((s+7)/8)*16;case Ph:return Math.floor((E+9)/10)*Math.floor((s+4)/5)*16;case Ih:return Math.floor((E+9)/10)*Math.floor((s+5)/6)*16;case Lh:return Math.floor((E+9)/10)*Math.floor((s+7)/8)*16;case Dh:return Math.floor((E+9)/10)*Math.floor((s+9)/10)*16;case Fh:return Math.floor((E+11)/12)*Math.floor((s+9)/10)*16;case Bh:return Math.floor((E+11)/12)*Math.floor((s+11)/12)*16;case Oh:case Uh:case kh:return Math.ceil(E/4)*Math.ceil(s/4)*16;case zh:case Vh:return Math.ceil(E/4)*Math.ceil(s/4)*8;case Ng:case Pg:return Math.ceil(E/4)*Math.ceil(s/4)*16}throw new Error(`Unable to determine texture byte length for ${l} format.`)}function zm(E){switch(E){case Di:case Kc:return{byteLength:1,components:1};case jo:case Jc:case Hi:return{byteLength:2,components:1};case Ip:case Lp:return{byteLength:2,components:4};case yi:case er:case Si:return{byteLength:4,components:1};case Dp:case Fp:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${E}.`)}class VA{static contain(s,l){return Z0(s,l)}static cover(s,l){return UA(s,l)}static fill(s){return kA(s)}static getByteLength(s,l,h,f){return zA(s,l,h,f)}}typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:xe}})),typeof window!="undefined"&&(window.__THREE__?Mn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=xe)}}]);
}());