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.
5042 lines
1.8 MiB
5042 lines
1.8 MiB
!(function(){var vY=Object.defineProperty,bY=Object.defineProperties;var SY=Object.getOwnPropertyDescriptors;var lD=Object.getOwnPropertySymbols,TY=Object.getPrototypeOf,wY=Object.prototype.hasOwnProperty,MY=Object.prototype.propertyIsEnumerable,AY=Reflect.get;var hb=Math.pow,cD=(lt,Ze,he)=>Ze in lt?vY(lt,Ze,{enumerable:!0,configurable:!0,writable:!0,value:he}):lt[Ze]=he,Ii=(lt,Ze)=>{for(var he in Ze||(Ze={}))wY.call(Ze,he)&&cD(lt,he,Ze[he]);if(lD)for(var he of lD(Ze))MY.call(Ze,he)&&cD(lt,he,Ze[he]);return lt},_a=(lt,Ze)=>bY(lt,SY(Ze));var uD=(lt,Ze,he)=>AY(TY(lt),he,Ze);var en=(lt,Ze,he)=>new Promise((_e,ye)=>{var fe=oe=>{try{J(he.next(oe))}catch(te){ye(te)}},X=oe=>{try{J(he.throw(oe))}catch(te){ye(te)}},J=oe=>oe.done?_e(oe.value):Promise.resolve(oe.value).then(fe,X);J((he=he.apply(lt,Ze)).next())});(self.webpackChunk=self.webpackChunk||[]).push([[1431],{16505:function(lt,Ze,he){lt.exports=ye,lt.exports.simulator=he(45818);var _e=he(77797);function ye(X,J){if(!X)throw new Error("Graph structure cannot be undefined");var oe=J&&J.createSimulator||he(45818),te=oe(J);if(Array.isArray(J))throw new Error("Physics settings is expected to be an object");var me=X.version>19?va:xa;J&&typeof J.nodeMass=="function"&&(me=J.nodeMass);var Me=new Map,Ne={},le=0,Be=te.settings.springTransform||fe;os(),St();var Ee=!1,ke={step:function(){if(le===0)return Ae(!0),!0;var Tt=te.step();ke.lastMove=Tt,ke.fire("step");var rn=Tt/le,On=rn<=.01;return Ae(On),On},getNodePosition:function(Tt){return Ss(Tt).pos},setNodePosition:function(Tt){var rn=Ss(Tt);rn.setPosition.apply(rn,Array.prototype.slice.call(arguments,1))},getLinkPosition:function(Tt){var rn=Ne[Tt];if(rn)return{from:rn.from.pos,to:rn.to.pos}},getGraphRect:function(){return te.getBBox()},forEachBody:qe,pinNode:function(Tt,rn){var On=Ss(Tt.id);On.isPinned=!!rn},isNodePinned:function(Tt){return Ss(Tt.id).isPinned},dispose:function(){X.off("changed",Fn),ke.fire("disposed")},getBody:at,getSpring:rt,getForceVectorLength:et,simulator:te,graph:X,lastMove:0};return _e(ke),ke;function Ae(Tt){Ee!==Tt&&(Ee=Tt,Ot(Tt))}function qe(Tt){Me.forEach(Tt)}function et(){var Tt=0,rn=0;return qe(function(On){Tt+=Math.abs(On.force.x),rn+=Math.abs(On.force.y)}),Math.sqrt(Tt*Tt+rn*rn)}function rt(Tt,rn){var On;if(rn===void 0)typeof Tt!="object"?On=Tt:On=Tt.id;else{var hs=X.hasLink(Tt,rn);if(!hs)return;On=hs.id}return Ne[On]}function at(Tt){return Me.get(Tt)}function St(){X.on("changed",Fn)}function Ot(Tt){ke.fire("stable",Tt)}function Fn(Tt){for(var rn=0;rn<Tt.length;++rn){var On=Tt[rn];On.changeType==="add"?(On.node&&Bn(On.node.id),On.link&&ni(On.link)):On.changeType==="remove"&&(On.node&&ei(On.node),On.link&&bs(On.link))}le=X.getNodesCount()}function os(){le=0,X.forEachNode(function(Tt){Bn(Tt.id),le+=1}),X.forEachLink(ni)}function Bn(Tt){var rn=Me.get(Tt);if(!rn){var On=X.getNode(Tt);if(!On)throw new Error("initBody() was called with unknown node id");var hs=On.position;if(!hs){var Il=vr(On);hs=te.getBestNewBodyPosition(Il)}rn=te.addBodyAt(hs),rn.id=Tt,Me.set(Tt,rn),Zr(Tt),Kr(On)&&(rn.isPinned=!0)}}function ei(Tt){var rn=Tt.id,On=Me.get(rn);On&&(Me.delete(rn),te.removeBody(On))}function ni(Tt){Zr(Tt.fromId),Zr(Tt.toId);var rn=Me.get(Tt.fromId),On=Me.get(Tt.toId),hs=te.addSpring(rn,On,Tt.length);Be(Tt,hs),Ne[Tt.id]=hs}function bs(Tt){var rn=Ne[Tt.id];if(rn){var On=X.getNode(Tt.fromId),hs=X.getNode(Tt.toId);On&&Zr(On.id),hs&&Zr(hs.id),delete Ne[Tt.id],te.removeSpring(rn)}}function vr(Tt){var rn=[];if(!Tt.links)return rn;for(var On=Math.min(Tt.links.length,2),hs=0;hs<On;++hs){var Il=Tt.links[hs],Hu=Il.fromId!==Tt.id?Me.get(Il.fromId):Me.get(Il.toId);Hu&&Hu.pos&&rn.push(Hu)}return rn}function Zr(Tt){var rn=Me.get(Tt);if(rn.mass=me(Tt),Number.isNaN(rn.mass))throw new Error("Node mass should be a number")}function Kr(Tt){return Tt&&(Tt.isPinned||Tt.data&&Tt.data.isPinned)}function Ss(Tt){var rn=Me.get(Tt);return rn||(Bn(Tt),rn=Me.get(Tt)),rn}function xa(Tt){var rn=X.getLinks(Tt);return rn?1+rn.length/3:1}function va(Tt){var rn=X.getLinks(Tt);return rn?1+rn.size/3:1}}function fe(){}},15189:function(lt,Ze,he){const _e=he(16422);lt.exports=function(fe){return X;function X(J,oe){let te=oe&&oe.indent||0,me=oe&&oe.join!==void 0?oe.join:`
|
|
`,Me=Array(te+1).join(" "),Ne=[];for(let le=0;le<fe;++le){let Be=_e(le),Ee=le===0?"":Me;Ne.push(Ee+J.replace(/{var}/g,Be))}return Ne.join(me)}}},30891:function(lt,Ze,he){lt.exports=ye,lt.exports.generateFunctionBody=fe;const _e=he(15189);function ye(X){let J=fe(X);return new Function("bodies","settings","random",J)}function fe(X){let J=_e(X);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})}
|
|
}
|
|
`}},6410:function(lt,Ze,he){const _e=he(15189);lt.exports=ye,lt.exports.generateCreateBodyFunctionBody=fe,lt.exports.getVectorCode=J,lt.exports.getBodyCode=X;function ye(oe,te){let me=fe(oe,te),{Body:Me}=new Function(me)();return Me}function fe(oe,te){return`
|
|
${J(oe,te)}
|
|
${X(oe,te)}
|
|
return {Body: Body, Vector: Vector};
|
|
`}function X(oe){let te=_e(oe),me=te("{var}",{join:", "});return`
|
|
function Body(${me}) {
|
|
this.isPinned = false;
|
|
this.pos = new Vector(${me});
|
|
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 (${me}) {
|
|
${te("this.pos.{var} = {var} || 0;",{indent:2})}
|
|
};`}function J(oe,te){let me=_e(oe),Me="";return te&&(Me=`${me(`
|
|
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(${me("{var}",{join:", "})}) {
|
|
${Me}
|
|
if (typeof arguments[0] === 'object') {
|
|
// could be another vector
|
|
let v = arguments[0];
|
|
${me('if (!Number.isFinite(v.{var})) throw new Error("Expected value is not a finite number at Vector constructor ({var})");',{indent:4})}
|
|
${me("this.{var} = v.{var};",{indent:4})}
|
|
} else {
|
|
${me('this.{var} = typeof {var} === "number" ? {var} : 0;',{indent:4})}
|
|
}
|
|
}
|
|
|
|
Vector.prototype.reset = function () {
|
|
${me("this.{var} = ",{join:""})}0;
|
|
};`}},36647:function(lt,Ze,he){const _e=he(15189);lt.exports=ye,lt.exports.generateCreateDragForceFunctionBody=fe;function ye(X){let J=fe(X);return new Function("options",J)}function fe(X){return`
|
|
if (!Number.isFinite(options.dragCoefficient)) throw new Error('dragCoefficient is not a finite number');
|
|
|
|
return {
|
|
update: function(body) {
|
|
${_e(X)("body.force.{var} -= options.dragCoefficient * body.velocity.{var};",{indent:6})}
|
|
}
|
|
};
|
|
`}},34079:function(lt,Ze,he){const _e=he(15189);lt.exports=ye,lt.exports.generateCreateSpringForceFunctionBody=fe;function ye(X){let J=fe(X);return new Function("options","random",J)}function fe(X){let J=_e(X);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;
|
|
}
|
|
};
|
|
`}},51763:function(lt,Ze,he){const _e=he(15189);lt.exports=ye,lt.exports.generateIntegratorFunctionBody=fe;function ye(X){let J=fe(X);return new Function("bodies","timeStep","adaptiveTimeStepWeight",J)}function fe(X){let J=_e(X);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;
|
|
`}},1584:function(lt,Ze,he){const _e=he(15189),ye=he(16422);lt.exports=fe,lt.exports.generateQuadTreeFunctionBody=X,lt.exports.getInsertStackCode=Me,lt.exports.getQuadNodeCode=me,lt.exports.isSamePosition=J,lt.exports.getChildBodyCode=te,lt.exports.setChildBodyCode=oe;function fe(Ne){let le=X(Ne);return new Function(le)()}function X(Ne){let le=_e(Ne),Be=Math.pow(2,Ne);return`
|
|
${Me()}
|
|
${me(Ne)}
|
|
${J(Ne)}
|
|
${te(Ne)}
|
|
${oe(Ne)}
|
|
|
|
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) {
|
|
${qe(" node.")}
|
|
node.body = null;
|
|
node.mass = ${le("node.mass_{var} = ",{join:""})}0;
|
|
${le("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;
|
|
${le("var d{var};",{indent:4})}
|
|
var r;
|
|
${le("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.
|
|
${le("d{var} = body.pos.{var} - sourceBody.pos.{var};",{indent:8})}
|
|
r = Math.sqrt(${le("d{var} * d{var}",{join:" + "})});
|
|
|
|
if (r === 0) {
|
|
// Poor man's protection against zero distance.
|
|
${le("d{var} = (random.nextDouble() - 0.5) / 50;",{indent:10})}
|
|
r = Math.sqrt(${le("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);
|
|
${le("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
|
|
${le("d{var} = node.mass_{var} / node.mass - sourceBody.pos.{var};",{indent:8})}
|
|
r = Math.sqrt(${le("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.
|
|
${le("d{var} = (random.nextDouble() - 0.5) / 50;",{indent:10})}
|
|
r = Math.sqrt(${le("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_${ye(0)} - node.min_${ye(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);
|
|
${le("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.
|
|
${Ae()}
|
|
}
|
|
}
|
|
}
|
|
|
|
${le("sourceBody.force.{var} += f{var};",{indent:4})}
|
|
}
|
|
|
|
function insertBodies(bodies) {
|
|
${le("var {var}min = Number.MAX_VALUE;",{indent:4})}
|
|
${le("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;
|
|
${le("if (pos.{var} < {var}min) {var}min = pos.{var};",{indent:6})}
|
|
${le("if (pos.{var} > {var}max) {var}max = pos.{var};",{indent:6})}
|
|
}
|
|
|
|
// Makes the bounds square.
|
|
var maxSideLength = -Infinity;
|
|
${le("if ({var}max - {var}min > maxSideLength) maxSideLength = {var}max - {var}min ;",{indent:4})}
|
|
|
|
currentInCache = 0;
|
|
root = newNode();
|
|
${le("root.min_{var} = {var}min;",{indent:4})}
|
|
${le("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.
|
|
${le("var {var} = body.pos.{var};",{indent:8})}
|
|
node.mass += body.mass;
|
|
${le("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.
|
|
${le("var min_{var} = node.min_{var};",{indent:8})}
|
|
${le("var max_{var} = (min_{var} + node.max_{var}) / 2;",{indent:8})}
|
|
|
|
${ke(8)}
|
|
|
|
var child = getChild(node, quadIdx);
|
|
|
|
if (!child) {
|
|
// The node is internal but this quadrant is not taken. Add
|
|
// subnode to it.
|
|
child = newNode();
|
|
${le("child.min_{var} = min_{var};",{indent:10})}
|
|
${le("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();
|
|
${le("var d{var} = (node.max_{var} - node.min_{var}) * offset;",{indent:12})}
|
|
|
|
${le("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 ke(et){let rt=[],at=Array(et+1).join(" ");for(let St=0;St<Ne;++St)rt.push(at+`if (${ye(St)} > max_${ye(St)}) {`),rt.push(at+` quadIdx = quadIdx + ${Math.pow(2,St)};`),rt.push(at+` min_${ye(St)} = max_${ye(St)};`),rt.push(at+` max_${ye(St)} = node.max_${ye(St)};`),rt.push(at+"}");return rt.join(`
|
|
`)}function Ae(){let et=Array(11).join(" "),rt=[];for(let at=0;at<Be;++at)rt.push(et+`if (node.quad${at}) {`),rt.push(et+` queue[pushIdx] = node.quad${at};`),rt.push(et+" queueLength += 1;"),rt.push(et+" pushIdx += 1;"),rt.push(et+"}");return rt.join(`
|
|
`)}function qe(et){let rt=[];for(let at=0;at<Be;++at)rt.push(`${et}quad${at} = null;`);return rt.join(`
|
|
`)}}function J(Ne){let le=_e(Ne);return`
|
|
function isSamePosition(point1, point2) {
|
|
${le("var d{var} = Math.abs(point1.{var} - point2.{var});",{indent:2})}
|
|
|
|
return ${le("d{var} < 1e-8",{join:" && "})};
|
|
}
|
|
`}function oe(Ne){var le=Math.pow(2,Ne);return`
|
|
function setChild(node, idx, child) {
|
|
${Be()}
|
|
}`;function Be(){let Ee=[];for(let ke=0;ke<le;++ke){let Ae=ke===0?" ":" else ";Ee.push(`${Ae}if (idx === ${ke}) node.quad${ke} = child;`)}return Ee.join(`
|
|
`)}}function te(Ne){return`function getChild(node, idx) {
|
|
${le()}
|
|
return null;
|
|
}`;function le(){let Be=[],Ee=Math.pow(2,Ne);for(let ke=0;ke<Ee;++ke)Be.push(` if (idx === ${ke}) return node.quad${ke};`);return Be.join(`
|
|
`)}}function me(Ne){let le=_e(Ne),Be=Math.pow(2,Ne);var Ee=`
|
|
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
|
|
${ke(" this.")}
|
|
|
|
// Total mass of current node
|
|
this.mass = 0;
|
|
|
|
// Center of mass coordinates
|
|
${le("this.mass_{var} = 0;",{indent:2})}
|
|
|
|
// bounding box coordinates
|
|
${le("this.min_{var} = 0;",{indent:2})}
|
|
${le("this.max_{var} = 0;",{indent:2})}
|
|
}
|
|
`;return Ee;function ke(Ae){let qe=[];for(let et=0;et<Be;++et)qe.push(`${Ae}quad${et} = null;`);return qe.join(`
|
|
`)}}function Me(){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
|
|
}
|
|
`}},16422:function(lt){lt.exports=function(he){return he===0?"x":he===1?"y":he===2?"z":"c"+(he+1)}},45818:function(lt,Ze,he){lt.exports=me;var _e=he(6410),ye=he(1584),fe=he(30891),X=he(36647),J=he(34079),oe=he(51763),te={};function me(le){var Be=he(68403),Ee=he(35510),ke=he(77797);if(le){if(le.springCoeff!==void 0)throw new Error("springCoeff was renamed to springCoefficient");if(le.dragCoeff!==void 0)throw new Error("dragCoeff was renamed to dragCoefficient")}le=Ee(le,{springLength:10,springCoefficient:.8,gravity:-12,theta:.8,dragCoefficient:.9,timeStep:.5,adaptiveTimeStepWeight:0,dimensions:2,debug:!1});var Ae=te[le.dimensions];if(!Ae){var qe=le.dimensions;Ae={Body:_e(qe,le.debug),createQuadTree:ye(qe),createBounds:fe(qe),createDragForce:X(qe),createSpringForce:J(qe),integrate:oe(qe)},te[qe]=Ae}var et=Ae.Body,rt=Ae.createQuadTree,at=Ae.createBounds,St=Ae.createDragForce,Ot=Ae.createSpringForce,Fn=Ae.integrate,os=Sn=>new et(Sn),Bn=he(78712).random(42),ei=[],ni=[],bs=rt(le,Bn),vr=at(ei,le,Bn),Zr=Ot(le,Bn),Kr=St(le),Ss=0,xa=[],va=new Map,Tt=0;hs("nbody",J_),hs("spring",Wu);var rn={bodies:ei,quadTree:bs,springs:ni,settings:le,addForce:hs,removeForce:Il,getForces:Hu,step:function(){for(var Sn=0;Sn<xa.length;++Sn)xa[Sn](Tt);var yi=Fn(ei,le.timeStep,le.adaptiveTimeStepWeight);return Tt+=1,yi},addBody:function(Sn){if(!Sn)throw new Error("Body is required");return ei.push(Sn),Sn},addBodyAt:function(Sn){if(!Sn)throw new Error("Body position is required");var yi=os(Sn);return ei.push(yi),yi},removeBody:function(Sn){if(Sn){var yi=ei.indexOf(Sn);if(!(yi<0))return ei.splice(yi,1),ei.length===0&&vr.reset(),!0}},addSpring:function(Sn,yi,Jr,Ec){if(!Sn||!yi)throw new Error("Cannot add null spring to force simulator");typeof Jr!="number"&&(Jr=-1);var Cc=new Be(Sn,yi,Jr,Ec>=0?Ec:-1);return ni.push(Cc),Cc},getTotalMovement:function(){return Ss},removeSpring:function(Sn){if(Sn){var yi=ni.indexOf(Sn);if(yi>-1)return ni.splice(yi,1),!0}},getBestNewBodyPosition:function(Sn){return vr.getBestNewPosition(Sn)},getBBox:On,getBoundingBox:On,invalidateBBox:function(){console.warn("invalidateBBox() is deprecated, bounds always recomputed on `getBBox()` call")},gravity:function(Sn){return Sn!==void 0?(le.gravity=Sn,bs.options({gravity:Sn}),this):le.gravity},theta:function(Sn){return Sn!==void 0?(le.theta=Sn,bs.options({theta:Sn}),this):le.theta},random:Bn};return Me(le,rn),ke(rn),rn;function On(){return vr.update(),vr.box}function hs(Sn,yi){if(va.has(Sn))throw new Error("Force "+Sn+" is already added");va.set(Sn,yi),xa.push(yi)}function Il(Sn){var yi=xa.indexOf(va.get(Sn));yi<0||(xa.splice(yi,1),va.delete(Sn))}function Hu(){return va}function J_(){if(ei.length!==0){bs.insertBodies(ei);for(var Sn=ei.length;Sn--;){var yi=ei[Sn];yi.isPinned||(yi.reset(),bs.updateBodyForce(yi),Kr.update(yi))}}}function Wu(){for(var Sn=ni.length;Sn--;)Zr.update(ni[Sn])}}function Me(le,Be){for(var Ee in le)Ne(le,Be,Ee)}function Ne(le,Be,Ee){if(le.hasOwnProperty(Ee)&&typeof Be[Ee]!="function"){var ke=Number.isFinite(le[Ee]);ke?Be[Ee]=function(Ae){if(Ae!==void 0){if(!Number.isFinite(Ae))throw new Error("Value of "+Ee+" should be a valid number.");return le[Ee]=Ae,Be}return le[Ee]}:Be[Ee]=function(Ae){return Ae!==void 0?(le[Ee]=Ae,Be):le[Ee]}}}},68403:function(lt){lt.exports=Ze;function Ze(he,_e,ye,fe){this.from=he,this.to=_e,this.length=ye,this.coefficient=fe}},35510:function(lt){lt.exports=Ze;function Ze(he,_e){var ye;if(he||(he={}),_e){for(ye in _e)if(_e.hasOwnProperty(ye)){var fe=he.hasOwnProperty(ye),X=typeof _e[ye],J=!fe||typeof he[ye]!==X;J?he[ye]=_e[ye]:X==="object"&&(he[ye]=Ze(he[ye],_e[ye]))}}return he}},78712:function(lt){lt.exports=Ze,lt.exports.random=Ze,lt.exports.randomIterator=oe;function Ze(te){var me=typeof te=="number"?te:+new Date;return new he(me)}function he(te){this.seed=te}he.prototype.next=J,he.prototype.nextDouble=X,he.prototype.uniform=X,he.prototype.gaussian=_e,he.prototype.random=X;function _e(){var te,me,Me;do me=this.nextDouble()*2-1,Me=this.nextDouble()*2-1,te=me*me+Me*Me;while(te>=1||te===0);return me*Math.sqrt(-2*Math.log(te)/te)}he.prototype.levy=ye;function ye(){var te=1.5,me=Math.pow(fe(1+te)*Math.sin(Math.PI*te/2)/(fe((1+te)/2)*te*Math.pow(2,(te-1)/2)),1/te);return this.gaussian()*me/Math.pow(Math.abs(this.gaussian()),1/te)}function fe(te){return Math.sqrt(2*Math.PI/te)*Math.pow(1/Math.E*(te+1/(12*te-1/(10*te))),te)}function X(){var te=this.seed;return te=te+2127912214+(te<<12)&4294967295,te=(te^3345072700^te>>>19)&4294967295,te=te+374761393+(te<<5)&4294967295,te=(te+3550635116^te<<9)&4294967295,te=te+4251993797+(te<<3)&4294967295,te=(te^3042594569^te>>>16)&4294967295,this.seed=te,(te&268435455)/268435456}function J(te){return Math.floor(this.nextDouble()*te)}function oe(te,me){var Me=me||Ze();if(typeof Me.next!="function")throw new Error("customRandom does not match expected API: next() function is missing");return{forEach:le,shuffle:Ne};function Ne(){var Be,Ee,ke;for(Be=te.length-1;Be>0;--Be)Ee=Me.next(Be+1),ke=te[Ee],te[Ee]=te[Be],te[Be]=ke;return te}function le(Be){var Ee,ke,Ae;for(Ee=te.length-1;Ee>0;--Ee)ke=Me.next(Ee+1),Ae=te[ke],te[ke]=te[Ee],te[Ee]=Ae,Be(Ae);te.length&&Be(te[0])}}},77797:function(lt){"use strict";function Ze(ye){_e(ye);const fe=he(ye);return ye.on=fe.on,ye.off=fe.off,ye.fire=fe.fire,ye}function he(ye){let fe=Object.create(null);return{on:function(X,J,oe){if(typeof J!="function")throw new Error("callback is expected to be a function");let te=fe[X];return te||(te=fe[X]=[]),te.push({callback:J,ctx:oe}),ye},off:function(X,J){if(typeof X>"u")return fe=Object.create(null),ye;if(fe[X])if(typeof J!="function")delete fe[X];else{const oe=fe[X];for(let te=0;te<oe.length;++te)oe[te].callback===J&&oe.splice(te,1)}return ye},fire:function(X){const J=fe[X];if(!J)return ye;let oe;arguments.length>1&&(oe=Array.prototype.slice.call(arguments,1));for(let te=0;te<J.length;++te){const me=J[te];me.callback.apply(me.ctx,oe)}return ye}}}function _e(ye){if(!ye)throw new Error("Eventify cannot use falsy object as events subject");const fe=["on","fire","off"];for(let X=0;X<fe.length;++X)if(ye.hasOwnProperty(fe[X]))throw new Error("Subject cannot be eventified, since it already has property '"+fe[X]+"'")}lt.exports=Ze},82309:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return fY}});const _e="180",ye={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},fe={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},X=0,J=1,oe=2,te=3,me=0,Me=1,Ne=2,le=3,Be=0,Ee=1,ke=2,Ae=0,qe=1,et=2,rt=3,at=4,St=5,Ot=100,Fn=101,os=102,Bn=103,ei=104,ni=200,bs=201,vr=202,Zr=203,Kr=204,Ss=205,xa=206,va=207,Tt=208,rn=209,On=210,hs=211,Il=212,Hu=213,J_=214,Wu=0,Sn=1,yi=2,Jr=3,Ec=4,Cc=5,pp=6,mp=7,Rc=0,db=1,fb=2,Qr=0,pb=1,mb=2,gb=3,yb=4,E1=5,_b=6,xb=7,lg="attached",vb="detached",$u=300,Br=301,Vo=302,Nc=303,Pc=304,Ll=306,ba=1e3,Ki=1001,Sa=1002,Jn=1003,gp=1004,hD=1004,Ta=1005,dD=1005,Yn=1006,Ic=1007,fD=1007,Ds=1008,C1=1008,Ui=1009,Lc=1010,Dc=1011,Go=1012,Ws=1013,pi=1014,mi=1015,Ts=1016,yp=1017,_p=1018,mo=1020,xp=35902,vp=35899,cg=1021,bd=1022,_i=1023,Or=1026,eo=1027,Fc=1028,Dl=1029,rl=1030,qu=1031,R1=1032,Xu=1033,Fl=33776,Bl=33777,Ol=33778,Ul=33779,Sd=35840,Td=35841,wd=35842,Md=35843,ju=36196,Yu=37492,Zu=37496,Ku=37808,Ju=37809,Qu=37810,eh=37811,th=37812,nh=37813,ih=37814,sh=37815,rh=37816,oh=37817,ah=37818,lh=37819,ch=37820,uh=37821,hh=36492,ug=36494,hg=36495,dh=36283,fh=36284,ph=36285,mh=36286,bb=2200,Sb=2201,Tb=2202,Bc=2300,Ad=2301,Ed=2302,Ho=2400,Wo=2401,Oc=2402,Cd=2500,dg=2501,pD=0,mD=1,gD=2,wb=3200,N1=3201,yD=3202,_D=3203,Ur=0,Mb=1,br="",Ei="srgb",ol="srgb-linear",Uc="linear",Dt="srgb",P1=0,go=7680,I1=7681,L1=7682,D1=7683,F1=34055,B1=34056,O1=5386,U1=512,k1=513,z1=514,V1=515,G1=516,H1=517,W1=518,bp=519,Q_=512,fg=513,e0=514,pg=515,t0=516,n0=517,i0=518,s0=519,kl=35044,Rd=35048,xD=35040,vD=35045,bD=35049,SD=35041,TD=35046,wD=35050,MD=35042,AD="100",Ab="300 es",ki=2e3,Sr=2001,Nd={COMPUTE:"compute",RENDER:"render"},ED={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},CD={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"};class wa{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 cr=["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 kc=1234567;const Ma=Math.PI/180,gh=180/Math.PI;function kr(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(cr[i&255]+cr[i>>8&255]+cr[i>>16&255]+cr[i>>24&255]+"-"+cr[e&255]+cr[e>>8&255]+"-"+cr[e>>16&15|64]+cr[e>>24&255]+"-"+cr[t&63|128]+cr[t>>8&255]+"-"+cr[t>>16&255]+cr[t>>24&255]+cr[n&255]+cr[n>>8&255]+cr[n>>16&255]+cr[n>>24&255]).toLowerCase()}function fn(i,e,t){return Math.max(e,Math.min(t,i))}function r0(i,e){return(i%e+e)%e}function $1(i,e,t,n,r){return n+(i-e)*(r-n)/(t-e)}function o0(i,e,t){return i!==e?(t-i)/(e-i):0}function _n(i,e,t){return(1-t)*i+t*e}function ci(i,e,t,n){return _n(i,e,1-Math.exp(-t*n))}function a0(i,e=1){return e-Math.abs(r0(i,e*2)-e)}function q1(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*(3-2*i))}function Sp(i,e,t){return i<=e?0:i>=t?1:(i=(i-e)/(t-e),i*i*i*(i*(i*6-15)+10))}function ur(i,e){return i+Math.floor(Math.random()*(e-i+1))}function l0(i,e){return i+Math.random()*(e-i)}function zc(i){return i*(.5-Math.random())}function Pd(i){i!==void 0&&(kc=i);let e=kc+=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 to(i){return i*Ma}function Tn(i){return i*gh}function mg(i){return(i&i-1)===0&&i!==0}function Eb(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function Cb(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Id(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:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+r)}}function Tr(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 Vn(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 Ld={DEG2RAD:Ma,RAD2DEG:gh,generateUUID:kr,clamp:fn,euclideanModulo:r0,mapLinear:$1,inverseLerp:o0,lerp:_n,damp:ci,pingpong:a0,smoothstep:q1,smootherstep:Sp,randInt:ur,randFloat:l0,randFloatSpread:zc,seededRandom:Pd,degToRad:to,radToDeg:Tn,isPowerOfTwo:mg,ceilPowerOfTwo:Eb,floorPowerOfTwo:Cb,setQuaternionFromProperEuler:Id,normalize:Vn,denormalize:Tr};class Ie{constructor(e=0,t=0){Ie.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=fn(this.x,e.x,t.x),this.y=fn(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=fn(this.x,e,t),this.y=fn(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(fn(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(fn(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 Fs{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];const y=o[a+0],x=o[a+1],v=o[a+2],M=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]=M;return}if(m!==M||u!==y||d!==x||p!==v){let T=1-c;const S=u*y+d*x+p*v+m*M,N=S>=0?1:-1,R=1-S*S;if(R>Number.EPSILON){const B=Math.sqrt(R),F=Math.atan2(B,S*N);T=Math.sin(T*F)/B,c=Math.sin(c*F)/B}const P=c*N;if(u=u*T+y*P,d=d*T+x*P,p=p*T+v*P,m=m*T+M*P,T===1-c){const B=1/Math.sqrt(u*u+d*d+p*p+m*m);u*=B,d*=B,p*=B,m*=B}}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:console.warn("THREE.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(fn(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);const n=this._x,r=this._y,o=this._z,a=this._w;let c=a*e._w+n*e._x+r*e._y+o*e._z;if(c<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,c=-c):this.copy(e),c>=1)return this._w=a,this._x=n,this._y=r,this._z=o,this;const u=1-c*c;if(u<=Number.EPSILON){const x=1-t;return this._w=x*a+t*this._w,this._x=x*n+t*this._x,this._y=x*r+t*this._y,this._z=x*o+t*this._z,this.normalize(),this}const d=Math.sqrt(u),p=Math.atan2(d,c),m=Math.sin((1-t)*p)/d,y=Math.sin(t*p)/d;return this._w=a*m+this._w*y,this._x=n*m+this._x*y,this._y=r*m+this._y*y,this._z=o*m+this._z*y,this._onChangeCallback(),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 W{constructor(e=0,t=0,n=0){W.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(c0.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(c0.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=fn(this.x,e.x,t.x),this.y=fn(this.y,e.y,t.y),this.z=fn(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=fn(this.x,e,t),this.y=fn(this.y,e,t),this.z=fn(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(fn(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 gg.copy(this).projectOnVector(e),this.sub(gg)}reflect(e){return this.sub(gg.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(fn(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 gg=new W,c0=new Fs;class Cn{constructor(e,t,n,r,o,a,c,u,d){Cn.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],M=r[0],T=r[3],S=r[6],N=r[1],R=r[4],P=r[7],B=r[2],F=r[5],k=r[8];return o[0]=a*M+c*N+u*B,o[3]=a*T+c*R+u*F,o[6]=a*S+c*P+u*k,o[1]=d*M+p*N+m*B,o[4]=d*T+p*R+m*F,o[7]=d*S+p*P+m*k,o[2]=y*M+x*N+v*B,o[5]=y*T+x*R+v*F,o[8]=y*S+x*P+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 M=1/v;return e[0]=m*M,e[1]=(r*d-p*n)*M,e[2]=(c*n-r*a)*M,e[3]=y*M,e[4]=(p*t-r*u)*M,e[5]=(r*o-c*t)*M,e[6]=x*M,e[7]=(n*u-d*t)*M,e[8]=(a*t-n*o)*M,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,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(yg.makeScale(e,t)),this}rotate(e){return this.premultiply(yg.makeRotation(-e)),this}translate(e,t){return this.premultiply(yg.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 yg=new Cn;function _g(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}const Rb={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function yh(i,e){return new Rb[i](e)}function Dd(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function hr(){const i=Dd("canvas");return i.style.display="block",i}const kn={};function wr(i){i in kn||(kn[i]=!0,console.warn(i))}function pt(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)})}const zr=new Cn().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),ne=new Cn().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function xg(){const i={enabled:!0,workingColorSpace:ol,spaces:{},convert:function(r,o,a){return this.enabled===!1||o===a||!o||!a||(this.spaces[o].transfer===Dt&&(r.r=$s(r.r),r.g=$s(r.g),r.b=$s(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===Dt&&(r.r=zl(r.r),r.g=zl(r.g),r.b=zl(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===br?Uc: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 wr("THREE.ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(r,o)},toWorkingColorSpace:function(r,o){return wr("THREE.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({[ol]:{primaries:e,whitePoint:n,transfer:Uc,toXYZ:zr,fromXYZ:ne,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:Ei},outputColorSpaceConfig:{drawingBufferColorSpace:Ei}},[Ei]:{primaries:e,whitePoint:n,transfer:Dt,toXYZ:zr,fromXYZ:ne,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:Ei}}}),i}const pn=xg();function $s(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function zl(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let Vc;class u0{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{Vc===void 0&&(Vc=Dd("canvas")),Vc.width=e.width,Vc.height=e.height;const r=Vc.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),n=Vc}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=Dd("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]=$s(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($s(t[n]/255)*255):t[n]=$s(t[n]);return{data:t,width:e.width,height:e.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Nb=0;class Bs{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Nb++}),this.uuid=kr(),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):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($o(r[a].image)):o.push($o(r[a]))}else o=$o(r);n.url=o}return t||(e.images[this.uuid]=n),n}}function $o(i){return typeof HTMLImageElement!="undefined"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&i instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&i instanceof ImageBitmap?u0.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let _h=0;const Vl=new W;class ds extends wa{constructor(e=ds.DEFAULT_IMAGE,t=ds.DEFAULT_MAPPING,n=Ki,r=Ki,o=Yn,a=Ds,c=_i,u=Ui,d=ds.DEFAULT_ANISOTROPY,p=br){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:_h++}),this.uuid=kr(),this.name="",this.source=new Bs(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 Ie(0,0),this.repeat=new Ie(1,1),this.center=new Ie(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Cn,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(Vl).x}get height(){return this.source.getSize(Vl).y}get depth(){return this.source.getSize(Vl).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){console.warn(`THREE.Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.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!==$u)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case ba:e.x=e.x-Math.floor(e.x);break;case Ki:e.x=e.x<0?0:1;break;case Sa: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 ba:e.y=e.y-Math.floor(e.y);break;case Ki:e.y=e.y<0?0:1;break;case Sa: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++}}ds.DEFAULT_IMAGE=null,ds.DEFAULT_MAPPING=$u,ds.DEFAULT_ANISOTROPY=1;class an{constructor(e=0,t=0,n=0,r=1){an.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],M=u[2],T=u[6],S=u[10];if(Math.abs(p-y)<.01&&Math.abs(m-M)<.01&&Math.abs(v-T)<.01){if(Math.abs(p+y)<.1&&Math.abs(m+M)<.1&&Math.abs(v+T)<.1&&Math.abs(d+x+S-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const R=(d+1)/2,P=(x+1)/2,B=(S+1)/2,F=(p+y)/4,k=(m+M)/4,V=(v+T)/4;return R>P&&R>B?R<.01?(n=0,r=.707106781,o=.707106781):(n=Math.sqrt(R),r=F/n,o=k/n):P>B?P<.01?(n=.707106781,r=0,o=.707106781):(r=Math.sqrt(P),n=F/r,o=V/r):B<.01?(n=.707106781,r=.707106781,o=0):(o=Math.sqrt(B),n=k/o,r=V/o),this.set(n,r,o,t),this}let N=Math.sqrt((T-v)*(T-v)+(m-M)*(m-M)+(y-p)*(y-p));return Math.abs(N)<.001&&(N=1),this.x=(T-v)/N,this.y=(m-M)/N,this.z=(y-p)/N,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=fn(this.x,e.x,t.x),this.y=fn(this.y,e.y,t.y),this.z=fn(this.z,e.z,t.z),this.w=fn(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=fn(this.x,e,t),this.y=fn(this.y,e,t),this.z=fn(this.z,e,t),this.w=fn(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(fn(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 Mr extends wa{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 an(0,0,e,t),this.scissorTest=!1,this.viewport=new an(0,0,e,t);const r={width:e,height:t,depth:n.depth},o=new ds(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].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 Bs(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 Aa extends Mr{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class Tp extends ds{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=Jn,this.minFilter=Jn,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 h0 extends null{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isWebGLArrayRenderTarget=!0,this.depth=n,this.texture=new Tp(null,e,t,n),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}}class no extends ds{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=Jn,this.minFilter=Jn,this.wrapR=Ki,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class tr extends null{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isWebGL3DRenderTarget=!0,this.depth=n,this.texture=new no(null,e,t,n),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}}class dr{constructor(e=new W(1/0,1/0,1/0),t=new W(-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(qo.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(qo.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=qo.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,qo):qo.fromBufferAttribute(o,a),qo.applyMatrix4(e.matrixWorld),this.expandByPoint(qo);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),vg.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),vg.copy(n.boundingBox)),vg.applyMatrix4(e.matrixWorld),this.union(vg)}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,qo),qo.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(Ca),al.subVectors(this.max,Ca),Gc.subVectors(e.a,Ca),Fd.subVectors(e.b,Ca),ws.subVectors(e.c,Ca),fr.subVectors(Fd,Gc),qs.subVectors(ws,Fd),Ea.subVectors(Gc,ws);let t=[0,-fr.z,fr.y,0,-qs.z,qs.y,0,-Ea.z,Ea.y,fr.z,0,-fr.x,qs.z,0,-qs.x,Ea.z,0,-Ea.x,-fr.y,fr.x,0,-qs.y,qs.x,0,-Ea.y,Ea.x,0];return!Ra(t,Gc,Fd,ws,al)||(t=[1,0,0,0,1,0,0,0,1],!Ra(t,Gc,Fd,ws,al))?!1:(ll.crossVectors(fr,qs),t=[ll.x,ll.y,ll.z],Ra(t,Gc,Fd,ws,al))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,qo).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(qo).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:(Gl[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Gl[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Gl[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Gl[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Gl[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Gl[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Gl[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Gl[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Gl),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 Gl=[new W,new W,new W,new W,new W,new W,new W,new W],qo=new W,vg=new dr,Gc=new W,Fd=new W,ws=new W,fr=new W,qs=new W,Ea=new W,Ca=new W,al=new W,ll=new W,Vr=new W;function Ra(i,e,t,n,r){for(let o=0,a=i.length-3;o<=a;o+=3){Vr.fromArray(i,o);const c=r.x*Math.abs(Vr.x)+r.y*Math.abs(Vr.y)+r.z*Math.abs(Vr.z),u=e.dot(Vr),d=t.dot(Vr),p=n.dot(Vr);if(Math.max(-Math.max(u,d,p),Math.min(u,d,p))>c)return!1}return!0}const Hc=new dr,cl=new W,xh=new W;class Ms{constructor(e=new W,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):Hc.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;cl.subVectors(e,this.center);const t=cl.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),r=(n-this.radius)*.5;this.center.addScaledVector(cl,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):(xh.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(cl.copy(e.center).add(xh)),this.expandByPoint(cl.copy(e.center).sub(xh))),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 Ar=new W,Bd=new W,wp=new W,yo=new W,Od=new W,Os=new W,Xo=new W;class Hl{constructor(e=new W,t=new W(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,Ar)),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=Ar.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Ar.copy(this.origin).addScaledVector(this.direction,t),Ar.distanceToSquared(e))}distanceSqToSegment(e,t,n,r){Bd.copy(e).add(t).multiplyScalar(.5),wp.copy(t).sub(e).normalize(),yo.copy(this.origin).sub(Bd);const o=e.distanceTo(t)*.5,a=-this.direction.dot(wp),c=yo.dot(this.direction),u=-yo.dot(wp),d=yo.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 M=1/p;m*=M,y*=M,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(Bd).addScaledVector(wp,y),x}intersectSphere(e,t){Ar.subVectors(e.center,this.origin);const n=Ar.dot(this.direction),r=Ar.dot(Ar)-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,Ar)!==null}intersectTriangle(e,t,n,r,o){Od.subVectors(t,e),Os.subVectors(n,e),Xo.crossVectors(Od,Os);let a=this.direction.dot(Xo),c;if(a>0){if(r)return null;c=1}else if(a<0)c=-1,a=-a;else return null;yo.subVectors(this.origin,e);const u=c*this.direction.dot(Os.crossVectors(yo,Os));if(u<0)return null;const d=c*this.direction.dot(Od.cross(yo));if(d<0||u+d>a)return null;const p=-c*yo.dot(Xo);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 Vt{constructor(e,t,n,r,o,a,c,u,d,p,m,y,x,v,M,T){Vt.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,M,T)}set(e,t,n,r,o,a,c,u,d,p,m,y,x,v,M,T){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]=M,S[15]=T,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 Vt().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 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){const t=this.elements,n=e.elements,r=1/io.setFromMatrixColumn(e,0).length(),o=1/io.setFromMatrixColumn(e,1).length(),a=1/io.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,M=c*m;t[0]=u*p,t[4]=-u*m,t[8]=d,t[1]=x+v*d,t[5]=y-M*d,t[9]=-c*u,t[2]=M-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,M=d*m;t[0]=y+M*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]=M+y*c,t[10]=a*u}else if(e.order==="ZXY"){const y=u*p,x=u*m,v=d*p,M=d*m;t[0]=y-M*c,t[4]=-a*m,t[8]=v+x*c,t[1]=x+v*c,t[5]=a*p,t[9]=M-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,M=c*m;t[0]=u*p,t[4]=v*d-x,t[8]=y*d+M,t[1]=u*m,t[5]=M*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,M=c*d;t[0]=u*p,t[4]=M-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-M*m}else if(e.order==="XZY"){const y=a*u,x=a*d,v=c*u,M=c*d;t[0]=u*p,t[4]=-m,t[8]=d*p,t[1]=y*m+M,t[5]=a*p,t[9]=x*m-v,t[2]=v*m-x,t[6]=c*p,t[10]=M*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(Mp,e,bg)}lookAt(e,t,n){const r=this.elements;return Xs.subVectors(e,t),Xs.lengthSq()===0&&(Xs.z=1),Xs.normalize(),_o.crossVectors(n,Xs),_o.lengthSq()===0&&(Math.abs(n.z)===1?Xs.x+=1e-4:Xs.z+=1e-4,Xs.normalize(),_o.crossVectors(n,Xs)),_o.normalize(),Pn.crossVectors(Xs,_o),r[0]=_o.x,r[4]=Pn.x,r[8]=Xs.x,r[1]=_o.y,r[5]=Pn.y,r[9]=Xs.y,r[2]=_o.z,r[6]=Pn.z,r[10]=Xs.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],M=n[6],T=n[10],S=n[14],N=n[3],R=n[7],P=n[11],B=n[15],F=r[0],k=r[4],V=r[8],U=r[12],z=r[1],j=r[5],se=r[9],pe=r[13],be=r[2],Pe=r[6],Ce=r[10],nt=r[14],Le=r[3],ht=r[7],De=r[11],Je=r[15];return o[0]=a*F+c*z+u*be+d*Le,o[4]=a*k+c*j+u*Pe+d*ht,o[8]=a*V+c*se+u*Ce+d*De,o[12]=a*U+c*pe+u*nt+d*Je,o[1]=p*F+m*z+y*be+x*Le,o[5]=p*k+m*j+y*Pe+x*ht,o[9]=p*V+m*se+y*Ce+x*De,o[13]=p*U+m*pe+y*nt+x*Je,o[2]=v*F+M*z+T*be+S*Le,o[6]=v*k+M*j+T*Pe+S*ht,o[10]=v*V+M*se+T*Ce+S*De,o[14]=v*U+M*pe+T*nt+S*Je,o[3]=N*F+R*z+P*be+B*Le,o[7]=N*k+R*j+P*Pe+B*ht,o[11]=N*V+R*se+P*Ce+B*De,o[15]=N*U+R*pe+P*nt+B*Je,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],M=e[7],T=e[11],S=e[15];return v*(+o*u*m-r*d*m-o*c*y+n*d*y+r*c*x-n*u*x)+M*(+t*u*x-t*d*y+o*a*y-r*a*x+r*d*p-o*u*p)+T*(+t*d*m-t*c*x-o*a*m+n*a*x+o*c*p-n*d*p)+S*(-r*c*p-t*u*m+t*c*y+r*a*m-n*a*y+n*u*p)}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],M=e[13],T=e[14],S=e[15],N=m*T*d-M*y*d+M*u*x-c*T*x-m*u*S+c*y*S,R=v*y*d-p*T*d-v*u*x+a*T*x+p*u*S-a*y*S,P=p*M*d-v*m*d+v*c*x-a*M*x-p*c*S+a*m*S,B=v*m*u-p*M*u-v*c*y+a*M*y+p*c*T-a*m*T,F=t*N+n*R+r*P+o*B;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]=N*k,e[1]=(M*y*o-m*T*o-M*r*x+n*T*x+m*r*S-n*y*S)*k,e[2]=(c*T*o-M*u*o+M*r*d-n*T*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]=R*k,e[5]=(p*T*o-v*y*o+v*r*x-t*T*x-p*r*S+t*y*S)*k,e[6]=(v*u*o-a*T*o-v*r*d+t*T*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]=P*k,e[9]=(v*m*o-p*M*o-v*n*x+t*M*x+p*n*S-t*m*S)*k,e[10]=(a*M*o-v*c*o+v*n*d-t*M*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]=B*k,e[13]=(p*M*r-v*m*r+v*n*y-t*M*y-p*n*T+t*m*T)*k,e[14]=(v*c*r-a*M*r-v*n*u+t*M*u+a*n*T-t*c*T)*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,M=a*p,T=a*m,S=c*m,N=u*d,R=u*p,P=u*m,B=n.x,F=n.y,k=n.z;return r[0]=(1-(M+S))*B,r[1]=(x+P)*B,r[2]=(v-R)*B,r[3]=0,r[4]=(x-P)*F,r[5]=(1-(y+S))*F,r[6]=(T+N)*F,r[7]=0,r[8]=(v+R)*k,r[9]=(T-N)*k,r[10]=(1-(y+M))*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;let o=io.set(r[0],r[1],r[2]).length();const a=io.set(r[4],r[5],r[6]).length(),c=io.set(r[8],r[9],r[10]).length();this.determinant()<0&&(o=-o),e.x=r[12],e.y=r[13],e.z=r[14],so.copy(this);const d=1/o,p=1/a,m=1/c;return so.elements[0]*=d,so.elements[1]*=d,so.elements[2]*=d,so.elements[4]*=p,so.elements[5]*=p,so.elements[6]*=p,so.elements[8]*=m,so.elements[9]*=m,so.elements[10]*=m,t.setFromRotationMatrix(so),n.x=o,n.y=a,n.z=c,this}makePerspective(e,t,n,r,o,a,c=ki,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,M;if(u)v=o/(a-o),M=a*o/(a-o);else if(c===ki)v=-(a+o)/(a-o),M=-2*a*o/(a-o);else if(c===Sr)v=-a/(a-o),M=-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]=M,d[3]=0,d[7]=0,d[11]=-1,d[15]=0,this}makeOrthographic(e,t,n,r,o,a,c=ki,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,M;if(u)v=1/(a-o),M=a/(a-o);else if(c===ki)v=-2/(a-o),M=-(a+o)/(a-o);else if(c===Sr)v=-1/(a-o),M=-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]=M,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 io=new W,so=new Vt,Mp=new W(0,0,0),bg=new W(1,1,1),_o=new W,Pn=new W,Xs=new W,xo=new Vt,d0=new Fs;class Gr{constructor(e=0,t=0,n=0,r=Gr.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(fn(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(-fn(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(fn(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(-fn(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(fn(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(-fn(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:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return xo.makeRotationFromQuaternion(e),this.setFromRotationMatrix(xo,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return d0.setFromEuler(this),this.setFromQuaternion(d0,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}}Gr.DEFAULT_ORDER="XYZ";class Na{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 Ap=0;const Hr=new W,Wc=new Fs,Pa=new Vt,ro=new W,vh=new W,Pb=new W,f0=new Fs,$c=new W(1,0,0),Ia=new W(0,1,0),Ud=new W(0,0,1),bh={type:"added"},Ib={type:"removed"},Sh={type:"childadded",child:null},Ep={type:"childremoved",child:null};class Hi extends wa{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Ap++}),this.uuid=kr(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Hi.DEFAULT_UP.clone();const e=new W,t=new Gr,n=new Fs,r=new W(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 Vt},normalMatrix:{value:new Cn}}),this.matrix=new Vt,this.matrixWorld=new Vt,this.matrixAutoUpdate=Hi.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Hi.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Na,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 Wc.setFromAxisAngle(e,t),this.quaternion.multiply(Wc),this}rotateOnWorldAxis(e,t){return Wc.setFromAxisAngle(e,t),this.quaternion.premultiply(Wc),this}rotateX(e){return this.rotateOnAxis($c,e)}rotateY(e){return this.rotateOnAxis(Ia,e)}rotateZ(e){return this.rotateOnAxis(Ud,e)}translateOnAxis(e,t){return Hr.copy(e).applyQuaternion(this.quaternion),this.position.add(Hr.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis($c,e)}translateY(e){return this.translateOnAxis(Ia,e)}translateZ(e){return this.translateOnAxis(Ud,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(Pa.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?ro.copy(e):ro.set(e,t,n);const r=this.parent;this.updateWorldMatrix(!0,!1),vh.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Pa.lookAt(vh,ro,this.up):Pa.lookAt(ro,vh,this.up),this.quaternion.setFromRotationMatrix(Pa),r&&(Pa.extractRotation(r.matrixWorld),Wc.setFromRotationMatrix(Pa),this.quaternion.premultiply(Wc.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(console.error("THREE.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(bh),Sh.child=e,this.dispatchEvent(Sh),Sh.child=null):console.error("THREE.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(Ib),Ep.child=e,this.dispatchEvent(Ep),Ep.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),Pa.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),Pa.multiply(e.parent.matrixWorld)),e.applyMatrix4(Pa),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(bh),Sh.child=e,this.dispatchEvent(Sh),Sh.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(vh,e,Pb),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(vh,f0,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=>_a(Ii({},c),{boundingBox:c.boundingBox?c.boundingBox.toJSON():void 0,boundingSphere:c.boundingSphere?c.boundingSphere.toJSON():void 0})),r.instanceInfo=this._instanceInfo.map(c=>Ii({},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}}Hi.DEFAULT_UP=new W(0,1,0),Hi.DEFAULT_MATRIX_AUTO_UPDATE=!0,Hi.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const vo=new W,La=new W,Sg=new W,Wr=new W,Wl=new W,Wi=new W,bo=new W,jo=new W,kd=new W,Yo=new W,$l=new an,ql=new an,Cp=new an;class Er{constructor(e=new W,t=new W,n=new W){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,r){r.subVectors(n,t),vo.subVectors(e,t),r.cross(vo);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){vo.subVectors(r,t),La.subVectors(n,t),Sg.subVectors(e,t);const a=vo.dot(vo),c=vo.dot(La),u=vo.dot(Sg),d=La.dot(La),p=La.dot(Sg),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,Wr)===null?!1:Wr.x>=0&&Wr.y>=0&&Wr.x+Wr.y<=1}static getInterpolation(e,t,n,r,o,a,c,u){return this.getBarycoord(e,t,n,r,Wr)===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,Wr.x),u.addScaledVector(a,Wr.y),u.addScaledVector(c,Wr.z),u)}static getInterpolatedAttribute(e,t,n,r,o,a){return $l.setScalar(0),ql.setScalar(0),Cp.setScalar(0),$l.fromBufferAttribute(e,t),ql.fromBufferAttribute(e,n),Cp.fromBufferAttribute(e,r),a.setScalar(0),a.addScaledVector($l,o.x),a.addScaledVector(ql,o.y),a.addScaledVector(Cp,o.z),a}static isFrontFacing(e,t,n,r){return vo.subVectors(n,t),La.subVectors(e,t),vo.cross(La).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 vo.subVectors(this.c,this.b),La.subVectors(this.a,this.b),vo.cross(La).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Er.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Er.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,r,o){return Er.getInterpolation(e,this.a,this.b,this.c,t,n,r,o)}containsPoint(e){return Er.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Er.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;Wl.subVectors(r,n),Wi.subVectors(o,n),jo.subVectors(e,n);const u=Wl.dot(jo),d=Wi.dot(jo);if(u<=0&&d<=0)return t.copy(n);kd.subVectors(e,r);const p=Wl.dot(kd),m=Wi.dot(kd);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(Wl,a);Yo.subVectors(e,o);const x=Wl.dot(Yo),v=Wi.dot(Yo);if(v>=0&&x<=v)return t.copy(o);const M=x*d-u*v;if(M<=0&&d>=0&&v<=0)return c=d/(d-v),t.copy(n).addScaledVector(Wi,c);const T=p*v-x*m;if(T<=0&&m-p>=0&&x-v>=0)return bo.subVectors(o,r),c=(m-p)/(m-p+(x-v)),t.copy(r).addScaledVector(bo,c);const S=1/(T+M+y);return a=M*S,c=y*S,t.copy(n).addScaledVector(Wl,a).addScaledVector(Wi,c)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}const Rp={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},Da={h:0,s:0,l:0},Th={h:0,s:0,l:0};function zd(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 At{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=Ei){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,pn.colorSpaceToWorking(this,t),this}setRGB(e,t,n,r=pn.workingColorSpace){return this.r=e,this.g=t,this.b=n,pn.colorSpaceToWorking(this,r),this}setHSL(e,t,n,r=pn.workingColorSpace){if(e=r0(e,1),t=fn(t,0,1),n=fn(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=zd(a,o,e+1/3),this.g=zd(a,o,e),this.b=zd(a,o,e-1/3)}return pn.colorSpaceToWorking(this,r),this}setStyle(e,t=Ei){function n(o){o!==void 0&&parseFloat(o)<1&&console.warn("THREE.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:console.warn("THREE.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);console.warn("THREE.Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=Ei){const n=Rp[e.toLowerCase()];return n!==void 0?this.setHex(n,t):console.warn("THREE.Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=$s(e.r),this.g=$s(e.g),this.b=$s(e.b),this}copyLinearToSRGB(e){return this.r=zl(e.r),this.g=zl(e.g),this.b=zl(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=Ei){return pn.workingToColorSpace(Ci.copy(this),e),Math.round(fn(Ci.r*255,0,255))*65536+Math.round(fn(Ci.g*255,0,255))*256+Math.round(fn(Ci.b*255,0,255))}getHexString(e=Ei){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=pn.workingColorSpace){pn.workingToColorSpace(Ci.copy(this),t);const n=Ci.r,r=Ci.g,o=Ci.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=pn.workingColorSpace){return pn.workingToColorSpace(Ci.copy(this),t),e.r=Ci.r,e.g=Ci.g,e.b=Ci.b,e}getStyle(e=Ei){pn.workingToColorSpace(Ci.copy(this),e);const t=Ci.r,n=Ci.g,r=Ci.b;return e!==Ei?`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(Da),this.setHSL(Da.h+e,Da.s+t,Da.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(Da),e.getHSL(Th);const n=_n(Da.h,Th.h,t),r=_n(Da.s,Th.s,t),o=_n(Da.l,Th.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 Ci=new At;At.NAMES=Rp;let p0=0;class $i extends wa{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:p0++}),this.uuid=kr(),this.name="",this.type="Material",this.blending=qe,this.side=Be,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Kr,this.blendDst=Ss,this.blendEquation=Ot,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new At(0,0,0),this.blendAlpha=0,this.depthFunc=Jr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=bp,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=go,this.stencilZFail=go,this.stencilZPass=go,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){console.warn(`THREE.Material: parameter '${t}' has value of undefined.`);continue}const r=this[t];if(r===void 0){console.warn(`THREE.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!==qe&&(n.blending=this.blending),this.side!==Be&&(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!==Kr&&(n.blendSrc=this.blendSrc),this.blendDst!==Ss&&(n.blendDst=this.blendDst),this.blendEquation!==Ot&&(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!==Jr&&(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!==bp&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==go&&(n.stencilFail=this.stencilFail),this.stencilZFail!==go&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==go&&(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.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.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 js extends $i{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new At(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 Gr,this.combine=Rc,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 Zo=Un();function Un(){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 xi(i){Math.abs(i)>65504&&console.warn("THREE.DataUtils.toHalfFloat(): Value out of range."),i=fn(i,-65504,65504),Zo.floatView[0]=i;const e=Zo.uint32View[0],t=e>>23&511;return Zo.baseTable[t]+((e&8388607)>>Zo.shiftTable[t])}function Vd(i){const e=i>>10;return Zo.uint32View[0]=Zo.mantissaTable[Zo.offsetTable[e]+(i&1023)]+Zo.exponentTable[e],Zo.floatView[0]}class Tg{static toHalfFloat(e){return xi(e)}static fromHalfFloat(e){return Vd(e)}}const Di=new W,So=new Ie;let X1=0;class $n{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:X1++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=kl,this.updateRanges=[],this.gpuType=mi,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++)So.fromBufferAttribute(this,t),So.applyMatrix3(e),this.setXY(t,So.x,So.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Di.fromBufferAttribute(this,t),Di.applyMatrix3(e),this.setXYZ(t,Di.x,Di.y,Di.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Di.fromBufferAttribute(this,t),Di.applyMatrix4(e),this.setXYZ(t,Di.x,Di.y,Di.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Di.fromBufferAttribute(this,t),Di.applyNormalMatrix(e),this.setXYZ(t,Di.x,Di.y,Di.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Di.fromBufferAttribute(this,t),Di.transformDirection(e),this.setXYZ(t,Di.x,Di.y,Di.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=Tr(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Vn(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=Tr(t,this.array)),t}setX(e,t){return this.normalized&&(t=Vn(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=Tr(t,this.array)),t}setY(e,t){return this.normalized&&(t=Vn(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=Tr(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Vn(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=Tr(t,this.array)),t}setW(e,t){return this.normalized&&(t=Vn(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Vn(t,this.array),n=Vn(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=Vn(t,this.array),n=Vn(n,this.array),r=Vn(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=Vn(t,this.array),n=Vn(n,this.array),r=Vn(r,this.array),o=Vn(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!==kl&&(e.usage=this.usage),e}}class Np extends null{constructor(e,t,n){super(new Int8Array(e),t,n)}}class RD extends null{constructor(e,t,n){super(new Uint8Array(e),t,n)}}class Us extends null{constructor(e,t,n){super(new Uint8ClampedArray(e),t,n)}}class wg extends null{constructor(e,t,n){super(new Int16Array(e),t,n)}}class Mg extends $n{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class pr extends null{constructor(e,t,n){super(new Int32Array(e),t,n)}}class m0 extends $n{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class Lb extends $n{constructor(e,t,n){super(new Uint16Array(e),t,n),this.isFloat16BufferAttribute=!0}getX(e){let t=Vd(this.array[e*this.itemSize]);return this.normalized&&(t=Tr(t,this.array)),t}setX(e,t){return this.normalized&&(t=Vn(t,this.array)),this.array[e*this.itemSize]=xi(t),this}getY(e){let t=Vd(this.array[e*this.itemSize+1]);return this.normalized&&(t=Tr(t,this.array)),t}setY(e,t){return this.normalized&&(t=Vn(t,this.array)),this.array[e*this.itemSize+1]=xi(t),this}getZ(e){let t=Vd(this.array[e*this.itemSize+2]);return this.normalized&&(t=Tr(t,this.array)),t}setZ(e,t){return this.normalized&&(t=Vn(t,this.array)),this.array[e*this.itemSize+2]=xi(t),this}getW(e){let t=Vd(this.array[e*this.itemSize+3]);return this.normalized&&(t=Tr(t,this.array)),t}setW(e,t){return this.normalized&&(t=Vn(t,this.array)),this.array[e*this.itemSize+3]=xi(t),this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=Vn(t,this.array),n=Vn(n,this.array)),this.array[e+0]=xi(t),this.array[e+1]=xi(n),this}setXYZ(e,t,n,r){return e*=this.itemSize,this.normalized&&(t=Vn(t,this.array),n=Vn(n,this.array),r=Vn(r,this.array)),this.array[e+0]=xi(t),this.array[e+1]=xi(n),this.array[e+2]=xi(r),this}setXYZW(e,t,n,r,o){return e*=this.itemSize,this.normalized&&(t=Vn(t,this.array),n=Vn(n,this.array),r=Vn(r,this.array),o=Vn(o,this.array)),this.array[e+0]=xi(t),this.array[e+1]=xi(n),this.array[e+2]=xi(r),this.array[e+3]=xi(o),this}}class $t extends $n{constructor(e,t,n){super(new Float32Array(e),t,n)}}let j1=0;const To=new Vt,g0=new Hi,wh=new W,wo=new dr,Wt=new dr,Ys=new W;class gn extends wa{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:j1++}),this.uuid=kr(),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(e){return Array.isArray(e)?this.index=new(_g(e)?m0:Mg)(e,1):this.index=e,this}setIndirect(e){return this.indirect=e,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 Cn().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 To.makeRotationFromQuaternion(e),this.applyMatrix4(To),this}rotateX(e){return To.makeRotationX(e),this.applyMatrix4(To),this}rotateY(e){return To.makeRotationY(e),this.applyMatrix4(To),this}rotateZ(e){return To.makeRotationZ(e),this.applyMatrix4(To),this}translate(e,t,n){return To.makeTranslation(e,t,n),this.applyMatrix4(To),this}scale(e,t,n){return To.makeScale(e,t,n),this.applyMatrix4(To),this}lookAt(e){return g0.lookAt(e),g0.updateMatrix(),this.applyMatrix4(g0.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(wh).negate(),this.translate(wh.x,wh.y,wh.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 $t(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&&console.warn("THREE.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 dr);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new W(-1/0,-1/0,-1/0),new W(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];wo.setFromBufferAttribute(o),this.morphTargetsRelative?(Ys.addVectors(this.boundingBox.min,wo.min),this.boundingBox.expandByPoint(Ys),Ys.addVectors(this.boundingBox.max,wo.max),this.boundingBox.expandByPoint(Ys)):(this.boundingBox.expandByPoint(wo.min),this.boundingBox.expandByPoint(wo.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.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 Ms);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new W,1/0);return}if(e){const n=this.boundingSphere.center;if(wo.setFromBufferAttribute(e),t)for(let o=0,a=t.length;o<a;o++){const c=t[o];Wt.setFromBufferAttribute(c),this.morphTargetsRelative?(Ys.addVectors(wo.min,Wt.min),wo.expandByPoint(Ys),Ys.addVectors(wo.max,Wt.max),wo.expandByPoint(Ys)):(wo.expandByPoint(Wt.min),wo.expandByPoint(Wt.max))}wo.getCenter(n);let r=0;for(let o=0,a=e.count;o<a;o++)Ys.fromBufferAttribute(e,o),r=Math.max(r,n.distanceToSquared(Ys));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++)Ys.fromBufferAttribute(c,d),u&&(wh.fromBufferAttribute(e,d),Ys.add(wh)),r=Math.max(r,n.distanceToSquared(Ys))}this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error('THREE.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){console.error("THREE.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 $n(new Float32Array(4*n.count),4));const a=this.getAttribute("tangent"),c=[],u=[];for(let V=0;V<n.count;V++)c[V]=new W,u[V]=new W;const d=new W,p=new W,m=new W,y=new Ie,x=new Ie,v=new Ie,M=new W,T=new W;function S(V,U,z){d.fromBufferAttribute(n,V),p.fromBufferAttribute(n,U),m.fromBufferAttribute(n,z),y.fromBufferAttribute(o,V),x.fromBufferAttribute(o,U),v.fromBufferAttribute(o,z),p.sub(d),m.sub(d),x.sub(y),v.sub(y);const j=1/(x.x*v.y-v.x*x.y);isFinite(j)&&(M.copy(p).multiplyScalar(v.y).addScaledVector(m,-x.y).multiplyScalar(j),T.copy(m).multiplyScalar(x.x).addScaledVector(p,-v.x).multiplyScalar(j),c[V].add(M),c[U].add(M),c[z].add(M),u[V].add(T),u[U].add(T),u[z].add(T))}let N=this.groups;N.length===0&&(N=[{start:0,count:e.count}]);for(let V=0,U=N.length;V<U;++V){const z=N[V],j=z.start,se=z.count;for(let pe=j,be=j+se;pe<be;pe+=3)S(e.getX(pe+0),e.getX(pe+1),e.getX(pe+2))}const R=new W,P=new W,B=new W,F=new W;function k(V){B.fromBufferAttribute(r,V),F.copy(B);const U=c[V];R.copy(U),R.sub(B.multiplyScalar(B.dot(U))).normalize(),P.crossVectors(F,U);const j=P.dot(u[V])<0?-1:1;a.setXYZW(V,R.x,R.y,R.z,j)}for(let V=0,U=N.length;V<U;++V){const z=N[V],j=z.start,se=z.count;for(let pe=j,be=j+se;pe<be;pe+=3)k(e.getX(pe+0)),k(e.getX(pe+1)),k(e.getX(pe+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 $n(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 W,o=new W,a=new W,c=new W,u=new W,d=new W,p=new W,m=new W;if(e)for(let y=0,x=e.count;y<x;y+=3){const v=e.getX(y+0),M=e.getX(y+1),T=e.getX(y+2);r.fromBufferAttribute(t,v),o.fromBufferAttribute(t,M),a.fromBufferAttribute(t,T),p.subVectors(a,o),m.subVectors(r,o),p.cross(m),c.fromBufferAttribute(n,v),u.fromBufferAttribute(n,M),d.fromBufferAttribute(n,T),c.add(p),u.add(p),d.add(p),n.setXYZ(v,c.x,c.y,c.z),n.setXYZ(M,u.x,u.y,u.z),n.setXYZ(T,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++)Ys.fromBufferAttribute(e,t),Ys.normalize(),e.setXYZ(t,Ys.x,Ys.y,Ys.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 M=0,T=u.length;M<T;M++){c.isInterleavedBufferAttribute?x=u[M]*c.data.stride+c.offset:x=u[M]*p;for(let S=0;S<p;S++)y[v++]=d[x++]}return new $n(y,p,m)}if(this.index===null)return console.warn("THREE.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 Pp=new Vt,Mo=new Hl,mr=new Ms,Mh=new W,fs=new W,Gn=new W,Gd=new W,ul=new W,qc=new W,Ag=new W,Xc=new W;class vi extends Hi{constructor(e=new gn,t=new js){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){qc.set(0,0,0);for(let u=0,d=o.length;u<d;u++){const p=c[u],m=o[u];p!==0&&(ul.fromBufferAttribute(m,e),a?qc.addScaledVector(ul,p):qc.addScaledVector(ul.sub(t),p))}t.add(qc)}return t}raycast(e,t){const n=this.geometry,r=this.material,o=this.matrixWorld;r!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),mr.copy(n.boundingSphere),mr.applyMatrix4(o),Mo.copy(e.ray).recast(e.near),!(mr.containsPoint(Mo.origin)===!1&&(Mo.intersectSphere(mr,Mh)===null||Mo.origin.distanceToSquared(Mh)>hb(e.far-e.near,2)))&&(Pp.copy(o).invert(),Mo.copy(e.ray).applyMatrix4(Pp),!(n.boundingBox!==null&&Mo.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Mo)))}_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,M=y.length;v<M;v++){const T=y[v],S=a[T.materialIndex],N=Math.max(T.start,x.start),R=Math.min(c.count,Math.min(T.start+T.count,x.start+x.count));for(let P=N,B=R;P<B;P+=3){const F=c.getX(P),k=c.getX(P+1),V=c.getX(P+2);r=Ah(this,S,e,n,d,p,m,F,k,V),r&&(r.faceIndex=Math.floor(P/3),r.face.materialIndex=T.materialIndex,t.push(r))}}else{const v=Math.max(0,x.start),M=Math.min(c.count,x.start+x.count);for(let T=v,S=M;T<S;T+=3){const N=c.getX(T),R=c.getX(T+1),P=c.getX(T+2);r=Ah(this,a,e,n,d,p,m,N,R,P),r&&(r.faceIndex=Math.floor(T/3),t.push(r))}}else if(u!==void 0)if(Array.isArray(a))for(let v=0,M=y.length;v<M;v++){const T=y[v],S=a[T.materialIndex],N=Math.max(T.start,x.start),R=Math.min(u.count,Math.min(T.start+T.count,x.start+x.count));for(let P=N,B=R;P<B;P+=3){const F=P,k=P+1,V=P+2;r=Ah(this,S,e,n,d,p,m,F,k,V),r&&(r.faceIndex=Math.floor(P/3),r.face.materialIndex=T.materialIndex,t.push(r))}}else{const v=Math.max(0,x.start),M=Math.min(u.count,x.start+x.count);for(let T=v,S=M;T<S;T+=3){const N=T,R=T+1,P=T+2;r=Ah(this,a,e,n,d,p,m,N,R,P),r&&(r.faceIndex=Math.floor(T/3),t.push(r))}}}}function Ip(i,e,t,n,r,o,a,c){let u;if(e.side===Ee?u=n.intersectTriangle(a,o,r,!0,c):u=n.intersectTriangle(r,o,a,e.side===Be,c),u===null)return null;Xc.copy(c),Xc.applyMatrix4(i.matrixWorld);const d=t.ray.origin.distanceTo(Xc);return d<t.near||d>t.far?null:{distance:d,point:Xc.clone(),object:i}}function Ah(i,e,t,n,r,o,a,c,u,d){i.getVertexPosition(c,fs),i.getVertexPosition(u,Gn),i.getVertexPosition(d,Gd);const p=Ip(i,e,t,n,fs,Gn,Gd,Ag);if(p){const m=new W;Er.getBarycoord(Ag,fs,Gn,Gd,m),r&&(p.uv=Er.getInterpolatedAttribute(r,c,u,d,m,new Ie)),o&&(p.uv1=Er.getInterpolatedAttribute(o,c,u,d,m,new Ie)),a&&(p.normal=Er.getInterpolatedAttribute(a,c,u,d,m,new W),p.normal.dot(n.direction)>0&&p.normal.multiplyScalar(-1));const y={a:c,b:u,c:d,normal:new W,materialIndex:0};Er.getNormal(fs,Gn,Gd,y.normal),p.face=y,p.barycoord=m}return p}class Ko 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 $t(d,3)),this.setAttribute("normal",new $t(p,3)),this.setAttribute("uv",new $t(m,2));function v(M,T,S,N,R,P,B,F,k,V,U){const z=P/k,j=B/V,se=P/2,pe=B/2,be=F/2,Pe=k+1,Ce=V+1;let nt=0,Le=0;const ht=new W;for(let De=0;De<Ce;De++){const Je=De*j-pe;for(let wt=0;wt<Pe;wt++){const Xt=wt*z-se;ht[M]=Xt*N,ht[T]=Je*R,ht[S]=be,d.push(ht.x,ht.y,ht.z),ht[M]=0,ht[T]=0,ht[S]=F>0?1:-1,p.push(ht.x,ht.y,ht.z),m.push(wt/k),m.push(1-De/V),nt+=1}}for(let De=0;De<V;De++)for(let Je=0;Je<k;Je++){const wt=y+Je+Pe*De,Xt=y+Je+Pe*(De+1),Ln=y+(Je+1)+Pe*(De+1),Ke=y+(Je+1)+Pe*De;u.push(wt,Xt,Ke),u.push(Xt,Ln,Ke),Le+=6}c.addGroup(x,Le,U),x+=Le,y+=nt}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Ko(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}function jc(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?(console.warn("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 Zs(i){const e={};for(let t=0;t<i.length;t++){const n=jc(i[t]);for(const r in n)e[r]=n[r]}return e}function Xl(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function y0(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:pn.workingColorSpace}const Hd={clone:jc,merge:Zs};var Lp=`void main() {
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
}`,Dp=`void main() {
|
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
}`;class Jo extends $i{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Lp,this.fragmentShader=Dp,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=jc(e.uniforms),this.uniformsGroups=Xl(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}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 Fp extends Hi{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Vt,this.projectionMatrix=new Vt,this.projectionMatrixInverse=new Vt,this.coordinateSystem=ki,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 Yc=new W,Db=new Ie,_0=new Ie;class ps extends Fp{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=gh*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Ma*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return gh*2*Math.atan(Math.tan(Ma*.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){Yc.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Yc.x,Yc.y).multiplyScalar(-e/Yc.z),Yc.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Yc.x,Yc.y).multiplyScalar(-e/Yc.z)}getViewSize(e,t){return this.getViewBounds(e,Db,_0),t.subVectors(_0,Db)}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(Ma*.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 Zc=-90,Eh=1;class hl extends Hi{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const r=new ps(Zc,Eh,e,t);r.layers=this.layers,this.add(r);const o=new ps(Zc,Eh,e,t);o.layers=this.layers,this.add(o);const a=new ps(Zc,Eh,e,t);a.layers=this.layers,this.add(a);const c=new ps(Zc,Eh,e,t);c.layers=this.layers,this.add(c);const u=new ps(Zc,Eh,e,t);u.layers=this.layers,this.add(u);const d=new ps(Zc,Eh,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===ki)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===Sr)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 M=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=M,e.setRenderTarget(n,5,r),e.render(t,p),e.setRenderTarget(m,y,x),e.xr.enabled=v,n.texture.needsPMREMUpdate=!0}}class jl extends ds{constructor(e=[],t=Br,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 Eg extends Aa{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 jl(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 Ko(5,5,5),o=new Jo({name:"CubemapFromEquirect",uniforms:jc(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Ee,blending:Ae});o.uniforms.tEquirect.value=t;const a=new vi(r,o),c=t.minFilter;return t.minFilter===Ds&&(t.minFilter=Yn),new hl(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 nr extends Hi{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Ch={type:"move"};class dl{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new nr,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 nr,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new W,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new W),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new nr,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new W,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new W),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 M of e.hand.values()){const T=t.getJointPose(M,n),S=this._getHandJoint(d,M);T!==null&&(S.matrix.fromArray(T.transform.matrix),S.matrix.decompose(S.position,S.rotation,S.scale),S.matrixWorldNeedsUpdate=!0,S.jointRadius=T.radius),S.visible=T!==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(Ch)))}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 nr;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}class Cg{constructor(e,t=25e-5){this.isFogExp2=!0,this.name="",this.color=new At(e),this.density=t}clone(){return new Cg(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Wd{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new At(e),this.near=t,this.far=n}clone(){return new Wd(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Bp extends Hi{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 Gr,this.environmentIntensity=1,this.environmentRotation=new Gr,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 fl{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=kl,this.updateRanges=[],this.version=0,this.uuid=kr()}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=kr()),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=kr()),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 Cr=new W;class Rh{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++)Cr.fromBufferAttribute(this,t),Cr.applyMatrix4(e),this.setXYZ(t,Cr.x,Cr.y,Cr.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Cr.fromBufferAttribute(this,t),Cr.applyNormalMatrix(e),this.setXYZ(t,Cr.x,Cr.y,Cr.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Cr.fromBufferAttribute(this,t),Cr.transformDirection(e),this.setXYZ(t,Cr.x,Cr.y,Cr.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=Tr(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=Vn(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=Vn(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=Vn(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=Vn(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=Vn(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=Tr(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=Tr(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=Tr(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=Tr(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=Vn(t,this.array),n=Vn(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=Vn(t,this.array),n=Vn(n,this.array),r=Vn(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=Vn(t,this.array),n=Vn(n,this.array),r=Vn(r,this.array),o=Vn(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){console.log("THREE.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 $n(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 Rh(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){console.log("THREE.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 $d extends $i{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new At(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 Yl;const qd=new W,Kc=new W,As=new W,Qo=new Ie,Jc=new Ie,Qc=new Vt,Zl=new W,Fa=new W,pl=new W,eu=new Ie,tu=new Ie,Rg=new Ie;class Op extends null{constructor(e=new $d){if(super(),this.isSprite=!0,this.type="Sprite",Yl===void 0){Yl=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 fl(t,5);Yl.setIndex([0,1,2,0,2,3]),Yl.setAttribute("position",new Rh(n,3,0,!1)),Yl.setAttribute("uv",new Rh(n,2,3,!1))}this.geometry=Yl,this.material=e,this.center=new Ie(.5,.5),this.count=1}raycast(e,t){e.camera===null&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Kc.setFromMatrixScale(this.matrixWorld),Qc.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),As.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Kc.multiplyScalar(-As.z);const n=this.material.rotation;let r,o;n!==0&&(o=Math.cos(n),r=Math.sin(n));const a=this.center;Kl(Zl.set(-.5,-.5,0),As,a,Kc,r,o),Kl(Fa.set(.5,-.5,0),As,a,Kc,r,o),Kl(pl.set(.5,.5,0),As,a,Kc,r,o),eu.set(0,0),tu.set(1,0),Rg.set(1,1);let c=e.ray.intersectTriangle(Zl,Fa,pl,!1,qd);if(c===null&&(Kl(Fa.set(-.5,.5,0),As,a,Kc,r,o),tu.set(0,1),c=e.ray.intersectTriangle(Zl,pl,Fa,!1,qd),c===null))return;const u=e.ray.origin.distanceTo(qd);u<e.near||u>e.far||t.push({distance:u,point:qd.clone(),uv:Er.getInterpolation(qd,Zl,Fa,pl,eu,tu,Rg,new Ie),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 Kl(i,e,t,n,r,o){Qo.subVectors(i,t).addScalar(.5).multiply(n),r!==void 0?(Jc.x=o*Qo.x-r*Qo.y,Jc.y=r*Qo.x+o*Qo.y):Jc.copy(Qo),i.copy(e),i.x+=Jc.x,i.y+=Jc.y,i.applyMatrix4(Qc)}const nu=new W,Ng=new W;class Pg 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){nu.setFromMatrixPosition(this.matrixWorld);const r=e.ray.origin.distanceTo(nu);this.getObjectForDistance(r).raycast(e,t)}}update(e){const t=this.levels;if(t.length>1){nu.setFromMatrixPosition(e.matrixWorld),Ng.setFromMatrixPosition(this.matrixWorld);const n=nu.distanceTo(Ng)/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 Ig=new W,Lg=new an,Xd=new an,Up=new W,Dg=new Vt,kp=new W,zp=new Ms,Fg=new Vt,Vp=new Hl;class Fb extends null{constructor(e,t){super(e,t),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=lg,this.bindMatrix=new Vt,this.bindMatrixInverse=new Vt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const e=this.geometry;this.boundingBox===null&&(this.boundingBox=new dr),this.boundingBox.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,kp),this.boundingBox.expandByPoint(kp)}computeBoundingSphere(){const e=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Ms),this.boundingSphere.makeEmpty();const t=e.getAttribute("position");for(let n=0;n<t.count;n++)this.getVertexPosition(n,kp),this.boundingSphere.expandByPoint(kp)}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(),zp.copy(this.boundingSphere),zp.applyMatrix4(r),e.ray.intersectsSphere(zp)!==!1&&(Fg.copy(r).invert(),Vp.copy(e.ray).applyMatrix4(Fg),!(this.boundingBox!==null&&Vp.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(e,t,Vp)))}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 an,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===lg?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===vb?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(e,t){const n=this.skeleton,r=this.geometry;Lg.fromBufferAttribute(r.attributes.skinIndex,e),Xd.fromBufferAttribute(r.attributes.skinWeight,e),Ig.copy(t).applyMatrix4(this.bindMatrix),t.set(0,0,0);for(let o=0;o<4;o++){const a=Xd.getComponent(o);if(a!==0){const c=Lg.getComponent(o);Dg.multiplyMatrices(n.bones[c].matrixWorld,n.boneInverses[c]),t.addScaledVector(Up.copy(Ig).applyMatrix4(Dg),a)}}return t.applyMatrix4(this.bindMatrixInverse)}}class Bg extends null{constructor(){super(),this.isBone=!0,this.type="Bone"}}class oo extends ds{constructor(e=null,t=1,n=1,r,o,a,c,u,d=Jn,p=Jn,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 Gp=new Vt,x0=new Vt;class jd{constructor(e=[],t=[]){this.uuid=kr(),this.bones=e.slice(0),this.boneInverses=t,this.boneMatrices=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){console.warn("THREE.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 Vt)}}calculateInverses(){this.boneInverses.length=0;for(let e=0,t=this.bones.length;e<t;e++){const n=new Vt;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:x0;Gp.multiplyMatrices(c,t[o]),Gp.toArray(n,o*16)}r!==null&&(r.needsUpdate=!0)}clone(){return new jd(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 oo(t,e,e,_i,mi);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&&(console.warn("THREE.Skeleton: No bone found with UUID:",o),a=new Bg),this.bones.push(a),this.boneInverses.push(new Vt().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 ea extends $n{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 iu=new Vt,Ba=new Vt,Yd=null,v0=new dr,Og=new Vt,ml=new vi,Oa=new Ms;class b0 extends null{constructor(e,t,n){super(e,t),this.isInstancedMesh=!0,this.instanceMatrix=new ea(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,Og)}computeBoundingBox(){const e=this.geometry,t=this.count;this.boundingBox===null&&(this.boundingBox=new dr),e.boundingBox===null&&e.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,iu),v0.copy(e.boundingBox).applyMatrix4(iu),this.boundingBox.union(v0)}computeBoundingSphere(){const e=this.geometry,t=this.count;this.boundingSphere===null&&(this.boundingSphere=new Ms),e.boundingSphere===null&&e.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<t;n++)this.getMatrixAt(n,iu),Oa.copy(e.boundingSphere).applyMatrix4(iu),this.boundingSphere.union(Oa)}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(ml.geometry=this.geometry,ml.material=this.material,ml.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Oa.copy(this.boundingSphere),Oa.applyMatrix4(n),e.ray.intersectsSphere(Oa)!==!1))for(let o=0;o<r;o++){this.getMatrixAt(o,iu),Ba.multiplyMatrices(n,iu),ml.matrixWorld=Ba,ml.raycast(e,Yd);for(let a=0,c=Yd.length;a<c;a++){const u=Yd[a];u.instanceId=o,u.object=this,t.push(u)}Yd.length=0}}setColorAt(e,t){this.instanceColor===null&&(this.instanceColor=new ea(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 oo(new Float32Array(r*this.count),r,this.count,Fc,mi));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 Nh=new W,S0=new W,Bb=new Cn;class Rr{constructor(e=new W(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=Nh.subVectors(n,t).cross(S0.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(Nh),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||Bb.getNormalMatrix(e),r=this.coplanarPoint(Nh).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 ta=new Ms,Ob=new Ie(.5,.5),Ph=new W;class Ih{constructor(e=new Rr,t=new Rr,n=new Rr,r=new Rr,o=new Rr,a=new Rr){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=ki,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],M=o[9],T=o[10],S=o[11],N=o[12],R=o[13],P=o[14],B=o[15];if(r[0].setComponents(d-a,x-p,S-v,B-N).normalize(),r[1].setComponents(d+a,x+p,S+v,B+N).normalize(),r[2].setComponents(d+c,x+m,S+M,B+R).normalize(),r[3].setComponents(d-c,x-m,S-M,B-R).normalize(),n)r[4].setComponents(u,y,T,P).normalize(),r[5].setComponents(d-u,x-y,S-T,B-P).normalize();else if(r[4].setComponents(d-u,x-y,S-T,B-P).normalize(),t===ki)r[5].setComponents(d+u,x+y,S+T,B+P).normalize();else if(t===Sr)r[5].setComponents(u,y,T,P).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(),ta.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),ta.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(ta)}intersectsSprite(e){ta.center.set(0,0,0);const t=Ob.distanceTo(e.center);return ta.radius=.7071067811865476+t,ta.applyMatrix4(e.matrixWorld),this.intersectsSphere(ta)}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(Ph.x=r.normal.x>0?e.max.x:e.min.x,Ph.y=r.normal.y>0?e.max.y:e.min.y,Ph.z=r.normal.z>0?e.max.z:e.min.z,r.distanceToPoint(Ph)<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 Ua=new Vt,Nr=new Ih;class ka{constructor(){this.coordinateSystem=ki}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(Ua.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Nr.setFromProjectionMatrix(Ua,r.coordinateSystem,r.reversedDepth),Nr.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(Ua.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Nr.setFromProjectionMatrix(Ua,r.coordinateSystem,r.reversedDepth),Nr.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(Ua.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Nr.setFromProjectionMatrix(Ua,r.coordinateSystem,r.reversedDepth),Nr.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(Ua.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Nr.setFromProjectionMatrix(Ua,r.coordinateSystem,r.reversedDepth),Nr.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(Ua.multiplyMatrices(r.projectionMatrix,r.matrixWorldInverse),Nr.setFromProjectionMatrix(Ua,r.coordinateSystem,r.reversedDepth),Nr.containsPoint(e))return!0}return!1}clone(){return new ka}}function Ug(i,e){return i-e}function Hp(i,e){return i.z-e.z}function kg(i,e){return e.z-i.z}class za{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 Ji=new Vt,zg=new At(1,1,1),Wp=new Ih,Ub=new ka,$p=new dr,su=new Ms,Ks=new W,T0=new W,w0=new W,Vg=new za,ks=new vi,Va=null;function Zd(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 Jl(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 kb 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 oo(t,e,e,_i,mi);this._matricesTexture=n}_initIndirectTexture(){let e=Math.sqrt(this._maxInstanceCount);e=Math.ceil(e);const t=new Uint32Array(e*e),n=new oo(t,e,e,Dl,pi);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 oo(t,e,e,_i,mi);n.colorSpace=pn.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 $n(p,u,d);t.setAttribute(o,m)}if(e.getIndex()!==null){const o=n>65535?new Uint32Array(r):new Uint16Array(r);t.setIndex(new $n(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 dr);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,Ji),this.getBoundingBoxAt(o,$p).applyMatrix4(Ji),e.union($p)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Ms);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,Ji),this.getBoundingSphereAt(o,su).applyMatrix4(Ji),e.union(su)}}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(Ug),r=this._availableInstanceIds.shift(),this._instanceInfo[r]=n):(r=this._instanceInfo.length,this._instanceInfo.push(n));const o=this._matricesTexture;Ji.identity().toArray(o.image.data,r*16),o.needsUpdate=!0;const a=this._colorsTexture;return a&&(zg.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(Ug),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);Zd(m,y,u);const x=m.itemSize;for(let v=m.count,M=d;v<M;v++){const T=u+v;for(let S=0;S<x;S++)y.setComponent(T,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,M=e-m;for(let T=p;T<p+y;T++)v[T]=v[T]+M;x.array.copyWithin(t,p,p+y),x.addUpdateRange(t,y),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:M,itemSize:T}=v;M.copyWithin(e*T,p*T,(p+m)*T),v.addUpdateRange(e*T,m*T)}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}getBoundingBoxAt(e,t){if(e>=this._geometryCount)return null;const n=this.geometry,r=this._geometryInfo[e];if(r.boundingBox===null){const o=new dr,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(Ks.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 Ms;this.getBoundingBoxAt(e,$p),$p.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)),Ks.fromBufferAttribute(c,m),u=Math.max(u,o.center.distanceToSquared(Ks))}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(Ug);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);Jl(this._multiDrawCounts,r),Jl(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(),Jl(a.image.data,this._indirectTexture.image.data),c.dispose(),this._initMatricesTexture(),Jl(c.image.data,this._matricesTexture.image.data),u&&(u.dispose(),this._initColorsTexture(),Jl(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&&Jl(o.index.array,a.index.array);for(const c in o.attributes)Jl(o.attributes[c].array,a.attributes[c].array)}raycast(e,t){const n=this._instanceInfo,r=this._geometryInfo,o=this.matrixWorld,a=this.geometry;ks.material=this.material,ks.geometry.index=a.index,ks.geometry.attributes=a.attributes,ks.geometry.boundingBox===null&&(ks.geometry.boundingBox=new dr),ks.geometry.boundingSphere===null&&(ks.geometry.boundingSphere=new Ms);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];ks.geometry.setDrawRange(p.start,p.count),this.getMatrixAt(c,ks.matrixWorld).premultiply(o),this.getBoundingBoxAt(d,ks.geometry.boundingBox),this.getBoundingSphereAt(d,ks.geometry.boundingSphere),ks.raycast(e,Va);for(let m=0,y=Va.length;m<y;m++){const x=Va[m];x.object=this,x.batchId=c,t.push(x)}Va.length=0}ks.material=null,ks.geometry.index=null,ks.geometry.attributes={},ks.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=>_a(Ii({},t),{boundingBox:t.boundingBox!==null?t.boundingBox.clone():null,boundingSphere:t.boundingSphere!==null?t.boundingSphere.clone():null})),this._instanceInfo=e._instanceInfo.map(t=>Ii({},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,M=n.isArrayCamera?Ub:Wp;y&&!n.isArrayCamera&&(Ji.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse).multiply(this.matrixWorld),Wp.setFromProjectionMatrix(Ji,n.coordinateSystem,n.reversedDepth));let T=0;if(this.sortObjects){Ji.copy(this.matrixWorld).invert(),Ks.setFromMatrixPosition(n.matrixWorld).applyMatrix4(Ji),T0.set(0,0,-1).transformDirection(n.matrixWorld).transformDirection(Ji);for(let R=0,P=u.length;R<P;R++)if(u[R].visible&&u[R].active){const B=u[R].geometryIndex;this.getMatrixAt(R,Ji),this.getBoundingSphereAt(B,su).applyMatrix4(Ji);let F=!1;if(y&&(F=!M.intersectsSphere(su,n)),!F){const k=m[B],V=w0.subVectors(su.center,Ks).dot(T0);Vg.push(k.start,k.count,V,R)}}const S=Vg.list,N=this.customSort;N===null?S.sort(o.transparent?kg:Hp):N.call(this,S,n);for(let R=0,P=S.length;R<P;R++){const B=S[R];d[T]=B.start*c,p[T]=B.count,v[T]=B.index,T++}Vg.reset()}else for(let S=0,N=u.length;S<N;S++)if(u[S].visible&&u[S].active){const R=u[S].geometryIndex;let P=!1;if(y&&(this.getMatrixAt(S,Ji),this.getBoundingSphereAt(R,su).applyMatrix4(Ji),P=!M.intersectsSphere(su,n)),!P){const B=m[R];d[T]=B.start*c,p[T]=B.count,v[T]=S,T++}}x.needsUpdate=!0,this._multiDrawCount=T,this._visibilityChanged=!1}onBeforeShadow(e,t,n,r,o,a){this.onBeforeRender(e,null,r,o,a)}}class Js extends $i{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new At(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 zs=new W,ru=new W,M0=new Vt,na=new Hl,qp=new Ms,Pr=new W,Kd=new W;class Ql extends Hi{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++)zs.fromBufferAttribute(t,r-1),ru.fromBufferAttribute(t,r),n[r]=n[r-1],n[r]+=zs.distanceTo(ru);e.setAttribute("lineDistance",new $t(n,1))}else console.warn("THREE.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(),qp.copy(n.boundingSphere),qp.applyMatrix4(r),qp.radius+=o,e.ray.intersectsSphere(qp)===!1)return;M0.copy(r).invert(),na.copy(e.ray).applyMatrix4(M0);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 M=x,T=v-1;M<T;M+=d){const S=p.getX(M),N=p.getX(M+1),R=Jd(this,e,na,u,S,N,M);R&&t.push(R)}if(this.isLineLoop){const M=p.getX(v-1),T=p.getX(x),S=Jd(this,e,na,u,M,T,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 M=x,T=v-1;M<T;M+=d){const S=Jd(this,e,na,u,M,M+1,M);S&&t.push(S)}if(this.isLineLoop){const M=Jd(this,e,na,u,v-1,x,v-1);M&&t.push(M)}}}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 Jd(i,e,t,n,r,o,a){const c=i.geometry.attributes.position;if(zs.fromBufferAttribute(c,r),ru.fromBufferAttribute(c,o),t.distanceSqToSegment(zs,ru,Pr,Kd)>n)return;Pr.applyMatrix4(i.matrixWorld);const d=e.ray.origin.distanceTo(Pr);if(!(d<e.near||d>e.far))return{distance:d,point:Kd.clone().applyMatrix4(i.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:i}}const Lh=new W,Qd=new W;class Xp 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)Lh.fromBufferAttribute(t,r),Qd.fromBufferAttribute(t,r+1),n[r]=r===0?0:n[r-1],n[r+1]=n[r]+Lh.distanceTo(Qd);e.setAttribute("lineDistance",new $t(n,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class A0 extends null{constructor(e,t){super(e,t),this.isLineLoop=!0,this.type="LineLoop"}}class Dh extends $i{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new At(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 ef=new Vt,jp=new Hl,tf=new Ms,nf=new W;class zb extends null{constructor(e=new gn,t=new Dh){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(),tf.copy(n.boundingSphere),tf.applyMatrix4(r),tf.radius+=o,e.ray.intersectsSphere(tf)===!1)return;ef.copy(r).invert(),jp.copy(e.ray).applyMatrix4(ef);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,M=x;v<M;v++){const T=d.getX(v);nf.fromBufferAttribute(m,T),Gg(nf,T,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,M=x;v<M;v++)nf.fromBufferAttribute(m,v),Gg(nf,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 Gg(i,e,t,n,r,o,a){const c=jp.distanceSqToPoint(i);if(c<t){const u=new W;jp.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 Vb 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),super.dispose()}}class E0 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 sf extends ds{constructor(e,t){super({width:e,height:t}),this.isFramebufferTexture=!0,this.magFilter=Jn,this.minFilter=Jn,this.generateMipmaps=!1,this.needsUpdate=!0}}class Yp 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 Y1 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 Gb extends null{constructor(e,t,n){super(void 0,e[0].width,e[0].height,t,n,Br),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=e}}class ND 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 Ao extends ds{constructor(e,t,n=pi,r,o,a,c=Jn,u=Jn,d,p=Or,m=1){if(p!==Or&&p!==eo)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 Bs(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 Hb extends ds{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class Hg 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,M=r+1,T=new W,S=new W;for(let N=0;N<=v;N++){let R=0,P=0,B=0,F=0;if(N<=n){const U=N/n,z=U*Math.PI/2;P=-p-e*Math.cos(z),B=e*Math.sin(z),F=-e*Math.cos(z),R=U*m}else if(N<=n+o){const U=(N-n)/o;P=-p+U*t,B=e,F=0,R=m+U*y}else{const U=(N-n-o)/n,z=U*Math.PI/2;P=p+e*Math.sin(z),B=e*Math.cos(z),F=e*Math.sin(z),R=m+y+U*m}const k=Math.max(0,Math.min(1,R/x));let V=0;N===0?V=.5/r:N===v&&(V=-.5/r);for(let U=0;U<=r;U++){const z=U/r,j=z*Math.PI*2,se=Math.sin(j),pe=Math.cos(j);S.x=-B*pe,S.y=P,S.z=B*se,c.push(S.x,S.y,S.z),T.set(-B*pe,F,B*se),T.normalize(),u.push(T.x,T.y,T.z),d.push(z+V,k)}if(N>0){const U=(N-1)*M;for(let z=0;z<r;z++){const j=U+z,se=U+z+1,pe=N*M+z,be=N*M+z+1;a.push(j,se,pe),a.push(se,be,pe)}}}this.setIndex(a),this.setAttribute("position",new $t(c,3)),this.setAttribute("normal",new $t(u,3)),this.setAttribute("uv",new $t(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Hg(e.radius,e.height,e.capSegments,e.radialSegments,e.heightSegments)}}class C0 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 W,p=new Ie;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 $t(a,3)),this.setAttribute("normal",new $t(c,3)),this.setAttribute("uv",new $t(u,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new C0(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class rf 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 M=[],T=n/2;let S=0;N(),a===!1&&(e>0&&R(!0),t>0&&R(!1)),this.setIndex(p),this.setAttribute("position",new $t(m,3)),this.setAttribute("normal",new $t(y,3)),this.setAttribute("uv",new $t(x,2));function N(){const P=new W,B=new W;let F=0;const k=(t-e)/n;for(let V=0;V<=o;V++){const U=[],z=V/o,j=z*(t-e)+e;for(let se=0;se<=r;se++){const pe=se/r,be=pe*u+c,Pe=Math.sin(be),Ce=Math.cos(be);B.x=j*Pe,B.y=-z*n+T,B.z=j*Ce,m.push(B.x,B.y,B.z),P.set(Pe,k,Ce).normalize(),y.push(P.x,P.y,P.z),x.push(pe,1-z),U.push(v++)}M.push(U)}for(let V=0;V<r;V++)for(let U=0;U<o;U++){const z=M[U][V],j=M[U+1][V],se=M[U+1][V+1],pe=M[U][V+1];(e>0||U!==0)&&(p.push(z,j,pe),F+=3),(t>0||U!==o-1)&&(p.push(j,se,pe),F+=3)}d.addGroup(S,F,0),S+=F}function R(P){const B=v,F=new Ie,k=new W;let V=0;const U=P===!0?e:t,z=P===!0?1:-1;for(let se=1;se<=r;se++)m.push(0,T*z,0),y.push(0,z,0),x.push(.5,.5),v++;const j=v;for(let se=0;se<=r;se++){const be=se/r*u+c,Pe=Math.cos(be),Ce=Math.sin(be);k.x=U*Ce,k.y=T*z,k.z=U*Pe,m.push(k.x,k.y,k.z),y.push(0,z,0),F.x=Pe*.5+.5,F.y=Ce*.5*z+.5,x.push(F.x,F.y),v++}for(let se=0;se<r;se++){const pe=B+se,be=j+se;P===!0?p.push(be,be+1,pe):p.push(be+1,be,pe),V+=3}d.addGroup(S,V,P===!0?1:2),S+=V}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new rf(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class of extends rf{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 of(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Fh 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 $t(o,3)),this.setAttribute("normal",new $t(o.slice(),3)),this.setAttribute("uv",new $t(a,2)),r===0?this.computeVertexNormals():this.normalizeNormals();function c(N){const R=new W,P=new W,B=new W;for(let F=0;F<t.length;F+=3)x(t[F+0],R),x(t[F+1],P),x(t[F+2],B),u(R,P,B,N)}function u(N,R,P,B){const F=B+1,k=[];for(let V=0;V<=F;V++){k[V]=[];const U=N.clone().lerp(P,V/F),z=R.clone().lerp(P,V/F),j=F-V;for(let se=0;se<=j;se++)se===0&&V===F?k[V][se]=U:k[V][se]=U.clone().lerp(z,se/j)}for(let V=0;V<F;V++)for(let U=0;U<2*(F-V)-1;U++){const z=Math.floor(U/2);U%2===0?(y(k[V][z+1]),y(k[V+1][z]),y(k[V][z])):(y(k[V][z+1]),y(k[V+1][z+1]),y(k[V+1][z]))}}function d(N){const R=new W;for(let P=0;P<o.length;P+=3)R.x=o[P+0],R.y=o[P+1],R.z=o[P+2],R.normalize().multiplyScalar(N),o[P+0]=R.x,o[P+1]=R.y,o[P+2]=R.z}function p(){const N=new W;for(let R=0;R<o.length;R+=3){N.x=o[R+0],N.y=o[R+1],N.z=o[R+2];const P=T(N)/2/Math.PI+.5,B=S(N)/Math.PI+.5;a.push(P,1-B)}v(),m()}function m(){for(let N=0;N<a.length;N+=6){const R=a[N+0],P=a[N+2],B=a[N+4],F=Math.max(R,P,B),k=Math.min(R,P,B);F>.9&&k<.1&&(R<.2&&(a[N+0]+=1),P<.2&&(a[N+2]+=1),B<.2&&(a[N+4]+=1))}}function y(N){o.push(N.x,N.y,N.z)}function x(N,R){const P=N*3;R.x=e[P+0],R.y=e[P+1],R.z=e[P+2]}function v(){const N=new W,R=new W,P=new W,B=new W,F=new Ie,k=new Ie,V=new Ie;for(let U=0,z=0;U<o.length;U+=9,z+=6){N.set(o[U+0],o[U+1],o[U+2]),R.set(o[U+3],o[U+4],o[U+5]),P.set(o[U+6],o[U+7],o[U+8]),F.set(a[z+0],a[z+1]),k.set(a[z+2],a[z+3]),V.set(a[z+4],a[z+5]),B.copy(N).add(R).add(P).divideScalar(3);const j=T(B);M(F,z+0,N,j),M(k,z+2,R,j),M(V,z+4,P,j)}}function M(N,R,P,B){B<0&&N.x===1&&(a[R]=N.x-1),P.x===0&&P.z===0&&(a[R]=B/2/Math.PI+.5)}function T(N){return Math.atan2(N.z,-N.x)}function S(N){return Math.atan2(-N.y,Math.sqrt(N.x*N.x+N.z*N.z))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Fh(e.vertices,e.indices,e.radius,e.details)}}class R0 extends Fh{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 R0(e.radius,e.detail)}}const Bh=new W,Oh=new W,Uh=new W,ou=new Er;class au 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(Ma*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:M,b:T,c:S}=ou;if(M.fromBufferAttribute(c,d[0]),T.fromBufferAttribute(c,d[1]),S.fromBufferAttribute(c,d[2]),ou.getNormal(Uh),m[0]=`${Math.round(M.x*r)},${Math.round(M.y*r)},${Math.round(M.z*r)}`,m[1]=`${Math.round(T.x*r)},${Math.round(T.y*r)},${Math.round(T.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 N=0;N<3;N++){const R=(N+1)%3,P=m[N],B=m[R],F=ou[p[N]],k=ou[p[R]],V=`${P}_${B}`,U=`${B}_${P}`;U in y&&y[U]?(Uh.dot(y[U].normal)<=o&&(x.push(F.x,F.y,F.z),x.push(k.x,k.y,k.z)),y[U]=null):V in y||(y[V]={index0:d[N],index1:d[R],normal:Uh.clone()})}}for(const v in y)if(y[v]){const{index0:M,index1:T}=y[v];Bh.fromBufferAttribute(c,M),Oh.fromBufferAttribute(c,T),x.push(Bh.x,Bh.y,Bh.z),x.push(Oh.x,Oh.y,Oh.z)}this.setAttribute("position",new $t(x,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}class Eo{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){console.warn("THREE.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 Ie:new W);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 W,r=[],o=[],a=[],c=new W,u=new Vt;for(let x=0;x<=e;x++){const v=x/e;r[x]=this.getTangentAt(v,new W)}o[0]=new W,a[0]=new W;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(fn(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(fn(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 kh extends Eo{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 Ie){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 Zp extends kh{constructor(e,t,n,r,o,a){super(e,t,n,n,r,o,a),this.isArcCurve=!0,this.type="ArcCurve"}}function af(){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 lu=new W,Wg=new af,Co=new af,lf=new af;class Wb extends Eo{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 W){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]:(lu.subVectors(r[0],r[1]).add(r[0]),d=lu);const m=r[c%o],y=r[(c+1)%o];if(this.closed||c+2<o?p=r[(c+2)%o]:(lu.subVectors(r[o-1],r[o-2]).add(r[o-1]),p=lu),this.curveType==="centripetal"||this.curveType==="chordal"){const x=this.curveType==="chordal"?.5:.25;let v=Math.pow(d.distanceToSquared(m),x),M=Math.pow(m.distanceToSquared(y),x),T=Math.pow(y.distanceToSquared(p),x);M<1e-4&&(M=1),v<1e-4&&(v=M),T<1e-4&&(T=M),Wg.initNonuniformCatmullRom(d.x,m.x,y.x,p.x,v,M,T),Co.initNonuniformCatmullRom(d.y,m.y,y.y,p.y,v,M,T),lf.initNonuniformCatmullRom(d.z,m.z,y.z,p.z,v,M,T)}else this.curveType==="catmullrom"&&(Wg.initCatmullRom(d.x,m.x,y.x,p.x,this.tension),Co.initCatmullRom(d.y,m.y,y.y,p.y,this.tension),lf.initCatmullRom(d.z,m.z,y.z,p.z,this.tension));return n.set(Wg.calc(u),Co.calc(u),lf.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 W().fromArray(r))}return this.closed=e.closed,this.curveType=e.curveType,this.tension=e.tension,this}}function Kp(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 Jp(i,e){const t=1-i;return t*t*e}function $g(i,e){return 2*(1-i)*i*e}function qg(i,e){return i*i*e}function cu(i,e,t,n){return Jp(i,e)+$g(i,t)+qg(i,n)}function $b(i,e){const t=1-i;return t*t*t*e}function N0(i,e){const t=1-i;return 3*t*t*i*e}function qb(i,e){return 3*(1-i)*i*i*e}function Xb(i,e){return i*i*i*e}function cf(i,e,t,n,r){return $b(i,e)+N0(i,t)+qb(i,n)+Xb(i,r)}class zh extends Eo{constructor(e=new Ie,t=new Ie,n=new Ie,r=new Ie){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new Ie){const n=t,r=this.v0,o=this.v1,a=this.v2,c=this.v3;return n.set(cf(e,r.x,o.x,a.x,c.x),cf(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 P0 extends Eo{constructor(e=new W,t=new W,n=new W,r=new W){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=e,this.v1=t,this.v2=n,this.v3=r}getPoint(e,t=new W){const n=t,r=this.v0,o=this.v1,a=this.v2,c=this.v3;return n.set(cf(e,r.x,o.x,a.x,c.x),cf(e,r.y,o.y,a.y,c.y),cf(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 I0 extends Eo{constructor(e=new Ie,t=new Ie){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=e,this.v2=t}getPoint(e,t=new Ie){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 Ie){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 jb extends Eo{constructor(e=new W,t=new W){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=e,this.v2=t}getPoint(e,t=new W){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 W){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 L0 extends Eo{constructor(e=new Ie,t=new Ie,n=new Ie){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new Ie){const n=t,r=this.v0,o=this.v1,a=this.v2;return n.set(cu(e,r.x,o.x,a.x),cu(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 uu extends Eo{constructor(e=new W,t=new W,n=new W){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=e,this.v1=t,this.v2=n}getPoint(e,t=new W){const n=t,r=this.v0,o=this.v1,a=this.v2;return n.set(cu(e,r.x,o.x,a.x),cu(e,r.y,o.y,a.y),cu(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 Xg extends Eo{constructor(e=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=e}getPoint(e,t=new Ie){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(Kp(c,u.x,d.x,p.x,m.x),Kp(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 Ie().fromArray(r))}return this}}var Qp=Object.freeze({__proto__:null,ArcCurve:Zp,CatmullRomCurve3:Wb,CubicBezierCurve:zh,CubicBezierCurve3:P0,EllipseCurve:kh,LineCurve:I0,LineCurve3:jb,QuadraticBezierCurve:L0,QuadraticBezierCurve3:uu,SplineCurve:Xg});class D0 extends Eo{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 Qp[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 Qp[r.type]().fromJSON(r))}return this}}class jg extends D0{constructor(e){super(),this.type="Path",this.currentPoint=new Ie,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 I0(this.currentPoint.clone(),new Ie(e,t));return this.curves.push(n),this.currentPoint.set(e,t),this}quadraticCurveTo(e,t,n,r){const o=new L0(this.currentPoint.clone(),new Ie(e,t),new Ie(n,r));return this.curves.push(o),this.currentPoint.set(n,r),this}bezierCurveTo(e,t,n,r,o,a){const c=new zh(this.currentPoint.clone(),new Ie(e,t),new Ie(n,r),new Ie(o,a));return this.curves.push(c),this.currentPoint.set(o,a),this}splineThru(e){const t=[this.currentPoint.clone()].concat(e),n=new Xg(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 kh(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 hu extends jg{constructor(e){super(e),this.uuid=kr(),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 jg().fromJSON(r))}return this}}function F0(i,e,t=2){const n=e&&e.length,r=n?e[0]*t:i.length;let o=Yg(i,0,r,t,!0);const a=[];if(!o||o.next===o.prev)return a;let c,u,d;if(n&&(o=du(i,e,o,t)),i.length>80*t){c=1/0,u=1/0;let p=-1/0,m=-1/0;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 uf(o,a,t,c,u,d,0),a}function Yg(i,e,t,n,r){let o;if(r===mf(i,e,t,n)>0)for(let a=e;a<t;a+=n)o=pf(a/n|0,i[a],i[a+1],o);else for(let a=t-n;a>=e;a-=n)o=pf(a/n|0,i[a],i[a+1],o);return o&&ec(o,o.next)&&(nc(o),o=o.next),o}function Ga(i,e){if(!i)return i;e||(e=i);let t=i,n;do if(n=!1,!t.steiner&&(ec(t,t.next)||Qi(t.prev,t,t.next)===0)){if(nc(t),t=e=t.prev,t===t.next)break;n=!0}else t=t.next;while(n||t!==e);return e}function uf(i,e,t,n,r,o,a){if(!i)return;!a&&o&&Qb(i,n,r,o);let c=i;for(;i.prev!==i.next;){const u=i.prev,d=i.next;if(o?Vh(i,n,r,o):Zg(i)){e.push(u.i,i.i,d.i),nc(i),i=d.next,c=d.next;continue}if(i=d,i===c){a?a===1?(i=Yb(Ga(i),e),uf(i,e,t,n,r,o,2)):a===2&&B0(i,e,t,n,r,o):uf(Ga(i),e,t,n,r,o,1);break}}}function Zg(i){const e=i.prev,t=i,n=i.next;if(Qi(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&&df(r,c,o,u,a,d,v.x,v.y)&&Qi(v.prev,v,v.next)>=0)return!1;v=v.next}return!0}function Vh(i,e,t,n){const r=i.prev,o=i,a=i.next;if(Qi(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),M=Math.max(c,u,d),T=Math.max(p,m,y),S=Kg(x,v,e,t,n),N=Kg(M,T,e,t,n);let R=i.prevZ,P=i.nextZ;for(;R&&R.z>=S&&P&&P.z<=N;){if(R.x>=x&&R.x<=M&&R.y>=v&&R.y<=T&&R!==r&&R!==a&&df(c,p,u,m,d,y,R.x,R.y)&&Qi(R.prev,R,R.next)>=0||(R=R.prevZ,P.x>=x&&P.x<=M&&P.y>=v&&P.y<=T&&P!==r&&P!==a&&df(c,p,u,m,d,y,P.x,P.y)&&Qi(P.prev,P,P.next)>=0))return!1;P=P.nextZ}for(;R&&R.z>=S;){if(R.x>=x&&R.x<=M&&R.y>=v&&R.y<=T&&R!==r&&R!==a&&df(c,p,u,m,d,y,R.x,R.y)&&Qi(R.prev,R,R.next)>=0)return!1;R=R.prevZ}for(;P&&P.z<=N;){if(P.x>=x&&P.x<=M&&P.y>=v&&P.y<=T&&P!==r&&P!==a&&df(c,p,u,m,d,y,P.x,P.y)&&Qi(P.prev,P,P.next)>=0)return!1;P=P.nextZ}return!0}function Yb(i,e){let t=i;do{const n=t.prev,r=t.next.next;!ec(n,r)&&U0(n,t,t.next,r)&&Li(n,r)&&Li(r,n)&&(e.push(n.i,t.i,r.i),nc(t),nc(t.next),t=i=r),t=t.next}while(t!==i);return Ga(t)}function B0(i,e,t,n,r,o){let a=i;do{let c=a.next.next;for(;c!==a.prev;){if(a.i!==c.i&&nS(a,c)){let u=Jg(a,c);a=Ga(a,a.next),u=Ga(u,u.next),uf(a,e,t,n,r,o,0),uf(u,e,t,n,r,o,0);return}c=c.next}a=a.next}while(a!==i)}function du(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=Yg(i,c,u,n,!1);d===d.next&&(d.steiner=!0),r.push(tS(d))}r.sort(hf);for(let o=0;o<r.length;o++)t=Zb(r[o],t);return t}function hf(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 Zb(i,e){const t=Kb(i,e);if(!t)return e;const n=Jg(t,i);return Ga(n,n.next),Ga(t,t.next)}function Kb(i,e){let t=e;const n=i.x,r=i.y;let o=-1/0,a;if(ec(i,t))return t;do{if(ec(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&&O0(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);Li(t,i)&&(m<p||m===p&&(t.x>a.x||t.x===a.x&&Jb(a,t)))&&(a=t,p=m)}t=t.next}while(t!==c);return a}function Jb(i,e){return Qi(i.prev,i,e.prev)<0&&Qi(e.next,i,i.next)<0}function Qb(i,e,t,n){let r=i;do r.z===0&&(r.z=Kg(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,eS(r)}function eS(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 Kg(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 tS(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 O0(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 df(i,e,t,n,r,o,a,c){return!(i===a&&e===c)&&O0(i,e,t,n,r,o,a,c)}function nS(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!iS(i,e)&&(Li(i,e)&&Li(e,i)&&Gh(i,e)&&(Qi(i.prev,i,e.prev)||Qi(i,e.prev,e))||ec(i,e)&&Qi(i.prev,i,i.next)>0&&Qi(e.prev,e,e.next)>0)}function Qi(i,e,t){return(e.y-i.y)*(t.x-e.x)-(e.x-i.x)*(t.y-e.y)}function ec(i,e){return i.x===e.x&&i.y===e.y}function U0(i,e,t,n){const r=tc(Qi(i,e,t)),o=tc(Qi(i,e,n)),a=tc(Qi(t,n,i)),c=tc(Qi(t,n,e));return!!(r!==o&&a!==c||r===0&&ff(i,t,e)||o===0&&ff(i,n,e)||a===0&&ff(t,i,n)||c===0&&ff(t,e,n))}function ff(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 tc(i){return i>0?1:i<0?-1:0}function iS(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&&U0(t,t.next,i,e))return!0;t=t.next}while(t!==i);return!1}function Li(i,e){return Qi(i.prev,i,i.next)<0?Qi(i,e,i.next)>=0&&Qi(i,i.prev,e)>=0:Qi(i,e,i.prev)<0||Qi(i,i.next,e)<0}function Gh(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 Jg(i,e){const t=Qg(i.i,i.x,i.y),n=Qg(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 pf(i,e,t,n){const r=Qg(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 nc(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 Qg(i,e,t){return{i,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function mf(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 sS{static triangulate(e,t,n=2){return F0(e,t,n)}}class ia{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 ia.area(e)<0}static triangulateShape(e,t){const n=[],r=[],o=[];ey(e),Hh(n,e);let a=e.length;t.forEach(ey);for(let u=0;u<t.length;u++)r.push(a),a+=t[u].length,Hh(n,t[u]);const c=sS.triangulate(n,r);for(let u=0;u<c.length;u+=3)o.push(c.slice(u,u+3));return o}}function ey(i){const e=i.length;e>2&&i[e-1].equals(i[0])&&i.pop()}function Hh(i,e){for(let t=0;t<e.length;t++)i.push(e[t].x),i.push(e[t].y)}class gf extends gn{constructor(e=new hu([new Ie(.5,.5),new Ie(-.5,.5),new Ie(-.5,-.5),new Ie(.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 $t(r,3)),this.setAttribute("uv",new $t(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,M=t.bevelOffset!==void 0?t.bevelOffset:0,T=t.bevelSegments!==void 0?t.bevelSegments:3;const S=t.extrudePath,N=t.UVGenerator!==void 0?t.UVGenerator:rS;let R,P=!1,B,F,k,V;S&&(R=S.getSpacedPoints(p),P=!0,y=!1,B=S.computeFrenetFrames(p,!1),F=new W,k=new W,V=new W),y||(T=0,x=0,v=0,M=0);const U=c.extractPoints(d);let z=U.shape;const j=U.holes;if(!ia.isClockWise(z)){z=z.reverse();for(let st=0,it=j.length;st<it;st++){const tt=j[st];ia.isClockWise(tt)&&(j[st]=tt.reverse())}}function pe(st){const tt=10000000000000001e-36;let Qe=st[0];for(let Mt=1;Mt<=st.length;Mt++){const gt=Mt%st.length,Nt=st[gt],Hn=Nt.x-Qe.x,zn=Nt.y-Qe.y,K=Hn*Hn+zn*zn,H=Math.max(Math.abs(Nt.x),Math.abs(Nt.y),Math.abs(Qe.x),Math.abs(Qe.y)),we=tt*H*H;if(K<=we){st.splice(gt,1),Mt--;continue}Qe=Nt}}pe(z),j.forEach(pe);const be=j.length,Pe=z;for(let st=0;st<be;st++){const it=j[st];z=z.concat(it)}function Ce(st,it,tt){return it||console.error("THREE.ExtrudeGeometry: vec does not exist"),st.clone().addScaledVector(it,tt)}const nt=z.length;function Le(st,it,tt){let Qe,Mt,gt;const Nt=st.x-it.x,Hn=st.y-it.y,zn=tt.x-st.x,K=tt.y-st.y,H=Nt*Nt+Hn*Hn,we=Nt*K-Hn*zn;if(Math.abs(we)>Number.EPSILON){const $e=Math.sqrt(H),ut=Math.sqrt(zn*zn+K*K),Ye=it.x-Hn/$e,dn=it.y+Nt/$e,Ct=tt.x-K/ut,ln=tt.y+zn/ut,cn=((Ct-Ye)*K-(ln-dn)*zn)/(Nt*K-Hn*zn);Qe=Ye+Nt*cn-st.x,Mt=dn+Hn*cn-st.y;const yt=Qe*Qe+Mt*Mt;if(yt<=2)return new Ie(Qe,Mt);gt=Math.sqrt(yt/2)}else{let $e=!1;Nt>Number.EPSILON?zn>Number.EPSILON&&($e=!0):Nt<-Number.EPSILON?zn<-Number.EPSILON&&($e=!0):Math.sign(Hn)===Math.sign(K)&&($e=!0),$e?(Qe=-Hn,Mt=Nt,gt=Math.sqrt(H)):(Qe=Nt,Mt=Hn,gt=Math.sqrt(H/2))}return new Ie(Qe/gt,Mt/gt)}const ht=[];for(let st=0,it=Pe.length,tt=it-1,Qe=st+1;st<it;st++,tt++,Qe++)tt===it&&(tt=0),Qe===it&&(Qe=0),ht[st]=Le(Pe[st],Pe[tt],Pe[Qe]);const De=[];let Je,wt=ht.concat();for(let st=0,it=be;st<it;st++){const tt=j[st];Je=[];for(let Qe=0,Mt=tt.length,gt=Mt-1,Nt=Qe+1;Qe<Mt;Qe++,gt++,Nt++)gt===Mt&&(gt=0),Nt===Mt&&(Nt=0),Je[Qe]=Le(tt[Qe],tt[gt],tt[Nt]);De.push(Je),wt=wt.concat(Je)}let Xt;if(T===0)Xt=ia.triangulateShape(Pe,j);else{const st=[],it=[];for(let tt=0;tt<T;tt++){const Qe=tt/T,Mt=x*Math.cos(Qe*Math.PI/2),gt=v*Math.sin(Qe*Math.PI/2)+M;for(let Nt=0,Hn=Pe.length;Nt<Hn;Nt++){const zn=Ce(Pe[Nt],ht[Nt],gt);Bt(zn.x,zn.y,-Mt),Qe===0&&st.push(zn)}for(let Nt=0,Hn=be;Nt<Hn;Nt++){const zn=j[Nt];Je=De[Nt];const K=[];for(let H=0,we=zn.length;H<we;H++){const $e=Ce(zn[H],Je[H],gt);Bt($e.x,$e.y,-Mt),Qe===0&&K.push($e)}Qe===0&&it.push(K)}}Xt=ia.triangulateShape(st,it)}const Ln=Xt.length,Ke=v+M;for(let st=0;st<nt;st++){const it=y?Ce(z[st],wt[st],Ke):z[st];P?(k.copy(B.normals[0]).multiplyScalar(it.x),F.copy(B.binormals[0]).multiplyScalar(it.y),V.copy(R[0]).add(k).add(F),Bt(V.x,V.y,V.z)):Bt(it.x,it.y,0)}for(let st=1;st<=p;st++)for(let it=0;it<nt;it++){const tt=y?Ce(z[it],wt[it],Ke):z[it];P?(k.copy(B.normals[st]).multiplyScalar(tt.x),F.copy(B.binormals[st]).multiplyScalar(tt.y),V.copy(R[st]).add(k).add(F),Bt(V.x,V.y,V.z)):Bt(tt.x,tt.y,m/p*st)}for(let st=T-1;st>=0;st--){const it=st/T,tt=x*Math.cos(it*Math.PI/2),Qe=v*Math.sin(it*Math.PI/2)+M;for(let Mt=0,gt=Pe.length;Mt<gt;Mt++){const Nt=Ce(Pe[Mt],ht[Mt],Qe);Bt(Nt.x,Nt.y,m+tt)}for(let Mt=0,gt=j.length;Mt<gt;Mt++){const Nt=j[Mt];Je=De[Mt];for(let Hn=0,zn=Nt.length;Hn<zn;Hn++){const K=Ce(Nt[Hn],Je[Hn],Qe);P?Bt(K.x,K.y+R[p-1].y,R[p-1].x+tt):Bt(K.x,K.y,m+tt)}}}Se(),Fe();function Se(){const st=r.length/3;if(y){let it=0,tt=nt*it;for(let Qe=0;Qe<Ln;Qe++){const Mt=Xt[Qe];Rt(Mt[2]+tt,Mt[1]+tt,Mt[0]+tt)}it=p+T*2,tt=nt*it;for(let Qe=0;Qe<Ln;Qe++){const Mt=Xt[Qe];Rt(Mt[0]+tt,Mt[1]+tt,Mt[2]+tt)}}else{for(let it=0;it<Ln;it++){const tt=Xt[it];Rt(tt[2],tt[1],tt[0])}for(let it=0;it<Ln;it++){const tt=Xt[it];Rt(tt[0]+nt*p,tt[1]+nt*p,tt[2]+nt*p)}}n.addGroup(st,r.length/3-st,0)}function Fe(){const st=r.length/3;let it=0;mt(Pe,it),it+=Pe.length;for(let tt=0,Qe=j.length;tt<Qe;tt++){const Mt=j[tt];mt(Mt,it),it+=Mt.length}n.addGroup(st,r.length/3-st,1)}function mt(st,it){let tt=st.length;for(;--tt>=0;){const Qe=tt;let Mt=tt-1;Mt<0&&(Mt=st.length-1);for(let gt=0,Nt=p+T*2;gt<Nt;gt++){const Hn=nt*gt,zn=nt*(gt+1),K=it+Qe+Hn,H=it+Mt+Hn,we=it+Mt+zn,$e=it+Qe+zn;hn(K,H,we,$e)}}}function Bt(st,it,tt){u.push(st),u.push(it),u.push(tt)}function Rt(st,it,tt){ri(st),ri(it),ri(tt);const Qe=r.length/3,Mt=N.generateTopUV(n,r,Qe-3,Qe-2,Qe-1);re(Mt[0]),re(Mt[1]),re(Mt[2])}function hn(st,it,tt,Qe){ri(st),ri(it),ri(Qe),ri(it),ri(tt),ri(Qe);const Mt=r.length/3,gt=N.generateSideWallUV(n,r,Mt-6,Mt-3,Mt-2,Mt-1);re(gt[0]),re(gt[1]),re(gt[3]),re(gt[1]),re(gt[2]),re(gt[3])}function ri(st){r.push(u[st*3+0]),r.push(u[st*3+1]),r.push(u[st*3+2])}function re(st){o.push(st.x),o.push(st.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 oS(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 Qp[r.type]().fromJSON(r)),new gf(n,e.options)}}const rS={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 Ie(o,a),new Ie(c,u),new Ie(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],M=e[o*3],T=e[o*3+1],S=e[o*3+2];return Math.abs(c-p)<Math.abs(a-d)?[new Ie(a,1-u),new Ie(d,1-m),new Ie(y,1-v),new Ie(M,1-S)]:[new Ie(c,1-u),new Ie(p,1-m),new Ie(x,1-v),new Ie(T,1-S)]}};function oS(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 Ro extends Fh{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 Ro(e.radius,e.detail)}}class em extends gn{constructor(e=[new Ie(0,-.5),new Ie(.5,0),new Ie(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=fn(r,0,Math.PI*2);const o=[],a=[],c=[],u=[],d=[],p=1/t,m=new W,y=new Ie,x=new W,v=new W,M=new W;let T=0,S=0;for(let N=0;N<=e.length-1;N++)switch(N){case 0:T=e[N+1].x-e[N].x,S=e[N+1].y-e[N].y,x.x=S*1,x.y=-T,x.z=S*0,M.copy(x),x.normalize(),u.push(x.x,x.y,x.z);break;case e.length-1:u.push(M.x,M.y,M.z);break;default:T=e[N+1].x-e[N].x,S=e[N+1].y-e[N].y,x.x=S*1,x.y=-T,x.z=S*0,v.copy(x),x.x+=M.x,x.y+=M.y,x.z+=M.z,x.normalize(),u.push(x.x,x.y,x.z),M.copy(v)}for(let N=0;N<=t;N++){const R=n+N*p*r,P=Math.sin(R),B=Math.cos(R);for(let F=0;F<=e.length-1;F++){m.x=e[F].x*P,m.y=e[F].y,m.z=e[F].x*B,a.push(m.x,m.y,m.z),y.x=N/t,y.y=F/(e.length-1),c.push(y.x,y.y);const k=u[3*F+0]*P,V=u[3*F+1],U=u[3*F+0]*B;d.push(k,V,U)}}for(let N=0;N<t;N++)for(let R=0;R<e.length-1;R++){const P=R+N*e.length,B=P,F=P+e.length,k=P+e.length+1,V=P+1;o.push(B,F,V),o.push(k,V,F)}this.setIndex(o),this.setAttribute("position",new $t(a,3)),this.setAttribute("uv",new $t(c,2)),this.setAttribute("normal",new $t(d,3))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new em(e.points,e.segments,e.phiStart,e.phiLength)}}class yf extends Fh{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 yf(e.radius,e.detail)}}class ic 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=[],M=[],T=[];for(let S=0;S<p;S++){const N=S*y-a;for(let R=0;R<d;R++){const P=R*m-o;v.push(P,-N,0),M.push(0,0,1),T.push(R/c),T.push(1-S/u)}}for(let S=0;S<u;S++)for(let N=0;N<c;N++){const R=N+d*S,P=N+d*(S+1),B=N+1+d*(S+1),F=N+1+d*S;x.push(R,P,F),x.push(P,B,F)}this.setIndex(x),this.setAttribute("position",new $t(v,3)),this.setAttribute("normal",new $t(M,3)),this.setAttribute("uv",new $t(T,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ic(e.width,e.height,e.widthSegments,e.heightSegments)}}class ty 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 W,v=new Ie;for(let M=0;M<=r;M++){for(let T=0;T<=n;T++){const S=o+T/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 M=0;M<r;M++){const T=M*(n+1);for(let S=0;S<n;S++){const N=S+T,R=N,P=N+n+1,B=N+n+2,F=N+1;c.push(R,P,F),c.push(P,B,F)}}this.setIndex(c),this.setAttribute("position",new $t(u,3)),this.setAttribute("normal",new $t(d,3)),this.setAttribute("uv",new $t(p,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new ty(e.innerRadius,e.outerRadius,e.thetaSegments,e.phiSegments,e.thetaStart,e.thetaLength)}}class ny extends gn{constructor(e=new hu([new Ie(0,.5),new Ie(-.5,-.5),new Ie(.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 $t(r,3)),this.setAttribute("normal",new $t(o,3)),this.setAttribute("uv",new $t(a,2));function d(p){const m=r.length/3,y=p.extractPoints(t);let x=y.shape;const v=y.holes;ia.isClockWise(x)===!1&&(x=x.reverse());for(let T=0,S=v.length;T<S;T++){const N=v[T];ia.isClockWise(N)===!0&&(v[T]=N.reverse())}const M=ia.triangulateShape(x,v);for(let T=0,S=v.length;T<S;T++){const N=v[T];x=x.concat(N)}for(let T=0,S=x.length;T<S;T++){const N=x[T];r.push(N.x,N.y,0),o.push(0,0,1),a.push(N.x,N.y)}for(let T=0,S=M.length;T<S;T++){const N=M[T],R=N[0]+m,P=N[1]+m,B=N[2]+m;n.push(R,P,B),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 iy(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 ny(n,e.curveSegments)}}function iy(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 gl 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 W,y=new W,x=[],v=[],M=[],T=[];for(let S=0;S<=n;S++){const N=[],R=S/n;let P=0;S===0&&a===0?P=.5/t:S===n&&u===Math.PI&&(P=-.5/t);for(let B=0;B<=t;B++){const F=B/t;m.x=-e*Math.cos(r+F*o)*Math.sin(a+R*c),m.y=e*Math.cos(a+R*c),m.z=e*Math.sin(r+F*o)*Math.sin(a+R*c),v.push(m.x,m.y,m.z),y.copy(m).normalize(),M.push(y.x,y.y,y.z),T.push(F+P,1-R),N.push(d++)}p.push(N)}for(let S=0;S<n;S++)for(let N=0;N<t;N++){const R=p[S][N+1],P=p[S][N],B=p[S+1][N],F=p[S+1][N+1];(S!==0||a>0)&&x.push(R,P,F),(S!==n-1||u<Math.PI)&&x.push(P,B,F)}this.setIndex(x),this.setAttribute("position",new $t(v,3)),this.setAttribute("normal",new $t(M,3)),this.setAttribute("uv",new $t(T,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new gl(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}class Wh extends Fh{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 Wh(e.radius,e.detail)}}class _f 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 W,m=new W,y=new W;for(let x=0;x<=n;x++)for(let v=0;v<=r;v++){const M=v/r*o,T=x/n*Math.PI*2;m.x=(e+t*Math.cos(T))*Math.cos(M),m.y=(e+t*Math.cos(T))*Math.sin(M),m.z=t*Math.sin(T),c.push(m.x,m.y,m.z),p.x=e*Math.cos(M),p.y=e*Math.sin(M),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 M=(r+1)*x+v-1,T=(r+1)*(x-1)+v-1,S=(r+1)*(x-1)+v,N=(r+1)*x+v;a.push(M,T,N),a.push(T,S,N)}this.setIndex(a),this.setAttribute("position",new $t(c,3)),this.setAttribute("normal",new $t(u,3)),this.setAttribute("uv",new $t(d,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new _f(e.radius,e.tube,e.radialSegments,e.tubularSegments,e.arc)}}class xf 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 W,y=new W,x=new W,v=new W,M=new W,T=new W,S=new W;for(let R=0;R<=n;++R){const P=R/n*o*Math.PI*2;N(P,o,a,e,x),N(P+.01,o,a,e,v),T.subVectors(v,x),S.addVectors(v,x),M.crossVectors(T,S),S.crossVectors(M,T),M.normalize(),S.normalize();for(let B=0;B<=r;++B){const F=B/r*Math.PI*2,k=-t*Math.cos(F),V=t*Math.sin(F);m.x=x.x+(k*S.x+V*M.x),m.y=x.y+(k*S.y+V*M.y),m.z=x.z+(k*S.z+V*M.z),u.push(m.x,m.y,m.z),y.subVectors(m,x).normalize(),d.push(y.x,y.y,y.z),p.push(R/n),p.push(B/r)}}for(let R=1;R<=n;R++)for(let P=1;P<=r;P++){const B=(r+1)*(R-1)+(P-1),F=(r+1)*R+(P-1),k=(r+1)*R+P,V=(r+1)*(R-1)+P;c.push(B,F,V),c.push(F,k,V)}this.setIndex(c),this.setAttribute("position",new $t(u,3)),this.setAttribute("normal",new $t(d,3)),this.setAttribute("uv",new $t(p,2));function N(R,P,B,F,k){const V=Math.cos(R),U=Math.sin(R),z=B/P*R,j=Math.cos(z);k.x=F*(2+j)*.5*V,k.y=F*(2+j)*U*.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 xf(e.radius,e.tube,e.tubularSegments,e.radialSegments,e.p,e.q)}}class $h extends gn{constructor(e=new uu(new W(-1,-1,0),new W(-1,1,0),new W(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 W,u=new W,d=new Ie;let p=new W;const m=[],y=[],x=[],v=[];M(),this.setIndex(v),this.setAttribute("position",new $t(m,3)),this.setAttribute("normal",new $t(y,3)),this.setAttribute("uv",new $t(x,2));function M(){for(let R=0;R<t;R++)T(R);T(o===!1?t:0),N(),S()}function T(R){p=e.getPointAt(R/t,p);const P=a.normals[R],B=a.binormals[R];for(let F=0;F<=r;F++){const k=F/r*Math.PI*2,V=Math.sin(k),U=-Math.cos(k);u.x=U*P.x+V*B.x,u.y=U*P.y+V*B.y,u.z=U*P.z+V*B.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 R=1;R<=t;R++)for(let P=1;P<=r;P++){const B=(r+1)*(R-1)+(P-1),F=(r+1)*R+(P-1),k=(r+1)*R+P,V=(r+1)*(R-1)+P;v.push(B,F,V),v.push(F,k,V)}}function N(){for(let R=0;R<=t;R++)for(let P=0;P<=r;P++)d.x=R/t,d.y=P/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 $h(new Qp[e.path.type]().fromJSON(e.path),e.tubularSegments,e.radius,e.radialSegments,e.closed)}}class aS extends gn{constructor(e=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:e},e!==null){const t=[],n=new Set,r=new W,o=new W;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,M=y+x;v<M;v+=3)for(let T=0;T<3;T++){const S=c.getX(v+T),N=c.getX(v+(T+1)%3);r.fromBufferAttribute(a,S),o.fromBufferAttribute(a,N),qh(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),qh(r,o,n)===!0&&(t.push(r.x,r.y,r.z),t.push(o.x,o.y,o.z))}}this.setAttribute("position",new $t(t,3))}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}}function qh(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 tm=Object.freeze({__proto__:null,BoxGeometry:Ko,CapsuleGeometry:Hg,CircleGeometry:C0,ConeGeometry:of,CylinderGeometry:rf,DodecahedronGeometry:R0,EdgesGeometry:au,ExtrudeGeometry:gf,IcosahedronGeometry:Ro,LatheGeometry:em,OctahedronGeometry:yf,PlaneGeometry:ic,PolyhedronGeometry:Fh,RingGeometry:ty,ShapeGeometry:ny,SphereGeometry:gl,TetrahedronGeometry:Wh,TorusGeometry:_f,TorusKnotGeometry:xf,TubeGeometry:$h,WireframeGeometry:aS});class nm extends $i{constructor(e){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new At(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 sy extends null{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class vf extends $i{constructor(e){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new At(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 At(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ur,this.normalScale=new Ie(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 Gr,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 k0 extends vf{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 Ie(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return fn(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 At(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 At(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new At(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 ry extends $i{constructor(e){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new At(16777215),this.specular=new At(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new At(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ur,this.normalScale=new Ie(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Gr,this.combine=Rc,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 oy extends $i{constructor(e){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new At(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new At(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ur,this.normalScale=new Ie(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 z0 extends $i{constructor(e){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ur,this.normalScale=new Ie(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 ay extends $i{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new At(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new At(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ur,this.normalScale=new Ie(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Gr,this.combine=Rc,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 V0 extends $i{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=wb,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 G0 extends $i{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 ly extends $i{constructor(e){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new At(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ur,this.normalScale=new Ie(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.alphaMap=null,this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.defines={MATCAP:""},this.color.copy(e.color),this.matcap=e.matcap,this.map=e.map,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.alphaMap=e.alphaMap,this.flatShading=e.flatShading,this.fog=e.fog,this}}class cy 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 fu(i,e){return!i||i.constructor===e?i:typeof e.BYTES_PER_ELEMENT=="number"?new e(i):Array.prototype.slice.call(i)}function H0(i){return ArrayBuffer.isView(i)&&!(i instanceof DataView)}function W0(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 uy(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 hy(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 lS(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 M=0;M<p;++M)y.push(d.values[x*p+M])}}m.length!==0&&(d.times=fu(m,d.times.constructor),d.values=fu(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 pu(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 M;if(o<=c.times[0]){const S=p,N=m-p;M=c.values.slice(S,N)}else if(o>=c.times[v]){const S=v*m+p,N=S+m-p;M=c.values.slice(S,N)}else{const S=c.createInterpolant(),N=p,R=m-p;S.evaluate(o),M=S.resultBuffer.slice(N,R)}u==="quaternion"&&new Fs().fromArray(M).normalize().conjugate().toArray(M);const T=d.times.length;for(let S=0;S<T;++S){const N=S*x+y;if(u==="quaternion")Fs.multiplyQuaternionsFlat(d.values,N,M,0,d.values,N);else{const R=x-y*2;for(let P=0;P<R;++P)d.values[N+P]-=M[P]}}}return i.blendMode=dg,i}class cS{static convertArray(e,t){return fu(e,t)}static isTypedArray(e){return H0(e)}static getKeyframeOrder(e){return W0(e)}static sortedArray(e,t,n){return uy(e,t,n)}static flattenJSON(e,t,n,r){hy(e,t,n,r)}static subclip(e,t,n,r,o=30){return lS(e,t,n,r,o)}static makeClipAdditive(e,t=0,n=e,r=30){return pu(e,t,n,r)}}class bf{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 dy extends bf{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:Ho,endingEnd:Ho}}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 Wo:o=e,c=2*t-n;break;case Oc: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 Wo:a=e,u=2*n-t;break;case Oc: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),M=v*v,T=M*v,S=-y*T+2*y*M-y*v,N=(1+y)*T+(-1.5-2*y)*M+(-.5+y)*v+1,R=(-1-x)*T+(1.5+x)*M+.5*v,P=x*T-x*M;for(let B=0;B!==c;++B)o[B]=S*a[p+B]+N*a[d+B]+R*a[u+B]+P*a[m+B];return o}}class im extends bf{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 uS extends bf{constructor(e,t,n,r){super(e,t,n,r)}interpolate_(e){return this.copySampleValue_(e-1)}}class sa{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=fu(t,this.TimeBufferType),this.values=fu(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:fu(e.times,Array),values:fu(e.values,Array)};const r=e.getInterpolation();r!==e.DefaultInterpolation&&(n.interpolation=r)}return n.type=e.ValueTypeName,n}InterpolantFactoryMethodDiscrete(e){return new uS(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodLinear(e){return new im(this.times,this.values,this.getValueSize(),e)}InterpolantFactoryMethodSmooth(e){return new dy(this.times,this.values,this.getValueSize(),e)}setInterpolation(e){let t;switch(e){case Bc:t=this.InterpolantFactoryMethodDiscrete;break;case Ad:t=this.InterpolantFactoryMethodLinear;break;case Ed: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 console.warn("THREE.KeyframeTrack:",n),this}return this.createInterpolant=t,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Bc;case this.InterpolantFactoryMethodLinear:return Ad;case this.InterpolantFactoryMethodSmooth:return Ed}}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&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),e=!1);const n=this.times,r=this.values,o=n.length;o===0&&(console.error("THREE.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)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,c,u),e=!1;break}if(a!==null&&a>u){console.error("THREE.KeyframeTrack: Out of order keys.",this,c,u,a),e=!1;break}a=u}if(r!==void 0&&H0(r))for(let c=0,u=r.length;c!==u;++c){const d=r[c];if(isNaN(d)){console.error("THREE.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()===Ed,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 M=t[m+v];if(M!==t[y+v]||M!==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}}sa.prototype.ValueTypeName="",sa.prototype.TimeBufferType=Float32Array,sa.prototype.ValueBufferType=Float32Array,sa.prototype.DefaultInterpolation=Ad;class Sf extends sa{constructor(e,t,n){super(e,t,n)}}Sf.prototype.ValueTypeName="bool",Sf.prototype.ValueBufferType=Array,Sf.prototype.DefaultInterpolation=Bc,Sf.prototype.InterpolantFactoryMethodLinear=void 0,Sf.prototype.InterpolantFactoryMethodSmooth=void 0;class Tf extends sa{constructor(e,t,n,r){super(e,t,n,r)}}Tf.prototype.ValueTypeName="color";class sm extends sa{constructor(e,t,n,r){super(e,t,n,r)}}sm.prototype.ValueTypeName="number";class $0 extends bf{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)Fs.slerpFlat(o,0,a,d-c,a,d,u);return o}}class rm extends sa{constructor(e,t,n,r){super(e,t,n,r)}InterpolantFactoryMethodLinear(e){return new $0(this.times,this.values,this.getValueSize(),e)}}rm.prototype.ValueTypeName="quaternion",rm.prototype.InterpolantFactoryMethodSmooth=void 0;class gr extends sa{constructor(e,t,n){super(e,t,n)}}gr.prototype.ValueTypeName="string",gr.prototype.ValueBufferType=Array,gr.prototype.DefaultInterpolation=Bc,gr.prototype.InterpolantFactoryMethodLinear=void 0,gr.prototype.InterpolantFactoryMethodSmooth=void 0;class yl extends sa{constructor(e,t,n,r){super(e,t,n,r)}}yl.prototype.ValueTypeName="vector";class wf{constructor(e="",t=-1,n=[],r=Cd){this.name=e,this.tracks=n,this.duration=t,this.blendMode=r,this.uuid=kr(),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(hS(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(sa.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=W0(u);u=uy(u,1,p),d=uy(d,1,p),!r&&u[0]===0&&(u.push(o),d.push(d[0])),a.push(new sm(".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(console.warn("THREE.AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!e)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const n=function(m,y,x,v,M){if(x.length!==0){const T=[],S=[];hy(x,T,S,v),T.length!==0&&M.push(new m(y,T,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 M=0;M<y[v].morphTargets.length;M++)x[y[v].morphTargets[M]]=-1;for(const M in x){const T=[],S=[];for(let N=0;N!==y[v].morphTargets.length;++N){const R=y[v];T.push(R.time),S.push(R.morphTarget===M?1:0)}r.push(new sm(".morphTargetInfluence["+M+"]",T,S))}u=x.length*a}else{const x=".bones["+t[m].name+"]";n(yl,x+".position",y,"pos",r),n(rm,x+".quaternion",y,"rot",r),n(yl,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 om(i){switch(i.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return sm;case"vector":case"vector2":case"vector3":case"vector4":return yl;case"color":return Tf;case"quaternion":return rm;case"bool":case"boolean":return Sf;case"string":return gr}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+i)}function hS(i){if(i.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const e=om(i.type);if(i.times===void 0){const t=[],n=[];hy(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 No={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 mu{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=new AbortController,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=new AbortController,this}}}const am=new mu;class Xh{constructor(e){this.manager=e!==void 0?e:am,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}}Xh.DEFAULT_MATERIAL_NAME="__DEFAULT";const _l={};class dS extends null{constructor(e,t){super(e),this.response=t}}class yr 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=No.get(`file:${e}`);if(o!==void 0)return this.manager.itemStart(e),setTimeout(()=>{t&&t(o),this.manager.itemEnd(e)},0),o;if(_l[e]!==void 0){_l[e].push({onLoad:t,onProgress:n,onError:r});return}_l[e]=[],_l[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&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream=="undefined"||d.body===void 0||d.body.getReader===void 0)return d;const p=_l[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 M=0;const T=new ReadableStream({start(S){N();function N(){m.read().then(({done:R,value:P})=>{if(R)S.close();else{M+=P.byteLength;const B=new ProgressEvent("progress",{lengthComputable:v,loaded:M,total:x});for(let F=0,k=p.length;F<k;F++){const V=p[F];V.onProgress&&V.onProgress(B)}S.enqueue(P),N()}},R=>{S.error(R)})}}});return new Response(T)}else throw new dS(`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=>{No.add(`file:${e}`,d);const p=_l[e];delete _l[e];for(let m=0,y=p.length;m<y;m++){const x=p[m];x.onLoad&&x.onLoad(d)}}).catch(d=>{const p=_l[e];if(p===void 0)throw this.manager.itemError(e),d;delete _l[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 fS extends null{constructor(e){super(e)}load(e,t,n,r){const o=this,a=new yr(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):console.error(u),o.manager.itemError(e)}},n,r)}parse(e){const t=[];for(let n=0;n<e.length;n++){const r=wf.parse(e[n]);t.push(r)}return t}}class Z1 extends null{constructor(e){super(e)}load(e,t,n,r){const o=this,a=[],c=new Yp,u=new yr(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 M=0;M<y.mipmapCount;M++)a[v].mipmaps.push(y.mipmaps[v*y.mipmapCount+M]),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 jh=new WeakMap;class Po extends Xh{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=No.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=jh.get(a);m===void 0&&(m=[],jh.set(a,m)),m.push({onLoad:t,onError:r})}return a}const c=Dd("img");function u(){p(),t&&t(this);const m=jh.get(this)||[];for(let y=0;y<m.length;y++){const x=m[y];x.onLoad&&x.onLoad(this)}jh.delete(this),o.manager.itemEnd(e)}function d(m){p(),r&&r(m),No.remove(`image:${e}`);const y=jh.get(this)||[];for(let x=0;x<y.length;x++){const v=y[x];v.onError&&v.onError(m)}jh.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),No.add(`image:${e}`,c),o.manager.itemStart(e),c.src=e,c}}class K1 extends null{constructor(e){super(e)}load(e,t,n,r){const o=new jl;o.colorSpace=Ei;const a=new Po(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 gu extends null{constructor(e){super(e)}load(e,t,n,r){const o=this,a=new oo,c=new yr(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{console.error(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=Ds),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 J1 extends Xh{constructor(e){super(e)}load(e,t,n,r){const o=new ds,a=new Po(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 Yh extends Hi{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new At(e),this.intensity=t}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,this.groundColor!==void 0&&(t.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(t.object.distance=this.distance),this.angle!==void 0&&(t.object.angle=this.angle),this.decay!==void 0&&(t.object.decay=this.decay),this.penumbra!==void 0&&(t.object.penumbra=this.penumbra),this.shadow!==void 0&&(t.object.shadow=this.shadow.toJSON()),this.target!==void 0&&(t.object.target=this.target.uuid),t}}class yu extends Yh{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Hi.DEFAULT_UP),this.updateMatrix(),this.groundColor=new At(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}}const Zh=new Vt,pS=new W,mS=new W;class q0{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Ie(512,512),this.mapType=Ui,this.map=null,this.mapPass=null,this.matrix=new Vt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Ih,this._frameExtents=new Ie(1,1),this._viewportCount=1,this._viewports=[new an(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;pS.setFromMatrixPosition(e.matrixWorld),t.position.copy(pS),mS.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(mS),t.updateMatrixWorld(),Zh.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Zh,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(Zh)}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 Q1 extends q0{constructor(){super(new ps(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(e){const t=this.camera,n=gh*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 lm extends Yh{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(Hi.DEFAULT_UP),this.updateMatrix(),this.target=new Hi,this.distance=n,this.angle=r,this.penumbra=o,this.decay=a,this.map=null,this.shadow=new Q1}get power(){return this.intensity*Math.PI}set power(e){this.intensity=e/Math.PI}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.shadow=e.shadow.clone(),this}}const cm=new Vt,Kh=new W,um=new W;class eA extends q0{constructor(){super(new ps(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new Ie(4,2),this._viewportCount=6,this._viewports=[new an(2,1,1,1),new an(0,1,1,1),new an(3,1,1,1),new an(1,1,1,1),new an(3,0,1,1),new an(1,0,1,1)],this._cubeDirections=[new W(1,0,0),new W(-1,0,0),new W(0,0,1),new W(0,0,-1),new W(0,1,0),new W(0,-1,0)],this._cubeUps=[new W(0,1,0),new W(0,1,0),new W(0,1,0),new W(0,1,0),new W(0,0,1),new W(0,0,-1)]}updateMatrices(e,t=0){const n=this.camera,r=this.matrix,o=e.distance||n.far;o!==n.far&&(n.far=o,n.updateProjectionMatrix()),Kh.setFromMatrixPosition(e.matrixWorld),n.position.copy(Kh),um.copy(n.position),um.add(this._cubeDirections[t]),n.up.copy(this._cubeUps[t]),n.lookAt(um),n.updateMatrixWorld(),r.makeTranslation(-Kh.x,-Kh.y,-Kh.z),cm.multiplyMatrices(n.projectionMatrix,n.matrixWorldInverse),this._frustum.setFromProjectionMatrix(cm,n.coordinateSystem,n.reversedDepth)}}class X0 extends Yh{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 eA}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}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}}class Jh extends Fp{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 j0 extends q0{constructor(){super(new Jh(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class _u extends Yh{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Hi.DEFAULT_UP),this.updateMatrix(),this.target=new Hi,this.shadow=new j0}dispose(){this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}}class Mf extends Yh{constructor(e,t){super(e,t),this.isAmbientLight=!0,this.type="AmbientLight"}}class Y0 extends Yh{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 gS{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let e=0;e<9;e++)this.coefficients.push(new W)}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 fy extends Yh{constructor(e=new gS,t=1){super(void 0,t),this.isLightProbe=!0,this.sh=e}copy(e){return super.copy(e),this.sh.copy(e.sh),this}fromJSON(e){return this.intensity=e.intensity,this.sh.fromArray(e.sh),this}toJSON(e){const t=super.toJSON(e);return t.object.sh=this.sh.toArray(),t}}class py extends null{constructor(e){super(e),this.textures={}}load(e,t,n,r){const o=this,a=new yr(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):console.error(u),o.manager.itemError(e)}},n,r)}parse(e){const t=this.textures;function n(o){return t[o]===void 0&&console.warn("THREE.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 At().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.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 At().setHex(a.value);break;case"v2":r.uniforms[o].value=new Ie().fromArray(a.value);break;case"v3":r.uniforms[o].value=new W().fromArray(a.value);break;case"v4":r.uniforms[o].value=new an().fromArray(a.value);break;case"m3":r.uniforms[o].value=new Cn().fromArray(a.value);break;case"m4":r.uniforms[o].value=new Vt().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 Ie().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 Ie().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 py.createMaterialFromType(e)}static createMaterialFromType(e){const t={ShadowMaterial:nm,SpriteMaterial:$d,RawShaderMaterial:sy,ShaderMaterial:Jo,PointsMaterial:Dh,MeshPhysicalMaterial:k0,MeshStandardMaterial:vf,MeshPhongMaterial:ry,MeshToonMaterial:oy,MeshNormalMaterial:z0,MeshLambertMaterial:ay,MeshDepthMaterial:V0,MeshDistanceMaterial:G0,MeshBasicMaterial:js,MeshMatcapMaterial:ly,LineDashedMaterial:cy,LineBasicMaterial:Js,Material:$i};return new t[e]}}class Z0{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 yS 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 _S extends null{constructor(e){super(e)}load(e,t,n,r){const o=this,a=new yr(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):console.error(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 T=x.interleavedBuffers[v],S=o(x,T.buffer),N=yh(T.type,S),R=new fl(N,T.stride);return R.uuid=T.uuid,t[v]=R,R}function o(x,v){if(n[v]!==void 0)return n[v];const T=x.arrayBuffers[v],S=new Uint32Array(T).buffer;return n[v]=S,S}const a=e.isInstancedBufferGeometry?new yS:new gn,c=e.data.index;if(c!==void 0){const x=yh(c.type,c.array);a.setIndex(new $n(x,1))}const u=e.data.attributes;for(const x in u){const v=u[x];let M;if(v.isInterleavedBufferAttribute){const T=r(e.data,v.data);M=new Rh(T,v.itemSize,v.offset,v.normalized)}else{const T=yh(v.type,v.array),S=v.isInstancedBufferAttribute?ea:$n;M=new S(T,v.itemSize,v.normalized)}v.name!==void 0&&(M.name=v.name),v.usage!==void 0&&M.setUsage(v.usage),a.setAttribute(x,M)}const d=e.data.morphAttributes;if(d)for(const x in d){const v=d[x],M=[];for(let T=0,S=v.length;T<S;T++){const N=v[T];let R;if(N.isInterleavedBufferAttribute){const P=r(e.data,N.data);R=new Rh(P,N.itemSize,N.offset,N.normalized)}else{const P=yh(N.type,N.array);R=new $n(P,N.itemSize,N.normalized)}N.name!==void 0&&(R.name=N.name),M.push(R)}a.morphAttributes[x]=M}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 M=m[x];a.addGroup(M.start,M.count,M.materialIndex)}const y=e.data.boundingSphere;return y!==void 0&&(a.boundingSphere=new Ms().fromJSON(y)),e.name&&(a.name=e.name),e.userData&&(a.userData=e.userData),a}}class tA extends null{constructor(e){super(e)}load(e,t,n,r){const o=this,a=this.path===""?Z0.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||a;const c=new yr(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),console.error("THREE: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)),console.error("THREE.ObjectLoader: Can't load "+e);return}o.parse(d,t)},n,r)}loadAsync(e,t){return en(this,null,function*(){const n=this,r=this.path===""?Z0.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||r;const o=new yr(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 en(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 hu().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 jd().fromJSON(e[o],r);n[c.uuid]=c}return n}parseGeometries(e,t){const n={};if(e!==void 0){const r=new _S;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 tm?c=tm[u.type].fromJSON(u,t):console.warn(`THREE.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 py;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=wf.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:yh(u.type,u.data),width:u.width,height:u.height}:null}if(e!==void 0&&e.length>0){const u=new mu(t);o=new Po(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,M=y.length;v<M;v++){const T=y[v],S=c(T);S!==null&&(S instanceof HTMLImageElement?x.push(S):x.push(new oo(S.data,S.width,S.height)))}r[m.uuid]=new Bs(x)}else{const x=c(m.url);r[m.uuid]=new Bs(x)}}}return r}parseImagesAsync(e){return en(this,null,function*(){const t=this,n={};let r;function o(a){return en(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:yh(a.type,a.data),width:a.width,height:a.height}:null})}if(e!==void 0&&e.length>0){r=new Po(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 oo(v.data,v.width,v.height)))}n[u.uuid]=new Bs(p)}else{const p=yield o(u.url);n[u.uuid]=new Bs(p)}}}return n})}parseTextures(e,t){function n(o,a){return typeof o=="number"?o:(console.warn("THREE.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&&console.warn('THREE.ObjectLoader: No "image" specified for',c.uuid),t[c.image]===void 0&&console.warn("THREE.ObjectLoader: Undefined image",c.image);const u=t[c.image],d=u.data;let p;Array.isArray(d)?(p=new jl,d.length===6&&(p.needsUpdate=!0)):(d&&d.data?p=new oo:p=new ds,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,xS)),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],hm),p.wrapT=n(c.wrap[1],hm)),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,my)),c.magFilter!==void 0&&(p.magFilter=n(c.magFilter,my)),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&&console.warn("THREE.ObjectLoader: Undefined geometry",y),t[y]}function u(y){if(y!==void 0){if(Array.isArray(y)){const x=[];for(let v=0,M=y.length;v<M;v++){const T=y[v];n[T]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",T),x.push(n[T])}return x}return n[y]===void 0&&console.warn("THREE.ObjectLoader: Undefined material",y),n[y]}}function d(y){return r[y]===void 0&&console.warn("THREE.ObjectLoader: Undefined texture",y),r[y]}let p,m;switch(e.type){case"Scene":a=new Bp,e.background!==void 0&&(Number.isInteger(e.background)?a.background=new At(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 Wd(e.fog.color,e.fog.near,e.fog.far):e.fog.type==="FogExp2"&&(a.fog=new Cg(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 ps(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 Jh(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 Mf(e.color,e.intensity);break;case"DirectionalLight":a=new _u(e.color,e.intensity),a.target=e.target||"";break;case"PointLight":a=new X0(e.color,e.intensity,e.distance,e.decay);break;case"RectAreaLight":a=new Y0(e.color,e.intensity,e.width,e.height);break;case"SpotLight":a=new lm(e.color,e.intensity,e.distance,e.angle,e.penumbra,e.decay),a.target=e.target||"";break;case"HemisphereLight":a=new yu(e.color,e.groundColor,e.intensity);break;case"LightProbe":a=new fy().fromJSON(e);break;case"SkinnedMesh":p=c(e.geometry),m=u(e.material),a=new Fb(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 vi(p,m);break;case"InstancedMesh":p=c(e.geometry),m=u(e.material);const y=e.count,x=e.instanceMatrix,v=e.instanceColor;a=new b0(p,m,y),a.instanceMatrix=new ea(new Float32Array(x.array),16),v!==void 0&&(a.instanceColor=new ea(new Float32Array(v.array),v.itemSize));break;case"BatchedMesh":p=c(e.geometry),m=u(e.material),a=new kb(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 T=null,S=null;return M.boundingBox!==void 0&&(T=new dr().fromJSON(M.boundingBox)),M.boundingSphere!==void 0&&(S=new Ms().fromJSON(M.boundingSphere)),_a(Ii({},M),{boundingBox:T,boundingSphere:S})}),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 Ms().fromJSON(e.boundingSphere)),e.boundingBox!==void 0&&(a.boundingBox=new dr().fromJSON(e.boundingBox));break;case"LOD":a=new Pg;break;case"Line":a=new Ql(c(e.geometry),u(e.material));break;case"LineLoop":a=new A0(c(e.geometry),u(e.material));break;case"LineSegments":a=new Xp(c(e.geometry),u(e.material));break;case"PointCloud":case"Points":a=new zb(c(e.geometry),u(e.material));break;case"Sprite":a=new Op(u(e.material));break;case"Group":a=new nr;break;case"Bone":a=new Bg;break;default:a=new Hi}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],M=a.getObjectByProperty("uuid",v.object);M!==void 0&&a.addLevel(M,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?console.warn("THREE.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 Hi}})}}const xS={UVMapping:$u,CubeReflectionMapping:Br,CubeRefractionMapping:Vo,EquirectangularReflectionMapping:Nc,EquirectangularRefractionMapping:Pc,CubeUVReflectionMapping:Ll},hm={RepeatWrapping:ba,ClampToEdgeWrapping:Ki,MirroredRepeatWrapping:Sa},my={NearestFilter:Jn,NearestMipmapNearestFilter:gp,NearestMipmapLinearFilter:Ta,LinearFilter:Yn,LinearMipmapNearestFilter:Ic,LinearMipmapLinearFilter:Ds},gy=new WeakMap;class nA extends null{constructor(e){super(e),this.isImageBitmapLoader=!0,typeof createImageBitmap=="undefined"&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch=="undefined"&&console.warn("THREE.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=No.get(`image-bitmap:${e}`);if(a!==void 0){if(o.manager.itemStart(e),a.then){a.then(d=>{if(gy.has(a)===!0)r&&r(gy.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 No.add(`image-bitmap:${e}`,d),t&&t(d),o.manager.itemEnd(e),d}).catch(function(d){r&&r(d),gy.set(u,d),No.remove(`image-bitmap:${e}`),o.manager.itemError(e),o.manager.itemEnd(e)});No.add(`image-bitmap:${e}`,u),o.manager.itemStart(e)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let yy;class K0{static getContext(){return yy===void 0&&(yy=new(window.AudioContext||window.webkitAudioContext)),yy}static setContext(e){yy=e}}class vS extends null{constructor(e){super(e)}load(e,t,n,r){const o=this,a=new yr(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);K0.getContext().decodeAudioData(d,function(m){t(m)}).catch(c)}catch(d){c(d)}},n,r);function c(u){r?r(u):console.error(u),o.manager.itemError(e)}}}const _y=new Vt,dm=new Vt,Qh=new Vt;class xy{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new ps,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new ps,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,Qh.copy(e.projectionMatrix);const r=t.eyeSep/2,o=r*t.near/t.focus,a=t.near*Math.tan(Ma*t.fov*.5)/t.zoom;let c,u;dm.elements[12]=-r,_y.elements[12]=r,c=-a*t.aspect+o,u=a*t.aspect+o,Qh.elements[0]=2*t.near/(u-c),Qh.elements[8]=(u+c)/(u-c),this.cameraL.projectionMatrix.copy(Qh),c=-a*t.aspect-o,u=a*t.aspect-o,Qh.elements[0]=2*t.near/(u-c),Qh.elements[8]=(u+c)/(u-c),this.cameraR.projectionMatrix.copy(Qh)}this.cameraL.matrixWorld.copy(e.matrixWorld).multiply(dm),this.cameraR.matrixWorld.copy(e.matrixWorld).multiply(_y)}}class vy extends ps{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class J0{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 sc=new W,fm=new Fs,xu=new W,ed=new W,td=new W;class iA extends null{constructor(){super(),this.type="AudioListener",this.context=K0.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new J0}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(sc,fm,xu),ed.set(0,0,-1).applyQuaternion(fm),td.set(0,1,0).applyQuaternion(fm),t.positionX){const n=this.context.currentTime+this.timeDelta;t.positionX.linearRampToValueAtTime(sc.x,n),t.positionY.linearRampToValueAtTime(sc.y,n),t.positionZ.linearRampToValueAtTime(sc.z,n),t.forwardX.linearRampToValueAtTime(ed.x,n),t.forwardY.linearRampToValueAtTime(ed.y,n),t.forwardZ.linearRampToValueAtTime(ed.z,n),t.upX.linearRampToValueAtTime(td.x,n),t.upY.linearRampToValueAtTime(td.y,n),t.upZ.linearRampToValueAtTime(td.z,n)}else t.setPosition(sc.x,sc.y,sc.z),t.setOrientation(ed.x,ed.y,ed.z,td.x,td.y,td.z)}}class nd 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){console.warn("THREE.Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){console.warn("THREE.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){console.warn("THREE.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){console.warn("THREE.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){console.warn("THREE.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?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop}setLoop(e){if(this.hasPlaybackControl===!1){console.warn("THREE.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"?(console.warn("THREE.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 xl=new W,Q0=new Fs,vu=new W,ao=new W;class PD 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(xl,Q0,vu),ao.set(0,0,1).applyQuaternion(Q0);const t=this.panner;if(t.positionX){const n=this.context.currentTime+this.listener.timeDelta;t.positionX.linearRampToValueAtTime(xl.x,n),t.positionY.linearRampToValueAtTime(xl.y,n),t.positionZ.linearRampToValueAtTime(xl.z,n),t.orientationX.linearRampToValueAtTime(ao.x,n),t.orientationY.linearRampToValueAtTime(ao.y,n),t.orientationZ.linearRampToValueAtTime(ao.z,n)}else t.setPosition(xl.x,xl.y,xl.z),t.setOrientation(ao.x,ao.y,ao.z)}}class ID{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 bu{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){Fs.slerpFlat(e,t,e,t,e,n,r)}_slerpAdditive(e,t,n,r,o){const a=this._workIndex*o;Fs.multiplyQuaternionsFlat(e,a,e,t,e,n),Fs.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 pm="\\[\\]\\.:\\/",bS=new RegExp("["+pm+"]","g"),vl="[^"+pm+"]",sA="[^"+pm.replace("\\.","")+"]",rA=/((?:WC+[\/:])*)/.source.replace("WC",vl),SS=/(WCOD+)?/.source.replace("WCOD",sA),by=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",vl),TS=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",vl),Sy=new RegExp("^"+rA+SS+by+TS+"$"),wS=["material","materials","bones","map"];class MS{constructor(e,t,n){const r=n||ui.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 ui{constructor(e,t,n){this.path=t,this.parsedPath=n||ui.parseTrackName(t),this.node=ui.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 ui.Composite(e,t,n):new ui(e,t,n)}static sanitizeNodeName(e){return e.replace(/\s/g,"_").replace(bS,"")}static parseTrackName(e){const t=Sy.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=ui.findNode(this.rootNode,t.nodeName),this.node=e),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!e){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let d=t.objectIndex;switch(n){case"materials":if(!e.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.materials){console.error("THREE.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){console.error("THREE.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){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!e.material.map){console.error("THREE.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){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}e=e[n]}if(d!==void 0){if(e[d]===void 0){console.error("THREE.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;console.error("THREE.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){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!e.geometry.morphAttributes){console.error("THREE.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}}ui.Composite=MS,ui.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},ui.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},ui.prototype.GetterByBindingType=[ui.prototype._getValue_direct,ui.prototype._getValue_array,ui.prototype._getValue_arrayElement,ui.prototype._getValue_toArray],ui.prototype.SetterByBindingTypeAndVersioning=[[ui.prototype._setValue_direct,ui.prototype._setValue_direct_setNeedsUpdate,ui.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ui.prototype._setValue_array,ui.prototype._setValue_array_setNeedsUpdate,ui.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ui.prototype._setValue_arrayElement,ui.prototype._setValue_arrayElement_setNeedsUpdate,ui.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ui.prototype._setValue_fromArray,ui.prototype._setValue_fromArray_setNeedsUpdate,ui.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class oA{constructor(){this.isAnimationObjectGroup=!0,this.uuid=kr(),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 M=0,T=a;M!==T;++M)o[M].push(new ui(y,n[M],r[M]))}else if(v<d){c=e[v];const M=--d,T=e[M];t[T.uuid]=v,e[v]=T,t[x]=M,e[M]=y;for(let S=0,N=a;S!==N;++S){const R=o[S],P=R[M];let B=R[v];R[v]=P,B===void 0&&(B=new ui(y,n[S],r[S])),R[M]=B}}else e[v]!==c&&console.error("THREE.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 M=n[x],T=M[m],S=M[p];M[p]=T,M[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,M=e[v];t[x.uuid]=m,e[m]=x,t[M.uuid]=y,e[y]=M,e.pop();for(let T=0,S=r;T!==S;++T){const N=n[T],R=N[y],P=N[v];N[m]=R,N[y]=P,N.pop()}}else{const y=--a,x=e[y];y>0&&(t[x.uuid]=m),e[m]=x,e.pop();for(let v=0,M=r;v!==M;++v){const T=n[v];T[m]=T[y],T.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 ui(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 AS{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:Ho,endingEnd:Ho};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=Sb,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 dg:for(let p=0,m=u.length;p!==m;++p)u[p].evaluate(a),d[p].accumulateAdditive(c);break;case Cd: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===Tb;if(e===0)return o===-1?r:a&&(o&1)===1?t-r:r;if(n===bb){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=Wo,r.endingEnd=Wo):(e?r.endingStart=this.zeroSlopeAtStart?Wo:Ho:r.endingStart=Oc,t?r.endingEnd=this.zeroSlopeAtEnd?Wo:Ho:r.endingEnd=Oc)}_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 ES=new Float32Array(1);class aA 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 M=t&&t._propertyBindings[m].binding.parsedPath;v=new bu(ui.create(n,x,M),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 im(new Float32Array(2),new Float32Array(2),1,ES),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"?wf.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=Cd),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 AS(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"?wf.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 lA extends null{constructor(e=1,t=1,n=1,r={}){super(e,t,r),this.isRenderTarget3D=!0,this.depth=n,this.texture=new no(null,e,t,n),this._setTextureOptions(r),this.texture.isRenderTargetTexture=!0}}class li{constructor(e){this.value=e}clone(){return new li(this.value.clone===void 0?this.value:this.value.clone())}}let cA=0;class uA extends null{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:cA++}),this.name="",this.usage=kl,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 CS extends fl{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 LD{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 RS=new Vt;class Ty{constructor(e,t,n=0,r=1/0){this.ray=new Hl(e,t),this.near=n,this.far=r,this.camera=null,this.layers=new Na,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):console.error("THREE.Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return RS.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(RS),this}intersectObject(e,t=!0,n=[]){return tx(e,this,n,t),n.sort(ex),n}intersectObjects(e,t=!0,n=[]){for(let r=0,o=e.length;r<o;r++)tx(e[r],this,n,t);return n.sort(ex),n}}function ex(i,e){return i.distance-e.distance}function tx(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++)tx(o[a],e,t,!0)}}class DD{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=hA.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 hA(){this._document.hidden===!1&&this.reset()}class wy{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=fn(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(fn(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class FD{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 Af{constructor(e,t,n,r){Af.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 mm=new Ie;class BD{constructor(e=new Ie(1/0,1/0),t=new Ie(-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=mm.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,mm).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 nx=new W,My=new W,Ef=new W,Su=new W,gm=new W,dA=new W,ix=new W;class Ay{constructor(e=new W,t=new W){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){nx.subVectors(e,this.start),My.subVectors(this.end,this.start);const n=My.dot(My);let o=My.dot(nx)/n;return t&&(o=fn(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=dA,n=ix){const r=10000000000000001e-32;let o,a;const c=this.start,u=e.start,d=this.end,p=e.end;Ef.subVectors(d,c),Su.subVectors(p,u),gm.subVectors(c,u);const m=Ef.dot(Ef),y=Su.dot(Su),x=Su.dot(gm);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=fn(a,0,1);else{const v=Ef.dot(gm);if(y<=r)a=0,o=fn(-v/m,0,1);else{const M=Ef.dot(Su),T=m*y-M*M;T!==0?o=fn((M*x-v*y)/T,0,1):o=0,a=(M*o+x)/y,a<0?(a=0,o=fn(-v/m,0,1)):a>1&&(a=1,o=fn((M-v)/m,0,1))}}return t.copy(c).add(Ef.multiplyScalar(o)),n.copy(u).add(Su.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 Tu=new W;class Cf 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 $t(r,3));const o=new Js({fog:!1,toneMapped:!1});this.cone=new Xp(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),Tu.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Tu),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const Ha=new W,ym=new Vt,Ey=new Vt;class OD extends null{constructor(e){const t=Cy(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 $t(r,3)),n.setAttribute("color",new $t(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 At(255),u=new At(65280);this.setColors(c,u)}updateMatrixWorld(e){const t=this.bones,n=this.geometry,r=n.getAttribute("position");Ey.copy(this.root.matrixWorld).invert();for(let o=0,a=0;o<t.length;o++){const c=t[o];c.parent&&c.parent.isBone&&(ym.multiplyMatrices(Ey,c.matrixWorld),Ha.setFromMatrixPosition(ym),r.setXYZ(a,Ha.x,Ha.y,Ha.z),ym.multiplyMatrices(Ey,c.parent.matrixWorld),Ha.setFromMatrixPosition(ym),r.setXYZ(a+1,Ha.x,Ha.y,Ha.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 Cy(i){const e=[];i.isBone===!0&&e.push(i);for(let t=0;t<i.children.length;t++)e.push(...Cy(i.children[t]));return e}class UD extends null{constructor(e,t,n){const r=new gl(t,4,2),o=new js({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 rc=new W,Rf=new At,_m=new At;class kD 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 yf(t);r.rotateY(Math.PI*.5),this.material=new js({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 $n(a,3)),this.add(new vi(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");Rf.copy(this.light.color),_m.copy(this.light.groundColor);for(let n=0,r=t.count;n<r;n++){const o=n<r/2?Rf:_m;t.setXYZ(n,o.r,o.g,o.b)}t.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),e.lookAt(rc.setFromMatrixPosition(this.light.matrixWorld).negate())}}class NS extends null{constructor(e=10,t=10,n=4473924,r=8947848){n=new At(n),r=new At(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 M=y===o?n:r;M.toArray(d,x),x+=3,M.toArray(d,x),x+=3,M.toArray(d,x),x+=3,M.toArray(d,x),x+=3}const p=new gn;p.setAttribute("position",new $t(u,3)),p.setAttribute("color",new $t(d,3));const m=new Js({vertexColors:!0,toneMapped:!1});super(p,m),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class zD extends null{constructor(e=10,t=16,n=8,r=64,o=4473924,a=8947848){o=new At(o),a=new At(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 M=m&1?o:a;u.push(M.r,M.g,M.b),u.push(M.r,M.g,M.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 M=v/r*(Math.PI*2),T=Math.sin(M)*x,S=Math.cos(M)*x;c.push(T,0,S),u.push(y.r,y.g,y.b),M=(v+1)/r*(Math.PI*2),T=Math.sin(M)*x,S=Math.cos(M)*x,c.push(T,0,S),u.push(y.r,y.g,y.b)}}const d=new gn;d.setAttribute("position",new $t(c,3)),d.setAttribute("color",new $t(u,3));const p=new Js({vertexColors:!0,toneMapped:!1});super(d,p),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const sx=new W,Nf=new W,Ry=new W;class VD 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 $t([-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 Ql(r,o),this.add(this.lightPlane),r=new gn,r.setAttribute("position",new $t([0,0,0,0,0,1],3)),this.targetLine=new Ql(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),sx.setFromMatrixPosition(this.light.matrixWorld),Nf.setFromMatrixPosition(this.light.target.matrixWorld),Ry.subVectors(Nf,sx),this.lightPlane.lookAt(Nf),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(Nf),this.targetLine.scale.z=Ry.length()}}const Ny=new W,ms=new Fp;class PS 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,M){u(v),u(M)}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 $t(r,3)),t.setAttribute("color",new $t(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 At(16755200),p=new At(16711680),m=new At(43775),y=new At(16777215),x=new At(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(ms.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),this.camera.reversedDepth===!0)o=1,a=0;else if(this.camera.coordinateSystem===ki)o=-1,a=1;else if(this.camera.coordinateSystem===Sr)o=0,a=1;else throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);qi("c",t,e,ms,0,0,o),qi("t",t,e,ms,0,0,a),qi("n1",t,e,ms,-n,-r,o),qi("n2",t,e,ms,n,-r,o),qi("n3",t,e,ms,-n,r,o),qi("n4",t,e,ms,n,r,o),qi("f1",t,e,ms,-n,-r,a),qi("f2",t,e,ms,n,-r,a),qi("f3",t,e,ms,-n,r,a),qi("f4",t,e,ms,n,r,a),qi("u1",t,e,ms,n*.7,r*1.1,o),qi("u2",t,e,ms,-n*.7,r*1.1,o),qi("u3",t,e,ms,0,r*2,o),qi("cf1",t,e,ms,-n,0,a),qi("cf2",t,e,ms,n,0,a),qi("cf3",t,e,ms,0,-r,a),qi("cf4",t,e,ms,0,r,a),qi("cn1",t,e,ms,-n,0,o),qi("cn2",t,e,ms,n,0,o),qi("cn3",t,e,ms,0,-r,o),qi("cn4",t,e,ms,0,r,o),e.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function qi(i,e,t,n,r,o,a){Ny.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],Ny.x,Ny.y,Ny.z)}}const Pf=new dr;class GD 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 $n(n,1)),o.setAttribute("position",new $n(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&&Pf.setFromObject(this.object),Pf.isEmpty())return;const e=Pf.min,t=Pf.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 Py 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 $n(n,1)),o.setAttribute("position",new $t(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 gs 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 $t(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 $t(c,3)),u.computeBoundingSphere(),this.add(new vi(u,new js({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 IS=new W;let Xi,id;class HD extends null{constructor(e=new W(0,0,1),t=new W(0,0,0),n=1,r=16776960,o=n*.2,a=o*.2){super(),this.type="ArrowHelper",Xi===void 0&&(Xi=new gn,Xi.setAttribute("position",new $t([0,0,0,0,1,0],3)),id=new of(.5,1,5,1),id.translate(0,-.5,0)),this.position.copy(t),this.line=new Ql(Xi,new Js({color:r,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new vi(id,new js({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{IS.set(e.z,0,-e.x).normalize();const t=Math.acos(e.y);this.quaternion.setFromAxisAngle(IS,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 WD 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 $t(t,3)),r.setAttribute("color",new $t(n,3));const o=new Js({vertexColors:!0,toneMapped:!1});super(r,o),this.type="AxesHelper"}setColors(e,t,n){const r=new At,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 $D{constructor(){this.type="ShapePath",this.color=new At,this.subPaths=[],this.currentPath=null}moveTo(e,t){return this.currentPath=new jg,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 N=[];for(let R=0,P=S.length;R<P;R++){const B=S[R],F=new hu;F.curves=B.curves,N.push(F)}return N}function n(S,N){const R=N.length;let P=!1;for(let B=R-1,F=0;F<R;B=F++){let k=N[B],V=N[F],U=V.x-k.x,z=V.y-k.y;if(Math.abs(z)>Number.EPSILON){if(z<0&&(k=N[F],U=-U,V=N[B],z=-z),S.y<k.y||S.y>V.y)continue;if(S.y===k.y){if(S.x===k.x)return!0}else{const j=z*(S.x-k.x)-U*(S.y-k.y);if(j===0)return!0;if(j<0)continue;P=!P}}else{if(S.y!==k.y)continue;if(V.x<=S.x&&S.x<=k.x||k.x<=S.x&&S.x<=V.x)return!0}}return P}const r=ia.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 hu,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,M;y[v]=void 0,x[v]=[];for(let S=0,N=o.length;S<N;S++)c=o[S],M=c.getPoints(),a=r(M),a=e?!a:a,a?(!p&&y[v]&&v++,y[v]={s:new hu,p:M},y[v].s.curves=c.curves,p&&v++,x[v]=[]):x[v].push({h:c,p:M[0]});if(!y[0])return t(o);if(y.length>1){let S=!1,N=0;for(let R=0,P=y.length;R<P;R++)m[R]=[];for(let R=0,P=y.length;R<P;R++){const B=x[R];for(let F=0;F<B.length;F++){const k=B[F];let V=!0;for(let U=0;U<y.length;U++)n(k.p,y[U].p)&&(R!==U&&N++,V?(V=!1,m[U].push(k)):S=!0);V&&m[R].push(k)}}N>0&&S===!1&&(x=m)}let T;for(let S=0,N=y.length;S<N;S++){u=y[S].s,d.push(u),T=x[S];for(let R=0,P=T.length;R<P;R++)u.holes.push(T[R].h)}return d}}class If extends wa{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){console.warn("THREE.Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function xm(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 Iy(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 fA(i){return i.repeat.x=1,i.repeat.y=1,i.offset.x=0,i.offset.y=0,i}function Ly(i,e,t,n){const r=pA(n);switch(t){case cg:return i*e;case Fc:return i*e/r.components*r.byteLength;case Dl:return i*e/r.components*r.byteLength;case rl:return i*e*2/r.components*r.byteLength;case qu:return i*e*2/r.components*r.byteLength;case bd:return i*e*3/r.components*r.byteLength;case _i:return i*e*4/r.components*r.byteLength;case Xu:return i*e*4/r.components*r.byteLength;case Fl:case Bl:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Ol:case Ul:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Td:case Md:return Math.max(i,16)*Math.max(e,8)/4;case Sd:case wd:return Math.max(i,8)*Math.max(e,8)/2;case ju:case Yu:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Zu:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Ku:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Ju:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case Qu:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case eh:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case th:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case nh:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case ih:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case sh:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case rh:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case oh:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case ah:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case lh:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case ch:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case uh:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case hh:case ug:case hg:return Math.ceil(i/4)*Math.ceil(e/4)*16;case dh:case fh:return Math.ceil(i/4)*Math.ceil(e/4)*8;case ph:case mh:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function pA(i){switch(i){case Ui:case Lc:return{byteLength:1,components:1};case Go:case Dc:case Ts:return{byteLength:2,components:1};case yp:case _p:return{byteLength:2,components:4};case pi:case Ws:case mi:return{byteLength:4,components:1};case xp:case vp:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${i}.`)}class qD{static contain(e,t){return xm(e,t)}static cover(e,t){return Iy(e,t)}static fill(e){return fA(e)}static getByteLength(e,t,n,r){return Ly(e,t,n,r)}}typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:_e}})),typeof window!="undefined"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=_e);const sd=new Rr,bl=new Ie,rx=new W,Dy=new Ie,vm=new Ie,Fy=new W,E=new W,s=new Vt,l=new W,h=new W;let f=null,g=null;const _=[],b={NONE:-1,PAN:0,ROTATE:1};class w extends If{constructor(e,t,n=null){super(t,n),this.objects=e,this.recursive=!0,this.transformGroup=!1,this.rotateSpeed=1,this.raycaster=new Ty,this.mouseButtons={LEFT:ye.PAN,MIDDLE:ye.PAN,RIGHT:ye.ROTATE},this.touches={ONE:fe.PAN},this._onPointerMove=A.bind(this),this._onPointerDown=C.bind(this),this._onPointerCancel=I.bind(this),this._onContextMenu=L.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();bl.x=(e.clientX-t.left)/t.width*2-1,bl.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 ye.PAN:case fe.PAN:this.state=b.PAN;break;case ye.ROTATE:case fe.ROTATE:this.state=b.ROTATE;break;default:this.state=b.NONE}}}function A(i){const e=this.object,t=this.domElement,n=this.raycaster;if(this.enabled!==!1){if(this._updatePointer(i),n.setFromCamera(bl,e),f)this.state===b.PAN?n.ray.intersectPlane(sd,Fy)&&(f.position.copy(Fy.sub(rx).applyMatrix4(s)),this.dispatchEvent({type:"drag",object:f})):this.state===b.ROTATE&&(Dy.subVectors(bl,vm).multiplyScalar(this.rotateSpeed),f.rotateOnWorldAxis(l,Dy.x),f.rotateOnWorldAxis(h.normalize(),-Dy.y),this.dispatchEvent({type:"drag",object:f})),vm.copy(bl);else if(i.pointerType==="mouse"||i.pointerType==="pen")if(_.length=0,n.setFromCamera(bl,e),n.intersectObjects(this.objects,this.recursive,_),_.length>0){const r=_[0].object;sd.setFromNormalAndCoplanarPoint(e.getWorldDirection(sd.normal),E.setFromMatrixPosition(r.matrixWorld)),g!==r&&g!==null&&(this.dispatchEvent({type:"hoveroff",object:g}),t.style.cursor="auto",g=null),g!==r&&(this.dispatchEvent({type:"hoveron",object:r}),t.style.cursor="pointer",g=r)}else g!==null&&(this.dispatchEvent({type:"hoveroff",object:g}),t.style.cursor="auto",g=null);vm.copy(bl)}}function C(i){const e=this.object,t=this.domElement,n=this.raycaster;this.enabled!==!1&&(this._updatePointer(i),this._updateState(i),_.length=0,n.setFromCamera(bl,e),n.intersectObjects(this.objects,this.recursive,_),_.length>0&&(this.transformGroup===!0?f=D(_[0].object):f=_[0].object,sd.setFromNormalAndCoplanarPoint(e.getWorldDirection(sd.normal),E.setFromMatrixPosition(f.matrixWorld)),n.ray.intersectPlane(sd,Fy)&&(this.state===b.PAN?(s.copy(f.parent.matrixWorld).invert(),rx.copy(Fy).sub(E.setFromMatrixPosition(f.matrixWorld)),t.style.cursor="move",this.dispatchEvent({type:"dragstart",object:f})):this.state===b.ROTATE&&(l.set(0,1,0).applyQuaternion(e.quaternion).normalize(),h.set(1,0,0).applyQuaternion(e.quaternion).normalize(),t.style.cursor="move",this.dispatchEvent({type:"dragstart",object:f})))),vm.copy(bl))}function I(){this.enabled!==!1&&(f&&(this.dispatchEvent({type:"dragend",object:f}),f=null),this.domElement.style.cursor=g?"pointer":"auto",this.state=b.NONE)}function L(i){this.enabled!==!1&&i.preventDefault()}function D(i,e=null){return i.isGroup&&(e=i),i.parent===null?e:D(i.parent,e)}var O={value:()=>{}};function G(){for(var i=0,e=arguments.length,t={},n;i<e;++i){if(!(n=arguments[i]+"")||n in t||/[\s.]/.test(n))throw new Error("illegal type: "+n);t[n]=[]}return new Z(t)}function Z(i){this._=i}function Y(i,e){return i.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");if(r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}Z.prototype=G.prototype={constructor:Z,on:function(i,e){var t=this._,n=Y(i+"",t),r,o=-1,a=n.length;if(arguments.length<2){for(;++o<a;)if((r=(i=n[o]).type)&&(r=Q(t[r],i.name)))return r;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++o<a;)if(r=(i=n[o]).type)t[r]=ee(t[r],i.name,e);else if(e==null)for(r in t)t[r]=ee(t[r],i.name,null);return this},copy:function(){var i={},e=this._;for(var t in e)i[t]=e[t].slice();return new Z(i)},call:function(i,e){if((r=arguments.length-2)>0)for(var t=new Array(r),n=0,r,o;n<r;++n)t[n]=arguments[n+2];if(!this._.hasOwnProperty(i))throw new Error("unknown type: "+i);for(o=this._[i],n=0,r=o.length;n<r;++n)o[n].value.apply(e,t)},apply:function(i,e,t){if(!this._.hasOwnProperty(i))throw new Error("unknown type: "+i);for(var n=this._[i],r=0,o=n.length;r<o;++r)n[r].value.apply(e,t)}};function Q(i,e){for(var t=0,n=i.length,r;t<n;++t)if((r=i[t]).name===e)return r.value}function ee(i,e,t){for(var n=0,r=i.length;n<r;++n)if(i[n].name===e){i[n]=O,i=i.slice(0,n).concat(i.slice(n+1));break}return t!=null&&i.push({name:e,value:t}),i}var ae=G,Re=0,Oe=0,je=0,He=1e3,ct,dt,tn=0,Mn=0,qn=0,di=typeof performance=="object"&&performance.now?performance:Date,bi=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(i){setTimeout(i,17)};function Es(){return Mn||(bi(ir),Mn=di.now()+qn)}function ir(){Mn=0}function lo(){this._call=this._time=this._next=null}lo.prototype=es.prototype={constructor:lo,restart:function(i,e,t){if(typeof i!="function")throw new TypeError("callback is not a function");t=(t==null?Es():+t)+(e==null?0:+e),!this._next&&dt!==this&&(dt?dt._next=this:ct=this,dt=this),this._call=i,this._time=t,oc()},stop:function(){this._call&&(this._call=null,this._time=1/0,oc())}};function es(i,e,t){var n=new lo;return n.restart(i,e,t),n}function Cs(){Es(),++Re;for(var i=ct,e;i;)(e=Mn-i._time)>=0&&i._call.call(void 0,e),i=i._next;--Re}function ts(){Mn=(tn=di.now())+qn,Re=Oe=0;try{Cs()}finally{Re=0,Io(),Mn=0}}function ra(){var i=di.now(),e=i-tn;e>He&&(qn-=e,tn=i)}function Io(){for(var i,e=ct,t,n=1/0;e;)e._call?(n>e._time&&(n=e._time),i=e,e=e._next):(t=e._next,e._next=null,e=i?i._next=t:ct=t);dt=i,oc(n)}function oc(i){if(!Re){Oe&&(Oe=clearTimeout(Oe));var e=i-Mn;e>24?(i<1/0&&(Oe=setTimeout(ts,i-di.now()-qn)),je&&(je=clearInterval(je))):(je||(tn=di.now(),je=setInterval(ra,He)),Re=1,bi(ts))}}const Lf=1664525,LS=1013904223,ox=4294967296;function ax(){let i=1;return()=>(i=(Lf*i+LS)%ox)/ox}var Wa=3;function rd(i){return i.x}function lx(i){return i.y}function Sl(i){return i.z}var Tl=10,Ft=Math.PI*(3-Math.sqrt(5)),qt=Math.PI*20/(9+Math.sqrt(221));function jt(i,e){e=e||2;var t=Math.min(Wa,Math.max(1,Math.round(e))),n,r=1,o=.001,a=1-Math.pow(o,1/300),c=0,u=.6,d=new Map,p=es(x),m=ae("tick","end"),y=ax();i==null&&(i=[]);function x(){v(),m.call("tick",n),r<o&&(p.stop(),m.call("end",n))}function v(S){var N,R=i.length,P;S===void 0&&(S=1);for(var B=0;B<S;++B)for(r+=(c-r)*a,d.forEach(function(F){F(r)}),N=0;N<R;++N)P=i[N],P.fx==null?P.x+=P.vx*=u:(P.x=P.fx,P.vx=0),t>1&&(P.fy==null?P.y+=P.vy*=u:(P.y=P.fy,P.vy=0)),t>2&&(P.fz==null?P.z+=P.vz*=u:(P.z=P.fz,P.vz=0));return n}function M(){for(var S=0,N=i.length,R;S<N;++S){if(R=i[S],R.index=S,R.fx!=null&&(R.x=R.fx),R.fy!=null&&(R.y=R.fy),R.fz!=null&&(R.z=R.fz),isNaN(R.x)||t>1&&isNaN(R.y)||t>2&&isNaN(R.z)){var P=Tl*(t>2?Math.cbrt(.5+S):t>1?Math.sqrt(.5+S):S),B=S*Ft,F=S*qt;t===1?R.x=P:t===2?(R.x=P*Math.cos(B),R.y=P*Math.sin(B)):(R.x=P*Math.sin(B)*Math.cos(F),R.y=P*Math.cos(B),R.z=P*Math.sin(B)*Math.sin(F))}(isNaN(R.vx)||t>1&&isNaN(R.vy)||t>2&&isNaN(R.vz))&&(R.vx=0,t>1&&(R.vy=0),t>2&&(R.vz=0))}}function T(S){return S.initialize&&S.initialize(i,y,t),S}return M(),n={tick:v,restart:function(){return p.restart(x),n},stop:function(){return p.stop(),n},numDimensions:function(S){return arguments.length?(t=Math.min(Wa,Math.max(1,Math.round(S))),d.forEach(T),n):t},nodes:function(S){return arguments.length?(i=S,M(),d.forEach(T),n):i},alpha:function(S){return arguments.length?(r=+S,n):r},alphaMin:function(S){return arguments.length?(o=+S,n):o},alphaDecay:function(S){return arguments.length?(a=+S,n):+a},alphaTarget:function(S){return arguments.length?(c=+S,n):c},velocityDecay:function(S){return arguments.length?(u=1-S,n):1-u},randomSource:function(S){return arguments.length?(y=S,d.forEach(T),n):y},force:function(S,N){return arguments.length>1?(N==null?d.delete(S):d.set(S,T(N)),n):d.get(S)},find:function(){var S=Array.prototype.slice.call(arguments),N=S.shift()||0,R=(t>1?S.shift():null)||0,P=(t>2?S.shift():null)||0,B=S.shift()||1/0,F=0,k=i.length,V,U,z,j,se,pe;for(B*=B,F=0;F<k;++F)se=i[F],V=N-se.x,U=R-(se.y||0),z=P-(se.z||0),j=V*V+U*U+z*z,j<B&&(pe=se,B=j);return pe},on:function(S,N){return arguments.length>1?(m.on(S,N),n):m.on(S)}}}function nn(i){return function(){return i}}function Kt(i){return(i()-.5)*1e-6}function hi(i){return i.index}function Xn(i,e){var t=i.get(e);if(!t)throw new Error("node not found: "+e);return t}function ji(i){var e=hi,t=y,n,r=nn(30),o,a,c,u,d,p,m=1;i==null&&(i=[]);function y(S){return 1/Math.min(u[S.source.index],u[S.target.index])}function x(S){for(var N=0,R=i.length;N<m;++N)for(var P=0,B,F,k,V=0,U=0,z=0,j,se;P<R;++P)B=i[P],F=B.source,k=B.target,V=k.x+k.vx-F.x-F.vx||Kt(p),c>1&&(U=k.y+k.vy-F.y-F.vy||Kt(p)),c>2&&(z=k.z+k.vz-F.z-F.vz||Kt(p)),j=Math.sqrt(V*V+U*U+z*z),j=(j-o[P])/j*S*n[P],V*=j,U*=j,z*=j,k.vx-=V*(se=d[P]),c>1&&(k.vy-=U*se),c>2&&(k.vz-=z*se),F.vx+=V*(se=1-se),c>1&&(F.vy+=U*se),c>2&&(F.vz+=z*se)}function v(){if(a){var S,N=a.length,R=i.length,P=new Map(a.map((F,k)=>[e(F,k,a),F])),B;for(S=0,u=new Array(N);S<R;++S)B=i[S],B.index=S,typeof B.source!="object"&&(B.source=Xn(P,B.source)),typeof B.target!="object"&&(B.target=Xn(P,B.target)),u[B.source.index]=(u[B.source.index]||0)+1,u[B.target.index]=(u[B.target.index]||0)+1;for(S=0,d=new Array(R);S<R;++S)B=i[S],d[S]=u[B.source.index]/(u[B.source.index]+u[B.target.index]);n=new Array(R),M(),o=new Array(R),T()}}function M(){if(a)for(var S=0,N=i.length;S<N;++S)n[S]=+t(i[S],S,i)}function T(){if(a)for(var S=0,N=i.length;S<N;++S)o[S]=+r(i[S],S,i)}return x.initialize=function(S,...N){a=S,p=N.find(R=>typeof R=="function")||Math.random,c=N.find(R=>[1,2,3].includes(R))||2,v()},x.links=function(S){return arguments.length?(i=S,v(),x):i},x.id=function(S){return arguments.length?(e=S,x):e},x.iterations=function(S){return arguments.length?(m=+S,x):m},x.strength=function(S){return arguments.length?(t=typeof S=="function"?S:nn(+S),M(),x):t},x.distance=function(S){return arguments.length?(r=typeof S=="function"?S:nn(+S),T(),x):r},x}var ns=he(20928),Vs=he(46632),co=he(67217);function wu(){var i,e,t,n,r,o=nn(-30),a,c=1,u=1/0,d=.81;function p(v){var M,T=i.length,S=(e===1?(0,ns.Z)(i,rd):e===2?(0,Vs.Z)(i,rd,lx):e===3?(0,co.Z)(i,rd,lx,Sl):null).visitAfter(y);for(r=v,M=0;M<T;++M)t=i[M],S.visit(x)}function m(){if(i){var v,M=i.length,T;for(a=new Array(M),v=0;v<M;++v)T=i[v],a[T.index]=+o(T,v,i)}}function y(v){var M=0,T,S,N=0,R,P,B,F,k=v.length;if(k){for(R=P=B=F=0;F<k;++F)(T=v[F])&&(S=Math.abs(T.value))&&(M+=T.value,N+=S,R+=S*(T.x||0),P+=S*(T.y||0),B+=S*(T.z||0));M*=Math.sqrt(4/k),v.x=R/N,e>1&&(v.y=P/N),e>2&&(v.z=B/N)}else{T=v,T.x=T.data.x,e>1&&(T.y=T.data.y),e>2&&(T.z=T.data.z);do M+=a[T.data.index];while(T=T.next)}v.value=M}function x(v,M,T,S,N){if(!v.value)return!0;var R=[T,S,N][e-1],P=v.x-t.x,B=e>1?v.y-t.y:0,F=e>2?v.z-t.z:0,k=R-M,V=P*P+B*B+F*F;if(k*k/d<V)return V<u&&(P===0&&(P=Kt(n),V+=P*P),e>1&&B===0&&(B=Kt(n),V+=B*B),e>2&&F===0&&(F=Kt(n),V+=F*F),V<c&&(V=Math.sqrt(c*V)),t.vx+=P*v.value*r/V,e>1&&(t.vy+=B*v.value*r/V),e>2&&(t.vz+=F*v.value*r/V)),!0;if(v.length||V>=u)return;(v.data!==t||v.next)&&(P===0&&(P=Kt(n),V+=P*P),e>1&&B===0&&(B=Kt(n),V+=B*B),e>2&&F===0&&(F=Kt(n),V+=F*F),V<c&&(V=Math.sqrt(c*V)));do v.data!==t&&(k=a[v.data.index]*r/V,t.vx+=P*k,e>1&&(t.vy+=B*k),e>2&&(t.vz+=F*k));while(v=v.next)}return p.initialize=function(v,...M){i=v,n=M.find(T=>typeof T=="function")||Math.random,e=M.find(T=>[1,2,3].includes(T))||2,m()},p.strength=function(v){return arguments.length?(o=typeof v=="function"?v:nn(+v),m(),p):o},p.distanceMin=function(v){return arguments.length?(c=v*v,p):Math.sqrt(c)},p.distanceMax=function(v){return arguments.length?(u=v*v,p):Math.sqrt(u)},p.theta=function(v){return arguments.length?(d=v*v,p):Math.sqrt(d)},p}function uo(i,e,t){var n,r=1;i==null&&(i=0),e==null&&(e=0),t==null&&(t=0);function o(){var a,c=n.length,u,d=0,p=0,m=0;for(a=0;a<c;++a)u=n[a],d+=u.x||0,p+=u.y||0,m+=u.z||0;for(d=(d/c-i)*r,p=(p/c-e)*r,m=(m/c-t)*r,a=0;a<c;++a)u=n[a],d&&(u.x-=d),p&&(u.y-=p),m&&(u.z-=m)}return o.initialize=function(a){n=a},o.x=function(a){return arguments.length?(i=+a,o):i},o.y=function(a){return arguments.length?(e=+a,o):e},o.z=function(a){return arguments.length?(t=+a,o):t},o.strength=function(a){return arguments.length?(r=+a,o):r},o}function cx(i,e,t,n){var r,o,a=nn(.1),c,u;typeof i!="function"&&(i=nn(+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],M=v.x-e||1e-6,T=(v.y||0)-t||1e-6,S=(v.z||0)-n||1e-6,N=Math.sqrt(M*M+T*T+S*S),R=(u[y]-N)*c[y]*m/N;v.vx+=M*R,o>1&&(v.vy+=T*R),o>2&&(v.vz+=S*R)}}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:nn(+m),p(),d):a},d.radius=function(m){return arguments.length?(i=typeof m=="function"?m:nn(+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 ux(i){DS(i);const e=hx(i);return i.on=e.on,i.off=e.off,i.fire=e.fire,i}function hx(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 DS(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 FS=dx;function dx(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?P:R,a=[],c=Ce,u=Ce,d=Ce,p=Ce,m={version:20,addNode:M,addLink:N,removeLink:V,removeNode:S,getNode:T,getNodeCount:B,getLinkCount:F,getEdgeCount:F,getLinksCount:F,getNodesCount:B,getLinks:k,forEachNode:ht,forEachLinkedNode:pe,forEachLink:se,beginUpdate:d,endUpdate:p,clear:j,hasLink:z,hasNode:T,getLink:z};return ux(m),y(),m;function y(){var De=m.on;m.on=Je;function Je(){return m.beginUpdate=d=nt,m.endUpdate=p=Le,c=x,u=v,m.on=De,De.apply(m,arguments)}}function x(De,Je){a.push({link:De,changeType:Je})}function v(De,Je){a.push({node:De,changeType:Je})}function M(De,Je){if(De===void 0)throw new Error("Invalid node identifier");d();var wt=T(De);return wt?(wt.data=Je,u(wt,"update")):(wt=new fx(De,Je),u(wt,"add")),e.set(De,wt),p(),wt}function T(De){return e.get(De)}function S(De){var Je=T(De);if(!Je)return!1;d();var wt=Je.links;return wt&&(wt.forEach(U),Je.links=null),e.delete(De),u(Je,"remove"),p(),!0}function N(De,Je,wt){d();var Xt=T(De)||M(De),Ln=T(Je)||M(Je),Ke=o(De,Je,wt),Se=t.has(Ke.id);return t.set(Ke.id,Ke),mA(Xt,Ke),De!==Je&&mA(Ln,Ke),c(Ke,Se?"update":"add"),p(),Ke}function R(De,Je,wt){var Xt=px(De,Je),Ln=t.get(Xt);return Ln?(Ln.data=wt,Ln):new gA(De,Je,wt,Xt)}function P(De,Je,wt){var Xt=px(De,Je),Ln=n.hasOwnProperty(Xt);if(Ln||z(De,Je)){Ln||(n[Xt]=0);var Ke="@"+ ++n[Xt];Xt=px(De+Ke,Je+Ke)}return new gA(De,Je,wt,Xt)}function B(){return e.size}function F(){return t.size}function k(De){var Je=T(De);return Je?Je.links:null}function V(De,Je){return Je!==void 0&&(De=z(De,Je)),U(De)}function U(De){if(!De||!t.get(De.id))return!1;d(),t.delete(De.id);var Je=T(De.fromId),wt=T(De.toId);return Je&&Je.links.delete(De),wt&&wt.links.delete(De),c(De,"remove"),p(),!0}function z(De,Je){if(!(De===void 0||Je===void 0))return t.get(px(De,Je))}function j(){d(),ht(function(De){S(De.id)}),p()}function se(De){if(typeof De=="function")for(var Je=t.values(),wt=Je.next();!wt.done;){if(De(wt.value))return!0;wt=Je.next()}}function pe(De,Je,wt){var Xt=T(De);if(Xt&&Xt.links&&typeof Je=="function")return wt?Pe(Xt.links,De,Je):be(Xt.links,De,Je)}function be(De,Je,wt){for(var Xt,Ln=De.values(),Ke=Ln.next();!Ke.done;){var Se=Ke.value,Fe=Se.fromId===Je?Se.toId:Se.fromId;if(Xt=wt(e.get(Fe),Se),Xt)return!0;Ke=Ln.next()}}function Pe(De,Je,wt){for(var Xt,Ln=De.values(),Ke=Ln.next();!Ke.done;){var Se=Ke.value;if(Se.fromId===Je&&(Xt=wt(e.get(Se.toId),Se),Xt))return!0;Ke=Ln.next()}}function Ce(){}function nt(){r+=1}function Le(){r-=1,r===0&&a.length>0&&(m.fire("changed",a),a.length=0)}function ht(De){if(typeof De!="function")throw new Error("Function is expected to iterate over graph nodes. You passed "+De);for(var Je=e.values(),wt=Je.next();!wt.done;){if(De(wt.value))return!0;wt=Je.next()}}}function fx(i,e){this.id=i,this.links=null,this.data=e}function mA(i,e){i.links?i.links.add(e):i.links=new Set([e])}function gA(i,e,t,n){this.fromId=i,this.toId=e,this.data=t,this.id=n}function px(i,e){return i.toString()+"\u{1F449} "+e.toString()}var XD=he(16505);function jD(i){var e=typeof i;return i!=null&&(e=="object"||e=="function")}var BS=jD,YD=typeof global=="object"&&global&&global.Object===Object&&global,ZD=YD,KD=typeof self=="object"&&self&&self.Object===Object&&self,JD=ZD||KD||Function("return this")(),yA=JD,QD=function(){return yA.Date.now()},OS=QD,eF=/\s/;function tF(i){for(var e=i.length;e--&&eF.test(i.charAt(e)););return e}var nF=tF,iF=/^\s+/;function sF(i){return i&&i.slice(0,nF(i)+1).replace(iF,"")}var rF=sF,oF=yA.Symbol,mx=oF,_A=Object.prototype,aF=_A.hasOwnProperty,lF=_A.toString,By=mx?mx.toStringTag:void 0;function cF(i){var e=aF.call(i,By),t=i[By];try{i[By]=void 0;var n=!0}catch(o){}var r=lF.call(i);return n&&(e?i[By]=t:delete i[By]),r}var uF=cF,hF=Object.prototype,dF=hF.toString;function fF(i){return dF.call(i)}var pF=fF,mF="[object Null]",gF="[object Undefined]",xA=mx?mx.toStringTag:void 0;function yF(i){return i==null?i===void 0?gF:mF:xA&&xA in Object(i)?uF(i):pF(i)}var _F=yF;function xF(i){return i!=null&&typeof i=="object"}var vF=xF,bF="[object Symbol]";function SF(i){return typeof i=="symbol"||vF(i)&&_F(i)==bF}var TF=SF,vA=NaN,wF=/^[-+]0x[0-9a-f]+$/i,MF=/^0b[01]+$/i,AF=/^0o[0-7]+$/i,EF=parseInt;function CF(i){if(typeof i=="number")return i;if(TF(i))return vA;if(BS(i)){var e=typeof i.valueOf=="function"?i.valueOf():i;i=BS(e)?e+"":e}if(typeof i!="string")return i===0?i:+i;i=rF(i);var t=MF.test(i);return t||AF.test(i)?EF(i.slice(2),t?2:8):wF.test(i)?vA:+i}var bA=CF,RF="Expected a function",NF=Math.max,PF=Math.min;function IF(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(RF);e=bA(e)||0,BS(t)&&(p=!!t.leading,m="maxWait"in t,o=m?NF(bA(t.maxWait)||0,e):o,y="trailing"in t?!!t.trailing:y);function x(F){var k=n,V=r;return n=r=void 0,d=F,a=i.apply(V,k),a}function v(F){return d=F,c=setTimeout(S,e),p?x(F):a}function M(F){var k=F-u,V=F-d,U=e-k;return m?PF(U,o-V):U}function T(F){var k=F-u,V=F-d;return u===void 0||k>=e||k<0||m&&V>=o}function S(){var F=OS();if(T(F))return N(F);c=setTimeout(S,M(F))}function N(F){return c=void 0,y&&n?x(F):(n=r=void 0,a)}function R(){c!==void 0&&clearTimeout(c),d=0,n=u=r=c=void 0}function P(){return c===void 0?a:N(OS())}function B(){var F=OS(),k=T(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 B.cancel=R,B.flush=P,B}var LF=IF;function SA(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 DF(i){if(Array.isArray(i))return i}function FF(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")}function BF(i,e,t){return Object.defineProperty(i,"prototype",{writable:!1}),i}function OF(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 UF(){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 kF(i,e){return DF(i)||OF(i,e)||zF(i,e)||UF()}function zF(i,e){if(i){if(typeof i=="string")return SA(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)?SA(i,e):void 0}}var VF=BF(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;FF(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 VF(v,r[v])});return function v(){for(var M=arguments.length,T=new Array(M),S=0;S<M;S++)T[S]=arguments[S];var N=!!(this instanceof v&&this.constructor),R=N?T.shift():void 0,P=T[0],B=P===void 0?{}:P,F=Object.assign({},t instanceof Function?t(B):t,{initialised:!1}),k={};function V(j){return U(j,B),z(),V}var U=function(se,pe){p.call(V,se,F,pe),F.initialised=!0},z=LF(function(){F.initialised&&(y.call(V,F,k),k={})},1);return x.forEach(function(j){V[j.name]=se(j);function se(pe){var be=pe.name,Pe=pe.triggerUpdate,Ce=Pe===void 0?!1:Pe,nt=pe.onChange,Le=nt===void 0?function(Je,wt){}:nt,ht=pe.defaultVal,De=ht===void 0?null:ht;return function(Je){var wt=F[be];if(!arguments.length)return wt;var Xt=Je===void 0?De:Je;return F[be]=Xt,Le.call(V,Xt,F,wt),!k.hasOwnProperty(be)&&(k[be]=wt),Ce&&z(),V}}}),Object.keys(a).forEach(function(j){V[j]=function(){for(var se,pe=arguments.length,be=new Array(pe),Pe=0;Pe<pe;Pe++)be[Pe]=arguments[Pe];return(se=a[j]).call.apply(se,[V,F].concat(be))}}),Object.entries(u).forEach(function(j){var se=kF(j,2),pe=se[0],be=se[1];return V[pe]=V[be]}),V.resetProps=function(){return x.forEach(function(j){V[j.name](j.defaultVal)}),V},V.resetProps(),F._rerender=z,N&&R&&V(R),V}}var ii=function(i){return typeof i=="function"?i:typeof i=="string"?function(e){return e[i]}:function(e){return i}};function GF(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 HF(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 US(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 WF(i){if(Array.isArray(i))return i}function $F(i){if(Array.isArray(i))return US(i)}function TA(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 qF(i,e){if(e.has(i))throw new TypeError("Cannot initialize the same private elements twice on an object")}function XF(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")}function $r(i,e){return i.get(TA(i,e))}function bm(i,e,t){qF(i,e),e.set(i,t)}function yx(i,e,t){return i.set(TA(i,e),t),t}function jF(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,iB(n.key),n)}}function YF(i,e,t){return e&&jF(i.prototype,e),Object.defineProperty(i,"prototype",{writable:!1}),i}function ZF(i){if(typeof Symbol!="undefined"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function KF(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 JF(){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 QF(){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 eB(i,e){return WF(i)||KF(i,e)||wA(i,e)||JF()}function tB(i){return $F(i)||ZF(i)||wA(i)||QF()}function nB(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 iB(i){var e=nB(i,"string");return typeof e=="symbol"?e:e+""}function wA(i,e){if(i){if(typeof i=="string")return US(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)?US(i,e):void 0}}var Sm=new WeakMap,Oy=new WeakMap,Tm=new WeakMap,kS=new WeakMap,zS=new WeakMap,VS=new WeakMap,sB=function(){function i(){XF(this,i),bm(this,Sm,new Map),bm(this,Oy,new Map),bm(this,Tm,function(e){return e}),bm(this,kS,function(){return{}}),bm(this,zS,function(){}),bm(this,VS,function(){})}return YF(i,[{key:"getObj",value:function(t){return $r(Sm,this).get($r(Tm,this).call(this,t))}},{key:"getData",value:function(t){return $r(Oy,this).get(t)}},{key:"entries",value:function(){return tB($r(Oy,this).entries()).map(function(t){var n=eB(t,2),r=n[0],o=n[1];return[o,r]})}},{key:"id",value:function(t){return yx(Tm,this,ii(t)),this}},{key:"onCreateObj",value:function(t){return yx(kS,this,t),this}},{key:"onUpdateObj",value:function(t){return yx(zS,this,t),this}},{key:"onRemoveObj",value:function(t){return yx(VS,this,t),this}},{key:"digest",value:function(t){var n=this;t.filter(function(o){return!$r(Sm,n).has($r(Tm,n).call(n,o))}).forEach(function(o){var a=$r(kS,n).call(n,o);$r(Sm,n).set($r(Tm,n).call(n,o),a),$r(Oy,n).set(a,o)});var r=new Map(t.map(function(o){return[$r(Tm,n).call(n,o),o]}));return $r(Sm,this).forEach(function(o,a){r.has(a)?$r(zS,n).call(n,o,r.get(a)):($r(VS,n).call(n,o,a),$r(Sm,n).delete(a),$r(Oy,n).delete(o))}),this}},{key:"clear",value:function(){return this.digest([]),this}}])}();class MA extends Map{constructor(e,t=CA){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(GS(this,e))}has(e){return super.has(GS(this,e))}set(e,t){return super.set(AA(this,e),t)}delete(e){return super.delete(EA(this,e))}}class EY extends null{constructor(e,t=CA){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(GS(this,e))}add(e){return super.add(AA(this,e))}delete(e){return super.delete(EA(this,e))}}function GS({_intern:i,_key:e},t){const n=e(t);return i.has(n)?i.get(n):t}function AA({_intern:i,_key:e},t){const n=e(t);return i.has(n)?i.get(n):(i.set(n,t),t)}function EA({_intern:i,_key:e},t){const n=e(t);return i.has(n)&&(t=i.get(n),i.delete(n)),t}function CA(i){return i!==null&&typeof i=="object"?i.valueOf():i}function rB(i,e){switch(arguments.length){case 0:break;case 1:this.range(i);break;default:this.range(e).domain(i);break}return this}function CY(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 RA=Symbol("implicit");function NA(){var i=new MA,e=[],t=[],n=RA;function r(o){let a=i.get(o);if(a===void 0){if(n!==RA)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 MA;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 NA(e,t).unknown(n)},rB.apply(r,arguments),r}function oB(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 aB=oB("a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928");function _x(i){"@babel/helpers - typeof";return _x=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},_x(i)}var lB=/^\s+/,cB=/\s+$/;function mn(i,e){if(i=i||"",e=e||{},i instanceof mn)return i;if(!(this instanceof mn))return new mn(i,e);var t=uB(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}mn.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=BA(e),this._roundA=Math.round(100*this._a)/100,this},toHsv:function(){var e=IA(this._r,this._g,this._b);return{h:e.h*360,s:e.s,v:e.v,a:this._a}},toHsvString:function(){var e=IA(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=PA(this._r,this._g,this._b);return{h:e.h*360,s:e.s,l:e.l,a:this._a}},toHslString:function(){var e=PA(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 LA(this._r,this._g,this._b,e)},toHexString:function(e){return"#"+this.toHex(e)},toHex8:function(e){return pB(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(as(this._r,255)*100)+"%",g:Math.round(as(this._g,255)*100)+"%",b:Math.round(as(this._b,255)*100)+"%",a:this._a}},toPercentageRgbString:function(){return this._a==1?"rgb("+Math.round(as(this._r,255)*100)+"%, "+Math.round(as(this._g,255)*100)+"%, "+Math.round(as(this._b,255)*100)+"%)":"rgba("+Math.round(as(this._r,255)*100)+"%, "+Math.round(as(this._g,255)*100)+"%, "+Math.round(as(this._b,255)*100)+"%, "+this._roundA+")"},toName:function(){return this._a===0?"transparent":this._a<1?!1:AB[LA(this._r,this._g,this._b,!0)]||!1},toFilter:function(e){var t="#"+DA(this._r,this._g,this._b,this._a),n=t,r=this._gradientType?"GradientType = 1, ":"";if(e){var o=mn(e);n="#"+DA(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 mn(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(_B,arguments)},brighten:function(){return this._applyModification(xB,arguments)},darken:function(){return this._applyModification(vB,arguments)},desaturate:function(){return this._applyModification(mB,arguments)},saturate:function(){return this._applyModification(gB,arguments)},greyscale:function(){return this._applyModification(yB,arguments)},spin:function(){return this._applyModification(bB,arguments)},_applyCombination:function(e,t){return e.apply(null,[this].concat([].slice.call(t)))},analogous:function(){return this._applyCombination(wB,arguments)},complement:function(){return this._applyCombination(SB,arguments)},monochromatic:function(){return this._applyCombination(MB,arguments)},splitcomplement:function(){return this._applyCombination(TB,arguments)},triad:function(){return this._applyCombination(FA,[3])},tetrad:function(){return this._applyCombination(FA,[4])}},mn.fromRatio=function(i,e){if(_x(i)=="object"){var t={};for(var n in i)i.hasOwnProperty(n)&&(n==="a"?t[n]=i[n]:t[n]=Uy(i[n]));i=t}return mn(i,e)};function uB(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=NB(i)),_x(i)=="object"&&(Mu(i.r)&&Mu(i.g)&&Mu(i.b)?(e=hB(i.r,i.g,i.b),a=!0,c=String(i.r).substr(-1)==="%"?"prgb":"rgb"):Mu(i.h)&&Mu(i.s)&&Mu(i.v)?(n=Uy(i.s),r=Uy(i.v),e=fB(i.h,n,r),a=!0,c="hsv"):Mu(i.h)&&Mu(i.s)&&Mu(i.l)&&(n=Uy(i.s),o=Uy(i.l),e=dB(i.h,n,o),a=!0,c="hsl"),i.hasOwnProperty("a")&&(t=i.a)),t=BA(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 hB(i,e,t){return{r:as(i,255)*255,g:as(e,255)*255,b:as(t,255)*255}}function PA(i,e,t){i=as(i,255),e=as(e,255),t=as(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 dB(i,e,t){var n,r,o;i=as(i,360),e=as(e,100),t=as(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 IA(i,e,t){i=as(i,255),e=as(e,255),t=as(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 fB(i,e,t){i=as(i,360)*6,e=as(e,100),t=as(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 LA(i,e,t,n){var r=[wl(Math.round(i).toString(16)),wl(Math.round(e).toString(16)),wl(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 pB(i,e,t,n,r){var o=[wl(Math.round(i).toString(16)),wl(Math.round(e).toString(16)),wl(Math.round(t).toString(16)),wl(OA(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 DA(i,e,t,n){var r=[wl(OA(n)),wl(Math.round(i).toString(16)),wl(Math.round(e).toString(16)),wl(Math.round(t).toString(16))];return r.join("")}mn.equals=function(i,e){return!i||!e?!1:mn(i).toRgbString()==mn(e).toRgbString()},mn.random=function(){return mn.fromRatio({r:Math.random(),g:Math.random(),b:Math.random()})};function mB(i,e){e=e===0?0:e||10;var t=mn(i).toHsl();return t.s-=e/100,t.s=xx(t.s),mn(t)}function gB(i,e){e=e===0?0:e||10;var t=mn(i).toHsl();return t.s+=e/100,t.s=xx(t.s),mn(t)}function yB(i){return mn(i).desaturate(100)}function _B(i,e){e=e===0?0:e||10;var t=mn(i).toHsl();return t.l+=e/100,t.l=xx(t.l),mn(t)}function xB(i,e){e=e===0?0:e||10;var t=mn(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)))),mn(t)}function vB(i,e){e=e===0?0:e||10;var t=mn(i).toHsl();return t.l-=e/100,t.l=xx(t.l),mn(t)}function bB(i,e){var t=mn(i).toHsl(),n=(t.h+e)%360;return t.h=n<0?360+n:n,mn(t)}function SB(i){var e=mn(i).toHsl();return e.h=(e.h+180)%360,mn(e)}function FA(i,e){if(isNaN(e)||e<=0)throw new Error("Argument to polyad must be a positive number");for(var t=mn(i).toHsl(),n=[mn(i)],r=360/e,o=1;o<e;o++)n.push(mn({h:(t.h+o*r)%360,s:t.s,l:t.l}));return n}function TB(i){var e=mn(i).toHsl(),t=e.h;return[mn(i),mn({h:(t+72)%360,s:e.s,l:e.l}),mn({h:(t+216)%360,s:e.s,l:e.l})]}function wB(i,e,t){e=e||6,t=t||30;var n=mn(i).toHsl(),r=360/t,o=[mn(i)];for(n.h=(n.h-(r*e>>1)+720)%360;--e;)n.h=(n.h+r)%360,o.push(mn(n));return o}function MB(i,e){e=e||6;for(var t=mn(i).toHsv(),n=t.h,r=t.s,o=t.v,a=[],c=1/e;e--;)a.push(mn({h:n,s:r,v:o})),o=(o+c)%1;return a}mn.mix=function(i,e,t){t=t===0?0:t||50;var n=mn(i).toRgb(),r=mn(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 mn(a)},mn.readability=function(i,e){var t=mn(i),n=mn(e);return(Math.max(t.getLuminance(),n.getLuminance())+.05)/(Math.min(t.getLuminance(),n.getLuminance())+.05)},mn.isReadable=function(i,e,t){var n=mn.readability(i,e),r,o;switch(o=!1,r=PB(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},mn.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=mn.readability(i,e[d]),o>r&&(r=o,n=mn(e[d]));return mn.isReadable(i,n,{level:c,size:u})||!a?n:(t.includeFallbackColors=!1,mn.mostReadable(i,["#fff","#000"],t))};var HS=mn.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"},AB=mn.hexNames=EB(HS);function EB(i){var e={};for(var t in i)i.hasOwnProperty(t)&&(e[i[t]]=t);return e}function BA(i){return i=parseFloat(i),(isNaN(i)||i<0||i>1)&&(i=1),i}function as(i,e){CB(i)&&(i="100%");var t=RB(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 xx(i){return Math.min(1,Math.max(0,i))}function oa(i){return parseInt(i,16)}function CB(i){return typeof i=="string"&&i.indexOf(".")!=-1&&parseFloat(i)===1}function RB(i){return typeof i=="string"&&i.indexOf("%")!=-1}function wl(i){return i.length==1?"0"+i:""+i}function Uy(i){return i<=1&&(i=i*100+"%"),i}function OA(i){return Math.round(parseFloat(i)*255).toString(16)}function UA(i){return oa(i)/255}var Ml=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 Mu(i){return!!Ml.CSS_UNIT.exec(i)}function NB(i){i=i.replace(lB,"").replace(cB,"").toLowerCase();var e=!1;if(HS[i])i=HS[i],e=!0;else if(i=="transparent")return{r:0,g:0,b:0,a:0,format:"name"};var t;return(t=Ml.rgb.exec(i))?{r:t[1],g:t[2],b:t[3]}:(t=Ml.rgba.exec(i))?{r:t[1],g:t[2],b:t[3],a:t[4]}:(t=Ml.hsl.exec(i))?{h:t[1],s:t[2],l:t[3]}:(t=Ml.hsla.exec(i))?{h:t[1],s:t[2],l:t[3],a:t[4]}:(t=Ml.hsv.exec(i))?{h:t[1],s:t[2],v:t[3]}:(t=Ml.hsva.exec(i))?{h:t[1],s:t[2],v:t[3],a:t[4]}:(t=Ml.hex8.exec(i))?{r:oa(t[1]),g:oa(t[2]),b:oa(t[3]),a:UA(t[4]),format:e?"name":"hex8"}:(t=Ml.hex6.exec(i))?{r:oa(t[1]),g:oa(t[2]),b:oa(t[3]),format:e?"name":"hex"}:(t=Ml.hex4.exec(i))?{r:oa(t[1]+""+t[1]),g:oa(t[2]+""+t[2]),b:oa(t[3]+""+t[3]),a:UA(t[4]+""+t[4]),format:e?"name":"hex8"}:(t=Ml.hex3.exec(i))?{r:oa(t[1]+""+t[1]),g:oa(t[2]+""+t[2]),b:oa(t[3]+""+t[3]),format:e?"name":"hex"}:!1}function PB(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 WS(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 IB(i){if(Array.isArray(i))return i}function LB(i){if(Array.isArray(i))return WS(i)}function kA(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 DB(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function zA(i,e,t){return e=wm(e),GB(i,XS()?Reflect.construct(e,t||[],wm(i).constructor):e.apply(i,t))}function FB(i,e){if(e.has(i))throw new TypeError("Cannot initialize the same private elements twice on an object")}function VA(i,e){if(!(i instanceof e))throw new TypeError("Cannot call a class as a function")}function $S(i,e){return i.get(kA(i,e))}function GA(i,e,t){FB(i,e),e.set(i,t)}function HA(i,e,t){return i.set(kA(i,e),t),t}function WA(i,e,t){if(XS())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 BB(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,jA(n.key),n)}}function $A(i,e,t){return e&&BB(i.prototype,e),Object.defineProperty(i,"prototype",{writable:!1}),i}function vx(i,e,t){return(e=jA(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function qS(){return qS=typeof Reflect!="undefined"&&Reflect.get?Reflect.get.bind():function(i,e,t){var n=HB(i,e);if(n){var r=Object.getOwnPropertyDescriptor(n,e);return r.get?r.get.call(arguments.length<3?i:t):r.value}},qS.apply(null,arguments)}function wm(i){return wm=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},wm(i)}function qA(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&&jS(i,e)}function XS(){try{var i=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(XS=function(){return!!i})()}function OB(i){if(typeof Symbol!="undefined"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function UB(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 kB(){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 zB(){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 XA(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 VB(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?XA(Object(t),!0).forEach(function(n){vx(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):XA(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function GB(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 DB(i)}function jS(i,e){return jS=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},jS(i,e)}function ky(i,e){return IB(i)||UB(i,e)||YA(i,e)||kB()}function HB(i,e){for(;!{}.hasOwnProperty.call(i,e)&&(i=wm(i))!==null;);return i}function YS(i,e,t,n){var r=qS(wm(i.prototype),e,t);return typeof r=="function"?function(o){return r.apply(t,o)}:r}function Al(i){return LB(i)||OB(i)||YA(i)||zB()}function WB(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 jA(i){var e=WB(i,"string");return typeof e=="symbol"?e:e+""}function ZS(i){"@babel/helpers - typeof";return ZS=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},ZS(i)}function YA(i,e){if(i){if(typeof i=="string")return WS(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)?WS(i,e):void 0}}var ZA=function(e){e instanceof Array?e.forEach(ZA):(e.map&&e.map.dispose(),e.dispose())},KA=function(e){e.geometry&&e.geometry.dispose(),e.material&&ZA(e.material),e.texture&&e.texture.dispose(),e.children&&e.children.forEach(KA)},KS=function(e){for(;e.children.length;){var t=e.children[0];e.remove(t),KA(t)}},JS=new WeakMap,bx=new WeakMap,zy=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 VA(this,e),n=zA(this,e),vx(n,"scene",void 0),GA(n,JS,void 0),GA(n,bx,void 0),n.scene=t,HA(JS,n,a),HA(bx,n,u),n.onRemoveObj(function(){}),n}return qA(e,i),$A(e,[{key:"onCreateObj",value:function(n){var r=this;return YS(e,"onCreateObj",this)([function(o){var a=n(o);return o[$S(bx,r)]=a,a[$S(JS,r)]=o,r.scene.add(a),a}]),this}},{key:"onRemoveObj",value:function(n){var r=this;return YS(e,"onRemoveObj",this)([function(o,a){var c=YS(e,"getData",r)([o]);n(o,a),r.scene.remove(o),KS(o),delete c[$S(bx,r)]}]),this}}])}(sB),Vy=function(e){return isNaN(e)?parseInt(mn(e).toHex(),16):e},QS=function(e){return isNaN(e)?mn(e).getAlpha():1},$B=NA(aB);function JA(i,e,t){!e||typeof t!="string"||i.filter(function(n){return!n[t]}).forEach(function(n){n[t]=$B(e(n))})}function qB(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,M=x.target,T=P(v),S=P(M);if(!d.hasOwnProperty(T))throw"Missing source node with id: ".concat(T);if(!d.hasOwnProperty(S))throw"Missing target node with id: ".concat(S);var N=d[T],R=d[S];N.out.push(R);function P(B){return ZS(B)==="object"?e(B):B}});var p=[];y(Object.values(d));var m=Object.assign.apply(Object,[{}].concat(Al(Object.entries(d).filter(function(x){var v=ky(x,2),M=v[1];return!M.skip}).map(function(x){var v=ky(x,2),M=v[0],T=v[1];return vx({},M,T.depth)}))));return m;function y(x){for(var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],M=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,T=function(){var P=x[S];if(v.indexOf(P)!==-1){var B=[].concat(Al(v.slice(v.indexOf(P))),[P]).map(function(F){return e(F.data)});return p.some(function(F){return F.length===B.length&&F.every(function(k,V){return k===B[V]})})||(p.push(B),u(B)),1}M>P.depth&&(P.depth=M,y(P.out,[].concat(Al(v),[P]),M+(P.skip?0:1)))},S=0,N=x.length;S<N;S++)T()}}var An=window.THREE?window.THREE:{Group:nr,Mesh:vi,MeshLambertMaterial:ay,Color:At,BufferGeometry:gn,BufferAttribute:$n,Matrix4:Vt,Vector3:W,SphereGeometry:gl,CylinderGeometry:rf,TubeGeometry:$h,ConeGeometry:of,Line:Ql,LineBasicMaterial:Js,QuadraticBezierCurve3:uu,CubicBezierCurve3:P0,Box3:dr},QA={graph:FS,forcelayout:XD},XB=2,eT=new An.BufferGeometry().setAttribute?"setAttribute":"addAttribute",Sx=new An.BufferGeometry().applyMatrix4?"applyMatrix4":"applyMatrix",jB=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=ii(e.nodeThreeObjectExtend);e.nodeDataMapper.entries().forEach(function(y){var x=ky(y,2),v=x[0],M=x[1];if(M){var T=t?v:e.layout.getNodePosition(v[e.nodeId]),S=a(v);(!e.nodePositionUpdate||!e.nodePositionUpdate(S?M.children[0]:M,{x:T.x,y:T.y,z:T.z},v)||S)&&(M.position.x=T.x,M.position.y=T.y||0,M.position.z=T.z||0)}});var c=ii(e.linkWidth),u=ii(e.linkCurvature),d=ii(e.linkCurveRotation),p=ii(e.linkThreeObjectExtend);e.linkDataMapper.entries().forEach(function(y){var x=ky(y,2),v=x[0],M=x[1];if(M){var T=t?v:e.layout.getLinkPosition(e.layout.graph.getLink(v.source,v.target).id),S=T[t?"source":"from"],N=T[t?"target":"to"];if(!(!S||!N||!S.hasOwnProperty("x")||!N.hasOwnProperty("x"))){m(v);var R=p(v);if(!(e.linkPositionUpdate&&e.linkPositionUpdate(R?M.children[1]:M,{start:{x:S.x,y:S.y,z:S.z},end:{x:N.x,y:N.y,z:N.z}},v)&&!R)){var P=30,B=v.__curve,F=M.children.length?M.children[0]:M;if(F.type==="Line"){if(B){var V=B.getPoints(P);F.geometry.getAttribute("position").array.length!==V.length*3&&F.geometry[eT]("position",new An.BufferAttribute(new Float32Array(V.length*3),3)),F.geometry.setFromPoints(V)}else{var k=F.geometry.getAttribute("position");(!k||!k.array||k.array.length!==6)&&F.geometry[eT]("position",k=new An.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]=N.x,k.array[4]=N.y||0,k.array[5]=N.z||0,k.needsUpdate=!0}F.geometry.computeBoundingSphere()}else if(F.type==="Mesh")if(B){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,Ce=Pe/2,nt=new An.TubeGeometry(B,P,Ce,e.linkResolution,!1);F.geometry.dispose(),F.geometry=nt}else{if(!F.geometry.type.match(/^Cylinder(Buffer)?Geometry$/)){var U=Math.ceil(c(v)*10)/10,z=U/2,j=new An.CylinderGeometry(z,z,1,e.linkResolution,1,!1);j[Sx](new An.Matrix4().makeTranslation(0,1/2,0)),j[Sx](new An.Matrix4().makeRotationX(Math.PI/2)),F.geometry.dispose(),F.geometry=j}var se=new An.Vector3(S.x,S.y||0,S.z||0),pe=new An.Vector3(N.x,N.y||0,N.z||0),be=se.distanceTo(pe);F.position.x=se.x,F.position.y=se.y,F.position.z=se.z,F.scale.z=be,F.parent.localToWorld(pe),F.lookAt(pe)}}}}});function m(y){var x=t?y:e.layout.getLinkPosition(e.layout.graph.getLink(y.source,y.target).id),v=x[t?"source":"from"],M=x[t?"target":"to"];if(!(!v||!M||!v.hasOwnProperty("x")||!M.hasOwnProperty("x"))){var T=u(y);if(!T)y.__curve=null;else{var S=new An.Vector3(v.x,v.y||0,v.z||0),N=new An.Vector3(M.x,M.y||0,M.z||0),R=S.distanceTo(N),P,B=d(y);if(R>0){var F=M.x-v.x,k=M.y-v.y||0,V=new An.Vector3().subVectors(N,S),U=V.clone().multiplyScalar(T).cross(F!==0||k!==0?new An.Vector3(0,0,1):new An.Vector3(0,1,0)).applyAxisAngle(V.normalize(),B).add(new An.Vector3().addVectors(S,N).divideScalar(2));P=new An.QuadraticBezierCurve3(S,U,N)}else{var z=T*70,j=-B,se=j+Math.PI/2;P=new An.CubicBezierCurve3(S,new An.Vector3(z*Math.cos(se),z*Math.sin(se),0).add(S),new An.Vector3(z*Math.cos(j),z*Math.sin(j),0).add(S),N)}y.__curve=P}}}}function r(){var a=ii(e.linkDirectionalArrowRelPos),c=ii(e.linkDirectionalArrowLength),u=ii(e.nodeVal);e.arrowDataMapper.entries().forEach(function(d){var p=ky(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"],M=x[t?"target":"to"];if(!(!v||!M||!v.hasOwnProperty("x")||!M.hasOwnProperty("x"))){var T=Math.cbrt(Math.max(0,u(v)||1))*e.nodeRelSize,S=Math.cbrt(Math.max(0,u(M)||1))*e.nodeRelSize,N=c(m),R=a(m),P=m.__curve?function(z){return m.__curve.getPoint(z)}:function(z){var j=function(pe,be,Pe,Ce){return be[pe]+(Pe[pe]-be[pe])*Ce||0};return{x:j("x",v,M,z),y:j("y",v,M,z),z:j("z",v,M,z)}},B=m.__curve?m.__curve.getLength():Math.sqrt(["x","y","z"].map(function(z){return Math.pow((M[z]||0)-(v[z]||0),2)}).reduce(function(z,j){return z+j},0)),F=T+N+(B-T-S-N)*R,k=P(F/B),V=P((F-N)/B);["x","y","z"].forEach(function(z){return y.position[z]=V[z]});var U=WA(An.Vector3,Al(["x","y","z"].map(function(z){return k[z]})));y.parent.localToWorld(U),y.lookAt(U)}}})}function o(){var a=ii(e.linkDirectionalParticleSpeed),c=ii(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 M=a(u),T=Math.abs(c(u)),S=u.__curve?function(R){return u.__curve.getPoint(R)}:function(R){var P=function(F,k,V,U){return k[F]+(V[F]-k[F])*U||0};return{x:P("x",x,v,R),y:P("y",x,v,R),z:P("z",x,v,R)}},N=[].concat(Al(p||[]),Al(m||[]));N.forEach(function(R,P){var B=R.parent.__linkThreeObjType==="singleHopPhotons";if(R.hasOwnProperty("__progressRatio")||(R.__progressRatio=B?0:(P+T)/p.length),R.__progressRatio+=M,R.__progressRatio>=1)if(!B)R.__progressRatio=R.__progressRatio%1;else{R.parent.remove(R),KS(R);return}var F=R.__progressRatio,k=S(F);R.geometry.type!=="SphereGeometry"&&R.lookAt(k.x,k.y,k.z),["x","y","z"].forEach(function(V){return R.position[V]=k[V]})})}}})}},emitParticle:function(e,t){if(t&&e.graphData.links.includes(t)){if(!t.__singleHopPhotonsObj){var n=new An.Group;n.__linkThreeObjType="singleHopPhotons",t.__singleHopPhotonsObj=n,e.graphScene.add(n)}var r=ii(e.linkDirectionalParticleThreeObject)(t);if(r&&e.linkDirectionalParticleThreeObject===r&&(r=r.clone()),!r){var o=ii(e.linkDirectionalParticleWidth),a=Math.ceil(o(t)*10)/10/2,c=e.linkDirectionalParticleResolution,u=new An.SphereGeometry(a,c,c),d=ii(e.linkColor),p=ii(e.linkDirectionalParticleColor),m=p(t)||d(t)||"#f0f0f0",y=new An.Color(Vy(m)),x=e.linkOpacity*3,v=new An.MeshLambertMaterial({color:y,transparent:!0,opacity:x});r=new An.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 An.Box3;c.copy(o.geometry.boundingBox).applyMatrix4(o.matrixWorld),a.push(c)}return a.concat.apply(a,Al((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,Al(["x","y","z"].map(function(r){return vx({},r,[GF(n,function(o){return o.min[r]}),HF(n,function(o){return o.max[r]})])}))):null}},stateInit:function(){return{d3ForceLayout:jt().force("link",ji()).force("charge",wu()).force("center",uo()).force("dagRadial",null).stop(),engineRunning:!1}},init:function(e,t){t.graphScene=e,t.nodeDataMapper=new zy(e,{objBindAttr:"__threeObj"}),t.linkDataMapper=new zy(e,{objBindAttr:"__lineObj"}),t.arrowDataMapper=new zy(e,{objBindAttr:"__arrowObj"}),t.particlesDataMapper=new zy(e,{objBindAttr:"__photonsObj"})},update:function(e,t){var n=function(Se){return Se.some(function(Fe){return t.hasOwnProperty(Fe)})};if(e.engineRunning=!1,typeof e.onUpdate=="function"&&e.onUpdate(),e.nodeAutoColorBy!==null&&n(["nodeAutoColorBy","graphData","nodeColor"])&&JA(e.graphData.nodes,ii(e.nodeAutoColorBy),e.nodeColor),e.linkAutoColorBy!==null&&n(["linkAutoColorBy","graphData","linkColor"])&&JA(e.graphData.links,ii(e.linkAutoColorBy),e.linkColor),e._flushObjects||n(["graphData","nodeThreeObject","nodeThreeObjectExtend","nodeVal","nodeColor","nodeVisibility","nodeRelSize","nodeResolution","nodeOpacity"])){var r=ii(e.nodeThreeObject),o=ii(e.nodeThreeObjectExtend),a=ii(e.nodeVal),c=ii(e.nodeColor),u=ii(e.nodeVisibility),d={},p={};(e._flushObjects||n(["nodeThreeObject","nodeThreeObjectExtend"]))&&e.nodeDataMapper.clear(),e.nodeDataMapper.onCreateObj(function(Ke){var Se=r(Ke),Fe=o(Ke);Se&&e.nodeThreeObject===Se&&(Se=Se.clone());var mt;return Se&&!Fe?mt=Se:(mt=new An.Mesh,mt.__graphDefaultObj=!0,Se&&Fe&&mt.add(Se)),mt.__graphObjType="node",mt}).onUpdateObj(function(Ke,Se){if(Ke.__graphDefaultObj){var Fe=a(Se)||1,mt=Math.cbrt(Fe)*e.nodeRelSize,Bt=e.nodeResolution;(!Ke.geometry.type.match(/^Sphere(Buffer)?Geometry$/)||Ke.geometry.parameters.radius!==mt||Ke.geometry.parameters.widthSegments!==Bt)&&(d.hasOwnProperty(Fe)||(d[Fe]=new An.SphereGeometry(mt,Bt,Bt)),Ke.geometry.dispose(),Ke.geometry=d[Fe]);var Rt=c(Se),hn=new An.Color(Vy(Rt||"#ffffaa")),ri=e.nodeOpacity*QS(Rt);(Ke.material.type!=="MeshLambertMaterial"||!Ke.material.color.equals(hn)||Ke.material.opacity!==ri)&&(p.hasOwnProperty(Rt)||(p[Rt]=new An.MeshLambertMaterial({color:hn,transparent:!0,opacity:ri})),Ke.material.dispose(),Ke.material=p[Rt])}}).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=ii(e.linkThreeObject),y=ii(e.linkThreeObjectExtend),x=ii(e.linkMaterial),v=ii(e.linkVisibility),M=ii(e.linkColor),T=ii(e.linkWidth),S={},N={},R={},P=e.graphData.links.filter(v);if((e._flushObjects||n(["linkThreeObject","linkThreeObjectExtend","linkWidth"]))&&e.linkDataMapper.clear(),e.linkDataMapper.onRemoveObj(function(Ke){var Se=Ke.__data&&Ke.__data.__singleHopPhotonsObj;Se&&(Se.parent.remove(Se),KS(Se),delete Ke.__data.__singleHopPhotonsObj)}).onCreateObj(function(Ke){var Se=m(Ke),Fe=y(Ke);Se&&e.linkThreeObject===Se&&(Se=Se.clone());var mt;if(!Se||Fe){var Bt=!!T(Ke);if(Bt)mt=new An.Mesh;else{var Rt=new An.BufferGeometry;Rt[eT]("position",new An.BufferAttribute(new Float32Array(2*3),3)),mt=new An.Line(Rt)}}var hn;return Se?Fe?(hn=new An.Group,hn.__graphDefaultObj=!0,hn.add(mt),hn.add(Se)):hn=Se:(hn=mt,hn.__graphDefaultObj=!0),hn.renderOrder=10,hn.__graphObjType="link",hn}).onUpdateObj(function(Ke,Se){if(Ke.__graphDefaultObj){var Fe=Ke.children.length?Ke.children[0]:Ke,mt=Math.ceil(T(Se)*10)/10,Bt=!!mt;if(Bt){var Rt=mt/2,hn=e.linkResolution;if(!Fe.geometry.type.match(/^Cylinder(Buffer)?Geometry$/)||Fe.geometry.parameters.radiusTop!==Rt||Fe.geometry.parameters.radialSegments!==hn){if(!S.hasOwnProperty(mt)){var ri=new An.CylinderGeometry(Rt,Rt,1,hn,1,!1);ri[Sx](new An.Matrix4().makeTranslation(0,1/2,0)),ri[Sx](new An.Matrix4().makeRotationX(Math.PI/2)),S[mt]=ri}Fe.geometry.dispose(),Fe.geometry=S[mt]}}var re=x(Se);if(re)Fe.material=re;else{var st=M(Se),it=new An.Color(Vy(st||"#f0f0f0")),tt=e.linkOpacity*QS(st),Qe=Bt?"MeshLambertMaterial":"LineBasicMaterial";if(Fe.material.type!==Qe||!Fe.material.color.equals(it)||Fe.material.opacity!==tt){var Mt=Bt?N:R;Mt.hasOwnProperty(st)||(Mt[st]=new An[Qe]({color:it,transparent:tt<1,opacity:tt,depthWrite:tt>=1})),Fe.material.dispose(),Fe.material=Mt[st]}}}}).digest(P),e.linkDirectionalArrowLength||t.hasOwnProperty("linkDirectionalArrowLength")){var B=ii(e.linkDirectionalArrowLength),F=ii(e.linkDirectionalArrowColor);e.arrowDataMapper.onCreateObj(function(){var Ke=new An.Mesh(void 0,new An.MeshLambertMaterial({transparent:!0}));return Ke.__linkThreeObjType="arrow",Ke}).onUpdateObj(function(Ke,Se){var Fe=B(Se),mt=e.linkDirectionalArrowResolution;if(!Ke.geometry.type.match(/^Cone(Buffer)?Geometry$/)||Ke.geometry.parameters.height!==Fe||Ke.geometry.parameters.radialSegments!==mt){var Bt=new An.ConeGeometry(Fe*.25,Fe,mt);Bt.translate(0,Fe/2,0),Bt.rotateX(Math.PI/2),Ke.geometry.dispose(),Ke.geometry=Bt}var Rt=F(Se)||M(Se)||"#f0f0f0";Ke.material.color=new An.Color(Vy(Rt)),Ke.material.opacity=e.linkOpacity*3*QS(Rt)}).digest(P.filter(B))}if(e.linkDirectionalParticles||t.hasOwnProperty("linkDirectionalParticles")){var k=ii(e.linkDirectionalParticles),V=ii(e.linkDirectionalParticleWidth),U=ii(e.linkDirectionalParticleColor),z=ii(e.linkDirectionalParticleThreeObject),j={},se={};e.particlesDataMapper.onCreateObj(function(){var Ke=new An.Group;return Ke.__linkThreeObjType="photons",Ke.__photonDataMapper=new zy(Ke),Ke}).onUpdateObj(function(Ke,Se){var Fe=!!Ke.children.length&&Ke.children[0],mt=z(Se),Bt,Rt;if(mt)Bt=mt.geometry,Rt=mt.material;else{var hn=Math.ceil(V(Se)*10)/10/2,ri=e.linkDirectionalParticleResolution;Fe&&Fe.geometry.parameters.radius===hn&&Fe.geometry.parameters.widthSegments===ri?Bt=Fe.geometry:(se.hasOwnProperty(hn)||(se[hn]=new An.SphereGeometry(hn,ri,ri)),Bt=se[hn]);var re=U(Se)||M(Se)||"#f0f0f0",st=new An.Color(Vy(re)),it=e.linkOpacity*3;Fe&&Fe.material.color.equals(st)&&Fe.material.opacity===it?Rt=Fe.material:(j.hasOwnProperty(re)||(j[re]=new An.MeshLambertMaterial({color:st,transparent:!0,opacity:it})),Rt=j[re])}Fe&&(Fe.geometry!==Bt&&Fe.geometry.dispose(),Fe.material!==Rt&&Fe.material.dispose());var tt=Math.round(Math.abs(k(Se)));Ke.__photonDataMapper.id(function(Qe){return Qe.idx}).onCreateObj(function(){return new An.Mesh(Bt,Rt)}).onUpdateObj(function(Qe){Qe.geometry=Bt,Qe.material=Rt}).digest(Al(new Array(tt)).map(function(Qe,Mt){return{idx:Mt}}))}).digest(P.filter(k))}}if(e._flushObjects=!1,n(["graphData","nodeId","linkSource","linkTarget","numDimensions","forceEngine","dagMode","dagNodeFilter","dagLevelDistance"])){e.engineRunning=!1,e.graphData.links.forEach(function(Ke){Ke.source=Ke[e.linkSource],Ke.target=Ke[e.linkTarget]});var pe=e.forceEngine!=="ngraph",be;if(pe){(be=e.d3ForceLayout).stop().alpha(1).numDimensions(e.numDimensions).nodes(e.graphData.nodes);var Pe=e.d3ForceLayout.force("link");Pe&&Pe.id(function(Ke){return Ke[e.nodeId]}).links(e.graphData.links);var Ce=e.dagMode&&qB(e.graphData,function(Ke){return Ke[e.nodeId]},{nodeFilter:e.dagNodeFilter,onLoopError:e.onDagError||void 0}),nt=Math.max.apply(Math,Al(Object.values(Ce||[]))),Le=e.dagLevelDistance||e.graphData.nodes.length/(nt||1)*XB*(["radialin","radialout"].indexOf(e.dagMode)!==-1?.7:1);if(["lr","rl","td","bu","zin","zout"].includes(t.dagMode)){var ht=["lr","rl"].includes(t.dagMode)?"fx":["td","bu"].includes(t.dagMode)?"fy":"fz";e.graphData.nodes.filter(e.dagNodeFilter).forEach(function(Ke){return delete Ke[ht]})}if(["lr","rl","td","bu","zin","zout"].includes(e.dagMode)){var De=["rl","td","zout"].includes(e.dagMode),Je=function(Se){return(Ce[Se[e.nodeId]]-nt/2)*Le*(De?-1:1)},wt=["lr","rl"].includes(e.dagMode)?"fx":["td","bu"].includes(e.dagMode)?"fy":"fz";e.graphData.nodes.filter(e.dagNodeFilter).forEach(function(Ke){return Ke[wt]=Je(Ke)})}e.d3ForceLayout.force("dagRadial",["radialin","radialout"].indexOf(e.dagMode)!==-1?cx(function(Ke){var Se=Ce[Ke[e.nodeId]]||-1;return(e.dagMode==="radialin"?nt-Se:Se)*Le}).strength(function(Ke){return e.dagNodeFilter(Ke)?1:0}):null)}else{var Xt=QA.graph();e.graphData.nodes.forEach(function(Ke){Xt.addNode(Ke[e.nodeId])}),e.graphData.links.forEach(function(Ke){Xt.addLink(Ke.source,Ke.target)}),be=QA.forcelayout(Xt,VB({dimensions:e.numDimensions},e.ngraphPhysics)),be.graph=Xt}for(var Ln=0;Ln<e.warmupTicks&&!(pe&&e.d3AlphaMin>0&&e.d3ForceLayout.alpha()<e.d3AlphaMin);Ln++)be[pe?"tick":"step"]();e.layout=be,this.resetCountdown()}e.engineRunning=!0,e.onFinishUpdate()}});function YB(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;VA(this,o);for(var c=arguments.length,u=new Array(c),d=0;d<c;d++)u[d]=arguments[d];return a=zA(this,o,[].concat(u)),a.__kapsuleInstance=WA(i,[].concat(Al(t?[a]:[]),u)),a}return qA(o,r),$A(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 ZB=window.THREE?window.THREE:{Group:nr},eE=YB(jB,ZB.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 KB(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],M=m[x];M.start<=v.start+v.count+1?v.count=Math.max(v.count,M.start+M.count-v.start):(++y,m[y]=M)}m.length=y+1;for(let x=0,v=m.length;x<v;x++){const M=m[x];i.bufferSubData(d,M.start*p.BYTES_PER_ELEMENT,p,M.start,M.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 JB=`#ifdef USE_ALPHAHASH
|
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
#endif`,QB=`#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`,eO=`#ifdef USE_ALPHAMAP
|
|
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
|
#endif`,tO=`#ifdef USE_ALPHAMAP
|
|
uniform sampler2D alphaMap;
|
|
#endif`,nO=`#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`,iO=`#ifdef USE_ALPHATEST
|
|
uniform float alphaTest;
|
|
#endif`,sO=`#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`,rO=`#ifdef USE_AOMAP
|
|
uniform sampler2D aoMap;
|
|
uniform float aoMapIntensity;
|
|
#endif`,oO=`#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`,aO=`#ifdef USE_BATCHING
|
|
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
|
#endif`,lO=`vec3 transformed = vec3( position );
|
|
#ifdef USE_ALPHAHASH
|
|
vPosition = vec3( position );
|
|
#endif`,cO=`vec3 objectNormal = vec3( normal );
|
|
#ifdef USE_TANGENT
|
|
vec3 objectTangent = vec3( tangent.xyz );
|
|
#endif`,uO=`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`,hO=`#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`,dO=`#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`,fO=`#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`,pO=`#if NUM_CLIPPING_PLANES > 0
|
|
varying vec3 vClipPosition;
|
|
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
|
#endif`,mO=`#if NUM_CLIPPING_PLANES > 0
|
|
varying vec3 vClipPosition;
|
|
#endif`,gO=`#if NUM_CLIPPING_PLANES > 0
|
|
vClipPosition = - mvPosition.xyz;
|
|
#endif`,yO=`#if defined( USE_COLOR_ALPHA )
|
|
diffuseColor *= vColor;
|
|
#elif defined( USE_COLOR )
|
|
diffuseColor.rgb *= vColor;
|
|
#endif`,_O=`#if defined( USE_COLOR_ALPHA )
|
|
varying vec4 vColor;
|
|
#elif defined( USE_COLOR )
|
|
varying vec3 vColor;
|
|
#endif`,xO=`#if defined( USE_COLOR_ALPHA )
|
|
varying vec4 vColor;
|
|
#elif defined( USE_COLOR ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
varying vec3 vColor;
|
|
#endif`,vO=`#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`,bO=`#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 );
|
|
}
|
|
mat3 transposeMat3( const in mat3 m ) {
|
|
mat3 tmp;
|
|
tmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );
|
|
tmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );
|
|
tmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );
|
|
return tmp;
|
|
}
|
|
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`,SO=`#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`,TO=`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`,wO=`#ifdef USE_DISPLACEMENTMAP
|
|
uniform sampler2D displacementMap;
|
|
uniform float displacementScale;
|
|
uniform float displacementBias;
|
|
#endif`,MO=`#ifdef USE_DISPLACEMENTMAP
|
|
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
|
#endif`,AO=`#ifdef USE_EMISSIVEMAP
|
|
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
|
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
|
|
emissiveColor = sRGBTransferEOTF( emissiveColor );
|
|
#endif
|
|
totalEmissiveRadiance *= emissiveColor.rgb;
|
|
#endif`,EO=`#ifdef USE_EMISSIVEMAP
|
|
uniform sampler2D emissiveMap;
|
|
#endif`,CO="gl_FragColor = linearToOutputTexel( gl_FragColor );",RO=`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 );
|
|
}`,NO=`#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`,PO=`#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`,IO=`#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`,LO=`#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`,DO=`#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`,FO=`#ifdef USE_FOG
|
|
vFogDepth = - mvPosition.z;
|
|
#endif`,BO=`#ifdef USE_FOG
|
|
varying float vFogDepth;
|
|
#endif`,OO=`#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`,UO=`#ifdef USE_FOG
|
|
uniform vec3 fogColor;
|
|
varying float vFogDepth;
|
|
#ifdef FOG_EXP2
|
|
uniform float fogDensity;
|
|
#else
|
|
uniform float fogNear;
|
|
uniform float fogFar;
|
|
#endif
|
|
#endif`,kO=`#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
|
|
}`,zO=`#ifdef USE_LIGHTMAP
|
|
uniform sampler2D lightMap;
|
|
uniform float lightMapIntensity;
|
|
#endif`,VO=`LambertMaterial material;
|
|
material.diffuseColor = diffuseColor.rgb;
|
|
material.specularStrength = specularStrength;`,GO=`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`,HO=`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`,WO=`#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, roughness * 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`,$O=`ToonMaterial material;
|
|
material.diffuseColor = diffuseColor.rgb;`,qO=`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`,XO=`BlinnPhongMaterial material;
|
|
material.diffuseColor = diffuseColor.rgb;
|
|
material.specularColor = specular;
|
|
material.specularShininess = shininess;
|
|
material.specularStrength = specularStrength;`,jO=`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`,YO=`PhysicalMaterial material;
|
|
material.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
|
vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) );
|
|
float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );
|
|
material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness;
|
|
material.roughness = min( material.roughness, 1.0 );
|
|
#ifdef IOR
|
|
material.ior = ior;
|
|
#ifdef USE_SPECULAR
|
|
float specularIntensityFactor = specularIntensity;
|
|
vec3 specularColorFactor = specularColor;
|
|
#ifdef USE_SPECULAR_COLORMAP
|
|
specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb;
|
|
#endif
|
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a;
|
|
#endif
|
|
material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor );
|
|
#else
|
|
float specularIntensityFactor = 1.0;
|
|
vec3 specularColorFactor = vec3( 1.0 );
|
|
material.specularF90 = 1.0;
|
|
#endif
|
|
material.specularColor = mix( min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor, diffuseColor.rgb, metalnessFactor );
|
|
#else
|
|
material.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );
|
|
material.specularF90 = 1.0;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
material.clearcoat = clearcoat;
|
|
material.clearcoatRoughness = clearcoatRoughness;
|
|
material.clearcoatF0 = vec3( 0.04 );
|
|
material.clearcoatF90 = 1.0;
|
|
#ifdef USE_CLEARCOATMAP
|
|
material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y;
|
|
#endif
|
|
material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );
|
|
material.clearcoatRoughness += geometryRoughness;
|
|
material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );
|
|
#endif
|
|
#ifdef USE_DISPERSION
|
|
material.dispersion = dispersion;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE
|
|
material.iridescence = iridescence;
|
|
material.iridescenceIOR = iridescenceIOR;
|
|
#ifdef USE_IRIDESCENCEMAP
|
|
material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum;
|
|
#else
|
|
material.iridescenceThickness = iridescenceThicknessMaximum;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
material.sheenColor = sheenColor;
|
|
#ifdef USE_SHEEN_COLORMAP
|
|
material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb;
|
|
#endif
|
|
material.sheenRoughness = clamp( sheenRoughness, 0.07, 1.0 );
|
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_ANISOTROPY
|
|
#ifdef USE_ANISOTROPYMAP
|
|
mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x );
|
|
vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb;
|
|
vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b;
|
|
#else
|
|
vec2 anisotropyV = anisotropyVector;
|
|
#endif
|
|
material.anisotropy = length( anisotropyV );
|
|
if( material.anisotropy == 0.0 ) {
|
|
anisotropyV = vec2( 1.0, 0.0 );
|
|
} else {
|
|
anisotropyV /= material.anisotropy;
|
|
material.anisotropy = saturate( material.anisotropy );
|
|
}
|
|
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
|
|
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
|
|
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
|
|
#endif`,ZO=`struct PhysicalMaterial {
|
|
vec3 diffuseColor;
|
|
float roughness;
|
|
vec3 specularColor;
|
|
float specularF90;
|
|
float dispersion;
|
|
#ifdef USE_CLEARCOAT
|
|
float clearcoat;
|
|
float clearcoatRoughness;
|
|
vec3 clearcoatF0;
|
|
float clearcoatF90;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE
|
|
float iridescence;
|
|
float iridescenceIOR;
|
|
float iridescenceThickness;
|
|
vec3 iridescenceFresnel;
|
|
vec3 iridescenceF0;
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
vec3 sheenColor;
|
|
float sheenRoughness;
|
|
#endif
|
|
#ifdef IOR
|
|
float ior;
|
|
#endif
|
|
#ifdef USE_TRANSMISSION
|
|
float transmission;
|
|
float transmissionAlpha;
|
|
float thickness;
|
|
float attenuationDistance;
|
|
vec3 attenuationColor;
|
|
#endif
|
|
#ifdef USE_ANISOTROPY
|
|
float anisotropy;
|
|
float alphaT;
|
|
vec3 anisotropyT;
|
|
vec3 anisotropyB;
|
|
#endif
|
|
};
|
|
vec3 clearcoatSpecularDirect = vec3( 0.0 );
|
|
vec3 clearcoatSpecularIndirect = vec3( 0.0 );
|
|
vec3 sheenSpecularDirect = vec3( 0.0 );
|
|
vec3 sheenSpecularIndirect = vec3(0.0 );
|
|
vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) {
|
|
float x = clamp( 1.0 - dotVH, 0.0, 1.0 );
|
|
float x2 = x * x;
|
|
float x5 = clamp( x * x2 * x2, 0.0, 0.9999 );
|
|
return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 );
|
|
}
|
|
float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {
|
|
float a2 = pow2( alpha );
|
|
float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );
|
|
float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );
|
|
return 0.5 / max( gv + gl, EPSILON );
|
|
}
|
|
float D_GGX( const in float alpha, const in float dotNH ) {
|
|
float a2 = pow2( alpha );
|
|
float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;
|
|
return RECIPROCAL_PI * a2 / pow2( denom );
|
|
}
|
|
#ifdef USE_ANISOTROPY
|
|
float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) {
|
|
float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) );
|
|
float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) );
|
|
float v = 0.5 / ( gv + gl );
|
|
return saturate(v);
|
|
}
|
|
float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) {
|
|
float a2 = alphaT * alphaB;
|
|
highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH );
|
|
highp float v2 = dot( v, v );
|
|
float w2 = a2 / v2;
|
|
return RECIPROCAL_PI * a2 * pow2 ( w2 );
|
|
}
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) {
|
|
vec3 f0 = material.clearcoatF0;
|
|
float f90 = material.clearcoatF90;
|
|
float roughness = material.clearcoatRoughness;
|
|
float alpha = pow2( roughness );
|
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|
float dotNL = saturate( dot( normal, lightDir ) );
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
float dotNH = saturate( dot( normal, halfDir ) );
|
|
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|
vec3 F = F_Schlick( f0, f90, dotVH );
|
|
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
|
float D = D_GGX( alpha, dotNH );
|
|
return F * ( V * D );
|
|
}
|
|
#endif
|
|
vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) {
|
|
vec3 f0 = material.specularColor;
|
|
float f90 = material.specularF90;
|
|
float roughness = material.roughness;
|
|
float alpha = pow2( roughness );
|
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|
float dotNL = saturate( dot( normal, lightDir ) );
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
float dotNH = saturate( dot( normal, halfDir ) );
|
|
float dotVH = saturate( dot( viewDir, halfDir ) );
|
|
vec3 F = F_Schlick( f0, f90, dotVH );
|
|
#ifdef USE_IRIDESCENCE
|
|
F = mix( F, material.iridescenceFresnel, material.iridescence );
|
|
#endif
|
|
#ifdef USE_ANISOTROPY
|
|
float dotTL = dot( material.anisotropyT, lightDir );
|
|
float dotTV = dot( material.anisotropyT, viewDir );
|
|
float dotTH = dot( material.anisotropyT, halfDir );
|
|
float dotBL = dot( material.anisotropyB, lightDir );
|
|
float dotBV = dot( material.anisotropyB, viewDir );
|
|
float dotBH = dot( material.anisotropyB, halfDir );
|
|
float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL );
|
|
float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH );
|
|
#else
|
|
float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV );
|
|
float D = D_GGX( alpha, dotNH );
|
|
#endif
|
|
return F * ( V * D );
|
|
}
|
|
vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {
|
|
const float LUT_SIZE = 64.0;
|
|
const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;
|
|
const float LUT_BIAS = 0.5 / LUT_SIZE;
|
|
float dotNV = saturate( dot( N, V ) );
|
|
vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );
|
|
uv = uv * LUT_SCALE + LUT_BIAS;
|
|
return uv;
|
|
}
|
|
float LTC_ClippedSphereFormFactor( const in vec3 f ) {
|
|
float l = length( f );
|
|
return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );
|
|
}
|
|
vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {
|
|
float x = dot( v1, v2 );
|
|
float y = abs( x );
|
|
float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;
|
|
float b = 3.4175940 + ( 4.1616724 + y ) * y;
|
|
float v = a / b;
|
|
float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;
|
|
return cross( v1, v2 ) * theta_sintheta;
|
|
}
|
|
vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {
|
|
vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];
|
|
vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];
|
|
vec3 lightNormal = cross( v1, v2 );
|
|
if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );
|
|
vec3 T1, T2;
|
|
T1 = normalize( V - N * dot( V, N ) );
|
|
T2 = - cross( N, T1 );
|
|
mat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );
|
|
vec3 coords[ 4 ];
|
|
coords[ 0 ] = mat * ( rectCoords[ 0 ] - P );
|
|
coords[ 1 ] = mat * ( rectCoords[ 1 ] - P );
|
|
coords[ 2 ] = mat * ( rectCoords[ 2 ] - P );
|
|
coords[ 3 ] = mat * ( rectCoords[ 3 ] - P );
|
|
coords[ 0 ] = normalize( coords[ 0 ] );
|
|
coords[ 1 ] = normalize( coords[ 1 ] );
|
|
coords[ 2 ] = normalize( coords[ 2 ] );
|
|
coords[ 3 ] = normalize( coords[ 3 ] );
|
|
vec3 vectorFormFactor = vec3( 0.0 );
|
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );
|
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );
|
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );
|
|
vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );
|
|
float result = LTC_ClippedSphereFormFactor( vectorFormFactor );
|
|
return vec3( result );
|
|
}
|
|
#if defined( USE_SHEEN )
|
|
float D_Charlie( float roughness, float dotNH ) {
|
|
float alpha = pow2( roughness );
|
|
float invAlpha = 1.0 / alpha;
|
|
float cos2h = dotNH * dotNH;
|
|
float sin2h = max( 1.0 - cos2h, 0.0078125 );
|
|
return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI );
|
|
}
|
|
float V_Neubelt( float dotNV, float dotNL ) {
|
|
return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) );
|
|
}
|
|
vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) {
|
|
vec3 halfDir = normalize( lightDir + viewDir );
|
|
float dotNL = saturate( dot( normal, lightDir ) );
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
float dotNH = saturate( dot( normal, halfDir ) );
|
|
float D = D_Charlie( sheenRoughness, dotNH );
|
|
float V = V_Neubelt( dotNV, dotNL );
|
|
return sheenColor * ( D * V );
|
|
}
|
|
#endif
|
|
float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
float r2 = roughness * roughness;
|
|
float a = roughness < 0.25 ? -339.2 * r2 + 161.4 * roughness - 25.9 : -8.48 * r2 + 14.3 * roughness - 9.95;
|
|
float b = roughness < 0.25 ? 44.0 * r2 - 23.7 * roughness + 3.26 : 1.97 * r2 - 3.27 * roughness + 0.72;
|
|
float DG = exp( a * dotNV + b ) + ( roughness < 0.25 ? 0.0 : 0.1 * ( roughness - 0.25 ) );
|
|
return saturate( DG * RECIPROCAL_PI );
|
|
}
|
|
vec2 DFGApprox( const in vec3 normal, const in vec3 viewDir, const in float roughness ) {
|
|
float dotNV = saturate( dot( normal, viewDir ) );
|
|
const vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
|
|
const vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );
|
|
vec4 r = roughness * c0 + c1;
|
|
float a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;
|
|
vec2 fab = vec2( - 1.04, 1.04 ) * a004 + r.zw;
|
|
return fab;
|
|
}
|
|
vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) {
|
|
vec2 fab = DFGApprox( normal, viewDir, roughness );
|
|
return specularColor * fab.x + specularF90 * fab.y;
|
|
}
|
|
#ifdef USE_IRIDESCENCE
|
|
void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
|
|
#else
|
|
void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {
|
|
#endif
|
|
vec2 fab = DFGApprox( normal, viewDir, roughness );
|
|
#ifdef USE_IRIDESCENCE
|
|
vec3 Fr = mix( specularColor, iridescenceF0, iridescence );
|
|
#else
|
|
vec3 Fr = specularColor;
|
|
#endif
|
|
vec3 FssEss = Fr * fab.x + specularF90 * fab.y;
|
|
float Ess = fab.x + fab.y;
|
|
float Ems = 1.0 - Ess;
|
|
vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );
|
|
singleScatter += FssEss;
|
|
multiScatter += Fms * Ems;
|
|
}
|
|
#if NUM_RECT_AREA_LIGHTS > 0
|
|
void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
vec3 normal = geometryNormal;
|
|
vec3 viewDir = geometryViewDir;
|
|
vec3 position = geometryPosition;
|
|
vec3 lightPos = rectAreaLight.position;
|
|
vec3 halfWidth = rectAreaLight.halfWidth;
|
|
vec3 halfHeight = rectAreaLight.halfHeight;
|
|
vec3 lightColor = rectAreaLight.color;
|
|
float roughness = material.roughness;
|
|
vec3 rectCoords[ 4 ];
|
|
rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight;
|
|
rectCoords[ 2 ] = lightPos - halfWidth + halfHeight;
|
|
rectCoords[ 3 ] = lightPos + halfWidth + halfHeight;
|
|
vec2 uv = LTC_Uv( normal, viewDir, roughness );
|
|
vec4 t1 = texture2D( ltc_1, uv );
|
|
vec4 t2 = texture2D( ltc_2, uv );
|
|
mat3 mInv = mat3(
|
|
vec3( t1.x, 0, t1.y ),
|
|
vec3( 0, 1, 0 ),
|
|
vec3( t1.z, 0, t1.w )
|
|
);
|
|
vec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );
|
|
reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );
|
|
reflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );
|
|
}
|
|
#endif
|
|
void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
float dotNL = saturate( dot( geometryNormal, directLight.direction ) );
|
|
vec3 irradiance = dotNL * directLight.color;
|
|
#ifdef USE_CLEARCOAT
|
|
float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) );
|
|
vec3 ccIrradiance = dotNLcc * directLight.color;
|
|
clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material );
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness );
|
|
#endif
|
|
reflectedLight.directSpecular += irradiance * BRDF_GGX( directLight.direction, geometryViewDir, geometryNormal, material );
|
|
reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {
|
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
}
|
|
void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {
|
|
#ifdef USE_CLEARCOAT
|
|
clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness );
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness );
|
|
#endif
|
|
vec3 singleScattering = vec3( 0.0 );
|
|
vec3 multiScattering = vec3( 0.0 );
|
|
vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;
|
|
#ifdef USE_IRIDESCENCE
|
|
computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnel, material.roughness, singleScattering, multiScattering );
|
|
#else
|
|
computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScattering, multiScattering );
|
|
#endif
|
|
vec3 totalScattering = singleScattering + multiScattering;
|
|
vec3 diffuse = material.diffuseColor * ( 1.0 - max( max( totalScattering.r, totalScattering.g ), totalScattering.b ) );
|
|
reflectedLight.indirectSpecular += radiance * singleScattering;
|
|
reflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;
|
|
reflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;
|
|
}
|
|
#define RE_Direct RE_Direct_Physical
|
|
#define RE_Direct_RectArea RE_Direct_RectArea_Physical
|
|
#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical
|
|
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
|
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
|
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
|
}`,KO=`
|
|
vec3 geometryPosition = - vViewPosition;
|
|
vec3 geometryNormal = normal;
|
|
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
vec3 geometryClearcoatNormal = vec3( 0.0 );
|
|
#ifdef USE_CLEARCOAT
|
|
geometryClearcoatNormal = clearcoatNormal;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE
|
|
float dotNVi = saturate( dot( normal, geometryViewDir ) );
|
|
if ( material.iridescenceThickness == 0.0 ) {
|
|
material.iridescence = 0.0;
|
|
} else {
|
|
material.iridescence = saturate( material.iridescence );
|
|
}
|
|
if ( material.iridescence > 0.0 ) {
|
|
material.iridescenceFresnel = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor );
|
|
material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi );
|
|
}
|
|
#endif
|
|
IncidentLight directLight;
|
|
#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )
|
|
PointLight pointLight;
|
|
#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0
|
|
PointLightShadow pointLightShadow;
|
|
#endif
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {
|
|
pointLight = pointLights[ i ];
|
|
getPointLightInfo( pointLight, geometryPosition, directLight );
|
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )
|
|
pointLightShadow = pointLightShadows[ i ];
|
|
directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;
|
|
#endif
|
|
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )
|
|
SpotLight spotLight;
|
|
vec4 spotColor;
|
|
vec3 spotLightCoord;
|
|
bool inSpotLightMap;
|
|
#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0
|
|
SpotLightShadow spotLightShadow;
|
|
#endif
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {
|
|
spotLight = spotLights[ i ];
|
|
getSpotLightInfo( spotLight, geometryPosition, directLight );
|
|
#if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
|
#define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX
|
|
#elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
#define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS
|
|
#else
|
|
#define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS )
|
|
#endif
|
|
#if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS )
|
|
spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w;
|
|
inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) );
|
|
spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy );
|
|
directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color;
|
|
#endif
|
|
#undef SPOT_LIGHT_MAP_INDEX
|
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
|
|
spotLightShadow = spotLightShadows[ i ];
|
|
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
|
#endif
|
|
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )
|
|
DirectionalLight directionalLight;
|
|
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
|
|
DirectionalLightShadow directionalLightShadow;
|
|
#endif
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {
|
|
directionalLight = directionalLights[ i ];
|
|
getDirectionalLightInfo( directionalLight, directLight );
|
|
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )
|
|
directionalLightShadow = directionalLightShadows[ i ];
|
|
directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
|
#endif
|
|
RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )
|
|
RectAreaLight rectAreaLight;
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {
|
|
rectAreaLight = rectAreaLights[ i ];
|
|
RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if defined( RE_IndirectDiffuse )
|
|
vec3 iblIrradiance = vec3( 0.0 );
|
|
vec3 irradiance = getAmbientLightIrradiance( ambientLightColor );
|
|
#if defined( USE_LIGHT_PROBES )
|
|
irradiance += getLightProbeIrradiance( lightProbe, geometryNormal );
|
|
#endif
|
|
#if ( NUM_HEMI_LIGHTS > 0 )
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {
|
|
irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal );
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#endif
|
|
#if defined( RE_IndirectSpecular )
|
|
vec3 radiance = vec3( 0.0 );
|
|
vec3 clearcoatRadiance = vec3( 0.0 );
|
|
#endif`,JO=`#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`,QO=`#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`,eU=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
|
#endif`,tU=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
uniform float logDepthBufFC;
|
|
varying float vFragDepth;
|
|
varying float vIsPerspective;
|
|
#endif`,nU=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
varying float vFragDepth;
|
|
varying float vIsPerspective;
|
|
#endif`,iU=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
vFragDepth = 1.0 + gl_Position.w;
|
|
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
#endif`,sU=`#ifdef USE_MAP
|
|
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|
#ifdef DECODE_VIDEO_TEXTURE
|
|
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
|
|
#endif
|
|
diffuseColor *= sampledDiffuseColor;
|
|
#endif`,rU=`#ifdef USE_MAP
|
|
uniform sampler2D map;
|
|
#endif`,oU=`#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`,aU=`#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`,lU=`float metalnessFactor = metalness;
|
|
#ifdef USE_METALNESSMAP
|
|
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
|
metalnessFactor *= texelMetalness.b;
|
|
#endif`,cU=`#ifdef USE_METALNESSMAP
|
|
uniform sampler2D metalnessMap;
|
|
#endif`,uU=`#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`,hU=`#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`,dU=`#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`,fU=`#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`,pU=`#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`,mU=`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;`,gU=`#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`,yU=`#ifndef FLAT_SHADED
|
|
varying vec3 vNormal;
|
|
#ifdef USE_TANGENT
|
|
varying vec3 vTangent;
|
|
varying vec3 vBitangent;
|
|
#endif
|
|
#endif`,_U=`#ifndef FLAT_SHADED
|
|
varying vec3 vNormal;
|
|
#ifdef USE_TANGENT
|
|
varying vec3 vTangent;
|
|
varying vec3 vBitangent;
|
|
#endif
|
|
#endif`,xU=`#ifndef FLAT_SHADED
|
|
vNormal = normalize( transformedNormal );
|
|
#ifdef USE_TANGENT
|
|
vTangent = normalize( transformedTangent );
|
|
vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );
|
|
#endif
|
|
#endif`,vU=`#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`,bU=`#ifdef USE_CLEARCOAT
|
|
vec3 clearcoatNormal = nonPerturbedNormal;
|
|
#endif`,SU=`#ifdef USE_CLEARCOAT_NORMALMAP
|
|
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
|
clearcoatMapN.xy *= clearcoatNormalScale;
|
|
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
|
#endif`,TU=`#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`,wU=`#ifdef USE_IRIDESCENCEMAP
|
|
uniform sampler2D iridescenceMap;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
uniform sampler2D iridescenceThicknessMap;
|
|
#endif`,MU=`#ifdef OPAQUE
|
|
diffuseColor.a = 1.0;
|
|
#endif
|
|
#ifdef USE_TRANSMISSION
|
|
diffuseColor.a *= material.transmissionAlpha;
|
|
#endif
|
|
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,AU=`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 );
|
|
}`,EU=`#ifdef PREMULTIPLIED_ALPHA
|
|
gl_FragColor.rgb *= gl_FragColor.a;
|
|
#endif`,CU=`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;`,RU=`#ifdef DITHERING
|
|
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|
#endif`,NU=`#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`,PU=`float roughnessFactor = roughness;
|
|
#ifdef USE_ROUGHNESSMAP
|
|
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
|
roughnessFactor *= texelRoughness.g;
|
|
#endif`,IU=`#ifdef USE_ROUGHNESSMAP
|
|
uniform sampler2D roughnessMap;
|
|
#endif`,LU=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
#endif
|
|
#if NUM_SPOT_LIGHT_MAPS > 0
|
|
uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ];
|
|
#endif
|
|
#ifdef USE_SHADOWMAP
|
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
|
|
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
|
struct DirectionalLightShadow {
|
|
float shadowIntensity;
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
};
|
|
uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];
|
|
#endif
|
|
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
struct SpotLightShadow {
|
|
float shadowIntensity;
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
};
|
|
uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
#endif
|
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
uniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
|
|
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
|
struct PointLightShadow {
|
|
float shadowIntensity;
|
|
float shadowBias;
|
|
float shadowNormalBias;
|
|
float shadowRadius;
|
|
vec2 shadowMapSize;
|
|
float shadowCameraNear;
|
|
float shadowCameraFar;
|
|
};
|
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
#endif
|
|
float texture2DCompare( sampler2D depths, vec2 uv, float compare ) {
|
|
float depth = unpackRGBAToDepth( texture2D( depths, uv ) );
|
|
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
return step( depth, compare );
|
|
#else
|
|
return step( compare, depth );
|
|
#endif
|
|
}
|
|
vec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {
|
|
return unpackRGBATo2Half( texture2D( shadow, uv ) );
|
|
}
|
|
float VSMShadow( sampler2D shadow, vec2 uv, float compare ) {
|
|
float occlusion = 1.0;
|
|
vec2 distribution = texture2DDistribution( shadow, uv );
|
|
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
float hard_shadow = step( distribution.x, compare );
|
|
#else
|
|
float hard_shadow = step( compare, distribution.x );
|
|
#endif
|
|
if ( hard_shadow != 1.0 ) {
|
|
float distance = compare - distribution.x;
|
|
float variance = max( 0.00000, distribution.y * distribution.y );
|
|
float softness_probability = variance / (variance + distance * distance ); softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
|
|
}
|
|
return occlusion;
|
|
}
|
|
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
|
float shadow = 1.0;
|
|
shadowCoord.xyz /= shadowCoord.w;
|
|
shadowCoord.z += shadowBias;
|
|
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
|
|
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
|
|
if ( frustumTest ) {
|
|
#if defined( SHADOWMAP_TYPE_PCF )
|
|
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
|
float dx0 = - texelSize.x * shadowRadius;
|
|
float dy0 = - texelSize.y * shadowRadius;
|
|
float dx1 = + texelSize.x * shadowRadius;
|
|
float dy1 = + texelSize.y * shadowRadius;
|
|
float dx2 = dx0 / 2.0;
|
|
float dy2 = dy0 / 2.0;
|
|
float dx3 = dx1 / 2.0;
|
|
float dy3 = dy1 / 2.0;
|
|
shadow = (
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
|
|
) * ( 1.0 / 17.0 );
|
|
#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
|
|
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
|
float dx = texelSize.x;
|
|
float dy = texelSize.y;
|
|
vec2 uv = shadowCoord.xy;
|
|
vec2 f = fract( uv * shadowMapSize + 0.5 );
|
|
uv -= f * texelSize;
|
|
shadow = (
|
|
texture2DCompare( shadowMap, uv, shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
|
|
texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
|
|
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
|
|
f.x ) +
|
|
mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
|
|
f.x ) +
|
|
mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
|
|
f.y ) +
|
|
mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
|
|
f.y ) +
|
|
mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
|
|
f.x ),
|
|
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
|
|
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
|
|
f.x ),
|
|
f.y )
|
|
) * ( 1.0 / 9.0 );
|
|
#elif defined( SHADOWMAP_TYPE_VSM )
|
|
shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
|
|
#else
|
|
shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
|
|
#endif
|
|
}
|
|
return mix( 1.0, shadow, shadowIntensity );
|
|
}
|
|
vec2 cubeToUV( vec3 v, float texelSizeY ) {
|
|
vec3 absV = abs( v );
|
|
float scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );
|
|
absV *= scaleToCube;
|
|
v *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );
|
|
vec2 planar = v.xy;
|
|
float almostATexel = 1.5 * texelSizeY;
|
|
float almostOne = 1.0 - almostATexel;
|
|
if ( absV.z >= almostOne ) {
|
|
if ( v.z > 0.0 )
|
|
planar.x = 4.0 - v.x;
|
|
} else if ( absV.x >= almostOne ) {
|
|
float signX = sign( v.x );
|
|
planar.x = v.z * signX + 2.0 * signX;
|
|
} else if ( absV.y >= almostOne ) {
|
|
float signY = sign( v.y );
|
|
planar.x = v.x + 2.0 * signY + 2.0;
|
|
planar.y = v.z * signY - 2.0;
|
|
}
|
|
return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
|
|
}
|
|
float getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
|
|
float shadow = 1.0;
|
|
vec3 lightToPosition = shadowCoord.xyz;
|
|
|
|
float lightToPositionLength = length( lightToPosition );
|
|
if ( lightToPositionLength - shadowCameraFar <= 0.0 && lightToPositionLength - shadowCameraNear >= 0.0 ) {
|
|
float dp = ( lightToPositionLength - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); dp += shadowBias;
|
|
vec3 bd3D = normalize( lightToPosition );
|
|
vec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );
|
|
#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )
|
|
vec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;
|
|
shadow = (
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
|
|
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
|
|
) * ( 1.0 / 9.0 );
|
|
#else
|
|
shadow = texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );
|
|
#endif
|
|
}
|
|
return mix( 1.0, shadow, shadowIntensity );
|
|
}
|
|
#endif`,DU=`#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`,FU=`#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`,BU=`float getShadowMask() {
|
|
float shadow = 1.0;
|
|
#ifdef USE_SHADOWMAP
|
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
DirectionalLightShadow directionalLight;
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {
|
|
directionalLight = directionalLightShadows[ i ];
|
|
shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
SpotLightShadow spotLight;
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {
|
|
spotLight = spotLightShadows[ i ];
|
|
shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
PointLightShadow pointLight;
|
|
#pragma unroll_loop_start
|
|
for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {
|
|
pointLight = pointLightShadows[ i ];
|
|
shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;
|
|
}
|
|
#pragma unroll_loop_end
|
|
#endif
|
|
#endif
|
|
return shadow;
|
|
}`,OU=`#ifdef USE_SKINNING
|
|
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
|
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
|
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
|
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
|
#endif`,UU=`#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`,kU=`#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`,zU=`#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`,VU=`float specularStrength;
|
|
#ifdef USE_SPECULARMAP
|
|
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
|
specularStrength = texelSpecular.r;
|
|
#else
|
|
specularStrength = 1.0;
|
|
#endif`,GU=`#ifdef USE_SPECULARMAP
|
|
uniform sampler2D specularMap;
|
|
#endif`,HU=`#if defined( TONE_MAPPING )
|
|
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
|
#endif`,WU=`#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; }`,$U=`#ifdef USE_TRANSMISSION
|
|
material.transmission = transmission;
|
|
material.transmissionAlpha = 1.0;
|
|
material.thickness = thickness;
|
|
material.attenuationDistance = attenuationDistance;
|
|
material.attenuationColor = attenuationColor;
|
|
#ifdef USE_TRANSMISSIONMAP
|
|
material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r;
|
|
#endif
|
|
#ifdef USE_THICKNESSMAP
|
|
material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g;
|
|
#endif
|
|
vec3 pos = vWorldPosition;
|
|
vec3 v = normalize( cameraPosition - pos );
|
|
vec3 n = inverseTransformDirection( normal, viewMatrix );
|
|
vec4 transmitted = getIBLVolumeRefraction(
|
|
n, v, material.roughness, material.diffuseColor, material.specularColor, material.specularF90,
|
|
pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
|
|
material.attenuationColor, material.attenuationDistance );
|
|
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
|
|
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
|
|
#endif`,qU=`#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`,XU=`#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`,jU=`#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`,YU=`#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`,ZU=`#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 Zn={alphahash_fragment:JB,alphahash_pars_fragment:QB,alphamap_fragment:eO,alphamap_pars_fragment:tO,alphatest_fragment:nO,alphatest_pars_fragment:iO,aomap_fragment:sO,aomap_pars_fragment:rO,batching_pars_vertex:oO,batching_vertex:aO,begin_vertex:lO,beginnormal_vertex:cO,bsdfs:uO,iridescence_fragment:hO,bumpmap_pars_fragment:dO,clipping_planes_fragment:fO,clipping_planes_pars_fragment:pO,clipping_planes_pars_vertex:mO,clipping_planes_vertex:gO,color_fragment:yO,color_pars_fragment:_O,color_pars_vertex:xO,color_vertex:vO,common:bO,cube_uv_reflection_fragment:SO,defaultnormal_vertex:TO,displacementmap_pars_vertex:wO,displacementmap_vertex:MO,emissivemap_fragment:AO,emissivemap_pars_fragment:EO,colorspace_fragment:CO,colorspace_pars_fragment:RO,envmap_fragment:NO,envmap_common_pars_fragment:PO,envmap_pars_fragment:IO,envmap_pars_vertex:LO,envmap_physical_pars_fragment:WO,envmap_vertex:DO,fog_vertex:FO,fog_pars_vertex:BO,fog_fragment:OO,fog_pars_fragment:UO,gradientmap_pars_fragment:kO,lightmap_pars_fragment:zO,lights_lambert_fragment:VO,lights_lambert_pars_fragment:GO,lights_pars_begin:HO,lights_toon_fragment:$O,lights_toon_pars_fragment:qO,lights_phong_fragment:XO,lights_phong_pars_fragment:jO,lights_physical_fragment:YO,lights_physical_pars_fragment:ZO,lights_fragment_begin:KO,lights_fragment_maps:JO,lights_fragment_end:QO,logdepthbuf_fragment:eU,logdepthbuf_pars_fragment:tU,logdepthbuf_pars_vertex:nU,logdepthbuf_vertex:iU,map_fragment:sU,map_pars_fragment:rU,map_particle_fragment:oU,map_particle_pars_fragment:aU,metalnessmap_fragment:lU,metalnessmap_pars_fragment:cU,morphinstance_vertex:uU,morphcolor_vertex:hU,morphnormal_vertex:dU,morphtarget_pars_vertex:fU,morphtarget_vertex:pU,normal_fragment_begin:mU,normal_fragment_maps:gU,normal_pars_fragment:yU,normal_pars_vertex:_U,normal_vertex:xU,normalmap_pars_fragment:vU,clearcoat_normal_fragment_begin:bU,clearcoat_normal_fragment_maps:SU,clearcoat_pars_fragment:TU,iridescence_pars_fragment:wU,opaque_fragment:MU,packing:AU,premultiplied_alpha_fragment:EU,project_vertex:CU,dithering_fragment:RU,dithering_pars_fragment:NU,roughnessmap_fragment:PU,roughnessmap_pars_fragment:IU,shadowmap_pars_fragment:LU,shadowmap_pars_vertex:DU,shadowmap_vertex:FU,shadowmask_pars_fragment:BU,skinbase_vertex:OU,skinning_pars_vertex:UU,skinning_vertex:kU,skinnormal_vertex:zU,specularmap_fragment:VU,specularmap_pars_fragment:GU,tonemapping_fragment:HU,tonemapping_pars_fragment:WU,transmission_fragment:$U,transmission_pars_fragment:qU,uv_pars_fragment:XU,uv_pars_vertex:jU,uv_vertex:YU,worldpos_vertex:ZU,background_vert:`varying vec2 vUv;
|
|
uniform mat3 uvTransform;
|
|
void main() {
|
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
|
}`,background_frag:`uniform sampler2D t2D;
|
|
uniform float backgroundIntensity;
|
|
varying vec2 vUv;
|
|
void main() {
|
|
vec4 texColor = texture2D( t2D, vUv );
|
|
#ifdef DECODE_VIDEO_TEXTURE
|
|
texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w );
|
|
#endif
|
|
texColor.rgb *= backgroundIntensity;
|
|
gl_FragColor = texColor;
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,backgroundCube_vert:`varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
gl_Position.z = gl_Position.w;
|
|
}`,backgroundCube_frag:`#ifdef ENVMAP_TYPE_CUBE
|
|
uniform samplerCube envMap;
|
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
uniform sampler2D envMap;
|
|
#endif
|
|
uniform float flipEnvMap;
|
|
uniform float backgroundBlurriness;
|
|
uniform float backgroundIntensity;
|
|
uniform mat3 backgroundRotation;
|
|
varying vec3 vWorldDirection;
|
|
#include <cube_uv_reflection_fragment>
|
|
void main() {
|
|
#ifdef ENVMAP_TYPE_CUBE
|
|
vec4 texColor = textureCube( envMap, backgroundRotation * vec3( flipEnvMap * vWorldDirection.x, vWorldDirection.yz ) );
|
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness );
|
|
#else
|
|
vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 );
|
|
#endif
|
|
texColor.rgb *= backgroundIntensity;
|
|
gl_FragColor = texColor;
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,cube_vert:`varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
gl_Position.z = gl_Position.w;
|
|
}`,cube_frag:`uniform samplerCube tCube;
|
|
uniform float tFlip;
|
|
uniform float opacity;
|
|
varying vec3 vWorldDirection;
|
|
void main() {
|
|
vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );
|
|
gl_FragColor = texColor;
|
|
gl_FragColor.a *= opacity;
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,depth_vert:`#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
varying vec2 vHighPrecisionZW;
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <batching_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <morphinstance_vertex>
|
|
#ifdef USE_DISPLACEMENTMAP
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinnormal_vertex>
|
|
#endif
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vHighPrecisionZW = gl_Position.zw;
|
|
}`,depth_frag:`#if DEPTH_PACKING == 3200
|
|
uniform float opacity;
|
|
#endif
|
|
#include <common>
|
|
#include <packing>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
varying vec2 vHighPrecisionZW;
|
|
void main() {
|
|
vec4 diffuseColor = vec4( 1.0 );
|
|
#include <clipping_planes_fragment>
|
|
#if DEPTH_PACKING == 3200
|
|
diffuseColor.a = opacity;
|
|
#endif
|
|
#include <map_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <logdepthbuf_fragment>
|
|
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ];
|
|
#else
|
|
float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5;
|
|
#endif
|
|
#if DEPTH_PACKING == 3200
|
|
gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );
|
|
#elif DEPTH_PACKING == 3201
|
|
gl_FragColor = packDepthToRGBA( fragCoordZ );
|
|
#elif DEPTH_PACKING == 3202
|
|
gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
|
|
#elif DEPTH_PACKING == 3203
|
|
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
|
|
#endif
|
|
}`,distanceRGBA_vert:`#define DISTANCE
|
|
varying vec3 vWorldPosition;
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <batching_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <morphinstance_vertex>
|
|
#ifdef USE_DISPLACEMENTMAP
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinnormal_vertex>
|
|
#endif
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vWorldPosition = worldPosition.xyz;
|
|
}`,distanceRGBA_frag:`#define DISTANCE
|
|
uniform vec3 referencePosition;
|
|
uniform float nearDistance;
|
|
uniform float farDistance;
|
|
varying vec3 vWorldPosition;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main () {
|
|
vec4 diffuseColor = vec4( 1.0 );
|
|
#include <clipping_planes_fragment>
|
|
#include <map_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
float dist = length( vWorldPosition - referencePosition );
|
|
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
|
dist = saturate( dist );
|
|
gl_FragColor = packDepthToRGBA( dist );
|
|
}`,equirect_vert:`varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
#include <begin_vertex>
|
|
#include <project_vertex>
|
|
}`,equirect_frag:`uniform sampler2D tEquirect;
|
|
varying vec3 vWorldDirection;
|
|
#include <common>
|
|
void main() {
|
|
vec3 direction = normalize( vWorldDirection );
|
|
vec2 sampleUV = equirectUv( direction );
|
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
}`,linedashed_vert:`uniform float scale;
|
|
attribute float lineDistance;
|
|
varying float vLineDistance;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
vLineDistance = scale * lineDistance;
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <fog_vertex>
|
|
}`,linedashed_frag:`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
uniform float dashSize;
|
|
uniform float totalSize;
|
|
varying float vLineDistance;
|
|
#include <common>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
if ( mod( vLineDistance, totalSize ) > dashSize ) {
|
|
discard;
|
|
}
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
outgoingLight = diffuseColor.rgb;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
}`,meshbasic_vert:`#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <envmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#if defined ( USE_ENVMAP ) || defined ( USE_SKINNING )
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#endif
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <envmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,meshbasic_frag:`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
#ifndef FLAT_SHADED
|
|
varying vec3 vNormal;
|
|
#endif
|
|
#include <common>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <specularmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <specularmap_fragment>
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
#ifdef USE_LIGHTMAP
|
|
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI;
|
|
#else
|
|
reflectedLight.indirectDiffuse += vec3( 1.0 );
|
|
#endif
|
|
#include <aomap_fragment>
|
|
reflectedLight.indirectDiffuse *= diffuseColor.rgb;
|
|
vec3 outgoingLight = reflectedLight.indirectDiffuse;
|
|
#include <envmap_fragment>
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,meshlambert_vert:`#define LAMBERT
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <envmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <envmap_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,meshlambert_frag:`#define LAMBERT
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_lambert_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <specularmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <specularmap_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_lambert_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|
#include <envmap_fragment>
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,meshmatcap_vert:`#define MATCAP
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <fog_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
}`,meshmatcap_frag:`#define MATCAP
|
|
uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
uniform sampler2D matcap;
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <normal_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
vec3 viewDir = normalize( vViewPosition );
|
|
vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );
|
|
vec3 y = cross( viewDir, x );
|
|
vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;
|
|
#ifdef USE_MATCAP
|
|
vec4 matcapColor = texture2D( matcap, uv );
|
|
#else
|
|
vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 );
|
|
#endif
|
|
vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,meshnormal_vert:`#define NORMAL
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
varying vec3 vViewPosition;
|
|
#endif
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
vViewPosition = - mvPosition.xyz;
|
|
#endif
|
|
}`,meshnormal_frag:`#define NORMAL
|
|
uniform float opacity;
|
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
varying vec3 vViewPosition;
|
|
#endif
|
|
#include <packing>
|
|
#include <uv_pars_fragment>
|
|
#include <normal_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity );
|
|
#include <clipping_planes_fragment>
|
|
#include <logdepthbuf_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
gl_FragColor = vec4( packNormalToRGB( normal ), diffuseColor.a );
|
|
#ifdef OPAQUE
|
|
gl_FragColor.a = 1.0;
|
|
#endif
|
|
}`,meshphong_vert:`#define PHONG
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <envmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <envmap_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,meshphong_frag:`#define PHONG
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform vec3 specular;
|
|
uniform float shininess;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_phong_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <specularmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <specularmap_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_phong_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;
|
|
#include <envmap_fragment>
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,meshphysical_vert:`#define STANDARD
|
|
varying vec3 vViewPosition;
|
|
#ifdef USE_TRANSMISSION
|
|
varying vec3 vWorldPosition;
|
|
#endif
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
#ifdef USE_TRANSMISSION
|
|
vWorldPosition = worldPosition.xyz;
|
|
#endif
|
|
}`,meshphysical_frag:`#define STANDARD
|
|
#ifdef PHYSICAL
|
|
#define IOR
|
|
#define USE_SPECULAR
|
|
#endif
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform float roughness;
|
|
uniform float metalness;
|
|
uniform float opacity;
|
|
#ifdef IOR
|
|
uniform float ior;
|
|
#endif
|
|
#ifdef USE_SPECULAR
|
|
uniform float specularIntensity;
|
|
uniform vec3 specularColor;
|
|
#ifdef USE_SPECULAR_COLORMAP
|
|
uniform sampler2D specularColorMap;
|
|
#endif
|
|
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
uniform sampler2D specularIntensityMap;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
uniform float clearcoat;
|
|
uniform float clearcoatRoughness;
|
|
#endif
|
|
#ifdef USE_DISPERSION
|
|
uniform float dispersion;
|
|
#endif
|
|
#ifdef USE_IRIDESCENCE
|
|
uniform float iridescence;
|
|
uniform float iridescenceIOR;
|
|
uniform float iridescenceThicknessMinimum;
|
|
uniform float iridescenceThicknessMaximum;
|
|
#endif
|
|
#ifdef USE_SHEEN
|
|
uniform vec3 sheenColor;
|
|
uniform float sheenRoughness;
|
|
#ifdef USE_SHEEN_COLORMAP
|
|
uniform sampler2D sheenColorMap;
|
|
#endif
|
|
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
uniform sampler2D sheenRoughnessMap;
|
|
#endif
|
|
#endif
|
|
#ifdef USE_ANISOTROPY
|
|
uniform vec2 anisotropyVector;
|
|
#ifdef USE_ANISOTROPYMAP
|
|
uniform sampler2D anisotropyMap;
|
|
#endif
|
|
#endif
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <iridescence_fragment>
|
|
#include <cube_uv_reflection_fragment>
|
|
#include <envmap_common_pars_fragment>
|
|
#include <envmap_physical_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_physical_pars_fragment>
|
|
#include <transmission_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <clearcoat_pars_fragment>
|
|
#include <iridescence_pars_fragment>
|
|
#include <roughnessmap_pars_fragment>
|
|
#include <metalnessmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <roughnessmap_fragment>
|
|
#include <metalnessmap_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <clearcoat_normal_fragment_begin>
|
|
#include <clearcoat_normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_physical_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
|
|
vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
|
|
#include <transmission_fragment>
|
|
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
|
|
#ifdef USE_SHEEN
|
|
float sheenEnergyComp = 1.0 - 0.157 * max3( material.sheenColor );
|
|
outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
|
|
#endif
|
|
#ifdef USE_CLEARCOAT
|
|
float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
|
|
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
|
|
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
|
|
#endif
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,meshtoon_vert:`#define TOON
|
|
varying vec3 vViewPosition;
|
|
#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <uv_pars_vertex>
|
|
#include <displacementmap_pars_vertex>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <normal_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <normal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <displacementmap_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
vViewPosition = - mvPosition.xyz;
|
|
#include <worldpos_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,meshtoon_frag:`#define TOON
|
|
uniform vec3 diffuse;
|
|
uniform vec3 emissive;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <dithering_pars_fragment>
|
|
#include <color_pars_fragment>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <aomap_pars_fragment>
|
|
#include <lightmap_pars_fragment>
|
|
#include <emissivemap_pars_fragment>
|
|
#include <gradientmap_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <normal_pars_fragment>
|
|
#include <lights_toon_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <bumpmap_pars_fragment>
|
|
#include <normalmap_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
vec3 totalEmissiveRadiance = emissive;
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <color_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
#include <normal_fragment_begin>
|
|
#include <normal_fragment_maps>
|
|
#include <emissivemap_fragment>
|
|
#include <lights_toon_fragment>
|
|
#include <lights_fragment_begin>
|
|
#include <lights_fragment_maps>
|
|
#include <lights_fragment_end>
|
|
#include <aomap_fragment>
|
|
vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
#include <dithering_fragment>
|
|
}`,points_vert:`uniform float size;
|
|
uniform float scale;
|
|
#include <common>
|
|
#include <color_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
#ifdef USE_POINTS_UV
|
|
varying vec2 vUv;
|
|
uniform mat3 uvTransform;
|
|
#endif
|
|
void main() {
|
|
#ifdef USE_POINTS_UV
|
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
#endif
|
|
#include <color_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphcolor_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <project_vertex>
|
|
gl_PointSize = size;
|
|
#ifdef USE_SIZEATTENUATION
|
|
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
|
if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );
|
|
#endif
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <fog_vertex>
|
|
}`,points_frag:`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <color_pars_fragment>
|
|
#include <map_particle_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_particle_fragment>
|
|
#include <color_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
outgoingLight = diffuseColor.rgb;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
#include <premultiplied_alpha_fragment>
|
|
}`,shadow_vert:`#include <common>
|
|
#include <batching_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <morphtarget_pars_vertex>
|
|
#include <skinning_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <shadowmap_pars_vertex>
|
|
void main() {
|
|
#include <batching_vertex>
|
|
#include <beginnormal_vertex>
|
|
#include <morphinstance_vertex>
|
|
#include <morphnormal_vertex>
|
|
#include <skinbase_vertex>
|
|
#include <skinnormal_vertex>
|
|
#include <defaultnormal_vertex>
|
|
#include <begin_vertex>
|
|
#include <morphtarget_vertex>
|
|
#include <skinning_vertex>
|
|
#include <project_vertex>
|
|
#include <logdepthbuf_vertex>
|
|
#include <worldpos_vertex>
|
|
#include <shadowmap_vertex>
|
|
#include <fog_vertex>
|
|
}`,shadow_frag:`uniform vec3 color;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <packing>
|
|
#include <fog_pars_fragment>
|
|
#include <bsdfs>
|
|
#include <lights_pars_begin>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <shadowmap_pars_fragment>
|
|
#include <shadowmask_pars_fragment>
|
|
void main() {
|
|
#include <logdepthbuf_fragment>
|
|
gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
}`,sprite_vert:`uniform float rotation;
|
|
uniform vec2 center;
|
|
#include <common>
|
|
#include <uv_pars_vertex>
|
|
#include <fog_pars_vertex>
|
|
#include <logdepthbuf_pars_vertex>
|
|
#include <clipping_planes_pars_vertex>
|
|
void main() {
|
|
#include <uv_vertex>
|
|
vec4 mvPosition = modelViewMatrix[ 3 ];
|
|
vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) );
|
|
#ifndef USE_SIZEATTENUATION
|
|
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
|
|
if ( isPerspective ) scale *= - mvPosition.z;
|
|
#endif
|
|
vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;
|
|
vec2 rotatedPosition;
|
|
rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
|
|
rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
|
|
mvPosition.xy += rotatedPosition;
|
|
gl_Position = projectionMatrix * mvPosition;
|
|
#include <logdepthbuf_vertex>
|
|
#include <clipping_planes_vertex>
|
|
#include <fog_vertex>
|
|
}`,sprite_frag:`uniform vec3 diffuse;
|
|
uniform float opacity;
|
|
#include <common>
|
|
#include <uv_pars_fragment>
|
|
#include <map_pars_fragment>
|
|
#include <alphamap_pars_fragment>
|
|
#include <alphatest_pars_fragment>
|
|
#include <alphahash_pars_fragment>
|
|
#include <fog_pars_fragment>
|
|
#include <logdepthbuf_pars_fragment>
|
|
#include <clipping_planes_pars_fragment>
|
|
void main() {
|
|
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
#include <clipping_planes_fragment>
|
|
vec3 outgoingLight = vec3( 0.0 );
|
|
#include <logdepthbuf_fragment>
|
|
#include <map_fragment>
|
|
#include <alphamap_fragment>
|
|
#include <alphatest_fragment>
|
|
#include <alphahash_fragment>
|
|
outgoingLight = diffuseColor.rgb;
|
|
#include <opaque_fragment>
|
|
#include <tonemapping_fragment>
|
|
#include <colorspace_fragment>
|
|
#include <fog_fragment>
|
|
}`},Ut={common:{diffuse:{value:new At(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Cn},alphaMap:{value:null},alphaMapTransform:{value:new Cn},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Cn}},envmap:{envMap:{value:null},envMapRotation:{value:new Cn},flipEnvMap:{value:-1},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Cn}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Cn}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Cn},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Cn},normalScale:{value:new Ie(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Cn},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Cn}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Cn}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Cn}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new At(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 At(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Cn},alphaTest:{value:0},uvTransform:{value:new Cn}},sprite:{diffuse:{value:new At(16777215)},opacity:{value:1},center:{value:new Ie(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Cn},alphaMap:{value:null},alphaMapTransform:{value:new Cn},alphaTest:{value:0}}},ac={basic:{uniforms:Zs([Ut.common,Ut.specularmap,Ut.envmap,Ut.aomap,Ut.lightmap,Ut.fog]),vertexShader:Zn.meshbasic_vert,fragmentShader:Zn.meshbasic_frag},lambert:{uniforms:Zs([Ut.common,Ut.specularmap,Ut.envmap,Ut.aomap,Ut.lightmap,Ut.emissivemap,Ut.bumpmap,Ut.normalmap,Ut.displacementmap,Ut.fog,Ut.lights,{emissive:{value:new At(0)}}]),vertexShader:Zn.meshlambert_vert,fragmentShader:Zn.meshlambert_frag},phong:{uniforms:Zs([Ut.common,Ut.specularmap,Ut.envmap,Ut.aomap,Ut.lightmap,Ut.emissivemap,Ut.bumpmap,Ut.normalmap,Ut.displacementmap,Ut.fog,Ut.lights,{emissive:{value:new At(0)},specular:{value:new At(1118481)},shininess:{value:30}}]),vertexShader:Zn.meshphong_vert,fragmentShader:Zn.meshphong_frag},standard:{uniforms:Zs([Ut.common,Ut.envmap,Ut.aomap,Ut.lightmap,Ut.emissivemap,Ut.bumpmap,Ut.normalmap,Ut.displacementmap,Ut.roughnessmap,Ut.metalnessmap,Ut.fog,Ut.lights,{emissive:{value:new At(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Zn.meshphysical_vert,fragmentShader:Zn.meshphysical_frag},toon:{uniforms:Zs([Ut.common,Ut.aomap,Ut.lightmap,Ut.emissivemap,Ut.bumpmap,Ut.normalmap,Ut.displacementmap,Ut.gradientmap,Ut.fog,Ut.lights,{emissive:{value:new At(0)}}]),vertexShader:Zn.meshtoon_vert,fragmentShader:Zn.meshtoon_frag},matcap:{uniforms:Zs([Ut.common,Ut.bumpmap,Ut.normalmap,Ut.displacementmap,Ut.fog,{matcap:{value:null}}]),vertexShader:Zn.meshmatcap_vert,fragmentShader:Zn.meshmatcap_frag},points:{uniforms:Zs([Ut.points,Ut.fog]),vertexShader:Zn.points_vert,fragmentShader:Zn.points_frag},dashed:{uniforms:Zs([Ut.common,Ut.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Zn.linedashed_vert,fragmentShader:Zn.linedashed_frag},depth:{uniforms:Zs([Ut.common,Ut.displacementmap]),vertexShader:Zn.depth_vert,fragmentShader:Zn.depth_frag},normal:{uniforms:Zs([Ut.common,Ut.bumpmap,Ut.normalmap,Ut.displacementmap,{opacity:{value:1}}]),vertexShader:Zn.meshnormal_vert,fragmentShader:Zn.meshnormal_frag},sprite:{uniforms:Zs([Ut.sprite,Ut.fog]),vertexShader:Zn.sprite_vert,fragmentShader:Zn.sprite_frag},background:{uniforms:{uvTransform:{value:new Cn},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Zn.background_vert,fragmentShader:Zn.background_frag},backgroundCube:{uniforms:{envMap:{value:null},flipEnvMap:{value:-1},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Cn}},vertexShader:Zn.backgroundCube_vert,fragmentShader:Zn.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Zn.cube_vert,fragmentShader:Zn.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Zn.equirect_vert,fragmentShader:Zn.equirect_frag},distanceRGBA:{uniforms:Zs([Ut.common,Ut.displacementmap,{referencePosition:{value:new W},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Zn.distanceRGBA_vert,fragmentShader:Zn.distanceRGBA_frag},shadow:{uniforms:Zs([Ut.lights,Ut.fog,{color:{value:new At(0)},opacity:{value:1}}]),vertexShader:Zn.shadow_vert,fragmentShader:Zn.shadow_frag}};ac.physical={uniforms:Zs([ac.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Cn},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Cn},clearcoatNormalScale:{value:new Ie(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Cn},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Cn},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Cn},sheen:{value:0},sheenColor:{value:new At(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Cn},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Cn},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Cn},transmissionSamplerSize:{value:new Ie},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Cn},attenuationDistance:{value:0},attenuationColor:{value:new At(0)},specularColor:{value:new At(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Cn},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Cn},anisotropyVector:{value:new Ie},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Cn}}]),vertexShader:Zn.meshphysical_vert,fragmentShader:Zn.meshphysical_frag};const Tx={r:0,b:0,g:0},Df=new Gr,KU=new Vt;function JU(i,e,t,n,r,o,a){const c=new At(0);let u=o===!0?0:1,d,p,m=null,y=0,x=null;function v(R){let P=R.isScene===!0?R.background:null;return P&&P.isTexture&&(P=(R.backgroundBlurriness>0?t:e).get(P)),P}function M(R){let P=!1;const B=v(R);B===null?S(c,u):B&&B.isColor&&(S(B,1),P=!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||P)&&(n.buffers.depth.setTest(!0),n.buffers.depth.setMask(!0),n.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function T(R,P){const B=v(P);B&&(B.isCubeTexture||B.mapping===Ll)?(p===void 0&&(p=new vi(new Ko(1,1,1),new Jo({name:"BackgroundCubeMaterial",uniforms:jc(ac.backgroundCube.uniforms),vertexShader:ac.backgroundCube.vertexShader,fragmentShader:ac.backgroundCube.fragmentShader,side:Ee,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),p.geometry.deleteAttribute("normal"),p.geometry.deleteAttribute("uv"),p.onBeforeRender=function(F,k,V){this.matrixWorld.copyPosition(V.matrixWorld)},Object.defineProperty(p.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),r.update(p)),Df.copy(P.backgroundRotation),Df.x*=-1,Df.y*=-1,Df.z*=-1,B.isCubeTexture&&B.isRenderTargetTexture===!1&&(Df.y*=-1,Df.z*=-1),p.material.uniforms.envMap.value=B,p.material.uniforms.flipEnvMap.value=B.isCubeTexture&&B.isRenderTargetTexture===!1?-1:1,p.material.uniforms.backgroundBlurriness.value=P.backgroundBlurriness,p.material.uniforms.backgroundIntensity.value=P.backgroundIntensity,p.material.uniforms.backgroundRotation.value.setFromMatrix4(KU.makeRotationFromEuler(Df)),p.material.toneMapped=pn.getTransfer(B.colorSpace)!==Dt,(m!==B||y!==B.version||x!==i.toneMapping)&&(p.material.needsUpdate=!0,m=B,y=B.version,x=i.toneMapping),p.layers.enableAll(),R.unshift(p,p.geometry,p.material,0,0,null)):B&&B.isTexture&&(d===void 0&&(d=new vi(new ic(2,2),new Jo({name:"BackgroundMaterial",uniforms:jc(ac.background.uniforms),vertexShader:ac.background.vertexShader,fragmentShader:ac.background.fragmentShader,side:Be,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=B,d.material.uniforms.backgroundIntensity.value=P.backgroundIntensity,d.material.toneMapped=pn.getTransfer(B.colorSpace)!==Dt,B.matrixAutoUpdate===!0&&B.updateMatrix(),d.material.uniforms.uvTransform.value.copy(B.matrix),(m!==B||y!==B.version||x!==i.toneMapping)&&(d.material.needsUpdate=!0,m=B,y=B.version,x=i.toneMapping),d.layers.enableAll(),R.unshift(d,d.geometry,d.material,0,0,null))}function S(R,P){R.getRGB(Tx,y0(i)),n.buffers.color.setClear(Tx.r,Tx.g,Tx.b,P,a)}function N(){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(R,P=1){c.set(R),u=P,S(c,u)},getClearAlpha:function(){return u},setClearAlpha:function(R){u=R,S(c,u)},render:M,addToRenderList:T,dispose:N}}function QU(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},r=y(null);let o=r,a=!1;function c(z,j,se,pe,be){let Pe=!1;const Ce=m(pe,se,j);o!==Ce&&(o=Ce,d(o.object)),Pe=x(z,pe,se,be),Pe&&v(z,pe,se,be),be!==null&&e.update(be,i.ELEMENT_ARRAY_BUFFER),(Pe||a)&&(a=!1,P(z,j,se,pe),be!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(be).buffer))}function u(){return i.createVertexArray()}function d(z){return i.bindVertexArray(z)}function p(z){return i.deleteVertexArray(z)}function m(z,j,se){const pe=se.wireframe===!0;let be=n[z.id];be===void 0&&(be={},n[z.id]=be);let Pe=be[j.id];Pe===void 0&&(Pe={},be[j.id]=Pe);let Ce=Pe[pe];return Ce===void 0&&(Ce=y(u()),Pe[pe]=Ce),Ce}function y(z){const j=[],se=[],pe=[];for(let be=0;be<t;be++)j[be]=0,se[be]=0,pe[be]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:j,enabledAttributes:se,attributeDivisors:pe,object:z,attributes:{},index:null}}function x(z,j,se,pe){const be=o.attributes,Pe=j.attributes;let Ce=0;const nt=se.getAttributes();for(const Le in nt)if(nt[Le].location>=0){const De=be[Le];let Je=Pe[Le];if(Je===void 0&&(Le==="instanceMatrix"&&z.instanceMatrix&&(Je=z.instanceMatrix),Le==="instanceColor"&&z.instanceColor&&(Je=z.instanceColor)),De===void 0||De.attribute!==Je||Je&&De.data!==Je.data)return!0;Ce++}return o.attributesNum!==Ce||o.index!==pe}function v(z,j,se,pe){const be={},Pe=j.attributes;let Ce=0;const nt=se.getAttributes();for(const Le in nt)if(nt[Le].location>=0){let De=Pe[Le];De===void 0&&(Le==="instanceMatrix"&&z.instanceMatrix&&(De=z.instanceMatrix),Le==="instanceColor"&&z.instanceColor&&(De=z.instanceColor));const Je={};Je.attribute=De,De&&De.data&&(Je.data=De.data),be[Le]=Je,Ce++}o.attributes=be,o.attributesNum=Ce,o.index=pe}function M(){const z=o.newAttributes;for(let j=0,se=z.length;j<se;j++)z[j]=0}function T(z){S(z,0)}function S(z,j){const se=o.newAttributes,pe=o.enabledAttributes,be=o.attributeDivisors;se[z]=1,pe[z]===0&&(i.enableVertexAttribArray(z),pe[z]=1),be[z]!==j&&(i.vertexAttribDivisor(z,j),be[z]=j)}function N(){const z=o.newAttributes,j=o.enabledAttributes;for(let se=0,pe=j.length;se<pe;se++)j[se]!==z[se]&&(i.disableVertexAttribArray(se),j[se]=0)}function R(z,j,se,pe,be,Pe,Ce){Ce===!0?i.vertexAttribIPointer(z,j,se,be,Pe):i.vertexAttribPointer(z,j,se,pe,be,Pe)}function P(z,j,se,pe){M();const be=pe.attributes,Pe=se.getAttributes(),Ce=j.defaultAttributeValues;for(const nt in Pe){const Le=Pe[nt];if(Le.location>=0){let ht=be[nt];if(ht===void 0&&(nt==="instanceMatrix"&&z.instanceMatrix&&(ht=z.instanceMatrix),nt==="instanceColor"&&z.instanceColor&&(ht=z.instanceColor)),ht!==void 0){const De=ht.normalized,Je=ht.itemSize,wt=e.get(ht);if(wt===void 0)continue;const Xt=wt.buffer,Ln=wt.type,Ke=wt.bytesPerElement,Se=Ln===i.INT||Ln===i.UNSIGNED_INT||ht.gpuType===Ws;if(ht.isInterleavedBufferAttribute){const Fe=ht.data,mt=Fe.stride,Bt=ht.offset;if(Fe.isInstancedInterleavedBuffer){for(let Rt=0;Rt<Le.locationSize;Rt++)S(Le.location+Rt,Fe.meshPerAttribute);z.isInstancedMesh!==!0&&pe._maxInstanceCount===void 0&&(pe._maxInstanceCount=Fe.meshPerAttribute*Fe.count)}else for(let Rt=0;Rt<Le.locationSize;Rt++)T(Le.location+Rt);i.bindBuffer(i.ARRAY_BUFFER,Xt);for(let Rt=0;Rt<Le.locationSize;Rt++)R(Le.location+Rt,Je/Le.locationSize,Ln,De,mt*Ke,(Bt+Je/Le.locationSize*Rt)*Ke,Se)}else{if(ht.isInstancedBufferAttribute){for(let Fe=0;Fe<Le.locationSize;Fe++)S(Le.location+Fe,ht.meshPerAttribute);z.isInstancedMesh!==!0&&pe._maxInstanceCount===void 0&&(pe._maxInstanceCount=ht.meshPerAttribute*ht.count)}else for(let Fe=0;Fe<Le.locationSize;Fe++)T(Le.location+Fe);i.bindBuffer(i.ARRAY_BUFFER,Xt);for(let Fe=0;Fe<Le.locationSize;Fe++)R(Le.location+Fe,Je/Le.locationSize,Ln,De,Je*Ke,Je/Le.locationSize*Fe*Ke,Se)}}else if(Ce!==void 0){const De=Ce[nt];if(De!==void 0)switch(De.length){case 2:i.vertexAttrib2fv(Le.location,De);break;case 3:i.vertexAttrib3fv(Le.location,De);break;case 4:i.vertexAttrib4fv(Le.location,De);break;default:i.vertexAttrib1fv(Le.location,De)}}}}N()}function B(){V();for(const z in n){const j=n[z];for(const se in j){const pe=j[se];for(const be in pe)p(pe[be].object),delete pe[be];delete j[se]}delete n[z]}}function F(z){if(n[z.id]===void 0)return;const j=n[z.id];for(const se in j){const pe=j[se];for(const be in pe)p(pe[be].object),delete pe[be];delete j[se]}delete n[z.id]}function k(z){for(const j in n){const se=n[j];if(se[z.id]===void 0)continue;const pe=se[z.id];for(const be in pe)p(pe[be].object),delete pe[be];delete se[z.id]}}function V(){U(),a=!0,o!==r&&(o=r,d(o.object))}function U(){r.geometry=null,r.program=null,r.wireframe=!1}return{setup:c,reset:V,resetDefaultState:U,dispose:B,releaseStatesOfGeometry:F,releaseStatesOfProgram:k,initAttributes:M,enableAttribute:T,disableUnusedAttributes:N}}function e3(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 M=0;M<m;M++)v+=p[M]*y[M];t.update(v,n,1)}}this.setMode=r,this.render=o,this.renderInstances=a,this.renderMultiDraw=c,this.renderMultiDrawInstances=u}function t3(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!==_i&&n.convert(k)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function c(k){const V=k===Ts&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(k!==Ui&&n.convert(k)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&k!==mi&&!V)}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&&(console.warn("THREE.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),M=i.getParameter(i.MAX_TEXTURE_SIZE),T=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),S=i.getParameter(i.MAX_VERTEX_ATTRIBS),N=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),R=i.getParameter(i.MAX_VARYING_VECTORS),P=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),B=v>0,F=i.getParameter(i.MAX_SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:o,getMaxPrecision:u,textureFormatReadable:a,textureTypeReadable:c,precision:d,logarithmicDepthBuffer:m,reversedDepthBuffer:y,maxTextures:x,maxVertexTextures:v,maxTextureSize:M,maxCubemapSize:T,maxAttributes:S,maxVertexUniforms:N,maxVaryings:R,maxFragmentUniforms:P,vertexTextures:B,maxSamples:F}}function n3(i){const e=this;let t=null,n=0,r=!1,o=!1;const a=new Rr,c=new Cn,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,M=m.clipIntersection,T=m.clipShadows,S=i.get(m);if(!r||v===null||v.length===0||o&&!T)o?p(null):d();else{const N=o?0:n,R=N*4;let P=S.clippingState||null;u.value=P,P=p(v,y,R,x);for(let B=0;B!==R;++B)P[B]=t[B];S.clippingState=P,this.numIntersection=M?this.numPlanes:0,this.numPlanes+=N}};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 M=m!==null?m.length:0;let T=null;if(M!==0){if(T=u.value,v!==!0||T===null){const S=x+M*4,N=y.matrixWorldInverse;c.getNormalMatrix(N),(T===null||T.length<S)&&(T=new Float32Array(S));for(let R=0,P=x;R!==M;++R,P+=4)a.copy(m[R]).applyMatrix4(N,c),a.normal.toArray(T,P),T[P+3]=a.constant}u.value=T,u.needsUpdate=!0}return e.numPlanes=M,e.numIntersection=0,T}}function i3(i){let e=new WeakMap;function t(a,c){return c===Nc?a.mapping=Br:c===Pc&&(a.mapping=Vo),a}function n(a){if(a&&a.isTexture){const c=a.mapping;if(c===Nc||c===Pc)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 Eg(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 Mm=4,nE=[.125,.215,.35,.446,.526,.582],Ff=20,tT=new Jh,iE=new At;let nT=null,iT=0,sT=0,rT=!1;const Bf=(1+Math.sqrt(5))/2,Am=1/Bf,sE=[new W(-Bf,Am,0),new W(Bf,Am,0),new W(-Am,0,Bf),new W(Am,0,Bf),new W(0,Bf,-Am),new W(0,Bf,Am),new W(-1,1,-1),new W(1,1,-1),new W(-1,1,1),new W(1,1,1)],s3=new W;class rE{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._compileMaterial(this._blurMaterial)}fromScene(e,t=0,n=.1,r=100,o={}){const{size:a=256,position:c=s3}=o;nT=this._renderer.getRenderTarget(),iT=this._renderer.getActiveCubeFace(),sT=this._renderer.getActiveMipmapLevel(),rT=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=lE(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=aE(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.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._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(nT,iT,sT),this._renderer.xr.enabled=rT,e.scissorTest=!1,wx(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===Br||e.mapping===Vo?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),nT=this._renderer.getRenderTarget(),iT=this._renderer.getActiveCubeFace(),sT=this._renderer.getActiveMipmapLevel(),rT=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:Ts,format:_i,colorSpace:ol,depthBuffer:!1},r=oE(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=oE(e,t,n);const{_lodMax:o}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas}=r3(o)),this._blurMaterial=o3(o,e,t)}return r}_compileMaterial(e){const t=new vi(this._lodPlanes[0],e);this._renderer.compile(t,tT)}_sceneToCubeUV(e,t,n,r,o){const u=new ps(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(iE),m.toneMapping=Qr,m.autoClear=!1,m.state.buffers.depth.getReversed()&&(m.setRenderTarget(r),m.clearDepth(),m.setRenderTarget(null));const M=new js({name:"PMREM.Background",side:Ee,depthWrite:!1,depthTest:!1}),T=new vi(new Ko,M);let S=!1;const N=e.background;N?N.isColor&&(M.color.copy(N),e.background=null,S=!0):(M.color.copy(iE),S=!0);for(let R=0;R<6;R++){const P=R%3;P===0?(u.up.set(0,d[R],0),u.position.set(o.x,o.y,o.z),u.lookAt(o.x+p[R],o.y,o.z)):P===1?(u.up.set(0,0,d[R]),u.position.set(o.x,o.y,o.z),u.lookAt(o.x,o.y+p[R],o.z)):(u.up.set(0,d[R],0),u.position.set(o.x,o.y,o.z),u.lookAt(o.x,o.y,o.z+p[R]));const B=this._cubeSize;wx(r,P*B,R>2?B:0,B,B),m.setRenderTarget(r),S&&m.render(T,u),m.render(e,u)}T.geometry.dispose(),T.material.dispose(),m.toneMapping=x,m.autoClear=y,e.background=N}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===Br||e.mapping===Vo;r?(this._cubemapMaterial===null&&(this._cubemapMaterial=lE()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=aE());const o=r?this._cubemapMaterial:this._equirectMaterial,a=new vi(this._lodPlanes[0],o),c=o.uniforms;c.envMap.value=e;const u=this._cubeSize;wx(t,0,0,3*u,2*u),n.setRenderTarget(t),n.render(a,tT)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let o=1;o<r;o++){const a=Math.sqrt(this._sigmas[o]*this._sigmas[o]-this._sigmas[o-1]*this._sigmas[o-1]),c=sE[(r-o-1)%sE.length];this._blur(e,o-1,o,a,c)}t.autoClear=n}_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"&&console.error("blur direction must be either latitudinal or longitudinal!");const p=3,m=new vi(this._lodPlanes[r],d),y=d.uniforms,x=this._sizeLods[n]-1,v=isFinite(o)?Math.PI/(2*x):2*Math.PI/(2*Ff-1),M=o/v,T=isFinite(o)?1+Math.floor(p*M):Ff;T>Ff&&console.warn(`sigmaRadians, ${o}, is too large and will clip, as it requested ${T} samples when the maximum is set to ${Ff}`);const S=[];let N=0;for(let k=0;k<Ff;++k){const V=k/M,U=Math.exp(-V*V/2);S.push(U),k===0?N+=U:k<T&&(N+=2*U)}for(let k=0;k<S.length;k++)S[k]=S[k]/N;y.envMap.value=e.texture,y.samples.value=T,y.weights.value=S,y.latitudinal.value=a==="latitudinal",c&&(y.poleAxis.value=c);const{_lodMax:R}=this;y.dTheta.value=v,y.mipInt.value=R-n;const P=this._sizeLods[r],B=3*P*(r>R-Mm?r-R+Mm:0),F=4*(this._cubeSize-P);wx(t,B,F,3*P,2*P),u.setRenderTarget(t),u.render(m,tT)}}function r3(i){const e=[],t=[],n=[];let r=i;const o=i-Mm+1+nE.length;for(let a=0;a<o;a++){const c=Math.pow(2,r);t.push(c);let u=1/c;a>i-Mm?u=nE[a-i+Mm-1]:a===0&&(u=0),n.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,M=3,T=2,S=1,N=new Float32Array(M*v*x),R=new Float32Array(T*v*x),P=new Float32Array(S*v*x);for(let F=0;F<x;F++){const k=F%3*2/3-1,V=F>2?0:-1,U=[k,V,0,k+2/3,V,0,k+2/3,V+1,0,k,V,0,k+2/3,V+1,0,k,V+1,0];N.set(U,M*v*F),R.set(y,T*v*F);const z=[F,F,F,F,F,F];P.set(z,S*v*F)}const B=new gn;B.setAttribute("position",new $n(N,M)),B.setAttribute("uv",new $n(R,T)),B.setAttribute("faceIndex",new $n(P,S)),e.push(B),r>Mm&&r--}return{lodPlanes:e,sizeLods:t,sigmas:n}}function oE(i,e,t){const n=new Aa(i,e,t);return n.texture.mapping=Ll,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function wx(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function o3(i,e,t){const n=new Float32Array(Ff),r=new W(0,1,0);return new Jo({name:"SphericalGaussianBlur",defines:{n:Ff,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:oT(),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:Ae,depthTest:!1,depthWrite:!1})}function aE(){return new Jo({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:oT(),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:Ae,depthTest:!1,depthWrite:!1})}function lE(){return new Jo({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:oT(),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:Ae,depthTest:!1,depthWrite:!1})}function oT(){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 a3(i){let e=new WeakMap,t=null;function n(c){if(c&&c.isTexture){const u=c.mapping,d=u===Nc||u===Pc,p=u===Br||u===Vo;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 rE(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 rE(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 l3(i){const e={};function t(n){if(e[n]!==void 0)return e[n];let r;switch(n){case"WEBGL_depth_texture":r=i.getExtension("WEBGL_depth_texture")||i.getExtension("MOZ_WEBGL_depth_texture")||i.getExtension("WEBKIT_WEBGL_depth_texture");break;case"EXT_texture_filter_anisotropic":r=i.getExtension("EXT_texture_filter_anisotropic")||i.getExtension("MOZ_EXT_texture_filter_anisotropic")||i.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case"WEBGL_compressed_texture_s3tc":r=i.getExtension("WEBGL_compressed_texture_s3tc")||i.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case"WEBGL_compressed_texture_pvrtc":r=i.getExtension("WEBGL_compressed_texture_pvrtc")||i.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default: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&&wr("THREE.WebGLRenderer: "+n+" extension not supported."),r}}}function c3(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 M=0;if(x!==null){const N=x.array;M=x.version;for(let R=0,P=N.length;R<P;R+=3){const B=N[R+0],F=N[R+1],k=N[R+2];y.push(B,F,F,k,k,B)}}else if(v!==void 0){const N=v.array;M=v.version;for(let R=0,P=N.length/3-1;R<P;R+=3){const B=R+0,F=R+1,k=R+2;y.push(B,F,F,k,k,B)}}else return;const T=new(_g(y)?m0:Mg)(y,1);T.version=M;const S=o.get(m);S&&e.remove(S),o.set(m,T)}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 u3(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 T=0;for(let S=0;S<v;S++)T+=x[S];t.update(T,n,1)}function m(y,x,v,M){if(v===0)return;const T=e.get("WEBGL_multi_draw");if(T===null)for(let S=0;S<y.length;S++)d(y[S]/a,x[S],M[S]);else{T.multiDrawElementsInstancedWEBGL(n,x,0,o,y,0,M,0,v);let S=0;for(let N=0;N<v;N++)S+=x[N]*M[N];t.update(S,n,1)}}this.setMode=r,this.setIndex=c,this.render=u,this.renderInstances=d,this.renderMultiDraw=p,this.renderMultiDrawInstances=m}function h3(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:console.error("THREE.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 d3(i,e,t){const n=new WeakMap,r=new an;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 U=function(){k.dispose(),n.delete(c),c.removeEventListener("dispose",U)};y!==void 0&&y.texture.dispose();const x=c.morphAttributes.position!==void 0,v=c.morphAttributes.normal!==void 0,M=c.morphAttributes.color!==void 0,T=c.morphAttributes.position||[],S=c.morphAttributes.normal||[],N=c.morphAttributes.color||[];let R=0;x===!0&&(R=1),v===!0&&(R=2),M===!0&&(R=3);let P=c.attributes.position.count*R,B=1;P>e.maxTextureSize&&(B=Math.ceil(P/e.maxTextureSize),P=e.maxTextureSize);const F=new Float32Array(P*B*4*m),k=new Tp(F,P,B,m);k.type=mi,k.needsUpdate=!0;const V=R*4;for(let z=0;z<m;z++){const j=T[z],se=S[z],pe=N[z],be=P*B*4*z;for(let Pe=0;Pe<j.count;Pe++){const Ce=Pe*V;x===!0&&(r.fromBufferAttribute(j,Pe),F[be+Ce+0]=r.x,F[be+Ce+1]=r.y,F[be+Ce+2]=r.z,F[be+Ce+3]=0),v===!0&&(r.fromBufferAttribute(se,Pe),F[be+Ce+4]=r.x,F[be+Ce+5]=r.y,F[be+Ce+6]=r.z,F[be+Ce+7]=0),M===!0&&(r.fromBufferAttribute(pe,Pe),F[be+Ce+8]=r.x,F[be+Ce+9]=r.y,F[be+Ce+10]=r.z,F[be+Ce+11]=pe.itemSize===4?r.w:1)}}y={count:m,texture:k,size:new Ie(P,B)},n.set(c,y),c.addEventListener("dispose",U)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)u.getUniforms().setValue(i,"morphTexture",a.morphTexture,t);else{let x=0;for(let M=0;M<d.length;M++)x+=d[M];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 f3(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 cE=new ds,uE=new Ao(1,1),hE=new Tp,dE=new no,fE=new jl,pE=[],mE=[],gE=new Float32Array(16),yE=new Float32Array(9),_E=new Float32Array(4);function Em(i,e,t){const n=i[0];if(n<=0||n>0)return i;const r=e*t;let o=pE[r];if(o===void 0&&(o=new Float32Array(r),pE[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 sr(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 rr(i,e){for(let t=0,n=e.length;t<n;t++)i[t]=e[t]}function Mx(i,e){let t=mE[e];t===void 0&&(t=new Int32Array(e),mE[e]=t);for(let n=0;n!==e;++n)t[n]=i.allocateTextureUnit();return t}function p3(i,e){const t=this.cache;t[0]!==e&&(i.uniform1f(this.addr,e),t[0]=e)}function m3(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(sr(t,e))return;i.uniform2fv(this.addr,e),rr(t,e)}}function g3(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(sr(t,e))return;i.uniform3fv(this.addr,e),rr(t,e)}}function y3(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(sr(t,e))return;i.uniform4fv(this.addr,e),rr(t,e)}}function _3(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(sr(t,e))return;i.uniformMatrix2fv(this.addr,!1,e),rr(t,e)}else{if(sr(t,n))return;_E.set(n),i.uniformMatrix2fv(this.addr,!1,_E),rr(t,n)}}function x3(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(sr(t,e))return;i.uniformMatrix3fv(this.addr,!1,e),rr(t,e)}else{if(sr(t,n))return;yE.set(n),i.uniformMatrix3fv(this.addr,!1,yE),rr(t,n)}}function v3(i,e){const t=this.cache,n=e.elements;if(n===void 0){if(sr(t,e))return;i.uniformMatrix4fv(this.addr,!1,e),rr(t,e)}else{if(sr(t,n))return;gE.set(n),i.uniformMatrix4fv(this.addr,!1,gE),rr(t,n)}}function b3(i,e){const t=this.cache;t[0]!==e&&(i.uniform1i(this.addr,e),t[0]=e)}function S3(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(sr(t,e))return;i.uniform2iv(this.addr,e),rr(t,e)}}function T3(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(sr(t,e))return;i.uniform3iv(this.addr,e),rr(t,e)}}function w3(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(sr(t,e))return;i.uniform4iv(this.addr,e),rr(t,e)}}function M3(i,e){const t=this.cache;t[0]!==e&&(i.uniform1ui(this.addr,e),t[0]=e)}function A3(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(sr(t,e))return;i.uniform2uiv(this.addr,e),rr(t,e)}}function E3(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(sr(t,e))return;i.uniform3uiv(this.addr,e),rr(t,e)}}function C3(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(sr(t,e))return;i.uniform4uiv(this.addr,e),rr(t,e)}}function R3(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?(uE.compareFunction=pg,o=uE):o=cE,t.setTexture2D(e||o,r)}function N3(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture3D(e||dE,r)}function P3(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTextureCube(e||fE,r)}function I3(i,e,t){const n=this.cache,r=t.allocateTextureUnit();n[0]!==r&&(i.uniform1i(this.addr,r),n[0]=r),t.setTexture2DArray(e||hE,r)}function L3(i){switch(i){case 5126:return p3;case 35664:return m3;case 35665:return g3;case 35666:return y3;case 35674:return _3;case 35675:return x3;case 35676:return v3;case 5124:case 35670:return b3;case 35667:case 35671:return S3;case 35668:case 35672:return T3;case 35669:case 35673:return w3;case 5125:return M3;case 36294:return A3;case 36295:return E3;case 36296:return C3;case 35678:case 36198:case 36298:case 36306:case 35682:return R3;case 35679:case 36299:case 36307:return N3;case 35680:case 36300:case 36308:case 36293:return P3;case 36289:case 36303:case 36311:case 36292:return I3}}function D3(i,e){i.uniform1fv(this.addr,e)}function F3(i,e){const t=Em(e,this.size,2);i.uniform2fv(this.addr,t)}function B3(i,e){const t=Em(e,this.size,3);i.uniform3fv(this.addr,t)}function O3(i,e){const t=Em(e,this.size,4);i.uniform4fv(this.addr,t)}function U3(i,e){const t=Em(e,this.size,4);i.uniformMatrix2fv(this.addr,!1,t)}function k3(i,e){const t=Em(e,this.size,9);i.uniformMatrix3fv(this.addr,!1,t)}function z3(i,e){const t=Em(e,this.size,16);i.uniformMatrix4fv(this.addr,!1,t)}function V3(i,e){i.uniform1iv(this.addr,e)}function G3(i,e){i.uniform2iv(this.addr,e)}function H3(i,e){i.uniform3iv(this.addr,e)}function W3(i,e){i.uniform4iv(this.addr,e)}function $3(i,e){i.uniform1uiv(this.addr,e)}function q3(i,e){i.uniform2uiv(this.addr,e)}function X3(i,e){i.uniform3uiv(this.addr,e)}function j3(i,e){i.uniform4uiv(this.addr,e)}function Y3(i,e,t){const n=this.cache,r=e.length,o=Mx(t,r);sr(n,o)||(i.uniform1iv(this.addr,o),rr(n,o));for(let a=0;a!==r;++a)t.setTexture2D(e[a]||cE,o[a])}function Z3(i,e,t){const n=this.cache,r=e.length,o=Mx(t,r);sr(n,o)||(i.uniform1iv(this.addr,o),rr(n,o));for(let a=0;a!==r;++a)t.setTexture3D(e[a]||dE,o[a])}function K3(i,e,t){const n=this.cache,r=e.length,o=Mx(t,r);sr(n,o)||(i.uniform1iv(this.addr,o),rr(n,o));for(let a=0;a!==r;++a)t.setTextureCube(e[a]||fE,o[a])}function J3(i,e,t){const n=this.cache,r=e.length,o=Mx(t,r);sr(n,o)||(i.uniform1iv(this.addr,o),rr(n,o));for(let a=0;a!==r;++a)t.setTexture2DArray(e[a]||hE,o[a])}function Q3(i){switch(i){case 5126:return D3;case 35664:return F3;case 35665:return B3;case 35666:return O3;case 35674:return U3;case 35675:return k3;case 35676:return z3;case 5124:case 35670:return V3;case 35667:case 35671:return G3;case 35668:case 35672:return H3;case 35669:case 35673:return W3;case 5125:return $3;case 36294:return q3;case 36295:return X3;case 36296:return j3;case 35678:case 36198:case 36298:case 36306:case 35682:return Y3;case 35679:case 36299:case 36307:return Z3;case 35680:case 36300:case 36308:case 36293:return K3;case 36289:case 36303:case 36311:case 36292:return J3}}class ek{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.setValue=L3(t.type)}}class tk{constructor(e,t,n){this.id=e,this.addr=n,this.cache=[],this.type=t.type,this.size=t.size,this.setValue=Q3(t.type)}}class nk{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 aT=/(\w+)(\])?(\[|\.)?/g;function xE(i,e){i.seq.push(e),i.map[e.id]=e}function ik(i,e,t){const n=i.name,r=n.length;for(aT.lastIndex=0;;){const o=aT.exec(n),a=aT.lastIndex;let c=o[1];const u=o[2]==="]",d=o[3];if(u&&(c=c|0),d===void 0||d==="["&&a+2===r){xE(t,d===void 0?new ek(c,i,e):new tk(c,i,e));break}else{let m=t.map[c];m===void 0&&(m=new nk(c),xE(t,m)),t=m}}}class Ax{constructor(e,t){this.seq=[],this.map={};const n=e.getProgramParameter(t,e.ACTIVE_UNIFORMS);for(let r=0;r<n;++r){const o=e.getActiveUniform(t,r),a=e.getUniformLocation(t,o.name);ik(o,a,this)}}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 sk=37297;let rk=0;function ok(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 bE=new Cn;function ak(i){pn._getMatrix(bE,pn.workingColorSpace,i);const e=`mat3( ${bE.elements.map(t=>t.toFixed(4))} )`;switch(pn.getTransfer(i)){case Uc:return[e,"LinearTransferOETF"];case Dt:return[e,"sRGBTransferOETF"];default:return console.warn("THREE.WebGLProgram: Unsupported color space: ",i),[e,"LinearTransferOETF"]}}function SE(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+`
|
|
|
|
`+ok(i.getShaderSource(e),c)}else return o}function lk(i,e){const t=ak(e);return[`vec4 ${i}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(`
|
|
`)}function ck(i,e){let t;switch(e){case pb:t="Linear";break;case mb:t="Reinhard";break;case gb:t="Cineon";break;case yb:t="ACESFilmic";break;case _b:t="AgX";break;case xb:t="Neutral";break;case E1:t="Custom";break;default:console.warn("THREE.WebGLProgram: Unsupported toneMapping:",e),t="Linear"}return"vec3 "+i+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Ex=new W;function uk(){pn.getLuminanceCoefficients(Ex);const i=Ex.x.toFixed(4),e=Ex.y.toFixed(4),t=Ex.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(`
|
|
`)}function hk(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Gy).join(`
|
|
`)}function dk(i){const e=[];for(const t in i){const n=i[t];n!==!1&&e.push("#define "+t+" "+n)}return e.join(`
|
|
`)}function fk(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 Gy(i){return i!==""}function TE(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 wE(i,e){return i.replace(/NUM_CLIPPING_PLANES/g,e.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,e.numClippingPlanes-e.numClipIntersection)}const pk=/^[ \t]*#include +<([\w\d./]+)>/gm;function lT(i){return i.replace(pk,gk)}const mk=new Map;function gk(i,e){let t=Zn[e];if(t===void 0){const n=mk.get(e);if(n!==void 0)t=Zn[n],console.warn('THREE.WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,n);else throw new Error("Can not resolve #include <"+e+">")}return lT(t)}const yk=/#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 ME(i){return i.replace(yk,_k)}function _k(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 AE(i){let e=`precision ${i.precision} float;
|
|
precision ${i.precision} int;
|
|
precision ${i.precision} sampler2D;
|
|
precision ${i.precision} samplerCube;
|
|
precision ${i.precision} sampler3D;
|
|
precision ${i.precision} sampler2DArray;
|
|
precision ${i.precision} sampler2DShadow;
|
|
precision ${i.precision} samplerCubeShadow;
|
|
precision ${i.precision} sampler2DArrayShadow;
|
|
precision ${i.precision} isampler2D;
|
|
precision ${i.precision} isampler3D;
|
|
precision ${i.precision} isamplerCube;
|
|
precision ${i.precision} isampler2DArray;
|
|
precision ${i.precision} usampler2D;
|
|
precision ${i.precision} usampler3D;
|
|
precision ${i.precision} usamplerCube;
|
|
precision ${i.precision} usampler2DArray;
|
|
`;return i.precision==="highp"?e+=`
|
|
#define HIGH_PRECISION`:i.precision==="mediump"?e+=`
|
|
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(e+=`
|
|
#define LOW_PRECISION`),e}function xk(i){let e="SHADOWMAP_TYPE_BASIC";return i.shadowMapType===Me?e="SHADOWMAP_TYPE_PCF":i.shadowMapType===Ne?e="SHADOWMAP_TYPE_PCF_SOFT":i.shadowMapType===le&&(e="SHADOWMAP_TYPE_VSM"),e}function vk(i){let e="ENVMAP_TYPE_CUBE";if(i.envMap)switch(i.envMapMode){case Br:case Vo:e="ENVMAP_TYPE_CUBE";break;case Ll:e="ENVMAP_TYPE_CUBE_UV";break}return e}function bk(i){let e="ENVMAP_MODE_REFLECTION";if(i.envMap)switch(i.envMapMode){case Vo:e="ENVMAP_MODE_REFRACTION";break}return e}function Sk(i){let e="ENVMAP_BLENDING_NONE";if(i.envMap)switch(i.combine){case Rc:e="ENVMAP_BLENDING_MULTIPLY";break;case db:e="ENVMAP_BLENDING_MIX";break;case fb:e="ENVMAP_BLENDING_ADD";break}return e}function Tk(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 wk(i,e,t,n){const r=i.getContext(),o=t.defines;let a=t.vertexShader,c=t.fragmentShader;const u=xk(t),d=vk(t),p=bk(t),m=Sk(t),y=Tk(t),x=hk(t),v=dk(o),M=r.createProgram();let T,S,N=t.glslVersion?"#version "+t.glslVersion+`
|
|
`:"";t.isRawShaderMaterial?(T=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v].filter(Gy).join(`
|
|
`),T.length>0&&(T+=`
|
|
`),S=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,v].filter(Gy).join(`
|
|
`),S.length>0&&(S+=`
|
|
`)):(T=[AE(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(Gy).join(`
|
|
`),S=[AE(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!==Qr?"#define TONE_MAPPING":"",t.toneMapping!==Qr?Zn.tonemapping_pars_fragment:"",t.toneMapping!==Qr?ck("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Zn.colorspace_pars_fragment,lk("linearToOutputTexel",t.outputColorSpace),uk(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",`
|
|
`].filter(Gy).join(`
|
|
`)),a=lT(a),a=TE(a,t),a=wE(a,t),c=lT(c),c=TE(c,t),c=wE(c,t),a=ME(a),c=ME(c),t.isRawShaderMaterial!==!0&&(N=`#version 300 es
|
|
`,T=[x,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
`)+`
|
|
`+T,S=["#define varying in",t.glslVersion===Ab?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===Ab?"":"#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 R=N+T+a,P=N+S+c,B=vE(r,r.VERTEX_SHADER,R),F=vE(r,r.FRAGMENT_SHADER,P);r.attachShader(M,B),r.attachShader(M,F),t.index0AttributeName!==void 0?r.bindAttribLocation(M,0,t.index0AttributeName):t.morphTargets===!0&&r.bindAttribLocation(M,0,"position"),r.linkProgram(M);function k(j){if(i.debug.checkShaderErrors){const se=r.getProgramInfoLog(M)||"",pe=r.getShaderInfoLog(B)||"",be=r.getShaderInfoLog(F)||"",Pe=se.trim(),Ce=pe.trim(),nt=be.trim();let Le=!0,ht=!0;if(r.getProgramParameter(M,r.LINK_STATUS)===!1)if(Le=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(r,M,B,F);else{const De=SE(r,B,"vertex"),Je=SE(r,F,"fragment");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(M,r.VALIDATE_STATUS)+`
|
|
|
|
Material Name: `+j.name+`
|
|
Material Type: `+j.type+`
|
|
|
|
Program Info Log: `+Pe+`
|
|
`+De+`
|
|
`+Je)}else Pe!==""?console.warn("THREE.WebGLProgram: Program Info Log:",Pe):(Ce===""||nt==="")&&(ht=!1);ht&&(j.diagnostics={runnable:Le,programLog:Pe,vertexShader:{log:Ce,prefix:T},fragmentShader:{log:nt,prefix:S}})}r.deleteShader(B),r.deleteShader(F),V=new Ax(r,M),U=fk(r,M)}let V;this.getUniforms=function(){return V===void 0&&k(this),V};let U;this.getAttributes=function(){return U===void 0&&k(this),U};let z=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return z===!1&&(z=r.getProgramParameter(M,sk)),z},this.destroy=function(){n.releaseStatesOfProgram(this),r.deleteProgram(M),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=rk++,this.cacheKey=e,this.usedTimes=1,this.program=M,this.vertexShader=B,this.fragmentShader=F,this}let Mk=0;class Ak{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 Ek(e),t.set(e,n)),n}}class Ek{constructor(e){this.id=Mk++,this.code=e,this.usedTimes=0}}function Ck(i,e,t,n,r,o,a){const c=new Na,u=new Ak,d=new Set,p=[],m=r.logarithmicDepthBuffer,y=r.vertexTextures;let x=r.precision;const v={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function M(U){return d.add(U),U===0?"uv":`uv${U}`}function T(U,z,j,se,pe){const be=se.fog,Pe=pe.geometry,Ce=U.isMeshStandardMaterial?se.environment:null,nt=(U.isMeshStandardMaterial?t:e).get(U.envMap||Ce),Le=nt&&nt.mapping===Ll?nt.image.height:null,ht=v[U.type];U.precision!==null&&(x=r.getMaxPrecision(U.precision),x!==U.precision&&console.warn("THREE.WebGLProgram.getParameters:",U.precision,"not supported, using",x,"instead."));const De=Pe.morphAttributes.position||Pe.morphAttributes.normal||Pe.morphAttributes.color,Je=De!==void 0?De.length:0;let wt=0;Pe.morphAttributes.position!==void 0&&(wt=1),Pe.morphAttributes.normal!==void 0&&(wt=2),Pe.morphAttributes.color!==void 0&&(wt=3);let Xt,Ln,Ke,Se;if(ht){const Pi=ac[ht];Xt=Pi.vertexShader,Ln=Pi.fragmentShader}else Xt=U.vertexShader,Ln=U.fragmentShader,u.update(U),Ke=u.getVertexShaderID(U),Se=u.getFragmentShaderID(U);const Fe=i.getRenderTarget(),mt=i.state.buffers.depth.getReversed(),Bt=pe.isInstancedMesh===!0,Rt=pe.isBatchedMesh===!0,hn=!!U.map,ri=!!U.matcap,re=!!nt,st=!!U.aoMap,it=!!U.lightMap,tt=!!U.bumpMap,Qe=!!U.normalMap,Mt=!!U.displacementMap,gt=!!U.emissiveMap,Nt=!!U.metalnessMap,Hn=!!U.roughnessMap,zn=U.anisotropy>0,K=U.clearcoat>0,H=U.dispersion>0,we=U.iridescence>0,$e=U.sheen>0,ut=U.transmission>0,Ye=zn&&!!U.anisotropyMap,dn=K&&!!U.clearcoatMap,Ct=K&&!!U.clearcoatNormalMap,ln=K&&!!U.clearcoatRoughnessMap,cn=we&&!!U.iridescenceMap,yt=we&&!!U.iridescenceThicknessMap,Ht=$e&&!!U.sheenColorMap,Nn=$e&&!!U.sheenRoughnessMap,yn=!!U.specularMap,zt=!!U.specularColorMap,jn=!!U.specularIntensityMap,ge=ut&&!!U.transmissionMap,bt=ut&&!!U.thicknessMap,It=!!U.gradientMap,sn=!!U.alphaMap,_t=U.alphaTest>0,ot=!!U.alphaHash,un=!!U.extensions;let Wn=Qr;U.toneMapped&&(Fe===null||Fe.isXRRenderTarget===!0)&&(Wn=i.toneMapping);const Zi={shaderID:ht,shaderType:U.type,shaderName:U.name,vertexShader:Xt,fragmentShader:Ln,defines:U.defines,customVertexShaderID:Ke,customFragmentShaderID:Se,isRawShaderMaterial:U.isRawShaderMaterial===!0,glslVersion:U.glslVersion,precision:x,batching:Rt,batchingColor:Rt&&pe._colorsTexture!==null,instancing:Bt,instancingColor:Bt&&pe.instanceColor!==null,instancingMorph:Bt&&pe.morphTexture!==null,supportsVertexTextures:y,outputColorSpace:Fe===null?i.outputColorSpace:Fe.isXRRenderTarget===!0?Fe.texture.colorSpace:ol,alphaToCoverage:!!U.alphaToCoverage,map:hn,matcap:ri,envMap:re,envMapMode:re&&nt.mapping,envMapCubeUVHeight:Le,aoMap:st,lightMap:it,bumpMap:tt,normalMap:Qe,displacementMap:y&&Mt,emissiveMap:gt,normalMapObjectSpace:Qe&&U.normalMapType===Mb,normalMapTangentSpace:Qe&&U.normalMapType===Ur,metalnessMap:Nt,roughnessMap:Hn,anisotropy:zn,anisotropyMap:Ye,clearcoat:K,clearcoatMap:dn,clearcoatNormalMap:Ct,clearcoatRoughnessMap:ln,dispersion:H,iridescence:we,iridescenceMap:cn,iridescenceThicknessMap:yt,sheen:$e,sheenColorMap:Ht,sheenRoughnessMap:Nn,specularMap:yn,specularColorMap:zt,specularIntensityMap:jn,transmission:ut,transmissionMap:ge,thicknessMap:bt,gradientMap:It,opaque:U.transparent===!1&&U.blending===qe&&U.alphaToCoverage===!1,alphaMap:sn,alphaTest:_t,alphaHash:ot,combine:U.combine,mapUv:hn&&M(U.map.channel),aoMapUv:st&&M(U.aoMap.channel),lightMapUv:it&&M(U.lightMap.channel),bumpMapUv:tt&&M(U.bumpMap.channel),normalMapUv:Qe&&M(U.normalMap.channel),displacementMapUv:Mt&&M(U.displacementMap.channel),emissiveMapUv:gt&&M(U.emissiveMap.channel),metalnessMapUv:Nt&&M(U.metalnessMap.channel),roughnessMapUv:Hn&&M(U.roughnessMap.channel),anisotropyMapUv:Ye&&M(U.anisotropyMap.channel),clearcoatMapUv:dn&&M(U.clearcoatMap.channel),clearcoatNormalMapUv:Ct&&M(U.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ln&&M(U.clearcoatRoughnessMap.channel),iridescenceMapUv:cn&&M(U.iridescenceMap.channel),iridescenceThicknessMapUv:yt&&M(U.iridescenceThicknessMap.channel),sheenColorMapUv:Ht&&M(U.sheenColorMap.channel),sheenRoughnessMapUv:Nn&&M(U.sheenRoughnessMap.channel),specularMapUv:yn&&M(U.specularMap.channel),specularColorMapUv:zt&&M(U.specularColorMap.channel),specularIntensityMapUv:jn&&M(U.specularIntensityMap.channel),transmissionMapUv:ge&&M(U.transmissionMap.channel),thicknessMapUv:bt&&M(U.thicknessMap.channel),alphaMapUv:sn&&M(U.alphaMap.channel),vertexTangents:!!Pe.attributes.tangent&&(Qe||zn),vertexColors:U.vertexColors,vertexAlphas:U.vertexColors===!0&&!!Pe.attributes.color&&Pe.attributes.color.itemSize===4,pointsUvs:pe.isPoints===!0&&!!Pe.attributes.uv&&(hn||sn),fog:!!be,useFog:U.fog===!0,fogExp2:!!be&&be.isFogExp2,flatShading:U.flatShading===!0&&U.wireframe===!1,sizeAttenuation:U.sizeAttenuation===!0,logarithmicDepthBuffer:m,reversedDepthBuffer:mt,skinning:pe.isSkinnedMesh===!0,morphTargets:Pe.morphAttributes.position!==void 0,morphNormals:Pe.morphAttributes.normal!==void 0,morphColors:Pe.morphAttributes.color!==void 0,morphTargetsCount:Je,morphTextureStride:wt,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:U.dithering,shadowMapEnabled:i.shadowMap.enabled&&j.length>0,shadowMapType:i.shadowMap.type,toneMapping:Wn,decodeVideoTexture:hn&&U.map.isVideoTexture===!0&&pn.getTransfer(U.map.colorSpace)===Dt,decodeVideoTextureEmissive:gt&&U.emissiveMap.isVideoTexture===!0&&pn.getTransfer(U.emissiveMap.colorSpace)===Dt,premultipliedAlpha:U.premultipliedAlpha,doubleSided:U.side===ke,flipSided:U.side===Ee,useDepthPacking:U.depthPacking>=0,depthPacking:U.depthPacking||0,index0AttributeName:U.index0AttributeName,extensionClipCullDistance:un&&U.extensions.clipCullDistance===!0&&n.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(un&&U.extensions.multiDraw===!0||Rt)&&n.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:n.has("KHR_parallel_shader_compile"),customProgramCacheKey:U.customProgramCacheKey()};return Zi.vertexUv1s=d.has(1),Zi.vertexUv2s=d.has(2),Zi.vertexUv3s=d.has(3),d.clear(),Zi}function S(U){const z=[];if(U.shaderID?z.push(U.shaderID):(z.push(U.customVertexShaderID),z.push(U.customFragmentShaderID)),U.defines!==void 0)for(const j in U.defines)z.push(j),z.push(U.defines[j]);return U.isRawShaderMaterial===!1&&(N(z,U),R(z,U),z.push(i.outputColorSpace)),z.push(U.customProgramCacheKey),z.join()}function N(U,z){U.push(z.precision),U.push(z.outputColorSpace),U.push(z.envMapMode),U.push(z.envMapCubeUVHeight),U.push(z.mapUv),U.push(z.alphaMapUv),U.push(z.lightMapUv),U.push(z.aoMapUv),U.push(z.bumpMapUv),U.push(z.normalMapUv),U.push(z.displacementMapUv),U.push(z.emissiveMapUv),U.push(z.metalnessMapUv),U.push(z.roughnessMapUv),U.push(z.anisotropyMapUv),U.push(z.clearcoatMapUv),U.push(z.clearcoatNormalMapUv),U.push(z.clearcoatRoughnessMapUv),U.push(z.iridescenceMapUv),U.push(z.iridescenceThicknessMapUv),U.push(z.sheenColorMapUv),U.push(z.sheenRoughnessMapUv),U.push(z.specularMapUv),U.push(z.specularColorMapUv),U.push(z.specularIntensityMapUv),U.push(z.transmissionMapUv),U.push(z.thicknessMapUv),U.push(z.combine),U.push(z.fogExp2),U.push(z.sizeAttenuation),U.push(z.morphTargetsCount),U.push(z.morphAttributeCount),U.push(z.numDirLights),U.push(z.numPointLights),U.push(z.numSpotLights),U.push(z.numSpotLightMaps),U.push(z.numHemiLights),U.push(z.numRectAreaLights),U.push(z.numDirLightShadows),U.push(z.numPointLightShadows),U.push(z.numSpotLightShadows),U.push(z.numSpotLightShadowsWithMaps),U.push(z.numLightProbes),U.push(z.shadowMapType),U.push(z.toneMapping),U.push(z.numClippingPlanes),U.push(z.numClipIntersection),U.push(z.depthPacking)}function R(U,z){c.disableAll(),z.supportsVertexTextures&&c.enable(0),z.instancing&&c.enable(1),z.instancingColor&&c.enable(2),z.instancingMorph&&c.enable(3),z.matcap&&c.enable(4),z.envMap&&c.enable(5),z.normalMapObjectSpace&&c.enable(6),z.normalMapTangentSpace&&c.enable(7),z.clearcoat&&c.enable(8),z.iridescence&&c.enable(9),z.alphaTest&&c.enable(10),z.vertexColors&&c.enable(11),z.vertexAlphas&&c.enable(12),z.vertexUv1s&&c.enable(13),z.vertexUv2s&&c.enable(14),z.vertexUv3s&&c.enable(15),z.vertexTangents&&c.enable(16),z.anisotropy&&c.enable(17),z.alphaHash&&c.enable(18),z.batching&&c.enable(19),z.dispersion&&c.enable(20),z.batchingColor&&c.enable(21),z.gradientMap&&c.enable(22),U.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),U.push(c.mask)}function P(U){const z=v[U.type];let j;if(z){const se=ac[z];j=Hd.clone(se.uniforms)}else j=U.uniforms;return j}function B(U,z){let j;for(let se=0,pe=p.length;se<pe;se++){const be=p[se];if(be.cacheKey===z){j=be,++j.usedTimes;break}}return j===void 0&&(j=new wk(i,z,U,o),p.push(j)),j}function F(U){if(--U.usedTimes===0){const z=p.indexOf(U);p[z]=p[p.length-1],p.pop(),U.destroy()}}function k(U){u.remove(U)}function V(){u.dispose()}return{getParameters:T,getProgramCacheKey:S,getUniforms:P,acquireProgram:B,releaseProgram:F,releaseShaderCache:k,programs:p,dispose:V}}function Rk(){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 Nk(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 EE(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 CE(){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,M,T){let S=i[e];return S===void 0?(S={id:m.id,object:m,geometry:y,material:x,groupOrder:v,renderOrder:m.renderOrder,z:M,group:T},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=M,S.group=T),e++,S}function c(m,y,x,v,M,T){const S=a(m,y,x,v,M,T);x.transmission>0?n.push(S):x.transparent===!0?r.push(S):t.push(S)}function u(m,y,x,v,M,T){const S=a(m,y,x,v,M,T);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||Nk),n.length>1&&n.sort(y||EE),r.length>1&&r.sort(y||EE)}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 Pk(){let i=new WeakMap;function e(n,r){const o=i.get(n);let a;return o===void 0?(a=new CE,i.set(n,[a])):r>=o.length?(a=new CE,o.push(a)):a=o[r],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function Ik(){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 W,color:new At};break;case"SpotLight":t={position:new W,direction:new W,color:new At,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new W,color:new At,distance:0,decay:0};break;case"HemisphereLight":t={direction:new W,skyColor:new At,groundColor:new At};break;case"RectAreaLight":t={color:new At,position:new W,halfWidth:new W,halfHeight:new W};break}return i[e.id]=t,t}}}function Lk(){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 Ie};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ie};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ie,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let Dk=0;function Fk(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function Bk(i){const e=new Ik,t=Lk(),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 W);const r=new W,o=new Vt,a=new Vt;function c(d){let p=0,m=0,y=0;for(let U=0;U<9;U++)n.probe[U].set(0,0,0);let x=0,v=0,M=0,T=0,S=0,N=0,R=0,P=0,B=0,F=0,k=0;d.sort(Fk);for(let U=0,z=d.length;U<z;U++){const j=d[U],se=j.color,pe=j.intensity,be=j.distance,Pe=j.shadow&&j.shadow.map?j.shadow.map.texture:null;if(j.isAmbientLight)p+=se.r*pe,m+=se.g*pe,y+=se.b*pe;else if(j.isLightProbe){for(let Ce=0;Ce<9;Ce++)n.probe[Ce].addScaledVector(j.sh.coefficients[Ce],pe);k++}else if(j.isDirectionalLight){const Ce=e.get(j);if(Ce.color.copy(j.color).multiplyScalar(j.intensity),j.castShadow){const nt=j.shadow,Le=t.get(j);Le.shadowIntensity=nt.intensity,Le.shadowBias=nt.bias,Le.shadowNormalBias=nt.normalBias,Le.shadowRadius=nt.radius,Le.shadowMapSize=nt.mapSize,n.directionalShadow[x]=Le,n.directionalShadowMap[x]=Pe,n.directionalShadowMatrix[x]=j.shadow.matrix,N++}n.directional[x]=Ce,x++}else if(j.isSpotLight){const Ce=e.get(j);Ce.position.setFromMatrixPosition(j.matrixWorld),Ce.color.copy(se).multiplyScalar(pe),Ce.distance=be,Ce.coneCos=Math.cos(j.angle),Ce.penumbraCos=Math.cos(j.angle*(1-j.penumbra)),Ce.decay=j.decay,n.spot[M]=Ce;const nt=j.shadow;if(j.map&&(n.spotLightMap[B]=j.map,B++,nt.updateMatrices(j),j.castShadow&&F++),n.spotLightMatrix[M]=nt.matrix,j.castShadow){const Le=t.get(j);Le.shadowIntensity=nt.intensity,Le.shadowBias=nt.bias,Le.shadowNormalBias=nt.normalBias,Le.shadowRadius=nt.radius,Le.shadowMapSize=nt.mapSize,n.spotShadow[M]=Le,n.spotShadowMap[M]=Pe,P++}M++}else if(j.isRectAreaLight){const Ce=e.get(j);Ce.color.copy(se).multiplyScalar(pe),Ce.halfWidth.set(j.width*.5,0,0),Ce.halfHeight.set(0,j.height*.5,0),n.rectArea[T]=Ce,T++}else if(j.isPointLight){const Ce=e.get(j);if(Ce.color.copy(j.color).multiplyScalar(j.intensity),Ce.distance=j.distance,Ce.decay=j.decay,j.castShadow){const nt=j.shadow,Le=t.get(j);Le.shadowIntensity=nt.intensity,Le.shadowBias=nt.bias,Le.shadowNormalBias=nt.normalBias,Le.shadowRadius=nt.radius,Le.shadowMapSize=nt.mapSize,Le.shadowCameraNear=nt.camera.near,Le.shadowCameraFar=nt.camera.far,n.pointShadow[v]=Le,n.pointShadowMap[v]=Pe,n.pointShadowMatrix[v]=j.shadow.matrix,R++}n.point[v]=Ce,v++}else if(j.isHemisphereLight){const Ce=e.get(j);Ce.skyColor.copy(j.color).multiplyScalar(pe),Ce.groundColor.copy(j.groundColor).multiplyScalar(pe),n.hemi[S]=Ce,S++}}T>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=Ut.LTC_FLOAT_1,n.rectAreaLTC2=Ut.LTC_FLOAT_2):(n.rectAreaLTC1=Ut.LTC_HALF_1,n.rectAreaLTC2=Ut.LTC_HALF_2)),n.ambient[0]=p,n.ambient[1]=m,n.ambient[2]=y;const V=n.hash;(V.directionalLength!==x||V.pointLength!==v||V.spotLength!==M||V.rectAreaLength!==T||V.hemiLength!==S||V.numDirectionalShadows!==N||V.numPointShadows!==R||V.numSpotShadows!==P||V.numSpotMaps!==B||V.numLightProbes!==k)&&(n.directional.length=x,n.spot.length=M,n.rectArea.length=T,n.point.length=v,n.hemi.length=S,n.directionalShadow.length=N,n.directionalShadowMap.length=N,n.pointShadow.length=R,n.pointShadowMap.length=R,n.spotShadow.length=P,n.spotShadowMap.length=P,n.directionalShadowMatrix.length=N,n.pointShadowMatrix.length=R,n.spotLightMatrix.length=P+B-F,n.spotLightMap.length=B,n.numSpotLightShadowsWithMaps=F,n.numLightProbes=k,V.directionalLength=x,V.pointLength=v,V.spotLength=M,V.rectAreaLength=T,V.hemiLength=S,V.numDirectionalShadows=N,V.numPointShadows=R,V.numSpotShadows=P,V.numSpotMaps=B,V.numLightProbes=k,n.version=Dk++)}function u(d,p){let m=0,y=0,x=0,v=0,M=0;const T=p.matrixWorldInverse;for(let S=0,N=d.length;S<N;S++){const R=d[S];if(R.isDirectionalLight){const P=n.directional[m];P.direction.setFromMatrixPosition(R.matrixWorld),r.setFromMatrixPosition(R.target.matrixWorld),P.direction.sub(r),P.direction.transformDirection(T),m++}else if(R.isSpotLight){const P=n.spot[x];P.position.setFromMatrixPosition(R.matrixWorld),P.position.applyMatrix4(T),P.direction.setFromMatrixPosition(R.matrixWorld),r.setFromMatrixPosition(R.target.matrixWorld),P.direction.sub(r),P.direction.transformDirection(T),x++}else if(R.isRectAreaLight){const P=n.rectArea[v];P.position.setFromMatrixPosition(R.matrixWorld),P.position.applyMatrix4(T),a.identity(),o.copy(R.matrixWorld),o.premultiply(T),a.extractRotation(o),P.halfWidth.set(R.width*.5,0,0),P.halfHeight.set(0,R.height*.5,0),P.halfWidth.applyMatrix4(a),P.halfHeight.applyMatrix4(a),v++}else if(R.isPointLight){const P=n.point[y];P.position.setFromMatrixPosition(R.matrixWorld),P.position.applyMatrix4(T),y++}else if(R.isHemisphereLight){const P=n.hemi[M];P.direction.setFromMatrixPosition(R.matrixWorld),P.direction.transformDirection(T),M++}}}return{setup:c,setupView:u,state:n}}function RE(i){const e=new Bk(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 Ok(i){let e=new WeakMap;function t(r,o=0){const a=e.get(r);let c;return a===void 0?(c=new RE(i),e.set(r,[c])):o>=a.length?(c=new RE(i),a.push(c)):c=a[o],c}function n(){e=new WeakMap}return{get:t,dispose:n}}const Uk=`void main() {
|
|
gl_Position = vec4( position, 1.0 );
|
|
}`,kk=`uniform sampler2D shadow_pass;
|
|
uniform vec2 resolution;
|
|
uniform float radius;
|
|
#include <packing>
|
|
void main() {
|
|
const float samples = float( VSM_SAMPLES );
|
|
float mean = 0.0;
|
|
float squared_mean = 0.0;
|
|
float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 );
|
|
float uvStart = samples <= 1.0 ? 0.0 : - 1.0;
|
|
for ( float i = 0.0; i < samples; i ++ ) {
|
|
float uvOffset = uvStart + i * uvStride;
|
|
#ifdef HORIZONTAL_PASS
|
|
vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ) );
|
|
mean += distribution.x;
|
|
squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;
|
|
#else
|
|
float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ) );
|
|
mean += depth;
|
|
squared_mean += depth * depth;
|
|
#endif
|
|
}
|
|
mean = mean / samples;
|
|
squared_mean = squared_mean / samples;
|
|
float std_dev = sqrt( squared_mean - mean * mean );
|
|
gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );
|
|
}`;function zk(i,e,t){let n=new Ih;const r=new Ie,o=new Ie,a=new an,c=new V0({depthPacking:N1}),u=new G0,d={},p=t.maxTextureSize,m={[Be]:Ee,[Ee]:Be,[ke]:ke},y=new Jo({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ie},radius:{value:4}},vertexShader:Uk,fragmentShader:kk}),x=y.clone();x.defines.HORIZONTAL_PASS=1;const v=new gn;v.setAttribute("position",new $n(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const M=new vi(v,y),T=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Me;let S=this.type;this.render=function(F,k,V){if(T.enabled===!1||T.autoUpdate===!1&&T.needsUpdate===!1||F.length===0)return;const U=i.getRenderTarget(),z=i.getActiveCubeFace(),j=i.getActiveMipmapLevel(),se=i.state;se.setBlending(Ae),se.buffers.depth.getReversed()===!0?se.buffers.color.setClear(0,0,0,0):se.buffers.color.setClear(1,1,1,1),se.buffers.depth.setTest(!0),se.setScissorTest(!1);const pe=S!==le&&this.type===le,be=S===le&&this.type!==le;for(let Pe=0,Ce=F.length;Pe<Ce;Pe++){const nt=F[Pe],Le=nt.shadow;if(Le===void 0){console.warn("THREE.WebGLShadowMap:",nt,"has no shadow.");continue}if(Le.autoUpdate===!1&&Le.needsUpdate===!1)continue;r.copy(Le.mapSize);const ht=Le.getFrameExtents();if(r.multiply(ht),o.copy(Le.mapSize),(r.x>p||r.y>p)&&(r.x>p&&(o.x=Math.floor(p/ht.x),r.x=o.x*ht.x,Le.mapSize.x=o.x),r.y>p&&(o.y=Math.floor(p/ht.y),r.y=o.y*ht.y,Le.mapSize.y=o.y)),Le.map===null||pe===!0||be===!0){const Je=this.type!==le?{minFilter:Jn,magFilter:Jn}:{};Le.map!==null&&Le.map.dispose(),Le.map=new Aa(r.x,r.y,Je),Le.map.texture.name=nt.name+".shadowMap",Le.camera.updateProjectionMatrix()}i.setRenderTarget(Le.map),i.clear();const De=Le.getViewportCount();for(let Je=0;Je<De;Je++){const wt=Le.getViewport(Je);a.set(o.x*wt.x,o.y*wt.y,o.x*wt.z,o.y*wt.w),se.viewport(a),Le.updateMatrices(nt,Je),n=Le.getFrustum(),P(k,V,Le.camera,nt,this.type)}Le.isPointLightShadow!==!0&&this.type===le&&N(Le,V),Le.needsUpdate=!1}S=this.type,T.needsUpdate=!1,i.setRenderTarget(U,z,j)};function N(F,k){const V=e.update(M);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 Aa(r.x,r.y)),y.uniforms.shadow_pass.value=F.map.texture,y.uniforms.resolution.value=F.mapSize,y.uniforms.radius.value=F.radius,i.setRenderTarget(F.mapPass),i.clear(),i.renderBufferDirect(k,null,V,y,M,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,V,x,M,null)}function R(F,k,V,U){let z=null;const j=V.isPointLight===!0?F.customDistanceMaterial:F.customDepthMaterial;if(j!==void 0)z=j;else if(z=V.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 se=z.uuid,pe=k.uuid;let be=d[se];be===void 0&&(be={},d[se]=be);let Pe=be[pe];Pe===void 0&&(Pe=z.clone(),be[pe]=Pe,k.addEventListener("dispose",B)),z=Pe}if(z.visible=k.visible,z.wireframe=k.wireframe,U===le?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,V.isPointLight===!0&&z.isMeshDistanceMaterial===!0){const se=i.properties.get(z);se.light=V}return z}function P(F,k,V,U,z){if(F.visible===!1)return;if(F.layers.test(k.layers)&&(F.isMesh||F.isLine||F.isPoints)&&(F.castShadow||F.receiveShadow&&z===le)&&(!F.frustumCulled||n.intersectsObject(F))){F.modelViewMatrix.multiplyMatrices(V.matrixWorldInverse,F.matrixWorld);const pe=e.update(F),be=F.material;if(Array.isArray(be)){const Pe=pe.groups;for(let Ce=0,nt=Pe.length;Ce<nt;Ce++){const Le=Pe[Ce],ht=be[Le.materialIndex];if(ht&&ht.visible){const De=R(F,ht,U,z);F.onBeforeShadow(i,F,k,V,pe,De,Le),i.renderBufferDirect(V,null,pe,De,F,Le),F.onAfterShadow(i,F,k,V,pe,De,Le)}}}else if(be.visible){const Pe=R(F,be,U,z);F.onBeforeShadow(i,F,k,V,pe,Pe,null),i.renderBufferDirect(V,null,pe,Pe,F,null),F.onAfterShadow(i,F,k,V,pe,Pe,null)}}const se=F.children;for(let pe=0,be=se.length;pe<be;pe++)P(se[pe],k,V,U,z)}function B(F){F.target.removeEventListener("dispose",B);for(const V in d){const U=d[V],z=F.target.uuid;z in U&&(U[z].dispose(),delete U[z])}}}const Vk={[Wu]:Sn,[yi]:pp,[Ec]:mp,[Jr]:Cc,[Sn]:Wu,[pp]:yi,[mp]:Ec,[Cc]:Jr};function Gk(i,e){function t(){let ge=!1;const bt=new an;let It=null;const sn=new an(0,0,0,0);return{setMask:function(_t){It!==_t&&!ge&&(i.colorMask(_t,_t,_t,_t),It=_t)},setLocked:function(_t){ge=_t},setClear:function(_t,ot,un,Wn,Zi){Zi===!0&&(_t*=Wn,ot*=Wn,un*=Wn),bt.set(_t,ot,un,Wn),sn.equals(bt)===!1&&(i.clearColor(_t,ot,un,Wn),sn.copy(bt))},reset:function(){ge=!1,It=null,sn.set(-1,0,0,0)}}}function n(){let ge=!1,bt=!1,It=null,sn=null,_t=null;return{setReversed:function(ot){if(bt!==ot){const un=e.get("EXT_clip_control");ot?un.clipControlEXT(un.LOWER_LEFT_EXT,un.ZERO_TO_ONE_EXT):un.clipControlEXT(un.LOWER_LEFT_EXT,un.NEGATIVE_ONE_TO_ONE_EXT),bt=ot;const Wn=_t;_t=null,this.setClear(Wn)}},getReversed:function(){return bt},setTest:function(ot){ot?Fe(i.DEPTH_TEST):mt(i.DEPTH_TEST)},setMask:function(ot){It!==ot&&!ge&&(i.depthMask(ot),It=ot)},setFunc:function(ot){if(bt&&(ot=Vk[ot]),sn!==ot){switch(ot){case Wu:i.depthFunc(i.NEVER);break;case Sn:i.depthFunc(i.ALWAYS);break;case yi:i.depthFunc(i.LESS);break;case Jr:i.depthFunc(i.LEQUAL);break;case Ec:i.depthFunc(i.EQUAL);break;case Cc:i.depthFunc(i.GEQUAL);break;case pp:i.depthFunc(i.GREATER);break;case mp:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}sn=ot}},setLocked:function(ot){ge=ot},setClear:function(ot){_t!==ot&&(bt&&(ot=1-ot),i.clearDepth(ot),_t=ot)},reset:function(){ge=!1,It=null,sn=null,_t=null,bt=!1}}}function r(){let ge=!1,bt=null,It=null,sn=null,_t=null,ot=null,un=null,Wn=null,Zi=null;return{setTest:function(Pi){ge||(Pi?Fe(i.STENCIL_TEST):mt(i.STENCIL_TEST))},setMask:function(Pi){bt!==Pi&&!ge&&(i.stencilMask(Pi),bt=Pi)},setFunc:function(Pi,Gu,Ac){(It!==Pi||sn!==Gu||_t!==Ac)&&(i.stencilFunc(Pi,Gu,Ac),It=Pi,sn=Gu,_t=Ac)},setOp:function(Pi,Gu,Ac){(ot!==Pi||un!==Gu||Wn!==Ac)&&(i.stencilOp(Pi,Gu,Ac),ot=Pi,un=Gu,Wn=Ac)},setLocked:function(Pi){ge=Pi},setClear:function(Pi){Zi!==Pi&&(i.clearStencil(Pi),Zi=Pi)},reset:function(){ge=!1,bt=null,It=null,sn=null,_t=null,ot=null,un=null,Wn=null,Zi=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,M=!1,T=null,S=null,N=null,R=null,P=null,B=null,F=null,k=new At(0,0,0),V=0,U=!1,z=null,j=null,se=null,pe=null,be=null;const Pe=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let Ce=!1,nt=0;const Le=i.getParameter(i.VERSION);Le.indexOf("WebGL")!==-1?(nt=parseFloat(/^WebGL (\d)/.exec(Le)[1]),Ce=nt>=1):Le.indexOf("OpenGL ES")!==-1&&(nt=parseFloat(/^OpenGL ES (\d)/.exec(Le)[1]),Ce=nt>=2);let ht=null,De={};const Je=i.getParameter(i.SCISSOR_BOX),wt=i.getParameter(i.VIEWPORT),Xt=new an().fromArray(Je),Ln=new an().fromArray(wt);function Ke(ge,bt,It,sn){const _t=new Uint8Array(4),ot=i.createTexture();i.bindTexture(ge,ot),i.texParameteri(ge,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(ge,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let un=0;un<It;un++)ge===i.TEXTURE_3D||ge===i.TEXTURE_2D_ARRAY?i.texImage3D(bt,0,i.RGBA,1,1,sn,0,i.RGBA,i.UNSIGNED_BYTE,_t):i.texImage2D(bt+un,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,_t);return ot}const Se={};Se[i.TEXTURE_2D]=Ke(i.TEXTURE_2D,i.TEXTURE_2D,1),Se[i.TEXTURE_CUBE_MAP]=Ke(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),Se[i.TEXTURE_2D_ARRAY]=Ke(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),Se[i.TEXTURE_3D]=Ke(i.TEXTURE_3D,i.TEXTURE_3D,1,1),o.setClear(0,0,0,1),a.setClear(1),c.setClear(0),Fe(i.DEPTH_TEST),a.setFunc(Jr),tt(!1),Qe(J),Fe(i.CULL_FACE),st(Ae);function Fe(ge){p[ge]!==!0&&(i.enable(ge),p[ge]=!0)}function mt(ge){p[ge]!==!1&&(i.disable(ge),p[ge]=!1)}function Bt(ge,bt){return m[ge]!==bt?(i.bindFramebuffer(ge,bt),m[ge]=bt,ge===i.DRAW_FRAMEBUFFER&&(m[i.FRAMEBUFFER]=bt),ge===i.FRAMEBUFFER&&(m[i.DRAW_FRAMEBUFFER]=bt),!0):!1}function Rt(ge,bt){let It=x,sn=!1;if(ge){It=y.get(bt),It===void 0&&(It=[],y.set(bt,It));const _t=ge.textures;if(It.length!==_t.length||It[0]!==i.COLOR_ATTACHMENT0){for(let ot=0,un=_t.length;ot<un;ot++)It[ot]=i.COLOR_ATTACHMENT0+ot;It.length=_t.length,sn=!0}}else It[0]!==i.BACK&&(It[0]=i.BACK,sn=!0);sn&&i.drawBuffers(It)}function hn(ge){return v!==ge?(i.useProgram(ge),v=ge,!0):!1}const ri={[Ot]:i.FUNC_ADD,[Fn]:i.FUNC_SUBTRACT,[os]:i.FUNC_REVERSE_SUBTRACT};ri[Bn]=i.MIN,ri[ei]=i.MAX;const re={[ni]:i.ZERO,[bs]:i.ONE,[vr]:i.SRC_COLOR,[Kr]:i.SRC_ALPHA,[On]:i.SRC_ALPHA_SATURATE,[Tt]:i.DST_COLOR,[xa]:i.DST_ALPHA,[Zr]:i.ONE_MINUS_SRC_COLOR,[Ss]:i.ONE_MINUS_SRC_ALPHA,[rn]:i.ONE_MINUS_DST_COLOR,[va]:i.ONE_MINUS_DST_ALPHA,[hs]:i.CONSTANT_COLOR,[Il]:i.ONE_MINUS_CONSTANT_COLOR,[Hu]:i.CONSTANT_ALPHA,[J_]:i.ONE_MINUS_CONSTANT_ALPHA};function st(ge,bt,It,sn,_t,ot,un,Wn,Zi,Pi){if(ge===Ae){M===!0&&(mt(i.BLEND),M=!1);return}if(M===!1&&(Fe(i.BLEND),M=!0),ge!==St){if(ge!==T||Pi!==U){if((S!==Ot||P!==Ot)&&(i.blendEquation(i.FUNC_ADD),S=Ot,P=Ot),Pi)switch(ge){case qe:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case et:i.blendFunc(i.ONE,i.ONE);break;case rt:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case at:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:console.error("THREE.WebGLState: Invalid blending: ",ge);break}else switch(ge){case qe:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case et:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case rt:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case at:console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:console.error("THREE.WebGLState: Invalid blending: ",ge);break}N=null,R=null,B=null,F=null,k.set(0,0,0),V=0,T=ge,U=Pi}return}_t=_t||bt,ot=ot||It,un=un||sn,(bt!==S||_t!==P)&&(i.blendEquationSeparate(ri[bt],ri[_t]),S=bt,P=_t),(It!==N||sn!==R||ot!==B||un!==F)&&(i.blendFuncSeparate(re[It],re[sn],re[ot],re[un]),N=It,R=sn,B=ot,F=un),(Wn.equals(k)===!1||Zi!==V)&&(i.blendColor(Wn.r,Wn.g,Wn.b,Zi),k.copy(Wn),V=Zi),T=ge,U=!1}function it(ge,bt){ge.side===ke?mt(i.CULL_FACE):Fe(i.CULL_FACE);let It=ge.side===Ee;bt&&(It=!It),tt(It),ge.blending===qe&&ge.transparent===!1?st(Ae):st(ge.blending,ge.blendEquation,ge.blendSrc,ge.blendDst,ge.blendEquationAlpha,ge.blendSrcAlpha,ge.blendDstAlpha,ge.blendColor,ge.blendAlpha,ge.premultipliedAlpha),a.setFunc(ge.depthFunc),a.setTest(ge.depthTest),a.setMask(ge.depthWrite),o.setMask(ge.colorWrite);const sn=ge.stencilWrite;c.setTest(sn),sn&&(c.setMask(ge.stencilWriteMask),c.setFunc(ge.stencilFunc,ge.stencilRef,ge.stencilFuncMask),c.setOp(ge.stencilFail,ge.stencilZFail,ge.stencilZPass)),gt(ge.polygonOffset,ge.polygonOffsetFactor,ge.polygonOffsetUnits),ge.alphaToCoverage===!0?Fe(i.SAMPLE_ALPHA_TO_COVERAGE):mt(i.SAMPLE_ALPHA_TO_COVERAGE)}function tt(ge){z!==ge&&(ge?i.frontFace(i.CW):i.frontFace(i.CCW),z=ge)}function Qe(ge){ge!==X?(Fe(i.CULL_FACE),ge!==j&&(ge===J?i.cullFace(i.BACK):ge===oe?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):mt(i.CULL_FACE),j=ge}function Mt(ge){ge!==se&&(Ce&&i.lineWidth(ge),se=ge)}function gt(ge,bt,It){ge?(Fe(i.POLYGON_OFFSET_FILL),(pe!==bt||be!==It)&&(i.polygonOffset(bt,It),pe=bt,be=It)):mt(i.POLYGON_OFFSET_FILL)}function Nt(ge){ge?Fe(i.SCISSOR_TEST):mt(i.SCISSOR_TEST)}function Hn(ge){ge===void 0&&(ge=i.TEXTURE0+Pe-1),ht!==ge&&(i.activeTexture(ge),ht=ge)}function zn(ge,bt,It){It===void 0&&(ht===null?It=i.TEXTURE0+Pe-1:It=ht);let sn=De[It];sn===void 0&&(sn={type:void 0,texture:void 0},De[It]=sn),(sn.type!==ge||sn.texture!==bt)&&(ht!==It&&(i.activeTexture(It),ht=It),i.bindTexture(ge,bt||Se[ge]),sn.type=ge,sn.texture=bt)}function K(){const ge=De[ht];ge!==void 0&&ge.type!==void 0&&(i.bindTexture(ge.type,null),ge.type=void 0,ge.texture=void 0)}function H(){try{i.compressedTexImage2D(...arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function we(){try{i.compressedTexImage3D(...arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function $e(){try{i.texSubImage2D(...arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function ut(){try{i.texSubImage3D(...arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function Ye(){try{i.compressedTexSubImage2D(...arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function dn(){try{i.compressedTexSubImage3D(...arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function Ct(){try{i.texStorage2D(...arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function ln(){try{i.texStorage3D(...arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function cn(){try{i.texImage2D(...arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function yt(){try{i.texImage3D(...arguments)}catch(ge){console.error("THREE.WebGLState:",ge)}}function Ht(ge){Xt.equals(ge)===!1&&(i.scissor(ge.x,ge.y,ge.z,ge.w),Xt.copy(ge))}function Nn(ge){Ln.equals(ge)===!1&&(i.viewport(ge.x,ge.y,ge.z,ge.w),Ln.copy(ge))}function yn(ge,bt){let It=d.get(bt);It===void 0&&(It=new WeakMap,d.set(bt,It));let sn=It.get(ge);sn===void 0&&(sn=i.getUniformBlockIndex(bt,ge.name),It.set(ge,sn))}function zt(ge,bt){const sn=d.get(bt).get(ge);u.get(bt)!==sn&&(i.uniformBlockBinding(bt,sn,ge.__bindingPointIndex),u.set(bt,sn))}function jn(){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={},ht=null,De={},m={},y=new WeakMap,x=[],v=null,M=!1,T=null,S=null,N=null,R=null,P=null,B=null,F=null,k=new At(0,0,0),V=0,U=!1,z=null,j=null,se=null,pe=null,be=null,Xt.set(0,0,i.canvas.width,i.canvas.height),Ln.set(0,0,i.canvas.width,i.canvas.height),o.reset(),a.reset(),c.reset()}return{buffers:{color:o,depth:a,stencil:c},enable:Fe,disable:mt,bindFramebuffer:Bt,drawBuffers:Rt,useProgram:hn,setBlending:st,setMaterial:it,setFlipSided:tt,setCullFace:Qe,setLineWidth:Mt,setPolygonOffset:gt,setScissorTest:Nt,activeTexture:Hn,bindTexture:zn,unbindTexture:K,compressedTexImage2D:H,compressedTexImage3D:we,texImage2D:cn,texImage3D:yt,updateUBOMapping:yn,uniformBlockBinding:zt,texStorage2D:Ct,texStorage3D:ln,texSubImage2D:$e,texSubImage3D:ut,compressedTexSubImage2D:Ye,compressedTexSubImage3D:dn,scissor:Ht,viewport:Nn,reset:jn}}function Hk(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 Ie,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(K){}function v(K,H){return x?new OffscreenCanvas(K,H):Dd("canvas")}function M(K,H,we){let $e=1;const ut=zn(K);if((ut.width>we||ut.height>we)&&($e=we/Math.max(ut.width,ut.height)),$e<1)if(typeof HTMLImageElement!="undefined"&&K instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&K instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&K instanceof ImageBitmap||typeof VideoFrame!="undefined"&&K instanceof VideoFrame){const Ye=Math.floor($e*ut.width),dn=Math.floor($e*ut.height);m===void 0&&(m=v(Ye,dn));const Ct=H?v(Ye,dn):m;return Ct.width=Ye,Ct.height=dn,Ct.getContext("2d").drawImage(K,0,0,Ye,dn),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+ut.width+"x"+ut.height+") to ("+Ye+"x"+dn+")."),Ct}else return"data"in K&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+ut.width+"x"+ut.height+")."),K;return K}function T(K){return K.generateMipmaps}function S(K){i.generateMipmap(K)}function N(K){return K.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:K.isWebGL3DRenderTarget?i.TEXTURE_3D:K.isWebGLArrayRenderTarget||K.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function R(K,H,we,$e,ut=!1){if(K!==null){if(i[K]!==void 0)return i[K];console.warn("THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format '"+K+"'")}let Ye=H;if(H===i.RED&&(we===i.FLOAT&&(Ye=i.R32F),we===i.HALF_FLOAT&&(Ye=i.R16F),we===i.UNSIGNED_BYTE&&(Ye=i.R8)),H===i.RED_INTEGER&&(we===i.UNSIGNED_BYTE&&(Ye=i.R8UI),we===i.UNSIGNED_SHORT&&(Ye=i.R16UI),we===i.UNSIGNED_INT&&(Ye=i.R32UI),we===i.BYTE&&(Ye=i.R8I),we===i.SHORT&&(Ye=i.R16I),we===i.INT&&(Ye=i.R32I)),H===i.RG&&(we===i.FLOAT&&(Ye=i.RG32F),we===i.HALF_FLOAT&&(Ye=i.RG16F),we===i.UNSIGNED_BYTE&&(Ye=i.RG8)),H===i.RG_INTEGER&&(we===i.UNSIGNED_BYTE&&(Ye=i.RG8UI),we===i.UNSIGNED_SHORT&&(Ye=i.RG16UI),we===i.UNSIGNED_INT&&(Ye=i.RG32UI),we===i.BYTE&&(Ye=i.RG8I),we===i.SHORT&&(Ye=i.RG16I),we===i.INT&&(Ye=i.RG32I)),H===i.RGB_INTEGER&&(we===i.UNSIGNED_BYTE&&(Ye=i.RGB8UI),we===i.UNSIGNED_SHORT&&(Ye=i.RGB16UI),we===i.UNSIGNED_INT&&(Ye=i.RGB32UI),we===i.BYTE&&(Ye=i.RGB8I),we===i.SHORT&&(Ye=i.RGB16I),we===i.INT&&(Ye=i.RGB32I)),H===i.RGBA_INTEGER&&(we===i.UNSIGNED_BYTE&&(Ye=i.RGBA8UI),we===i.UNSIGNED_SHORT&&(Ye=i.RGBA16UI),we===i.UNSIGNED_INT&&(Ye=i.RGBA32UI),we===i.BYTE&&(Ye=i.RGBA8I),we===i.SHORT&&(Ye=i.RGBA16I),we===i.INT&&(Ye=i.RGBA32I)),H===i.RGB&&(we===i.UNSIGNED_INT_5_9_9_9_REV&&(Ye=i.RGB9_E5),we===i.UNSIGNED_INT_10F_11F_11F_REV&&(Ye=i.R11F_G11F_B10F)),H===i.RGBA){const dn=ut?Uc:pn.getTransfer($e);we===i.FLOAT&&(Ye=i.RGBA32F),we===i.HALF_FLOAT&&(Ye=i.RGBA16F),we===i.UNSIGNED_BYTE&&(Ye=dn===Dt?i.SRGB8_ALPHA8:i.RGBA8),we===i.UNSIGNED_SHORT_4_4_4_4&&(Ye=i.RGBA4),we===i.UNSIGNED_SHORT_5_5_5_1&&(Ye=i.RGB5_A1)}return(Ye===i.R16F||Ye===i.R32F||Ye===i.RG16F||Ye===i.RG32F||Ye===i.RGBA16F||Ye===i.RGBA32F)&&e.get("EXT_color_buffer_float"),Ye}function P(K,H){let we;return K?H===null||H===pi||H===mo?we=i.DEPTH24_STENCIL8:H===mi?we=i.DEPTH32F_STENCIL8:H===Go&&(we=i.DEPTH24_STENCIL8,console.warn("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):H===null||H===pi||H===mo?we=i.DEPTH_COMPONENT24:H===mi?we=i.DEPTH_COMPONENT32F:H===Go&&(we=i.DEPTH_COMPONENT16),we}function B(K,H){return T(K)===!0||K.isFramebufferTexture&&K.minFilter!==Jn&&K.minFilter!==Yn?Math.log2(Math.max(H.width,H.height))+1:K.mipmaps!==void 0&&K.mipmaps.length>0?K.mipmaps.length:K.isCompressedTexture&&Array.isArray(K.image)?H.mipmaps.length:1}function F(K){const H=K.target;H.removeEventListener("dispose",F),V(H),H.isVideoTexture&&p.delete(H)}function k(K){const H=K.target;H.removeEventListener("dispose",k),z(H)}function V(K){const H=n.get(K);if(H.__webglInit===void 0)return;const we=K.source,$e=y.get(we);if($e){const ut=$e[H.__cacheKey];ut.usedTimes--,ut.usedTimes===0&&U(K),Object.keys($e).length===0&&y.delete(we)}n.remove(K)}function U(K){const H=n.get(K);i.deleteTexture(H.__webglTexture);const we=K.source,$e=y.get(we);delete $e[H.__cacheKey],a.memory.textures--}function z(K){const H=n.get(K);if(K.depthTexture&&(K.depthTexture.dispose(),n.remove(K.depthTexture)),K.isWebGLCubeRenderTarget)for(let $e=0;$e<6;$e++){if(Array.isArray(H.__webglFramebuffer[$e]))for(let ut=0;ut<H.__webglFramebuffer[$e].length;ut++)i.deleteFramebuffer(H.__webglFramebuffer[$e][ut]);else i.deleteFramebuffer(H.__webglFramebuffer[$e]);H.__webglDepthbuffer&&i.deleteRenderbuffer(H.__webglDepthbuffer[$e])}else{if(Array.isArray(H.__webglFramebuffer))for(let $e=0;$e<H.__webglFramebuffer.length;$e++)i.deleteFramebuffer(H.__webglFramebuffer[$e]);else i.deleteFramebuffer(H.__webglFramebuffer);if(H.__webglDepthbuffer&&i.deleteRenderbuffer(H.__webglDepthbuffer),H.__webglMultisampledFramebuffer&&i.deleteFramebuffer(H.__webglMultisampledFramebuffer),H.__webglColorRenderbuffer)for(let $e=0;$e<H.__webglColorRenderbuffer.length;$e++)H.__webglColorRenderbuffer[$e]&&i.deleteRenderbuffer(H.__webglColorRenderbuffer[$e]);H.__webglDepthRenderbuffer&&i.deleteRenderbuffer(H.__webglDepthRenderbuffer)}const we=K.textures;for(let $e=0,ut=we.length;$e<ut;$e++){const Ye=n.get(we[$e]);Ye.__webglTexture&&(i.deleteTexture(Ye.__webglTexture),a.memory.textures--),n.remove(we[$e])}n.remove(K)}let j=0;function se(){j=0}function pe(){const K=j;return K>=r.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+K+" texture units while this GPU supports only "+r.maxTextures),j+=1,K}function be(K){const H=[];return H.push(K.wrapS),H.push(K.wrapT),H.push(K.wrapR||0),H.push(K.magFilter),H.push(K.minFilter),H.push(K.anisotropy),H.push(K.internalFormat),H.push(K.format),H.push(K.type),H.push(K.generateMipmaps),H.push(K.premultiplyAlpha),H.push(K.flipY),H.push(K.unpackAlignment),H.push(K.colorSpace),H.join()}function Pe(K,H){const we=n.get(K);if(K.isVideoTexture&&Nt(K),K.isRenderTargetTexture===!1&&K.isExternalTexture!==!0&&K.version>0&&we.__version!==K.version){const $e=K.image;if($e===null)console.warn("THREE.WebGLRenderer: Texture marked for update but no image data found.");else if($e.complete===!1)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{Se(we,K,H);return}}else K.isExternalTexture&&(we.__webglTexture=K.sourceTexture?K.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,we.__webglTexture,i.TEXTURE0+H)}function Ce(K,H){const we=n.get(K);if(K.isRenderTargetTexture===!1&&K.version>0&&we.__version!==K.version){Se(we,K,H);return}t.bindTexture(i.TEXTURE_2D_ARRAY,we.__webglTexture,i.TEXTURE0+H)}function nt(K,H){const we=n.get(K);if(K.isRenderTargetTexture===!1&&K.version>0&&we.__version!==K.version){Se(we,K,H);return}t.bindTexture(i.TEXTURE_3D,we.__webglTexture,i.TEXTURE0+H)}function Le(K,H){const we=n.get(K);if(K.version>0&&we.__version!==K.version){Fe(we,K,H);return}t.bindTexture(i.TEXTURE_CUBE_MAP,we.__webglTexture,i.TEXTURE0+H)}const ht={[ba]:i.REPEAT,[Ki]:i.CLAMP_TO_EDGE,[Sa]:i.MIRRORED_REPEAT},De={[Jn]:i.NEAREST,[gp]:i.NEAREST_MIPMAP_NEAREST,[Ta]:i.NEAREST_MIPMAP_LINEAR,[Yn]:i.LINEAR,[Ic]:i.LINEAR_MIPMAP_NEAREST,[Ds]:i.LINEAR_MIPMAP_LINEAR},Je={[Q_]:i.NEVER,[s0]:i.ALWAYS,[fg]:i.LESS,[pg]:i.LEQUAL,[e0]:i.EQUAL,[i0]:i.GEQUAL,[t0]:i.GREATER,[n0]:i.NOTEQUAL};function wt(K,H){if(H.type===mi&&e.has("OES_texture_float_linear")===!1&&(H.magFilter===Yn||H.magFilter===Ic||H.magFilter===Ta||H.magFilter===Ds||H.minFilter===Yn||H.minFilter===Ic||H.minFilter===Ta||H.minFilter===Ds)&&console.warn("THREE.WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(K,i.TEXTURE_WRAP_S,ht[H.wrapS]),i.texParameteri(K,i.TEXTURE_WRAP_T,ht[H.wrapT]),(K===i.TEXTURE_3D||K===i.TEXTURE_2D_ARRAY)&&i.texParameteri(K,i.TEXTURE_WRAP_R,ht[H.wrapR]),i.texParameteri(K,i.TEXTURE_MAG_FILTER,De[H.magFilter]),i.texParameteri(K,i.TEXTURE_MIN_FILTER,De[H.minFilter]),H.compareFunction&&(i.texParameteri(K,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(K,i.TEXTURE_COMPARE_FUNC,Je[H.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(H.magFilter===Jn||H.minFilter!==Ta&&H.minFilter!==Ds||H.type===mi&&e.has("OES_texture_float_linear")===!1)return;if(H.anisotropy>1||n.get(H).__currentAnisotropy){const we=e.get("EXT_texture_filter_anisotropic");i.texParameterf(K,we.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(H.anisotropy,r.getMaxAnisotropy())),n.get(H).__currentAnisotropy=H.anisotropy}}}function Xt(K,H){let we=!1;K.__webglInit===void 0&&(K.__webglInit=!0,H.addEventListener("dispose",F));const $e=H.source;let ut=y.get($e);ut===void 0&&(ut={},y.set($e,ut));const Ye=be(H);if(Ye!==K.__cacheKey){ut[Ye]===void 0&&(ut[Ye]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,we=!0),ut[Ye].usedTimes++;const dn=ut[K.__cacheKey];dn!==void 0&&(ut[K.__cacheKey].usedTimes--,dn.usedTimes===0&&U(H)),K.__cacheKey=Ye,K.__webglTexture=ut[Ye].texture}return we}function Ln(K,H,we){return Math.floor(Math.floor(K/we)/H)}function Ke(K,H,we,$e){const Ye=K.updateRanges;if(Ye.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,H.width,H.height,we,$e,H.data);else{Ye.sort((yt,Ht)=>yt.start-Ht.start);let dn=0;for(let yt=1;yt<Ye.length;yt++){const Ht=Ye[dn],Nn=Ye[yt],yn=Ht.start+Ht.count,zt=Ln(Nn.start,H.width,4),jn=Ln(Ht.start,H.width,4);Nn.start<=yn+1&&zt===jn&&Ln(Nn.start+Nn.count-1,H.width,4)===zt?Ht.count=Math.max(Ht.count,Nn.start+Nn.count-Ht.start):(++dn,Ye[dn]=Nn)}Ye.length=dn+1;const Ct=i.getParameter(i.UNPACK_ROW_LENGTH),ln=i.getParameter(i.UNPACK_SKIP_PIXELS),cn=i.getParameter(i.UNPACK_SKIP_ROWS);i.pixelStorei(i.UNPACK_ROW_LENGTH,H.width);for(let yt=0,Ht=Ye.length;yt<Ht;yt++){const Nn=Ye[yt],yn=Math.floor(Nn.start/4),zt=Math.ceil(Nn.count/4),jn=yn%H.width,ge=Math.floor(yn/H.width),bt=zt,It=1;i.pixelStorei(i.UNPACK_SKIP_PIXELS,jn),i.pixelStorei(i.UNPACK_SKIP_ROWS,ge),t.texSubImage2D(i.TEXTURE_2D,0,jn,ge,bt,It,we,$e,H.data)}K.clearUpdateRanges(),i.pixelStorei(i.UNPACK_ROW_LENGTH,Ct),i.pixelStorei(i.UNPACK_SKIP_PIXELS,ln),i.pixelStorei(i.UNPACK_SKIP_ROWS,cn)}}function Se(K,H,we){let $e=i.TEXTURE_2D;(H.isDataArrayTexture||H.isCompressedArrayTexture)&&($e=i.TEXTURE_2D_ARRAY),H.isData3DTexture&&($e=i.TEXTURE_3D);const ut=Xt(K,H),Ye=H.source;t.bindTexture($e,K.__webglTexture,i.TEXTURE0+we);const dn=n.get(Ye);if(Ye.version!==dn.__version||ut===!0){t.activeTexture(i.TEXTURE0+we);const Ct=pn.getPrimaries(pn.workingColorSpace),ln=H.colorSpace===br?null:pn.getPrimaries(H.colorSpace),cn=H.colorSpace===br||Ct===ln?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,H.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,H.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,H.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,cn);let yt=M(H.image,!1,r.maxTextureSize);yt=Hn(H,yt);const Ht=o.convert(H.format,H.colorSpace),Nn=o.convert(H.type);let yn=R(H.internalFormat,Ht,Nn,H.colorSpace,H.isVideoTexture);wt($e,H);let zt;const jn=H.mipmaps,ge=H.isVideoTexture!==!0,bt=dn.__version===void 0||ut===!0,It=Ye.dataReady,sn=B(H,yt);if(H.isDepthTexture)yn=P(H.format===eo,H.type),bt&&(ge?t.texStorage2D(i.TEXTURE_2D,1,yn,yt.width,yt.height):t.texImage2D(i.TEXTURE_2D,0,yn,yt.width,yt.height,0,Ht,Nn,null));else if(H.isDataTexture)if(jn.length>0){ge&&bt&&t.texStorage2D(i.TEXTURE_2D,sn,yn,jn[0].width,jn[0].height);for(let _t=0,ot=jn.length;_t<ot;_t++)zt=jn[_t],ge?It&&t.texSubImage2D(i.TEXTURE_2D,_t,0,0,zt.width,zt.height,Ht,Nn,zt.data):t.texImage2D(i.TEXTURE_2D,_t,yn,zt.width,zt.height,0,Ht,Nn,zt.data);H.generateMipmaps=!1}else ge?(bt&&t.texStorage2D(i.TEXTURE_2D,sn,yn,yt.width,yt.height),It&&Ke(H,yt,Ht,Nn)):t.texImage2D(i.TEXTURE_2D,0,yn,yt.width,yt.height,0,Ht,Nn,yt.data);else if(H.isCompressedTexture)if(H.isCompressedArrayTexture){ge&&bt&&t.texStorage3D(i.TEXTURE_2D_ARRAY,sn,yn,jn[0].width,jn[0].height,yt.depth);for(let _t=0,ot=jn.length;_t<ot;_t++)if(zt=jn[_t],H.format!==_i)if(Ht!==null)if(ge){if(It)if(H.layerUpdates.size>0){const un=Ly(zt.width,zt.height,H.format,H.type);for(const Wn of H.layerUpdates){const Zi=zt.data.subarray(Wn*un/zt.data.BYTES_PER_ELEMENT,(Wn+1)*un/zt.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,_t,0,0,Wn,zt.width,zt.height,1,Ht,Zi)}H.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,_t,0,0,0,zt.width,zt.height,yt.depth,Ht,zt.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,_t,yn,zt.width,zt.height,yt.depth,0,zt.data,0,0);else console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else ge?It&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,_t,0,0,0,zt.width,zt.height,yt.depth,Ht,Nn,zt.data):t.texImage3D(i.TEXTURE_2D_ARRAY,_t,yn,zt.width,zt.height,yt.depth,0,Ht,Nn,zt.data)}else{ge&&bt&&t.texStorage2D(i.TEXTURE_2D,sn,yn,jn[0].width,jn[0].height);for(let _t=0,ot=jn.length;_t<ot;_t++)zt=jn[_t],H.format!==_i?Ht!==null?ge?It&&t.compressedTexSubImage2D(i.TEXTURE_2D,_t,0,0,zt.width,zt.height,Ht,zt.data):t.compressedTexImage2D(i.TEXTURE_2D,_t,yn,zt.width,zt.height,0,zt.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):ge?It&&t.texSubImage2D(i.TEXTURE_2D,_t,0,0,zt.width,zt.height,Ht,Nn,zt.data):t.texImage2D(i.TEXTURE_2D,_t,yn,zt.width,zt.height,0,Ht,Nn,zt.data)}else if(H.isDataArrayTexture)if(ge){if(bt&&t.texStorage3D(i.TEXTURE_2D_ARRAY,sn,yn,yt.width,yt.height,yt.depth),It)if(H.layerUpdates.size>0){const _t=Ly(yt.width,yt.height,H.format,H.type);for(const ot of H.layerUpdates){const un=yt.data.subarray(ot*_t/yt.data.BYTES_PER_ELEMENT,(ot+1)*_t/yt.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,ot,yt.width,yt.height,1,Ht,Nn,un)}H.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,yt.width,yt.height,yt.depth,Ht,Nn,yt.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,yn,yt.width,yt.height,yt.depth,0,Ht,Nn,yt.data);else if(H.isData3DTexture)ge?(bt&&t.texStorage3D(i.TEXTURE_3D,sn,yn,yt.width,yt.height,yt.depth),It&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,yt.width,yt.height,yt.depth,Ht,Nn,yt.data)):t.texImage3D(i.TEXTURE_3D,0,yn,yt.width,yt.height,yt.depth,0,Ht,Nn,yt.data);else if(H.isFramebufferTexture){if(bt)if(ge)t.texStorage2D(i.TEXTURE_2D,sn,yn,yt.width,yt.height);else{let _t=yt.width,ot=yt.height;for(let un=0;un<sn;un++)t.texImage2D(i.TEXTURE_2D,un,yn,_t,ot,0,Ht,Nn,null),_t>>=1,ot>>=1}}else if(jn.length>0){if(ge&&bt){const _t=zn(jn[0]);t.texStorage2D(i.TEXTURE_2D,sn,yn,_t.width,_t.height)}for(let _t=0,ot=jn.length;_t<ot;_t++)zt=jn[_t],ge?It&&t.texSubImage2D(i.TEXTURE_2D,_t,0,0,Ht,Nn,zt):t.texImage2D(i.TEXTURE_2D,_t,yn,Ht,Nn,zt);H.generateMipmaps=!1}else if(ge){if(bt){const _t=zn(yt);t.texStorage2D(i.TEXTURE_2D,sn,yn,_t.width,_t.height)}It&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,Ht,Nn,yt)}else t.texImage2D(i.TEXTURE_2D,0,yn,Ht,Nn,yt);T(H)&&S($e),dn.__version=Ye.version,H.onUpdate&&H.onUpdate(H)}K.__version=H.version}function Fe(K,H,we){if(H.image.length!==6)return;const $e=Xt(K,H),ut=H.source;t.bindTexture(i.TEXTURE_CUBE_MAP,K.__webglTexture,i.TEXTURE0+we);const Ye=n.get(ut);if(ut.version!==Ye.__version||$e===!0){t.activeTexture(i.TEXTURE0+we);const dn=pn.getPrimaries(pn.workingColorSpace),Ct=H.colorSpace===br?null:pn.getPrimaries(H.colorSpace),ln=H.colorSpace===br||dn===Ct?i.NONE:i.BROWSER_DEFAULT_WEBGL;i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,H.flipY),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,H.premultiplyAlpha),i.pixelStorei(i.UNPACK_ALIGNMENT,H.unpackAlignment),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,ln);const cn=H.isCompressedTexture||H.image[0].isCompressedTexture,yt=H.image[0]&&H.image[0].isDataTexture,Ht=[];for(let ot=0;ot<6;ot++)!cn&&!yt?Ht[ot]=M(H.image[ot],!0,r.maxCubemapSize):Ht[ot]=yt?H.image[ot].image:H.image[ot],Ht[ot]=Hn(H,Ht[ot]);const Nn=Ht[0],yn=o.convert(H.format,H.colorSpace),zt=o.convert(H.type),jn=R(H.internalFormat,yn,zt,H.colorSpace),ge=H.isVideoTexture!==!0,bt=Ye.__version===void 0||$e===!0,It=ut.dataReady;let sn=B(H,Nn);wt(i.TEXTURE_CUBE_MAP,H);let _t;if(cn){ge&&bt&&t.texStorage2D(i.TEXTURE_CUBE_MAP,sn,jn,Nn.width,Nn.height);for(let ot=0;ot<6;ot++){_t=Ht[ot].mipmaps;for(let un=0;un<_t.length;un++){const Wn=_t[un];H.format!==_i?yn!==null?ge?It&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ot,un,0,0,Wn.width,Wn.height,yn,Wn.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ot,un,jn,Wn.width,Wn.height,0,Wn.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):ge?It&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ot,un,0,0,Wn.width,Wn.height,yn,zt,Wn.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ot,un,jn,Wn.width,Wn.height,0,yn,zt,Wn.data)}}}else{if(_t=H.mipmaps,ge&&bt){_t.length>0&&sn++;const ot=zn(Ht[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,sn,jn,ot.width,ot.height)}for(let ot=0;ot<6;ot++)if(yt){ge?It&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ot,0,0,0,Ht[ot].width,Ht[ot].height,yn,zt,Ht[ot].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ot,0,jn,Ht[ot].width,Ht[ot].height,0,yn,zt,Ht[ot].data);for(let un=0;un<_t.length;un++){const Zi=_t[un].image[ot].image;ge?It&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ot,un+1,0,0,Zi.width,Zi.height,yn,zt,Zi.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ot,un+1,jn,Zi.width,Zi.height,0,yn,zt,Zi.data)}}else{ge?It&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ot,0,0,0,yn,zt,Ht[ot]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ot,0,jn,yn,zt,Ht[ot]);for(let un=0;un<_t.length;un++){const Wn=_t[un];ge?It&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ot,un+1,0,0,yn,zt,Wn.image[ot]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ot,un+1,jn,yn,zt,Wn.image[ot])}}}T(H)&&S(i.TEXTURE_CUBE_MAP),Ye.__version=ut.version,H.onUpdate&&H.onUpdate(H)}K.__version=H.version}function mt(K,H,we,$e,ut,Ye){const dn=o.convert(we.format,we.colorSpace),Ct=o.convert(we.type),ln=R(we.internalFormat,dn,Ct,we.colorSpace),cn=n.get(H),yt=n.get(we);if(yt.__renderTarget=H,!cn.__hasExternalTextures){const Ht=Math.max(1,H.width>>Ye),Nn=Math.max(1,H.height>>Ye);ut===i.TEXTURE_3D||ut===i.TEXTURE_2D_ARRAY?t.texImage3D(ut,Ye,ln,Ht,Nn,H.depth,0,dn,Ct,null):t.texImage2D(ut,Ye,ln,Ht,Nn,0,dn,Ct,null)}t.bindFramebuffer(i.FRAMEBUFFER,K),gt(H)?c.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,$e,ut,yt.__webglTexture,0,Mt(H)):(ut===i.TEXTURE_2D||ut>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&ut<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,$e,ut,yt.__webglTexture,Ye),t.bindFramebuffer(i.FRAMEBUFFER,null)}function Bt(K,H,we){if(i.bindRenderbuffer(i.RENDERBUFFER,K),H.depthBuffer){const $e=H.depthTexture,ut=$e&&$e.isDepthTexture?$e.type:null,Ye=P(H.stencilBuffer,ut),dn=H.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Ct=Mt(H);gt(H)?c.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,Ct,Ye,H.width,H.height):we?i.renderbufferStorageMultisample(i.RENDERBUFFER,Ct,Ye,H.width,H.height):i.renderbufferStorage(i.RENDERBUFFER,Ye,H.width,H.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,dn,i.RENDERBUFFER,K)}else{const $e=H.textures;for(let ut=0;ut<$e.length;ut++){const Ye=$e[ut],dn=o.convert(Ye.format,Ye.colorSpace),Ct=o.convert(Ye.type),ln=R(Ye.internalFormat,dn,Ct,Ye.colorSpace),cn=Mt(H);we&>(H)===!1?i.renderbufferStorageMultisample(i.RENDERBUFFER,cn,ln,H.width,H.height):gt(H)?c.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,cn,ln,H.width,H.height):i.renderbufferStorage(i.RENDERBUFFER,ln,H.width,H.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Rt(K,H){if(H&&H.isWebGLCubeRenderTarget)throw new Error("Depth Texture with cube render targets is not supported");if(t.bindFramebuffer(i.FRAMEBUFFER,K),!(H.depthTexture&&H.depthTexture.isDepthTexture))throw new Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");const $e=n.get(H.depthTexture);$e.__renderTarget=H,(!$e.__webglTexture||H.depthTexture.image.width!==H.width||H.depthTexture.image.height!==H.height)&&(H.depthTexture.image.width=H.width,H.depthTexture.image.height=H.height,H.depthTexture.needsUpdate=!0),Pe(H.depthTexture,0);const ut=$e.__webglTexture,Ye=Mt(H);if(H.depthTexture.format===Or)gt(H)?c.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,ut,0,Ye):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,ut,0);else if(H.depthTexture.format===eo)gt(H)?c.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,ut,0,Ye):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,ut,0);else throw new Error("Unknown depthTexture format")}function hn(K){const H=n.get(K),we=K.isWebGLCubeRenderTarget===!0;if(H.__boundDepthTexture!==K.depthTexture){const $e=K.depthTexture;if(H.__depthDisposeCallback&&H.__depthDisposeCallback(),$e){const ut=()=>{delete H.__boundDepthTexture,delete H.__depthDisposeCallback,$e.removeEventListener("dispose",ut)};$e.addEventListener("dispose",ut),H.__depthDisposeCallback=ut}H.__boundDepthTexture=$e}if(K.depthTexture&&!H.__autoAllocateDepthBuffer){if(we)throw new Error("target.depthTexture not supported in Cube render targets");const $e=K.texture.mipmaps;$e&&$e.length>0?Rt(H.__webglFramebuffer[0],K):Rt(H.__webglFramebuffer,K)}else if(we){H.__webglDepthbuffer=[];for(let $e=0;$e<6;$e++)if(t.bindFramebuffer(i.FRAMEBUFFER,H.__webglFramebuffer[$e]),H.__webglDepthbuffer[$e]===void 0)H.__webglDepthbuffer[$e]=i.createRenderbuffer(),Bt(H.__webglDepthbuffer[$e],K,!1);else{const ut=K.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Ye=H.__webglDepthbuffer[$e];i.bindRenderbuffer(i.RENDERBUFFER,Ye),i.framebufferRenderbuffer(i.FRAMEBUFFER,ut,i.RENDERBUFFER,Ye)}}else{const $e=K.texture.mipmaps;if($e&&$e.length>0?t.bindFramebuffer(i.FRAMEBUFFER,H.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,H.__webglFramebuffer),H.__webglDepthbuffer===void 0)H.__webglDepthbuffer=i.createRenderbuffer(),Bt(H.__webglDepthbuffer,K,!1);else{const ut=K.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,Ye=H.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,Ye),i.framebufferRenderbuffer(i.FRAMEBUFFER,ut,i.RENDERBUFFER,Ye)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function ri(K,H,we){const $e=n.get(K);H!==void 0&&mt($e.__webglFramebuffer,K,K.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),we!==void 0&&hn(K)}function re(K){const H=K.texture,we=n.get(K),$e=n.get(H);K.addEventListener("dispose",k);const ut=K.textures,Ye=K.isWebGLCubeRenderTarget===!0,dn=ut.length>1;if(dn||($e.__webglTexture===void 0&&($e.__webglTexture=i.createTexture()),$e.__version=H.version,a.memory.textures++),Ye){we.__webglFramebuffer=[];for(let Ct=0;Ct<6;Ct++)if(H.mipmaps&&H.mipmaps.length>0){we.__webglFramebuffer[Ct]=[];for(let ln=0;ln<H.mipmaps.length;ln++)we.__webglFramebuffer[Ct][ln]=i.createFramebuffer()}else we.__webglFramebuffer[Ct]=i.createFramebuffer()}else{if(H.mipmaps&&H.mipmaps.length>0){we.__webglFramebuffer=[];for(let Ct=0;Ct<H.mipmaps.length;Ct++)we.__webglFramebuffer[Ct]=i.createFramebuffer()}else we.__webglFramebuffer=i.createFramebuffer();if(dn)for(let Ct=0,ln=ut.length;Ct<ln;Ct++){const cn=n.get(ut[Ct]);cn.__webglTexture===void 0&&(cn.__webglTexture=i.createTexture(),a.memory.textures++)}if(K.samples>0&>(K)===!1){we.__webglMultisampledFramebuffer=i.createFramebuffer(),we.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,we.__webglMultisampledFramebuffer);for(let Ct=0;Ct<ut.length;Ct++){const ln=ut[Ct];we.__webglColorRenderbuffer[Ct]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,we.__webglColorRenderbuffer[Ct]);const cn=o.convert(ln.format,ln.colorSpace),yt=o.convert(ln.type),Ht=R(ln.internalFormat,cn,yt,ln.colorSpace,K.isXRRenderTarget===!0),Nn=Mt(K);i.renderbufferStorageMultisample(i.RENDERBUFFER,Nn,Ht,K.width,K.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Ct,i.RENDERBUFFER,we.__webglColorRenderbuffer[Ct])}i.bindRenderbuffer(i.RENDERBUFFER,null),K.depthBuffer&&(we.__webglDepthRenderbuffer=i.createRenderbuffer(),Bt(we.__webglDepthRenderbuffer,K,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(Ye){t.bindTexture(i.TEXTURE_CUBE_MAP,$e.__webglTexture),wt(i.TEXTURE_CUBE_MAP,H);for(let Ct=0;Ct<6;Ct++)if(H.mipmaps&&H.mipmaps.length>0)for(let ln=0;ln<H.mipmaps.length;ln++)mt(we.__webglFramebuffer[Ct][ln],K,H,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+Ct,ln);else mt(we.__webglFramebuffer[Ct],K,H,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+Ct,0);T(H)&&S(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(dn){for(let Ct=0,ln=ut.length;Ct<ln;Ct++){const cn=ut[Ct],yt=n.get(cn);let Ht=i.TEXTURE_2D;(K.isWebGL3DRenderTarget||K.isWebGLArrayRenderTarget)&&(Ht=K.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(Ht,yt.__webglTexture),wt(Ht,cn),mt(we.__webglFramebuffer,K,cn,i.COLOR_ATTACHMENT0+Ct,Ht,0),T(cn)&&S(Ht)}t.unbindTexture()}else{let Ct=i.TEXTURE_2D;if((K.isWebGL3DRenderTarget||K.isWebGLArrayRenderTarget)&&(Ct=K.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(Ct,$e.__webglTexture),wt(Ct,H),H.mipmaps&&H.mipmaps.length>0)for(let ln=0;ln<H.mipmaps.length;ln++)mt(we.__webglFramebuffer[ln],K,H,i.COLOR_ATTACHMENT0,Ct,ln);else mt(we.__webglFramebuffer,K,H,i.COLOR_ATTACHMENT0,Ct,0);T(H)&&S(Ct),t.unbindTexture()}K.depthBuffer&&hn(K)}function st(K){const H=K.textures;for(let we=0,$e=H.length;we<$e;we++){const ut=H[we];if(T(ut)){const Ye=N(K),dn=n.get(ut).__webglTexture;t.bindTexture(Ye,dn),S(Ye),t.unbindTexture()}}}const it=[],tt=[];function Qe(K){if(K.samples>0){if(gt(K)===!1){const H=K.textures,we=K.width,$e=K.height;let ut=i.COLOR_BUFFER_BIT;const Ye=K.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,dn=n.get(K),Ct=H.length>1;if(Ct)for(let cn=0;cn<H.length;cn++)t.bindFramebuffer(i.FRAMEBUFFER,dn.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+cn,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,dn.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+cn,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,dn.__webglMultisampledFramebuffer);const ln=K.texture.mipmaps;ln&&ln.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,dn.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,dn.__webglFramebuffer);for(let cn=0;cn<H.length;cn++){if(K.resolveDepthBuffer&&(K.depthBuffer&&(ut|=i.DEPTH_BUFFER_BIT),K.stencilBuffer&&K.resolveStencilBuffer&&(ut|=i.STENCIL_BUFFER_BIT)),Ct){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,dn.__webglColorRenderbuffer[cn]);const yt=n.get(H[cn]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,yt,0)}i.blitFramebuffer(0,0,we,$e,0,0,we,$e,ut,i.NEAREST),u===!0&&(it.length=0,tt.length=0,it.push(i.COLOR_ATTACHMENT0+cn),K.depthBuffer&&K.resolveDepthBuffer===!1&&(it.push(Ye),tt.push(Ye),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,tt)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,it))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),Ct)for(let cn=0;cn<H.length;cn++){t.bindFramebuffer(i.FRAMEBUFFER,dn.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+cn,i.RENDERBUFFER,dn.__webglColorRenderbuffer[cn]);const yt=n.get(H[cn]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,dn.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+cn,i.TEXTURE_2D,yt,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,dn.__webglMultisampledFramebuffer)}else if(K.depthBuffer&&K.resolveDepthBuffer===!1&&u){const H=K.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[H])}}}function Mt(K){return Math.min(r.maxSamples,K.samples)}function gt(K){const H=n.get(K);return K.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&H.__useRenderToTexture!==!1}function Nt(K){const H=a.render.frame;p.get(K)!==H&&(p.set(K,H),K.update())}function Hn(K,H){const we=K.colorSpace,$e=K.format,ut=K.type;return K.isCompressedTexture===!0||K.isVideoTexture===!0||we!==ol&&we!==br&&(pn.getTransfer(we)===Dt?($e!==_i||ut!==Ui)&&console.warn("THREE.WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):console.error("THREE.WebGLTextures: Unsupported texture color space:",we)),H}function zn(K){return typeof HTMLImageElement!="undefined"&&K instanceof HTMLImageElement?(d.width=K.naturalWidth||K.width,d.height=K.naturalHeight||K.height):typeof VideoFrame!="undefined"&&K instanceof VideoFrame?(d.width=K.displayWidth,d.height=K.displayHeight):(d.width=K.width,d.height=K.height),d}this.allocateTextureUnit=pe,this.resetTextureUnits=se,this.setTexture2D=Pe,this.setTexture2DArray=Ce,this.setTexture3D=nt,this.setTextureCube=Le,this.rebindTextures=ri,this.setupRenderTarget=re,this.updateRenderTargetMipmap=st,this.updateMultisampleRenderTarget=Qe,this.setupDepthRenderbuffer=hn,this.setupFrameBufferTexture=mt,this.useMultisampledRTT=gt}function Wk(i,e){function t(n,r=br){let o;const a=pn.getTransfer(r);if(n===Ui)return i.UNSIGNED_BYTE;if(n===yp)return i.UNSIGNED_SHORT_4_4_4_4;if(n===_p)return i.UNSIGNED_SHORT_5_5_5_1;if(n===xp)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===vp)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===Lc)return i.BYTE;if(n===Dc)return i.SHORT;if(n===Go)return i.UNSIGNED_SHORT;if(n===Ws)return i.INT;if(n===pi)return i.UNSIGNED_INT;if(n===mi)return i.FLOAT;if(n===Ts)return i.HALF_FLOAT;if(n===cg)return i.ALPHA;if(n===bd)return i.RGB;if(n===_i)return i.RGBA;if(n===Or)return i.DEPTH_COMPONENT;if(n===eo)return i.DEPTH_STENCIL;if(n===Fc)return i.RED;if(n===Dl)return i.RED_INTEGER;if(n===rl)return i.RG;if(n===qu)return i.RG_INTEGER;if(n===Xu)return i.RGBA_INTEGER;if(n===Fl||n===Bl||n===Ol||n===Ul)if(a===Dt)if(o=e.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(n===Fl)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Bl)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Ol)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Ul)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=e.get("WEBGL_compressed_texture_s3tc"),o!==null){if(n===Fl)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Bl)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Ol)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Ul)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Sd||n===Td||n===wd||n===Md)if(o=e.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(n===Sd)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Td)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===wd)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Md)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===ju||n===Yu||n===Zu)if(o=e.get("WEBGL_compressed_texture_etc"),o!==null){if(n===ju||n===Yu)return a===Dt?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(n===Zu)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(n===Ku||n===Ju||n===Qu||n===eh||n===th||n===nh||n===ih||n===sh||n===rh||n===oh||n===ah||n===lh||n===ch||n===uh)if(o=e.get("WEBGL_compressed_texture_astc"),o!==null){if(n===Ku)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Ju)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Qu)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===eh)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===th)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===nh)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===ih)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===sh)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===rh)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===oh)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===ah)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===lh)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===ch)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===uh)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===hh||n===ug||n===hg)if(o=e.get("EXT_texture_compression_bptc"),o!==null){if(n===hh)return a===Dt?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===ug)return o.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===hg)return o.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===dh||n===fh||n===ph||n===mh)if(o=e.get("EXT_texture_compression_rgtc"),o!==null){if(n===dh)return o.COMPRESSED_RED_RGTC1_EXT;if(n===fh)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===ph)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===mh)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===mo?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const $k=`
|
|
void main() {
|
|
|
|
gl_Position = vec4( position, 1.0 );
|
|
|
|
}`,qk=`
|
|
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 Xk{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new Hb(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 Jo({vertexShader:$k,fragmentShader:qk,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new vi(new ic(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class jk extends wa{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 M=typeof XRWebGLBinding!="undefined",T=new Xk,S={},N=t.getContextAttributes();let R=null,P=null;const B=[],F=[],k=new Ie;let V=null;const U=new ps;U.viewport=new an;const z=new ps;z.viewport=new an;const j=[U,z],se=new vy;let pe=null,be=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Se){let Fe=B[Se];return Fe===void 0&&(Fe=new dl,B[Se]=Fe),Fe.getTargetRaySpace()},this.getControllerGrip=function(Se){let Fe=B[Se];return Fe===void 0&&(Fe=new dl,B[Se]=Fe),Fe.getGripSpace()},this.getHand=function(Se){let Fe=B[Se];return Fe===void 0&&(Fe=new dl,B[Se]=Fe),Fe.getHandSpace()};function Pe(Se){const Fe=F.indexOf(Se.inputSource);if(Fe===-1)return;const mt=B[Fe];mt!==void 0&&(mt.update(Se.inputSource,Se.frame,d||a),mt.dispatchEvent({type:Se.type,data:Se.inputSource}))}function Ce(){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",Ce),r.removeEventListener("inputsourceschange",nt);for(let Se=0;Se<B.length;Se++){const Fe=F[Se];Fe!==null&&(F[Se]=null,B[Se].disconnect(Fe))}pe=null,be=null,T.reset();for(const Se in S)delete S[Se];e.setRenderTarget(R),x=null,y=null,m=null,r=null,P=null,Ke.stop(),n.isPresenting=!1,e.setPixelRatio(V),e.setSize(k.width,k.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Se){o=Se,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Se){c=Se,n.isPresenting===!0&&console.warn("THREE.WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return d||a},this.setReferenceSpace=function(Se){d=Se},this.getBaseLayer=function(){return y!==null?y:x},this.getBinding=function(){return m===null&&M&&(m=new XRWebGLBinding(r,t)),m},this.getFrame=function(){return v},this.getSession=function(){return r},this.setSession=function(Se){return en(this,null,function*(){if(r=Se,r!==null){if(R=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",Ce),r.addEventListener("inputsourceschange",nt),N.xrCompatible!==!0&&(yield t.makeXRCompatible()),V=e.getPixelRatio(),e.getSize(k),M&&"createProjectionLayer"in XRWebGLBinding.prototype){let mt=null,Bt=null,Rt=null;N.depth&&(Rt=N.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,mt=N.stencil?eo:Or,Bt=N.stencil?mo:pi);const hn={colorFormat:t.RGBA8,depthFormat:Rt,scaleFactor:o};m=this.getBinding(),y=m.createProjectionLayer(hn),r.updateRenderState({layers:[y]}),e.setPixelRatio(1),e.setSize(y.textureWidth,y.textureHeight,!1),P=new Aa(y.textureWidth,y.textureHeight,{format:_i,type:Ui,depthTexture:new Ao(y.textureWidth,y.textureHeight,Bt,void 0,void 0,void 0,void 0,void 0,void 0,mt),stencilBuffer:N.stencil,colorSpace:e.outputColorSpace,samples:N.antialias?4:0,resolveDepthBuffer:y.ignoreDepthValues===!1,resolveStencilBuffer:y.ignoreDepthValues===!1})}else{const mt={antialias:N.antialias,alpha:!0,depth:N.depth,stencil:N.stencil,framebufferScaleFactor:o};x=new XRWebGLLayer(r,t,mt),r.updateRenderState({baseLayer:x}),e.setPixelRatio(1),e.setSize(x.framebufferWidth,x.framebufferHeight,!1),P=new Aa(x.framebufferWidth,x.framebufferHeight,{format:_i,type:Ui,colorSpace:e.outputColorSpace,stencilBuffer:N.stencil,resolveDepthBuffer:x.ignoreDepthValues===!1,resolveStencilBuffer:x.ignoreDepthValues===!1})}P.isXRRenderTarget=!0,this.setFoveation(u),d=null,a=yield r.requestReferenceSpace(c),Ke.setContext(r),Ke.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}})},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return T.getDepthTexture()};function nt(Se){for(let Fe=0;Fe<Se.removed.length;Fe++){const mt=Se.removed[Fe],Bt=F.indexOf(mt);Bt>=0&&(F[Bt]=null,B[Bt].disconnect(mt))}for(let Fe=0;Fe<Se.added.length;Fe++){const mt=Se.added[Fe];let Bt=F.indexOf(mt);if(Bt===-1){for(let hn=0;hn<B.length;hn++)if(hn>=F.length){F.push(mt),Bt=hn;break}else if(F[hn]===null){F[hn]=mt,Bt=hn;break}if(Bt===-1)break}const Rt=B[Bt];Rt&&Rt.connect(mt)}}const Le=new W,ht=new W;function De(Se,Fe,mt){Le.setFromMatrixPosition(Fe.matrixWorld),ht.setFromMatrixPosition(mt.matrixWorld);const Bt=Le.distanceTo(ht),Rt=Fe.projectionMatrix.elements,hn=mt.projectionMatrix.elements,ri=Rt[14]/(Rt[10]-1),re=Rt[14]/(Rt[10]+1),st=(Rt[9]+1)/Rt[5],it=(Rt[9]-1)/Rt[5],tt=(Rt[8]-1)/Rt[0],Qe=(hn[8]+1)/hn[0],Mt=ri*tt,gt=ri*Qe,Nt=Bt/(-tt+Qe),Hn=Nt*-tt;if(Fe.matrixWorld.decompose(Se.position,Se.quaternion,Se.scale),Se.translateX(Hn),Se.translateZ(Nt),Se.matrixWorld.compose(Se.position,Se.quaternion,Se.scale),Se.matrixWorldInverse.copy(Se.matrixWorld).invert(),Rt[10]===-1)Se.projectionMatrix.copy(Fe.projectionMatrix),Se.projectionMatrixInverse.copy(Fe.projectionMatrixInverse);else{const zn=ri+Nt,K=re+Nt,H=Mt-Hn,we=gt+(Bt-Hn),$e=st*re/K*zn,ut=it*re/K*zn;Se.projectionMatrix.makePerspective(H,we,$e,ut,zn,K),Se.projectionMatrixInverse.copy(Se.projectionMatrix).invert()}}function Je(Se,Fe){Fe===null?Se.matrixWorld.copy(Se.matrix):Se.matrixWorld.multiplyMatrices(Fe.matrixWorld,Se.matrix),Se.matrixWorldInverse.copy(Se.matrixWorld).invert()}this.updateCamera=function(Se){if(r===null)return;let Fe=Se.near,mt=Se.far;T.texture!==null&&(T.depthNear>0&&(Fe=T.depthNear),T.depthFar>0&&(mt=T.depthFar)),se.near=z.near=U.near=Fe,se.far=z.far=U.far=mt,(pe!==se.near||be!==se.far)&&(r.updateRenderState({depthNear:se.near,depthFar:se.far}),pe=se.near,be=se.far),se.layers.mask=Se.layers.mask|6,U.layers.mask=se.layers.mask&3,z.layers.mask=se.layers.mask&5;const Bt=Se.parent,Rt=se.cameras;Je(se,Bt);for(let hn=0;hn<Rt.length;hn++)Je(Rt[hn],Bt);Rt.length===2?De(se,U,z):se.projectionMatrix.copy(U.projectionMatrix),wt(Se,se,Bt)};function wt(Se,Fe,mt){mt===null?Se.matrix.copy(Fe.matrixWorld):(Se.matrix.copy(mt.matrixWorld),Se.matrix.invert(),Se.matrix.multiply(Fe.matrixWorld)),Se.matrix.decompose(Se.position,Se.quaternion,Se.scale),Se.updateMatrixWorld(!0),Se.projectionMatrix.copy(Fe.projectionMatrix),Se.projectionMatrixInverse.copy(Fe.projectionMatrixInverse),Se.isPerspectiveCamera&&(Se.fov=gh*2*Math.atan(1/Se.projectionMatrix.elements[5]),Se.zoom=1)}this.getCamera=function(){return se},this.getFoveation=function(){if(!(y===null&&x===null))return u},this.setFoveation=function(Se){u=Se,y!==null&&(y.fixedFoveation=Se),x!==null&&x.fixedFoveation!==void 0&&(x.fixedFoveation=Se)},this.hasDepthSensing=function(){return T.texture!==null},this.getDepthSensingMesh=function(){return T.getMesh(se)},this.getCameraTexture=function(Se){return S[Se]};let Xt=null;function Ln(Se,Fe){if(p=Fe.getViewerPose(d||a),v=Fe,p!==null){const mt=p.views;x!==null&&(e.setRenderTargetFramebuffer(P,x.framebuffer),e.setRenderTarget(P));let Bt=!1;mt.length!==se.cameras.length&&(se.cameras.length=0,Bt=!0);for(let re=0;re<mt.length;re++){const st=mt[re];let it=null;if(x!==null)it=x.getViewport(st);else{const Qe=m.getViewSubImage(y,st);it=Qe.viewport,re===0&&(e.setRenderTargetTextures(P,Qe.colorTexture,Qe.depthStencilTexture),e.setRenderTarget(P))}let tt=j[re];tt===void 0&&(tt=new ps,tt.layers.enable(re),tt.viewport=new an,j[re]=tt),tt.matrix.fromArray(st.transform.matrix),tt.matrix.decompose(tt.position,tt.quaternion,tt.scale),tt.projectionMatrix.fromArray(st.projectionMatrix),tt.projectionMatrixInverse.copy(tt.projectionMatrix).invert(),tt.viewport.set(it.x,it.y,it.width,it.height),re===0&&(se.matrix.copy(tt.matrix),se.matrix.decompose(se.position,se.quaternion,se.scale)),Bt===!0&&se.cameras.push(tt)}const Rt=r.enabledFeatures;if(Rt&&Rt.includes("depth-sensing")&&r.depthUsage=="gpu-optimized"&&M){m=n.getBinding();const re=m.getDepthInformation(mt[0]);re&&re.isValid&&re.texture&&T.init(re,r.renderState)}if(Rt&&Rt.includes("camera-access")&&M){e.state.unbindTexture(),m=n.getBinding();for(let re=0;re<mt.length;re++){const st=mt[re].camera;if(st){let it=S[st];it||(it=new Hb,S[st]=it);const tt=m.getCameraImage(st);it.sourceTexture=tt}}}}for(let mt=0;mt<B.length;mt++){const Bt=F[mt],Rt=B[mt];Bt!==null&&Rt!==void 0&&Rt.update(Bt,Fe,d||a)}Xt&&Xt(Se,Fe),Fe.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:Fe}),v=null}const Ke=new tE;Ke.setAnimationLoop(Ln),this.setAnimationLoop=function(Se){Xt=Se},this.dispose=function(){}}}const Of=new Gr,Yk=new Vt;function Zk(i,e){function t(T,S){T.matrixAutoUpdate===!0&&T.updateMatrix(),S.value.copy(T.matrix)}function n(T,S){S.color.getRGB(T.fogColor.value,y0(i)),S.isFog?(T.fogNear.value=S.near,T.fogFar.value=S.far):S.isFogExp2&&(T.fogDensity.value=S.density)}function r(T,S,N,R,P){S.isMeshBasicMaterial||S.isMeshLambertMaterial?o(T,S):S.isMeshToonMaterial?(o(T,S),m(T,S)):S.isMeshPhongMaterial?(o(T,S),p(T,S)):S.isMeshStandardMaterial?(o(T,S),y(T,S),S.isMeshPhysicalMaterial&&x(T,S,P)):S.isMeshMatcapMaterial?(o(T,S),v(T,S)):S.isMeshDepthMaterial?o(T,S):S.isMeshDistanceMaterial?(o(T,S),M(T,S)):S.isMeshNormalMaterial?o(T,S):S.isLineBasicMaterial?(a(T,S),S.isLineDashedMaterial&&c(T,S)):S.isPointsMaterial?u(T,S,N,R):S.isSpriteMaterial?d(T,S):S.isShadowMaterial?(T.color.value.copy(S.color),T.opacity.value=S.opacity):S.isShaderMaterial&&(S.uniformsNeedUpdate=!1)}function o(T,S){T.opacity.value=S.opacity,S.color&&T.diffuse.value.copy(S.color),S.emissive&&T.emissive.value.copy(S.emissive).multiplyScalar(S.emissiveIntensity),S.map&&(T.map.value=S.map,t(S.map,T.mapTransform)),S.alphaMap&&(T.alphaMap.value=S.alphaMap,t(S.alphaMap,T.alphaMapTransform)),S.bumpMap&&(T.bumpMap.value=S.bumpMap,t(S.bumpMap,T.bumpMapTransform),T.bumpScale.value=S.bumpScale,S.side===Ee&&(T.bumpScale.value*=-1)),S.normalMap&&(T.normalMap.value=S.normalMap,t(S.normalMap,T.normalMapTransform),T.normalScale.value.copy(S.normalScale),S.side===Ee&&T.normalScale.value.negate()),S.displacementMap&&(T.displacementMap.value=S.displacementMap,t(S.displacementMap,T.displacementMapTransform),T.displacementScale.value=S.displacementScale,T.displacementBias.value=S.displacementBias),S.emissiveMap&&(T.emissiveMap.value=S.emissiveMap,t(S.emissiveMap,T.emissiveMapTransform)),S.specularMap&&(T.specularMap.value=S.specularMap,t(S.specularMap,T.specularMapTransform)),S.alphaTest>0&&(T.alphaTest.value=S.alphaTest);const N=e.get(S),R=N.envMap,P=N.envMapRotation;R&&(T.envMap.value=R,Of.copy(P),Of.x*=-1,Of.y*=-1,Of.z*=-1,R.isCubeTexture&&R.isRenderTargetTexture===!1&&(Of.y*=-1,Of.z*=-1),T.envMapRotation.value.setFromMatrix4(Yk.makeRotationFromEuler(Of)),T.flipEnvMap.value=R.isCubeTexture&&R.isRenderTargetTexture===!1?-1:1,T.reflectivity.value=S.reflectivity,T.ior.value=S.ior,T.refractionRatio.value=S.refractionRatio),S.lightMap&&(T.lightMap.value=S.lightMap,T.lightMapIntensity.value=S.lightMapIntensity,t(S.lightMap,T.lightMapTransform)),S.aoMap&&(T.aoMap.value=S.aoMap,T.aoMapIntensity.value=S.aoMapIntensity,t(S.aoMap,T.aoMapTransform))}function a(T,S){T.diffuse.value.copy(S.color),T.opacity.value=S.opacity,S.map&&(T.map.value=S.map,t(S.map,T.mapTransform))}function c(T,S){T.dashSize.value=S.dashSize,T.totalSize.value=S.dashSize+S.gapSize,T.scale.value=S.scale}function u(T,S,N,R){T.diffuse.value.copy(S.color),T.opacity.value=S.opacity,T.size.value=S.size*N,T.scale.value=R*.5,S.map&&(T.map.value=S.map,t(S.map,T.uvTransform)),S.alphaMap&&(T.alphaMap.value=S.alphaMap,t(S.alphaMap,T.alphaMapTransform)),S.alphaTest>0&&(T.alphaTest.value=S.alphaTest)}function d(T,S){T.diffuse.value.copy(S.color),T.opacity.value=S.opacity,T.rotation.value=S.rotation,S.map&&(T.map.value=S.map,t(S.map,T.mapTransform)),S.alphaMap&&(T.alphaMap.value=S.alphaMap,t(S.alphaMap,T.alphaMapTransform)),S.alphaTest>0&&(T.alphaTest.value=S.alphaTest)}function p(T,S){T.specular.value.copy(S.specular),T.shininess.value=Math.max(S.shininess,1e-4)}function m(T,S){S.gradientMap&&(T.gradientMap.value=S.gradientMap)}function y(T,S){T.metalness.value=S.metalness,S.metalnessMap&&(T.metalnessMap.value=S.metalnessMap,t(S.metalnessMap,T.metalnessMapTransform)),T.roughness.value=S.roughness,S.roughnessMap&&(T.roughnessMap.value=S.roughnessMap,t(S.roughnessMap,T.roughnessMapTransform)),S.envMap&&(T.envMapIntensity.value=S.envMapIntensity)}function x(T,S,N){T.ior.value=S.ior,S.sheen>0&&(T.sheenColor.value.copy(S.sheenColor).multiplyScalar(S.sheen),T.sheenRoughness.value=S.sheenRoughness,S.sheenColorMap&&(T.sheenColorMap.value=S.sheenColorMap,t(S.sheenColorMap,T.sheenColorMapTransform)),S.sheenRoughnessMap&&(T.sheenRoughnessMap.value=S.sheenRoughnessMap,t(S.sheenRoughnessMap,T.sheenRoughnessMapTransform))),S.clearcoat>0&&(T.clearcoat.value=S.clearcoat,T.clearcoatRoughness.value=S.clearcoatRoughness,S.clearcoatMap&&(T.clearcoatMap.value=S.clearcoatMap,t(S.clearcoatMap,T.clearcoatMapTransform)),S.clearcoatRoughnessMap&&(T.clearcoatRoughnessMap.value=S.clearcoatRoughnessMap,t(S.clearcoatRoughnessMap,T.clearcoatRoughnessMapTransform)),S.clearcoatNormalMap&&(T.clearcoatNormalMap.value=S.clearcoatNormalMap,t(S.clearcoatNormalMap,T.clearcoatNormalMapTransform),T.clearcoatNormalScale.value.copy(S.clearcoatNormalScale),S.side===Ee&&T.clearcoatNormalScale.value.negate())),S.dispersion>0&&(T.dispersion.value=S.dispersion),S.iridescence>0&&(T.iridescence.value=S.iridescence,T.iridescenceIOR.value=S.iridescenceIOR,T.iridescenceThicknessMinimum.value=S.iridescenceThicknessRange[0],T.iridescenceThicknessMaximum.value=S.iridescenceThicknessRange[1],S.iridescenceMap&&(T.iridescenceMap.value=S.iridescenceMap,t(S.iridescenceMap,T.iridescenceMapTransform)),S.iridescenceThicknessMap&&(T.iridescenceThicknessMap.value=S.iridescenceThicknessMap,t(S.iridescenceThicknessMap,T.iridescenceThicknessMapTransform))),S.transmission>0&&(T.transmission.value=S.transmission,T.transmissionSamplerMap.value=N.texture,T.transmissionSamplerSize.value.set(N.width,N.height),S.transmissionMap&&(T.transmissionMap.value=S.transmissionMap,t(S.transmissionMap,T.transmissionMapTransform)),T.thickness.value=S.thickness,S.thicknessMap&&(T.thicknessMap.value=S.thicknessMap,t(S.thicknessMap,T.thicknessMapTransform)),T.attenuationDistance.value=S.attenuationDistance,T.attenuationColor.value.copy(S.attenuationColor)),S.anisotropy>0&&(T.anisotropyVector.value.set(S.anisotropy*Math.cos(S.anisotropyRotation),S.anisotropy*Math.sin(S.anisotropyRotation)),S.anisotropyMap&&(T.anisotropyMap.value=S.anisotropyMap,t(S.anisotropyMap,T.anisotropyMapTransform))),T.specularIntensity.value=S.specularIntensity,T.specularColor.value.copy(S.specularColor),S.specularColorMap&&(T.specularColorMap.value=S.specularColorMap,t(S.specularColorMap,T.specularColorMapTransform)),S.specularIntensityMap&&(T.specularIntensityMap.value=S.specularIntensityMap,t(S.specularIntensityMap,T.specularIntensityMapTransform))}function v(T,S){S.matcap&&(T.matcap.value=S.matcap)}function M(T,S){const N=e.get(S).light;T.referencePosition.value.setFromMatrixPosition(N.matrixWorld),T.nearDistance.value=N.shadow.camera.near,T.farDistance.value=N.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:r}}function Kk(i,e,t,n){let r={},o={},a=[];const c=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function u(N,R){const P=R.program;n.uniformBlockBinding(N,P)}function d(N,R){let P=r[N.id];P===void 0&&(v(N),P=p(N),r[N.id]=P,N.addEventListener("dispose",T));const B=R.program;n.updateUBOMapping(N,B);const F=e.render.frame;o[N.id]!==F&&(y(N),o[N.id]=F)}function p(N){const R=m();N.__bindingPointIndex=R;const P=i.createBuffer(),B=N.__size,F=N.usage;return i.bindBuffer(i.UNIFORM_BUFFER,P),i.bufferData(i.UNIFORM_BUFFER,B,F),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,R,P),P}function m(){for(let N=0;N<c;N++)if(a.indexOf(N)===-1)return a.push(N),N;return console.error("THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function y(N){const R=r[N.id],P=N.uniforms,B=N.__cache;i.bindBuffer(i.UNIFORM_BUFFER,R);for(let F=0,k=P.length;F<k;F++){const V=Array.isArray(P[F])?P[F]:[P[F]];for(let U=0,z=V.length;U<z;U++){const j=V[U];if(x(j,F,U,B)===!0){const se=j.__offset,pe=Array.isArray(j.value)?j.value:[j.value];let be=0;for(let Pe=0;Pe<pe.length;Pe++){const Ce=pe[Pe],nt=M(Ce);typeof Ce=="number"||typeof Ce=="boolean"?(j.__data[0]=Ce,i.bufferSubData(i.UNIFORM_BUFFER,se+be,j.__data)):Ce.isMatrix3?(j.__data[0]=Ce.elements[0],j.__data[1]=Ce.elements[1],j.__data[2]=Ce.elements[2],j.__data[3]=0,j.__data[4]=Ce.elements[3],j.__data[5]=Ce.elements[4],j.__data[6]=Ce.elements[5],j.__data[7]=0,j.__data[8]=Ce.elements[6],j.__data[9]=Ce.elements[7],j.__data[10]=Ce.elements[8],j.__data[11]=0):(Ce.toArray(j.__data,be),be+=nt.storage/Float32Array.BYTES_PER_ELEMENT)}i.bufferSubData(i.UNIFORM_BUFFER,se,j.__data)}}}i.bindBuffer(i.UNIFORM_BUFFER,null)}function x(N,R,P,B){const F=N.value,k=R+"_"+P;if(B[k]===void 0)return typeof F=="number"||typeof F=="boolean"?B[k]=F:B[k]=F.clone(),!0;{const V=B[k];if(typeof F=="number"||typeof F=="boolean"){if(V!==F)return B[k]=F,!0}else if(V.equals(F)===!1)return V.copy(F),!0}return!1}function v(N){const R=N.uniforms;let P=0;const B=16;for(let k=0,V=R.length;k<V;k++){const U=Array.isArray(R[k])?R[k]:[R[k]];for(let z=0,j=U.length;z<j;z++){const se=U[z],pe=Array.isArray(se.value)?se.value:[se.value];for(let be=0,Pe=pe.length;be<Pe;be++){const Ce=pe[be],nt=M(Ce),Le=P%B,ht=Le%nt.boundary,De=Le+ht;P+=ht,De!==0&&B-De<nt.storage&&(P+=B-De),se.__data=new Float32Array(nt.storage/Float32Array.BYTES_PER_ELEMENT),se.__offset=P,P+=nt.storage}}}const F=P%B;return F>0&&(P+=B-F),N.__size=P,N.__cache={},this}function M(N){const R={boundary:0,storage:0};return typeof N=="number"||typeof N=="boolean"?(R.boundary=4,R.storage=4):N.isVector2?(R.boundary=8,R.storage=8):N.isVector3||N.isColor?(R.boundary=16,R.storage=12):N.isVector4?(R.boundary=16,R.storage=16):N.isMatrix3?(R.boundary=48,R.storage=48):N.isMatrix4?(R.boundary=64,R.storage=64):N.isTexture?console.warn("THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group."):console.warn("THREE.WebGLRenderer: Unsupported uniform value type.",N),R}function T(N){const R=N.target;R.removeEventListener("dispose",T);const P=a.indexOf(R.__bindingPointIndex);a.splice(P,1),i.deleteBuffer(r[R.id]),delete r[R.id],delete o[R.id]}function S(){for(const N in r)i.deleteBuffer(r[N]);a=[],r={},o={}}return{bind:u,update:d,dispose:S}}class Jk{constructor(e={}){const{canvas:t=hr(),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}=e;this.isWebGLRenderer=!0;let x;if(n!==null){if(typeof WebGLRenderingContext!="undefined"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");x=n.getContextAttributes().alpha}else x=a;const v=new Uint32Array(4),M=new Int32Array(4);let T=null,S=null;const N=[],R=[];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=Qr,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const P=this;let B=!1;this._outputColorSpace=Ei;let F=0,k=0,V=null,U=-1,z=null;const j=new an,se=new an;let pe=null;const be=new At(0);let Pe=0,Ce=t.width,nt=t.height,Le=1,ht=null,De=null;const Je=new an(0,0,Ce,nt),wt=new an(0,0,Ce,nt);let Xt=!1;const Ln=new Ih;let Ke=!1,Se=!1;const Fe=new Vt,mt=new W,Bt=new an,Rt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let hn=!1;function ri(){return V===null?Le:1}let re=n;function st(q,ve){return t.getContext(q,ve)}try{const q={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${_e}`),t.addEventListener("webglcontextlost",It,!1),t.addEventListener("webglcontextrestored",sn,!1),t.addEventListener("webglcontextcreationerror",_t,!1),re===null){const ve="webgl2";if(re=st(ve,q),re===null)throw st(ve)?new Error("Error creating WebGL context with your selected attributes."):new Error("Error creating WebGL context.")}}catch(q){throw console.error("THREE.WebGLRenderer: "+q.message),q}let it,tt,Qe,Mt,gt,Nt,Hn,zn,K,H,we,$e,ut,Ye,dn,Ct,ln,cn,yt,Ht,Nn,yn,zt,jn;function ge(){it=new l3(re),it.init(),yn=new Wk(re,it),tt=new t3(re,it,e,yn),Qe=new Gk(re,it),tt.reversedDepthBuffer&&y&&Qe.buffers.depth.setReversed(!0),Mt=new h3(re),gt=new Rk,Nt=new Hk(re,it,Qe,gt,tt,yn,Mt),Hn=new i3(P),zn=new a3(P),K=new KB(re),zt=new QU(re,K),H=new c3(re,K,Mt,zt),we=new f3(re,H,K,Mt),yt=new d3(re,tt,Nt),Ct=new n3(gt),$e=new Ck(P,Hn,zn,it,tt,zt,Ct),ut=new Zk(P,gt),Ye=new Pk,dn=new Ok(it),cn=new JU(P,Hn,zn,Qe,we,x,u),ln=new zk(P,we,tt),jn=new Kk(re,Mt,tt,Qe),Ht=new e3(re,it,Mt),Nn=new u3(re,it,Mt),Mt.programs=$e.programs,P.capabilities=tt,P.extensions=it,P.properties=gt,P.renderLists=Ye,P.shadowMap=ln,P.state=Qe,P.info=Mt}ge();const bt=new jk(P,re);this.xr=bt,this.getContext=function(){return re},this.getContextAttributes=function(){return re.getContextAttributes()},this.forceContextLoss=function(){const q=it.get("WEBGL_lose_context");q&&q.loseContext()},this.forceContextRestore=function(){const q=it.get("WEBGL_lose_context");q&&q.restoreContext()},this.getPixelRatio=function(){return Le},this.setPixelRatio=function(q){q!==void 0&&(Le=q,this.setSize(Ce,nt,!1))},this.getSize=function(q){return q.set(Ce,nt)},this.setSize=function(q,ve,Ue=!0){if(bt.isPresenting){console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting.");return}Ce=q,nt=ve,t.width=Math.floor(q*Le),t.height=Math.floor(ve*Le),Ue===!0&&(t.style.width=q+"px",t.style.height=ve+"px"),this.setViewport(0,0,q,ve)},this.getDrawingBufferSize=function(q){return q.set(Ce*Le,nt*Le).floor()},this.setDrawingBufferSize=function(q,ve,Ue){Ce=q,nt=ve,Le=Ue,t.width=Math.floor(q*Ue),t.height=Math.floor(ve*Ue),this.setViewport(0,0,q,ve)},this.getCurrentViewport=function(q){return q.copy(j)},this.getViewport=function(q){return q.copy(Je)},this.setViewport=function(q,ve,Ue,ze){q.isVector4?Je.set(q.x,q.y,q.z,q.w):Je.set(q,ve,Ue,ze),Qe.viewport(j.copy(Je).multiplyScalar(Le).round())},this.getScissor=function(q){return q.copy(wt)},this.setScissor=function(q,ve,Ue,ze){q.isVector4?wt.set(q.x,q.y,q.z,q.w):wt.set(q,ve,Ue,ze),Qe.scissor(se.copy(wt).multiplyScalar(Le).round())},this.getScissorTest=function(){return Xt},this.setScissorTest=function(q){Qe.setScissorTest(Xt=q)},this.setOpaqueSort=function(q){ht=q},this.setTransparentSort=function(q){De=q},this.getClearColor=function(q){return q.copy(cn.getClearColor())},this.setClearColor=function(){cn.setClearColor(...arguments)},this.getClearAlpha=function(){return cn.getClearAlpha()},this.setClearAlpha=function(){cn.setClearAlpha(...arguments)},this.clear=function(q=!0,ve=!0,Ue=!0){let ze=0;if(q){let Te=!1;if(V!==null){const vt=V.texture.format;Te=vt===Xu||vt===qu||vt===Dl}if(Te){const vt=V.texture.type,Gt=vt===Ui||vt===pi||vt===Go||vt===mo||vt===yp||vt===_p,on=cn.getClearColor(),Qt=cn.getClearAlpha(),Rn=on.r,Dn=on.g,vn=on.b;Gt?(v[0]=Rn,v[1]=Dn,v[2]=vn,v[3]=Qt,re.clearBufferuiv(re.COLOR,0,v)):(M[0]=Rn,M[1]=Dn,M[2]=vn,M[3]=Qt,re.clearBufferiv(re.COLOR,0,M))}else ze|=re.COLOR_BUFFER_BIT}ve&&(ze|=re.DEPTH_BUFFER_BIT),Ue&&(ze|=re.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),re.clear(ze)},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",It,!1),t.removeEventListener("webglcontextrestored",sn,!1),t.removeEventListener("webglcontextcreationerror",_t,!1),cn.dispose(),Ye.dispose(),dn.dispose(),gt.dispose(),Hn.dispose(),zn.dispose(),we.dispose(),zt.dispose(),jn.dispose(),$e.dispose(),bt.dispose(),bt.removeEventListener("sessionstart",Ac),bt.removeEventListener("sessionend",nD),dp.stop()};function It(q){q.preventDefault(),console.log("THREE.WebGLRenderer: Context Lost."),B=!0}function sn(){console.log("THREE.WebGLRenderer: Context Restored."),B=!1;const q=Mt.autoReset,ve=ln.enabled,Ue=ln.autoUpdate,ze=ln.needsUpdate,Te=ln.type;ge(),Mt.autoReset=q,ln.enabled=ve,ln.autoUpdate=Ue,ln.needsUpdate=ze,ln.type=Te}function _t(q){console.error("THREE.WebGLRenderer: A WebGL context could not be created. Reason: ",q.statusMessage)}function ot(q){const ve=q.target;ve.removeEventListener("dispose",ot),un(ve)}function un(q){Wn(q),gt.remove(q)}function Wn(q){const ve=gt.get(q).programs;ve!==void 0&&(ve.forEach(function(Ue){$e.releaseProgram(Ue)}),q.isShaderMaterial&&$e.releaseShaderCache(q))}this.renderBufferDirect=function(q,ve,Ue,ze,Te,vt){ve===null&&(ve=Rt);const Gt=Te.isMesh&&Te.matrixWorld.determinant()<0,on=pY(q,ve,Ue,ze,Te);Qe.setMaterial(ze,Gt);let Qt=Ue.index,Rn=1;if(ze.wireframe===!0){if(Qt=H.getWireframeAttribute(Ue),Qt===void 0)return;Rn=2}const Dn=Ue.drawRange,vn=Ue.attributes.position;let ai=Dn.start*Rn,Oi=(Dn.start+Dn.count)*Rn;vt!==null&&(ai=Math.max(ai,vt.start*Rn),Oi=Math.min(Oi,(vt.start+vt.count)*Rn)),Qt!==null?(ai=Math.max(ai,0),Oi=Math.min(Oi,Qt.count)):vn!=null&&(ai=Math.max(ai,0),Oi=Math.min(Oi,vn.count));const Ls=Oi-ai;if(Ls<0||Ls===1/0)return;zt.setup(Te,ze,on,Ue,Qt);let rs,Gi=Ht;if(Qt!==null&&(rs=K.get(Qt),Gi=Nn,Gi.setIndex(rs)),Te.isMesh)ze.wireframe===!0?(Qe.setLineWidth(ze.wireframeLinewidth*ri()),Gi.setMode(re.LINES)):Gi.setMode(re.TRIANGLES);else if(Te.isLine){let wn=ze.linewidth;wn===void 0&&(wn=1),Qe.setLineWidth(wn*ri()),Te.isLineSegments?Gi.setMode(re.LINES):Te.isLineLoop?Gi.setMode(re.LINE_LOOP):Gi.setMode(re.LINE_STRIP)}else Te.isPoints?Gi.setMode(re.POINTS):Te.isSprite&&Gi.setMode(re.TRIANGLES);if(Te.isBatchedMesh)if(Te._multiDrawInstances!==null)wr("THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),Gi.renderMultiDrawInstances(Te._multiDrawStarts,Te._multiDrawCounts,Te._multiDrawCount,Te._multiDrawInstances);else if(it.get("WEBGL_multi_draw"))Gi.renderMultiDraw(Te._multiDrawStarts,Te._multiDrawCounts,Te._multiDrawCount);else{const wn=Te._multiDrawStarts,xs=Te._multiDrawCounts,gi=Te._multiDrawCount,ga=Qt?K.get(Qt).bytesPerElement:1,ag=gt.get(ze).currentProgram.getUniforms();for(let ya=0;ya<gi;ya++)ag.setValue(re,"_gl_DrawID",ya),Gi.render(wn[ya]/ga,xs[ya])}else if(Te.isInstancedMesh)Gi.renderInstances(ai,Ls,Te.count);else if(Ue.isInstancedBufferGeometry){const wn=Ue._maxInstanceCount!==void 0?Ue._maxInstanceCount:1/0,xs=Math.min(Ue.instanceCount,wn);Gi.renderInstances(ai,Ls,xs)}else Gi.render(ai,Ls)};function Zi(q,ve,Ue){q.transparent===!0&&q.side===ke&&q.forceSinglePass===!1?(q.side=Ee,q.needsUpdate=!0,ub(q,ve,Ue),q.side=Be,q.needsUpdate=!0,ub(q,ve,Ue),q.side=ke):ub(q,ve,Ue)}this.compile=function(q,ve,Ue=null){Ue===null&&(Ue=q),S=dn.get(Ue),S.init(ve),R.push(S),Ue.traverseVisible(function(Te){Te.isLight&&Te.layers.test(ve.layers)&&(S.pushLight(Te),Te.castShadow&&S.pushShadow(Te))}),q!==Ue&&q.traverseVisible(function(Te){Te.isLight&&Te.layers.test(ve.layers)&&(S.pushLight(Te),Te.castShadow&&S.pushShadow(Te))}),S.setupLights();const ze=new Set;return q.traverse(function(Te){if(!(Te.isMesh||Te.isPoints||Te.isLine||Te.isSprite))return;const vt=Te.material;if(vt)if(Array.isArray(vt))for(let Gt=0;Gt<vt.length;Gt++){const on=vt[Gt];Zi(on,Ue,Te),ze.add(on)}else Zi(vt,Ue,Te),ze.add(vt)}),S=R.pop(),ze},this.compileAsync=function(q,ve,Ue=null){const ze=this.compile(q,ve,Ue);return new Promise(Te=>{function vt(){if(ze.forEach(function(Gt){gt.get(Gt).currentProgram.isReady()&&ze.delete(Gt)}),ze.size===0){Te(q);return}setTimeout(vt,10)}it.get("KHR_parallel_shader_compile")!==null?vt():setTimeout(vt,10)})};let Pi=null;function Gu(q){Pi&&Pi(q)}function Ac(){dp.stop()}function nD(){dp.start()}const dp=new tE;dp.setAnimationLoop(Gu),typeof self!="undefined"&&dp.setContext(self),this.setAnimationLoop=function(q){Pi=q,bt.setAnimationLoop(q),q===null?dp.stop():dp.start()},bt.addEventListener("sessionstart",Ac),bt.addEventListener("sessionend",nD),this.render=function(q,ve){if(ve!==void 0&&ve.isCamera!==!0){console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(B===!0)return;if(q.matrixWorldAutoUpdate===!0&&q.updateMatrixWorld(),ve.parent===null&&ve.matrixWorldAutoUpdate===!0&&ve.updateMatrixWorld(),bt.enabled===!0&&bt.isPresenting===!0&&(bt.cameraAutoUpdate===!0&&bt.updateCamera(ve),ve=bt.getCamera()),q.isScene===!0&&q.onBeforeRender(P,q,ve,V),S=dn.get(q,R.length),S.init(ve),R.push(S),Fe.multiplyMatrices(ve.projectionMatrix,ve.matrixWorldInverse),Ln.setFromProjectionMatrix(Fe,ki,ve.reversedDepth),Se=this.localClippingEnabled,Ke=Ct.init(this.clippingPlanes,Se),T=Ye.get(q,N.length),T.init(),N.push(T),bt.enabled===!0&&bt.isPresenting===!0){const vt=P.xr.getDepthSensingMesh();vt!==null&&M1(vt,ve,-1/0,P.sortObjects)}M1(q,ve,0,P.sortObjects),T.finish(),P.sortObjects===!0&&T.sort(ht,De),hn=bt.enabled===!1||bt.isPresenting===!1||bt.hasDepthSensing()===!1,hn&&cn.addToRenderList(T,q),this.info.render.frame++,Ke===!0&&Ct.beginShadows();const Ue=S.state.shadowsArray;ln.render(Ue,q,ve),Ke===!0&&Ct.endShadows(),this.info.autoReset===!0&&this.info.reset();const ze=T.opaque,Te=T.transmissive;if(S.setupLights(),ve.isArrayCamera){const vt=ve.cameras;if(Te.length>0)for(let Gt=0,on=vt.length;Gt<on;Gt++){const Qt=vt[Gt];sD(ze,Te,q,Qt)}hn&&cn.render(q);for(let Gt=0,on=vt.length;Gt<on;Gt++){const Qt=vt[Gt];iD(T,q,Qt,Qt.viewport)}}else Te.length>0&&sD(ze,Te,q,ve),hn&&cn.render(q),iD(T,q,ve);V!==null&&k===0&&(Nt.updateMultisampleRenderTarget(V),Nt.updateRenderTargetMipmap(V)),q.isScene===!0&&q.onAfterRender(P,q,ve),zt.resetDefaultState(),U=-1,z=null,R.pop(),R.length>0?(S=R[R.length-1],Ke===!0&&Ct.setGlobalState(P.clippingPlanes,S.state.camera)):S=null,N.pop(),N.length>0?T=N[N.length-1]:T=null};function M1(q,ve,Ue,ze){if(q.visible===!1)return;if(q.layers.test(ve.layers)){if(q.isGroup)Ue=q.renderOrder;else if(q.isLOD)q.autoUpdate===!0&&q.update(ve);else if(q.isLight)S.pushLight(q),q.castShadow&&S.pushShadow(q);else if(q.isSprite){if(!q.frustumCulled||Ln.intersectsSprite(q)){ze&&Bt.setFromMatrixPosition(q.matrixWorld).applyMatrix4(Fe);const Gt=we.update(q),on=q.material;on.visible&&T.push(q,Gt,on,Ue,Bt.z,null)}}else if((q.isMesh||q.isLine||q.isPoints)&&(!q.frustumCulled||Ln.intersectsObject(q))){const Gt=we.update(q),on=q.material;if(ze&&(q.boundingSphere!==void 0?(q.boundingSphere===null&&q.computeBoundingSphere(),Bt.copy(q.boundingSphere.center)):(Gt.boundingSphere===null&&Gt.computeBoundingSphere(),Bt.copy(Gt.boundingSphere.center)),Bt.applyMatrix4(q.matrixWorld).applyMatrix4(Fe)),Array.isArray(on)){const Qt=Gt.groups;for(let Rn=0,Dn=Qt.length;Rn<Dn;Rn++){const vn=Qt[Rn],ai=on[vn.materialIndex];ai&&ai.visible&&T.push(q,Gt,ai,Ue,Bt.z,vn)}}else on.visible&&T.push(q,Gt,on,Ue,Bt.z,null)}}const vt=q.children;for(let Gt=0,on=vt.length;Gt<on;Gt++)M1(vt[Gt],ve,Ue,ze)}function iD(q,ve,Ue,ze){const Te=q.opaque,vt=q.transmissive,Gt=q.transparent;S.setupLightsView(Ue),Ke===!0&&Ct.setGlobalState(P.clippingPlanes,Ue),ze&&Qe.viewport(j.copy(ze)),Te.length>0&&cb(Te,ve,Ue),vt.length>0&&cb(vt,ve,Ue),Gt.length>0&&cb(Gt,ve,Ue),Qe.buffers.depth.setTest(!0),Qe.buffers.depth.setMask(!0),Qe.buffers.color.setMask(!0),Qe.setPolygonOffset(!1)}function sD(q,ve,Ue,ze){if((Ue.isScene===!0?Ue.overrideMaterial:null)!==null)return;S.state.transmissionRenderTarget[ze.id]===void 0&&(S.state.transmissionRenderTarget[ze.id]=new Aa(1,1,{generateMipmaps:!0,type:it.has("EXT_color_buffer_half_float")||it.has("EXT_color_buffer_float")?Ts:Ui,minFilter:Ds,samples:4,stencilBuffer:o,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:pn.workingColorSpace}));const vt=S.state.transmissionRenderTarget[ze.id],Gt=ze.viewport||j;vt.setSize(Gt.z*P.transmissionResolutionScale,Gt.w*P.transmissionResolutionScale);const on=P.getRenderTarget(),Qt=P.getActiveCubeFace(),Rn=P.getActiveMipmapLevel();P.setRenderTarget(vt),P.getClearColor(be),Pe=P.getClearAlpha(),Pe<1&&P.setClearColor(16777215,.5),P.clear(),hn&&cn.render(Ue);const Dn=P.toneMapping;P.toneMapping=Qr;const vn=ze.viewport;if(ze.viewport!==void 0&&(ze.viewport=void 0),S.setupLightsView(ze),Ke===!0&&Ct.setGlobalState(P.clippingPlanes,ze),cb(q,Ue,ze),Nt.updateMultisampleRenderTarget(vt),Nt.updateRenderTargetMipmap(vt),it.has("WEBGL_multisampled_render_to_texture")===!1){let ai=!1;for(let Oi=0,Ls=ve.length;Oi<Ls;Oi++){const rs=ve[Oi],Gi=rs.object,wn=rs.geometry,xs=rs.material,gi=rs.group;if(xs.side===ke&&Gi.layers.test(ze.layers)){const ga=xs.side;xs.side=Ee,xs.needsUpdate=!0,rD(Gi,Ue,ze,wn,xs,gi),xs.side=ga,xs.needsUpdate=!0,ai=!0}}ai===!0&&(Nt.updateMultisampleRenderTarget(vt),Nt.updateRenderTargetMipmap(vt))}P.setRenderTarget(on,Qt,Rn),P.setClearColor(be,Pe),vn!==void 0&&(ze.viewport=vn),P.toneMapping=Dn}function cb(q,ve,Ue){const ze=ve.isScene===!0?ve.overrideMaterial:null;for(let Te=0,vt=q.length;Te<vt;Te++){const Gt=q[Te],on=Gt.object,Qt=Gt.geometry,Rn=Gt.group;let Dn=Gt.material;Dn.allowOverride===!0&&ze!==null&&(Dn=ze),on.layers.test(Ue.layers)&&rD(on,ve,Ue,Qt,Dn,Rn)}}function rD(q,ve,Ue,ze,Te,vt){q.onBeforeRender(P,ve,Ue,ze,Te,vt),q.modelViewMatrix.multiplyMatrices(Ue.matrixWorldInverse,q.matrixWorld),q.normalMatrix.getNormalMatrix(q.modelViewMatrix),Te.onBeforeRender(P,ve,Ue,ze,q,vt),Te.transparent===!0&&Te.side===ke&&Te.forceSinglePass===!1?(Te.side=Ee,Te.needsUpdate=!0,P.renderBufferDirect(Ue,ve,ze,Te,q,vt),Te.side=Be,Te.needsUpdate=!0,P.renderBufferDirect(Ue,ve,ze,Te,q,vt),Te.side=ke):P.renderBufferDirect(Ue,ve,ze,Te,q,vt),q.onAfterRender(P,ve,Ue,ze,Te,vt)}function ub(q,ve,Ue){ve.isScene!==!0&&(ve=Rt);const ze=gt.get(q),Te=S.state.lights,vt=S.state.shadowsArray,Gt=Te.state.version,on=$e.getParameters(q,Te.state,vt,ve,Ue),Qt=$e.getProgramCacheKey(on);let Rn=ze.programs;ze.environment=q.isMeshStandardMaterial?ve.environment:null,ze.fog=ve.fog,ze.envMap=(q.isMeshStandardMaterial?zn:Hn).get(q.envMap||ze.environment),ze.envMapRotation=ze.environment!==null&&q.envMap===null?ve.environmentRotation:q.envMapRotation,Rn===void 0&&(q.addEventListener("dispose",ot),Rn=new Map,ze.programs=Rn);let Dn=Rn.get(Qt);if(Dn!==void 0){if(ze.currentProgram===Dn&&ze.lightsStateVersion===Gt)return aD(q,on),Dn}else on.uniforms=$e.getUniforms(q),q.onBeforeCompile(on,P),Dn=$e.acquireProgram(on,Qt),Rn.set(Qt,Dn),ze.uniforms=on.uniforms;const vn=ze.uniforms;return(!q.isShaderMaterial&&!q.isRawShaderMaterial||q.clipping===!0)&&(vn.clippingPlanes=Ct.uniform),aD(q,on),ze.needsLights=gY(q),ze.lightsStateVersion=Gt,ze.needsLights&&(vn.ambientLightColor.value=Te.state.ambient,vn.lightProbe.value=Te.state.probe,vn.directionalLights.value=Te.state.directional,vn.directionalLightShadows.value=Te.state.directionalShadow,vn.spotLights.value=Te.state.spot,vn.spotLightShadows.value=Te.state.spotShadow,vn.rectAreaLights.value=Te.state.rectArea,vn.ltc_1.value=Te.state.rectAreaLTC1,vn.ltc_2.value=Te.state.rectAreaLTC2,vn.pointLights.value=Te.state.point,vn.pointLightShadows.value=Te.state.pointShadow,vn.hemisphereLights.value=Te.state.hemi,vn.directionalShadowMap.value=Te.state.directionalShadowMap,vn.directionalShadowMatrix.value=Te.state.directionalShadowMatrix,vn.spotShadowMap.value=Te.state.spotShadowMap,vn.spotLightMatrix.value=Te.state.spotLightMatrix,vn.spotLightMap.value=Te.state.spotLightMap,vn.pointShadowMap.value=Te.state.pointShadowMap,vn.pointShadowMatrix.value=Te.state.pointShadowMatrix),ze.currentProgram=Dn,ze.uniformsList=null,Dn}function oD(q){if(q.uniformsList===null){const ve=q.currentProgram.getUniforms();q.uniformsList=Ax.seqWithValue(ve.seq,q.uniforms)}return q.uniformsList}function aD(q,ve){const Ue=gt.get(q);Ue.outputColorSpace=ve.outputColorSpace,Ue.batching=ve.batching,Ue.batchingColor=ve.batchingColor,Ue.instancing=ve.instancing,Ue.instancingColor=ve.instancingColor,Ue.instancingMorph=ve.instancingMorph,Ue.skinning=ve.skinning,Ue.morphTargets=ve.morphTargets,Ue.morphNormals=ve.morphNormals,Ue.morphColors=ve.morphColors,Ue.morphTargetsCount=ve.morphTargetsCount,Ue.numClippingPlanes=ve.numClippingPlanes,Ue.numIntersection=ve.numClipIntersection,Ue.vertexAlphas=ve.vertexAlphas,Ue.vertexTangents=ve.vertexTangents,Ue.toneMapping=ve.toneMapping}function pY(q,ve,Ue,ze,Te){ve.isScene!==!0&&(ve=Rt),Nt.resetTextureUnits();const vt=ve.fog,Gt=ze.isMeshStandardMaterial?ve.environment:null,on=V===null?P.outputColorSpace:V.isXRRenderTarget===!0?V.texture.colorSpace:ol,Qt=(ze.isMeshStandardMaterial?zn:Hn).get(ze.envMap||Gt),Rn=ze.vertexColors===!0&&!!Ue.attributes.color&&Ue.attributes.color.itemSize===4,Dn=!!Ue.attributes.tangent&&(!!ze.normalMap||ze.anisotropy>0),vn=!!Ue.morphAttributes.position,ai=!!Ue.morphAttributes.normal,Oi=!!Ue.morphAttributes.color;let Ls=Qr;ze.toneMapped&&(V===null||V.isXRRenderTarget===!0)&&(Ls=P.toneMapping);const rs=Ue.morphAttributes.position||Ue.morphAttributes.normal||Ue.morphAttributes.color,Gi=rs!==void 0?rs.length:0,wn=gt.get(ze),xs=S.state.lights;if(Ke===!0&&(Se===!0||q!==z)){const po=q===z&&ze.id===U;Ct.setState(ze,q,po)}let gi=!1;ze.version===wn.__version?(wn.needsLights&&wn.lightsStateVersion!==xs.state.version||wn.outputColorSpace!==on||Te.isBatchedMesh&&wn.batching===!1||!Te.isBatchedMesh&&wn.batching===!0||Te.isBatchedMesh&&wn.batchingColor===!0&&Te.colorTexture===null||Te.isBatchedMesh&&wn.batchingColor===!1&&Te.colorTexture!==null||Te.isInstancedMesh&&wn.instancing===!1||!Te.isInstancedMesh&&wn.instancing===!0||Te.isSkinnedMesh&&wn.skinning===!1||!Te.isSkinnedMesh&&wn.skinning===!0||Te.isInstancedMesh&&wn.instancingColor===!0&&Te.instanceColor===null||Te.isInstancedMesh&&wn.instancingColor===!1&&Te.instanceColor!==null||Te.isInstancedMesh&&wn.instancingMorph===!0&&Te.morphTexture===null||Te.isInstancedMesh&&wn.instancingMorph===!1&&Te.morphTexture!==null||wn.envMap!==Qt||ze.fog===!0&&wn.fog!==vt||wn.numClippingPlanes!==void 0&&(wn.numClippingPlanes!==Ct.numPlanes||wn.numIntersection!==Ct.numIntersection)||wn.vertexAlphas!==Rn||wn.vertexTangents!==Dn||wn.morphTargets!==vn||wn.morphNormals!==ai||wn.morphColors!==Oi||wn.toneMapping!==Ls||wn.morphTargetsCount!==Gi)&&(gi=!0):(gi=!0,wn.__version=ze.version);let ga=wn.currentProgram;gi===!0&&(ga=ub(ze,ve,Te));let ag=!1,ya=!1,K_=!1;const vs=ga.getUniforms(),il=wn.uniforms;if(Qe.useProgram(ga.program)&&(ag=!0,ya=!0,K_=!0),ze.id!==U&&(U=ze.id,ya=!0),ag||z!==q){Qe.buffers.depth.getReversed()&&q.reversedDepth!==!0&&(q._reversedDepth=!0,q.updateProjectionMatrix()),vs.setValue(re,"projectionMatrix",q.projectionMatrix),vs.setValue(re,"viewMatrix",q.matrixWorldInverse);const zo=vs.map.cameraPosition;zo!==void 0&&zo.setValue(re,mt.setFromMatrixPosition(q.matrixWorld)),tt.logarithmicDepthBuffer&&vs.setValue(re,"logDepthBufFC",2/(Math.log(q.far+1)/Math.LN2)),(ze.isMeshPhongMaterial||ze.isMeshToonMaterial||ze.isMeshLambertMaterial||ze.isMeshBasicMaterial||ze.isMeshStandardMaterial||ze.isShaderMaterial)&&vs.setValue(re,"isOrthographic",q.isOrthographicCamera===!0),z!==q&&(z=q,ya=!0,K_=!0)}if(Te.isSkinnedMesh){vs.setOptional(re,Te,"bindMatrix"),vs.setOptional(re,Te,"bindMatrixInverse");const po=Te.skeleton;po&&(po.boneTexture===null&&po.computeBoneTexture(),vs.setValue(re,"boneTexture",po.boneTexture,Nt))}Te.isBatchedMesh&&(vs.setOptional(re,Te,"batchingTexture"),vs.setValue(re,"batchingTexture",Te._matricesTexture,Nt),vs.setOptional(re,Te,"batchingIdTexture"),vs.setValue(re,"batchingIdTexture",Te._indirectTexture,Nt),vs.setOptional(re,Te,"batchingColorTexture"),Te._colorsTexture!==null&&vs.setValue(re,"batchingColorTexture",Te._colorsTexture,Nt));const sl=Ue.morphAttributes;if((sl.position!==void 0||sl.normal!==void 0||sl.color!==void 0)&&yt.update(Te,Ue,ga),(ya||wn.receiveShadow!==Te.receiveShadow)&&(wn.receiveShadow=Te.receiveShadow,vs.setValue(re,"receiveShadow",Te.receiveShadow)),ze.isMeshGouraudMaterial&&ze.envMap!==null&&(il.envMap.value=Qt,il.flipEnvMap.value=Qt.isCubeTexture&&Qt.isRenderTargetTexture===!1?-1:1),ze.isMeshStandardMaterial&&ze.envMap===null&&ve.environment!==null&&(il.envMapIntensity.value=ve.environmentIntensity),ya&&(vs.setValue(re,"toneMappingExposure",P.toneMappingExposure),wn.needsLights&&mY(il,K_),vt&&ze.fog===!0&&ut.refreshFogUniforms(il,vt),ut.refreshMaterialUniforms(il,ze,Le,nt,S.state.transmissionRenderTarget[q.id]),Ax.upload(re,oD(wn),il,Nt)),ze.isShaderMaterial&&ze.uniformsNeedUpdate===!0&&(Ax.upload(re,oD(wn),il,Nt),ze.uniformsNeedUpdate=!1),ze.isSpriteMaterial&&vs.setValue(re,"center",Te.center),vs.setValue(re,"modelViewMatrix",Te.modelViewMatrix),vs.setValue(re,"normalMatrix",Te.normalMatrix),vs.setValue(re,"modelMatrix",Te.matrixWorld),ze.isShaderMaterial||ze.isRawShaderMaterial){const po=ze.uniformsGroups;for(let zo=0,A1=po.length;zo<A1;zo++){const fp=po[zo];jn.update(fp,ga),jn.bind(fp,ga)}}return ga}function mY(q,ve){q.ambientLightColor.needsUpdate=ve,q.lightProbe.needsUpdate=ve,q.directionalLights.needsUpdate=ve,q.directionalLightShadows.needsUpdate=ve,q.pointLights.needsUpdate=ve,q.pointLightShadows.needsUpdate=ve,q.spotLights.needsUpdate=ve,q.spotLightShadows.needsUpdate=ve,q.rectAreaLights.needsUpdate=ve,q.hemisphereLights.needsUpdate=ve}function gY(q){return q.isMeshLambertMaterial||q.isMeshToonMaterial||q.isMeshPhongMaterial||q.isMeshStandardMaterial||q.isShadowMaterial||q.isShaderMaterial&&q.lights===!0}this.getActiveCubeFace=function(){return F},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return V},this.setRenderTargetTextures=function(q,ve,Ue){const ze=gt.get(q);ze.__autoAllocateDepthBuffer=q.resolveDepthBuffer===!1,ze.__autoAllocateDepthBuffer===!1&&(ze.__useRenderToTexture=!1),gt.get(q.texture).__webglTexture=ve,gt.get(q.depthTexture).__webglTexture=ze.__autoAllocateDepthBuffer?void 0:Ue,ze.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(q,ve){const Ue=gt.get(q);Ue.__webglFramebuffer=ve,Ue.__useDefaultFramebuffer=ve===void 0};const yY=re.createFramebuffer();this.setRenderTarget=function(q,ve=0,Ue=0){V=q,F=ve,k=Ue;let ze=!0,Te=null,vt=!1,Gt=!1;if(q){const Qt=gt.get(q);if(Qt.__useDefaultFramebuffer!==void 0)Qe.bindFramebuffer(re.FRAMEBUFFER,null),ze=!1;else if(Qt.__webglFramebuffer===void 0)Nt.setupRenderTarget(q);else if(Qt.__hasExternalTextures)Nt.rebindTextures(q,gt.get(q.texture).__webglTexture,gt.get(q.depthTexture).__webglTexture);else if(q.depthBuffer){const vn=q.depthTexture;if(Qt.__boundDepthTexture!==vn){if(vn!==null&>.has(vn)&&(q.width!==vn.image.width||q.height!==vn.image.height))throw new Error("WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.");Nt.setupDepthRenderbuffer(q)}}const Rn=q.texture;(Rn.isData3DTexture||Rn.isDataArrayTexture||Rn.isCompressedArrayTexture)&&(Gt=!0);const Dn=gt.get(q).__webglFramebuffer;q.isWebGLCubeRenderTarget?(Array.isArray(Dn[ve])?Te=Dn[ve][Ue]:Te=Dn[ve],vt=!0):q.samples>0&&Nt.useMultisampledRTT(q)===!1?Te=gt.get(q).__webglMultisampledFramebuffer:Array.isArray(Dn)?Te=Dn[Ue]:Te=Dn,j.copy(q.viewport),se.copy(q.scissor),pe=q.scissorTest}else j.copy(Je).multiplyScalar(Le).floor(),se.copy(wt).multiplyScalar(Le).floor(),pe=Xt;if(Ue!==0&&(Te=yY),Qe.bindFramebuffer(re.FRAMEBUFFER,Te)&&ze&&Qe.drawBuffers(q,Te),Qe.viewport(j),Qe.scissor(se),Qe.setScissorTest(pe),vt){const Qt=gt.get(q.texture);re.framebufferTexture2D(re.FRAMEBUFFER,re.COLOR_ATTACHMENT0,re.TEXTURE_CUBE_MAP_POSITIVE_X+ve,Qt.__webglTexture,Ue)}else if(Gt){const Qt=ve;for(let Rn=0;Rn<q.textures.length;Rn++){const Dn=gt.get(q.textures[Rn]);re.framebufferTextureLayer(re.FRAMEBUFFER,re.COLOR_ATTACHMENT0+Rn,Dn.__webglTexture,Ue,Qt)}}else if(q!==null&&Ue!==0){const Qt=gt.get(q.texture);re.framebufferTexture2D(re.FRAMEBUFFER,re.COLOR_ATTACHMENT0,re.TEXTURE_2D,Qt.__webglTexture,Ue)}U=-1},this.readRenderTargetPixels=function(q,ve,Ue,ze,Te,vt,Gt,on=0){if(!(q&&q.isWebGLRenderTarget)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Qt=gt.get(q).__webglFramebuffer;if(q.isWebGLCubeRenderTarget&&Gt!==void 0&&(Qt=Qt[Gt]),Qt){Qe.bindFramebuffer(re.FRAMEBUFFER,Qt);try{const Rn=q.textures[on],Dn=Rn.format,vn=Rn.type;if(!tt.textureFormatReadable(Dn)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!tt.textureTypeReadable(vn)){console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}ve>=0&&ve<=q.width-ze&&Ue>=0&&Ue<=q.height-Te&&(q.textures.length>1&&re.readBuffer(re.COLOR_ATTACHMENT0+on),re.readPixels(ve,Ue,ze,Te,yn.convert(Dn),yn.convert(vn),vt))}finally{const Rn=V!==null?gt.get(V).__webglFramebuffer:null;Qe.bindFramebuffer(re.FRAMEBUFFER,Rn)}}},this.readRenderTargetPixelsAsync=function(q,ve,Ue,ze,Te,vt,Gt,on=0){return en(this,null,function*(){if(!(q&&q.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Qt=gt.get(q).__webglFramebuffer;if(q.isWebGLCubeRenderTarget&&Gt!==void 0&&(Qt=Qt[Gt]),Qt)if(ve>=0&&ve<=q.width-ze&&Ue>=0&&Ue<=q.height-Te){Qe.bindFramebuffer(re.FRAMEBUFFER,Qt);const Rn=q.textures[on],Dn=Rn.format,vn=Rn.type;if(!tt.textureFormatReadable(Dn))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!tt.textureTypeReadable(vn))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const ai=re.createBuffer();re.bindBuffer(re.PIXEL_PACK_BUFFER,ai),re.bufferData(re.PIXEL_PACK_BUFFER,vt.byteLength,re.STREAM_READ),q.textures.length>1&&re.readBuffer(re.COLOR_ATTACHMENT0+on),re.readPixels(ve,Ue,ze,Te,yn.convert(Dn),yn.convert(vn),0);const Oi=V!==null?gt.get(V).__webglFramebuffer:null;Qe.bindFramebuffer(re.FRAMEBUFFER,Oi);const Ls=re.fenceSync(re.SYNC_GPU_COMMANDS_COMPLETE,0);return re.flush(),yield pt(re,Ls,4),re.bindBuffer(re.PIXEL_PACK_BUFFER,ai),re.getBufferSubData(re.PIXEL_PACK_BUFFER,0,vt),re.deleteBuffer(ai),re.deleteSync(Ls),vt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")})},this.copyFramebufferToTexture=function(q,ve=null,Ue=0){const ze=Math.pow(2,-Ue),Te=Math.floor(q.image.width*ze),vt=Math.floor(q.image.height*ze),Gt=ve!==null?ve.x:0,on=ve!==null?ve.y:0;Nt.setTexture2D(q,0),re.copyTexSubImage2D(re.TEXTURE_2D,Ue,0,0,Gt,on,Te,vt),Qe.unbindTexture()};const _Y=re.createFramebuffer(),xY=re.createFramebuffer();this.copyTextureToTexture=function(q,ve,Ue=null,ze=null,Te=0,vt=null){vt===null&&(Te!==0?(wr("WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels."),vt=Te,Te=0):vt=0);let Gt,on,Qt,Rn,Dn,vn,ai,Oi,Ls;const rs=q.isCompressedTexture?q.mipmaps[vt]:q.image;if(Ue!==null)Gt=Ue.max.x-Ue.min.x,on=Ue.max.y-Ue.min.y,Qt=Ue.isBox3?Ue.max.z-Ue.min.z:1,Rn=Ue.min.x,Dn=Ue.min.y,vn=Ue.isBox3?Ue.min.z:0;else{const sl=Math.pow(2,-Te);Gt=Math.floor(rs.width*sl),on=Math.floor(rs.height*sl),q.isDataArrayTexture?Qt=rs.depth:q.isData3DTexture?Qt=Math.floor(rs.depth*sl):Qt=1,Rn=0,Dn=0,vn=0}ze!==null?(ai=ze.x,Oi=ze.y,Ls=ze.z):(ai=0,Oi=0,Ls=0);const Gi=yn.convert(ve.format),wn=yn.convert(ve.type);let xs;ve.isData3DTexture?(Nt.setTexture3D(ve,0),xs=re.TEXTURE_3D):ve.isDataArrayTexture||ve.isCompressedArrayTexture?(Nt.setTexture2DArray(ve,0),xs=re.TEXTURE_2D_ARRAY):(Nt.setTexture2D(ve,0),xs=re.TEXTURE_2D),re.pixelStorei(re.UNPACK_FLIP_Y_WEBGL,ve.flipY),re.pixelStorei(re.UNPACK_PREMULTIPLY_ALPHA_WEBGL,ve.premultiplyAlpha),re.pixelStorei(re.UNPACK_ALIGNMENT,ve.unpackAlignment);const gi=re.getParameter(re.UNPACK_ROW_LENGTH),ga=re.getParameter(re.UNPACK_IMAGE_HEIGHT),ag=re.getParameter(re.UNPACK_SKIP_PIXELS),ya=re.getParameter(re.UNPACK_SKIP_ROWS),K_=re.getParameter(re.UNPACK_SKIP_IMAGES);re.pixelStorei(re.UNPACK_ROW_LENGTH,rs.width),re.pixelStorei(re.UNPACK_IMAGE_HEIGHT,rs.height),re.pixelStorei(re.UNPACK_SKIP_PIXELS,Rn),re.pixelStorei(re.UNPACK_SKIP_ROWS,Dn),re.pixelStorei(re.UNPACK_SKIP_IMAGES,vn);const vs=q.isDataArrayTexture||q.isData3DTexture,il=ve.isDataArrayTexture||ve.isData3DTexture;if(q.isDepthTexture){const sl=gt.get(q),po=gt.get(ve),zo=gt.get(sl.__renderTarget),A1=gt.get(po.__renderTarget);Qe.bindFramebuffer(re.READ_FRAMEBUFFER,zo.__webglFramebuffer),Qe.bindFramebuffer(re.DRAW_FRAMEBUFFER,A1.__webglFramebuffer);for(let fp=0;fp<Qt;fp++)vs&&(re.framebufferTextureLayer(re.READ_FRAMEBUFFER,re.COLOR_ATTACHMENT0,gt.get(q).__webglTexture,Te,vn+fp),re.framebufferTextureLayer(re.DRAW_FRAMEBUFFER,re.COLOR_ATTACHMENT0,gt.get(ve).__webglTexture,vt,Ls+fp)),re.blitFramebuffer(Rn,Dn,Gt,on,ai,Oi,Gt,on,re.DEPTH_BUFFER_BIT,re.NEAREST);Qe.bindFramebuffer(re.READ_FRAMEBUFFER,null),Qe.bindFramebuffer(re.DRAW_FRAMEBUFFER,null)}else if(Te!==0||q.isRenderTargetTexture||gt.has(q)){const sl=gt.get(q),po=gt.get(ve);Qe.bindFramebuffer(re.READ_FRAMEBUFFER,_Y),Qe.bindFramebuffer(re.DRAW_FRAMEBUFFER,xY);for(let zo=0;zo<Qt;zo++)vs?re.framebufferTextureLayer(re.READ_FRAMEBUFFER,re.COLOR_ATTACHMENT0,sl.__webglTexture,Te,vn+zo):re.framebufferTexture2D(re.READ_FRAMEBUFFER,re.COLOR_ATTACHMENT0,re.TEXTURE_2D,sl.__webglTexture,Te),il?re.framebufferTextureLayer(re.DRAW_FRAMEBUFFER,re.COLOR_ATTACHMENT0,po.__webglTexture,vt,Ls+zo):re.framebufferTexture2D(re.DRAW_FRAMEBUFFER,re.COLOR_ATTACHMENT0,re.TEXTURE_2D,po.__webglTexture,vt),Te!==0?re.blitFramebuffer(Rn,Dn,Gt,on,ai,Oi,Gt,on,re.COLOR_BUFFER_BIT,re.NEAREST):il?re.copyTexSubImage3D(xs,vt,ai,Oi,Ls+zo,Rn,Dn,Gt,on):re.copyTexSubImage2D(xs,vt,ai,Oi,Rn,Dn,Gt,on);Qe.bindFramebuffer(re.READ_FRAMEBUFFER,null),Qe.bindFramebuffer(re.DRAW_FRAMEBUFFER,null)}else il?q.isDataTexture||q.isData3DTexture?re.texSubImage3D(xs,vt,ai,Oi,Ls,Gt,on,Qt,Gi,wn,rs.data):ve.isCompressedArrayTexture?re.compressedTexSubImage3D(xs,vt,ai,Oi,Ls,Gt,on,Qt,Gi,rs.data):re.texSubImage3D(xs,vt,ai,Oi,Ls,Gt,on,Qt,Gi,wn,rs):q.isDataTexture?re.texSubImage2D(re.TEXTURE_2D,vt,ai,Oi,Gt,on,Gi,wn,rs.data):q.isCompressedTexture?re.compressedTexSubImage2D(re.TEXTURE_2D,vt,ai,Oi,rs.width,rs.height,Gi,rs.data):re.texSubImage2D(re.TEXTURE_2D,vt,ai,Oi,Gt,on,Gi,wn,rs);re.pixelStorei(re.UNPACK_ROW_LENGTH,gi),re.pixelStorei(re.UNPACK_IMAGE_HEIGHT,ga),re.pixelStorei(re.UNPACK_SKIP_PIXELS,ag),re.pixelStorei(re.UNPACK_SKIP_ROWS,ya),re.pixelStorei(re.UNPACK_SKIP_IMAGES,K_),vt===0&&ve.generateMipmaps&&re.generateMipmap(xs),Qe.unbindTexture()},this.initRenderTarget=function(q){gt.get(q).__webglFramebuffer===void 0&&Nt.setupRenderTarget(q)},this.initTexture=function(q){q.isCubeTexture?Nt.setTextureCube(q,0):q.isData3DTexture?Nt.setTexture3D(q,0):q.isDataArrayTexture||q.isCompressedArrayTexture?Nt.setTexture2DArray(q,0):Nt.setTexture2D(q,0),Qe.unbindTexture()},this.resetState=function(){F=0,k=0,V=null,Qe.reset(),zt.reset()},typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return ki}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=pn._getDrawingBufferColorSpace(e),t.unpackColorSpace=pn._getUnpackColorSpace()}}const Qk=["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"],cT=new WeakMap;class ez{constructor(e){this.renderObjects=new WeakMap,this.hasNode=this.containsNode(e),this.hasAnimation=e.object.isSkinnedMesh===!0,this.refreshUniforms=Qk,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.renderer.overrideNodes.modelViewMatrix!==null||e.renderer.overrideNodes.modelNormalViewMatrix!==null}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 T in c){const S=c[T],N=r[T];if(S.equals!==void 0){if(S.equals(N)===!1)return S.copy(N),!1}else if(N.isTexture===!0){if(S.id!==N.id||S.version!==N.version)return S.id=N.id,S.version=N.version,!1}else if(S!==N)return c[T]=N,!1}if(c.transmission>0){const{width:T,height:S}=e.context;if(a.bufferWidth!==T||a.bufferHeight!==S)return a.bufferWidth=T,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 T of m){const S=p[T],N=d[T];if(N===void 0)return delete p[T],!1;if(S.version!==N.version)return S.version=N.version,!1}const x=o.index,v=u.indexVersion,M=x?x.version:null;if(v!==M)return u.indexVersion=M,!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 T=!1;for(let S=0;S<a.morphTargetInfluences.length;S++)a.morphTargetInfluences[S]!==n.morphTargetInfluences[S]&&(T=!0);if(T)return!0}if(a.lights){for(let T=0;T<t.length;T++)if(a.lights[T].map!==t[T].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(cT.has(e)){const r=cT.get(e);if(r.renderId===t)return r.lightsData}const n=this.getLightsData(e.getLights());return cT.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 Hy(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 uT=i=>Hy(i),Wy=i=>Hy(i),$y=(...i)=>Hy(i);function hT(i,e=!1){const t=[];i.isNode===!0&&t.push(i.id);for(const{property:n,childNode:r}of qy(i))t.push(Hy(n.slice(0,-4)),r.getCacheKey(e));return Hy(t)}function*qy(i,e=!1){for(const t of Object.getOwnPropertyNames(i)){if(t.startsWith("_")===!0)continue;const n=i[t];if(Array.isArray(n)===!0)for(let r=0;r<n.length;r++){const o=n[r];o&&(o.isNode===!0||e&&typeof o.toJSON=="function")&&(yield{property:t,index:r,childNode:o})}else if(n&&n.isNode===!0)yield{property:t,childNode:n};else if(n&&Object.getPrototypeOf(n)===Object.prototype)for(const r in n){if(r.startsWith("_")===!0)continue;const o=n[r];o&&(o.isNode===!0||e&&typeof o.toJSON=="function")&&(yield{property:t,index:r,childNode:o})}}}const tz=new Map([[1,"float"],[2,"vec2"],[3,"vec3"],[4,"vec4"],[9,"mat3"],[16,"mat4"]]),NE=new WeakMap;function dT(i){return tz.get(i)}function Xy(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 fT(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;console.error("THREE.TSL: Unsupported type:",i)}function PE(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;console.error("THREE.TSL: Unsupported type:",i)}function IE(i){if(/float|int|uint/.test(i))return 4;if(/vec2/.test(i))return 8;if(/vec3/.test(i)||/vec4/.test(i))return 16;if(/mat2/.test(i))return 8;if(/mat3/.test(i))return 48;if(/mat4/.test(i))return 64;console.error("THREE.TSL: Unsupported type:",i)}function Au(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 Cx(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 At(...e):t==="vec2"?new Ie(...e):t==="vec3"?new W(...e):t==="vec4"?new an(...e):t==="mat2"?new Af(...e):t==="mat3"?new Cn(...e):t==="mat4"?new Vt(...e):i==="bool"?e[0]||!1:i==="float"||i==="int"||i==="uint"?e[0]||0:i==="string"?e[0]||"":i==="ArrayBuffer"?gT(e[0]):null}function pT(i){let e=NE.get(i);return e===void 0&&(e={},NE.set(i,e)),e}function mT(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 gT(i){return Uint8Array.from(atob(i),e=>e.charCodeAt(0)).buffer}var cZ=Object.freeze({__proto__:null,arrayBufferToBase64:mT,base64ToArrayBuffer:gT,getByteBoundaryFromType:IE,getCacheKey:hT,getDataFromObject:pT,getLengthFromType:fT,getMemoryLengthFromType:PE,getNodeChildren:qy,getTypeFromLength:dT,getTypedArrayFromType:Xy,getValueFromType:Cx,getValueType:Au,hash:$y,hashArray:Wy,hashString:uT});const jy={VERTEX:"vertex",FRAGMENT:"fragment"},In={NONE:"none",FRAME:"frame",RENDER:"render",OBJECT:"object"},nz={BOOLEAN:"bool",INTEGER:"int",FLOAT:"float",VECTOR2:"vec2",VECTOR3:"vec3",VECTOR4:"vec4",MATRIX2:"mat2",MATRIX3:"mat3",MATRIX4:"mat4"},Ir={READ_ONLY:"readOnly",WRITE_ONLY:"writeOnly",READ_WRITE:"readWrite"},LE=["fragment","vertex"],yT=["setup","analyze","generate"],_T=[...LE,"compute"],Uf=["x","y","z","w"],iz={analyze:"setup",generate:"analyze"};let sz=0;class kt extends wa{static get type(){return"Node"}constructor(e=null){super(),this.nodeType=e,this.updateType=In.NONE,this.updateBeforeType=In.NONE,this.updateAfterType=In.NONE,this.uuid=Ld.generateUUID(),this.version=0,this.global=!1,this.parents=!1,this.isNode=!0,this._cacheKey=null,this._cacheKeyVersion=0,Object.defineProperty(this,"id",{value:sz++})}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,In.FRAME)}onRenderUpdate(e){return this.onUpdate(e,In.RENDER)}onObjectUpdate(e){return this.onUpdate(e,In.OBJECT)}onReference(e){return this.updateReference=e.bind(this),this}updateReference(){return this}isGlobal(){return this.global}*getChildren(){for(const{childNode:e}of qy(this))yield e}dispose(){this.dispatchEvent({type:"dispose"})}traverse(e){e(this);for(const t of this.getChildren())t.traverse(e)}getCacheKey(e=!1){return e=e||this.version!==this._cacheKeyVersion,(e===!0||this._cacheKey===null)&&(this._cacheKey=$y(hT(this,e),this.customCacheKey()),this._cacheKeyVersion=this.version),this._cacheKey}customCacheKey(){return 0}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(){console.warn("Abstract function.")}updateAfter(){console.warn("Abstract function.")}update(){console.warn("Abstract function.")}build(e,t=null){const n=this.getShared(e);if(this!==n)return n.build(e,t);const r=e.getDataFromNode(this);r.buildStages=r.buildStages||{},r.buildStages[e.buildStage]=!0;const o=iz[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===1){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):(console.warn("THREE.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"&&(console.error(`THREE.TSL: Invalid generated code, expected a "${t}".`),a=e.generateConst(t))}return e.removeChain(this),e.addSequentialNode(this),a}getSerializeChildren(){return qy(this)}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 kf extends kt{static get type(){return"ArrayElementNode"}constructor(e,t){super(),this.node=e,this.indexNode=t,this.isArrayElementNode=!0}getNodeType(e){return this.node.getElementType(e)}generate(e){const t=this.indexNode.getNodeType(e),n=this.node.build(e),r=this.indexNode.build(e,!e.isVector(t)&&e.isInteger(t)?t:"uint");return`${n}[ ${r} ]`}}class DE extends kt{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 Rs extends kt{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 rz extends Rs{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){console.error(`THREE.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&&(console.error(`THREE.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 M=e.getTypeFromLength(y,a);x=e.format(x,m,M)}c.push(x)}const d=`${e.getType(n)}( ${c.join(", ")} )`;return e.format(d,n,t)}}const oz=Uf.join("");class FE extends kt{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(Uf.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===oz.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 az extends Rs{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=Uf[y];x===n[0]?(m.push(u),y+=n.length-1):m.push(d+"."+x)}return`${e.getType(o)}( ${m.join(", ")} )`}}class lz extends Rs{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=Uf[m];y===t[p]?(d.push("1.0 - "+(c+"."+y)),p++):d.push(c+"."+y)}return`${e.getType(r)}( ${d.join(", ")} )`}}class xT extends kt{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?Au(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=Au(this.value),e.nodeType=this.nodeType,e.valueType==="ArrayBuffer"&&(e.value=mT(e.value)),e.precision=this.precision}deserialize(e){super.deserialize(e),this.nodeType=e.nodeType,this.value=Array.isArray(e.value)?Cx(e.valueType,...e.value):e.value,this.precision=e.precision||null,this.value&&this.value.fromArray&&(this.value=this.value.fromArray(e.value))}generate(){console.warn("Abstract function.")}}const BE=/float|u?int/;class $a extends xT{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 BE.test(n)&&BE.test(t)?e.generateConst(t,this.value):e.format(this.generateConst(e),n,t)}}class cz extends kt{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){console.warn(`THREE.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 od=null;const vT=new Map;function Ve(i,e){if(vT.has(i)){console.warn(`THREE.TSL: Redefinition of method chaining '${i}'.`);return}if(typeof e!="function")throw new Error(`THREE.TSL: Node element ${i} is not a function`);vT.set(i,e),i!=="assign"&&(kt.prototype[i]=function(...t){return this.isStackNode?this.add(e(...t)):e(this,...t)},kt.prototype[i+"Assign"]=function(...t){return this.isStackNode?this.assign(t[0],e(...t)):this.assign(e(this,...t))})}const uz=i=>i.replace(/r|s/g,"x").replace(/g|t/g,"y").replace(/b|p/g,"z").replace(/a|q/g,"w"),OE=i=>uz(i).split("").sort().join("");kt.prototype.assign=function(...i){if(this.isStackNode!==!0)return od!==null?od.assign(this,...i):console.error("THREE.TSL: No stack defined for assign operation. Make sure the assign is inside a Fn()."),this;{const e=vT.get("assign");return this.add(e(...i))}},kt.prototype.toVarIntent=function(){return this},kt.prototype.get=function(i){return new cz(this,i)};const Yy={};function Rx(i,e,t){Yy[i]=Yy[e]=Yy[t]={get(){this._cache=this._cache||{};let a=this._cache[i];return a===void 0&&(a=new FE(this,i),this._cache[i]=a),a},set(a){this[i].assign(Ge(a))}};const n=i.toUpperCase(),r=e.toUpperCase(),o=t.toUpperCase();kt.prototype["set"+n]=kt.prototype["set"+r]=kt.prototype["set"+o]=function(a){const c=OE(i);return new az(this,c,Ge(a))},kt.prototype["flip"+n]=kt.prototype["flip"+r]=kt.prototype["flip"+o]=function(){const a=OE(i);return new lz(this,a)}}const lc=["x","y","z","w"],cc=["r","g","b","a"],uc=["s","t","p","q"];for(let i=0;i<4;i++){let e=lc[i],t=cc[i],n=uc[i];Rx(e,t,n);for(let r=0;r<4;r++){e=lc[i]+lc[r],t=cc[i]+cc[r],n=uc[i]+uc[r],Rx(e,t,n);for(let o=0;o<4;o++){e=lc[i]+lc[r]+lc[o],t=cc[i]+cc[r]+cc[o],n=uc[i]+uc[r]+uc[o],Rx(e,t,n);for(let a=0;a<4;a++)e=lc[i]+lc[r]+lc[o]+lc[a],t=cc[i]+cc[r]+cc[o]+cc[a],n=uc[i]+uc[r]+uc[o]+uc[a],Rx(e,t,n)}}}for(let i=0;i<32;i++)Yy[i]={get(){this._cache=this._cache||{};let e=this._cache[i];return e===void 0&&(e=new kf(this,new $a(i,"uint")),this._cache[i]=e),e},set(e){this[i].assign(Ge(e))}};Object.defineProperties(kt.prototype,Yy);const UE=new WeakMap,hz=function(i,e=null){const t=Au(i);return t==="node"?i:e===null&&(t==="float"||t==="boolean")||t&&t!=="shader"&&t!=="string"?Ge(wT(i,e)):t==="shader"?i.isFn?i:de(i):i},dz=function(i,e=null){for(const t in i)i[t]=Ge(i[t],e);return i},fz=function(i,e=null){const t=i.length;for(let n=0;n<t;n++)i[n]=Ge(i[n],e);return i},kE=function(i,e=null,t=null,n=null){function r(p){return n!==null?(p=Ge(Object.assign(p,n)),n.intent===!0&&(p=p.toVarIntent())):p=Ge(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?(console.error(`THREE.TSL: "${m}" parameter length is less than minimum required.`),p.concat(new Array(c-p.length).fill(0))):u!==void 0&&p.length>u?(console.error(`THREE.TSL: "${m}" parameter length exceeds limit.`),p.slice(0,u)):p}return e===null?o=(...p)=>r(new i(...zf(d(p)))):t!==null?(t=Ge(t),o=(...p)=>r(new i(e,...zf(d(p)),t))):o=(...p)=>r(new i(e,...zf(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},pz=function(i,...e){return Ge(new i(...zf(e)))};class mz extends kt{constructor(e,t){super(),this.shaderNode=e,this.rawInputs=t,this.isShaderCallNodeInternal=!0}getNodeType(e){return this.shaderNode.nodeType||this.getOutputNode(e).getNodeType(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;e.subBuildFn=o;let u=null;if(t.layout){let d=UE.get(e.constructor);d===void 0&&(d=new WeakMap,UE.set(e.constructor,d));let p=d.get(t);p===void 0&&(p=Ge(e.buildFunctionNode(t)),d.set(t,p)),e.addInclude(p);const m=n?gz(n):null;u=Ge(p.call(m))}else{const d=new Proxy(e,{get:(v,M,T)=>{let S;return Symbol.iterator===M?S=function*(){yield void 0}:S=Reflect.get(v,M,T),S}}),p=n?yz(n):null,m=Array.isArray(n)?n.length>0:n!==null,y=t.jsFunc,x=m||y.length>1?y(p,d):y(d);u=Ge(x)}return e.subBuildFn=c,t.once&&(r[a]=u),u}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);if(r==="setup"){const u=e.getSubBuildProperty("initialized",this);if(o[u]!==!0&&(o[u]=!0,o[a]=this.getOutputNode(e),o[a].build(e),this.shaderNode.subBuilds))for(const d of e.chaining){const p=e.getDataFromNode(d,"any");p.subBuilds=p.subBuilds||new Set;for(const m of this.shaderNode.subBuilds)p.subBuilds.add(m)}n=o[a]}else r==="analyze"?c.build(e,t):r==="generate"&&(n=c.build(e,t)||"");return n}}function gz(i){let e;return Ix(i),i[0]&&(i[0].isNode||Object.getPrototypeOf(i[0])!==Object.prototype)?e=[...i]:e=i[0],e}function yz(i){let e=0;return Ix(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 Ge(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 kt&&(i[n]===void 0?o=i[e++]:o=Reflect.get(i,n,r));else o=Reflect.get(t,n,r);o=Ge(o)}return o}})}class _z extends kt{constructor(e,t){super(t),this.jsFunc=e,this.layout=null,this.global=!0,this.once=!1}setLayout(e){return this.layout=e,this}call(e=null){return Ge(new mz(this,e))}setup(){return this.call()}}const xz=[!1,!0],vz=[0,1,2,3],bz=[-1,-2],zE=[.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],bT=new Map;for(const i of xz)bT.set(i,new $a(i));const ST=new Map;for(const i of vz)ST.set(i,new $a(i,"uint"));const TT=new Map([...ST].map(i=>new $a(i.value,"int")));for(const i of bz)TT.set(i,new $a(i,"int"));const Nx=new Map([...TT].map(i=>new $a(i.value)));for(const i of zE)Nx.set(i,new $a(i));for(const i of zE)Nx.set(-i,new $a(-i));const Px={bool:bT,uint:ST,ints:TT,float:Nx},VE=new Map([...bT,...Nx]),wT=(i,e)=>VE.has(i)?VE.get(i):i.isNode===!0?i:new $a(i,e),Qs=function(i,e=null){return(...t)=>{for(const r of t)if(r===void 0)return console.error(`THREE.TSL: Invalid parameter for the type "${i}".`),Ge(new $a(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=[Cx(i,...t)]),t.length===1&&e!==null&&e.has(t[0]))return Ky(e.get(t[0]));if(t.length===1){const r=wT(t[0],i);return r.nodeType===i?Ky(r):Ky(new DE(r,i))}const n=t.map(r=>wT(r));return Ky(new rz(n,i))}},Zy=i=>typeof i=="object"&&i!==null?i.value:i,GE=i=>i!=null?i.nodeType||i.convertTo||(typeof i=="string"?i:null):null;function Cm(i,e){return new _z(i,e)}const Ge=(i,e=null)=>hz(i,e),Ky=(i,e=null)=>Ge(i,e).toVarIntent(),Ix=(i,e=null)=>new dz(i,e),zf=(i,e=null)=>new fz(i,e),xn=(i,e=null,t=null,n=null)=>new kE(i,e,t,n),xt=(i,...e)=>new pz(i,...e),ft=(i,e=null,t=null,n={})=>new kE(i,e,t,Ii({intent:!0},n));let Sz=0;class Tz extends kt{constructor(e,t=null){super();let n=null;t!==null&&(typeof t=="object"?n=t.return:(typeof t=="string"?n=t:console.error("THREE.TSL: Invalid layout type."),t=null)),this.shaderNode=new Cm(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"+Sz++,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 console.error('THREE.TSL: "Fn()" was declared but not invoked. Try calling it like "Fn()( ...params )".'),e.generateConst(t)}}function de(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 Jy=i=>{od=i},Lx=()=>od,Yt=(...i)=>od.If(...i),wz=(...i)=>od.Switch(...i);function Dx(i){return od&&od.add(i),i}Ve("toStack",Dx);const HE=new Qs("color"),$=new Qs("float",Px.float),ie=new Qs("int",Px.ints),Pt=new Qs("uint",Px.uint),qa=new Qs("bool",Px.bool),Xe=new Qs("vec2"),or=new Qs("ivec2"),WE=new Qs("uvec2"),$E=new Qs("bvec2"),ue=new Qs("vec3"),qE=new Qs("ivec3"),Rm=new Qs("uvec3"),MT=new Qs("bvec3"),Lt=new Qs("vec4"),XE=new Qs("ivec4"),jE=new Qs("uvec4"),YE=new Qs("bvec4"),Fx=new Qs("mat2"),qr=new Qs("mat3"),Vf=new Qs("mat4"),Mz=(i="")=>Ge(new $a(i,"string")),Az=i=>Ge(new $a(i,"ArrayBuffer"));Ve("toColor",HE),Ve("toFloat",$),Ve("toInt",ie),Ve("toUint",Pt),Ve("toBool",qa),Ve("toVec2",Xe),Ve("toIVec2",or),Ve("toUVec2",WE),Ve("toBVec2",$E),Ve("toVec3",ue),Ve("toIVec3",qE),Ve("toUVec3",Rm),Ve("toBVec3",MT),Ve("toVec4",Lt),Ve("toIVec4",XE),Ve("toUVec4",jE),Ve("toBVec4",YE),Ve("toMat2",Fx),Ve("toMat3",qr),Ve("toMat4",Vf);const ZE=xn(kf).setParameterLength(2),KE=(i,e)=>Ge(new DE(Ge(i),e)),Ez=(i,e)=>Ge(new FE(Ge(i),e));Ve("element",ZE),Ve("convert",KE);const Cz=i=>(console.warn("THREE.TSL: append() has been renamed to Stack()."),Dx(i));Ve("append",i=>(console.warn("THREE.TSL: .append() has been renamed to .toStack()."),Dx(i)));class Si extends kt{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}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 El=(i,e)=>Ge(new Si(i,e)),aa=(i,e)=>Ge(new Si(i,e,!0)),fi=xt(Si,"vec4","DiffuseColor"),AT=xt(Si,"vec3","EmissiveColor"),hc=xt(Si,"float","Roughness"),Qy=xt(Si,"float","Metalness"),Bx=xt(Si,"float","Clearcoat"),e_=xt(Si,"float","ClearcoatRoughness"),Gf=xt(Si,"vec3","Sheen"),Ox=xt(Si,"float","SheenRoughness"),Ux=xt(Si,"float","Iridescence"),ET=xt(Si,"float","IridescenceIOR"),CT=xt(Si,"float","IridescenceThickness"),kx=xt(Si,"float","AlphaT"),ad=xt(Si,"float","Anisotropy"),t_=xt(Si,"vec3","AnisotropyT"),Hf=xt(Si,"vec3","AnisotropyB"),Lo=xt(Si,"color","SpecularColor"),n_=xt(Si,"float","SpecularF90"),zx=xt(Si,"float","Shininess"),Nm=xt(Si,"vec4","Output"),Wf=xt(Si,"float","dashSize"),i_=xt(Si,"float","gapSize"),Rz=xt(Si,"float","pointWidth"),s_=xt(Si,"float","IOR"),Vx=xt(Si,"float","Transmission"),RT=xt(Si,"float","Thickness"),NT=xt(Si,"float","AttenuationDistance"),PT=xt(Si,"color","AttenuationColor"),IT=xt(Si,"float","Dispersion");class JE extends kt{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 QE=i=>new JE(i),Gx=(i,e=0)=>new JE(i,!0,e),eC=Gx("frame"),Zt=Gx("render"),LT=QE("object");class r_ extends xT{static get type(){return"UniformNode"}constructor(e,t=null){super(e,t),this.isUniformNode=!0,this.name="",this.groupNode=LT}setName(e){return this.name=e,this}label(e){return console.warn('THREE.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 Jt=(i,e)=>{const t=GE(e||i);return t===i&&(i=Cx(t)),i=i&&i.isNode===!0?i.node&&i.node.value||i.value:i,Ge(new r_(i,t))};class tC extends Rs{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.nodeType=this.values[0].getNodeType(e)),this.nodeType}getElementType(e){return this.getNodeType(e)}generate(e){const t=this.getNodeType(e);return e.generateArray(t,this.count,this.values)}}const nC=(...i)=>{let e;if(i.length===1){const t=i[0];e=new tC(null,t.length,t)}else{const t=i[0],n=i[1];e=new tC(t,n)}return Ge(e)};Ve("toArray",(i,e)=>nC(Array(e).fill(i)));class Nz extends Rs{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 Uf.join("").slice(0,n)!==t.components}return!1}setup(e){const{targetNode:t,sourceNode:n}=this,r=t.getScope(),o=e.getNodeProperties(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,T=v.node.context({assign:!0}).build(e);for(let S=0;S<v.components.length;S++){const N=v.components[S];e.addLineFlowCode(`${T}.${N} = ${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 iC=xn(Nz).setParameterLength(2);Ve("assign",iC);class Pz extends Rs{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)console.error("THREE.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(console.error("THREE.TSL: The number of provided parameters is less than the expected number of inputs in 'Fn()'.");o.length<r.length;)o.push($(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)):(console.error(`THREE.TSL: Input '${u.name}' not found in 'Fn()'.`),t.push(a($(0),u)))}return`${n.build(e,"property")}( ${t.join(", ")} )`}}const sC=(i,...e)=>(e=e.length>1||e[0]&&e[0].isNode===!0?zf(e):Ix(e[0]),Ge(new Pz(Ge(i),e)));Ve("call",sC);const Iz={"==":"equal","!=":"notEqual","<":"lessThan",">":"greaterThan","<=":"lessThanEqual",">=":"greaterThanEqual","%":"mod"};class ls extends Rs{static get type(){return"OperatorNode"}constructor(e,t,n,...r){if(super(),r.length>0){let o=new ls(e,t,n);for(let a=0;a<r.length-1;a++)o=new ls(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(Iz[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===ki;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 Gs=ft(ls,"+").setParameterLength(2,1/0).setName("add"),Qn=ft(ls,"-").setParameterLength(2,1/0).setName("sub"),En=ft(ls,"*").setParameterLength(2,1/0).setName("mul"),la=ft(ls,"/").setParameterLength(2,1/0).setName("div"),o_=ft(ls,"%").setParameterLength(2).setName("mod"),DT=ft(ls,"==").setParameterLength(2).setName("equal"),rC=ft(ls,"!=").setParameterLength(2).setName("notEqual"),oC=ft(ls,"<").setParameterLength(2).setName("lessThan"),FT=ft(ls,">").setParameterLength(2).setName("greaterThan"),aC=ft(ls,"<=").setParameterLength(2).setName("lessThanEqual"),lC=ft(ls,">=").setParameterLength(2).setName("greaterThanEqual"),cC=ft(ls,"&&").setParameterLength(2,1/0).setName("and"),uC=ft(ls,"||").setParameterLength(2,1/0).setName("or"),hC=ft(ls,"!").setParameterLength(1).setName("not"),dC=ft(ls,"^^").setParameterLength(2).setName("xor"),fC=ft(ls,"&").setParameterLength(2).setName("bitAnd"),pC=ft(ls,"~").setParameterLength(2).setName("bitNot"),mC=ft(ls,"|").setParameterLength(2).setName("bitOr"),gC=ft(ls,"^").setParameterLength(2).setName("bitXor"),yC=ft(ls,"<<").setParameterLength(2).setName("shiftLeft"),_C=ft(ls,">>").setParameterLength(2).setName("shiftRight"),xC=de(([i])=>(i.addAssign(1),i)),vC=de(([i])=>(i.subAssign(1),i)),bC=de(([i])=>{const e=ie(i).toConst();return i.addAssign(1),e}),SC=de(([i])=>{const e=ie(i).toConst();return i.subAssign(1),e});Ve("add",Gs),Ve("sub",Qn),Ve("mul",En),Ve("div",la),Ve("mod",o_),Ve("equal",DT),Ve("notEqual",rC),Ve("lessThan",oC),Ve("greaterThan",FT),Ve("lessThanEqual",aC),Ve("greaterThanEqual",lC),Ve("and",cC),Ve("or",uC),Ve("not",hC),Ve("xor",dC),Ve("bitAnd",fC),Ve("bitNot",pC),Ve("bitOr",mC),Ve("bitXor",gC),Ve("shiftLeft",yC),Ve("shiftRight",_C),Ve("incrementBefore",xC),Ve("decrementBefore",vC),Ve("increment",bC),Ve("decrement",SC);const TC=(i,e)=>(console.warn('THREE.TSL: "modInt()" is deprecated. Use "mod( int( ... ) )" instead.'),o_(ie(i),ie(e)));Ve("modInt",TC);class xe extends Rs{static get type(){return"MathNode"}constructor(e,t,n=null,r=null){if(super(),(e===xe.MAX||e===xe.MIN)&&arguments.length>3){let o=new xe(e,t,n);for(let a=2;a<arguments.length-1;a++)o=new xe(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===xe.LENGTH||t===xe.DISTANCE||t===xe.DOT?"float":t===xe.CROSS?"vec3":t===xe.ALL||t===xe.ANY?"bool":t===xe.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===xe.ONE_MINUS)o=Qn(1,t);else if(r===xe.RECIPROCAL)o=la(1,t);else if(r===xe.DIFFERENCE)o=zi(Qn(t,n));else if(r===xe.TRANSFORM_DIRECTION){let a=t,c=n;e.isMatrix(a.getNodeType(e))?c=Lt(ue(c),0):a=Lt(ue(a),0);const u=En(a,c).xyz;o=Eu(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===xe.NEGATE)return e.format("( - "+c.build(e,a)+" )",o,t);{const m=[];return r===xe.CROSS?m.push(c.build(e,o),u.build(e,o)):p===ki&&r===xe.STEP?m.push(c.build(e,e.getTypeLength(c.getNodeType(e))===1?"float":a),u.build(e,a)):p===ki&&(r===xe.MIN||r===xe.MAX)?m.push(c.build(e,a),u.build(e,e.getTypeLength(u.getNodeType(e))===1?"float":a)):r===xe.REFRACT?m.push(c.build(e,a),u.build(e,a),d.build(e,"float")):r===xe.MIX?m.push(c.build(e,a),u.build(e,a),d.build(e,e.getTypeLength(d.getNodeType(e))===1?"float":a)):(p===Sr&&r===xe.ATAN&&u!==null&&(r="atan2"),e.shaderStage!=="fragment"&&(r===xe.DFDX||r===xe.DFDY)&&(console.warn(`THREE.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}}xe.ALL="all",xe.ANY="any",xe.RADIANS="radians",xe.DEGREES="degrees",xe.EXP="exp",xe.EXP2="exp2",xe.LOG="log",xe.LOG2="log2",xe.SQRT="sqrt",xe.INVERSE_SQRT="inversesqrt",xe.FLOOR="floor",xe.CEIL="ceil",xe.NORMALIZE="normalize",xe.FRACT="fract",xe.SIN="sin",xe.COS="cos",xe.TAN="tan",xe.ASIN="asin",xe.ACOS="acos",xe.ATAN="atan",xe.ABS="abs",xe.SIGN="sign",xe.LENGTH="length",xe.NEGATE="negate",xe.ONE_MINUS="oneMinus",xe.DFDX="dFdx",xe.DFDY="dFdy",xe.ROUND="round",xe.RECIPROCAL="reciprocal",xe.TRUNC="trunc",xe.FWIDTH="fwidth",xe.TRANSPOSE="transpose",xe.DETERMINANT="determinant",xe.INVERSE="inverse",xe.EQUALS="equals",xe.MIN="min",xe.MAX="max",xe.STEP="step",xe.REFLECT="reflect",xe.DISTANCE="distance",xe.DIFFERENCE="difference",xe.DOT="dot",xe.CROSS="cross",xe.POW="pow",xe.TRANSFORM_DIRECTION="transformDirection",xe.MIX="mix",xe.CLAMP="clamp",xe.REFRACT="refract",xe.SMOOTHSTEP="smoothstep",xe.FACEFORWARD="faceforward";const wC=$(1e-6),Lz=$(1e6),Hx=$(Math.PI),Dz=$(Math.PI*2),MC=ft(xe,xe.ALL).setParameterLength(1),AC=ft(xe,xe.ANY).setParameterLength(1),EC=ft(xe,xe.RADIANS).setParameterLength(1),CC=ft(xe,xe.DEGREES).setParameterLength(1),BT=ft(xe,xe.EXP).setParameterLength(1),Pm=ft(xe,xe.EXP2).setParameterLength(1),Wx=ft(xe,xe.LOG).setParameterLength(1),dc=ft(xe,xe.LOG2).setParameterLength(1),fc=ft(xe,xe.SQRT).setParameterLength(1),OT=ft(xe,xe.INVERSE_SQRT).setParameterLength(1),pc=ft(xe,xe.FLOOR).setParameterLength(1),$x=ft(xe,xe.CEIL).setParameterLength(1),Eu=ft(xe,xe.NORMALIZE).setParameterLength(1),Cu=ft(xe,xe.FRACT).setParameterLength(1),ca=ft(xe,xe.SIN).setParameterLength(1),Ru=ft(xe,xe.COS).setParameterLength(1),RC=ft(xe,xe.TAN).setParameterLength(1),NC=ft(xe,xe.ASIN).setParameterLength(1),UT=ft(xe,xe.ACOS).setParameterLength(1),qx=ft(xe,xe.ATAN).setParameterLength(1,2),zi=ft(xe,xe.ABS).setParameterLength(1),a_=ft(xe,xe.SIGN).setParameterLength(1),mc=ft(xe,xe.LENGTH).setParameterLength(1),PC=ft(xe,xe.NEGATE).setParameterLength(1),IC=ft(xe,xe.ONE_MINUS).setParameterLength(1),kT=ft(xe,xe.DFDX).setParameterLength(1),zT=ft(xe,xe.DFDY).setParameterLength(1),LC=ft(xe,xe.ROUND).setParameterLength(1),DC=ft(xe,xe.RECIPROCAL).setParameterLength(1),VT=ft(xe,xe.TRUNC).setParameterLength(1),FC=ft(xe,xe.FWIDTH).setParameterLength(1),BC=ft(xe,xe.TRANSPOSE).setParameterLength(1),OC=ft(xe,xe.DETERMINANT).setParameterLength(1),UC=ft(xe,xe.INVERSE).setParameterLength(1),kC=(i,e)=>(console.warn('THREE.TSL: "equals" is deprecated. Use "equal" inside a vector instead, like: "bvec*( equal( ... ) )"'),DT(i,e)),Do=ft(xe,xe.MIN).setParameterLength(2,1/0),ys=ft(xe,xe.MAX).setParameterLength(2,1/0),Xx=ft(xe,xe.STEP).setParameterLength(2),zC=ft(xe,xe.REFLECT).setParameterLength(2),VC=ft(xe,xe.DISTANCE).setParameterLength(2),GC=ft(xe,xe.DIFFERENCE).setParameterLength(2),ld=ft(xe,xe.DOT).setParameterLength(2),jx=ft(xe,xe.CROSS).setParameterLength(2),Xa=ft(xe,xe.POW).setParameterLength(2),GT=i=>En(i,i),HC=i=>En(i,i,i),WC=i=>En(i,i,i,i),$C=ft(xe,xe.TRANSFORM_DIRECTION).setParameterLength(2),qC=i=>En(a_(i),Xa(zi(i),1/3)),HT=i=>ld(i,i),oi=ft(xe,xe.MIX).setParameterLength(3),ja=(i,e=0,t=1)=>Ge(new xe(xe.CLAMP,Ge(i),Ge(e),Ge(t))),WT=i=>ja(i),$T=ft(xe,xe.REFRACT).setParameterLength(3),Ya=ft(xe,xe.SMOOTHSTEP).setParameterLength(3),qT=ft(xe,xe.FACEFORWARD).setParameterLength(3),XC=de(([i])=>{const n=43758.5453,r=ld(i.xy,Xe(12.9898,78.233)),o=o_(r,Hx);return Cu(ca(o).mul(n))}),jC=(i,e,t)=>oi(e,t,i),YC=(i,e,t)=>Ya(e,t,i),ZC=(i,e)=>Xx(e,i),KC=(i,e)=>(console.warn('THREE.TSL: "atan2" is overloaded. Use "atan" instead.'),qx(i,e)),Fz=qT,Bz=OT;Ve("all",MC),Ve("any",AC),Ve("equals",kC),Ve("radians",EC),Ve("degrees",CC),Ve("exp",BT),Ve("exp2",Pm),Ve("log",Wx),Ve("log2",dc),Ve("sqrt",fc),Ve("inverseSqrt",OT),Ve("floor",pc),Ve("ceil",$x),Ve("normalize",Eu),Ve("fract",Cu),Ve("sin",ca),Ve("cos",Ru),Ve("tan",RC),Ve("asin",NC),Ve("acos",UT),Ve("atan",qx),Ve("abs",zi),Ve("sign",a_),Ve("length",mc),Ve("lengthSq",HT),Ve("negate",PC),Ve("oneMinus",IC),Ve("dFdx",kT),Ve("dFdy",zT),Ve("round",LC),Ve("reciprocal",DC),Ve("trunc",VT),Ve("fwidth",FC),Ve("atan2",KC),Ve("min",Do),Ve("max",ys),Ve("step",ZC),Ve("reflect",zC),Ve("distance",VC),Ve("dot",ld),Ve("cross",jx),Ve("pow",Xa),Ve("pow2",GT),Ve("pow3",HC),Ve("pow4",WC),Ve("transformDirection",$C),Ve("mix",jC),Ve("clamp",ja),Ve("refract",$T),Ve("smoothstep",YC),Ve("faceForward",qT),Ve("difference",GC),Ve("saturate",WT),Ve("cbrt",qC),Ve("transpose",BC),Ve("determinant",OC),Ve("inverse",UC),Ve("rand",XC);class Oz extends kt{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.cache(),n=this.ifNode.cache(),r=this.elseNode?this.elseNode.cache():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?El(n).build(e):"";r.nodeProperty=p;const m=o.build(e,"bool");if(e.context.uniformFlow&&c!==null){const v=a.build(e,n),M=c.build(e,n),T=e.getTernary(m,v,M);return e.format(T,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&&(console.warn("THREE.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&&(console.warn("THREE.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 _r=xn(Oz).setParameterLength(2,3);Ve("select",_r);class JC extends kt{static get type(){return"ContextNode"}constructor(e,t={}){super(),this.isContextNode=!0,this.node=e,this.value=t}getScope(){return this.node.getScope()}getNodeType(e){return this.node.getNodeType(e)}getMemberType(e,t){return this.node.getMemberType(e,t)}analyze(e){const t=e.getContext();e.setContext(Ii(Ii({},e.context),this.value)),this.node.build(e),e.setContext(t)}setup(e){const t=e.getContext();e.setContext(Ii(Ii({},e.context),this.value)),this.node.build(e),e.setContext(t)}generate(e,t){const n=e.getContext();e.setContext(Ii(Ii({},e.context),this.value));const r=this.node.build(e,t);return e.setContext(n),r}}const l_=xn(JC).setParameterLength(1,2),QC=i=>l_(i,{uniformFlow:!0}),XT=(i,e)=>l_(i,{nodeName:e});function eR(i,e){return console.warn('THREE.TSL: "label()" has been deprecated. Use "setName()" instead.'),XT(i,e)}Ve("context",l_),Ve("label",eR),Ve("uniformFlow",QC),Ve("setName",XT);class Yx extends kt{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}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)}build(...e){return this.intent===!0&&e[0].getNodeProperties(this).assign!==!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=e.getVectorType(this.getNodeType(e)),p=t.build(e,d),m=e.getVarFromNode(this,n,d,void 0,u),y=e.getPropertyName(m);let x=y;if(u)if(a)x=c?`const ${y}`:`let ${y}`;else{const v=t.getArrayCount(e);x=`const ${e.getVar(m.type,y,v)}`}return e.addLineFlowCode(`${x} = ${p}`,this),y}}const jT=xn(Yx),tR=(i,e=null)=>jT(i,e).toStack(),nR=(i,e=null)=>jT(i,e,!0).toStack(),iR=i=>Lx()===null?i:jT(i).setIntent(!0).toStack();Ve("toVar",tR),Ve("toConst",nR),Ve("toVarIntent",iR);class Uz extends kt{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 Im=(i,e,t=null)=>Ge(new Uz(Ge(i),e,t));class kz extends kt{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=Im(this.node,"VERTEX")}return n.needsInterpolation||(n.needsInterpolation=e.shaderStage==="fragment"),n}setup(e){this.setupVarying(e),e.flowNodeFromShaderStage(jy.VERTEX,this.node)}analyze(e){this.setupVarying(e),e.flowNodeFromShaderStage(jy.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,jy.VERTEX);e.flowNodeFromShaderStage(jy.VERTEX,n.node,o,a),n[t]=a}return e.getPropertyName(r)}}const gc=xn(kz).setParameterLength(1,2),sR=i=>gc(i);Ve("toVarying",gc),Ve("toVertexStage",sR),Ve("varying",(...i)=>(console.warn("THREE.TSL: .varying() has been renamed to .toVarying()."),gc(...i))),Ve("vertexStage",(...i)=>(console.warn("THREE.TSL: .vertexStage() has been renamed to .toVertexStage()."),gc(...i)));const rR=de(([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"}]}),oR=de(([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"}]}),YT="WorkingColorSpace",zz="OutputColorSpace";class ZT extends Rs{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===YT?pn.workingColorSpace:t===zz?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 pn.enabled===!1||n===r||!n||!r||(pn.getTransfer(n)===Dt&&(o=Lt(rR(o.rgb),o.a)),pn.getPrimaries(n)!==pn.getPrimaries(r)&&(o=Lt(qr(pn._getMatrix(new Cn,n,r)).mul(o.rgb),o.a)),pn.getTransfer(r)===Dt&&(o=Lt(oR(o.rgb),o.a))),o}}const aR=(i,e)=>Ge(new ZT(Ge(i),YT,e)),Zx=(i,e)=>Ge(new ZT(Ge(i),e,YT)),Vz=(i,e,t)=>Ge(new ZT(Ge(i),e,t));Ve("workingToColorSpace",aR),Ve("colorSpaceToWorking",Zx);let Gz=class extends kf{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 lR extends kt{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=In.OBJECT}setGroup(e){return this.group=e,this}element(e){return Ge(new Gz(this,Ge(e)))}setNodeType(e){const t=Jt(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 Hz=(i,e,t)=>Ge(new lR(i,e,t));class Wz extends lR{static get type(){return"RendererReferenceNode"}constructor(e,t,n=null){super(e,t,n),this.renderer=n,this.setGroup(Zt)}updateReference(e){return this.reference=this.renderer!==null?this.renderer:e.renderer,this.reference}}const cR=(i,e,t=null)=>Ge(new Wz(i,e,t));class $z extends Rs{static get type(){return"ToneMappingNode"}constructor(e,t=hR,n=null){super("vec3"),this.toneMapping=e,this.exposureNode=t,this.colorNode=n}customCacheKey(){return $y(this.toneMapping)}setup(e){const t=this.colorNode||e.context.color,n=this.toneMapping;if(n===Qr)return t;let r=null;const o=e.renderer.library.getToneMappingFunction(n);return o!==null?r=Lt(o(t.rgb,this.exposureNode),t.a):(console.error("ToneMappingNode: Unsupported Tone Mapping configuration.",n),r=t),r}}const uR=(i,e,t)=>Ge(new $z(i,Ge(e),Ge(t))),hR=cR("toneMappingExposure","float");Ve("toneMapping",(i,e,t)=>uR(e,t,i));class qz extends xT{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=kl,this.instanced=!1,this.attribute=null,this.global=!0,e&&e.isBufferAttribute===!0&&(this.attribute=e,this.usage=e.usage,this.instanced=e.isInstancedBufferAttribute)}getHash(e){if(this.bufferStride===0&&this.bufferOffset===0){let t=e.globalCache.getData(this.value);return t===void 0&&(t={node:this},e.globalCache.setData(this.value,t)),t.node.uuid}return this.uuid}getNodeType(e){return this.bufferType===null&&(this.bufferType=e.getTypeFromAttribute(this.attribute)),this.bufferType}setup(e){if(this.attribute!==null)return;const t=this.getNodeType(e),n=this.value,r=e.getTypeLength(t),o=this.bufferStride||r,a=this.bufferOffset,c=n.isInterleavedBuffer===!0?n:new fl(n,o),u=new Rh(c,r,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=gc(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}}const c_=(i,e=null,t=0,n=0)=>Ge(new qz(i,e,t,n)),dR=(i,e=null,t=0,n=0)=>c_(i,e,t,n).setUsage(Rd),Kx=(i,e=null,t=0,n=0)=>c_(i,e,t,n).setInstanced(!0),KT=(i,e=null,t=0,n=0)=>dR(i,e,t,n).setInstanced(!0);Ve("toAttribute",i=>c_(i.value));class Xz extends kt{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=In.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 console.warn('THREE.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 JT=(i,e=[64])=>{(e.length===0||e.length>3)&&console.error("THREE.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))&&console.error(`THREE.TSL: compute() workgroupSize element at index [ ${t} ] must be a positive integer`)}for(;e.length<3;)e.push(1);return Ge(new Xz(Ge(i),e))},fR=(i,e,t)=>JT(i,t).setCount(e);Ve("compute",fR),Ve("computeKernel",JT);class jz extends kt{static get type(){return"CacheNode"}constructor(e,t=!0){super(),this.node=e,this.parent=t,this.isCacheNode=!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}}const u_=(i,e)=>Ge(new jz(Ge(i),e));Ve("cache",u_);class Yz extends kt{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 pR=xn(Yz).setParameterLength(2);Ve("bypass",pR);class mR extends kt{static get type(){return"RemapNode"}constructor(e,t,n,r=$(0),o=$(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 gR=xn(mR,null,null,{doClamp:!1}).setParameterLength(3,5),yR=xn(mR).setParameterLength(3,5);Ve("remap",gR),Ve("remapClamp",yR);class Jx extends kt{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 Nu=xn(Jx).setParameterLength(1,2),_R=i=>(i?_r(i,Nu("discard")):Nu("discard")).toStack(),Zz=()=>Nu("return").toStack();Ve("discard",_R);class Kz extends Rs{static get type(){return"RenderOutputNode"}constructor(e,t,n){super("vec4"),this.colorNode=e,this.toneMapping=t,this.outputColorSpace=n,this.isRenderOutputNode=!0}setup({context:e}){let t=this.colorNode||e.color;const n=(this.toneMapping!==null?this.toneMapping:e.toneMapping)||Qr,r=(this.outputColorSpace!==null?this.outputColorSpace:e.outputColorSpace)||br;return n!==Qr&&(t=t.toneMapping(n)),r!==br&&r!==pn.workingColorSpace&&(t=t.workingToColorSpace(r)),t}}const QT=(i,e=null,t=null)=>Ge(new Kz(Ge(i),e,t));Ve("renderOutput",QT);class Jz extends Rs{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):console.log(a),n}}const xR=(i,e=null)=>Ge(new Jz(Ge(i),e)).toStack();Ve("debug",xR);function Qz(i){console.warn("THREE.TSL: AddNodeElement has been removed in favor of tree-shaking. Trying add",i)}class vR extends kt{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):gc(this).build(e,n)}else return console.warn(`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 ho=(i,e=null)=>Ge(new vR(i,e)),Ri=(i=0)=>ho("uv"+(i>0?i:""),"vec2");class eV extends kt{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 cd=xn(eV).setParameterLength(1,2);class tV extends r_{static get type(){return"MaxMipLevelNode"}constructor(e){super(0),this._textureNode=e,this.updateType=In.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 ew=xn(tV).setParameterLength(1),tw=new ds;class yc extends r_{static get type(){return"TextureNode"}constructor(e=tw,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=In.NONE,this.referenceNode=null,this._value=e,this._matrixUniform=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===pi?"uvec4":this.value.type===Ws?"ivec4":"vec4"}getInputType(){return"texture"}getDefaultUV(){return Ri(this.value.channel)}updateReference(){return this.value}getTransformedUV(e){return this._matrixUniform===null&&(this._matrixUniform=Jt(this.value.matrix)),this._matrixUniform.mul(ue(e,1)).xy}setUpdateMatrix(e){return this.updateMatrix=e,this.updateType=e?In.OBJECT:In.NONE,this}setupUV(e,t){const n=this.value;return e.isFlipY()&&(n.image instanceof ImageBitmap&&n.flipY===!0||n.isRenderTargetTexture===!0||n.isFramebufferTexture===!0||n.isDepthTexture===!0)&&(this.sampler?t=t.flipY():t=t.setY(ie(cd(this,this.levelNode).y).sub(t.y).sub(1))),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().");let r=this.uvNode;(r===null||e.context.forceUVContext===!0)&&e.context.getUV&&(r=e.context.getUV(this,e)),r||(r=this.getDefaultUV()),this.updateMatrix===!0&&(r=this.getTransformedUV(r)),r=this.setupUV(e,r);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 r?m=e.generateTextureLevel(p,t,n,r,a,d):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,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:M,offsetNode:T}=r,S=this.generateUV(e,p),N=m?m.build(e,"float"):null,R=y?y.build(e,"float"):null,P=v?v.build(e,"int"):null,B=x?x.build(e,"float"):null,F=M?[M[0].build(e,"vec2"),M[1].build(e,"vec2")]:null,k=T?this.generateOffset(e,T):null,V=e.getVarFromNode(this);c=e.getPropertyName(V);const U=this.generateSnippet(e,o,S,N,R,P,B,F,k);e.addLineFlowCode(`${c} = ${U}`,this),a.snippet=U,a.propertyName=c}let u=c;const d=this.getNodeType(e);return e.needsToWorkingColorSpace(n)&&(u=Zx(Nu(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 console.warn("THREE.TextureNode: .uv() has been renamed. Use .sample() instead."),this.sample(e)}sample(e){const t=this.clone();return t.uvNode=Ge(e),t.referenceNode=this.getBase(),Ge(t)}load(e){return this.sample(e).setSampler(!1)}blur(e){const t=this.clone();t.biasNode=Ge(e).mul(ew(t)),t.referenceNode=this.getBase();const n=t.value;return t.generateMipmaps===!1&&(n&&n.generateMipmaps===!1||n.minFilter===Jn||n.magFilter===Jn)&&(console.warn("THREE.TSL: texture().blur() requires mipmaps and sampling. Use .generateMipmaps=true and .minFilter/.magFilter=THREE.LinearFilter in the Texture."),t.biasNode=null),Ge(t)}level(e){const t=this.clone();return t.levelNode=Ge(e),t.referenceNode=this.getBase(),Ge(t)}size(e){return cd(this,e)}bias(e){const t=this.clone();return t.biasNode=Ge(e),t.referenceNode=this.getBase(),Ge(t)}getBase(){return this.referenceNode?this.referenceNode.getBase():this}compare(e){const t=this.clone();return t.compareNode=Ge(e),t.referenceNode=this.getBase(),Ge(t)}grad(e,t){const n=this.clone();return n.gradNode=[Ge(e),Ge(t)],n.referenceNode=this.getBase(),Ge(n)}depth(e){const t=this.clone();return t.depthNode=Ge(e),t.referenceNode=this.getBase(),Ge(t)}offset(e){const t=this.clone();return t.offsetNode=Ge(e),t.referenceNode=this.getBase(),Ge(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()}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 nV=xn(yc).setParameterLength(1,4).setName("texture"),Kn=(i=tw,e=null,t=null,n=null)=>{let r;return i&&i.isTextureNode===!0?(r=Ge(i.clone()),r.referenceNode=i.getBase(),e!==null&&(r.uvNode=Ge(e)),t!==null&&(r.levelNode=Ge(t)),n!==null&&(r.biasNode=Ge(n))):r=nV(i,e,t,n),r},iV=(i=tw)=>Kn(i),Ns=(...i)=>Kn(...i).setSampler(!1),sV=i=>(i.isNode===!0?i:Kn(i)).convert("sampler"),rV=i=>(i.isNode===!0?i:Kn(i)).convert("samplerComparison");class nw extends r_{static get type(){return"BufferNode"}constructor(e,t,n=0){super(e,t),this.isBufferNode=!0,this.bufferType=t,this.bufferCount=n}getElementType(e){return this.getNodeType(e)}getInputType(){return"buffer"}}const h_=(i,e,t)=>Ge(new nw(i,e,t));class oV extends kf{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 aV extends nw{static get type(){return"UniformArrayNode"}constructor(e,t=null){super(null),this.array=e,this.elementType=t===null?Au(e[0]):t,this.paddedType=this.getPaddedType(),this.updateType=In.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 Ge(new oV(this,Ge(e)))}}const Xr=(i,e)=>Ge(new aV(i,e));class lV extends kt{constructor(e){super("float"),this.name=e,this.isBuiltinNode=!0}generate(){return this.name}}const Pu=xn(lV).setParameterLength(1);let d_,f_;class Vi extends kt{static get type(){return"ScreenNode"}constructor(e){super(),this.scope=e,this._output=null,this.isViewportNode=!0}getNodeType(){return this.scope===Vi.DPR?"float":this.scope===Vi.VIEWPORT?"vec4":"vec2"}getUpdateType(){let e=In.NONE;return(this.scope===Vi.SIZE||this.scope===Vi.VIEWPORT||this.scope===Vi.DPR)&&(e=In.RENDER),this.updateType=e,e}update({renderer:e}){const t=e.getRenderTarget();this.scope===Vi.VIEWPORT?t!==null?f_.copy(t.viewport):(e.getViewport(f_),f_.multiplyScalar(e.getPixelRatio())):this.scope===Vi.DPR?this._output.value=e.getPixelRatio():t!==null?(d_.width=t.width,d_.height=t.height):e.getDrawingBufferSize(d_)}setup(){const e=this.scope;let t=null;return e===Vi.SIZE?t=Jt(d_||(d_=new Ie)):e===Vi.VIEWPORT?t=Jt(f_||(f_=new an)):e===Vi.DPR?t=Jt(1):t=Xe(p_.div($f)),this._output=t,t}generate(e){if(this.scope===Vi.COORDINATE){let t=e.getFragCoord();if(e.isFlipY()){const n=e.getNodeProperties($f).outputNode.build(e);t=`${e.getType("vec2")}( ${t}.x, ${n}.y - ${t}.y )`}return t}return super.generate(e)}}Vi.COORDINATE="coordinate",Vi.VIEWPORT="viewport",Vi.SIZE="size",Vi.UV="uv",Vi.DPR="dpr";const bR=xt(Vi,Vi.DPR),Iu=xt(Vi,Vi.UV),$f=xt(Vi,Vi.SIZE),p_=xt(Vi,Vi.COORDINATE),Lm=xt(Vi,Vi.VIEWPORT),iw=Lm.zw,SR=p_.sub(Lm.xy),cV=SR.div(iw),uV=de(()=>(console.warn('THREE.TSL: "viewportResolution" is deprecated. Use "screenSize" instead.'),$f),"vec2").once()(),ud=Jt(0,"uint").setName("u_cameraIndex").setGroup(Gx("cameraIndex")).toVarying("v_cameraIndex"),Lu=Jt("float").setName("cameraNear").setGroup(Zt).onRenderUpdate(({camera:i})=>i.near),Du=Jt("float").setName("cameraFar").setGroup(Zt).onRenderUpdate(({camera:i})=>i.far),Za=de(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const r of i.cameras)t.push(r.projectionMatrix);e=Xr(t).setGroup(Zt).setName("cameraProjectionMatrices").element(i.isMultiViewCamera?Pu("gl_ViewID_OVR"):ud).toConst("cameraProjectionMatrix")}else e=Jt("mat4").setName("cameraProjectionMatrix").setGroup(Zt).onRenderUpdate(({camera:t})=>t.projectionMatrix);return e}).once()(),hV=de(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const r of i.cameras)t.push(r.projectionMatrixInverse);e=Xr(t).setGroup(Zt).setName("cameraProjectionMatricesInverse").element(i.isMultiViewCamera?Pu("gl_ViewID_OVR"):ud).toConst("cameraProjectionMatrixInverse")}else e=Jt("mat4").setName("cameraProjectionMatrixInverse").setGroup(Zt).onRenderUpdate(({camera:t})=>t.projectionMatrixInverse);return e}).once()(),ua=de(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const r of i.cameras)t.push(r.matrixWorldInverse);e=Xr(t).setGroup(Zt).setName("cameraViewMatrices").element(i.isMultiViewCamera?Pu("gl_ViewID_OVR"):ud).toConst("cameraViewMatrix")}else e=Jt("mat4").setName("cameraViewMatrix").setGroup(Zt).onRenderUpdate(({camera:t})=>t.matrixWorldInverse);return e}).once()(),dV=de(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const r of i.cameras)t.push(r.matrixWorld);e=Xr(t).setGroup(Zt).setName("cameraWorldMatrices").element(i.isMultiViewCamera?Pu("gl_ViewID_OVR"):ud).toConst("cameraWorldMatrix")}else e=Jt("mat4").setName("cameraWorldMatrix").setGroup(Zt).onRenderUpdate(({camera:t})=>t.matrixWorld);return e}).once()(),fV=de(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const r of i.cameras)t.push(r.normalMatrix);e=Xr(t).setGroup(Zt).setName("cameraNormalMatrices").element(i.isMultiViewCamera?Pu("gl_ViewID_OVR"):ud).toConst("cameraNormalMatrix")}else e=Jt("mat3").setName("cameraNormalMatrix").setGroup(Zt).onRenderUpdate(({camera:t})=>t.normalMatrix);return e}).once()(),m_=de(({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 W);e=Xr(t).setGroup(Zt).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?Pu("gl_ViewID_OVR"):ud).toConst("cameraPosition")}else e=Jt(new W).setName("cameraPosition").setGroup(Zt).onRenderUpdate(({camera:t},n)=>n.value.setFromMatrixPosition(t.matrixWorld));return e}).once()(),pV=de(({camera:i})=>{let e;if(i.isArrayCamera&&i.cameras.length>0){const t=[];for(const r of i.cameras)t.push(r.viewport);e=Xr(t,"vec4").setGroup(Zt).setName("cameraViewports").element(ud).toConst("cameraViewport")}else e=Lt(0,0,$f.x,$f.y).toConst("cameraViewport");return e}).once()(),TR=new Ms;class ti extends kt{static get type(){return"Object3DNode"}constructor(e,t=null){super(),this.scope=e,this.object3d=t,this.updateType=In.OBJECT,this.uniformNode=new r_(null)}getNodeType(){const e=this.scope;if(e===ti.WORLD_MATRIX)return"mat4";if(e===ti.POSITION||e===ti.VIEW_POSITION||e===ti.DIRECTION||e===ti.SCALE)return"vec3";if(e===ti.RADIUS)return"float"}update(e){const t=this.object3d,n=this.uniformNode,r=this.scope;if(r===ti.WORLD_MATRIX)n.value=t.matrixWorld;else if(r===ti.POSITION)n.value=n.value||new W,n.value.setFromMatrixPosition(t.matrixWorld);else if(r===ti.SCALE)n.value=n.value||new W,n.value.setFromMatrixScale(t.matrixWorld);else if(r===ti.DIRECTION)n.value=n.value||new W,t.getWorldDirection(n.value);else if(r===ti.VIEW_POSITION){const o=e.camera;n.value=n.value||new W,n.value.setFromMatrixPosition(t.matrixWorld),n.value.applyMatrix4(o.matrixWorldInverse)}else if(r===ti.RADIUS){const o=e.object.geometry;o.boundingSphere===null&&o.computeBoundingSphere(),TR.copy(o.boundingSphere).applyMatrix4(t.matrixWorld),n.value=TR.radius}}generate(e){const t=this.scope;return t===ti.WORLD_MATRIX?this.uniformNode.nodeType="mat4":t===ti.POSITION||t===ti.VIEW_POSITION||t===ti.DIRECTION||t===ti.SCALE?this.uniformNode.nodeType="vec3":t===ti.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}}ti.WORLD_MATRIX="worldMatrix",ti.POSITION="position",ti.SCALE="scale",ti.VIEW_POSITION="viewPosition",ti.DIRECTION="direction",ti.RADIUS="radius";const mV=xn(ti,ti.DIRECTION).setParameterLength(1),gV=xn(ti,ti.WORLD_MATRIX).setParameterLength(1),wR=xn(ti,ti.POSITION).setParameterLength(1),yV=xn(ti,ti.SCALE).setParameterLength(1),_V=xn(ti,ti.VIEW_POSITION).setParameterLength(1),xV=xn(ti,ti.RADIUS).setParameterLength(1);class Ka extends ti{static get type(){return"ModelNode"}constructor(e){super(e)}update(e){this.object3d=e.object,super.update(e)}}const vV=xt(Ka,Ka.DIRECTION),Ja=xt(Ka,Ka.WORLD_MATRIX),bV=xt(Ka,Ka.POSITION),SV=xt(Ka,Ka.SCALE),TV=xt(Ka,Ka.VIEW_POSITION),MR=xt(Ka,Ka.RADIUS),AR=Jt(new Cn).onObjectUpdate(({object:i},e)=>e.value.getNormalMatrix(i.matrixWorld)),wV=Jt(new Vt).onObjectUpdate(({object:i},e)=>e.value.copy(i.matrixWorld).invert()),Fu=de(i=>i.renderer.overrideNodes.modelViewMatrix||ER).once()().toVar("modelViewMatrix"),ER=ua.mul(Ja),sw=de(i=>(i.context.isHighPrecisionModelViewMatrix=!0,Jt("mat4").onObjectUpdate(({object:e,camera:t})=>e.modelViewMatrix.multiplyMatrices(t.matrixWorldInverse,e.matrixWorld)))).once()().toVar("highpModelViewMatrix"),rw=de(i=>{const e=i.context.isHighPrecisionModelViewMatrix;return Jt("mat3").onObjectUpdate(({object:t,camera:n})=>(e!==!0&&t.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,t.matrixWorld),t.normalMatrix.getNormalMatrix(t.modelViewMatrix)))}).once()().toVar("highpModelNormalViewMatrix"),Lr=ho("position","vec3"),Ps=Lr.toVarying("positionLocal"),Qx=Lr.toVarying("positionPrevious"),ha=de(i=>Ja.mul(Ps).xyz.toVarying(i.getSubBuildProperty("v_positionWorld")),"vec3").once(["POSITION"])(),ow=de(()=>Ps.transformDirection(Ja).toVarying("v_positionWorldDirection").normalize().toVar("positionWorldDirection"),"vec3").once(["POSITION"])(),Is=de(i=>i.context.setupPositionView().toVarying("v_positionView"),"vec3").once(["POSITION"])(),Yi=Is.negate().toVarying("v_positionViewDirection").normalize().toVar("positionViewDirection");class MV extends kt{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===Ee?"false":e.getFrontFacing()}}const CR=xt(MV),aw=$(CR).mul(2).sub(1),Dm=de(([i],{material:e})=>{const t=e.side;return t===Ee?i=i.mul(-1):t===ke&&(i=i.mul(aw)),i}),ev=ho("normal","vec3"),Fo=de(i=>i.geometry.hasAttribute("normal")===!1?(console.warn('THREE.TSL: Vertex attribute "normal" not found on geometry.'),ue(0,1,0)):ev,"vec3").once()().toVar("normalLocal"),RR=Is.dFdx().cross(Is.dFdy()).normalize().toVar("normalFlat"),Fm=de(i=>{let e;return i.material.flatShading===!0?e=RR:e=lw(Fo).toVarying("v_normalViewGeometry").normalize(),e},"vec3").once()().toVar("normalViewGeometry"),NR=de(i=>{let e=Fm.transformDirection(ua);return i.material.flatShading!==!0&&(e=e.toVarying("v_normalWorldGeometry")),e.normalize().toVar("normalWorldGeometry")},"vec3").once()(),Ti=de(({subBuildFn:i,material:e,context:t})=>{let n;return i==="NORMAL"||i==="VERTEX"?(n=Fm,e.flatShading!==!0&&(n=Dm(n))):n=t.setupNormal().context({getUV:null}),n},"vec3").once(["NORMAL","VERTEX"])().toVar("normalView"),hd=Ti.transformDirection(ua).toVar("normalWorld"),qf=de(({subBuildFn:i,context:e})=>{let t;return i==="NORMAL"||i==="VERTEX"?t=Ti:t=e.setupClearcoatNormal().context({getUV:null}),t},"vec3").once(["NORMAL","VERTEX"])().toVar("clearcoatNormalView"),PR=de(([i,e=Ja])=>{const t=qr(e),n=i.div(ue(t[0].dot(t[0]),t[1].dot(t[1]),t[2].dot(t[2])));return t.mul(n).xyz}),lw=de(([i],e)=>{const t=e.renderer.overrideNodes.modelNormalViewMatrix;if(t!==null)return t.transformDirection(i);const n=AR.mul(i);return ua.transformDirection(n)}),AV=de(()=>(console.warn('THREE.TSL: "transformedNormalView" is deprecated. Use "normalView" instead.'),Ti)).once(["NORMAL","VERTEX"])(),EV=de(()=>(console.warn('THREE.TSL: "transformedNormalWorld" is deprecated. Use "normalWorld" instead.'),hd)).once(["NORMAL","VERTEX"])(),CV=de(()=>(console.warn('THREE.TSL: "transformedClearcoatNormalView" is deprecated. Use "clearcoatNormalView" instead.'),qf)).once(["NORMAL","VERTEX"])(),IR=new Gr,cw=new Vt,LR=Jt(0).onReference(({material:i})=>i).onObjectUpdate(({material:i})=>i.refractionRatio),tv=Jt(1).onReference(({material:i})=>i).onObjectUpdate(function({material:i,scene:e}){return i.envMap?i.envMapIntensity:e.environmentIntensity}),uw=Jt(new Vt).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?(IR.copy(t),cw.makeRotationFromEuler(IR)):cw.identity(),cw}),DR=Yi.negate().reflect(Ti),FR=Yi.negate().refract(Ti,LR),BR=DR.transformDirection(ua).toVar("reflectVector"),OR=FR.transformDirection(ua).toVar("reflectVector"),UR=new jl;class RV extends yc{static get type(){return"CubeTextureNode"}constructor(e,t=null,n=null,r=null){super(e,t,n,r),this.isCubeTextureNode=!0}getInputType(){return"cubeTexture"}getDefaultUV(){const e=this.value;return e.mapping===Br?BR:e.mapping===Vo?OR:(console.error('THREE.CubeTextureNode: Mapping "%s" not supported.',e.mapping),ue(0,0,0))}setUpdateMatrix(){}setupUV(e,t){const n=this.value;return(e.renderer.coordinateSystem===Sr||!n.isRenderTargetTexture)&&(t=ue(t.x.negate(),t.yz)),uw.mul(t)}generateUV(e,t){return t.build(e,"vec3")}}const hw=xn(RV).setParameterLength(1,4).setName("cubeTexture"),Bm=(i=UR,e=null,t=null,n=null)=>{let r;return i&&i.isCubeTextureNode===!0?(r=Ge(i.clone()),r.referenceNode=i,e!==null&&(r.uvNode=Ge(e)),t!==null&&(r.levelNode=Ge(t)),n!==null&&(r.biasNode=Ge(n))):r=hw(i,e,t,n),r},NV=(i=UR)=>hw(i);class PV extends kf{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 nv extends kt{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=In.OBJECT}element(e){return Ge(new PV(this,Ge(e)))}setGroup(e){return this.group=e,this}setName(e){return this.name=e,this}label(e){return console.warn('THREE.TSL: "label()" has been deprecated. Use "setName()" instead.'),this.setName(e)}setNodeType(e){let t=null;this.count!==null?t=h_(null,e,this.count):Array.isArray(this.getValueFromReference())?t=Xr(null,e):e==="texture"?t=Kn(null):e==="cubeTexture"?t=Bm(null):t=Jt(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 Fi=(i,e,t)=>Ge(new nv(i,e,t)),dw=(i,e,t,n)=>Ge(new nv(i,e,n,t));class IV extends nv{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 Bu=(i,e,t=null)=>Ge(new IV(i,e,t)),kR=Ri(),LV=Is.dFdx(),DV=Is.dFdy(),zR=kR.dFdx(),VR=kR.dFdy(),GR=Ti,HR=DV.cross(GR),WR=GR.cross(LV),fw=HR.mul(zR.x).add(WR.mul(VR.x)),pw=HR.mul(zR.y).add(WR.mul(VR.y)),$R=fw.dot(fw).max(pw.dot(pw)),qR=$R.equal(0).select(0,$R.inverseSqrt()),FV=fw.mul(qR).toVar("tangentViewFrame"),BV=pw.mul(qR).toVar("bitangentViewFrame"),iv=de(i=>(i.geometry.hasAttribute("tangent")===!1&&i.geometry.computeTangents(),ho("tangent","vec4")))(),g_=iv.xyz.toVar("tangentLocal"),sv=de(({subBuildFn:i,geometry:e,material:t})=>{let n;return i==="VERTEX"||e.hasAttribute("tangent")?n=Fu.mul(Lt(g_,0)).xyz.toVarying("v_tangentView").normalize():n=FV,t.flatShading!==!0&&(n=Dm(n)),n},"vec3").once(["NORMAL","VERTEX"])().toVar("tangentView"),XR=sv.transformDirection(ua).toVarying("v_tangentWorld").normalize().toVar("tangentWorld"),rv=de(([i,e],{subBuildFn:t,material:n})=>{let r=i.mul(iv.w).xyz;return t==="NORMAL"&&n.flatShading!==!0&&(r=r.toVarying(e)),r}).once(["NORMAL"]),OV=rv(ev.cross(iv),"v_bitangentGeometry").normalize().toVar("bitangentGeometry"),UV=rv(Fo.cross(g_),"v_bitangentLocal").normalize().toVar("bitangentLocal"),jR=de(({subBuildFn:i,geometry:e,material:t})=>{let n;return i==="VERTEX"||e.hasAttribute("tangent")?n=rv(Ti.cross(sv),"v_bitangentView").normalize():n=BV,t.flatShading!==!0&&(n=Dm(n)),n},"vec3").once(["NORMAL","VERTEX"])().toVar("bitangentView"),kV=rv(hd.cross(XR),"v_bitangentWorld").normalize().toVar("bitangentWorld"),Xf=qr(sv,jR,Ti).toVar("TBNViewMatrix"),YR=Yi.mul(Xf),zV=(i,e)=>i.sub(YR.mul(e)),ZR=de(()=>{let i=Hf.cross(Yi);return i=i.cross(Hf).normalize(),i=oi(i,Ti,ad.mul(hc.oneMinus()).oneMinus().pow2().pow2()).normalize(),i}).once()();class VV extends Rs{static get type(){return"NormalMapNode"}constructor(e,t=null){super("vec3"),this.node=e,this.scaleNode=t,this.normalMapType=Ur}setup({material:e}){const{normalMapType:t,scaleNode:n}=this;let r=this.node.mul(2).sub(1);if(n!==null){let a=n;e.flatShading===!0&&(a=Dm(a)),r=ue(r.xy.mul(a),r.z)}let o=null;return t===Mb?o=lw(r):t===Ur?o=Xf.mul(r).normalize():(console.error(`THREE.NodeMaterial: Unsupported normal map type: ${t}`),o=Ti),o}}const mw=xn(VV).setParameterLength(1,2),GV=de(({textureNode:i,bumpScale:e})=>{const t=r=>i.cache().context({getUV:o=>r(o.uvNode||Ri()),forceUVContext:!0}),n=$(t(r=>r));return Xe($(t(r=>r.add(r.dFdx()))).sub(n),$(t(r=>r.add(r.dFdy()))).sub(n)).mul(e)}),HV=de(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(aw),p=d.sign().mul(n.x.mul(c).add(n.y.mul(u)));return d.abs().mul(t).sub(p).normalize()});class WV extends Rs{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=GV({textureNode:this.textureNode,bumpScale:e});return HV({surf_pos:Is,surf_norm:Ti,dHdxy:t})}}const gw=xn(WV).setParameterLength(1,2),KR=new Map;class We extends kt{static get type(){return"MaterialNode"}constructor(e){super(),this.scope=e}getCache(e,t){let n=KR.get(e);return n===void 0&&(n=Bu(e,t),KR.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===We.COLOR){const o=t.color!==void 0?this.getColor(n):ue();t.map&&t.map.isTexture===!0?r=o.mul(this.getTexture("map")):r=o}else if(n===We.OPACITY){const o=this.getFloat(n);t.alphaMap&&t.alphaMap.isTexture===!0?r=o.mul(this.getTexture("alpha")):r=o}else if(n===We.SPECULAR_STRENGTH)t.specularMap&&t.specularMap.isTexture===!0?r=this.getTexture("specular").r:r=$(1);else if(n===We.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===We.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===We.ROUGHNESS){const o=this.getFloat(n);t.roughnessMap&&t.roughnessMap.isTexture===!0?r=o.mul(this.getTexture(n).g):r=o}else if(n===We.METALNESS){const o=this.getFloat(n);t.metalnessMap&&t.metalnessMap.isTexture===!0?r=o.mul(this.getTexture(n).b):r=o}else if(n===We.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===We.NORMAL)t.normalMap?(r=mw(this.getTexture("normal"),this.getCache("normalScale","vec2")),r.normalMapType=t.normalMapType):t.bumpMap?r=gw(this.getTexture("bump").r,this.getFloat("bumpScale")):r=Ti;else if(n===We.CLEARCOAT){const o=this.getFloat(n);t.clearcoatMap&&t.clearcoatMap.isTexture===!0?r=o.mul(this.getTexture(n).r):r=o}else if(n===We.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===We.CLEARCOAT_NORMAL)t.clearcoatNormalMap?r=mw(this.getTexture(n),this.getCache(n+"Scale","vec2")):r=Ti;else if(n===We.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===We.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(.07,1)}else if(n===We.ANISOTROPY)if(t.anisotropyMap&&t.anisotropyMap.isTexture===!0){const o=this.getTexture(n);r=Fx(Om.x,Om.y,Om.y.negate(),Om.x).mul(o.rg.mul(2).sub(Xe(1)).normalize().mul(o.b))}else r=Om;else if(n===We.IRIDESCENCE_THICKNESS){const o=Fi("1","float",t.iridescenceThicknessRange);if(t.iridescenceThicknessMap){const a=Fi("0","float",t.iridescenceThicknessRange);r=o.sub(a).mul(this.getTexture(n).g).add(a)}else r=o}else if(n===We.TRANSMISSION){const o=this.getFloat(n);t.transmissionMap?r=o.mul(this.getTexture(n).r):r=o}else if(n===We.THICKNESS){const o=this.getFloat(n);t.thicknessMap?r=o.mul(this.getTexture(n).g):r=o}else if(n===We.IOR)r=this.getFloat(n);else if(n===We.LIGHT_MAP)r=this.getTexture(n).rgb.mul(this.getFloat("lightMapIntensity"));else if(n===We.AO)r=this.getTexture(n).r.sub(1).mul(this.getFloat("aoMapIntensity")).add(1);else if(n===We.LINE_DASH_OFFSET)r=t.dashOffset?this.getFloat(n):$(0);else{const o=this.getNodeType(e);r=this.getCache(n,o)}return r}}We.ALPHA_TEST="alphaTest",We.COLOR="color",We.OPACITY="opacity",We.SHININESS="shininess",We.SPECULAR="specular",We.SPECULAR_STRENGTH="specularStrength",We.SPECULAR_INTENSITY="specularIntensity",We.SPECULAR_COLOR="specularColor",We.REFLECTIVITY="reflectivity",We.ROUGHNESS="roughness",We.METALNESS="metalness",We.NORMAL="normal",We.CLEARCOAT="clearcoat",We.CLEARCOAT_ROUGHNESS="clearcoatRoughness",We.CLEARCOAT_NORMAL="clearcoatNormal",We.EMISSIVE="emissive",We.ROTATION="rotation",We.SHEEN="sheen",We.SHEEN_ROUGHNESS="sheenRoughness",We.ANISOTROPY="anisotropy",We.IRIDESCENCE="iridescence",We.IRIDESCENCE_IOR="iridescenceIOR",We.IRIDESCENCE_THICKNESS="iridescenceThickness",We.IOR="ior",We.TRANSMISSION="transmission",We.THICKNESS="thickness",We.ATTENUATION_DISTANCE="attenuationDistance",We.ATTENUATION_COLOR="attenuationColor",We.LINE_SCALE="scale",We.LINE_DASH_SIZE="dashSize",We.LINE_GAP_SIZE="gapSize",We.LINE_WIDTH="linewidth",We.LINE_DASH_OFFSET="dashOffset",We.POINT_SIZE="size",We.DISPERSION="dispersion",We.LIGHT_MAP="light",We.AO="ao";const JR=xt(We,We.ALPHA_TEST),ov=xt(We,We.COLOR),QR=xt(We,We.SHININESS),eN=xt(We,We.EMISSIVE),av=xt(We,We.OPACITY),tN=xt(We,We.SPECULAR),yw=xt(We,We.SPECULAR_INTENSITY),nN=xt(We,We.SPECULAR_COLOR),y_=xt(We,We.SPECULAR_STRENGTH),lv=xt(We,We.REFLECTIVITY),iN=xt(We,We.ROUGHNESS),sN=xt(We,We.METALNESS),rN=xt(We,We.NORMAL),oN=xt(We,We.CLEARCOAT),aN=xt(We,We.CLEARCOAT_ROUGHNESS),lN=xt(We,We.CLEARCOAT_NORMAL),cN=xt(We,We.ROTATION),uN=xt(We,We.SHEEN),hN=xt(We,We.SHEEN_ROUGHNESS),dN=xt(We,We.ANISOTROPY),fN=xt(We,We.IRIDESCENCE),pN=xt(We,We.IRIDESCENCE_IOR),mN=xt(We,We.IRIDESCENCE_THICKNESS),gN=xt(We,We.TRANSMISSION),yN=xt(We,We.THICKNESS),_N=xt(We,We.IOR),xN=xt(We,We.ATTENUATION_DISTANCE),vN=xt(We,We.ATTENUATION_COLOR),_w=xt(We,We.LINE_SCALE),xw=xt(We,We.LINE_DASH_SIZE),vw=xt(We,We.LINE_GAP_SIZE),cv=xt(We,We.LINE_WIDTH),bw=xt(We,We.LINE_DASH_OFFSET),bN=xt(We,We.POINT_SIZE),SN=xt(We,We.DISPERSION),Sw=xt(We,We.LIGHT_MAP),TN=xt(We,We.AO),Om=Jt(new Ie).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))}),Tw=de(i=>i.context.setupModelViewProjection(),"vec4").once()().toVarying("v_modelViewProjection");class is extends kt{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===is.VERTEX)r=e.getVertexIndex();else if(n===is.INSTANCE)r=e.getInstanceIndex();else if(n===is.DRAW)r=e.getDrawIndex();else if(n===is.INVOCATION_LOCAL)r=e.getInvocationLocalIndex();else if(n===is.INVOCATION_SUBGROUP)r=e.getInvocationSubgroupIndex();else if(n===is.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=gc(this).build(e,t),o}}is.VERTEX="vertex",is.INSTANCE="instance",is.SUBGROUP="subgroup",is.INVOCATION_LOCAL="invocationLocal",is.INVOCATION_SUBGROUP="invocationSubgroup",is.DRAW="draw";const wN=xt(is,is.VERTEX),dd=xt(is,is.INSTANCE),$V=xt(is,is.SUBGROUP),qV=xt(is,is.INVOCATION_SUBGROUP),XV=xt(is,is.INVOCATION_LOCAL),MN=xt(is,is.DRAW);class AN extends kt{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=In.FRAME,this.buffer=null,this.bufferColor=null}setup(e){const{instanceMatrix:t,instanceColor:n}=this,{count:r}=t;let{instanceMatrixNode:o,instanceColorNode:a}=this;if(o===null){if(r<=1e3)o=h_(t.array,"mat4",Math.max(r,1)).element(dd);else{const u=new CS(t.array,16,1);this.buffer=u;const d=t.usage===Rd?KT:Kx,p=[d(u,"vec4",16,0),d(u,"vec4",16,4),d(u,"vec4",16,8),d(u,"vec4",16,12)];o=Vf(...p)}this.instanceMatrixNode=o}if(n&&a===null){const u=new ea(n.array,3),d=n.usage===Rd?KT:Kx;this.bufferColor=u,a=ue(d(u,"vec3",3,0)),this.instanceColorNode=a}const c=o.mul(Ps).xyz;if(Ps.assign(c),e.hasGeometryAttribute("normal")){const u=PR(Fo,o);Fo.assign(u)}this.instanceColorNode!==null&&aa("vec3","vInstanceColor").assign(this.instanceColorNode)}update(){this.instanceMatrix.usage!==Rd&&this.buffer!==null&&this.instanceMatrix.version!==this.buffer.version&&(this.buffer.version=this.instanceMatrix.version),this.instanceColor&&this.instanceColor.usage!==Rd&&this.bufferColor!==null&&this.instanceColor.version!==this.bufferColor.version&&(this.bufferColor.version=this.instanceColor.version)}}const jV=xn(AN).setParameterLength(2,3);class YV extends AN{static get type(){return"InstancedMeshNode"}constructor(e){const{count:t,instanceMatrix:n,instanceColor:r}=e;super(t,n,r),this.instancedMesh=e}}const EN=xn(YV).setParameterLength(1);class ZV extends kt{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=dd:this.batchingIdNode=MN);const n=de(([v])=>{const M=ie(cd(Ns(this.batchMesh._indirectTexture),0).x),T=ie(v).mod(M),S=ie(v).div(M);return Ns(this.batchMesh._indirectTexture,or(T,S)).x}).setLayout({name:"getIndirectIndex",type:"uint",inputs:[{name:"id",type:"int"}]})(ie(this.batchingIdNode)),r=this.batchMesh._matricesTexture,o=ie(cd(Ns(r),0).x),a=$(n).mul(4).toInt().toVar(),c=a.mod(o),u=a.div(o),d=Vf(Ns(r,or(c,u)),Ns(r,or(c.add(1),u)),Ns(r,or(c.add(2),u)),Ns(r,or(c.add(3),u))),p=this.batchMesh._colorsTexture;if(p!==null){const M=de(([T])=>{const S=ie(cd(Ns(p),0).x),N=T,R=N.mod(S),P=N.div(S);return Ns(p,or(R,P)).rgb}).setLayout({name:"getBatchingColor",type:"vec3",inputs:[{name:"id",type:"int"}]})(n);aa("vec3","vBatchColor").assign(M)}const m=qr(d);Ps.assign(d.mul(Ps));const y=Fo.div(ue(m[0].dot(m[0]),m[1].dot(m[1]),m[2].dot(m[2]))),x=m.mul(y).xyz;Fo.assign(x),e.hasGeometryAttribute("tangent")&&g_.mulAssign(m)}}const CN=xn(ZV).setParameterLength(1);class KV extends kf{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=xn(KV).setParameterLength(2);class QV extends nw{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=dT(e.itemSize),n=e.count):r=t,super(e,r,n),this.isStorageBufferNode=!0,this.structTypeNode=o,this.access=Ir.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(Ir.READ_ONLY)}setAtomic(e){return this.isAtomic=e,this}toAtomic(){return this.setAtomic(!0)}getAttributeData(){return this._attribute===null&&(this._attribute=c_(this.value),this._varying=gc(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 jf=(i,e=null,t=0)=>Ge(new QV(i,e,t)),eG=(i,e,t)=>(console.warn('THREE.TSL: "storageObject()" is deprecated. Use "storage().setPBO( true )" instead.'),jf(i,e,t).setPBO(!0)),RN=new WeakMap;class NN extends kt{static get type(){return"SkinningNode"}constructor(e){super("void"),this.skinnedMesh=e,this.updateType=In.OBJECT,this.skinIndexNode=ho("skinIndex","uvec4"),this.skinWeightNode=ho("skinWeight","vec4"),this.bindMatrixNode=Fi("bindMatrix","mat4"),this.bindMatrixInverseNode=Fi("bindMatrixInverse","mat4"),this.boneMatricesNode=dw("skeleton.boneMatrices","mat4",e.skeleton.bones.length),this.positionNode=Ps,this.toPositionNode=Ps,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=Gs(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=Fo){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=Gs(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=dw("skeleton.previousBoneMatrices","mat4",t.skeleton.bones.length)),this.getSkinnedPosition(this.previousBoneMatricesNode,Qx)}needsPreviousBoneMatrices(e){const t=e.renderer.getMRT();return t&&t.has("velocity")||pT(e.object).useVelocity===!0}setup(e){this.needsPreviousBoneMatrices(e)&&Qx.assign(this.getPreviousSkinnedPosition(e));const t=this.getSkinnedPosition();if(this.toPositionNode&&this.toPositionNode.assign(t),e.hasGeometryAttribute("normal")){const n=this.getSkinnedNormal();Fo.assign(n),e.hasGeometryAttribute("tangent")&&g_.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;RN.get(t)!==e.frameId&&(RN.set(t,e.frameId),this.previousBoneMatricesNode!==null&&t.previousBoneMatrices.set(t.boneMatrices),t.update())}}const PN=i=>Ge(new NN(i)),tG=(i,e=null)=>{const t=new NN(i);return t.positionNode=jf(new ea(i.geometry.getAttribute("position").array,3),"vec3").setPBO(!0).toReadOnly().element(dd).toVar(),t.skinIndexNode=jf(new ea(new Uint32Array(i.geometry.getAttribute("skinIndex").array),4),"uvec4").setPBO(!0).toReadOnly().element(dd).toVar(),t.skinWeightNode=jf(new ea(i.geometry.getAttribute("skinWeight").array,4),"vec4").setPBO(!0).toReadOnly().element(dd).toVar(),t.bindMatrixNode=Jt(i.bindMatrix,"mat4"),t.bindMatrixInverseNode=Jt(i.bindMatrixInverse,"mat4"),t.boneMatricesNode=h_(i.skeleton.boneMatrices,"mat4",i.skeleton.bones.length),t.toPositionNode=e,Ge(t)};class nG extends kt{static get type(){return"LoopNode"}constructor(e=[]){super(),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 a=0,c=this.params.length-1;a<c;a++){const u=this.params[a],d=u.isNode!==!0&&u.name||this.getVarName(a),p=u.isNode!==!0&&u.type||"int";n[d]=Nu(d,p)}const r=e.addStack();t.returnsNode=this.params[this.params.length-1](n,e),t.stackNode=r;const o=this.params[0];return o.isNode!==!0&&typeof o.update=="function"&&(t.updateNode=de(this.params[0].update)(n)),e.removeStack(),t}getNodeType(e){const{returnsNode:t}=this.getProperties(e);return t?t.getNodeType(e):"void"}setup(e){this.getProperties(e)}generate(e){const t=this.getProperties(e),n=this.params,r=t.stackNode;for(let c=0,u=n.length-1;c<u;c++){const d=n[c];let p=!1,m=null,y=null,x=null,v=null,M=null,T=null;d.isNode?d.getNodeType(e)==="bool"?(p=!0,v="bool",y=d.build(e,v)):(v="int",x=this.getVarName(c),m="0",y=d.build(e,v),M="<"):(v=d.type||"int",x=d.name||this.getVarName(c),m=d.start,y=d.end,M=d.condition,T=d.update,typeof m=="number"?m=e.generateConst(v,m):m&&m.isNode&&(m=m.build(e,v)),typeof y=="number"?y=e.generateConst(v,y):y&&y.isNode&&(y=y.build(e,v)),m!==void 0&&y===void 0?(m=m+" - 1",y="0",M=">="):y!==void 0&&m===void 0&&(m="0",M="<"),M===void 0&&(Number(m)>Number(y)?M=">=":M="<"));let S;if(p)S=`while ( ${y} )`;else{const N={start:m,end:y},R=N.start,P=N.end;let B;const F=()=>M.includes("<")?"+=":"-=";if(T!=null)switch(typeof T){case"function":B=e.flowStagesNode(t.updateNode,"void").code.replace(/\t|;/g,"");break;case"number":B=x+" "+F()+" "+e.generateConst(v,T);break;case"string":B=x+" "+T;break;default:T.isNode?B=x+" "+F()+" "+T.build(e):(console.error("THREE.TSL: 'Loop( { update: ... } )' is not a function, string or number."),B="break /* invalid update */")}else v==="int"||v==="uint"?T=M.includes("<")?"++":"--":T=F()+" 1.",B=x+" "+T;const k=e.getVar(v,x)+" = "+R,V=x+" "+M+" "+P;S=`for ( ${k}; ${V}; ${B} )`}e.addFlowCode((c===0?`
|
|
`:"")+e.tab+S+` {
|
|
|
|
`).addFlowTab()}const o=r.build(e,"void"),a=t.returnsNode?t.returnsNode.build(e):"";e.removeFlowTab().addFlowCode(`
|
|
`+e.tab+o);for(let c=0,u=this.params.length-1;c<u;c++)e.addFlowCode((c===0?"":e.tab)+`}
|
|
|
|
`).removeFlowTab();return e.addFlowTab(),a}}const wi=(...i)=>Ge(new nG(zf(i,"int"))).toStack(),iG=()=>Nu("continue").toStack(),IN=()=>Nu("break").toStack(),ww=new WeakMap,da=new an,LN=de(({bufferMap:i,influence:e,stride:t,width:n,depth:r,offset:o})=>{const a=ie(wN).mul(t).add(o),c=a.div(n),u=a.sub(c.mul(n));return Ns(i,or(u,c)).depth(r).xyz.mul(e)});function sG(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=ww.get(i);if(a===void 0||a.count!==o){let S=function(){M.dispose(),ww.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),M=new Tp(v,m,y,o);M.type=mi,M.needsUpdate=!0;const T=p*4;for(let N=0;N<o;N++){const R=c[N],P=u[N],B=d[N],F=m*y*4*N;for(let k=0;k<R.count;k++){const V=k*T;e===!0&&(da.fromBufferAttribute(R,k),v[F+V+0]=da.x,v[F+V+1]=da.y,v[F+V+2]=da.z,v[F+V+3]=0),t===!0&&(da.fromBufferAttribute(P,k),v[F+V+4]=da.x,v[F+V+5]=da.y,v[F+V+6]=da.z,v[F+V+7]=0),n===!0&&(da.fromBufferAttribute(B,k),v[F+V+8]=da.x,v[F+V+9]=da.y,v[F+V+10]=da.z,v[F+V+11]=B.itemSize===4?da.w:1)}}a={count:o,texture:M,stride:p,size:new Ie(m,y)},ww.set(i,a),i.addEventListener("dispose",S)}return a}class rG extends kt{static get type(){return"MorphNode"}constructor(e){super("void"),this.mesh=e,this.morphBaseInfluence=Jt(1),this.updateType=In.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}=sG(t);n===!0&&Ps.mulAssign(this.morphBaseInfluence),r===!0&&Fo.mulAssign(this.morphBaseInfluence);const p=ie(d.width);wi(a,({i:m})=>{const y=$(0).toVar();this.mesh.count>1&&this.mesh.morphTexture!==null&&this.mesh.morphTexture!==void 0?y.assign(Ns(this.mesh.morphTexture,or(ie(m).add(1),ie(dd))).r):y.assign(Fi("morphTargetInfluences","float").element(m).toVar()),Yt(y.notEqual(0),()=>{n===!0&&Ps.addAssign(LN({bufferMap:c,influence:y,stride:u,width:p,depth:m,offset:ie(0)})),r===!0&&Fo.addAssign(LN({bufferMap:c,influence:y,stride:u,width:p,depth:m,offset:ie(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 DN=xn(rG).setParameterLength(1);class Um extends kt{static get type(){return"LightingNode"}constructor(){super("vec3"),this.isLightingNode=!0}}class oG extends Um{static get type(){return"AONode"}constructor(e=null){super(),this.aoNode=e}setup(e){e.context.ambientOcclusion.mulAssign(this.aoNode)}}class aG extends JC{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=ue().toVar("directDiffuse"),r=ue().toVar("directSpecular"),o=ue().toVar("indirectDiffuse"),a=ue().toVar("indirectSpecular"),c={directDiffuse:n,directSpecular:r,indirectDiffuse:o,indirectSpecular:a};return{radiance:ue().toVar("radiance"),irradiance:ue().toVar("irradiance"),iblIrradiance:ue().toVar("iblIrradiance"),ambientOcclusion:$(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 FN=xn(aG);class lG extends Um{static get type(){return"IrradianceNode"}constructor(e){super(),this.node=e}setup(e){e.context.irradiance.addAssign(this.node)}}const km=new Ie;class uv extends yc{static get type(){return"ViewportTextureNode"}constructor(e=Iu,t=null,n=null){let r=null;n===null?(r=new sf,r.minFilter=Ds,n=r):r=n,super(n,e,t),this.generateMipmaps=!1,this.defaultFramebuffer=r,this.isOutputTextureNode=!0,this.updateBeforeType=In.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(km):km.set(n.width,n.height);const r=this.getTextureForReference(n);(r.image.width!==km.width||r.image.height!==km.height)&&(r.image.width=km.width,r.image.height=km.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 cG=xn(uv).setParameterLength(0,3),Mw=xn(uv,null,null,{generateMipmaps:!0}).setParameterLength(0,3);let hv=null;class uG extends uv{static get type(){return"ViewportDepthTextureNode"}constructor(e=Iu,t=null){hv===null&&(hv=new Ao),super(e,t,hv)}getTextureForReference(){return hv}}const Aw=xn(uG).setParameterLength(0,2);class Bo extends kt{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===Bo.DEPTH_BASE?e.getFragDepth():super.generate(e)}setup({camera:e}){const{scope:t}=this,n=this.valueNode;let r=null;if(t===Bo.DEPTH_BASE)n!==null&&(r=BN().assign(n));else if(t===Bo.DEPTH)e.isPerspectiveCamera?r=Ew(Is.z,Lu,Du):r=zm(Is.z,Lu,Du);else if(t===Bo.LINEAR_DEPTH)if(n!==null)if(e.isPerspectiveCamera){const o=Cw(n,Lu,Du);r=zm(o,Lu,Du)}else r=n;else r=zm(Is.z,Lu,Du);return r}}Bo.DEPTH_BASE="depthBase",Bo.DEPTH="depth",Bo.LINEAR_DEPTH="linearDepth";const zm=(i,e,t)=>i.add(e).div(e.sub(t)),hG=(i,e,t)=>e.sub(t).mul(i).sub(e),Ew=(i,e,t)=>e.add(i).mul(t).div(t.sub(e).mul(i)),Cw=(i,e,t)=>e.mul(t).div(t.sub(e).mul(i).sub(t)),Rw=(i,e,t)=>{e=e.max(1e-6).toVar();const n=dc(i.negate().div(e)),r=dc(t.div(e));return n.div(r)},dG=(i,e,t)=>{const n=i.mul(Wx(t.div(e)));return $(Math.E).pow(n).mul(e).negate()},BN=xn(Bo,Bo.DEPTH_BASE),Nw=xt(Bo,Bo.DEPTH),Vm=xn(Bo,Bo.LINEAR_DEPTH).setParameterLength(0,1),fG=Vm(Aw());Nw.assign=i=>BN(i);class Qa extends kt{static get type(){return"ClippingNode"}constructor(e=Qa.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===Qa.ALPHA_TO_COVERAGE?this.setupAlphaToCoverage(n,r):this.scope===Qa.HARDWARE?this.setupHardwareClipping(r,e):this.setupDefault(n,r)}setupAlphaToCoverage(e,t){return de(()=>{const n=$().toVar("distanceToPlane"),r=$().toVar("distanceToGradient"),o=$(1).toVar("clipOpacity"),a=t.length;if(this.hardwareClipping===!1&&a>0){const u=Xr(t).setGroup(Zt);wi(a,({i:d})=>{const p=u.element(d);n.assign(Is.dot(p.xyz).negate().add(p.w)),r.assign(n.fwidth().div(2)),o.mulAssign(Ya(r.negate(),r,n))})}const c=e.length;if(c>0){const u=Xr(e).setGroup(Zt),d=$(1).toVar("intersectionClipOpacity");wi(c,({i:p})=>{const m=u.element(p);n.assign(Is.dot(m.xyz).negate().add(m.w)),r.assign(n.fwidth().div(2)),d.mulAssign(Ya(r.negate(),r,n).oneMinus())}),o.mulAssign(d.oneMinus())}fi.a.mulAssign(o),fi.a.equal(0).discard()})()}setupDefault(e,t){return de(()=>{const n=t.length;if(this.hardwareClipping===!1&&n>0){const o=Xr(t).setGroup(Zt);wi(n,({i:a})=>{const c=o.element(a);Is.dot(c.xyz).greaterThan(c.w).discard()})}const r=e.length;if(r>0){const o=Xr(e).setGroup(Zt),a=qa(!0).toVar("clipped");wi(r,({i:c})=>{const u=o.element(c);a.assign(Is.dot(u.xyz).greaterThan(u.w).and(a))}),a.discard()}})()}setupHardwareClipping(e,t){const n=e.length;return t.enableHardwareClipping(n),de(()=>{const r=Xr(e).setGroup(Zt),o=Pu(t.getClipDistance());wi(n,({i:a})=>{const c=r.element(a),u=Is.dot(c.xyz).sub(c.w).negate();o.element(a).assign(u)})})()}}Qa.ALPHA_TO_COVERAGE="alphaToCoverage",Qa.DEFAULT="default",Qa.HARDWARE="hardware";const pG=()=>Ge(new Qa),mG=()=>Ge(new Qa(Qa.ALPHA_TO_COVERAGE)),gG=()=>Ge(new Qa(Qa.HARDWARE)),yG=.05,ON=de(([i])=>Cu(En(1e4,ca(En(17,i.x).add(En(.1,i.y)))).mul(Gs(.1,zi(ca(En(13,i.y).add(i.x))))))),UN=de(([i])=>ON(Xe(ON(i.xy),i.z))),_G=de(([i])=>{const e=ys(mc(kT(i.xyz)),mc(zT(i.xyz))),t=$(1).div($(yG).mul(e)).toVar("pixScale"),n=Xe(Pm(pc(dc(t))),Pm($x(dc(t)))),r=Xe(UN(pc(n.x.mul(i.xyz))),UN(pc(n.y.mul(i.xyz)))),o=Cu(dc(t)),a=Gs(En(o.oneMinus(),r.x),En(o,r.y)),c=Do(o,o.oneMinus()),u=ue(a.mul(a).div(En(2,c).mul(Qn(1,c))),a.sub(En(.5,c)).div(Qn(1,c)),Qn(1,Qn(1,a).mul(Qn(1,a)).div(En(2,c).mul(Qn(1,c))))),d=a.lessThan(c.oneMinus()).select(a.lessThan(c).select(u.x,u.y),u.z);return ja(d,1e-6,1)}).setLayout({name:"getAlphaHashThreshold",type:"float",inputs:[{name:"position",type:"vec3"}]});class xG extends vR{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 an(1,1,1,1)),r}serialize(e){super.serialize(e),e.index=this.index}deserialize(e){super.deserialize(e),this.index=e.index}}const kN=(i=0)=>Ge(new xG(i)),zN=de(([i,e])=>Do(1,i.oneMinus().div(e)).oneMinus()).setLayout({name:"blendBurn",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),VN=de(([i,e])=>Do(i.div(e.oneMinus()),1)).setLayout({name:"blendDodge",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),GN=de(([i,e])=>i.oneMinus().mul(e.oneMinus()).oneMinus()).setLayout({name:"blendScreen",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),HN=de(([i,e])=>oi(i.mul(2).mul(e),i.oneMinus().mul(2).mul(e.oneMinus()).oneMinus(),Xx(.5,i))).setLayout({name:"blendOverlay",type:"vec3",inputs:[{name:"base",type:"vec3"},{name:"blend",type:"vec3"}]}),vG=de(([i,e])=>{const t=e.a.add(i.a.mul(e.a.oneMinus()));return Lt(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"}]}),WN=de(([i])=>Lt(i.rgb.mul(i.a),i.a),{color:"vec4",return:"vec4"}),bG=de(([i])=>(Yt(i.a.equal(0),()=>Lt(0)),Lt(i.rgb.div(i.a),i.a)),{color:"vec4",return:"vec4"}),SG=(...i)=>(console.warn('THREE.TSL: "burn" has been renamed. Use "blendBurn" instead.'),zN(i)),TG=(...i)=>(console.warn('THREE.TSL: "dodge" has been renamed. Use "blendDodge" instead.'),VN(i)),wG=(...i)=>(console.warn('THREE.TSL: "screen" has been renamed. Use "blendScreen" instead.'),GN(i)),MG=(...i)=>(console.warn('THREE.TSL: "overlay" has been renamed. Use "blendOverlay" instead.'),HN(i));class _s extends $i{static get type(){return"NodeMaterial"}get type(){return this.constructor.type}set type(e){}constructor(){super(),this.isNodeMaterial=!0,this.fog=!0,this.lights=!1,this.hardwareClipping=!1,this.lightsNode=null,this.envNode=null,this.aoNode=null,this.colorNode=null,this.normalNode=null,this.opacityNode=null,this.backdropNode=null,this.backdropAlphaNode=null,this.alphaTestNode=null,this.maskNode=null,this.positionNode=null,this.geometryNode=null,this.depthNode=null,this.receivedShadowPositionNode=null,this.castShadowPositionNode=null,this.receivedShadowNode=null,this.castShadowNode=null,this.outputNode=null,this.mrtNode=null,this.fragmentNode=null,this.vertexNode=null,Object.defineProperty(this,"shadowPositionNode",{get:()=>this.receivedShadowPositionNode,set:e=>{console.warn('THREE.NodeMaterial: ".shadowPositionNode" was renamed to ".receivedShadowPositionNode".'),this.receivedShadowPositionNode=e}})}customProgramCacheKey(){return this.type+hT(this)}build(e){this.setup(e)}setupObserver(e){return new ez(e)}setup(e){e.context.setupNormal=()=>Im(this.setupNormal(e),"NORMAL","vec3"),e.context.setupPositionView=()=>this.setupPositionView(e),e.context.setupModelViewProjection=()=>this.setupModelViewProjection(e);const t=e.renderer,n=t.getRenderTarget();e.addStack();const r=Im(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.add(c);const d=Lt(u,fi.a).max(0);a=this.setupOutput(e,d),Nm.assign(a);const p=this.outputNode!==null;if(p&&(a=this.outputNode),n!==null){const m=t.getMRT(),y=this.mrtNode;m!==null?(p&&Nm.assign(a),a=m,y!==null&&(a=m.merge(y))):y!==null&&(a=y)}}else{let u=this.fragmentNode;u.isOutputStructNode!==!0&&(u=Lt(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.samples;this.alphaToCoverage&&o>1?r=mG():e.stack.add(pG())}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.add(gG()),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=Rw(Is.z,Lu,Du):r=zm(Is.z,Lu,Du))}r!==null&&Nw.assign(r).toStack()}setupPositionView(){return Fu.mul(Ps).xyz}setupModelViewProjection(){return Za.mul(Is)}setupVertex(e){return e.addStack(),this.setupPosition(e),e.context.vertex=e.removeStack(),Tw}setupPosition(e){const{object:t,geometry:n}=e;if((n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color)&&DN(t).toStack(),t.isSkinnedMesh===!0&&PN(t).toStack(),this.displacementMap){const r=Bu("displacementMap","texture"),o=Bu("displacementScale","float"),a=Bu("displacementBias","float");Ps.addAssign(Fo.normalize().mul(r.x.mul(o).add(a)))}return t.isBatchedMesh&&CN(t).toStack(),t.isInstancedMesh&&t.instanceMatrix&&t.instanceMatrix.isInstancedBufferAttribute===!0&&EN(t).toStack(),this.positionNode!==null&&Ps.assign(Im(this.positionNode,"POSITION","vec3")),Ps}setupDiffuseColor({object:e,geometry:t}){this.maskNode!==null&&qa(this.maskNode).not().discard();let n=this.colorNode?Lt(this.colorNode):ov;this.vertexColors===!0&&t.hasAttribute("color")&&(n=n.mul(kN())),e.instanceColor&&(n=aa("vec3","vInstanceColor").mul(n)),e.isBatchedMesh&&e._colorsTexture&&(n=aa("vec3","vBatchColor").mul(n)),fi.assign(n);const r=this.opacityNode?$(this.opacityNode):av;fi.a.assign(fi.a.mul(r));let o=null;(this.alphaTestNode!==null||this.alphaTest>0)&&(o=this.alphaTestNode!==null?$(this.alphaTestNode):JR,fi.a.lessThanEqual(o).discard()),this.alphaHash===!0&&fi.a.lessThan(_G(Ps)).discard(),this.transparent===!1&&this.blending===qe&&this.alphaToCoverage===!1?fi.a.assign(1):o===null&&fi.a.lessThanEqual(0).discard()}setupVariants(){}setupOutgoingLight(){return this.lights===!0?ue(0):fi.rgb}setupNormal(){return this.normalNode?ue(this.normalNode):rN}setupEnvironment(){let e=null;return this.envNode?e=this.envNode:this.envMap&&(e=this.envMap.isCubeTexture?Bu("envMap","cubeTexture"):Bu("envMap","texture")),e}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new lG(Sw)),t}setupLights(e){const t=[],n=this.setupEnvironment(e);n&&n.isLightingNode&&t.push(n);const r=this.setupLightMap(e);if(r&&r.isLightingNode&&t.push(r),this.aoNode!==null||e.material.aoMap){const a=this.aoNode!==null?this.aoNode:TN;t.push(new oG(a))}let o=this.lightsNode||e.lightsNode;return t.length>0&&(o=e.renderer.lighting.createNode([...o.getLights(),...t])),o}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=FN(c,d,n,r)}else n!==null&&(u=ue(r!==null?oi(u,n,r):n));return(o&&o.isNode===!0||t.emissive&&t.emissive.isColor===!0)&&(AT.assign(ue(o||eN)),u=u.add(AT)),u}setupFog(e,t){const n=e.fogNode;return n&&(Nm.assign(t),t=Lt(n.toVar())),t}setupPremultipliedAlpha(e,t){return WN(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=$i.prototype.toJSON.call(this,e),r=qy(this);n.inputNodes={};for(const{property:a,childNode:c}of r)n.inputNodes[a]=c.toJSON(e).uuid;function o(a){const c=[];for(const u in a){const d=a[u];delete d.metadata,c.push(d)}return c}if(t){const a=o(e.textures),c=o(e.images),u=o(e.nodes);a.length>0&&(n.textures=a),c.length>0&&(n.images=c),u.length>0&&(n.nodes=u)}return n}copy(e){return this.lightsNode=e.lightsNode,this.envNode=e.envNode,this.colorNode=e.colorNode,this.normalNode=e.normalNode,this.opacityNode=e.opacityNode,this.backdropNode=e.backdropNode,this.backdropAlphaNode=e.backdropAlphaNode,this.alphaTestNode=e.alphaTestNode,this.maskNode=e.maskNode,this.positionNode=e.positionNode,this.geometryNode=e.geometryNode,this.depthNode=e.depthNode,this.receivedShadowPositionNode=e.receivedShadowPositionNode,this.castShadowPositionNode=e.castShadowPositionNode,this.receivedShadowNode=e.receivedShadowNode,this.castShadowNode=e.castShadowNode,this.outputNode=e.outputNode,this.mrtNode=e.mrtNode,this.fragmentNode=e.fragmentNode,this.vertexNode=e.vertexNode,super.copy(e)}}const AG=new Js;class EG extends _s{static get type(){return"LineBasicNodeMaterial"}constructor(e){super(),this.isLineBasicNodeMaterial=!0,this.setDefaultValues(AG),this.setValues(e)}}const CG=new cy;class RG extends _s{static get type(){return"LineDashedNodeMaterial"}constructor(e){super(),this.isLineDashedNodeMaterial=!0,this.setDefaultValues(CG),this.dashOffset=0,this.offsetNode=null,this.dashScaleNode=null,this.dashSizeNode=null,this.gapSizeNode=null,this.setValues(e)}setupVariants(){const e=this.offsetNode?$(this.offsetNode):bw,t=this.dashScaleNode?$(this.dashScaleNode):_w,n=this.dashSizeNode?$(this.dashSizeNode):xw,r=this.gapSizeNode?$(this.gapSizeNode):vw;Wf.assign(n),i_.assign(r);const o=gc(ho("lineDistance").mul(t));(e?o.add(e):o).mod(Wf.add(i_)).greaterThan(Wf).discard()}}let dv=null;class NG extends uv{static get type(){return"ViewportSharedTextureNode"}constructor(e=Iu,t=null){dv===null&&(dv=new sf),super(e,t,dv)}getTextureForReference(){return dv}updateReference(){return this}}const $N=xn(NG).setParameterLength(0,2),PG=new cy;class uZ extends null{static get type(){return"Line2NodeMaterial"}constructor(e={}){super(),this.isLine2NodeMaterial=!0,this.setDefaultValues(PG),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=de(({start:d,end:p})=>{const m=Za.element(2).element(2),v=Za.element(3).element(2).mul(-.5).div(m).sub(d.z).div(p.z.sub(d.z));return Lt(oi(d.xyz,p.xyz,v),p.w)}).setLayout({name:"trimSegment",type:"vec4",inputs:[{name:"start",type:"vec4"},{name:"end",type:"vec4"}]});this.vertexNode=de(()=>{const d=ho("instanceStart"),p=ho("instanceEnd"),m=Lt(Fu.mul(Lt(d,1))).toVar("start"),y=Lt(Fu.mul(Lt(p,1))).toVar("end");if(o){const B=this.dashScaleNode?$(this.dashScaleNode):_w,F=this.offsetNode?$(this.offsetNode):bw,k=ho("instanceDistanceStart"),V=ho("instanceDistanceEnd");let U=Lr.y.lessThan(.5).select(B.mul(k),B.mul(V));U=U.add(F),aa("float","lineDistance").assign(U)}a&&(aa("vec3","worldStart").assign(m.xyz),aa("vec3","worldEnd").assign(y.xyz));const x=Lm.z.div(Lm.w),v=Za.element(2).element(3).equal(-1);Yt(v,()=>{Yt(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 M=Za.mul(m),T=Za.mul(y),S=M.xyz.div(M.w),N=T.xyz.div(T.w),R=N.xy.sub(S.xy).toVar();R.x.assign(R.x.mul(x)),R.assign(R.normalize());const P=Lt().toVar();if(a){const B=y.xyz.sub(m.xyz).normalize(),F=oi(m.xyz,y.xyz,.5).normalize(),k=B.cross(F).normalize(),V=B.cross(k),U=aa("vec4","worldPos");U.assign(Lr.y.lessThan(.5).select(m,y));const z=cv.mul(.5);U.addAssign(Lt(Lr.x.lessThan(0).select(k.mul(z),k.mul(z).negate()),0)),o||(U.addAssign(Lt(Lr.y.lessThan(.5).select(B.mul(z).negate(),B.mul(z)),0)),U.addAssign(Lt(V.mul(z),0)),Yt(Lr.y.greaterThan(1).or(Lr.y.lessThan(0)),()=>{U.subAssign(Lt(V.mul(2).mul(z),0))})),P.assign(Za.mul(U));const j=ue().toVar();j.assign(Lr.y.lessThan(.5).select(S,N)),P.z.assign(j.z.mul(P.w))}else{const B=Xe(R.y,R.x.negate()).toVar("offset");R.x.assign(R.x.div(x)),B.x.assign(B.x.div(x)),B.assign(Lr.x.lessThan(0).select(B.negate(),B)),Yt(Lr.y.lessThan(0),()=>{B.assign(B.sub(R))}).ElseIf(Lr.y.greaterThan(1),()=>{B.assign(B.add(R))}),B.assign(B.mul(cv)),B.assign(B.div(Lm.w)),P.assign(Lr.y.lessThan(.5).select(M,T)),B.assign(B.mul(P.w)),P.assign(P.add(Lt(B,0,0)))}return P})();const u=de(({p1:d,p2:p,p3:m,p4:y})=>{const x=d.sub(m),v=y.sub(m),M=p.sub(d),T=x.dot(v),S=v.dot(M),N=x.dot(M),R=v.dot(v),B=M.dot(M).mul(R).sub(S.mul(S)),k=T.mul(S).sub(N.mul(R)).div(B).clamp(),V=T.add(S.mul(k)).div(R).clamp();return Xe(k,V)});if(this.colorNode=de(()=>{const d=Ri();if(o){const y=this.dashSizeNode?$(this.dashSizeNode):xw,x=this.gapSizeNode?$(this.gapSizeNode):vw;Wf.assign(y),i_.assign(x);const v=aa("float","lineDistance");d.y.lessThan(-1).or(d.y.greaterThan(1)).discard(),v.mod(Wf.add(i_)).greaterThan(Wf).discard()}const p=$(1).toVar("alpha");if(a){const y=aa("vec3","worldStart"),x=aa("vec3","worldEnd"),v=aa("vec4","worldPos").xyz.normalize().mul(1e5),M=x.sub(y),T=u({p1:y,p2:x,p3:ue(0,0,0),p4:v}),S=y.add(M.mul(T.x)),N=v.mul(T.y),B=S.sub(N).length().div(cv);if(!o)if(n&&t.samples>1){const F=B.fwidth();p.assign(Ya(F.negate().add(.5),F.add(.5),B).oneMinus())}else B.greaterThan(.5).discard()}else if(n&&t.samples>1){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)),M=$(v.fwidth()).toVar("dlen");Yt(d.y.abs().greaterThan(1),()=>{p.assign(Ya(M.oneMinus(),M.add(1),v).oneMinus())})}else Yt(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=ho("instanceColorStart"),x=ho("instanceColorEnd");m=Lr.y.lessThan(.5).select(y,x).mul(ov)}else m=ov;return Lt(m,p)})(),this.transparent){const d=this.opacityNode?$(this.opacityNode):av;this.outputNode=Lt(this.colorNode.rgb.mul(d).add($N().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 qN=i=>Ge(i).mul(.5).add(.5),IG=i=>Ge(i).mul(2).sub(1),LG=new z0;class DG extends _s{static get type(){return"MeshNormalNodeMaterial"}constructor(e){super(),this.isMeshNormalNodeMaterial=!0,this.setDefaultValues(LG),this.setValues(e)}setupDiffuseColor(){const e=this.opacityNode?$(this.opacityNode):av;fi.assign(Zx(Lt(qN(Ti),e),Ei))}}const Pw=de(([i=ow])=>{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 Xe(e,t)});class XN extends Eg{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 Ko(5,5,5),a=Pw(ow),c=new _s;c.colorNode=Kn(t,a,0),c.side=Ee,c.blending=Ae;const u=new vi(o,c),d=new Bp;d.add(u),t.minFilter===Ds&&(t.minFilter=Yn);const p=new hl(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 __=new WeakMap;class FG extends Rs{static get type(){return"CubeMapNode"}constructor(e){super("vec3"),this.envNode=e,this._cubeTexture=null,this._cubeTextureNode=Bm(null);const t=new jl;t.isRenderTargetTexture=!0,this._defaultTexture=t,this.updateBeforeType=In.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===Nc||a===Pc){if(__.has(o)){const c=__.get(o);YN(c,o.mapping),this._cubeTexture=c}else{const c=o.image;if(BG(c)){const u=new XN(c.height);u.fromEquirectangularTexture(t,o),YN(u.texture,o.mapping),this._cubeTexture=u.texture,__.set(o,u.texture),o.addEventListener("dispose",jN)}else this._cubeTexture=this._defaultTexture}this._cubeTextureNode.value=this._cubeTexture}else this._cubeTextureNode=this.envNode}}}setup(e){return this.updateBefore(e),this._cubeTextureNode}}function BG(i){return i==null?!1:i.height>0}function jN(i){const e=i.target;e.removeEventListener("dispose",jN);const t=__.get(e);t!==void 0&&(__.delete(e),t.dispose())}function YN(i,e){e===Nc?i.mapping=Br:e===Pc&&(i.mapping=Vo)}const ZN=xn(FG).setParameterLength(1);class Iw extends Um{static get type(){return"BasicEnvironmentNode"}constructor(e=null){super(),this.envNode=e}setup(e){e.context.environment=ZN(this.envNode)}}class OG extends Um{static get type(){return"BasicLightMapNode"}constructor(e=null){super(),this.lightMapNode=e}setup(e){const t=$(1/Math.PI);e.context.irradianceLightMap=this.lightMapNode.mul(t)}}class fv{start(e){e.lightsNode.setupLights(e,e.lightsNode.getLightNodes(e)),this.indirect(e)}finish(){}direct(){}directRectArea(){}indirect(){}ambientOcclusion(){}}class KN extends fv{constructor(){super()}indirect({context:e}){const t=e.ambientOcclusion,n=e.reflectedLight,r=e.irradianceLightMap;n.indirectDiffuse.assign(Lt(0)),r?n.indirectDiffuse.addAssign(r):n.indirectDiffuse.addAssign(Lt(1,1,1,0)),n.indirectDiffuse.mulAssign(t),n.indirectDiffuse.mulAssign(fi.rgb)}finish(e){const{material:t,context:n}=e,r=n.outgoingLight,o=e.context.environment;if(o)switch(t.combine){case Rc:r.rgb.assign(oi(r.rgb,r.rgb.mul(o.rgb),y_.mul(lv)));break;case db:r.rgb.assign(oi(r.rgb,o.rgb,y_.mul(lv)));break;case fb:r.rgb.addAssign(o.rgb.mul(y_.mul(lv)));break;default:console.warn("THREE.BasicLightingModel: Unsupported .combine value:",t.combine);break}}}const UG=new js;class kG extends _s{static get type(){return"MeshBasicNodeMaterial"}constructor(e){super(),this.isMeshBasicNodeMaterial=!0,this.lights=!0,this.setDefaultValues(UG),this.setValues(e)}setupNormal(){return Dm(Fm)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Iw(t):null}setupLightMap(e){let t=null;return e.material.lightMap&&(t=new OG(Sw)),t}setupOutgoingLight(){return fi.rgb}setupLightingModel(){return new KN}}const Gm=de(({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))}),Yf=de(i=>i.diffuseColor.mul(1/Math.PI)),zG=()=>$(.25),VG=de(({dotNH:i})=>zx.mul($(.5)).add(1).mul($(1/Math.PI)).mul(i.pow(zx))),GG=de(({lightDirection:i})=>{const e=i.add(Yi).normalize(),t=Ti.dot(e).clamp(),n=Yi.dot(e).clamp(),r=Gm({f0:Lo,f90:1,dotVH:n}),o=zG(),a=VG({dotNH:t});return r.mul(o).mul(a)});class JN extends KN{constructor(e=!0){super(),this.specular=e}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const o=Ti.dot(e).clamp().mul(t);n.directDiffuse.addAssign(o.mul(Yf({diffuseColor:fi.rgb}))),this.specular===!0&&n.directSpecular.addAssign(o.mul(GG({lightDirection:e})).mul(y_))}indirect(e){const{ambientOcclusion:t,irradiance:n,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(n.mul(Yf({diffuseColor:fi}))),r.indirectDiffuse.mulAssign(t)}}const HG=new ay;class WG extends _s{static get type(){return"MeshLambertNodeMaterial"}constructor(e){super(),this.isMeshLambertNodeMaterial=!0,this.lights=!0,this.setDefaultValues(HG),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Iw(t):null}setupLightingModel(){return new JN(!1)}}const $G=new ry;class qG extends _s{static get type(){return"MeshPhongNodeMaterial"}constructor(e){super(),this.isMeshPhongNodeMaterial=!0,this.lights=!0,this.shininessNode=null,this.specularNode=null,this.setDefaultValues($G),this.setValues(e)}setupEnvironment(e){const t=super.setupEnvironment(e);return t?new Iw(t):null}setupLightingModel(){return new JN}setupVariants(){const e=(this.shininessNode?$(this.shininessNode):QR).max(1e-4);zx.assign(e);const t=this.specularNode||tN;Lo.assign(t)}copy(e){return this.shininessNode=e.shininessNode,this.specularNode=e.specularNode,super.copy(e)}}const QN=de(i=>{if(i.geometry.hasAttribute("normal")===!1)return $(0);const e=Fm.dFdx().abs().max(Fm.dFdy().abs());return e.x.max(e.y).max(e.z)}),Lw=de(i=>{const{roughness:e}=i,t=QN();let n=e.max(.0525);return n=n.add(t),n=n.min(1),n}),eP=de(({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 la(.5,r.add(o).max(wC))}).setLayout({name:"V_GGX_SmithCorrelated",type:"float",inputs:[{name:"alpha",type:"float"},{name:"dotNL",type:"float"},{name:"dotNV",type:"float"}]}),XG=de(({alphaT:i,alphaB:e,dotTV:t,dotBV:n,dotTL:r,dotBL:o,dotNV:a,dotNL:c})=>{const u=c.mul(ue(i.mul(t),e.mul(n),a).length()),d=a.mul(ue(i.mul(r),e.mul(o),c).length());return la(.5,u.add(d)).saturate()}).setLayout({name:"V_GGX_SmithCorrelated_Anisotropic",type:"float",inputs:[{name:"alphaT",type:"float",qualifier:"in"},{name:"alphaB",type:"float",qualifier:"in"},{name:"dotTV",type:"float",qualifier:"in"},{name:"dotBV",type:"float",qualifier:"in"},{name:"dotTL",type:"float",qualifier:"in"},{name:"dotBL",type:"float",qualifier:"in"},{name:"dotNV",type:"float",qualifier:"in"},{name:"dotNL",type:"float",qualifier:"in"}]}),tP=de(({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"}]}),jG=$(1/Math.PI),YG=de(({alphaT:i,alphaB:e,dotNH:t,dotTH:n,dotBH:r})=>{const o=i.mul(e),a=ue(e.mul(n),i.mul(r),o.mul(t)),c=a.dot(a),u=o.div(c);return jG.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"}]}),Dw=de(({lightDirection:i,f0:e,f90:t,roughness:n,f:r,normalView:o=Ti,USE_IRIDESCENCE:a,USE_ANISOTROPY:c})=>{const u=n.pow2(),d=i.add(Yi).normalize(),p=o.dot(i).clamp(),m=o.dot(Yi).clamp(),y=o.dot(d).clamp(),x=Yi.dot(d).clamp();let v=Gm({f0:e,f90:t,dotVH:x}),M,T;if(Zy(a)&&(v=Ux.mix(v,r)),Zy(c)){const S=t_.dot(i),N=t_.dot(Yi),R=t_.dot(d),P=Hf.dot(i),B=Hf.dot(Yi),F=Hf.dot(d);M=XG({alphaT:kx,alphaB:u,dotTV:N,dotBV:B,dotTL:S,dotBL:P,dotNV:m,dotNL:p}),T=YG({alphaT:kx,alphaB:u,dotNH:y,dotTH:R,dotBH:F})}else M=eP({alpha:u,dotNL:p,dotNV:m}),T=tP({alpha:u,dotNH:y});return v.mul(M).mul(T)}),Fw=de(({roughness:i,dotNV:e})=>{const t=Lt(-1,-.0275,-.572,.022),n=Lt(1,.0425,1.04,-.04),r=i.mul(t).add(n),o=r.x.mul(r.x).min(e.mul(-9.28).exp2()).mul(r.x).add(r.y);return Xe(-1.04,1.04).mul(o).add(r.zw)}).setLayout({name:"DFGApprox",type:"vec2",inputs:[{name:"roughness",type:"float"},{name:"dotNV",type:"vec3"}]}),nP=de(i=>{const{dotNV:e,specularColor:t,specularF90:n,roughness:r}=i,o=Fw({dotNV:e,roughness:r});return t.mul(o.x).add(n.mul(o.y))}),iP=de(({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(ue(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"}]}),ZG=de(({roughness:i,dotNH:e})=>{const t=i.pow2(),n=$(1).div(t),o=e.pow2().oneMinus().max(.0078125);return $(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"}]}),KG=de(({dotNV:i,dotNL:e})=>$(1).div($(4).mul(e.add(i).sub(e.mul(i))))).setLayout({name:"V_Neubelt",type:"float",inputs:[{name:"dotNV",type:"float"},{name:"dotNL",type:"float"}]}),JG=de(({lightDirection:i})=>{const e=i.add(Yi).normalize(),t=Ti.dot(i).clamp(),n=Ti.dot(Yi).clamp(),r=Ti.dot(e).clamp(),o=ZG({roughness:Ox,dotNH:r}),a=KG({dotNV:n,dotNL:t});return Gf.mul(o).mul(a)}),QG=de(({N:i,V:e,roughness:t})=>{const o=.0078125,a=i.dot(e).saturate(),c=Xe(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"}]}),sP=de(({f:i})=>{const e=i.length();return ys(e.mul(e).add(i.z).div(e.add(1)),0)}).setLayout({name:"LTC_ClippedSphereFormFactor",type:"float",inputs:[{name:"f",type:"vec3"}]}),fd=de(({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,ys(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"}]}),rP=de(({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=ue().toVar();return Yt(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(qr(y,x,i).transpose()).toVar(),M=v.mul(r.sub(t)).normalize().toVar(),T=v.mul(o.sub(t)).normalize().toVar(),S=v.mul(a.sub(t)).normalize().toVar(),N=v.mul(c.sub(t)).normalize().toVar(),R=ue(0).toVar();R.addAssign(fd({v1:M,v2:T})),R.addAssign(fd({v1:T,v2:S})),R.addAssign(fd({v1:S,v2:N})),R.addAssign(fd({v1:N,v2:M})),m.assign(ue(sP({f:R})))}),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"}]}),e4=de(({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=ue().toVar();return Yt(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=ue(0).toVar();x.addAssign(fd({v1:d,v2:p})),x.addAssign(fd({v1:p,v2:m})),x.addAssign(fd({v1:m,v2:y})),x.addAssign(fd({v1:y,v2:d})),u.assign(ue(sP({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"}]}),pv=1/6,oP=i=>En(pv,En(i,En(i,i.negate().add(3)).sub(3)).add(1)),Bw=i=>En(pv,En(i,En(i,En(3,i).sub(6))).add(4)),aP=i=>En(pv,En(i,En(i,En(-3,i).add(3)).add(3)).add(1)),Ow=i=>En(pv,Xa(i,3)),lP=i=>oP(i).add(Bw(i)),cP=i=>aP(i).add(Ow(i)),uP=i=>Gs(-1,Bw(i).div(oP(i).add(Bw(i)))),hP=i=>Gs(1,Ow(i).div(aP(i).add(Ow(i)))),dP=(i,e,t)=>{const n=i.uvNode,r=En(n,e.zw).add(.5),o=pc(r),a=Cu(r),c=lP(a.x),u=cP(a.x),d=uP(a.x),p=hP(a.x),m=uP(a.y),y=hP(a.y),x=Xe(o.x.add(d),o.y.add(m)).sub(.5).mul(e.xy),v=Xe(o.x.add(p),o.y.add(m)).sub(.5).mul(e.xy),M=Xe(o.x.add(d),o.y.add(y)).sub(.5).mul(e.xy),T=Xe(o.x.add(p),o.y.add(y)).sub(.5).mul(e.xy),S=lP(a.y).mul(Gs(c.mul(i.sample(x).level(t)),u.mul(i.sample(v).level(t)))),N=cP(a.y).mul(Gs(c.mul(i.sample(M).level(t)),u.mul(i.sample(T).level(t))));return S.add(N)},Uw=de(([i,e])=>{const t=Xe(i.size(ie(e))),n=Xe(i.size(ie(e.add(1)))),r=la(1,t),o=la(1,n),a=dP(i,Lt(r,t),pc(e)),c=dP(i,Lt(o,n),$x(e));return Cu(e).mix(a,c)}),t4=de(([i,e])=>{const t=e.mul(ew(i));return Uw(i,t)}),fP=de(([i,e,t,n,r])=>{const o=ue($T(e.negate(),Eu(i),la(1,n))),a=ue(mc(r[0].xyz),mc(r[1].xyz),mc(r[2].xyz));return Eu(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"}]}),n4=de(([i,e])=>i.mul(ja(e.mul(2).sub(2),0,1))).setLayout({name:"applyIorToRoughness",type:"float",inputs:[{name:"roughness",type:"float"},{name:"ior",type:"float"}]}),i4=Mw(),s4=Mw(),pP=de(([i,e,t],{material:n})=>{const o=(n.side===Ee?i4:s4).sample(i),a=dc($f.x).mul(n4(e,t));return Uw(o,a)}),mP=de(([i,e,t])=>(Yt(t.notEqual(0),()=>{const n=Wx(e).negate().div(t);return BT(n.negate().mul(i))}),ue(1))).setLayout({name:"volumeAttenuation",type:"vec3",inputs:[{name:"transmissionDistance",type:"float"},{name:"attenuationColor",type:"vec3"},{name:"attenuationDistance",type:"float"}]}),r4=de(([i,e,t,n,r,o,a,c,u,d,p,m,y,x,v])=>{let M,T;if(v){M=Lt().toVar(),T=ue().toVar();const B=p.sub(1).mul(v.mul(.025)),F=ue(p.sub(B),p,p.add(B));wi({start:0,end:3},({i:k})=>{const V=F.element(k),U=fP(i,e,m,V,c),z=a.add(U),j=d.mul(u.mul(Lt(z,1))),se=Xe(j.xy.div(j.w)).toVar();se.addAssign(1),se.divAssign(2),se.assign(Xe(se.x,se.y.oneMinus()));const pe=pP(se,t,V);M.element(k).assign(pe.element(k)),M.a.addAssign(pe.a),T.element(k).assign(n.element(k).mul(mP(mc(U),y,x).element(k)))}),M.a.divAssign(3)}else{const B=fP(i,e,m,p,c),F=a.add(B),k=d.mul(u.mul(Lt(F,1))),V=Xe(k.xy.div(k.w)).toVar();V.addAssign(1),V.divAssign(2),V.assign(Xe(V.x,V.y.oneMinus())),M=pP(V,t,p),T=n.mul(mP(mc(B),y,x))}const S=T.rgb.mul(M.rgb),N=i.dot(e).clamp(),R=ue(nP({dotNV:N,specularColor:r,specularF90:o,roughness:t})),P=T.r.add(T.g,T.b).div(3);return Lt(R.oneMinus().mul(S),M.a.oneMinus().mul(P).oneMinus())}),o4=qr(3.2404542,-.969266,.0556434,-1.5371385,1.8760108,-.2040259,-.4985314,.041556,1.0572252),a4=i=>{const e=i.sqrt();return ue(1).add(e).div(ue(1).sub(e))},gP=(i,e)=>i.sub(e).div(i.add(e)).pow2(),l4=(i,e)=>{const t=i.mul(2*Math.PI*1e-9),n=ue(54856e-17,44201e-17,52481e-17),r=ue(1681e3,1795300,2208400),o=ue(43278e5,93046e5,66121e5),a=$(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=ue(c.x.add(a),c.y,c.z).div(10685e-11),o4.mul(c)},c4=de(({outsideIOR:i,eta2:e,cosTheta1:t,thinFilmThickness:n,baseF0:r})=>{const o=oi(i,e,Ya(0,.03,n)),c=i.div(o).pow2().mul(t.pow2().oneMinus()).oneMinus();Yt(c.lessThan(0),()=>ue(1));const u=c.sqrt(),d=gP(o,i),p=Gm({f0:d,f90:1,dotVH:t}),m=p.oneMinus(),y=o.lessThan(i).select(Math.PI,0),x=$(Math.PI).sub(y),v=a4(r.clamp(0,.9999)),M=gP(v,o.toVec3()),T=Gm({f0:M,f90:1,dotVH:u}),S=ue(v.x.lessThan(o).select(Math.PI,0),v.y.lessThan(o).select(Math.PI,0),v.z.lessThan(o).select(Math.PI,0)),N=o.mul(n,u,2),R=ue(x).add(S),P=p.mul(T).clamp(1e-5,.9999),B=P.sqrt(),F=m.pow2().mul(T).div(ue(1).sub(P)),V=p.add(F).toVar(),U=F.sub(m).toVar();return wi({start:1,end:2,condition:"<=",name:"m"},({m:z})=>{U.mulAssign(B);const j=l4($(z).mul(N),$(z).mul(R)).mul(2);V.addAssign(U.mul(j))}),V.max(ue(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"}]}),u4=de(({normal:i,viewDir:e,roughness:t})=>{const n=i.dot(e).saturate(),r=t.pow2(),o=_r(t.lessThan(.25),$(-339.2).mul(r).add($(161.4).mul(t)).sub(25.9),$(-8.48).mul(r).add($(14.3).mul(t)).sub(9.95)),a=_r(t.lessThan(.25),$(44).mul(r).sub($(23.7).mul(t)).add(3.26),$(1.97).mul(r).sub($(3.27).mul(t)).add(.72));return _r(t.lessThan(.25),0,$(.1).mul(t).sub(.025)).add(o.mul(n).add(a).exp()).mul(1/Math.PI).saturate()}),kw=ue(.04),zw=$(1);class yP extends fv{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}start(e){if(this.clearcoat===!0&&(this.clearcoatRadiance=ue().toVar("clearcoatRadiance"),this.clearcoatSpecularDirect=ue().toVar("clearcoatSpecularDirect"),this.clearcoatSpecularIndirect=ue().toVar("clearcoatSpecularIndirect")),this.sheen===!0&&(this.sheenSpecularDirect=ue().toVar("sheenSpecularDirect"),this.sheenSpecularIndirect=ue().toVar("sheenSpecularIndirect")),this.iridescence===!0){const t=Ti.dot(Yi).clamp();this.iridescenceFresnel=c4({outsideIOR:$(1),eta2:ET,cosTheta1:t,thinFilmThickness:CT,baseF0:Lo}),this.iridescenceF0=iP({f:this.iridescenceFresnel,f90:1,dotVH:t})}if(this.transmission===!0){const t=ha,n=m_.sub(ha).normalize(),r=hd,o=e.context;o.backdrop=r4(r,n,hc,fi,Lo,n_,t,Ja,ua,Za,s_,RT,PT,NT,this.dispersion?IT:null),o.backdropAlpha=Vx,fi.a.mulAssign(oi(1,o.backdrop.a,Vx))}super.start(e)}computeMultiscattering(e,t,n){const r=Ti.dot(Yi).clamp(),o=Fw({roughness:hc,dotNV:r}),c=(this.iridescenceF0?Ux.mix(Lo,this.iridescenceF0):Lo).mul(o.x).add(n.mul(o.y)),d=o.x.add(o.y).oneMinus(),p=Lo.add(Lo.oneMinus().mul(.047619)),m=c.mul(p).div(d.mul(p).oneMinus());e.addAssign(c),t.addAssign(m.mul(d))}direct({lightDirection:e,lightColor:t,reflectedLight:n}){const o=Ti.dot(e).clamp().mul(t);if(this.sheen===!0&&this.sheenSpecularDirect.addAssign(o.mul(JG({lightDirection:e}))),this.clearcoat===!0){const c=qf.dot(e).clamp().mul(t);this.clearcoatSpecularDirect.addAssign(c.mul(Dw({lightDirection:e,f0:kw,f90:zw,roughness:e_,normalView:qf})))}n.directDiffuse.addAssign(o.mul(Yf({diffuseColor:fi.rgb}))),n.directSpecular.addAssign(o.mul(Dw({lightDirection:e,f0:Lo,f90:1,roughness:hc,iridescence:this.iridescence,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=Ti,x=Yi,v=Is.toVar(),M=QG({N:y,V:x,roughness:hc}),T=a.sample(M).toVar(),S=c.sample(M).toVar(),N=qr(ue(T.x,0,T.y),ue(0,1,0),ue(T.z,0,T.w)).toVar(),R=Lo.mul(S.x).add(Lo.oneMinus().mul(S.y)).toVar();o.directSpecular.addAssign(e.mul(R).mul(rP({N:y,V:x,P:v,mInv:N,p0:u,p1:d,p2:p,p3:m}))),o.directDiffuse.addAssign(e.mul(fi).mul(rP({N:y,V:x,P:v,mInv:qr(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;n.indirectDiffuse.addAssign(t.mul(Yf({diffuseColor:fi})))}indirectSpecular(e){const{radiance:t,iblIrradiance:n,reflectedLight:r}=e.context;if(this.sheen===!0&&this.sheenSpecularIndirect.addAssign(n.mul(Gf,u4({normal:Ti,viewDir:Yi,roughness:Ox}))),this.clearcoat===!0){const p=qf.dot(Yi).clamp(),m=nP({dotNV:p,specularColor:kw,specularF90:zw,roughness:e_});this.clearcoatSpecularIndirect.addAssign(this.clearcoatRadiance.mul(m))}const o=ue().toVar("singleScattering"),a=ue().toVar("multiScattering"),c=n.mul(1/Math.PI);this.computeMultiscattering(o,a,n_);const u=o.add(a),d=fi.mul(u.r.max(u.g).max(u.b).oneMinus());r.indirectSpecular.addAssign(t.mul(o)),r.indirectSpecular.addAssign(a.mul(c)),r.indirectDiffuse.addAssign(d.mul(c))}ambientOcclusion(e){const{ambientOcclusion:t,reflectedLight:n}=e.context,o=Ti.dot(Yi).clamp().add(t),a=hc.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=qf.dot(Yi).clamp(),r=Gm({dotVH:n,f0:kw,f90:zw}),o=t.mul(Bx.mul(r).oneMinus()).add(this.clearcoatSpecularDirect.add(this.clearcoatSpecularIndirect).mul(Bx));t.assign(o)}if(this.sheen===!0){const n=Gf.r.max(Gf.g).max(Gf.b).mul(.157).oneMinus(),r=t.mul(n).add(this.sheenSpecularDirect,this.sheenSpecularIndirect);t.assign(r)}}}const _P=$(1),Vw=$(-2),mv=$(.8),Gw=$(-1),gv=$(.4),Hw=$(2),yv=$(.305),Ww=$(3),xP=$(.21),h4=$(4),vP=$(4),d4=$(16),f4=de(([i])=>{const e=ue(zi(i)).toVar(),t=$(-1).toVar();return Yt(e.x.greaterThan(e.z),()=>{Yt(e.x.greaterThan(e.y),()=>{t.assign(_r(i.x.greaterThan(0),0,3))}).Else(()=>{t.assign(_r(i.y.greaterThan(0),1,4))})}).Else(()=>{Yt(e.z.greaterThan(e.y),()=>{t.assign(_r(i.z.greaterThan(0),2,5))}).Else(()=>{t.assign(_r(i.y.greaterThan(0),1,4))})}),t}).setLayout({name:"getFace",type:"float",inputs:[{name:"direction",type:"vec3"}]}),p4=de(([i,e])=>{const t=Xe().toVar();return Yt(e.equal(0),()=>{t.assign(Xe(i.z,i.y).div(zi(i.x)))}).ElseIf(e.equal(1),()=>{t.assign(Xe(i.x.negate(),i.z.negate()).div(zi(i.y)))}).ElseIf(e.equal(2),()=>{t.assign(Xe(i.x.negate(),i.y).div(zi(i.z)))}).ElseIf(e.equal(3),()=>{t.assign(Xe(i.z.negate(),i.y).div(zi(i.x)))}).ElseIf(e.equal(4),()=>{t.assign(Xe(i.x.negate(),i.z).div(zi(i.y)))}).Else(()=>{t.assign(Xe(i.x,i.y).div(zi(i.z)))}),En(.5,t.add(1))}).setLayout({name:"getUV",type:"vec2",inputs:[{name:"direction",type:"vec3"},{name:"face",type:"float"}]}),m4=de(([i])=>{const e=$(0).toVar();return Yt(i.greaterThanEqual(mv),()=>{e.assign(_P.sub(i).mul(Gw.sub(Vw)).div(_P.sub(mv)).add(Vw))}).ElseIf(i.greaterThanEqual(gv),()=>{e.assign(mv.sub(i).mul(Hw.sub(Gw)).div(mv.sub(gv)).add(Gw))}).ElseIf(i.greaterThanEqual(yv),()=>{e.assign(gv.sub(i).mul(Ww.sub(Hw)).div(gv.sub(yv)).add(Hw))}).ElseIf(i.greaterThanEqual(xP),()=>{e.assign(yv.sub(i).mul(h4.sub(Ww)).div(yv.sub(xP)).add(Ww))}).Else(()=>{e.assign($(-2).mul(dc(En(1.16,i))))}),e}).setLayout({name:"roughnessToMip",type:"float",inputs:[{name:"roughness",type:"float"}]}),bP=de(([i,e])=>{const t=i.toVar();t.assign(En(2,t).sub(1));const n=ue(t,1).toVar();return Yt(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"}]}),SP=de(([i,e,t,n,r,o])=>{const a=$(t),c=ue(e),u=ja(m4(a),Vw,o),d=Cu(u),p=pc(u),m=ue($w(i,c,p,n,r,o)).toVar();return Yt(d.notEqual(0),()=>{const y=ue($w(i,c,p.add(1),n,r,o)).toVar();m.assign(oi(m,y,d))}),m}),$w=de(([i,e,t,n,r,o])=>{const a=$(t).toVar(),c=ue(e),u=$(f4(c)).toVar(),d=$(ys(vP.sub(a),0)).toVar();a.assign(ys(a,vP));const p=$(Pm(a)).toVar(),m=Xe(p4(c,u).mul(p.sub(2)).add(1)).toVar();return Yt(u.greaterThan(2),()=>{m.y.addAssign(p),u.subAssign(3)}),m.x.addAssign(u.mul(p)),m.x.addAssign(d.mul(En(3,d4))),m.y.addAssign(En(4,Pm(o).sub(p))),m.x.mulAssign(n),m.y.mulAssign(r),i.sample(m).grad(Xe(),Xe())}),qw=de(({envMap:i,mipInt:e,outputDirection:t,theta:n,axis:r,CUBEUV_TEXEL_WIDTH:o,CUBEUV_TEXEL_HEIGHT:a,CUBEUV_MAX_MIP:c})=>{const u=Ru(n),d=t.mul(u).add(r.cross(t).mul(ca(n))).add(r.mul(r.dot(t).mul(u.oneMinus())));return $w(i,d,e,o,a,c)}),TP=de(({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=ue(_r(e,t,jx(t,n))).toVar();Yt(y.equal(ue(0)),()=>{y.assign(ue(n.z,0,n.x.negate()))}),y.assign(Eu(y));const x=ue().toVar();return x.addAssign(r.element(0).mul(qw({theta:0,axis:y,outputDirection:n,mipInt:c,envMap:u,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:m}))),wi({start:ie(1),end:i},({i:v})=>{Yt(v.greaterThanEqual(o),()=>{IN()});const M=$(a.mul($(v))).toVar();x.addAssign(r.element(v).mul(qw({theta:M.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(qw({theta:M,axis:y,outputDirection:n,mipInt:c,envMap:u,CUBEUV_TEXEL_WIDTH:d,CUBEUV_TEXEL_HEIGHT:p,CUBEUV_MAX_MIP:m})))}),Lt(x,1)}),Hm=4,wP=[.125,.215,.35,.446,.526,.582],Zf=20,Xw=new Jh(-1,1,1,-1,0,1),g4=new ps(90,1),MP=new At;let jw=null,Yw=0,Zw=0;const Kf=(1+Math.sqrt(5))/2,Wm=1/Kf,AP=[new W(-Kf,Wm,0),new W(Kf,Wm,0),new W(-Wm,0,Kf),new W(Wm,0,Kf),new W(0,Kf,-Wm),new W(0,Kf,Wm),new W(-1,1,-1),new W(1,1,-1),new W(-1,1,1),new W(1,1,1)],y4=new W,EP=new WeakMap,_4=[3,1,5,0,4,2],Kw=bP(Ri(),ho("faceIndex")).normalize(),Jw=ue(Kw.x,Kw.y,Kw.z);class x4{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._lodPlanes=[],this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._blurMaterial=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._backgroundBox=null}get _hasInitialized(){return this._renderer.hasInitialized()}fromScene(e,t=0,n=.1,r=100,o={}){const{size:a=256,position:c=y4,renderTarget:u=null}=o;if(this._setSize(a),this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromScene() called before the backend is initialized. Try using .fromSceneAsync() instead.");const p=u||this._allocateTarget();return o.renderTarget=p,this.fromSceneAsync(e,t,n,r,o),p}jw=this._renderer.getRenderTarget(),Yw=this._renderer.getActiveCubeFace(),Zw=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 en(this,arguments,function*(e,t=0,n=.1,r=100,o={}){return this._hasInitialized===!1&&(yield this._renderer.init()),this.fromScene(e,t,n,r,o)})}fromEquirectangular(e,t=null){if(this._hasInitialized===!1){console.warn("THREE.PMREMGenerator: .fromEquirectangular() called before the backend is initialized. Try using .fromEquirectangularAsync() 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 en(this,null,function*(){return this._hasInitialized===!1&&(yield this._renderer.init()),this._fromTexture(e,t)})}fromCubemap(e,t=null){if(this._hasInitialized===!1){console.warn("THREE.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 en(this,null,function*(){return this._hasInitialized===!1&&(yield this._renderer.init()),this._fromTexture(e,t)})}compileCubemapShader(){return en(this,null,function*(){this._cubemapMaterial===null&&(this._cubemapMaterial=RP(),yield this._compileMaterial(this._cubemapMaterial))})}compileEquirectangularShader(){return en(this,null,function*(){this._equirectMaterial===null&&(this._equirectMaterial=NP(),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===Br||e.mapping===Vo?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._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodPlanes.length;e++)this._lodPlanes[e].dispose()}_cleanup(e){this._renderer.setRenderTarget(jw,Yw,Zw),e.scissorTest=!1,_v(e,0,0,e.width,e.height)}_fromTexture(e,t){this._setSizeFromTexture(e),jw=this._renderer.getRenderTarget(),Yw=this._renderer.getActiveCubeFace(),Zw=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 CP(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=CP(e.width,e.height);const{_lodMax:t}=this;({sizeLods:this._sizeLods,lodPlanes:this._lodPlanes,sigmas:this._sigmas,lodMeshes:this._lodMeshes}=v4(t)),this._blurMaterial=b4(t,e.width,e.height)}}_compileMaterial(e){return en(this,null,function*(){const t=new vi(this._lodPlanes[0],e);yield this._renderer.compile(t,Xw)})}_sceneToCubeUV(e,t,n,r,o){const a=g4;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(MP),d.autoClear=!1;let m=this._backgroundBox;if(m===null){const v=new js({name:"PMREM.Background",side:Ee,depthWrite:!1,depthTest:!1});m=new vi(new Ko,v)}let y=!1;const x=e.background;x?x.isColor&&(m.material.color.copy(x),e.background=null,y=!0):(m.material.color.copy(MP),y=!0),d.setRenderTarget(r),d.clear(),y&&d.render(m,a);for(let v=0;v<6;v++){const M=v%3;M===0?(a.up.set(0,c[v],0),a.position.set(o.x,o.y,o.z),a.lookAt(o.x+u[v],o.y,o.z)):M===1?(a.up.set(0,0,c[v]),a.position.set(o.x,o.y,o.z),a.lookAt(o.x,o.y+u[v],o.z)):(a.up.set(0,c[v],0),a.position.set(o.x,o.y,o.z),a.lookAt(o.x,o.y,o.z+u[v]));const T=this._cubeSize;_v(r,M*T,v>2?T:0,T,T),d.render(e,a)}d.autoClear=p,e.background=x}_textureToCubeUV(e,t){const n=this._renderer,r=e.mapping===Br||e.mapping===Vo;r?this._cubemapMaterial===null&&(this._cubemapMaterial=RP(e)):this._equirectMaterial===null&&(this._equirectMaterial=NP(e));const o=r?this._cubemapMaterial:this._equirectMaterial;o.fragmentNode.value=e;const a=this._lodMeshes[0];a.material=o;const c=this._cubeSize;_v(t,0,0,3*c,2*c),n.setRenderTarget(t),n.render(a,Xw)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const r=this._lodPlanes.length;for(let o=1;o<r;o++){const a=Math.sqrt(this._sigmas[o]*this._sigmas[o]-this._sigmas[o-1]*this._sigmas[o-1]),c=AP[(r-o-1)%AP.length];this._blur(e,o-1,o,a,c)}t.autoClear=n}_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"&&console.error("blur direction must be either latitudinal or longitudinal!");const p=3,m=this._lodMeshes[r];m.material=d;const y=EP.get(d),x=this._sizeLods[n]-1,v=isFinite(o)?Math.PI/(2*x):2*Math.PI/(2*Zf-1),M=o/v,T=isFinite(o)?1+Math.floor(p*M):Zf;T>Zf&&console.warn(`sigmaRadians, ${o}, is too large and will clip, as it requested ${T} samples when the maximum is set to ${Zf}`);const S=[];let N=0;for(let k=0;k<Zf;++k){const V=k/M,U=Math.exp(-V*V/2);S.push(U),k===0?N+=U:k<T&&(N+=2*U)}for(let k=0;k<S.length;k++)S[k]=S[k]/N;e.texture.frame=(e.texture.frame||0)+1,y.envMap.value=e.texture,y.samples.value=T,y.weights.array=S,y.latitudinal.value=a==="latitudinal"?1:0,c&&(y.poleAxis.value=c);const{_lodMax:R}=this;y.dTheta.value=v,y.mipInt.value=R-n;const P=this._sizeLods[r],B=3*P*(r>R-Hm?r-R+Hm:0),F=4*(this._cubeSize-P);_v(t,B,F,3*P,2*P),u.setRenderTarget(t),u.render(m,Xw)}}function v4(i){const e=[],t=[],n=[],r=[];let o=i;const a=i-Hm+1+wP.length;for(let c=0;c<a;c++){const u=Math.pow(2,o);t.push(u);let d=1/u;c>i-Hm?d=wP[c-i+Hm-1]:c===0&&(d=0),n.push(d);const p=1/(u-2),m=-p,y=1+p,x=[m,m,y,m,y,y,m,m,y,y,m,y],v=6,M=6,T=3,S=2,N=1,R=new Float32Array(T*M*v),P=new Float32Array(S*M*v),B=new Float32Array(N*M*v);for(let k=0;k<v;k++){const V=k%3*2/3-1,U=k>2?0:-1,z=[V,U,0,V+2/3,U,0,V+2/3,U+1,0,V,U,0,V+2/3,U+1,0,V,U+1,0],j=_4[k];R.set(z,T*M*j),P.set(x,S*M*j);const se=[j,j,j,j,j,j];B.set(se,N*M*j)}const F=new gn;F.setAttribute("position",new $n(R,T)),F.setAttribute("uv",new $n(P,S)),F.setAttribute("faceIndex",new $n(B,N)),e.push(F),r.push(new vi(F,null)),o>Hm&&o--}return{lodPlanes:e,sizeLods:t,sigmas:n,lodMeshes:r}}function CP(i,e){const t={magFilter:Yn,minFilter:Yn,generateMipmaps:!1,type:Ts,format:_i,colorSpace:ol},n=new Mr(i,e,t);return n.texture.mapping=Ll,n.texture.name="PMREM.cubeUv",n.texture.isPMREMTexture=!0,n.scissorTest=!0,n}function _v(i,e,t,n,r){i.viewport.set(e,t,n,r),i.scissor.set(e,t,n,r)}function Qw(i){const e=new _s;return e.depthTest=!1,e.depthWrite=!1,e.blending=Ae,e.name=`PMREM_${i}`,e}function b4(i,e,t){const n=Xr(new Array(Zf).fill(0)),r=Jt(new W(0,1,0)),o=Jt(0),a=$(Zf),c=Jt(0),u=Jt(1),d=Kn(null),p=Jt(0),m=$(1/e),y=$(1/t),x=$(i),v={n:a,latitudinal:c,weights:n,poleAxis:r,outputDirection:Jw,dTheta:o,samples:u,envMap:d,mipInt:p,CUBEUV_TEXEL_WIDTH:m,CUBEUV_TEXEL_HEIGHT:y,CUBEUV_MAX_MIP:x},M=Qw("blur");return M.fragmentNode=TP(_a(Ii({},v),{latitudinal:c.equal(1)})),EP.set(M,v),M}function RP(i){const e=Qw("cubemap");return e.fragmentNode=Bm(i,Jw),e}function NP(i){const e=Qw("equirect");return e.fragmentNode=Kn(i,Pw(Jw),0),e}const PP=new WeakMap;function S4(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 T4(i,e,t){const n=w4(e);let r=n.get(i);if((r!==void 0?r.pmremVersion:-1)!==i.pmremVersion){const a=i.image;if(i.isCubeTexture)if(A4(a))r=t.fromCubemap(i,r);else return null;else if(E4(a))r=t.fromEquirectangular(i,r);else return null;r.pmremVersion=i.pmremVersion,n.set(i,r)}return r.texture}function w4(i){let e=PP.get(i);return e===void 0&&(e=new WeakMap,PP.set(i,e)),e}class M4 extends Rs{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 ds;r.isRenderTargetTexture=!0,this._texture=Kn(r),this._width=Jt(0),this._height=Jt(0),this._maxMip=Jt(0),this.updateBeforeType=In.RENDER}set value(e){this._value=e,this._pmrem=null}get value(){return this._value}updateFromTexture(e){const t=S4(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=T4(r,e.renderer,this._generator),t!==null&&(this._pmrem=t,this.updateFromTexture(t)))}setup(e){this._generator===null&&(this._generator=new x4(e.renderer)),this.updateBefore(e);let t=this.uvNode;t===null&&e.context.getUV&&(t=e.context.getUV(this)),t=uw.mul(ue(t.x,t.y.negate(),t.z));let n=this.levelNode;return n===null&&e.context.getTextureLevel&&(n=e.context.getTextureLevel(this)),SP(this._texture,t,n,this._width,this._height,this._maxMip)}dispose(){super.dispose(),this._generator!==null&&this._generator.dispose()}}function A4(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 E4(i){return i==null?!1:i.height>0}const eM=xn(M4).setParameterLength(1,3),IP=new WeakMap;class C4 extends Um{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=IP.get(m);y===void 0&&(y=eM(m),IP.set(m,y)),n=y}const o=t.useAnisotropy===!0||t.anisotropy>0?ZR:Ti,a=n.context(LP(hc,o)).mul(tv),c=n.context(R4(hd)).mul(Math.PI).mul(tv),u=u_(a),d=u_(c);e.context.radiance.addAssign(u),e.context.iblIrradiance.addAssign(d);const p=e.context.lightingModel.clearcoatRadiance;if(p){const m=n.context(LP(e_,qf)).mul(tv),y=u_(m);p.addAssign(y)}}}const LP=(i,e)=>{let t=null;return{getUV:()=>(t===null&&(t=Yi.negate().reflect(e),t=i.mul(i).mix(t,e).normalize(),t=t.transformDirection(ua)),t),getTextureLevel:()=>i}},R4=i=>({getUV:()=>i,getTextureLevel:()=>$(1)}),N4=new vf;class DP extends _s{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(N4),this.setValues(e)}setupEnvironment(e){let t=super.setupEnvironment(e);return t===null&&e.environmentNode&&(t=e.environmentNode),t?new C4(t):null}setupLightingModel(){return new yP}setupSpecular(){const e=oi(ue(.04),fi.rgb,Qy);Lo.assign(e),n_.assign(1)}setupVariants(){const e=this.metalnessNode?$(this.metalnessNode):sN;Qy.assign(e);let t=this.roughnessNode?$(this.roughnessNode):iN;t=Lw({roughness:t}),hc.assign(t),this.setupSpecular(),fi.assign(Lt(fi.rgb.mul(e.oneMinus()),fi.a))}copy(e){return this.emissiveNode=e.emissiveNode,this.metalnessNode=e.metalnessNode,this.roughnessNode=e.roughnessNode,super.copy(e)}}const P4=new k0;class I4 extends DP{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(P4),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?$(this.iorNode):_N;s_.assign(e),Lo.assign(oi(Do(GT(s_.sub(1).div(s_.add(1))).mul(nN),ue(1)).mul(yw),fi.rgb,Qy)),n_.assign(oi(yw,1,Qy))}setupLightingModel(){return new yP(this.useClearcoat,this.useSheen,this.useIridescence,this.useAnisotropy,this.useTransmission,this.useDispersion)}setupVariants(e){if(super.setupVariants(e),this.useClearcoat){const t=this.clearcoatNode?$(this.clearcoatNode):oN,n=this.clearcoatRoughnessNode?$(this.clearcoatRoughnessNode):aN;Bx.assign(t),e_.assign(Lw({roughness:n}))}if(this.useSheen){const t=this.sheenNode?ue(this.sheenNode):uN,n=this.sheenRoughnessNode?$(this.sheenRoughnessNode):hN;Gf.assign(t),Ox.assign(n)}if(this.useIridescence){const t=this.iridescenceNode?$(this.iridescenceNode):fN,n=this.iridescenceIORNode?$(this.iridescenceIORNode):pN,r=this.iridescenceThicknessNode?$(this.iridescenceThicknessNode):mN;Ux.assign(t),ET.assign(n),CT.assign(r)}if(this.useAnisotropy){const t=(this.anisotropyNode?Xe(this.anisotropyNode):dN).toVar();ad.assign(t.length()),Yt(ad.equal(0),()=>{t.assign(Xe(1,0))}).Else(()=>{t.divAssign(Xe(ad)),ad.assign(ad.saturate())}),kx.assign(ad.pow2().mix(hc.pow2(),1)),t_.assign(Xf[0].mul(t.x).add(Xf[1].mul(t.y))),Hf.assign(Xf[1].mul(t.x).sub(Xf[0].mul(t.y)))}if(this.useTransmission){const t=this.transmissionNode?$(this.transmissionNode):gN,n=this.thicknessNode?$(this.thicknessNode):yN,r=this.attenuationDistanceNode?$(this.attenuationDistanceNode):xN,o=this.attenuationColorNode?ue(this.attenuationColorNode):vN;if(Vx.assign(t),RT.assign(n),NT.assign(r),PT.assign(o),this.useDispersion){const a=this.dispersionNode?$(this.dispersionNode):SN;IT.assign(a)}}}setupClearcoatNormal(){return this.clearcoatNormalNode?ue(this.clearcoatNormalNode):lN}setup(e){e.context.setupClearcoatNormal=()=>Im(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 L4 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(Ti.mul(c)).normalize(),x=$(Yi.dot(y.negate()).saturate().pow(p).mul(m)),v=ue(x.add(u).mul(a));n.directDiffuse.addAssign(v.mul(d.mul(t)))}super.direct({lightDirection:e,lightColor:t,reflectedLight:n},r)}}class hZ extends null{static get type(){return"MeshSSSNodeMaterial"}constructor(e){super(e),this.thicknessColorNode=null,this.thicknessDistortionNode=$(.1),this.thicknessAmbientNode=$(0),this.thicknessAttenuationNode=$(.1),this.thicknessPowerNode=$(2),this.thicknessScaleNode=$(10)}get useSSS(){return this.thicknessColorNode!==null}setupLightingModel(){return new L4(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 D4=de(({normal:i,lightDirection:e,builder:t})=>{const n=i.dot(e),r=Xe(n.mul(.5).add(.5),0);if(t.material.gradientMap){const o=Bu("gradientMap","texture").context({getUV:()=>r});return ue(o.r)}else{const o=r.fwidth().mul(.5);return oi(ue(.7),ue(1),Ya($(.7).sub(o.x),$(.7).add(o.x),r.x))}});class F4 extends fv{direct({lightDirection:e,lightColor:t,reflectedLight:n},r){const o=D4({normal:ev,lightDirection:e,builder:r}).mul(t);n.directDiffuse.addAssign(o.mul(Yf({diffuseColor:fi.rgb})))}indirect(e){const{ambientOcclusion:t,irradiance:n,reflectedLight:r}=e.context;r.indirectDiffuse.addAssign(n.mul(Yf({diffuseColor:fi}))),r.indirectDiffuse.mulAssign(t)}}const B4=new oy;class O4 extends _s{static get type(){return"MeshToonNodeMaterial"}constructor(e){super(),this.isMeshToonNodeMaterial=!0,this.lights=!0,this.setDefaultValues(B4),this.setValues(e)}setupLightingModel(){return new F4}}const FP=de(()=>{const i=ue(Yi.z,0,Yi.x.negate()).normalize(),e=Yi.cross(i);return Xe(i.dot(Ti),e.dot(Ti)).mul(.495).add(.5)}).once(["NORMAL","VERTEX"])().toVar("matcapUV"),U4=new ly;class k4 extends _s{static get type(){return"MeshMatcapNodeMaterial"}constructor(e){super(),this.isMeshMatcapNodeMaterial=!0,this.setDefaultValues(U4),this.setValues(e)}setupVariants(e){const t=FP;let n;e.material.matcap?n=Bu("matcap","texture").context({getUV:()=>t}):n=ue(oi(.2,.8,t.y)),fi.rgb.mulAssign(n.rgb)}}class z4 extends Rs{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 Fx(o,a,a.negate(),o).mul(n)}else{const o=t,a=Vf(Lt(1,0,0,0),Lt(0,Ru(o.x),ca(o.x).negate(),0),Lt(0,ca(o.x),Ru(o.x),0),Lt(0,0,0,1)),c=Vf(Lt(Ru(o.y),0,ca(o.y),0),Lt(0,1,0,0),Lt(ca(o.y).negate(),0,Ru(o.y),0),Lt(0,0,0,1)),u=Vf(Lt(Ru(o.z),ca(o.z).negate(),0,0),Lt(ca(o.z),Ru(o.z),0,0),Lt(0,0,1,0),Lt(0,0,0,1));return a.mul(c).mul(u).mul(Lt(n,1)).xyz}}}const x_=xn(z4).setParameterLength(2),V4=new $d;class BP extends _s{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(V4),this.setValues(e)}setupPositionView(e){const{object:t,camera:n}=e,{positionNode:r,rotationNode:o,scaleNode:a,sizeAttenuation:c}=this,u=Fu.mul(ue(r||0));let d=Xe(Ja[0].xyz.length(),Ja[1].xyz.length());a!==null&&(d=d.mul(Xe(a))),n.isPerspectiveCamera&&c===!1&&(d=d.mul(u.z.negate()));let p=Lr.xy;if(t.center&&t.center.isVector2===!0){const x=Hz("center","vec2",t);p=p.sub(x.sub(.5))}p=p.mul(d);const m=$(o||cN),y=x_(p,m);return Lt(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 G4=new Dh,H4=new Ie;class W4 extends BP{static get type(){return"PointsNodeMaterial"}constructor(e){super(),this.sizeNode=null,this.isPointsNodeMaterial=!0,this.setDefaultValues(G4),this.setValues(e)}setupPositionView(){const{positionNode:e}=this;return Fu.mul(ue(e||Ps)).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?Xe(a):bN;d=d.mul(bR),n.isPerspectiveCamera&&c===!0&&(d=d.mul($4.div(Is.z.negate()))),o&&o.isNode&&(d=d.mul(Xe(o)));let p=Lr.xy;if(r&&r.isNode){const m=$(r);p=x_(p,m)}return p=p.mul(d),p=p.div(iw.div(2)),p=p.mul(u.w),u=u.add(Lt(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 $4=Jt(1).onFrameUpdate(function({renderer:i}){const e=i.getSize(H4);this.value=.5*e.y});class q4 extends fv{constructor(){super(),this.shadowNode=$(1).toVar("shadowMask")}direct({lightNode:e}){e.shadowNode!==null&&this.shadowNode.mulAssign(e.shadowNode)}finish({context:e}){fi.a.mulAssign(this.shadowNode.oneMinus()),e.outgoingLight.rgb.assign(fi.rgb)}}const X4=new nm;class j4 extends _s{static get type(){return"ShadowNodeMaterial"}constructor(e){super(),this.isShadowNodeMaterial=!0,this.lights=!0,this.transparent=!0,this.setDefaultValues(X4),this.setValues(e)}setupLightingModel(){return new q4}}const v_=El("vec3"),OP=El("vec3"),UP=El("vec3");class Y4 extends null{constructor(){super()}start(e){const{material:t,context:n}=e,r=El("vec3"),o=El("vec3");Yt(m_.sub(ha).length().greaterThan(MR.mul(2)),()=>{r.assign(m_),o.assign(ha)}).Else(()=>{r.assign(ha),o.assign(m_)});const a=o.sub(r),c=Jt("int").onRenderUpdate(({material:y})=>y.steps),u=a.length().div(c).toVar(),d=a.normalize().toVar(),p=$(0).toVar(),m=ue(1).toVar();t.offsetNode&&p.addAssign(t.offsetNode.mul(u)),wi(c,()=>{const y=r.add(d.mul(p)),x=ua.mul(Lt(y,1)).xyz;t.depthNode!==null&&(OP.assign(Vm(Ew(x.z,Lu,Du))),n.sceneDepthNode=Vm(t.depthNode).toVar()),n.positionWorld=y,n.shadowPositionWorld=y,n.positionView=x,v_.assign(0);let v;t.scatteringNode&&(v=t.scatteringNode({positionRay:y})),super.start(e),v&&v_.mulAssign(v);const M=v_.mul(.01).negate().mul(u).exp();m.mulAssign(M),p.addAssign(u)}),UP.addAssign(m.saturate().oneMinus())}scatteringLight(e,t){const n=t.context.sceneDepthNode;n?Yt(n.greaterThanEqual(OP),()=>{v_.addAssign(e)}):v_.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(e4({P:p,p0:a,p1:c,p2:u,p3:d})).pow(1.5);this.scatteringLight(m,o)}finish(e){e.context.outgoingLight.assign(UP)}}class dZ 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 Y4}}class Z4{constructor(e,t){this.nodes=e,this.info=t,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._animationLoop!==null&&this._animationLoop(t,n)};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 Cl{constructor(){this.weakMap=new WeakMap}get(e){let t=this.weakMap;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.weakMap;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.weakMap;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 K4=0;function J4(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 Q4{constructor(e,t,n,r,o,a,c,u,d,p){this.id=K4++,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)}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 M=y-m;return M<0||M===1/0?null:(a.vertexCount=M,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 J4(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)&&(r+=e.uuid+","),r+=e.receiveShadow+",",uT(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=$y(e,this.camera.cameras.length)),this.object.receiveShadow&&(e=$y(e,1)),e}getCacheKey(){return this.getMaterialCacheKey()+this.getDynamicCacheKey()}dispose(){this.material.removeEventListener("dispose",this.onMaterialDispose),this.geometry.removeEventListener("dispose",this.onGeometryDispose),this.onDispose()}}const Jf=[];class e5{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);Jf[0]=e,Jf[1]=t,Jf[2]=a,Jf[3]=o;let p=d.get(Jf);return p===void 0?(p=this.createRenderObject(this.nodes,this.geometries,this.renderer,e,t,n,r,o,a,c,u),d.set(Jf,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)),Jf.length=0,p}getChainMap(e="default"){return this.chainMaps[e]||(this.chainMaps[e]=new Cl)}dispose(){this.chainMaps={}}createRenderObject(e,t,n,r,o,a,c,u,d,p,m){const y=this.getChainMap(m),x=new Q4(e,t,n,r,o,a,c,u,d,p);return x.onDispose=()=>{this.pipelines.delete(x),this.bindings.delete(x),this.nodes.delete(x),y.delete(x.getChainArray())},x}}class pd{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 el={VERTEX:1,INDEX:2,STORAGE:3,INDIRECT:4},md=16,t5=211,n5=212;class i5 extends pd{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===el.VERTEX?this.backend.createAttribute(e):t===el.INDEX?this.backend.createIndexAttribute(e):t===el.STORAGE?this.backend.createStorageAttribute(e):t===el.INDIRECT&&this.backend.createIndirectStorageAttribute(e),n.version=this._getBufferAttribute(e).version;else{const r=this._getBufferAttribute(e);(n.version<r.version||r.usage===Rd)&&(this.backend.updateAttribute(e),n.version=r.version)}}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}function kP(i){return i.index!==null?i.index.version:i.attributes.position.version}function zP(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(_g(e)?m0:Mg)(e,1);return r.version=kP(i),r}class s5 extends pd{constructor(e,t){super(),this.attributes=e,this.info=t,this.wireframes=new WeakMap,this.attributeCall=new WeakMap}has(e){const t=e.geometry;return super.has(t)&&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)};t.addEventListener("dispose",r)}updateAttributes(e){const t=e.getAttributes();for(const o of t)o.isStorageBufferAttribute||o.isStorageInstancedBufferAttribute?this.updateAttribute(o,el.STORAGE):this.updateAttribute(o,el.VERTEX);const n=this.getIndex(e);n!==null&&this.updateAttribute(n,el.INDEX);const r=e.geometry.indirect;r!==null&&this.updateAttribute(r,el.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}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=zP(t),o.set(t,a)):a.version!==kP(t)&&(this.attributes.delete(a),a=zP(t),o.set(t,a)),r=a}return r}}class r5{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):console.error("THREE.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 VP{constructor(e){this.cacheKey=e,this.usedTimes=0}}class o5 extends VP{constructor(e,t,n){super(e),this.vertexProgram=t,this.fragmentProgram=n}}class a5 extends VP{constructor(e,t){super(e),this.computeProgram=t,this.isComputePipeline=!0}}let l5=0;class tM{constructor(e,t,n,r=null,o=null){this.id=l5++,this.code=e,this.stage=t,this.name=n,this.transforms=r,this.attributes=o,this.usedTimes=0}}class c5 extends pd{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 tM(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 tM(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 tM(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 a5(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 o5(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 u5 extends pd{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))}_updateBindings(e){for(const t of e)this._update(t,e)}_init(e){for(const t of e.bindings)if(t.isSampledTexture)this.textures.updateTexture(t.texture);else if(t.isStorageBuffer){const n=t.attribute,r=n.isIndirectStorageBufferAttribute?el.INDIRECT:el.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(!(u.isNodeUniformsGroup&&this.nodes.updateGroup(u)===!1)){if(u.isStorageBuffer){const d=u.attribute,p=d.isIndirectStorageBufferAttribute?el.INDIRECT:el.STORAGE;this.attributes.update(d,p)}if(u.isUniformBuffer)u.update()&&n.updateBinding(u);else if(u.isSampledTexture){const d=u.update(),p=u.texture,m=this.textures.get(p);if(d&&(this.textures.updateTexture(p),u.generation!==m.generation&&(u.generation=m.generation,r=!0,o=!1)),n.get(p).externalTexture!==void 0||m.isDefaultTexture?o=!1:(a=a*10+p.id,c+=p.version),p.isStorageTexture===!0){const x=this.get(p);u.store===!0?x.needsMipmap=!0:this.textures.needsMipmaps(p)&&x.needsMipmap===!0&&(this.backend.generateMipmaps(p),x.needsMipmap=!1)}}else u.isSampler&&u.update()}r===!0&&this.backend.updateBindings(e,t,o?a:0,c)}}function h5(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 GP(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 HP(i){return(i.transmission>0||i.transmissionNode)&&i.side===ke&&i.forceSinglePass===!1}class d5{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?(HP(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?(HP(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||h5),this.transparentDoublePass.length>1&&this.transparentDoublePass.sort(t||GP),this.transparent.length>1&&this.transparent.sort(t||GP)}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 b_=[];class f5{constructor(e){this.lighting=e,this.lists=new Cl}get(e,t){const n=this.lists;b_[0]=e,b_[1]=t;let r=n.get(b_);return r===void 0&&(r=new d5(this.lighting,e,t),n.set(b_,r)),b_.length=0,r}dispose(){this.lists=new Cl}}let p5=0;class m5{constructor(){this.id=p5++,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 an,this.scissor=!1,this.scissorValue=new an,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 WP(this)}}function WP(i){const{textures:e,activeCubeFace:t,activeMipmapLevel:n}=i,r=[t,n];for(const o of e)r.push(o.id);return Wy(r)}const S_=[],g5=new Bp,y5=new Fp;class _5{constructor(){this.chainMaps={}}get(e,t,n=null){S_[0]=e,S_[1]=t;let r;if(n===null)r="default";else{const c=n.texture.format;r=`${n.textures.length}:${c}:${n.samples}:${n.depthBuffer}:${n.stencilBuffer}`}const o=this._getChainMap(r);let a=o.get(S_);return a===void 0&&(a=new m5,o.set(S_,a)),S_.length=0,n!==null&&(a.sampleCount=n.samples===0?1:n.samples),a}getForClear(e=null){return this.get(g5,y5,e)}_getChainMap(e){return this.chainMaps[e]||(this.chainMaps[e]=new Cl)}dispose(){this.chainMaps={}}}const x5=new W;class v5 extends pd{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 Ao,p.format=e.stencilBuffer?eo:Or,p.type=e.stencilBuffer?mo:pi,p.image.width=u,p.image.height=d,p.image.depth=c.depth,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 M=a[v];y&&(M.needsUpdate=!0),this.updateTexture(M,x)}p&&this.updateTexture(p,x)}if(n.initialized!==!0){n.initialized=!0;const v=()=>{e.removeEventListener("dispose",v);for(let M=0;M<a.length;M++)this._destroyTexture(a[M]);p&&this._destroyTexture(p),this.delete(e),this.backend.delete(e)};e.addEventListener("dispose",v)}}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.destroySampler(e),o.destroyTexture(e)),e.isFramebufferTexture){const d=this.renderer.getRenderTarget();d?e.type=d.texture.type:e.type=Ui}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.createSampler(e),o.createTexture(e,t),n.generation=e.version;else if(n.initialized!==!0&&o.createSampler(e),e.version>0){const p=e.image;if(p===void 0)console.warn("THREE.Renderer: Texture marked for update but image is undefined.");else if(p.complete===!1)console.warn("THREE.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=p;(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),t.needsMipmaps&&e.mipmaps.length===0&&o.generateMipmaps(e),e.onUpdate&&e.onUpdate(e)}}else o.createDefaultTexture(e),n.isDefaultTexture=!0,n.generation=e.version;if(n.initialized!==!0){n.initialized=!0,n.generation=e.version,this.info.memory.textures++,e.isVideoTexture&&pn.getTransfer(e.colorSpace)!==Dt&&console.warn("WebGPURenderer: Video textures must use a color space with a sRGB transfer function, e.g. SRGBColorSpace.");const d=()=>{e.removeEventListener("dispose",d),this._destroyTexture(e)};e.addEventListener("dispose",d)}n.version=e.version}getSize(e,t=x5){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):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}_destroyTexture(e){this.has(e)===!0&&(this.backend.destroySampler(e),this.backend.destroyTexture(e),this.delete(e),this.info.memory.textures--)}}class nM extends At{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 $P extends Si{static get type(){return"ParameterNode"}constructor(e,t=null){super(e,t),this.isParameterNode=!0}getHash(){return this.uuid}generate(){return this.name}}const b5=(i,e)=>Ge(new $P(i,e));class S5 extends kt{static get type(){return"StackNode"}constructor(e=null){super(),this.nodes=[],this.outputNode=null,this.parent=e,this._currentCond=null,this._expressionNode=null,this.isStackNode=!0}getNodeType(e){return this.hasOutput?this.outputNode.getNodeType(e):"void"}getMemberType(e,t){return this.hasOutput?this.outputNode.getMemberType(e,t):"void"}add(e){return e.isNode!==!0?(console.error("THREE.TSL: Invalid node added to stack."),this):(this.nodes.push(e),this)}If(e,t){const n=new Cm(t);return this._currentCond=_r(e,n),this.add(this._currentCond)}ElseIf(e,t){const n=new Cm(t),r=_r(e,n);return this._currentCond.elseNode=r,this._currentCond=r,this}Else(e){return this._currentCond.elseNode=new Cm(e),this}Switch(e){return this._expressionNode=Ge(e),this}Case(...e){const t=[];if(e.length>=2)for(let c=0;c<e.length-1;c++)t.push(this._expressionNode.equal(Ge(e[c])));else console.error("THREE.TSL: Invalid parameter length. Case() requires at least two parameters.");const n=e[e.length-1],r=new Cm(n);let o=t[0];for(let c=1;c<t.length;c++)o=o.or(t[c]);const a=_r(o,r);return this._currentCond===null?(this._currentCond=a,this.add(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.intent===!0&&e.getNodeProperties(r).assign!==!0||(t["node"+n++]=r);return t.outputNode||null}get hasOutput(){return this.outputNode&&this.outputNode.isNode}build(e,...t){const n=e.currentStack,r=Lx();Jy(this),e.currentStack=this;const o=e.buildStage;for(const c of this.nodes)if(!(c.isVarNode&&c.intent===!0&&e.getNodeProperties(c).assign!==!0)){if(o==="setup")c.build(e);else if(o==="analyze")c.build(e,this);else if(o==="generate"){const u=e.getDataFromNode(c,"any").stages,d=u&&u[e.shaderStage];if(c.isVarNode&&d&&d.length===1&&d[0]&&d[0].isStackNode)continue;c.build(e,"void")}}let a;return this.hasOutput?a=this.outputNode.build(e,...t):a=super.build(e,...t),Jy(r),e.currentStack=n,a}}const xv=xn(S5).setParameterLength(0,1);function T5(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 w5 extends kt{static get type(){return"StructTypeNode"}constructor(e,t=null){super("struct"),this.membersLayout=T5(e),this.name=t,this.isStructLayoutNode=!0}getLength(){const t=Float32Array.BYTES_PER_ELEMENT;let n=0;for(const r of this.membersLayout){const o=r.type,a=PE(o)*t,c=IE(o),u=n%8,d=u%c,p=u+d;n+=d,p!==0&&8-p<a&&(n+=8-p),n+=a}return Math.ceil(n/8)*8/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 M5 extends kt{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 A5=(i,e=null)=>{const t=new w5(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 Ge(new M5(t,o))};return n.layout=t,n.isStruct=!0,n};class qP extends kt{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 E5=xn(qP);function XP(i,e){for(let t=0;t<i.length;t++)if(i[t].name===e)return t;return-1}class C5 extends qP{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=Ii(Ii({},this.outputNodes),e.outputNodes);return jP(t)}setup(e){const t=this.outputNodes,n=e.renderer.getRenderTarget(),r=[],o=n.textures;for(const a in t){const c=XP(o,a);r[c]=Lt(t[a])}return this.members=r,super.setup(e)}}const jP=xn(C5);class T_ extends Rs{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 R5=ft(T_).setParameterLength(2),N5=i=>new T_(i,"int","float"),P5=i=>new T_(i,"uint","float"),I5=i=>new T_(i,"float","int"),L5=i=>new T_(i,"float","uint"),D5=de(([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/hb(2,32))}),iM=(i,e)=>Xa(En(4,i.mul(Qn(1,i))),e),F5=(i,e)=>i.lessThan(.5)?iM(i.mul(2),e).div(2):Qn(1,iM(En(Qn(1,i),2),e).div(2)),B5=(i,e,t)=>Xa(la(Xa(i,e),Gs(Xa(i,e),Xa(Qn(1,i),t))),1/e),O5=(i,e)=>ca(Hx.mul(e.mul(i).sub(1))).div(Hx.mul(e.mul(i).sub(1))),Ou=de(([i])=>i.fract().sub(.5).abs()).setLayout({name:"tri",type:"float",inputs:[{name:"x",type:"float"}]}),U5=de(([i])=>ue(Ou(i.z.add(Ou(i.y.mul(1)))),Ou(i.z.add(Ou(i.x.mul(1)))),Ou(i.y.add(Ou(i.x.mul(1)))))).setLayout({name:"tri3",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),k5=de(([i,e,t])=>{const n=ue(i).toVar(),r=$(1.4).toVar(),o=$(0).toVar(),a=ue(n).toVar();return wi({start:$(0),end:$(3),type:"float",condition:"<="},()=>{const c=ue(U5(a.mul(2))).toVar();n.addAssign(c.add(t.mul($(.1).mul(e)))),a.mulAssign(1.8),r.mulAssign(1.5),n.mulAssign(1.2);const u=$(Ou(n.z.add(Ou(n.x.add(Ou(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 z5 extends kt{static get type(){return"FunctionOverloadingNode"}constructor(e=[],...t){super(),this.functionNodes=e,this.parametersNodes=t,this._candidateFnCall=null,this.global=!0}getNodeType(){return this.functionNodes[0].shaderNode.layout.type}setup(e){const t=this.parametersNodes;let n=this._candidateFnCall;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=0}p>o&&(r=a,o=p)}}this._candidateFnCall=n=r(...t)}return n}}const V5=xn(z5),Dr=i=>(...e)=>V5(i,...e),$m=Jt(0).setGroup(Zt).onRenderUpdate(i=>i.time),G5=Jt(0).setGroup(Zt).onRenderUpdate(i=>i.deltaTime),YP=Jt(0,"uint").setGroup(Zt).onRenderUpdate(i=>i.frameId),H5=(i=$m)=>i.add(.75).mul(Math.PI*2).sin().mul(.5).add(.5),W5=(i=$m)=>i.fract().round(),$5=(i=$m)=>i.add(.5).fract().mul(2).sub(1).abs(),q5=(i=$m)=>i.fract(),X5=de(([i,e,t=Xe(.5)])=>x_(i.sub(t),e).add(t)),j5=de(([i,e,t=Xe(.5)])=>{const n=i.sub(t),r=n.dot(n),a=r.mul(r).mul(e);return i.add(n.mul(a))}),Y5=de(({position:i=null,horizontal:e=!0,vertical:t=!1})=>{let n;i!==null?(n=Ja.toVar(),n[3][0]=i.x,n[3][1]=i.y,n[3][2]=i.z):n=Ja;const r=ua.mul(n);return Zy(e)&&(r[0][0]=Ja[0].length(),r[0][1]=0,r[0][2]=0),Zy(t)&&(r[1][0]=0,r[1][1]=Ja[1].length(),r[1][2]=0),r[2][0]=0,r[2][1]=0,r[2][2]=1,Za.mul(r).mul(Ps)}),Z5=de(([i=null])=>{const e=Vm();return Vm(Aw(i)).sub(e).lessThan(0).select(Iu,i)});class K5 extends kt{static get type(){return"SpriteSheetUVNode"}constructor(e,t=Ri(),n=$(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=Xe(c,u);return t.add(p).mul(d)}}const J5=xn(K5).setParameterLength(3),ZP=de(([i,e=null,t=null,n=$(1),r=Ps,o=Fo])=>{let a=o.abs().normalize();a=a.div(a.dot(ue(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=Kn(p,c).mul(a.x),v=Kn(m,u).mul(a.y),M=Kn(y,d).mul(a.z);return Gs(x,v,M)}),Q5=(...i)=>ZP(...i),qm=new Rr,Qf=new W,Xm=new W,sM=new W,w_=new Vt,vv=new W(0,0,-1),_c=new an,M_=new W,bv=new W,A_=new an,Sv=new Ie,Tv=new Mr,eH=Iu.flipX();Tv.depthTexture=new Ao(1,1);let wv=!1;class rM extends yc{static get type(){return"ReflectorNode"}constructor(e={}){super(e.defaultTexture||Tv.texture,eH),this._reflectorBaseNode=e.reflector||new tH(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=Ge(new rM({defaultTexture:Tv.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._reflectorBaseNode=this._reflectorBaseNode,e}dispose(){super.dispose(),this._reflectorBaseNode.dispose()}}class tH extends kt{static get type(){return"ReflectorBaseNode"}constructor(e,t={}){super();const{target:n=new Hi,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&&(wr('THREE.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?In.RENDER:In.FRAME,this.virtualCameras=new WeakMap,this.renderTargets=new Map,this.forceUpdate=!1,this.hasOutput=!1}_updateResolution(e,t){const n=this.resolutionScale;t.getDrawingBufferSize(Sv),e.setSize(Math.round(Sv.width*n),Math.round(Sv.height*n))}setup(e){return this._updateResolution(Tv,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 Mr(0,0,{type:Ts,samples:this.samples}),this.generateMipmaps===!0&&(t.texture.minFilter=C1,t.texture.generateMipmaps=!0),this.depth===!0&&(t.depthTexture=new Ao),this.renderTargets.set(e,t)),t}updateBefore(e){if(this.bounces===!1&&wv)return!1;wv=!0;const{scene:t,camera:n,renderer:r,material:o}=e,{target:a}=this,c=this.getVirtualCamera(n),u=this.getRenderTarget(c);r.getDrawingBufferSize(Sv),this._updateResolution(u,r),Xm.setFromMatrixPosition(a.matrixWorld),sM.setFromMatrixPosition(n.matrixWorld),w_.extractRotation(a.matrixWorld),Qf.set(0,0,1),Qf.applyMatrix4(w_),M_.subVectors(Xm,sM);const d=M_.dot(Qf)>0;let p=!1;if(d===!0&&this.forceUpdate===!1){if(this.hasOutput===!1){wv=!1;return}p=!0}M_.reflect(Qf).negate(),M_.add(Xm),w_.extractRotation(n.matrixWorld),vv.set(0,0,-1),vv.applyMatrix4(w_),vv.add(sM),bv.subVectors(Xm,vv),bv.reflect(Qf).negate(),bv.add(Xm),c.coordinateSystem=n.coordinateSystem,c.position.copy(M_),c.up.set(0,1,0),c.up.applyMatrix4(w_),c.up.reflect(Qf),c.lookAt(bv),c.near=n.near,c.far=n.far,c.updateMatrixWorld(),c.projectionMatrix.copy(n.projectionMatrix),qm.setFromNormalAndCoplanarPoint(Qf,Xm),qm.applyMatrix4(c.matrixWorldInverse),_c.set(qm.normal.x,qm.normal.y,qm.normal.z,qm.constant);const m=c.projectionMatrix;A_.x=(Math.sign(_c.x)+m.elements[8])/m.elements[0],A_.y=(Math.sign(_c.y)+m.elements[9])/m.elements[5],A_.z=-1,A_.w=(1+m.elements[10])/m.elements[14],_c.multiplyScalar(1/_c.dot(A_));const y=0;m.elements[2]=_c.x,m.elements[6]=_c.y,m.elements[10]=r.coordinateSystem===Sr?_c.z-y:_c.z+1-y,m.elements[14]=_c.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(),M=r.autoClear;r.setMRT(null),r.setRenderTarget(u),r.autoClear=!0,p?(r.clear(),this.hasOutput=!1):(r.render(t,c),this.hasOutput=!0),r.setMRT(v),r.setRenderTarget(x),r.autoClear=M,o.visible=!0,wv=!1,this.forceUpdate=!1}get resolution(){return wr('THREE.ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale}set resolution(e){wr('THREE.ReflectorNode: The "resolution" property has been renamed to "resolutionScale".'),this.resolutionScale=e}}const nH=i=>Ge(new rM(i)),oM=new Jh(-1,1,1,-1,0,1);class iH 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 $t([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new $t(t,2))}}const sH=new iH;class E_ extends vi{constructor(e=null){super(sH,e),this.camera=oM,this.isQuadMesh=!0}renderAsync(e){return en(this,null,function*(){return e.renderAsync(this,oM)})}render(e){e.render(this,oM)}}const rH=new Ie;class oH extends yc{static get type(){return"RTTNode"}constructor(e,t=null,n=null,r={type:Ts}){const o=new Mr(t,n,r);super(o.texture,Ri()),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 E_(new _s),this.updateBeforeType=In.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 n=e.getPixelRatio(),r=e.getSize(rH),o=r.width*n,a=r.height*n;(o!==this.renderTarget.width||a!==this.renderTarget.height)&&(this.renderTarget.setSize(o,a),this.textureNeedsUpdate=!0)}this._quadMesh.material.fragmentNode=this._rttNode;const t=e.getRenderTarget();e.setRenderTarget(this.renderTarget),this._quadMesh.render(e),e.setRenderTarget(t)}clone(){const e=new yc(this.value,this.uvNode,this.levelNode);return e.sampler=this.sampler,e.referenceNode=this,e}}const KP=(i,...e)=>Ge(new oH(Ge(i),...e)),aH=(i,...e)=>i.isSampleNode||i.isTextureNode?i:i.isPassNode?i.getTextureNode():KP(i,...e),jm=de(([i,e,t],n)=>{let r;n.renderer.coordinateSystem===Sr?(i=Xe(i.x,i.y.oneMinus()).mul(2).sub(1),r=Lt(ue(i,e),1)):r=Lt(ue(i.x,i.y.oneMinus(),e).mul(2).sub(1),1);const o=Lt(t.mul(r));return o.xyz.div(o.w)}),lH=de(([i,e])=>{const t=e.mul(Lt(i,1)),n=t.xy.div(t.w).mul(.5).add(.5).toVar();return Xe(n.x,n.y.oneMinus())}),cH=de(([i,e,t])=>{const n=cd(Ns(e)),r=or(i.mul(n)).toVar(),o=Ns(e,r).toVar(),a=Ns(e,r.sub(or(2,0))).toVar(),c=Ns(e,r.sub(or(1,0))).toVar(),u=Ns(e,r.add(or(1,0))).toVar(),d=Ns(e,r.add(or(2,0))).toVar(),p=Ns(e,r.add(or(0,2))).toVar(),m=Ns(e,r.add(or(0,1))).toVar(),y=Ns(e,r.sub(or(0,1))).toVar(),x=Ns(e,r.sub(or(0,2))).toVar(),v=zi(Qn($(2).mul(c).sub(a),o)).toVar(),M=zi(Qn($(2).mul(u).sub(d),o)).toVar(),T=zi(Qn($(2).mul(m).sub(p),o)).toVar(),S=zi(Qn($(2).mul(y).sub(x),o)).toVar(),N=jm(i,o,t).toVar(),R=v.lessThan(M).select(N.sub(jm(i.sub(Xe($(1).div(n.x),0)),c,t)),N.negate().add(jm(i.add(Xe($(1).div(n.x),0)),u,t))),P=T.lessThan(S).select(N.sub(jm(i.add(Xe(0,$(1).div(n.y))),m,t)),N.negate().add(jm(i.sub(Xe(0,$(1).div(n.y))),y,t)));return Eu(jx(R,P))});class uH extends kt{static get type(){return"SampleNode"}constructor(e,t=null){super(),this.callback=e,this.uvNode=t,this.isSampleNode=!0}setup(){return this.sample(Ri())}sample(e){return this.callback(e)}}const hH=(i,e=null)=>Ge(new uH(i,Ge(e)));class gd extends kt{static get type(){return"EventNode"}constructor(e,t){super("void"),this.eventType=e,this.callback=t,e===gd.OBJECT?this.updateType=In.OBJECT:e===gd.MATERIAL&&(this.updateType=In.RENDER)}update(e){this.callback(e)}}gd.OBJECT="object",gd.MATERIAL="material";const JP=(i,e)=>Ge(new gd(i,e)).toStack(),dH=i=>JP(gd.OBJECT,i),fH=i=>JP(gd.MATERIAL,i);class pH extends ea{constructor(e,t,n=Float32Array){const r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageInstancedBufferAttribute=!0}}class mH extends $n{constructor(e,t,n=Float32Array){const r=ArrayBuffer.isView(e)?e:new n(e*t);super(r,t),this.isStorageBufferAttribute=!0}}const gH=(i,e="float")=>{let t,n;e.isStruct===!0?(t=e.layout.getLength(),n=Xy("float")):(t=fT(e),n=Xy(e));const r=new mH(i,t,n);return jf(r,e,i)},yH=(i,e="float")=>{let t,n;e.isStruct===!0?(t=e.layout.getLength(),n=Xy("float")):(t=fT(e),n=Xy(e));const r=new pH(i,t,n);return jf(r,e,i)};class _H extends kt{static get type(){return"PointUVNode"}constructor(){super("vec2"),this.isPointUVNode=!0}generate(){return"vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y )"}}const xH=xt(_H),C_=new Gr,aM=new Vt;class Oo extends kt{static get type(){return"SceneNode"}constructor(e=Oo.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===Oo.BACKGROUND_BLURRINESS?r=Fi("backgroundBlurriness","float",n):t===Oo.BACKGROUND_INTENSITY?r=Fi("backgroundIntensity","float",n):t===Oo.BACKGROUND_ROTATION?r=Jt("mat4").setName("backgroundRotation").setGroup(Zt).onRenderUpdate(()=>{const o=n.background;return o!==null&&o.isTexture&&o.mapping!==$u?(C_.copy(n.backgroundRotation),C_.x*=-1,C_.y*=-1,C_.z*=-1,aM.makeRotationFromEuler(C_)):aM.identity(),aM}):console.error("THREE.SceneNode: Unknown scope:",t),r}}Oo.BACKGROUND_BLURRINESS="backgroundBlurriness",Oo.BACKGROUND_INTENSITY="backgroundIntensity",Oo.BACKGROUND_ROTATION="backgroundRotation";const QP=xt(Oo,Oo.BACKGROUND_BLURRINESS),lM=xt(Oo,Oo.BACKGROUND_INTENSITY),eI=xt(Oo,Oo.BACKGROUND_ROTATION);class vH extends yc{static get type(){return"StorageTextureNode"}constructor(e,t,n=null){super(e,t),this.storeNode=n,this.isStorageTextureNode=!0,this.access=Ir.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}generate(e,t){let n;return this.storeNode!==null?n=this.generateStore(e):n=super.generate(e,t),n}toReadWrite(){return this.setAccess(Ir.READ_WRITE)}toReadOnly(){return this.setAccess(Ir.READ_ONLY)}toWriteOnly(){return this.setAccess(Ir.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}}const tI=xn(vH).setParameterLength(1,3),bH=(i,e,t)=>{const n=tI(i,e,t);return t!==null&&n.toStack(),n},SH=de(({texture:i,uv:e})=>{const n=ue().toVar();return Yt(e.x.lessThan(1e-4),()=>{n.assign(ue(1,0,0))}).ElseIf(e.y.lessThan(1e-4),()=>{n.assign(ue(0,1,0))}).ElseIf(e.z.lessThan(1e-4),()=>{n.assign(ue(0,0,1))}).ElseIf(e.x.greaterThan(1-1e-4),()=>{n.assign(ue(-1,0,0))}).ElseIf(e.y.greaterThan(1-1e-4),()=>{n.assign(ue(0,-1,0))}).ElseIf(e.z.greaterThan(1-1e-4),()=>{n.assign(ue(0,0,-1))}).Else(()=>{const o=i.sample(e.add(ue(-.01,0,0))).r.sub(i.sample(e.add(ue(.01,0,0))).r),a=i.sample(e.add(ue(0,-.01,0))).r.sub(i.sample(e.add(ue(0,.01,0))).r),c=i.sample(e.add(ue(0,0,-.01))).r.sub(i.sample(e.add(ue(0,0,.01))).r);n.assign(ue(o,a,c))}),n.normalize()});class TH extends yc{static get type(){return"Texture3DNode"}constructor(e,t=null,n=null){super(e,t,n),this.isTexture3DNode=!0}getInputType(){return"texture3D"}getDefaultUV(){return ue(.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(ie(cd(this,this.levelNode).y).sub(t.y).sub(1))),t}generateUV(e,t){return t.build(e,"vec3")}generateOffset(e,t){return t.build(e,"ivec3")}normal(e){return SH({texture:this,uv:e})}}const nI=xn(TH).setParameterLength(1,3);class wH extends nv{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 MH=(i,e,t)=>Ge(new wH(i,e,t)),iI=new WeakMap;class AH extends Rs{static get type(){return"VelocityNode"}constructor(){super("vec2"),this.projectionMatrix=null,this.updateType=In.OBJECT,this.updateAfterType=In.OBJECT,this.previousModelWorldMatrix=Jt(new Vt),this.previousProjectionMatrix=Jt(new Vt).setGroup(Zt),this.previousCameraViewMatrix=Jt(new Vt)}setProjectionMatrix(e){this.projectionMatrix=e}update({frameId:e,camera:t,object:n}){const r=rI(n);this.previousModelWorldMatrix.value.copy(r);const o=sI(t);o.frameId!==e&&(o.frameId=e,o.previousProjectionMatrix===void 0?(o.previousProjectionMatrix=new Vt,o.previousCameraViewMatrix=new Vt,o.currentProjectionMatrix=new Vt,o.currentCameraViewMatrix=new Vt,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}){rI(e).copy(e.matrixWorld)}setup(){const e=this.projectionMatrix===null?Za:Jt(this.projectionMatrix),t=this.previousCameraViewMatrix.mul(this.previousModelWorldMatrix),n=e.mul(Fu).mul(Ps),r=this.previousProjectionMatrix.mul(t).mul(Qx),o=n.xy.div(n.w),a=r.xy.div(r.w);return Qn(o,a)}}function sI(i){let e=iI.get(i);return e===void 0&&(e={},iI.set(i,e)),e}function rI(i,e=0){const t=sI(i);let n=t[e];return n===void 0&&(t[e]=n=new Vt,t[e].copy(i.matrixWorld)),n}const EH=xt(AH),CH=de(([i])=>cM(i.rgb)),RH=de(([i,e=$(1)])=>e.mix(cM(i.rgb),i.rgb)),NH=de(([i,e=$(1)])=>{const t=Gs(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)}),PH=de(([i,e=$(1)])=>{const t=ue(.57735,.57735,.57735),n=e.cos();return ue(i.rgb.mul(n).add(t.cross(i.rgb).mul(e.sin()).add(t.mul(ld(t,i.rgb).mul(n.oneMinus())))))}),cM=(i,e=ue(pn.getLuminanceCoefficients(new W)))=>ld(i,e),IH=de(([i,e=ue(1),t=ue(0),n=ue(1),r=$(1),o=ue(pn.getLuminanceCoefficients(new W,ol))])=>{const a=i.rgb.dot(ue(o)),c=ys(i.rgb.mul(e).add(t),0).toVar(),u=c.pow(n).toVar();return Yt(c.r.greaterThan(0),()=>{c.r.assign(u.r)}),Yt(c.g.greaterThan(0),()=>{c.g.assign(u.g)}),Yt(c.b.greaterThan(0),()=>{c.b.assign(u.b)}),c.assign(a.add(c.sub(a).mul(r))),Lt(c.rgb,i.a)});class LH extends Rs{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 DH=xn(LH).setParameterLength(2),Mv=new Ie;class oI extends yc{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 oI{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}}class xc extends Rs{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 Ao;o.isRenderTargetTexture=!0,o.name="depth";const a=new Mr(this._width*this._pixelRatio,this._height*this._pixelRatio,Ii({type:Ts},r));a.texture.name="output",a.depthTexture=o,this.renderTarget=a,this._textures={output:a.texture,depth:o},this._textureNodes={},this._linearDepthNodes={},this._viewZNodes={},this._previousTextures={},this._previousTextureNodes={},this._cameraNear=Jt(0),this._cameraFar=Jt(0),this._mrt=null,this._layers=null,this._resolution=1,this._viewport=null,this._scissor=null,this.isPassNode=!0,this.updateBeforeType=In.FRAME,this.global=!0}setResolution(e){return this._resolution=e,this}getResolution(){return this._resolution}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=Ge(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=Ge(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=Cw(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=zm(o,n,r)}return t}compileAsync(e){return en(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.getColorBufferType(),this.scope===xc.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),Mv.set(a.width,a.height)):(r=this.camera,o=t.getPixelRatio(),t.getSize(Mv)),this._pixelRatio=o,this.setSize(Mv.width,Mv.height);const c=t.getRenderTarget(),u=t.getMRT(),d=r.layers.mask;this._cameraNear.value=r.near,this._cameraFar.value=r.far,this._layers!==null&&(r.layers.mask=this._layers.mask);for(const p in this._previousTextures)this.toggleTexture(p);t.setRenderTarget(this.renderTarget),t.setMRT(this._mrt),t.render(n,r),t.setRenderTarget(c),t.setMRT(u),r.layers.mask=d}setSize(e,t){this._width=e,this._height=t;const n=this._width*this._pixelRatio*this._resolution,r=this._height*this._pixelRatio*this._resolution;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 an),e.isVector4?this._scissor.copy(e):this._scissor.set(e,t,n,r),this._scissor.multiplyScalar(this._pixelRatio*this._resolution).floor())}setViewport(e,t,n,r){e===null?this._viewport=null:(this._viewport===null&&(this._viewport=new an),e.isVector4?this._viewport.copy(e):this._viewport.set(e,t,n,r),this._viewport.multiplyScalar(this._pixelRatio*this._resolution).floor())}setPixelRatio(e){this._pixelRatio=e,this.setSize(this._width,this._height)}dispose(){this.renderTarget.dispose()}}xc.COLOR="color",xc.DEPTH="depth";const FH=(i,e,t)=>Ge(new xc(xc.COLOR,i,e,t)),BH=(i,e)=>Ge(new oI(i,e)),OH=(i,e,t)=>Ge(new xc(xc.DEPTH,i,e,t));class UH extends xc{static get type(){return"ToonOutlinePassNode"}constructor(e,t,n,r,o){super(xc.COLOR,e,t),this.colorNode=n,this.thicknessNode=r,this.alphaNode=o,this._materialCache=new WeakMap}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 _s;e.isMeshToonOutlineMaterial=!0,e.name="Toon_Outline",e.side=Ee;const t=Fo.negate(),n=Za.mul(Fu),r=$(1),o=n.mul(Lt(Ps,1)),a=n.mul(Lt(Ps.add(t),1)),c=Eu(o.sub(a));return e.vertexNode=o.add(c.mul(this.thicknessNode).mul(o.w).mul(r)),e.colorNode=Lt(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 kH=(i,e,t=new At(0,0,0),n=.003,r=1)=>Ge(new UH(i,e,Ge(t),Ge(n),Ge(r))),lI=de(([i,e])=>i.mul(e).clamp()).setLayout({name:"linearToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),cI=de(([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"}]}),uI=de(([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"}]}),zH=de(([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)}),hI=de(([i,e])=>{const t=qr(.59719,.35458,.04823,.076,.90834,.01566,.0284,.13383,.83777),n=qr(1.60475,-.53108,-.07367,-.10208,1.10813,-.00605,-.00327,-.07276,1.07602);return i=i.mul(e).div(.6),i=t.mul(i),i=zH(i),i=n.mul(i),i.clamp()}).setLayout({name:"acesFilmicToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),VH=qr(ue(1.6605,-.1246,-.0182),ue(-.5876,1.1329,-.1006),ue(-.0728,-.0083,1.1187)),GH=qr(ue(.6274,.0691,.0164),ue(.3293,.9195,.088),ue(.0433,.0113,.8956)),HH=de(([i])=>{const e=ue(i).toVar(),t=ue(e.mul(e)).toVar(),n=ue(t.mul(t)).toVar();return $(15.5).mul(n.mul(t)).sub(En(40.14,n.mul(e))).add(En(31.96,n).sub(En(6.868,t.mul(e))).add(En(.4298,t).add(En(.1191,e).sub(.00232))))}),dI=de(([i,e])=>{const t=ue(i).toVar(),n=qr(ue(.856627153315983,.137318972929847,.11189821299995),ue(.0951212405381588,.761241990602591,.0767994186031903),ue(.0482516061458583,.101439036467562,.811302368396859)),r=qr(ue(1.1271005818144368,-.1413297634984383,-.14132976349843826),ue(-.11060664309660323,1.157823702216272,-.11060664309660294),ue(-.016493938717834573,-.016493938717834257,1.2519364065950405)),o=$(-12.47393),a=$(4.026069);return t.mulAssign(e),t.assign(GH.mul(t)),t.assign(n.mul(t)),t.assign(ys(t,1e-10)),t.assign(dc(t)),t.assign(t.sub(o).div(a.sub(o))),t.assign(ja(t,0,1)),t.assign(HH(t)),t.assign(r.mul(t)),t.assign(Xa(ys(ue(0),t),ue(2.2))),t.assign(VH.mul(t)),t.assign(ja(t,0,1)),t}).setLayout({name:"agxToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]}),fI=de(([i,e])=>{const t=$(.76),n=$(.15);i=i.mul(e);const r=Do(i.r,Do(i.g,i.b)),o=_r(r.lessThan(.08),r.sub(En(6.25,r.mul(r))),.04);i.subAssign(o);const a=ys(i.r,ys(i.g,i.b));Yt(a.lessThan(t),()=>i);const c=Qn(1,t),u=Qn(1,c.mul(c).div(a.add(c.sub(t))));i.mulAssign(u.div(a));const d=Qn(1,la(1,n.mul(a.sub(u)).add(1)));return oi(i,ue(u),d)}).setLayout({name:"neutralToneMapping",type:"vec3",inputs:[{name:"color",type:"vec3"},{name:"exposure",type:"float"}]});class jr extends kt{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 Av=xn(jr).setParameterLength(1,3),WH=(i,e)=>Av(i,e,"js"),$H=(i,e)=>Av(i,e,"wgsl"),qH=(i,e)=>Av(i,e,"glsl");class pI extends jr{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 mI=(i,e=[],t="")=>{for(let o=0;o<e.length;o++){const a=e[o];typeof a=="function"&&(e[o]=a.functionNode)}const n=Ge(new pI(i,e,t)),r=(...o)=>n.call(...o);return r.functionNode=n,r},XH=(i,e)=>mI(i,e,"glsl"),jH=(i,e)=>mI(i,e,"wgsl");class YH extends kt{static get type(){return"ScriptableValueNode"}constructor(e=null){super(),this._value=e,this._cache=null,this.inputType=null,this.outputType=null,this.events=new wa,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:$()}serialize(e){super.serialize(e),this.value!==null?this.inputType==="ArrayBuffer"?e.value=mT(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=gT(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 Ev=xn(YH).setParameterLength(1);class gI 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 ZH{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 Cv=new gI;class KH extends kt{static get type(){return"ScriptableNode"}constructor(e=null,t={}){super(),this.codeNode=e,this.parameters=t,this._local=new gI,this._output=Ev(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]=Ev(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]=Ev(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 en(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 ZH(this),r=Cv.get("THREE"),o=Cv.get("TSL"),a=this.getMethod(),c=[n,this._local,Cv,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:$()}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=[uT(this.source),this.getDefaultOutputNode().getCacheKey(e)];for(const n in this.parameters)t.push(this.parameters[n].getCacheKey(e));return Wy(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 JH=xn(KH).setParameterLength(1,2);function yI(i){let e;const t=i.context.getViewZ;return t!==void 0&&(e=t(this)),(e||Is.z).negate()}const uM=de(([i,e],t)=>{const n=yI(t);return Ya(i,e,n)}),hM=de(([i],e)=>{const t=yI(e);return i.mul(i,t,t).negate().exp().oneMinus()}),R_=de(([i,e])=>Lt(e.toFloat().mix(Nm.rgb,i.toVec3()),Nm.a));function QH(i,e,t){return console.warn('THREE.TSL: "rangeFog( color, near, far )" is deprecated. Use "fog( color, rangeFogFactor( near, far ) )" instead.'),R_(i,uM(e,t))}function eW(i,e){return console.warn('THREE.TSL: "densityFog( color, density )" is deprecated. Use "fog( color, densityFogFactor( density ) )" instead.'),R_(i,hM(e))}let ep=null,tp=null;class tW extends kt{static get type(){return"RangeNode"}constructor(e=$(),t=$()){super(),this.minNode=e,this.maxNode=t}getVectorLength(e){const t=e.getTypeLength(Au(this.minNode.value)),n=e.getTypeLength(Au(this.maxNode.value));return t>n?t:n}getNodeType(e){return e.object.count>1?e.getTypeFromLength(this.getVectorLength(e)):"float"}setup(e){const t=e.object;let n=null;if(t.count>1){const r=this.minNode.value,o=this.maxNode.value,a=e.getTypeLength(Au(r)),c=e.getTypeLength(Au(o));ep=ep||new an,tp=tp||new an,ep.setScalar(0),tp.setScalar(0),a===1?ep.setScalar(r):r.isColor?ep.set(r.r,r.g,r.b,1):ep.set(r.x,r.y,r.z||0,r.w||0),c===1?tp.setScalar(o):o.isColor?tp.set(o.r,o.g,o.b,1):tp.set(o.x,o.y,o.z||0,o.w||0);const u=4,d=u*t.count,p=new Float32Array(d);for(let y=0;y<d;y++){const x=y%u,v=ep.getComponent(x),M=tp.getComponent(x);p[y]=Ld.lerp(v,M,Math.random())}const m=this.getNodeType(e);if(t.count<=4096)n=h_(p,"vec4",t.count).element(dd).convert(m);else{const y=new ea(p,4);e.geometry.setAttribute("__range"+this.id,y),n=Kx(y).convert(m)}}else n=$(0);return n}}const nW=xn(tW).setParameterLength(2);class iW extends kt{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):(console.warn(`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 N_=(i,e)=>Ge(new iW(i,e)),sW=N_("numWorkgroups","uvec3"),rW=N_("workgroupId","uvec3"),oW=N_("globalId","uvec3"),aW=N_("localId","uvec3"),lW=N_("subgroupSize","uint");class cW extends kt{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 dM=xn(cW),uW=()=>dM("workgroup").toStack(),hW=()=>dM("storage").toStack(),dW=()=>dM("texture").toStack();class fW extends kf{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 pW extends kt{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 console.warn('THREE.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 Ge(new fW(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 mW=(i,e)=>Ge(new pW("Workgroup",i,e));class ar extends kt{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=Nu(p,o).toConst()),t.constNode.build(e)}}ar.ATOMIC_LOAD="atomicLoad",ar.ATOMIC_STORE="atomicStore",ar.ATOMIC_ADD="atomicAdd",ar.ATOMIC_SUB="atomicSub",ar.ATOMIC_MAX="atomicMax",ar.ATOMIC_MIN="atomicMin",ar.ATOMIC_AND="atomicAnd",ar.ATOMIC_OR="atomicOr",ar.ATOMIC_XOR="atomicXor";const gW=xn(ar),vc=(i,e,t)=>gW(i,e,t).toStack(),yW=i=>vc(ar.ATOMIC_LOAD,i,null),_W=(i,e)=>vc(ar.ATOMIC_STORE,i,e),xW=(i,e)=>vc(ar.ATOMIC_ADD,i,e),vW=(i,e)=>vc(ar.ATOMIC_SUB,i,e),bW=(i,e)=>vc(ar.ATOMIC_MAX,i,e),SW=(i,e)=>vc(ar.ATOMIC_MIN,i,e),TW=(i,e)=>vc(ar.ATOMIC_AND,i,e),wW=(i,e)=>vc(ar.ATOMIC_OR,i,e),MW=(i,e)=>vc(ar.ATOMIC_XOR,i,e);class Et extends Rs{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===Et.SUBGROUP_ELECT?"bool":t===Et.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===Et.SUBGROUP_BROADCAST||n===Et.SUBGROUP_SHUFFLE||n===Et.QUAD_BROADCAST){const p=c.getNodeType(e);u.push(a.build(e,r),c.build(e,p==="float"?"int":r))}else n===Et.SUBGROUP_SHUFFLE_XOR||n===Et.SUBGROUP_SHUFFLE_DOWN||n===Et.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}}Et.SUBGROUP_ELECT="subgroupElect",Et.SUBGROUP_BALLOT="subgroupBallot",Et.SUBGROUP_ADD="subgroupAdd",Et.SUBGROUP_INCLUSIVE_ADD="subgroupInclusiveAdd",Et.SUBGROUP_EXCLUSIVE_AND="subgroupExclusiveAdd",Et.SUBGROUP_MUL="subgroupMul",Et.SUBGROUP_INCLUSIVE_MUL="subgroupInclusiveMul",Et.SUBGROUP_EXCLUSIVE_MUL="subgroupExclusiveMul",Et.SUBGROUP_AND="subgroupAnd",Et.SUBGROUP_OR="subgroupOr",Et.SUBGROUP_XOR="subgroupXor",Et.SUBGROUP_MIN="subgroupMin",Et.SUBGROUP_MAX="subgroupMax",Et.SUBGROUP_ALL="subgroupAll",Et.SUBGROUP_ANY="subgroupAny",Et.SUBGROUP_BROADCAST_FIRST="subgroupBroadcastFirst",Et.QUAD_SWAP_X="quadSwapX",Et.QUAD_SWAP_Y="quadSwapY",Et.QUAD_SWAP_DIAGONAL="quadSwapDiagonal",Et.SUBGROUP_BROADCAST="subgroupBroadcast",Et.SUBGROUP_SHUFFLE="subgroupShuffle",Et.SUBGROUP_SHUFFLE_XOR="subgroupShuffleXor",Et.SUBGROUP_SHUFFLE_UP="subgroupShuffleUp",Et.SUBGROUP_SHUFFLE_DOWN="subgroupShuffleDown",Et.QUAD_BROADCAST="quadBroadcast";const AW=ft(Et,Et.SUBGROUP_ELECT).setParameterLength(0),EW=ft(Et,Et.SUBGROUP_BALLOT).setParameterLength(1),CW=ft(Et,Et.SUBGROUP_ADD).setParameterLength(1),RW=ft(Et,Et.SUBGROUP_INCLUSIVE_ADD).setParameterLength(1),NW=ft(Et,Et.SUBGROUP_EXCLUSIVE_AND).setParameterLength(1),PW=ft(Et,Et.SUBGROUP_MUL).setParameterLength(1),IW=ft(Et,Et.SUBGROUP_INCLUSIVE_MUL).setParameterLength(1),LW=ft(Et,Et.SUBGROUP_EXCLUSIVE_MUL).setParameterLength(1),DW=ft(Et,Et.SUBGROUP_AND).setParameterLength(1),FW=ft(Et,Et.SUBGROUP_OR).setParameterLength(1),BW=ft(Et,Et.SUBGROUP_XOR).setParameterLength(1),OW=ft(Et,Et.SUBGROUP_MIN).setParameterLength(1),UW=ft(Et,Et.SUBGROUP_MAX).setParameterLength(1),kW=ft(Et,Et.SUBGROUP_ALL).setParameterLength(0),zW=ft(Et,Et.SUBGROUP_ANY).setParameterLength(0),VW=ft(Et,Et.SUBGROUP_BROADCAST_FIRST).setParameterLength(2),GW=ft(Et,Et.QUAD_SWAP_X).setParameterLength(1),HW=ft(Et,Et.QUAD_SWAP_Y).setParameterLength(1),WW=ft(Et,Et.QUAD_SWAP_DIAGONAL).setParameterLength(1),$W=ft(Et,Et.SUBGROUP_BROADCAST).setParameterLength(2),qW=ft(Et,Et.SUBGROUP_SHUFFLE).setParameterLength(2),XW=ft(Et,Et.SUBGROUP_SHUFFLE_XOR).setParameterLength(2),jW=ft(Et,Et.SUBGROUP_SHUFFLE_UP).setParameterLength(2),YW=ft(Et,Et.SUBGROUP_SHUFFLE_DOWN).setParameterLength(2),ZW=ft(Et,Et.QUAD_BROADCAST).setParameterLength(1);let Rv;function Nv(i){Rv=Rv||new WeakMap;let e=Rv.get(i);return e===void 0&&Rv.set(i,e={}),e}function Pv(i){const e=Nv(i);return e.shadowMatrix||(e.shadowMatrix=Jt("mat4").setGroup(Zt).onRenderUpdate(t=>((i.castShadow!==!0||t.renderer.shadowMap.enabled===!1)&&i.shadow.updateMatrices(i),i.shadow.matrix)))}function _I(i,e=ha){const t=Pv(i).mul(e);return t.xyz.div(t.w)}function fM(i){const e=Nv(i);return e.position||(e.position=Jt(new W).setGroup(Zt).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(i.matrixWorld)))}function xI(i){const e=Nv(i);return e.targetPosition||(e.targetPosition=Jt(new W).setGroup(Zt).onRenderUpdate((t,n)=>n.value.setFromMatrixPosition(i.target.matrixWorld)))}function pM(i){const e=Nv(i);return e.viewPosition||(e.viewPosition=Jt(new W).setGroup(Zt).onRenderUpdate(({camera:t},n)=>{n.value=n.value||new W,n.value.setFromMatrixPosition(i.matrixWorld),n.value.applyMatrix4(t.matrixWorldInverse)}))}const mM=i=>ua.transformDirection(fM(i).sub(xI(i))),KW=i=>i.sort((e,t)=>e.id-t.id),JW=(i,e)=>{for(const t of e)if(t.isAnalyticLightNode&&t.light.id===i)return t;return null},gM=new WeakMap,P_=[];class yM extends kt{static get type(){return"LightsNode"}constructor(){super("vec3"),this.totalDiffuseNode=El("vec3","totalDiffuse"),this.totalSpecularNode=El("vec3","totalSpecular"),this.outgoingLightNode=El("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(P_.push(r.id),P_.push(r.castShadow?1:0),r.isSpotLight===!0){const o=r.map!==null?r.map.id:-1,a=r.colorNode?r.colorNode.getCacheKey():-1;P_.push(o,a)}}const t=Wy(P_);return P_.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=KW(this._lights),o=e.renderer.library;for(const a of r)if(a.isNode)t.push(Ge(a));else{let c=null;if(n!==null&&(c=JW(a.id,n)),c===null){const u=o.getLightNodeClass(a.constructor);if(u===null){console.warn(`LightsNode.setupNodeLights: Light node not found for ${a.constructor.name}`);continue}let d=null;gM.has(a)?d=gM.get(a):(d=Ge(new u(a)),gM.set(a,d)),t.push(d)}}this._lightNodes=t}setupDirectLight(e,t,n){const{lightingModel:r,reflectedLight:o}=e.context;r.direct(_a(Ii({},n),{lightNode:t,reflectedLight:o}),e)}setupDirectRectAreaLight(e,t,n){const{lightingModel:r,reflectedLight:o}=e.context;r.directRectArea(_a(Ii({},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:M}=r.reflectedLight;let T=y.add(v);p!==null&&(m!==null?T=ue(m.mix(T,p)):T=ue(p),r.material.transparent=!0),c.assign(T),u.assign(x.add(M)),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 QW=(i=[])=>Ge(new yM).setLights(i);class e6 extends kt{static get type(){return"ShadowBaseNode"}constructor(e){super(),this.light=e,this.updateBeforeType=In.RENDER,this.isShadowBaseNode=!0}setupShadowPosition({context:e,material:t}){_M.assign(t.receivedShadowPositionNode||e.shadowPositionWorld||ha)}}const _M=El("vec3","shadowPositionWorld");function xM(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 At),e.clearAlpha=i.getClearAlpha(),e.autoClear=i.autoClear,e.scissorTest=i.getScissorTest(),e}function vI(i,e){return e=xM(i,e),i.setMRT(null),i.setRenderObjectFunction(null),i.setClearColor(0,1),i.autoClear=!0,e}function bI(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 vM(i,e={}){return e.background=i.background,e.backgroundNode=i.backgroundNode,e.overrideMaterial=i.overrideMaterial,e}function SI(i,e){return e=vM(i,e),i.background=null,i.backgroundNode=null,i.overrideMaterial=null,e}function TI(i,e){i.background=e.background,i.backgroundNode=e.backgroundNode,i.overrideMaterial=e.overrideMaterial}function t6(i,e,t={}){return t=xM(i,t),t=vM(e,t),t}function wI(i,e,t){return t=vI(i,t),t=SI(e,t),t}function MI(i,e,t){bI(i,t),TI(e,t)}var fZ=Object.freeze({__proto__:null,resetRendererAndSceneState:wI,resetRendererState:vI,resetSceneState:SI,restoreRendererAndSceneState:MI,restoreRendererState:bI,restoreSceneState:TI,saveRendererAndSceneState:t6,saveRendererState:xM,saveSceneState:vM});const AI=new WeakMap,EI=de(({depthTexture:i,shadowCoord:e,depthLayer:t})=>{let n=Kn(i,e.xy).setName("t_basic");return i.isArrayTexture&&(n=n.depth(t)),n.compare(e.z)}),CI=de(({depthTexture:i,shadowCoord:e,shadow:t,depthLayer:n})=>{const r=(T,S)=>{let N=Kn(i,T);return i.isArrayTexture&&(N=N.depth(n)),N.compare(S)},o=Fi("mapSize","vec2",t).setGroup(Zt),a=Fi("radius","float",t).setGroup(Zt),c=Xe(1).div(o),u=c.x.negate().mul(a),d=c.y.negate().mul(a),p=c.x.mul(a),m=c.y.mul(a),y=u.div(2),x=d.div(2),v=p.div(2),M=m.div(2);return Gs(r(e.xy.add(Xe(u,d)),e.z),r(e.xy.add(Xe(0,d)),e.z),r(e.xy.add(Xe(p,d)),e.z),r(e.xy.add(Xe(y,x)),e.z),r(e.xy.add(Xe(0,x)),e.z),r(e.xy.add(Xe(v,x)),e.z),r(e.xy.add(Xe(u,0)),e.z),r(e.xy.add(Xe(y,0)),e.z),r(e.xy,e.z),r(e.xy.add(Xe(v,0)),e.z),r(e.xy.add(Xe(p,0)),e.z),r(e.xy.add(Xe(y,M)),e.z),r(e.xy.add(Xe(0,M)),e.z),r(e.xy.add(Xe(v,M)),e.z),r(e.xy.add(Xe(u,m)),e.z),r(e.xy.add(Xe(0,m)),e.z),r(e.xy.add(Xe(p,m)),e.z)).mul(1/17)}),RI=de(({depthTexture:i,shadowCoord:e,shadow:t,depthLayer:n})=>{const r=(m,y)=>{let x=Kn(i,m);return i.isArrayTexture&&(x=x.depth(n)),x.compare(y)},o=Fi("mapSize","vec2",t).setGroup(Zt),a=Xe(1).div(o),c=a.x,u=a.y,d=e.xy,p=Cu(d.mul(o).add(.5));return d.subAssign(p.mul(a)),Gs(r(d,e.z),r(d.add(Xe(c,0)),e.z),r(d.add(Xe(0,u)),e.z),r(d.add(a),e.z),oi(r(d.add(Xe(c.negate(),0)),e.z),r(d.add(Xe(c.mul(2),0)),e.z),p.x),oi(r(d.add(Xe(c.negate(),u)),e.z),r(d.add(Xe(c.mul(2),u)),e.z),p.x),oi(r(d.add(Xe(0,u.negate())),e.z),r(d.add(Xe(0,u.mul(2))),e.z),p.y),oi(r(d.add(Xe(c,u.negate())),e.z),r(d.add(Xe(c,u.mul(2))),e.z),p.y),oi(oi(r(d.add(Xe(c.negate(),u.negate())),e.z),r(d.add(Xe(c.mul(2),u.negate())),e.z),p.x),oi(r(d.add(Xe(c.negate(),u.mul(2))),e.z),r(d.add(Xe(c.mul(2),u.mul(2))),e.z),p.x),p.y)).mul(1/9)}),NI=de(({depthTexture:i,shadowCoord:e,depthLayer:t})=>{const n=$(1).toVar();let r=Kn(i).sample(e.xy);i.isArrayTexture&&(r=r.depth(t)),r=r.rg;const o=Xx(e.z,r.x);return Yt(o.notEqual($(1)),()=>{const a=e.z.sub(r.x),c=ys(0,r.y.mul(r.y));let u=c.div(c.add(a.mul(a)));u=ja(Qn(u,.3).div(.95-.3)),n.assign(ja(ys(o,u)))}),n}),n6=de(([i,e,t])=>{let n=ha.sub(i).length();return n=n.sub(e).div(t.sub(e)),n=n.saturate(),n}),i6=i=>{const e=i.shadow.camera,t=Fi("near","float",e).setGroup(Zt),n=Fi("far","float",e).setGroup(Zt),r=wR(i);return n6(r,t,n)},PI=i=>{let e=AI.get(i);if(e===void 0){const t=i.isPointLight?i6(i):null;e=new _s,e.colorNode=Lt(0,0,0,1),e.depthNode=t,e.isShadowPassMaterial=!0,e.name="ShadowMaterial",e.fog=!1,AI.set(i,e)}return e},II=new Cl,Ym=[],LI=(i,e,t,n)=>{Ym[0]=i,Ym[1]=e;let r=II.get(Ym);return(r===void 0||r.shadowType!==t||r.useVelocity!==n)&&(r=(o,a,c,u,d,p,...m)=>{(o.castShadow===!0||o.receiveShadow&&t===le)&&(n&&(pT(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,II.set(Ym,r)),Ym[0]=null,Ym[1]=null,r},s6=de(({samples:i,radius:e,size:t,shadowPass:n,depthLayer:r})=>{const o=$(0).toVar("meanVertical"),a=$(0).toVar("squareMeanVertical"),c=i.lessThanEqual($(1)).select($(0),$(2).div(i.sub(1))),u=i.lessThanEqual($(1)).select($(0),$(-1));wi({start:ie(0),end:ie(i),type:"int",condition:"<"},({i:p})=>{const m=u.add($(p).mul(c));let y=n.sample(Gs(p_.xy,Xe(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=fc(a.sub(o.mul(o)));return Xe(o,d)}),r6=de(({samples:i,radius:e,size:t,shadowPass:n,depthLayer:r})=>{const o=$(0).toVar("meanHorizontal"),a=$(0).toVar("squareMeanHorizontal"),c=i.lessThanEqual($(1)).select($(0),$(2).div(i.sub(1))),u=i.lessThanEqual($(1)).select($(0),$(-1));wi({start:ie(0),end:ie(i),type:"int",condition:"<"},({i:p})=>{const m=u.add($(p).mul(c));let y=n.sample(Gs(p_.xy,Xe(m,0).mul(e)).div(t));n.value.isArrayTexture&&(y=y.depth(r)),o.addAssign(y.x),a.addAssign(Gs(y.y.mul(y.y),y.x.mul(y.x)))}),o.divAssign(i),a.divAssign(i);const d=fc(a.sub(o.mul(o)));return Xe(o,d)}),o6=[EI,CI,RI,NI];let bM;const Iv=new E_;class DI extends e6{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._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,$(1))}setupShadowCoord(e,t){const{shadow:n}=this,{renderer:r}=e,o=Fi("bias","float",n).setGroup(Zt);let a=t,c;if(n.camera.isOrthographicCamera||r.logarithmicDepthBuffer!==!0)a=a.xyz.div(a.w),c=a.z,r.coordinateSystem===Sr&&(c=c.mul(2).sub(1));else{const u=a.w;a=a.xy.div(u);const d=Fi("near","float",n.camera).setGroup(Zt),p=Fi("far","float",n.camera).setGroup(Zt);c=Rw(u.negate(),d,p)}return a=ue(a.x,a.y.oneMinus(),c.add(o)),a}getShadowFilterFn(e){return o6[e]}setupRenderTarget(e,t){const n=new Ao(e.mapSize.width,e.mapSize.height);n.name="ShadowDepthTexture",n.compareFunction=fg;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}=e,{light:n,shadow:r}=this,o=t.shadowMap.type,{depthTexture:a,shadowMap:c}=this.setupRenderTarget(r,e);if(r.camera.updateProjectionMatrix(),o===le&&r.isPointLightShadow!==!0){a.compareFunction=null,c.depth>1?(c._vsmShadowMapVertical||(c._vsmShadowMapVertical=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:rl,type:Ts,depth:c.depth,depthBuffer:!1}),c._vsmShadowMapVertical.texture.name="VSMVertical"),this.vsmShadowMapVertical=c._vsmShadowMapVertical,c._vsmShadowMapHorizontal||(c._vsmShadowMapHorizontal=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:rl,type:Ts,depth:c.depth,depthBuffer:!1}),c._vsmShadowMapHorizontal.texture.name="VSMHorizontal"),this.vsmShadowMapHorizontal=c._vsmShadowMapHorizontal):(this.vsmShadowMapVertical=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:rl,type:Ts,depthBuffer:!1}),this.vsmShadowMapHorizontal=e.createRenderTarget(r.mapSize.width,r.mapSize.height,{format:rl,type:Ts,depthBuffer:!1}));let S=Kn(a);a.isArrayTexture&&(S=S.depth(this.depthLayer));let N=Kn(this.vsmShadowMapVertical.texture);a.isArrayTexture&&(N=N.depth(this.depthLayer));const R=Fi("blurSamples","float",r).setGroup(Zt),P=Fi("radius","float",r).setGroup(Zt),B=Fi("mapSize","vec2",r).setGroup(Zt);let F=this.vsmMaterialVertical||(this.vsmMaterialVertical=new _s);F.fragmentNode=s6({samples:R,radius:P,size:B,shadowPass:S,depthLayer:this.depthLayer}).context(e.getSharedContext()),F.name="VSMVertical",F=this.vsmMaterialHorizontal||(this.vsmMaterialHorizontal=new _s),F.fragmentNode=r6({samples:R,radius:P,size:B,shadowPass:N,depthLayer:this.depthLayer}).context(e.getSharedContext()),F.name="VSMHorizontal"}const u=Fi("intensity","float",r).setGroup(Zt),d=Fi("normalBias","float",r).setGroup(Zt),p=Pv(n).mul(_M.add(hd.mul(d))),m=this.setupShadowCoord(e,p),y=r.filterNode||this.getShadowFilterFn(t.shadowMap.type)||null;if(y===null)throw new Error("THREE.WebGPURenderer: Shadow map type not supported yet.");const x=o===le&&r.isPointLightShadow!==!0?this.vsmShadowMapHorizontal.texture:a,v=this.setupShadowFilter(e,{filterFn:y,shadowTexture:c.texture,depthTexture:x,shadowCoord:m,shadow:r,depthLayer:this.depthLayer});let M=Kn(c.texture,m);a.isArrayTexture&&(M=M.depth(this.depthLayer));const T=oi(1,v.rgb.mix(M,1),u.mul(M.a)).toVar();return this.shadowMap=c,this.shadow.map=c,T}setup(e){if(e.renderer.shadowMap.enabled!==!1)return de(()=>{let t=this._node;return this.setupShadowPosition(e),t===null&&(this._node=t=this.setupShadow(e)),e.material.shadowNode&&console.warn('THREE.NodeMaterial: ".shadowNode" is deprecated. Use ".castShadowNode" instead.'),e.material.receivedShadowNode&&(t=e.material.receivedShadowNode(t)),t})()}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),o.render(a,t.camera)}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;bM=wI(o,a,bM),a.overrideMaterial=PI(n),o.setRenderObjectFunction(LI(o,r,u,x)),o.setClearColor(0,0),o.setRenderTarget(t),this.renderShadow(e),o.setRenderObjectFunction(m),u===le&&r.isPointLightShadow!==!0&&this.vsmPass(o),r.camera.layers.mask=p,MI(o,a,bM)}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),Iv.material=this.vsmMaterialVertical,Iv.render(e),e.setRenderTarget(this.vsmShadowMapHorizontal),Iv.material=this.vsmMaterialHorizontal,Iv.render(e)}dispose(){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),super.dispose()}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 FI=(i,e)=>Ge(new DI(i,e)),a6=new At,Rl=de(([i,e])=>{const t=i.toVar(),n=zi(t),r=la(1,ys(n.x,ys(n.y,n.z)));n.mulAssign(r),t.mulAssign(r.mul(e.mul(2).oneMinus()));const o=Xe(t.xy).toVar(),c=e.mul(1.5).oneMinus();return Yt(n.z.greaterThanEqual(c),()=>{Yt(t.z.greaterThan(0),()=>{o.x.assign(Qn(4,t.x))})}).ElseIf(n.x.greaterThanEqual(c),()=>{const u=a_(t.x);o.x.assign(t.z.mul(u).add(u.mul(2)))}).ElseIf(n.y.greaterThanEqual(c),()=>{const u=a_(t.y);o.x.assign(t.x.add(u.mul(2)).add(2)),o.y.assign(t.z.mul(u).sub(2))}),Xe(.125,.25).mul(o).add(Xe(.375,.75)).flipY()}).setLayout({name:"cubeToUV",type:"vec2",inputs:[{name:"pos",type:"vec3"},{name:"texelSizeY",type:"float"}]}),BI=de(({depthTexture:i,bd3D:e,dp:t,texelSize:n})=>Kn(i,Rl(e,n.y)).compare(t)),OI=de(({depthTexture:i,bd3D:e,dp:t,texelSize:n,shadow:r})=>{const o=Fi("radius","float",r).setGroup(Zt),a=Xe(-1,1).mul(o).mul(n.y);return Kn(i,Rl(e.add(a.xyy),n.y)).compare(t).add(Kn(i,Rl(e.add(a.yyy),n.y)).compare(t)).add(Kn(i,Rl(e.add(a.xyx),n.y)).compare(t)).add(Kn(i,Rl(e.add(a.yyx),n.y)).compare(t)).add(Kn(i,Rl(e,n.y)).compare(t)).add(Kn(i,Rl(e.add(a.xxy),n.y)).compare(t)).add(Kn(i,Rl(e.add(a.yxy),n.y)).compare(t)).add(Kn(i,Rl(e.add(a.xxx),n.y)).compare(t)).add(Kn(i,Rl(e.add(a.yxx),n.y)).compare(t)).mul(1/9)}),l6=de(({filterFn:i,depthTexture:e,shadowCoord:t,shadow:n})=>{const r=t.xyz.toVar(),o=r.length(),a=Jt("float").setGroup(Zt).onRenderUpdate(()=>n.camera.near),c=Jt("float").setGroup(Zt).onRenderUpdate(()=>n.camera.far),u=Fi("bias","float",n).setGroup(Zt),d=Jt(n.mapSize).setGroup(Zt),p=$(1).toVar();return Yt(o.sub(c).lessThanEqual(0).and(o.sub(a).greaterThanEqual(0)),()=>{const m=o.sub(a).div(c.sub(a)).toVar();m.addAssign(u);const y=r.normalize(),x=Xe(1).div(d.mul(Xe(4,2)));p.assign(i({depthTexture:e,bd3D:y,dp:m,texelSize:x,shadow:n}))}),p}),UI=new an,Zm=new Ie,I_=new Ie;class c6 extends DI{static get type(){return"PointShadowNode"}constructor(e,t=null){super(e,t)}getShadowFilterFn(e){return e===me?BI:OI}setupShadowCoord(e,t){return t}setupShadowFilter(e,{filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:o,shadow:a}){return l6({filterFn:t,shadowTexture:n,depthTexture:r,shadowCoord:o,shadow:a})}renderShadow(e){const{shadow:t,shadowMap:n,light:r}=this,{renderer:o,scene:a}=e,c=t.getFrameExtents();I_.copy(t.mapSize),I_.multiply(c),n.setSize(I_.width,I_.height),Zm.copy(t.mapSize);const u=o.autoClear,d=o.getClearColor(a6),p=o.getClearAlpha();o.autoClear=!1,o.setClearColor(t.clearColor,t.clearAlpha),o.clear();const m=t.getViewportCount();for(let y=0;y<m;y++){const x=t.getViewport(y),v=Zm.x*x.x,M=I_.y-Zm.y-Zm.y*x.y;UI.set(v,M,Zm.x*x.z,Zm.y*x.w),n.viewport.copy(UI),t.updateMatrices(r,y),o.render(a,t.camera)}o.autoClear=u,o.setClearColor(d,p)}}const kI=(i,e)=>Ge(new c6(i,e));class np extends Um{static get type(){return"AnalyticLightNode"}constructor(e=null){super(),this.light=e,this.color=new At,this.colorNode=e&&e.colorNode||Jt(this.color).setGroup(Zt),this.baseColorNode=null,this.shadowNode=null,this.shadowColorNode=null,this.isAnalyticLightNode=!0,this.updateType=In.FRAME}getHash(){return this.light.uuid}getLightVector(e){return pM(this.light).sub(e.context.positionView||Is)}setupDirect(){}setupDirectRectArea(){}setupShadowNode(){return FI(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=Ge(r):o=this.setupShadowNode(),this.shadowNode=o,this.shadowColorNode=n=this.colorNode.mul(o),this.baseColorNode=this.colorNode}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 SM=de(({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)}),zI=({color:i,lightVector:e,cutoffDistance:t,decayExponent:n})=>{const r=e.normalize(),o=e.length(),a=SM({lightDistance:o,cutoffDistance:t,decayExponent:n}),c=i.mul(a);return{lightDirection:r,lightColor:c}};class u6 extends np{static get type(){return"PointLightNode"}constructor(e=null){super(e),this.cutoffDistanceNode=Jt(0).setGroup(Zt),this.decayExponentNode=Jt(2).setGroup(Zt)}update(e){const{light:t}=this;super.update(e),this.cutoffDistanceNode.value=t.distance,this.decayExponentNode.value=t.decay}setupShadowNode(){return kI(this.light)}setupDirect(e){return zI({color:this.colorNode,lightVector:this.getLightVector(e),cutoffDistance:this.cutoffDistanceNode,decayExponent:this.decayExponentNode})}}const h6=de(([i=Ri()])=>{const e=i.mul(2),t=e.x.floor(),n=e.y.floor();return t.add(n).mod(2).sign()}),d6=de(([i=Ri()],{renderer:e,material:t})=>{const n=HT(i.mul(2).sub(1));let r;if(t.alphaToCoverage&&e.samples>1){const o=$(n.fwidth()).toVar();r=Ya(o.oneMinus(),o.add(1),n).oneMinus()}else r=_r(n.greaterThan(1),0,1);return r}),L_=de(([i,e,t])=>{const n=$(t).toVar(),r=$(e).toVar(),o=qa(i).toVar();return _r(o,r,n)}).setLayout({name:"mx_select",type:"float",inputs:[{name:"b",type:"bool"},{name:"t",type:"float"},{name:"f",type:"float"}]}),Lv=de(([i,e])=>{const t=qa(e).toVar(),n=$(i).toVar();return _r(t,n.negate(),n)}).setLayout({name:"mx_negate_if",type:"float",inputs:[{name:"val",type:"float"},{name:"b",type:"bool"}]}),Hs=de(([i])=>{const e=$(i).toVar();return ie(pc(e))}).setLayout({name:"mx_floor",type:"int",inputs:[{name:"x",type:"float"}]}),ss=de(([i,e])=>{const t=$(i).toVar();return e.assign(Hs(t)),t.sub($(e))}),VI=Dr([de(([i,e,t,n,r,o])=>{const a=$(o).toVar(),c=$(r).toVar(),u=$(n).toVar(),d=$(t).toVar(),p=$(e).toVar(),m=$(i).toVar(),y=$(Qn(1,c)).toVar();return Qn(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"}]}),de(([i,e,t,n,r,o])=>{const a=$(o).toVar(),c=$(r).toVar(),u=ue(n).toVar(),d=ue(t).toVar(),p=ue(e).toVar(),m=ue(i).toVar(),y=$(Qn(1,c)).toVar();return Qn(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"}]})]),GI=Dr([de(([i,e,t,n,r,o,a,c,u,d,p])=>{const m=$(p).toVar(),y=$(d).toVar(),x=$(u).toVar(),v=$(c).toVar(),M=$(a).toVar(),T=$(o).toVar(),S=$(r).toVar(),N=$(n).toVar(),R=$(t).toVar(),P=$(e).toVar(),B=$(i).toVar(),F=$(Qn(1,x)).toVar(),k=$(Qn(1,y)).toVar();return $(Qn(1,m)).toVar().mul(k.mul(B.mul(F).add(P.mul(x))).add(y.mul(R.mul(F).add(N.mul(x))))).add(m.mul(k.mul(S.mul(F).add(T.mul(x))).add(y.mul(M.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"}]}),de(([i,e,t,n,r,o,a,c,u,d,p])=>{const m=$(p).toVar(),y=$(d).toVar(),x=$(u).toVar(),v=ue(c).toVar(),M=ue(a).toVar(),T=ue(o).toVar(),S=ue(r).toVar(),N=ue(n).toVar(),R=ue(t).toVar(),P=ue(e).toVar(),B=ue(i).toVar(),F=$(Qn(1,x)).toVar(),k=$(Qn(1,y)).toVar();return $(Qn(1,m)).toVar().mul(k.mul(B.mul(F).add(P.mul(x))).add(y.mul(R.mul(F).add(N.mul(x))))).add(m.mul(k.mul(S.mul(F).add(T.mul(x))).add(y.mul(M.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"}]})]),xr=Dr([de(([i,e,t])=>{const n=$(t).toVar(),r=$(e).toVar(),o=Pt(i).toVar(),a=Pt(o.bitAnd(Pt(7))).toVar(),c=$(L_(a.lessThan(Pt(4)),r,n)).toVar(),u=$(En(2,L_(a.lessThan(Pt(4)),n,r))).toVar();return Lv(c,qa(a.bitAnd(Pt(1)))).add(Lv(u,qa(a.bitAnd(Pt(2)))))}).setLayout({name:"mx_gradient_float_0",type:"float",inputs:[{name:"hash",type:"uint"},{name:"x",type:"float"},{name:"y",type:"float"}]}),de(([i,e,t,n])=>{const r=$(n).toVar(),o=$(t).toVar(),a=$(e).toVar(),c=Pt(i).toVar(),u=Pt(c.bitAnd(Pt(15))).toVar(),d=$(L_(u.lessThan(Pt(8)),a,o)).toVar(),p=$(L_(u.lessThan(Pt(4)),o,L_(u.equal(Pt(12)).or(u.equal(Pt(14))),a,r))).toVar();return Lv(d,qa(u.bitAnd(Pt(1)))).add(Lv(p,qa(u.bitAnd(Pt(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"}]})]),tl=Dr([de(([i,e,t])=>{const n=$(t).toVar(),r=$(e).toVar(),o=Rm(i).toVar();return ue(xr(o.x,r,n),xr(o.y,r,n),xr(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"}]}),de(([i,e,t,n])=>{const r=$(n).toVar(),o=$(t).toVar(),a=$(e).toVar(),c=Rm(i).toVar();return ue(xr(c.x,a,o,r),xr(c.y,a,o,r),xr(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"}]})]),f6=de(([i])=>{const e=$(i).toVar();return En(.6616,e)}).setLayout({name:"mx_gradient_scale2d_0",type:"float",inputs:[{name:"v",type:"float"}]}),p6=de(([i])=>{const e=$(i).toVar();return En(.982,e)}).setLayout({name:"mx_gradient_scale3d_0",type:"float",inputs:[{name:"v",type:"float"}]}),HI=Dr([f6,de(([i])=>{const e=ue(i).toVar();return En(.6616,e)}).setLayout({name:"mx_gradient_scale2d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),WI=Dr([p6,de(([i])=>{const e=ue(i).toVar();return En(.982,e)}).setLayout({name:"mx_gradient_scale3d_1",type:"vec3",inputs:[{name:"v",type:"vec3"}]})]),fa=de(([i,e])=>{const t=ie(e).toVar(),n=Pt(i).toVar();return n.shiftLeft(t).bitOr(n.shiftRight(ie(32).sub(t)))}).setLayout({name:"mx_rotl32",type:"uint",inputs:[{name:"x",type:"uint"},{name:"k",type:"int"}]}),$I=de(([i,e,t])=>{i.subAssign(t),i.bitXorAssign(fa(t,ie(4))),t.addAssign(e),e.subAssign(i),e.bitXorAssign(fa(i,ie(6))),i.addAssign(t),t.subAssign(e),t.bitXorAssign(fa(e,ie(8))),e.addAssign(i),i.subAssign(t),i.bitXorAssign(fa(t,ie(16))),t.addAssign(e),e.subAssign(i),e.bitXorAssign(fa(i,ie(19))),i.addAssign(t),t.subAssign(e),t.bitXorAssign(fa(e,ie(4))),e.addAssign(i)}),D_=de(([i,e,t])=>{const n=Pt(t).toVar(),r=Pt(e).toVar(),o=Pt(i).toVar();return n.bitXorAssign(r),n.subAssign(fa(r,ie(14))),o.bitXorAssign(n),o.subAssign(fa(n,ie(11))),r.bitXorAssign(o),r.subAssign(fa(o,ie(25))),n.bitXorAssign(r),n.subAssign(fa(r,ie(16))),o.bitXorAssign(n),o.subAssign(fa(n,ie(4))),r.bitXorAssign(o),r.subAssign(fa(o,ie(14))),n.bitXorAssign(r),n.subAssign(fa(r,ie(24))),n}).setLayout({name:"mx_bjfinal",type:"uint",inputs:[{name:"a",type:"uint"},{name:"b",type:"uint"},{name:"c",type:"uint"}]}),Yr=de(([i])=>{const e=Pt(i).toVar();return $(e).div($(Pt(ie(4294967295))))}).setLayout({name:"mx_bits_to_01",type:"float",inputs:[{name:"bits",type:"uint"}]}),bc=de(([i])=>{const e=$(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"}]}),Ni=Dr([de(([i])=>{const e=ie(i).toVar(),t=Pt(Pt(1)).toVar(),n=Pt(Pt(ie(3735928559)).add(t.shiftLeft(Pt(2))).add(Pt(13))).toVar();return D_(n.add(Pt(e)),n,n)}).setLayout({name:"mx_hash_int_0",type:"uint",inputs:[{name:"x",type:"int"}]}),de(([i,e])=>{const t=ie(e).toVar(),n=ie(i).toVar(),r=Pt(Pt(2)).toVar(),o=Pt().toVar(),a=Pt().toVar(),c=Pt().toVar();return o.assign(a.assign(c.assign(Pt(ie(3735928559)).add(r.shiftLeft(Pt(2))).add(Pt(13))))),o.addAssign(Pt(n)),a.addAssign(Pt(t)),D_(o,a,c)}).setLayout({name:"mx_hash_int_1",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),de(([i,e,t])=>{const n=ie(t).toVar(),r=ie(e).toVar(),o=ie(i).toVar(),a=Pt(Pt(3)).toVar(),c=Pt().toVar(),u=Pt().toVar(),d=Pt().toVar();return c.assign(u.assign(d.assign(Pt(ie(3735928559)).add(a.shiftLeft(Pt(2))).add(Pt(13))))),c.addAssign(Pt(o)),u.addAssign(Pt(r)),d.addAssign(Pt(n)),D_(c,u,d)}).setLayout({name:"mx_hash_int_2",type:"uint",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]}),de(([i,e,t,n])=>{const r=ie(n).toVar(),o=ie(t).toVar(),a=ie(e).toVar(),c=ie(i).toVar(),u=Pt(Pt(4)).toVar(),d=Pt().toVar(),p=Pt().toVar(),m=Pt().toVar();return d.assign(p.assign(m.assign(Pt(ie(3735928559)).add(u.shiftLeft(Pt(2))).add(Pt(13))))),d.addAssign(Pt(c)),p.addAssign(Pt(a)),m.addAssign(Pt(o)),$I(d,p,m),d.addAssign(Pt(r)),D_(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"}]}),de(([i,e,t,n,r])=>{const o=ie(r).toVar(),a=ie(n).toVar(),c=ie(t).toVar(),u=ie(e).toVar(),d=ie(i).toVar(),p=Pt(Pt(5)).toVar(),m=Pt().toVar(),y=Pt().toVar(),x=Pt().toVar();return m.assign(y.assign(x.assign(Pt(ie(3735928559)).add(p.shiftLeft(Pt(2))).add(Pt(13))))),m.addAssign(Pt(d)),y.addAssign(Pt(u)),x.addAssign(Pt(c)),$I(m,y,x),m.addAssign(Pt(a)),y.addAssign(Pt(o)),D_(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"}]})]),nl=Dr([de(([i,e])=>{const t=ie(e).toVar(),n=ie(i).toVar(),r=Pt(Ni(n,t)).toVar(),o=Rm().toVar();return o.x.assign(r.bitAnd(ie(255))),o.y.assign(r.shiftRight(ie(8)).bitAnd(ie(255))),o.z.assign(r.shiftRight(ie(16)).bitAnd(ie(255))),o}).setLayout({name:"mx_hash_vec3_0",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"}]}),de(([i,e,t])=>{const n=ie(t).toVar(),r=ie(e).toVar(),o=ie(i).toVar(),a=Pt(Ni(o,r,n)).toVar(),c=Rm().toVar();return c.x.assign(a.bitAnd(ie(255))),c.y.assign(a.shiftRight(ie(8)).bitAnd(ie(255))),c.z.assign(a.shiftRight(ie(16)).bitAnd(ie(255))),c}).setLayout({name:"mx_hash_vec3_1",type:"uvec3",inputs:[{name:"x",type:"int"},{name:"y",type:"int"},{name:"z",type:"int"}]})]),TM=Dr([de(([i])=>{const e=Xe(i).toVar(),t=ie().toVar(),n=ie().toVar(),r=$(ss(e.x,t)).toVar(),o=$(ss(e.y,n)).toVar(),a=$(bc(r)).toVar(),c=$(bc(o)).toVar(),u=$(VI(xr(Ni(t,n),r,o),xr(Ni(t.add(ie(1)),n),r.sub(1),o),xr(Ni(t,n.add(ie(1))),r,o.sub(1)),xr(Ni(t.add(ie(1)),n.add(ie(1))),r.sub(1),o.sub(1)),a,c)).toVar();return HI(u)}).setLayout({name:"mx_perlin_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"}]}),de(([i])=>{const e=ue(i).toVar(),t=ie().toVar(),n=ie().toVar(),r=ie().toVar(),o=$(ss(e.x,t)).toVar(),a=$(ss(e.y,n)).toVar(),c=$(ss(e.z,r)).toVar(),u=$(bc(o)).toVar(),d=$(bc(a)).toVar(),p=$(bc(c)).toVar(),m=$(GI(xr(Ni(t,n,r),o,a,c),xr(Ni(t.add(ie(1)),n,r),o.sub(1),a,c),xr(Ni(t,n.add(ie(1)),r),o,a.sub(1),c),xr(Ni(t.add(ie(1)),n.add(ie(1)),r),o.sub(1),a.sub(1),c),xr(Ni(t,n,r.add(ie(1))),o,a,c.sub(1)),xr(Ni(t.add(ie(1)),n,r.add(ie(1))),o.sub(1),a,c.sub(1)),xr(Ni(t,n.add(ie(1)),r.add(ie(1))),o,a.sub(1),c.sub(1)),xr(Ni(t.add(ie(1)),n.add(ie(1)),r.add(ie(1))),o.sub(1),a.sub(1),c.sub(1)),u,d,p)).toVar();return WI(m)}).setLayout({name:"mx_perlin_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"}]})]),F_=Dr([de(([i])=>{const e=Xe(i).toVar(),t=ie().toVar(),n=ie().toVar(),r=$(ss(e.x,t)).toVar(),o=$(ss(e.y,n)).toVar(),a=$(bc(r)).toVar(),c=$(bc(o)).toVar(),u=ue(VI(tl(nl(t,n),r,o),tl(nl(t.add(ie(1)),n),r.sub(1),o),tl(nl(t,n.add(ie(1))),r,o.sub(1)),tl(nl(t.add(ie(1)),n.add(ie(1))),r.sub(1),o.sub(1)),a,c)).toVar();return HI(u)}).setLayout({name:"mx_perlin_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),de(([i])=>{const e=ue(i).toVar(),t=ie().toVar(),n=ie().toVar(),r=ie().toVar(),o=$(ss(e.x,t)).toVar(),a=$(ss(e.y,n)).toVar(),c=$(ss(e.z,r)).toVar(),u=$(bc(o)).toVar(),d=$(bc(a)).toVar(),p=$(bc(c)).toVar(),m=ue(GI(tl(nl(t,n,r),o,a,c),tl(nl(t.add(ie(1)),n,r),o.sub(1),a,c),tl(nl(t,n.add(ie(1)),r),o,a.sub(1),c),tl(nl(t.add(ie(1)),n.add(ie(1)),r),o.sub(1),a.sub(1),c),tl(nl(t,n,r.add(ie(1))),o,a,c.sub(1)),tl(nl(t.add(ie(1)),n,r.add(ie(1))),o.sub(1),a,c.sub(1)),tl(nl(t,n.add(ie(1)),r.add(ie(1))),o,a.sub(1),c.sub(1)),tl(nl(t.add(ie(1)),n.add(ie(1)),r.add(ie(1))),o.sub(1),a.sub(1),c.sub(1)),u,d,p)).toVar();return WI(m)}).setLayout({name:"mx_perlin_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"}]})]),m6=Dr([de(([i])=>{const e=$(i).toVar(),t=ie(Hs(e)).toVar();return Yr(Ni(t))}).setLayout({name:"mx_cell_noise_float_0",type:"float",inputs:[{name:"p",type:"float"}]}),de(([i])=>{const e=Xe(i).toVar(),t=ie(Hs(e.x)).toVar(),n=ie(Hs(e.y)).toVar();return Yr(Ni(t,n))}).setLayout({name:"mx_cell_noise_float_1",type:"float",inputs:[{name:"p",type:"vec2"}]}),de(([i])=>{const e=ue(i).toVar(),t=ie(Hs(e.x)).toVar(),n=ie(Hs(e.y)).toVar(),r=ie(Hs(e.z)).toVar();return Yr(Ni(t,n,r))}).setLayout({name:"mx_cell_noise_float_2",type:"float",inputs:[{name:"p",type:"vec3"}]}),de(([i])=>{const e=Lt(i).toVar(),t=ie(Hs(e.x)).toVar(),n=ie(Hs(e.y)).toVar(),r=ie(Hs(e.z)).toVar(),o=ie(Hs(e.w)).toVar();return Yr(Ni(t,n,r,o))}).setLayout({name:"mx_cell_noise_float_3",type:"float",inputs:[{name:"p",type:"vec4"}]})]),Dv=Dr([de(([i])=>{const e=$(i).toVar(),t=ie(Hs(e)).toVar();return ue(Yr(Ni(t,ie(0))),Yr(Ni(t,ie(1))),Yr(Ni(t,ie(2))))}).setLayout({name:"mx_cell_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"float"}]}),de(([i])=>{const e=Xe(i).toVar(),t=ie(Hs(e.x)).toVar(),n=ie(Hs(e.y)).toVar();return ue(Yr(Ni(t,n,ie(0))),Yr(Ni(t,n,ie(1))),Yr(Ni(t,n,ie(2))))}).setLayout({name:"mx_cell_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec2"}]}),de(([i])=>{const e=ue(i).toVar(),t=ie(Hs(e.x)).toVar(),n=ie(Hs(e.y)).toVar(),r=ie(Hs(e.z)).toVar();return ue(Yr(Ni(t,n,r,ie(0))),Yr(Ni(t,n,r,ie(1))),Yr(Ni(t,n,r,ie(2))))}).setLayout({name:"mx_cell_noise_vec3_2",type:"vec3",inputs:[{name:"p",type:"vec3"}]}),de(([i])=>{const e=Lt(i).toVar(),t=ie(Hs(e.x)).toVar(),n=ie(Hs(e.y)).toVar(),r=ie(Hs(e.z)).toVar(),o=ie(Hs(e.w)).toVar();return ue(Yr(Ni(t,n,r,o,ie(0))),Yr(Ni(t,n,r,o,ie(1))),Yr(Ni(t,n,r,o,ie(2))))}).setLayout({name:"mx_cell_noise_vec3_3",type:"vec3",inputs:[{name:"p",type:"vec4"}]})]),Fv=de(([i,e,t,n])=>{const r=$(n).toVar(),o=$(t).toVar(),a=ie(e).toVar(),c=ue(i).toVar(),u=$(0).toVar(),d=$(1).toVar();return wi(a,()=>{u.addAssign(d.mul(TM(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"}]}),Bv=de(([i,e,t,n])=>{const r=$(n).toVar(),o=$(t).toVar(),a=ie(e).toVar(),c=ue(i).toVar(),u=ue(0).toVar(),d=$(1).toVar();return wi(a,()=>{u.addAssign(d.mul(F_(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"}]}),g6=de(([i,e,t,n])=>{const r=$(n).toVar(),o=$(t).toVar(),a=ie(e).toVar(),c=ue(i).toVar();return Xe(Fv(c,a,o,r),Fv(c.add(ue(ie(19),ie(193),ie(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"}]}),y6=de(([i,e,t,n])=>{const r=$(n).toVar(),o=$(t).toVar(),a=ie(e).toVar(),c=ue(i).toVar(),u=ue(Bv(c,a,o,r)).toVar(),d=$(Fv(c.add(ue(ie(19),ie(193),ie(17))),a,o,r)).toVar();return Lt(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"}]}),Km=Dr([de(([i,e,t,n,r,o,a])=>{const c=ie(a).toVar(),u=$(o).toVar(),d=ie(r).toVar(),p=ie(n).toVar(),m=ie(t).toVar(),y=ie(e).toVar(),x=Xe(i).toVar(),v=ue(Dv(Xe(y.add(p),m.add(d)))).toVar(),M=Xe(v.x,v.y).toVar();M.subAssign(.5),M.mulAssign(u),M.addAssign(.5);const T=Xe(Xe($(y),$(m)).add(M)).toVar(),S=Xe(T.sub(x)).toVar();return Yt(c.equal(ie(2)),()=>zi(S.x).add(zi(S.y))),Yt(c.equal(ie(3)),()=>ys(zi(S.x),zi(S.y))),ld(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"}]}),de(([i,e,t,n,r,o,a,c,u])=>{const d=ie(u).toVar(),p=$(c).toVar(),m=ie(a).toVar(),y=ie(o).toVar(),x=ie(r).toVar(),v=ie(n).toVar(),M=ie(t).toVar(),T=ie(e).toVar(),S=ue(i).toVar(),N=ue(Dv(ue(T.add(x),M.add(y),v.add(m)))).toVar();N.subAssign(.5),N.mulAssign(p),N.addAssign(.5);const R=ue(ue($(T),$(M),$(v)).add(N)).toVar(),P=ue(R.sub(S)).toVar();return Yt(d.equal(ie(2)),()=>zi(P.x).add(zi(P.y)).add(zi(P.z))),Yt(d.equal(ie(3)),()=>ys(zi(P.x),zi(P.y),zi(P.z))),ld(P,P)}).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"}]})]),_6=de(([i,e,t])=>{const n=ie(t).toVar(),r=$(e).toVar(),o=Xe(i).toVar(),a=ie().toVar(),c=ie().toVar(),u=Xe(ss(o.x,a),ss(o.y,c)).toVar(),d=$(1e6).toVar();return wi({start:-1,end:ie(1),name:"x",condition:"<="},({x:p})=>{wi({start:-1,end:ie(1),name:"y",condition:"<="},({y:m})=>{const y=$(Km(u,p,m,a,c,r,n)).toVar();d.assign(Do(d,y))})}),Yt(n.equal(ie(0)),()=>{d.assign(fc(d))}),d}).setLayout({name:"mx_worley_noise_float_0",type:"float",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),x6=de(([i,e,t])=>{const n=ie(t).toVar(),r=$(e).toVar(),o=Xe(i).toVar(),a=ie().toVar(),c=ie().toVar(),u=Xe(ss(o.x,a),ss(o.y,c)).toVar(),d=Xe(1e6,1e6).toVar();return wi({start:-1,end:ie(1),name:"x",condition:"<="},({x:p})=>{wi({start:-1,end:ie(1),name:"y",condition:"<="},({y:m})=>{const y=$(Km(u,p,m,a,c,r,n)).toVar();Yt(y.lessThan(d.x),()=>{d.y.assign(d.x),d.x.assign(y)}).ElseIf(y.lessThan(d.y),()=>{d.y.assign(y)})})}),Yt(n.equal(ie(0)),()=>{d.assign(fc(d))}),d}).setLayout({name:"mx_worley_noise_vec2_0",type:"vec2",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),v6=de(([i,e,t])=>{const n=ie(t).toVar(),r=$(e).toVar(),o=Xe(i).toVar(),a=ie().toVar(),c=ie().toVar(),u=Xe(ss(o.x,a),ss(o.y,c)).toVar(),d=ue(1e6,1e6,1e6).toVar();return wi({start:-1,end:ie(1),name:"x",condition:"<="},({x:p})=>{wi({start:-1,end:ie(1),name:"y",condition:"<="},({y:m})=>{const y=$(Km(u,p,m,a,c,r,n)).toVar();Yt(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)})})}),Yt(n.equal(ie(0)),()=>{d.assign(fc(d))}),d}).setLayout({name:"mx_worley_noise_vec3_0",type:"vec3",inputs:[{name:"p",type:"vec2"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]}),b6=Dr([_6,de(([i,e,t])=>{const n=ie(t).toVar(),r=$(e).toVar(),o=ue(i).toVar(),a=ie().toVar(),c=ie().toVar(),u=ie().toVar(),d=ue(ss(o.x,a),ss(o.y,c),ss(o.z,u)).toVar(),p=$(1e6).toVar();return wi({start:-1,end:ie(1),name:"x",condition:"<="},({x:m})=>{wi({start:-1,end:ie(1),name:"y",condition:"<="},({y})=>{wi({start:-1,end:ie(1),name:"z",condition:"<="},({z:x})=>{const v=$(Km(d,m,y,x,a,c,u,r,n)).toVar();p.assign(Do(p,v))})})}),Yt(n.equal(ie(0)),()=>{p.assign(fc(p))}),p}).setLayout({name:"mx_worley_noise_float_1",type:"float",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),S6=Dr([x6,de(([i,e,t])=>{const n=ie(t).toVar(),r=$(e).toVar(),o=ue(i).toVar(),a=ie().toVar(),c=ie().toVar(),u=ie().toVar(),d=ue(ss(o.x,a),ss(o.y,c),ss(o.z,u)).toVar(),p=Xe(1e6,1e6).toVar();return wi({start:-1,end:ie(1),name:"x",condition:"<="},({x:m})=>{wi({start:-1,end:ie(1),name:"y",condition:"<="},({y})=>{wi({start:-1,end:ie(1),name:"z",condition:"<="},({z:x})=>{const v=$(Km(d,m,y,x,a,c,u,r,n)).toVar();Yt(v.lessThan(p.x),()=>{p.y.assign(p.x),p.x.assign(v)}).ElseIf(v.lessThan(p.y),()=>{p.y.assign(v)})})})}),Yt(n.equal(ie(0)),()=>{p.assign(fc(p))}),p}).setLayout({name:"mx_worley_noise_vec2_1",type:"vec2",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),wM=Dr([v6,de(([i,e,t])=>{const n=ie(t).toVar(),r=$(e).toVar(),o=ue(i).toVar(),a=ie().toVar(),c=ie().toVar(),u=ie().toVar(),d=ue(ss(o.x,a),ss(o.y,c),ss(o.z,u)).toVar(),p=ue(1e6,1e6,1e6).toVar();return wi({start:-1,end:ie(1),name:"x",condition:"<="},({x:m})=>{wi({start:-1,end:ie(1),name:"y",condition:"<="},({y})=>{wi({start:-1,end:ie(1),name:"z",condition:"<="},({z:x})=>{const v=$(Km(d,m,y,x,a,c,u,r,n)).toVar();Yt(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)})})})}),Yt(n.equal(ie(0)),()=>{p.assign(fc(p))}),p}).setLayout({name:"mx_worley_noise_vec3_1",type:"vec3",inputs:[{name:"p",type:"vec3"},{name:"jitter",type:"float"},{name:"metric",type:"int"}]})]),T6=de(([i,e,t,n,r,o,a,c,u,d,p])=>{const m=ie(i).toVar(),y=Xe(e).toVar(),x=Xe(t).toVar(),v=Xe(n).toVar(),M=$(r).toVar(),T=$(o).toVar(),S=$(a).toVar(),N=qa(c).toVar(),R=ie(u).toVar(),P=$(d).toVar(),B=$(p).toVar(),F=y.mul(x).add(v),k=$(0).toVar();return Yt(m.equal(ie(0)),()=>{k.assign(F_(F))}),Yt(m.equal(ie(1)),()=>{k.assign(Dv(F))}),Yt(m.equal(ie(2)),()=>{k.assign(wM(F,M,ie(0)))}),Yt(m.equal(ie(3)),()=>{k.assign(Bv(ue(F,0),R,P,B))}),k.assign(k.mul(S.sub(T)).add(T)),Yt(N,()=>{k.assign(ja(k,T,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"}]}),w6=de(([i,e,t,n,r,o,a,c,u,d,p])=>{const m=ie(i).toVar(),y=ue(e).toVar(),x=ue(t).toVar(),v=ue(n).toVar(),M=$(r).toVar(),T=$(o).toVar(),S=$(a).toVar(),N=qa(c).toVar(),R=ie(u).toVar(),P=$(d).toVar(),B=$(p).toVar(),F=y.mul(x).add(v),k=$(0).toVar();return Yt(m.equal(ie(0)),()=>{k.assign(F_(F))}),Yt(m.equal(ie(1)),()=>{k.assign(Dv(F))}),Yt(m.equal(ie(2)),()=>{k.assign(wM(F,M,ie(0)))}),Yt(m.equal(ie(3)),()=>{k.assign(Bv(F,R,P,B))}),k.assign(k.mul(S.sub(T)).add(T)),Yt(N,()=>{k.assign(ja(k,T,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"}]}),M6=de(([i])=>{const e=i.y,t=i.z,n=ue().toVar();return Yt(e.lessThan(1e-4),()=>{n.assign(ue(t,t,t))}).Else(()=>{let r=i.x;r=r.sub(pc(r)).mul(6).toVar();const o=ie(VT(r)),a=r.sub($(o)),c=t.mul(e.oneMinus()),u=t.mul(e.mul(a).oneMinus()),d=t.mul(e.mul(a.oneMinus()).oneMinus());Yt(o.equal(ie(0)),()=>{n.assign(ue(t,d,c))}).ElseIf(o.equal(ie(1)),()=>{n.assign(ue(u,t,c))}).ElseIf(o.equal(ie(2)),()=>{n.assign(ue(c,t,d))}).ElseIf(o.equal(ie(3)),()=>{n.assign(ue(c,u,t))}).ElseIf(o.equal(ie(4)),()=>{n.assign(ue(d,c,t))}).Else(()=>{n.assign(ue(t,c,u))})}),n}).setLayout({name:"mx_hsvtorgb",type:"vec3",inputs:[{name:"hsv",type:"vec3"}]}),A6=de(([i])=>{const e=ue(i).toVar(),t=$(e.x).toVar(),n=$(e.y).toVar(),r=$(e.z).toVar(),o=$(Do(t,Do(n,r))).toVar(),a=$(ys(t,ys(n,r))).toVar(),c=$(a.sub(o)).toVar(),u=$().toVar(),d=$().toVar(),p=$().toVar();return p.assign(a),Yt(a.greaterThan(0),()=>{d.assign(c.div(a))}).Else(()=>{d.assign(0)}),Yt(d.lessThanEqual(0),()=>{u.assign(0)}).Else(()=>{Yt(t.greaterThanEqual(a),()=>{u.assign(n.sub(r).div(c))}).ElseIf(n.greaterThanEqual(a),()=>{u.assign(Gs(2,r.sub(t).div(c)))}).Else(()=>{u.assign(Gs(4,t.sub(n).div(c)))}),u.mulAssign(1/6),Yt(u.lessThan(0),()=>{u.addAssign(1)})}),ue(u,d,p)}).setLayout({name:"mx_rgbtohsv",type:"vec3",inputs:[{name:"c",type:"vec3"}]}),E6=de(([i])=>{const e=ue(i).toVar(),t=MT(FT(e,ue(.04045))).toVar(),n=ue(e.div(12.92)).toVar(),r=ue(Xa(ys(e.add(ue(.055)),ue(0)).div(1.055),ue(2.4))).toVar();return oi(n,r,t)}).setLayout({name:"mx_srgb_texture_to_lin_rec709",type:"vec3",inputs:[{name:"color",type:"vec3"}]}),qI=(i,e)=>{i=$(i),e=$(e);const t=Xe(e.dFdx(),e.dFdy()).length().mul(.7071067811865476);return Ya(i.sub(t),i.add(t),e)},XI=(i,e,t,n)=>oi(i,e,t[n].clamp()),C6=(i,e,t=Ri())=>XI(i,e,t,"x"),R6=(i,e,t=Ri())=>XI(i,e,t,"y"),N6=(i,e,t,n,r=Ri())=>{const o=r.x.clamp(),a=r.y.clamp(),c=oi(i,e,o),u=oi(t,n,o);return oi(c,u,a)},jI=(i,e,t,n,r)=>oi(i,e,qI(t,n[r])),P6=(i,e,t,n=Ri())=>jI(i,e,t,n,"x"),I6=(i,e,t,n=Ri())=>jI(i,e,t,n,"y"),L6=(i=1,e=0,t=Ri())=>t.mul(i).add(e),D6=(i,e=1)=>(i=$(i),i.abs().pow(e).mul(i.sign())),F6=(i,e=1,t=.5)=>$(i).sub(t).mul(e).add(t),B6=(i=Ri(),e=1,t=0)=>TM(i.convert("vec2|vec3")).mul(e).add(t),O6=(i=Ri(),e=1,t=0)=>F_(i.convert("vec2|vec3")).mul(e).add(t),U6=(i=Ri(),e=1,t=0)=>(i=i.convert("vec2|vec3"),Lt(F_(i),TM(i.add(Xe(19,73)))).mul(e).add(t)),k6=(i,e=Ri(),t=Xe(1,1),n=Xe(0,0),r=1,o=0,a=1,c=!1,u=1,d=2,p=.5)=>T6(i,e.convert("vec2|vec3"),t,n,r,o,a,c,u,d,p),z6=(i,e=Ri(),t=Xe(1,1),n=Xe(0,0),r=1,o=0,a=1,c=!1,u=1,d=2,p=.5)=>w6(i,e.convert("vec2|vec3"),t,n,r,o,a,c,u,d,p),V6=(i=Ri(),e=1)=>b6(i.convert("vec2|vec3"),e,ie(1)),G6=(i=Ri(),e=1)=>S6(i.convert("vec2|vec3"),e,ie(1)),H6=(i=Ri(),e=1)=>wM(i.convert("vec2|vec3"),e,ie(1)),W6=(i=Ri())=>m6(i.convert("vec2|vec3")),$6=(i=Ri(),e=3,t=2,n=.5,r=1)=>Fv(i,ie(e),t,n).mul(r),q6=(i=Ri(),e=3,t=2,n=.5,r=1)=>g6(i,ie(e),t,n).mul(r),X6=(i=Ri(),e=3,t=2,n=.5,r=1)=>Bv(i,ie(e),t,n).mul(r),j6=(i=Ri(),e=3,t=2,n=.5,r=1)=>y6(i,ie(e),t,n).mul(r),Y6=(i,e=$(0))=>Gs(i,e),Z6=(i,e=$(0))=>Qn(i,e),K6=(i,e=$(1))=>En(i,e),J6=(i,e=$(1))=>la(i,e),Q6=(i,e=$(1))=>o_(i,e),e8=(i,e=$(1))=>Xa(i,e),t8=(i=$(0),e=$(1))=>qx(i,e),n8=()=>$m,i8=()=>YP,s8=(i,e=$(1))=>Qn(e,i),r8=(i,e,t,n)=>i.greaterThan(e).mix(t,n),o8=(i,e,t,n)=>i.greaterThanEqual(e).mix(t,n),a8=(i,e,t,n)=>i.equal(e).mix(t,n),l8=(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},c8=(i,e=Xe(.5,.5),t=Xe(1,1),n=$(0),r=Xe(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=Xe(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},u8=(i,e)=>{i=Xe(i),e=$(e);const t=e.mul(Math.PI/180);return x_(i,t)},h8=(i,e,t)=>{i=ue(i),e=$(e),t=ue(t);const n=e.mul(Math.PI/180),r=t.normalize(),o=n.cos(),a=n.sin(),c=$(1).sub(o);return i.mul(o).add(r.cross(i).mul(a)).add(r.mul(r.dot(i)).mul(c))},d8=(i,e)=>(i=ue(i),e=$(e),gw(i,e)),f8=de(([i,e,t])=>{const n=Eu(i).toVar(),r=Qn($(.5).mul(e.sub(t)),ha).div(n).toVar(),o=Qn($(-.5).mul(e.sub(t)),ha).div(n).toVar(),a=ue().toVar();a.x=n.x.greaterThan($(0)).select(r.x,o.x),a.y=n.y.greaterThan($(0)).select(r.y,o.y),a.z=n.z.greaterThan($(0)).select(r.z,o.z);const c=Do(a.x,a.y,a.z).toVar();return ha.add(n.mul(c)).toVar().sub(t)}),YI=de(([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(En(t,t).sub(En(n,n)))),o});var jZ=Object.freeze({__proto__:null,BRDF_GGX:Dw,BRDF_Lambert:Yf,BasicPointShadowFilter:BI,BasicShadowFilter:EI,Break:IN,Const:nR,Continue:iG,DFGApprox:Fw,D_GGX:tP,Discard:_R,EPSILON:wC,F_Schlick:Gm,Fn:de,INFINITY:Lz,If:Yt,Loop:wi,NodeAccess:Ir,NodeShaderStage:jy,NodeType:nz,NodeUpdateType:In,OnMaterialUpdate:fH,OnObjectUpdate:dH,PCFShadowFilter:CI,PCFSoftShadowFilter:RI,PI:Hx,PI2:Dz,PointShadowFilter:OI,Return:Zz,Schlick_to_F0:iP,ScriptableNodeResources:Cv,ShaderNode:Cm,Stack:Dx,Switch:wz,TBNViewMatrix:Xf,VSMShadowFilter:NI,V_GGX_SmithCorrelated:eP,Var:tR,VarIntent:iR,abs:zi,acesFilmicToneMapping:hI,acos:UT,add:Gs,addMethodChaining:Ve,addNodeElement:Qz,agxToneMapping:dI,all:MC,alphaT:kx,and:cC,anisotropy:ad,anisotropyB:Hf,anisotropyT:t_,any:AC,append:Cz,array:nC,arrayBuffer:Az,asin:NC,assign:iC,atan:qx,atan2:KC,atomicAdd:xW,atomicAnd:TW,atomicFunc:vc,atomicLoad:yW,atomicMax:bW,atomicMin:SW,atomicOr:wW,atomicStore:_W,atomicSub:vW,atomicXor:MW,attenuationColor:PT,attenuationDistance:NT,attribute:ho,attributeArray:gH,backgroundBlurriness:QP,backgroundIntensity:lM,backgroundRotation:eI,batch:CN,bentNormalView:ZR,billboarding:Y5,bitAnd:fC,bitNot:pC,bitOr:mC,bitXor:gC,bitangentGeometry:OV,bitangentLocal:UV,bitangentView:jR,bitangentWorld:kV,bitcast:R5,blendBurn:zN,blendColor:vG,blendDodge:VN,blendOverlay:HN,blendScreen:GN,blur:TP,bool:qa,buffer:h_,bufferAttribute:c_,builtin:Pu,bumpMap:gw,burn:SG,bvec2:$E,bvec3:MT,bvec4:YE,bypass:pR,cache:u_,call:sC,cameraFar:Du,cameraIndex:ud,cameraNear:Lu,cameraNormalMatrix:fV,cameraPosition:m_,cameraProjectionMatrix:Za,cameraProjectionMatrixInverse:hV,cameraViewMatrix:ua,cameraViewport:pV,cameraWorldMatrix:dV,cbrt:qC,cdl:IH,ceil:$x,checker:h6,cineonToneMapping:uI,clamp:ja,clearcoat:Bx,clearcoatNormalView:qf,clearcoatRoughness:e_,code:Av,color:HE,colorSpaceToWorking:Zx,colorToDirection:IG,compute:fR,computeKernel:JT,computeSkinning:tG,context:l_,convert:KE,convertColorSpace:Vz,convertToTexture:aH,cos:Ru,cross:jx,cubeTexture:Bm,cubeTextureBase:hw,cubeToUV:Rl,dFdx:kT,dFdy:zT,dashSize:Wf,debug:xR,decrement:SC,decrementBefore:vC,defaultBuildStages:yT,defaultShaderStages:LE,defined:Zy,degrees:CC,deltaTime:G5,densityFog:eW,densityFogFactor:hM,depth:Nw,depthPass:OH,determinant:OC,difference:GC,diffuseColor:fi,directPointLight:zI,directionToColor:qN,directionToFaceDirection:Dm,dispersion:IT,distance:VC,div:la,dodge:TG,dot:ld,drawIndex:MN,dynamicBufferAttribute:dR,element:ZE,emissive:AT,equal:DT,equals:kC,equirectUV:Pw,exp:BT,exp2:Pm,expression:Nu,faceDirection:aw,faceForward:qT,faceforward:Fz,float:$,floatBitsToInt:N5,floatBitsToUint:P5,floor:pc,fog:R_,fract:Cu,frameGroup:eC,frameId:YP,frontFacing:CR,fwidth:FC,gain:F5,gapSize:i_,getConstNodeType:GE,getCurrentStack:Lx,getDirection:bP,getDistanceAttenuation:SM,getGeometryRoughness:QN,getNormalFromDepth:cH,getParallaxCorrectNormal:f8,getRoughness:Lw,getScreenPosition:lH,getShIrradianceAt:YI,getShadowMaterial:PI,getShadowRenderObjectFunction:LI,getTextureIndex:XP,getViewPosition:jm,globalId:oW,glsl:qH,glslFn:XH,grayscale:CH,greaterThan:FT,greaterThanEqual:lC,hash:D5,highpModelNormalViewMatrix:rw,highpModelViewMatrix:sw,hue:PH,increment:bC,incrementBefore:xC,instance:jV,instanceIndex:dd,instancedArray:yH,instancedBufferAttribute:Kx,instancedDynamicBufferAttribute:KT,instancedMesh:EN,int:ie,intBitsToFloat:I5,inverse:UC,inverseSqrt:OT,inversesqrt:Bz,invocationLocalIndex:XV,invocationSubgroupIndex:qV,ior:s_,iridescence:Ux,iridescenceIOR:ET,iridescenceThickness:CT,ivec2:or,ivec3:qE,ivec4:XE,js:WH,label:eR,length:mc,lengthSq:HT,lessThan:oC,lessThanEqual:aC,lightPosition:fM,lightProjectionUV:_I,lightShadowMatrix:Pv,lightTargetDirection:mM,lightTargetPosition:xI,lightViewPosition:pM,lightingContext:FN,lights:QW,linearDepth:Vm,linearToneMapping:lI,localId:aW,log:Wx,log2:dc,logarithmicDepthToViewZ:dG,luminance:cM,mat2:Fx,mat3:qr,mat4:Vf,matcapUV:FP,materialAO:TN,materialAlphaTest:JR,materialAnisotropy:dN,materialAnisotropyVector:Om,materialAttenuationColor:vN,materialAttenuationDistance:xN,materialClearcoat:oN,materialClearcoatNormal:lN,materialClearcoatRoughness:aN,materialColor:ov,materialDispersion:SN,materialEmissive:eN,materialEnvIntensity:tv,materialEnvRotation:uw,materialIOR:_N,materialIridescence:fN,materialIridescenceIOR:pN,materialIridescenceThickness:mN,materialLightMap:Sw,materialLineDashOffset:bw,materialLineDashSize:xw,materialLineGapSize:vw,materialLineScale:_w,materialLineWidth:cv,materialMetalness:sN,materialNormal:rN,materialOpacity:av,materialPointSize:bN,materialReference:Bu,materialReflectivity:lv,materialRefractionRatio:LR,materialRotation:cN,materialRoughness:iN,materialSheen:uN,materialSheenRoughness:hN,materialShininess:QR,materialSpecular:tN,materialSpecularColor:nN,materialSpecularIntensity:yw,materialSpecularStrength:y_,materialThickness:yN,materialTransmission:gN,max:ys,maxMipLevel:ew,mediumpModelViewMatrix:ER,metalness:Qy,min:Do,mix:oi,mixElement:jC,mod:o_,modInt:TC,modelDirection:vV,modelNormalMatrix:AR,modelPosition:bV,modelRadius:MR,modelScale:SV,modelViewMatrix:Fu,modelViewPosition:TV,modelViewProjection:Tw,modelWorldMatrix:Ja,modelWorldMatrixInverse:wV,morphReference:DN,mrt:jP,mul:En,mx_aastep:qI,mx_add:Y6,mx_atan2:t8,mx_cell_noise_float:W6,mx_contrast:F6,mx_divide:J6,mx_fractal_noise_float:$6,mx_fractal_noise_vec2:q6,mx_fractal_noise_vec3:X6,mx_fractal_noise_vec4:j6,mx_frame:i8,mx_heighttonormal:d8,mx_hsvtorgb:M6,mx_ifequal:a8,mx_ifgreater:r8,mx_ifgreatereq:o8,mx_invert:s8,mx_modulo:Q6,mx_multiply:K6,mx_noise_float:B6,mx_noise_vec3:O6,mx_noise_vec4:U6,mx_place2d:c8,mx_power:e8,mx_ramp4:N6,mx_ramplr:C6,mx_ramptb:R6,mx_rgbtohsv:A6,mx_rotate2d:u8,mx_rotate3d:h8,mx_safepower:D6,mx_separate:l8,mx_splitlr:P6,mx_splittb:I6,mx_srgb_texture_to_lin_rec709:E6,mx_subtract:Z6,mx_timer:n8,mx_transform_uv:L6,mx_unifiednoise2d:k6,mx_unifiednoise3d:z6,mx_worley_noise_float:V6,mx_worley_noise_vec2:G6,mx_worley_noise_vec3:H6,negate:PC,neutralToneMapping:fI,nodeArray:zf,nodeImmutable:xt,nodeObject:Ge,nodeObjectIntent:Ky,nodeObjects:Ix,nodeProxy:xn,nodeProxyIntent:ft,normalFlat:RR,normalGeometry:ev,normalLocal:Fo,normalMap:mw,normalView:Ti,normalViewGeometry:Fm,normalWorld:hd,normalWorldGeometry:NR,normalize:Eu,not:hC,notEqual:rC,numWorkgroups:sW,objectDirection:mV,objectGroup:LT,objectPosition:wR,objectRadius:xV,objectScale:yV,objectViewPosition:_V,objectWorldMatrix:gV,oneMinus:IC,or:uC,orthographicDepthToViewZ:hG,oscSawtooth:q5,oscSine:H5,oscSquare:W5,oscTriangle:$5,output:Nm,outputStruct:E5,overlay:MG,overloadingFn:Dr,parabola:iM,parallaxDirection:YR,parallaxUV:zV,parameter:b5,pass:FH,passTexture:BH,pcurve:B5,perspectiveDepthToViewZ:Cw,pmremTexture:eM,pointShadow:kI,pointUV:xH,pointWidth:Rz,positionGeometry:Lr,positionLocal:Ps,positionPrevious:Qx,positionView:Is,positionViewDirection:Yi,positionWorld:ha,positionWorldDirection:ow,posterize:DH,pow:Xa,pow2:GT,pow3:HC,pow4:WC,premultiplyAlpha:WN,property:El,quadBroadcast:ZW,quadSwapDiagonal:WW,quadSwapX:GW,quadSwapY:HW,radians:EC,rand:XC,range:nW,rangeFog:QH,rangeFogFactor:uM,reciprocal:DC,reference:Fi,referenceBuffer:dw,reflect:zC,reflectVector:BR,reflectView:DR,reflector:nH,refract:$T,refractVector:OR,refractView:FR,reinhardToneMapping:cI,remap:gR,remapClamp:yR,renderGroup:Zt,renderOutput:QT,rendererReference:cR,rotate:x_,rotateUV:X5,roughness:hc,round:LC,rtt:KP,sRGBTransferEOTF:rR,sRGBTransferOETF:oR,sample:hH,sampler:sV,samplerComparison:rV,saturate:WT,saturation:RH,screen:wG,screenCoordinate:p_,screenDPR:bR,screenSize:$f,screenUV:Iu,scriptable:JH,scriptableValue:Ev,select:_r,setCurrentStack:Jy,setName:XT,shaderStages:_T,shadow:FI,shadowPositionWorld:_M,shapeCircle:d6,sharedUniformGroup:Gx,sheen:Gf,sheenRoughness:Ox,shiftLeft:yC,shiftRight:_C,shininess:zx,sign:a_,sin:ca,sinc:O5,skinning:PN,smoothstep:Ya,smoothstepElement:YC,specularColor:Lo,specularF90:n_,spherizeUV:j5,split:Ez,spritesheetUV:J5,sqrt:fc,stack:xv,step:Xx,stepElement:ZC,storage:jf,storageBarrier:hW,storageObject:eG,storageTexture:tI,string:Mz,struct:A5,sub:Qn,subBuild:Im,subgroupAdd:CW,subgroupAll:kW,subgroupAnd:DW,subgroupAny:zW,subgroupBallot:EW,subgroupBroadcast:$W,subgroupBroadcastFirst:VW,subgroupElect:AW,subgroupExclusiveAdd:NW,subgroupExclusiveMul:LW,subgroupInclusiveAdd:RW,subgroupInclusiveMul:IW,subgroupIndex:$V,subgroupMax:UW,subgroupMin:OW,subgroupMul:PW,subgroupOr:FW,subgroupShuffle:qW,subgroupShuffleDown:YW,subgroupShuffleUp:jW,subgroupShuffleXor:XW,subgroupSize:lW,subgroupXor:BW,tan:RC,tangentGeometry:iv,tangentLocal:g_,tangentView:sv,tangentWorld:XR,texture:Kn,texture3D:nI,textureBarrier:dW,textureBicubic:t4,textureBicubicLevel:Uw,textureCubeUV:SP,textureLoad:Ns,textureSize:cd,textureStore:bH,thickness:RT,time:$m,toneMapping:uR,toneMappingExposure:hR,toonOutlinePass:kH,transformDirection:$C,transformNormal:PR,transformNormalToView:lw,transformedClearcoatNormalView:CV,transformedNormalView:AV,transformedNormalWorld:EV,transmission:Vx,transpose:BC,triNoise3D:k5,triplanarTexture:Q5,triplanarTextures:ZP,trunc:VT,uint:Pt,uintBitsToFloat:L5,uniform:Jt,uniformArray:Xr,uniformCubeTexture:NV,uniformFlow:QC,uniformGroup:QE,uniformTexture:iV,unpremultiplyAlpha:bG,userData:MH,uv:Ri,uvec2:WE,uvec3:Rm,uvec4:jE,varying:gc,varyingProperty:aa,vec2:Xe,vec3:ue,vec4:Lt,vectorComponents:Uf,velocity:EH,vertexColor:kN,vertexIndex:wN,vertexStage:sR,vibrance:NH,viewZToLogarithmicDepth:Rw,viewZToOrthographicDepth:zm,viewZToPerspectiveDepth:Ew,viewport:Lm,viewportCoordinate:SR,viewportDepthTexture:Aw,viewportLinearDepth:fG,viewportMipTexture:Mw,viewportResolution:uV,viewportSafeUV:Z5,viewportSharedTexture:$N,viewportSize:iw,viewportTexture:cG,viewportUV:cV,wgsl:$H,wgslFn:jH,workgroupArray:mW,workgroupBarrier:uW,workgroupId:rW,workingToColorSpace:aR,xor:dC});const Nl=new nM;class p8 extends pd{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(Nl),Nl.a=r._clearColor.a;else if(o.isColor===!0)o.getRGB(Nl),Nl.a=1,a=!0;else if(o.isNode===!0){const u=this.get(e),d=o;Nl.copy(r._clearColor);let p=u.backgroundMesh;if(p===void 0){let M=function(){o.removeEventListener("dispose",M),p.material.dispose(),p.geometry.dispose()};const y=l_(Lt(d).mul(lM),{getUV:()=>eI.mul(NR),getTextureLevel:()=>QP});let x=Tw;x=x.setZ(x.w);const v=new _s;v.name="Background.material",v.side=Ee,v.depthTest=!1,v.depthWrite=!1,v.allowOverride=!1,v.fog=!1,v.lights=!1,v.vertexNode=x,v.colorNode=y,u.backgroundMeshNode=y,u.backgroundMesh=p=new vi(new gl(1,32,32),v),p.frustumCulled=!1,p.name="Background.mesh",p.onBeforeRender=function(T,S,N){this.matrixWorld.copyPosition(N.matrixWorld)},o.addEventListener("dispose",M)}const m=d.getCacheKey();u.backgroundCacheKey!==m&&(u.backgroundMeshNode.node=Lt(d).mul(lM),u.backgroundMeshNode.needsUpdate=!0,p.material.needsUpdate=!0,u.backgroundCacheKey=m),t.unshift(p,p.geometry,p.material,0,0,null,null)}else console.error("THREE.Renderer: Unsupported background configuration.",o);const c=r.xr.getEnvironmentBlendMode();if(c==="additive"?Nl.set(0,0,0,1):c==="alpha-blend"&&Nl.set(0,0,0,0),r.autoClear===!0||a===!0){const u=n.clearColorValue;u.r=Nl.r,u.g=Nl.g,u.b=Nl.b,u.a=Nl.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 m8=0;class MM{constructor(e="",t=[],n=0,r=[]){this.name=e,this.bindings=t,this.index=n,this.bindingsReference=r,this.id=m8++}}class g8{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 MM(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 ZI{constructor(e,t,n=null){this.isNodeAttribute=!0,this.name=e,this.type=t,this.node=n}}class y8{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 KI{constructor(e,t,n=!1,r=null){this.isNodeVar=!0,this.name=e,this.type=t,this.readOnly=n,this.count=r}}class _8 extends KI{constructor(e,t,n=null,r=null){super(e,t),this.needsInterpolation=!1,this.isNodeVarying=!0,this.interpolationType=n,this.interpolationSampling=r}}class x8{constructor(e,t,n=""){this.name=e,this.type=t,this.code=n,Object.defineProperty(this,"isNodeCode",{value:!0})}}let v8=0;class AM{constructor(e=null){this.id=v8++,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 b8{constructor(e,t){this.name=e,this.members=t,this.output=!1}}class yd{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 S8 extends yd{constructor(e,t=0){super(e,t),this.isNumberUniform=!0,this.boundary=4,this.itemSize=1}}class T8 extends yd{constructor(e,t=new Ie){super(e,t),this.isVector2Uniform=!0,this.boundary=8,this.itemSize=2}}class w8 extends yd{constructor(e,t=new W){super(e,t),this.isVector3Uniform=!0,this.boundary=16,this.itemSize=3}}class M8 extends yd{constructor(e,t=new an){super(e,t),this.isVector4Uniform=!0,this.boundary=16,this.itemSize=4}}class A8 extends yd{constructor(e,t=new At){super(e,t),this.isColorUniform=!0,this.boundary=16,this.itemSize=3}}class E8 extends yd{constructor(e,t=new Af){super(e,t),this.isMatrix2Uniform=!0,this.boundary=8,this.itemSize=4}}class C8 extends yd{constructor(e,t=new Cn){super(e,t),this.isMatrix3Uniform=!0,this.boundary=48,this.itemSize=12}}class R8 extends yd{constructor(e,t=new Vt){super(e,t),this.isMatrix4Uniform=!0,this.boundary=64,this.itemSize=16}}class N8 extends S8{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class P8 extends T8{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class I8 extends w8{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class L8 extends M8{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class D8 extends A8{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class F8 extends E8{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class B8 extends C8{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}class O8 extends R8{constructor(e){super(e.name,e.value),this.nodeUniform=e}getValue(){return this.nodeUniform.value}getType(){return this.nodeUniform.type}}const JI=new WeakMap,U8=new Map([[Int8Array,"int"],[Int16Array,"int"],[Int32Array,"int"],[Uint8Array,"uint"],[Uint16Array,"uint"],[Uint32Array,"uint"],[Float32Array,"float"]]),Ov=i=>/e/g.test(i)?String(i).replace(/\+/g,""):(i=Number(i),i+(i%1?"":".0"));class QI{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=xv(),this.stacks=[],this.tab=" ",this.currentFunctionNode=null,this.context={material:this.material},this.cache=new AM,this.globalCache=this.cache,this.flowsData=new WeakMap,this.shaderStage=null,this.buildStage=null,this.subBuildLayers=[],this.currentStack=null,this.subBuildFn=null}getBindGroupsCache(){let e=JI.get(this.renderer);return e===void 0&&(e=new Cl,JI.set(this.renderer,e)),e}createRenderTarget(e,t,n){return new Mr(e,t,n)}createCubeRenderTarget(e,t){return new XN(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 MM(e,r,this.bindingsIndexes[e].group,r),n.set(r,a))):a=new MM(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 _T)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()!==In.NONE&&this.updateNodes.push(e);for(const e of this.sequentialNodes){const t=e.getUpdateBeforeType(),n=e.getUpdateAfterType();t!==In.NONE&&this.updateBeforeNodes.push(e),n!==In.NONE&&this.updateAfterNodes.push(e)}}get currentNode(){return this.chaining[this.chaining.length-1]}isFilteredTexture(e){return e.magFilter===Yn||e.magFilter===Ic||e.magFilter===Ta||e.magFilter===Ds||e.minFilter===Yn||e.minFilter===Ic||e.minFilter===Ta||e.minFilter===Ds}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}getSharedContext(){return Ii({},this.context),this.context}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 AM(t?this.getCache():null)),n.cache}isAvailable(){return!1}getVertexIndex(){console.warn("Abstract function.")}getInstanceIndex(){console.warn("Abstract function.")}getDrawIndex(){console.warn("Abstract function.")}getFrontFacing(){console.warn("Abstract function.")}getFragCoord(){console.warn("Abstract function.")}isFlipY(){return!1}increaseUsage(e){const t=this.getDataFromNode(e);return t.usageCount=t.usageCount===void 0?1:t.usageCount+1,t.usageCount}generateTexture(){console.warn("Abstract function.")}generateTextureLod(){console.warn("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 At:e==="vec2"?t=new Ie:e==="vec3"?t=new W:e==="vec4"&&(t=new an)),e==="float")return Ov(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")}( ${Ov(t.r)}, ${Ov(t.g)}, ${Ov(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 ZI(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===Ws)return"int";if(t===pi)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=dT(e);const r=t==="float"?"":t[0];return/mat2/.test(t)===!0&&(n=n.replace("vec","mat")),r+n}getTypeFromArray(e){return U8.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 Lb)&&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")}addStack(){this.stack=xv(this.stack);const e=Lx();return this.stacks.push(e),Jy(this.stack),this.stack}removeStack(){const e=this.stack;return this.stack=e.parent,Jy(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);let r=n.bufferAttribute;if(r===void 0){const o=this.uniforms.index++;r=new ZI("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 b8(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 y8(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 KI(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 _8(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,console.warn(`THREE.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 x8("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 pI,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 $P(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 AM,this.stack=xv();for(const p of yT)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(){console.warn("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=Ii({},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(){console.warn("Abstract function.")}getVaryings(){console.warn("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(){console.warn("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(){console.warn("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&&(console.error(`NodeMaterial: Material "${t.type}" is not compatible.`),r=new _s),r.build(this)}else this.addFlow("compute",e);for(const r of yT){this.setBuildStage(r),this.context.vertex&&this.context.vertex.isNode&&this.flowNodeFromShaderStage("vertex",this.context.vertex);for(const o of _T){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}getNodeUniform(e,t){if(t==="float"||t==="int"||t==="uint")return new N8(e);if(t==="vec2"||t==="ivec2"||t==="uvec2")return new P8(e);if(t==="vec3"||t==="ivec3"||t==="uvec3")return new I8(e);if(t==="vec4"||t==="ivec4"||t==="uvec4")return new L8(e);if(t==="color")return new D8(e);if(t==="mat2")return new F8(e);if(t==="mat3")return new B8(e);if(t==="mat4")return new O8(e);throw new Error(`Uniform "${t}" not declared.`)}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${_e} - Node System
|
|
`}}class e2{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={renderMap:new WeakMap,frameMap:new WeakMap},e.set(t,n)),n}updateBeforeNode(e){const t=e.getUpdateBeforeType(),n=e.updateReference(this);if(t===In.FRAME){const{frameMap:r}=this._getMaps(this.updateBeforeMap,n);r.get(n)!==this.frameId&&e.updateBefore(this)!==!1&&r.set(n,this.frameId)}else if(t===In.RENDER){const{renderMap:r}=this._getMaps(this.updateBeforeMap,n);r.get(n)!==this.renderId&&e.updateBefore(this)!==!1&&r.set(n,this.renderId)}else t===In.OBJECT&&e.updateBefore(this)}updateAfterNode(e){const t=e.getUpdateAfterType(),n=e.updateReference(this);if(t===In.FRAME){const{frameMap:r}=this._getMaps(this.updateAfterMap,n);r.get(n)!==this.frameId&&e.updateAfter(this)!==!1&&r.set(n,this.frameId)}else if(t===In.RENDER){const{renderMap:r}=this._getMaps(this.updateAfterMap,n);r.get(n)!==this.renderId&&e.updateAfter(this)!==!1&&r.set(n,this.renderId)}else t===In.OBJECT&&e.updateAfter(this)}updateNode(e){const t=e.getUpdateType(),n=e.updateReference(this);if(t===In.FRAME){const{frameMap:r}=this._getMaps(this.updateMap,n);r.get(n)!==this.frameId&&e.update(this)!==!1&&r.set(n,this.frameId)}else if(t===In.RENDER){const{renderMap:r}=this._getMaps(this.updateMap,n);r.get(n)!==this.renderId&&e.update(this)!==!1&&r.set(n,this.renderId)}else t===In.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 EM{constructor(e,t,n=null,r="",o=!1){this.type=e,this.name=t,this.count=n,this.qualifier=r,this.isConst=o}}EM.isNodeFunctionInput=!0;class k8 extends np{static get type(){return"DirectionalLightNode"}constructor(e=null){super(e)}setupDirect(){const e=this.colorNode;return{lightDirection:mM(this.light),lightColor:e}}}const CM=new Vt,Uv=new Vt;let B_=null;class z8 extends np{static get type(){return"RectAreaLightNode"}constructor(e=null){super(e),this.halfHeight=Jt(new W).setGroup(Zt),this.halfWidth=Jt(new W).setGroup(Zt),this.updateType=In.RENDER}update(e){super.update(e);const{light:t}=this,n=e.camera.matrixWorldInverse;Uv.identity(),CM.copy(t.matrixWorld),CM.premultiply(n),Uv.extractRotation(CM),this.halfWidth.value.set(t.width*.5,0,0),this.halfHeight.value.set(0,t.height*.5,0),this.halfWidth.value.applyMatrix4(Uv),this.halfHeight.value.applyMatrix4(Uv)}setupDirectRectArea(e){let t,n;e.isAvailable("float32Filterable")?(t=Kn(B_.LTC_FLOAT_1),n=Kn(B_.LTC_FLOAT_2)):(t=Kn(B_.LTC_HALF_1),n=Kn(B_.LTC_HALF_2));const{colorNode:r,light:o}=this,a=pM(o);return{lightColor:r,lightPosition:a,halfWidth:this.halfWidth,halfHeight:this.halfHeight,ltc_1:t,ltc_2:n}}static setLTC(e){B_=e}}class RM extends np{static get type(){return"SpotLightNode"}constructor(e=null){super(e),this.coneCosNode=Jt(0).setGroup(Zt),this.penumbraCosNode=Jt(0).setGroup(Zt),this.cutoffDistanceNode=Jt(0).setGroup(Zt),this.decayExponentNode=Jt(0).setGroup(Zt),this.colorNode=Jt(this.color).setGroup(Zt)}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 Ya(n,r,t)}getLightCoord(e){const t=e.getNodeProperties(this);let n=t.projectionUV;return n===void 0&&(n=_I(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(mM(o)),d=this.getSpotAttenuation(e,u),p=a.length(),m=SM({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=Kn(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 V8 extends RM{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=Kn(n,Xe(o,0),0).r}else r=super.getSpotAttenuation(t);return r}}const G8=de(([i,e])=>{const t=i.abs().sub(e);return mc(ys(t,0)).add(Do(ys(t.x,t.y),0))});class H8 extends RM{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=$(0),n=this.penumbraCosNode,r=Pv(this.light).mul(e.context.positionWorld||ha);return Yt(r.w.greaterThan(0),()=>{const o=r.xyz.div(r.w),a=G8(o.xy.sub(Xe(.5)),Xe(.5)),c=la(-1,Qn(1,UT(n)).sub(1));t.assign(WT(a.mul(-2).mul(c)))}),t}}class W8 extends np{static get type(){return"AmbientLightNode"}constructor(e=null){super(e)}setup({context:e}){e.irradiance.addAssign(this.colorNode)}}class $8 extends np{static get type(){return"HemisphereLightNode"}constructor(e=null){super(e),this.lightPositionNode=fM(e),this.lightDirectionNode=this.lightPositionNode.normalize(),this.groundColorNode=Jt(new At).setGroup(Zt)}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=hd.dot(r).mul(.5).add(.5),c=oi(n,t,a);e.context.irradiance.addAssign(c)}}class q8 extends np{static get type(){return"LightProbeNode"}constructor(e=null){super(e);const t=[];for(let n=0;n<9;n++)t.push(new W);this.lightProbe=Xr(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=YI(hd,this.lightProbe);e.context.irradiance.addAssign(t)}}class t2{parseFunction(){console.warn("Abstract function.")}}class NM{constructor(e,t,n="",r=""){this.type=e,this.inputs=t,this.name=n,this.precision=r}getCode(){console.warn("Abstract function.")}}NM.isNodeFunction=!0;const X8=/^\s*(highp|mediump|lowp)?\s*([a-z_0-9]+)\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)/i,j8=/[a-z_0-9]+/ig,n2="#pragma main",Y8=i=>{i=i.trim();const e=i.indexOf(n2),t=e!==-1?i.slice(e+n2.length):i,n=t.match(X8);if(n!==null&&n.length===5){const r=n[4],o=[];let a=null;for(;(a=j8.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 M=o[u][0];M==="in"||M==="out"||M==="inout"?u++:M="";const T=o[u++][0];let S=Number.parseInt(o[u][0]);Number.isNaN(S)===!1?u++:S=null;const N=o[u++][0];c.push(new EM(T,N,S,M,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 Z8 extends NM{constructor(e){const{type:t,inputs:n,name:r,precision:o,inputsCode:a,blockCode:c,headerCode:u}=Y8(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 K8 extends t2{parseFunction(e){return new Z8(e)}}const i2=new WeakMap,Sc=[],ip=[];class J8 extends pd{constructor(e,t){super(),this.renderer=e,this.backend=t,this.nodeFrame=new e2,this.nodeBuilderCache=new Map,this.callHashCache=new Cl,this.groupsData=new Cl,this.cacheLib={}}updateGroup(e){const t=e.groupNode,n=t.name;if(n===LT.name)return!0;if(n===Zt.name){const o=this.get(e),a=this.nodeFrame.renderId;return o.renderId!==a?(o.renderId=a,!0):!1}if(n===eC.name){const o=this.get(e),a=this.nodeFrame.frameId;return o.frameId!==a?(o.frameId=a,!0):!1}Sc[0]=t,Sc[1]=e;let r=this.groupsData.get(Sc);return r===void 0&&this.groupsData.set(Sc,r={}),Sc.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=this.backend.createNodeBuilder(e.object,this.renderer);a.scene=e.scene,a.material=e.material,a.camera=e.camera,a.context.material=e.material,a.lightsNode=e.lightsNode,a.environmentNode=this.getEnvironmentNode(e.scene),a.fogNode=this.getFogNode(e.scene),a.clippingContext=e.clippingContext,this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview&&a.enableMultiview(),a.build(),n=this._createNodeBuilderState(a),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 g8(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){Sc[0]=e,Sc[1]=t;const n=this.renderer.info.calls,r=this.callHashCache.get(Sc)||{};if(r.callId!==n){const o=this.getEnvironmentNode(e),a=this.getFogNode(e);t&&ip.push(t.getCacheKey(!0)),o&&ip.push(o.getCacheKey()),a&&ip.push(a.getCacheKey()),ip.push(this.renderer.getOutputRenderTarget()&&this.renderer.getOutputRenderTarget().multiview?1:0),ip.push(this.renderer.shadowMap.enabled?1:0),r.callId=n,r.cacheKey=Wy(ip),this.callHashCache.set(Sc,r),ip.length=0}return Sc.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===Nc||n.mapping===Pc||n.mapping===Ll){if(e.backgroundBlurriness>0||n.mapping===Ll)return eM(n);{let a;return n.isCubeTexture===!0?a=Bm(n):a=Kn(n),ZN(a)}}else{if(n.isTexture===!0)return Kn(n,Iu.flipY()).setUpdateMatrix(!0);n.isColor!==!0&&console.error("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=Fi("color","color",n).setGroup(Zt),a=Fi("density","float",n).setGroup(Zt);return R_(o,hM(a))}else if(n.isFog){const o=Fi("color","color",n).setGroup(Zt),a=Fi("near","float",n).setGroup(Zt),c=Fi("far","float",n).setGroup(Zt);return R_(o,uM(a,c))}else console.error("THREE.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 Bm(n);if(n.isTexture===!0)return Kn(n);console.error("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 i2.get(e)!==this.getOutputCacheKey()}getOutputNode(e){const t=this.renderer,n=this.getOutputCacheKey(),r=e.isArrayTexture?nI(e,ue(Iu,Pu("gl_ViewID_OVR"))).renderOutput(t.toneMapping,t.currentColorSpace):Kn(e,Iu).renderOutput(t.toneMapping,t.currentColorSpace);return i2.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 e2,this.nodeBuilderCache=new Map,this.cacheLib={}}}const PM=new Rr;class kv{constructor(e=null){this.version=0,this.clipIntersection=null,this.cacheKey="",this.shadowPass=!1,this.viewNormalMatrix=new Cn,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++){PM.copy(e[o]).applyMatrix4(this.viewMatrix,this.viewNormalMatrix);const a=t[n+o],c=PM.normal;a.x=-c.x,a.y=-c.y,a.z=-c.z,a.w=PM.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 an;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 kv(this),this.clippingGroupContexts.set(e,t)),t.update(this,e),t}get unionClippingCount(){return this.unionPlanes.length}}class Q8{constructor(e,t){this.bundleGroup=e,this.camera=t}}const O_=[];class e${constructor(){this.bundles=new Cl}get(e,t){const n=this.bundles;O_[0]=e,O_[1]=t;let r=n.get(O_);return r===void 0&&(r=new Q8(e,t),n.set(O_,r)),O_.length=0,r}dispose(){this.bundles=new Cl}}class s2{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)){console.warn(`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)){console.warn(`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 t$=new yM,U_=[];class n$ extends Cl{constructor(){super()}createNode(e=[]){return new yM().setLights(e)}getNode(e,t){if(e.isQuadMesh)return t$;U_[0]=e,U_[1]=t;let n=this.get(U_);return n===void 0&&(n=this.createNode(),this.set(U_,n)),U_.length=0,n}}class k_ extends Mr{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 r2=new W,o2=new W;class i$ extends wa{constructor(e,t=!1){super(),this.enabled=!1,this.isPresenting=!1,this.cameraAutoUpdate=!0,this._renderer=e,this._cameraL=new ps,this._cameraL.viewport=new an,this._cameraR=new ps,this._cameraR.viewport=new an,this._cameras=[this._cameraL,this._cameraR],this._cameraXR=new vy,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=c$.bind(this),this._gl=null,this._currentAnimationContext=null,this._currentAnimationLoop=null,this._currentPixelRatio=null,this._currentSize=new Ie,this._onSessionEvent=o$.bind(this),this._onSessionEnd=a$.bind(this),this._onInputSourcesChange=l$.bind(this),this._onAnimationFrame=u$.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&&console.warn("THREE.XRManager: Cannot change framebuffer scale while presenting.")}getReferenceSpaceType(){return this._referenceSpaceType}setReferenceSpaceType(e){this._referenceSpaceType=e,this.isPresenting===!0&&console.warn("THREE.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 ic(e,t),p=new k_(o,a,{format:_i,type:Ui,depthTexture:new Ao(o,a,u.stencil?mo:pi,void 0,void 0,void 0,void 0,void 0,void 0,u.stencil?eo:Or),stencilBuffer:u.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});p._autoAllocateDepthBuffer=!0;const m=new js({color:16777215,side:Be});m.map=p.texture,m.map.offset.y=1,m.map.repeat.y=-1;const y=new vi(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 js({color:16777215,side:Be}),x.plane.material.blending=St,x.plane.material.blendEquation=Ot,x.plane.material.blendSrc=ni,x.plane.material.blendDst=ni,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 rf(e,e,e*t/n,64,64,!0,Math.PI-t/2,t),m=new k_(a,c,{format:_i,type:Ui,depthTexture:new Ao(a,c,d.stencil?mo:pi,void 0,void 0,void 0,void 0,void 0,void 0,d.stencil?eo:Or),stencilBuffer:d.stencil,resolveDepthBuffer:!1,resolveStencilBuffer:!1});m._autoAllocateDepthBuffer=!0;const y=new js({color:16777215,side:Ee});y.map=m.texture,y.map.offset.y=1,y.map.repeat.y=-1;const x=new vi(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 js({color:16777215,side:Ee}),v.plane.material.blending=St,v.plane.material.blendEquation=Ot,v.plane.material.blendSrc=ni,v.plane.material.blendDst=ni,v.xrlayer=this._createXRLayer(v);const M=this._session.renderState.layers;M.unshift(v.xrlayer),this._session.updateRenderState({layers:M})}else m.isXRRenderTarget=!1;return x}renderLayers(){const e=new W,t=new Fs,n=this._renderer,r=this.isPresenting,o=n.getOutputRenderTarget(),a=n._frameBufferTarget;this.isPresenting=!1;const c=new Ie;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 E_(new _s),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 en(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?eo:Or,c=t.stencil?mo:pi);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 Ao(p.textureWidth,p.textureHeight,c,void 0,void 0,void 0,void 0,void 0,void 0,a,y);if(this._xrRenderTarget=new k_(p.textureWidth,p.textureHeight,{format:_i,type:Ui,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 js({color:16777215,side:v.type==="cylinder"?Ee:Be}),v.plane.material.blending=St,v.plane.material.blendEquation=Ot,v.plane.material.blendSrc=ni,v.plane.material.blendDst=ni,v.xrlayer=this._createXRLayer(v),m.unshift(v.xrlayer);e.updateRenderState({layers:m})}else{const a={antialias:t.samples>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 k_(c.framebufferWidth,c.framebufferHeight,{format:_i,type:Ui,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?s$(o,a,c):o.projectionMatrix.copy(a.projectionMatrix),r$(e,o,u)}_getController(e){let t=this._controllers[e];return t===void 0&&(t=new dl,this._controllers[e]=t),t}}function s$(i,e,t){r2.setFromMatrixPosition(e.matrixWorld),o2.setFromMatrixPosition(t.matrixWorld);const n=r2.distanceTo(o2),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),M=v*-p;if(e.matrixWorld.decompose(i.position,i.quaternion,i.scale),i.translateX(M),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 T=a+v,S=c+v,N=y-M,R=x+(n-M),P=u*c/S*T,B=d*c/S*T;i.projectionMatrix.makePerspective(N,R,P,B,T,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 r$(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=gh*2*Math.atan(1/i.projectionMatrix.elements[5]),i.zoom=1)}function o$(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 a$(){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._sessionUsesLayers===!0)for(const t of this._layers)t.renderTarget=new k_(t.pixelwidth,t.pixelheight,{format:_i,type:Ui,depthTexture:new Ao(t.pixelwidth,t.pixelheight,t.stencilBuffer?mo:pi,void 0,void 0,void 0,void 0,void 0,void 0,t.stencilBuffer?eo:Or),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 l$(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 c$(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 u$(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 ps,x.layers.enable(p),x.viewport=new an,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}const l2=new Bp,Jm=new Ie,IM=new an,LM=new Ih,DM=new ka,zv=new Vt,Uu=new an;class h${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,colorBufferType:p=Ts,multiview:m=!1}=t;this.domElement=e.getDomElement(),this.backend=e,this.samples=u||c===!0?4:0,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.alpha=r,this.logarithmicDepthBuffer=n,this.outputColorSpace=Ei,this.toneMapping=Qr,this.toneMappingExposure=1,this.sortObjects=!0,this.depth=o,this.stencil=a,this.info=new r5,this.overrideNodes={modelViewMatrix:null,modelNormalViewMatrix:null},this.library=new s2,this.lighting=new n$,this._getFallback=d,this._pixelRatio=1,this._width=this.domElement.width,this._height=this.domElement.height,this._viewport=new an(0,0,this._width,this._height),this._scissor=new an(0,0,this._width,this._height),this._scissorTest=!1,this._attributes=null,this._geometries=null,this._nodes=null,this._animation=null,this._bindings=null,this._objects=null,this._pipelines=null,this._bundles=null,this._renderLists=null,this._renderContexts=null,this._textures=null,this._background=null,this._quad=new E_(new _s),this._quad.material.name="Renderer_output",this._currentRenderContext=null,this._opaqueSort=null,this._transparentSort=null,this._frameBufferTarget=null;const y=this.alpha===!0?0:1;this._clearColor=new nM(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._colorBufferType=p,this._initialized=!1,this._initPromise=null,this._compilationPromises=null,this.transparent=!0,this.opaque=!0,this.shadowMap={enabled:!1,type:Me},this.xr=new i$(this,m),this.debug={checkShaderErrors:!0,onShaderError:null,getShaderAsync:(x,v,M)=>en(this,null,function*(){yield this.compileAsync(x,v);const T=this._renderLists.get(x,v),S=this._renderContexts.get(x,v,this._renderTarget),N=x.overrideMaterial||M.material,R=this._objects.get(M,N,x,v,T.lightsNode,S,S.clippingContext),{fragmentShader:P,vertexShader:B}=R.getNodeBuilderState();return{fragmentShader:P,vertexShader:B}})}}init(){return en(this,null,function*(){if(this._initialized)throw new Error("Renderer: Backend has already been initialized.");return this._initPromise!==null?this._initPromise:(this._initPromise=new Promise((e,t)=>en(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 J8(this,n),this._animation=new Z4(this._nodes,this.info),this._attributes=new i5(n),this._background=new p8(this,this._nodes),this._geometries=new s5(this._attributes,this.info),this._textures=new v5(this,n,this.info),this._pipelines=new c5(n,this._nodes),this._bindings=new u5(n,this._nodes,this._textures,this._attributes,this._pipelines,this.info),this._objects=new e5(this,this._nodes,this._geometries,this._pipelines,this._bindings,this.info),this._renderLists=new f5(this.lighting),this._bundles=new e$,this._renderContexts=new _5,this._animation.start(),this._initialized=!0,e(this)})),this._initPromise)})}get coordinateSystem(){return this.backend.coordinateSystem}compileAsync(e,t,n=null){return en(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:l2;n===null&&(n=e);const p=this._renderTarget,m=this._renderContexts.get(n,t,p),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 kv),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(R){R.isLight&&R.layers.test(t.layers)&&v.pushLight(R)}),v.finish(),p!==null){this._textures.updateRenderTarget(p,y);const R=this._textures.get(p);m.textures=R.textures,m.depthTexture=R.depthTexture}else m.textures=null,m.depthTexture=null;this._background.update(d,v,m);const M=v.opaque,T=v.transparent,S=v.transparentDoublePass,N=v.lightsNode;this.opaque===!0&&M.length>0&&this._renderObjects(M,t,d,N),this.transparent===!0&&T.length>0&&this._renderTransparents(T,S,t,d,N),r.renderId=o,this._currentRenderContext=a,this._currentRenderObjectFunction=c,this._compilationPromises=u,this._handleObjectFunction=this._renderObjectDirect,yield Promise.all(x)})}renderAsync(e,t){return en(this,null,function*(){this._initialized===!1&&(yield this.init()),this._renderScene(e,t)})}waitForGPU(){return en(this,null,function*(){yield this.backend.waitForGPU()})}set highPrecision(e){e===!0?(this.overrideNodes.modelViewMatrix=sw,this.overrideNodes.modelNormalViewMatrix=rw):this.highPrecision&&(this.overrideNodes.modelViewMatrix=null,this.overrideNodes.modelNormalViewMatrix=null)}get highPrecision(){return this.overrideNodes.modelViewMatrix===sw&&this.overrideNodes.modelNormalViewMatrix===rw}setMRT(e){return this._mrt=e,this}getMRT(){return this._mrt}getColorBufferType(){return this._colorBufferType}_onDeviceLost(e){let t=`THREE.WebGPURenderer: ${e.api} Device Lost:
|
|
|
|
Message: ${e.message}`;e.reason&&(t+=`
|
|
Reason: ${e.reason}`),console.error(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 M=y[x];this._nodes.needsRefresh(M)&&(this._nodes.updateBefore(M),this._nodes.updateForRender(M),this._bindings.updateForRender(M),this._nodes.updateAfter(M))}}this.backend.addBundle(c,u)}render(e,t){if(this._initialized===!1)return console.warn("THREE.Renderer: .render() called before the backend is initialized. Try using .renderAsync() instead."),this.renderAsync(e,t);this._renderScene(e,t)}_getFrameBufferTarget(){const{currentToneMapping:e,currentColorSpace:t}=this,n=e!==Qr,r=t!==pn.workingColorSpace;if(n===!1&&r===!1)return null;const{width:o,height:a}=this.getDrawingBufferSize(Jm),{depth:c,stencil:u}=this;let d=this._frameBufferTarget;d===null&&(d=new Mr(o,a,{depthBuffer:c,stencilBuffer:u,type:this._colorBufferType,format:_i,colorSpace:pn.workingColorSpace,generateMipmaps:!1,minFilter:Yn,magFilter:Yn,samples:this.samples}),d.isPostProcessingRenderTarget=!0,this._frameBufferTarget=d);const p=this.getOutputRenderTarget();return d.depthBuffer=c,d.stencilBuffer=u,p!==null?d.setSize(p.width,p.height,p.depth):d.setSize(o,a,1),d.viewport.copy(this._viewport),d.scissor.copy(this._scissor),d.viewport.multiplyScalar(this._pixelRatio),d.scissor.multiplyScalar(this._pixelRatio),d.scissorTest=this._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:l2,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._currentRenderContext=v,this._currentRenderObjectFunction=this._renderObjectFunction||this.renderObject,this.info.calls++,this.info.render.calls++,this.info.render.frameCalls++,o.renderId=this.info.calls;const M=this.coordinateSystem,T=this.xr;if(t.coordinateSystem!==M&&T.isPresenting===!1&&(t.coordinateSystem=M,t.updateProjectionMatrix(),t.isArrayCamera))for(const pe of t.cameras)pe.coordinateSystem=M,pe.updateProjectionMatrix();e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),T.enabled===!0&&T.isPresenting===!0&&(T.cameraAutoUpdate===!0&&T.updateCamera(t),t=T.getCamera());let S=this._viewport,N=this._scissor,R=this._pixelRatio;x!==null&&(S=x.viewport,N=x.scissor,R=1),this.getDrawingBufferSize(Jm),IM.set(0,0,Jm.width,Jm.height);const P=S.minDepth===void 0?0:S.minDepth,B=S.maxDepth===void 0?1:S.maxDepth;v.viewportValue.copy(S).multiplyScalar(R).floor(),v.viewportValue.width>>=y,v.viewportValue.height>>=y,v.viewportValue.minDepth=P,v.viewportValue.maxDepth=B,v.viewport=v.viewportValue.equals(IM)===!1,v.scissorValue.copy(N).multiplyScalar(R).floor(),v.scissor=this._scissorTest&&v.scissorValue.equals(IM)===!1,v.scissorValue.width>>=y,v.scissorValue.height>>=y,v.clippingContext||(v.clippingContext=new kv),v.clippingContext.updateGlobal(d,t),d.onBeforeRender(this,e,t,x);const F=t.isArrayCamera?DM:LM;t.isArrayCamera||(zv.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),F.setFromProjectionMatrix(zv,t.coordinateSystem,t.reversedDepth));const k=this._renderLists.get(e,t);if(k.begin(),this._projectObject(e,t,0,k,v.clippingContext),k.finish(),this.sortObjects===!0&&k.sort(this._opaqueSort,this._transparentSort),x!==null){this._textures.updateRenderTarget(x,y);const pe=this._textures.get(x);v.textures=pe.textures,v.depthTexture=pe.depthTexture,v.width=pe.width,v.height=pe.height,v.renderTarget=x,v.depth=x.depthBuffer,v.stencil=x.stencilBuffer}else v.textures=null,v.depthTexture=null,v.width=Jm.width,v.height=Jm.height,v.depth=this.depth,v.stencil=this.stencil;v.width>>=y,v.height>>=y,v.activeCubeFace=m,v.activeMipmapLevel=y,v.occlusionQueryCount=k.occlusionQueryCount,v.scissorValue.max(Uu.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,k,v),v.camera=t,this.backend.beginRender(v);const{bundles:V,lightsNode:U,transparentDoublePass:z,transparent:j,opaque:se}=k;return V.length>0&&this._renderBundles(V,d,U),this.opaque===!0&&se.length>0&&this._renderObjects(se,t,d,U),this.transparent===!0&&j.length>0&&this._renderTransparents(j,z,t,d,U),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),v}_setXRLayerSize(e,t){this._width=e,this._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 en(this,null,function*(){this._initialized===!1&&(yield this.init()),this._animation.setAnimationLoop(e)})}getArrayBufferAsync(e){return en(this,null,function*(){return yield this.backend.getArrayBufferAsync(e)})}getContext(){return this.backend.getContext()}getPixelRatio(){return this._pixelRatio}getDrawingBufferSize(e){return e.set(this._width*this._pixelRatio,this._height*this._pixelRatio).floor()}getSize(e){return e.set(this._width,this._height)}setPixelRatio(e=1){this._pixelRatio!==e&&(this._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._initialized&&this.backend.updateSize())}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._initialized&&this.backend.updateSize())}setOpaqueSort(e){this._opaqueSort=e}setTransparentSort(e){this._transparentSort=e}getScissor(e){const t=this._scissor;return e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,e}setScissor(e,t,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,this.backend.setScissorTest(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}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)return console.warn("THREE.Renderer: .clear() called before the backend is initialized. Try using .clearAsync() instead."),this.clearAsync(e,t,n);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(){return this.clear(!0,!1,!1)}clearDepth(){return this.clear(!1,!0,!1)}clearStencil(){return this.clear(!1,!1,!0)}clearAsync(e=!0,t=!0,n=!0){return en(this,null,function*(){this._initialized===!1&&(yield this.init()),this.clear(e,t,n)})}clearColorAsync(){return en(this,null,function*(){this.clearAsync(!0,!1,!1)})}clearDepthAsync(){return en(this,null,function*(){this.clearAsync(!1,!0,!1)})}clearStencilAsync(){return en(this,null,function*(){this.clearAsync(!1,!1,!0)})}get currentToneMapping(){return this.isOutputTarget?this.toneMapping:Qr}get currentColorSpace(){return this.isOutputTarget?this.outputColorSpace:pn.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._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}_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 console.warn("THREE.Renderer: .compute() called before the backend is initialized. Try using .computeAsync() instead."),this.computeAsync(e);const n=this._nodes.nodeFrame,r=n.renderId;this.info.calls++,this.info.compute.calls++,this.info.compute.frameCalls++,n.renderId=this.info.calls;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.delete(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}computeAsync(e,t=null){return en(this,null,function*(){this._initialized===!1&&(yield this.init()),this.compute(e,t)})}hasFeatureAsync(e){return en(this,null,function*(){return this._initialized===!1&&(yield this.init()),this.backend.hasFeature(e)})}resolveTimestampsAsync(e="render"){return en(this,null,function*(){return this._initialized===!1&&(yield this.init()),this.backend.resolveTimestampsAsync(e)})}hasFeature(e){return this._initialized===!1?(console.warn("THREE.Renderer: .hasFeature() called before the backend is initialized. Try using .hasFeatureAsync() instead."),!1):this.backend.hasFeature(e)}hasInitialized(){return this._initialized}initTextureAsync(e){return en(this,null,function*(){this._initialized===!1&&(yield this.init()),this._textures.updateTexture(e)})}initTexture(e){this._initialized===!1&&console.warn("THREE.Renderer: .initTexture() called before the backend is initialized. Try using .initTextureAsync() instead."),this._textures.updateTexture(e)}copyFramebufferToTexture(e,t=null){if(t!==null)if(t.isVector2)t=Uu.set(t.x,t.y,e.image.width,e.image.height).floor();else if(t.isVector4)t=Uu.copy(t).floor();else{console.error("THREE.Renderer.copyFramebufferToTexture: Invalid rectangle.");return}else t=Uu.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)}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)}readRenderTargetPixelsAsync(e,t,n,r,o,a=0,c=0){return en(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?DM:LM;if(!e.frustumCulled||u.intersectsSprite(e,t)){this.sortObjects===!0&&Uu.setFromMatrixPosition(e.matrixWorld).applyMatrix4(zv);const{geometry:d,material:p}=e;p.visible&&r.push(e,d,p,n,Uu.z,null,o)}}else if(e.isLineLoop)console.error("THREE.Renderer: Objects of type THREE.LineLoop are not supported. Please use THREE.Line or THREE.LineSegments.");else if(e.isMesh||e.isLine||e.isPoints){const u=t.isArrayCamera?DM:LM;if(!e.frustumCulled||u.intersectsObject(e,t)){const{geometry:d,material:p}=e;if(this.sortObjects===!0&&(d.boundingSphere===null&&d.computeBoundingSphere(),Uu.copy(d.boundingSphere.center).applyMatrix4(e.matrixWorld).applyMatrix4(zv)),Array.isArray(p)){const m=d.groups;for(let y=0,x=m.length;y<x;y++){const v=m[y],M=p[v.materialIndex];M&&M.visible&&r.push(e,d,M,n,Uu.z,v,o)}}else p.visible&&r.push(e,d,p,n,Uu.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=Ee;this._renderObjects(t,n,r,o,"backSide");for(const{material:a}of t)a.side=Be;this._renderObjects(e,n,r,o);for(const{material:a}of t)a.side=ke}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)}}renderObject(e,t,n,r,o,a,c,u=null,d=null){let p,m,y;if(e.onBeforeRender(this,t,n,r,o,a),o.allowOverride===!0&&t.overrideMaterial!==null){const x=t.overrideMaterial;o.positionNode&&o.positionNode.isNode&&(p=x.positionNode,x.positionNode=o.positionNode),x.alphaTest=o.alphaTest,x.alphaMap=o.alphaMap,x.transparent=o.transparent||o.transmission>0,x.isShadowPassMaterial&&(x.side=o.shadowSide===null?o.side:o.shadowSide,o.depthNode&&o.depthNode.isNode&&(y=x.depthNode,x.depthNode=o.depthNode),o.castShadowNode&&o.castShadowNode.isNode&&(m=x.colorNode,x.colorNode=o.castShadowNode),o.castShadowPositionNode&&o.castShadowPositionNode.isNode&&(p=x.positionNode,x.positionNode=o.castShadowPositionNode)),o=x}o.transparent===!0&&o.side===ke&&o.forceSinglePass===!1?(o.side=Ee,this._handleObjectFunction(e,o,t,n,c,a,u,"backSide"),o.side=Be,this._handleObjectFunction(e,o,t,n,c,a,u,d),o.side=ke):this._handleObjectFunction(e,o,t,n,c,a,u,d),p!==void 0&&(t.overrideMaterial.positionNode=p),y!==void 0&&(t.overrideMaterial.depthNode=y),m!==void 0&&(t.overrideMaterial.colorNode=m),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)}get compile(){return this.compileAsync}}class c2{constructor(e=""){this.name=e,this.visibility=0}setVisibility(e){this.visibility|=e}clone(){return Object.assign(new this.constructor,this)}}function d$(i){return i+(md-i%md)%md}class u2 extends c2{constructor(e,t=null){super(e),this.isBuffer=!0,this.bytesPerElement=Float32Array.BYTES_PER_ELEMENT,this._buffer=t}get byteLength(){return d$(this._buffer.byteLength)}get buffer(){return this._buffer}update(){return!0}}class h2 extends u2{constructor(e,t=null){super(e,t),this.isUniformBuffer=!0}}let f$=0;class d2 extends h2{constructor(e,t){super("UniformBuffer_"+f$++,e?e.value:null),this.nodeUniform=e,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class p$ extends h2{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%md,d=u%a,p=u+d;t+=d,p!==0&&md-p<c&&(t+=md-p),o.offset=t/e,t+=c}return Math.ceil(t/md)*md}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);console.error("THREE.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 g$(n,r,o)===!1&&(this.buffer.set(r,o),m$(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 m$(i,e,t){for(let n=0,r=e.length;n<r;n++)i[t+n]=e[n]}function g$(i,e,t){for(let n=0,r=e.length;n<r;n++)if(i[t+n]!==e[n])return!1;return!0}let y$=0;class f2 extends p${constructor(e,t){super(e),this.id=y$++,this.groupNode=t,this.isNodeUniformsGroup=!0}}class p2 extends c2{constructor(e,t){super(e),this.texture=t,this.version=t?t.version:0,this.generation=null,this.isSampler=!0}set texture(e){if(this._texture===e)return;const t=()=>{this._texture=null,this.generation=null,this.version=0};this._texture&&this._texture.removeEventListener("dispose",t),this._texture=e,this.generation=null,this.version=0,this._texture&&this._texture.addEventListener("dispose",t)}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.texture=this.texture,e}}let _$=0;class x$ extends p2{constructor(e,t){super(e,t),this.id=_$++,this.store=!1,this.isSampledTexture=!0}}class Vv extends x${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 m2 extends Vv{constructor(e,t,n,r=null){super(e,t,n,r),this.isSampledCubeTexture=!0}}class FM extends Vv{constructor(e,t,n,r=null){super(e,t,n,r),this.isSampledTexture3D=!0}}const g2={textureDimensions:"textureSize",equals:"equal",bitcast_float_int:"floatBitsToInt",bitcast_int_float:"intBitsToFloat",bitcast_uint_float:"uintBitsToFloat",bitcast_float_uint:"floatBitsToUint"},v$={low:"lowp",medium:"mediump",high:"highp"},y2={swizzleAssign:!0,storageBuffer:!1},_2={perspective:"smooth",linear:"noperspective"},x2={centroid:"centroid"},v2=`
|
|
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 b$ extends QI{constructor(e,t){super(e,t,new K8),this.uniformGroups={},this.transforms=[],this.extensions={},this.builtins={vertex:[],fragment:[],compute:[]}}needsToWorkingColorSpace(e){return e.isVideoTexture===!0&&e.colorSpace!==br}getMethod(e){return g2[e]||e}getBitcastMethod(e,t){return g2[`bitcast_${t}_${e}`]}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?Dl:Fc;o===2?c=a?qu:rl:o===3?c=a?R1:bd:o===4&&(c=a?Xu:_i);const u={Float32Array:mi,Uint8Array:Ui,Uint16Array:Go,Uint32Array:pi,Int8Array:Lc,Int16Array:Dc,Int32Array:Ws,Uint8ClampedArray:Ui},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 oo(t.array,d,p,c,u[t.array.constructor.name]||mi);x.needsUpdate=!0,x.isPBOTexture=!0;const v=new yc(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="."+Uf.join("").slice(0,x),M=`ivec2(${c} % ${y}, ${c} / ${y})`,T=this.generateTextureLoad(null,a,M,null,null,"0");let S="vec4";r.pbo.type===pi?S="uvec4":r.pbo.type===Ws&&(S="ivec4"),this.addLineFlowCode(`${d} = ${S}(${T})${v}`,e),u.propertyName=d}return d}generateTextureLoad(e,t,n,r,o,a="0"){let c;return r?o?c=`texelFetchOffset( ${t}, ivec3( ${n}, ${r} ), ${a}, ${o} )`:c=`texelFetch( ${t}, ivec3( ${n}, ${r} ), ${a} )`:o?c=`texelFetchOffset( ${t}, ${n}, ${a}, ${o} )`:c=`texelFetch( ${t}, ${n}, ${a} )`,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 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} ) )`;console.error(`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===pi?m="u":p.type===Ws&&(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==="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=v$[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!==Ws){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=_2[r.interpolationType]||r.interpolationType,c=x2[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=_2[r.interpolationType]||r.interpolationType,c=x2[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`}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=y2[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)}y2[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
|
|
${v2}
|
|
|
|
// 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
|
|
${v2}
|
|
|
|
// uniforms
|
|
${e.uniforms}
|
|
|
|
// varyings
|
|
${e.varyings}
|
|
|
|
// codes
|
|
${e.codes}
|
|
|
|
// structs
|
|
${e.structs}
|
|
|
|
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 Vv(o.name,o.node,u),p.push(c);else if(t==="cubeTexture")c=new m2(o.name,o.node,u),p.push(c);else if(t==="texture3D")c=new FM(o.name,o.node,u),p.push(c);else if(t==="buffer"){e.name=`NodeBuffer_${e.id}`,o.name=`buffer${e.id}`;const m=new d2(e,u);m.name=e.name,p.push(m),c=m}else{const m=this.uniformGroups[n]||(this.uniformGroups[n]={});let y=m[d];y===void 0&&(y=new f2(n+"_"+d,u),m[d]=y,p.push(y)),c=this.getNodeUniform(o,t),y.addUniform(c)}a.uniformGPU=c}return o}}let BM=null,Qm=null;class b2{constructor(e={}){this.parameters=Object.assign({},e),this.data=new WeakMap,this.renderer=null,this.domElement=null,this.timestampQueryPool={render:null,compute:null},this.trackTimestamp=e.trackTimestamp===!0}init(e){return en(this,null,function*(){this.renderer=e})}get coordinateSystem(){}beginRender(){}finishRender(){}beginCompute(){}finishCompute(){}draw(){}compute(){}createProgram(){}destroyProgram(){}createBindings(){}updateBindings(){}updateBinding(){}createRenderPipeline(){}createComputePipeline(){}needsRenderUpdate(){}getRenderCacheKey(){}createNodeBuilder(){}createSampler(){}destroySampler(){}createDefaultTexture(){}createTexture(){}updateTexture(){}generateMipmaps(){}destroyTexture(){}copyTextureToBuffer(){return en(this,null,function*(){})}copyTextureToTexture(){}copyFramebufferToTexture(){}createAttribute(){}createIndexAttribute(){}createStorageAttribute(){}updateAttribute(){}destroyAttribute(){}getContext(){}updateSize(){}updateViewport(){}getTimestampUID(e){const t=this.get(e);let n=e.isComputeNode===!0?"c":"r";return n+=":"+t.frameCalls+":"+e.id,n}isOccluded(){}resolveTimestampsAsync(e="render"){return en(this,null,function*(){if(!this.trackTimestamp){wr("WebGPURenderer: Timestamp tracking is disabled.");return}const t=this.timestampQueryPool[e];if(!t){wr(`WebGPURenderer: No timestamp query pool for type '${e}' found.`);return}const n=yield t.resolveQueriesAsync();return this.renderer.info[e].timestamp=n,n})}waitForGPU(){return en(this,null,function*(){})}getArrayBufferAsync(){return en(this,null,function*(){})}hasFeatureAsync(){return en(this,null,function*(){})}hasFeature(){}getMaxAnisotropy(){}getDrawingBufferSize(){return BM=BM||new Ie,this.renderer.getDrawingBufferSize(BM)}setScissorTest(){}getClearColor(){const e=this.renderer;return Qm=Qm||new nM,e.getClearColor(Qm),Qm.getRGB(Qm),Qm}getDomElement(){let e=this.domElement;return e===null&&(e=this.parameters.canvas!==void 0?this.parameters.canvas:hr(),"setAttribute"in e&&e.setAttribute("data-engine",`three.js r${_e} webgpu`),this.domElement=e),e}set(e,t){this.data.set(e,t)}get(e){let t=this.data.get(e);return t===void 0&&(t={},this.data.set(e,t)),t}has(e){return this.data.has(e)}delete(e){this.data.delete(e)}dispose(){}}let S$=0;class T${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 w${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===Ws,id:S$++};if(e.isStorageBufferAttribute||e.isStorageInstancedBufferAttribute){const y=this._createBuffer(r,t,o,a);m=new T$(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 en(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 OM,z_;class M${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;OM={[Ot]:e.FUNC_ADD,[Fn]:e.FUNC_SUBTRACT,[os]:e.FUNC_REVERSE_SUBTRACT},z_={[ni]:e.ZERO,[bs]:e.ONE,[vr]:e.SRC_COLOR,[Kr]:e.SRC_ALPHA,[On]:e.SRC_ALPHA_SATURATE,[Tt]:e.DST_COLOR,[xa]:e.DST_ALPHA,[Zr]:e.ONE_MINUS_SRC_COLOR,[Ss]:e.ONE_MINUS_SRC_ALPHA,[rn]:e.ONE_MINUS_DST_COLOR,[va]:e.ONE_MINUS_DST_ALPHA};const t=e.getParameter(e.SCISSOR_BOX),n=e.getParameter(e.VIEWPORT);this.currentScissor=new an().fromArray(t),this.currentViewport=new an().fromArray(n),this._tempVec4=new an}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!==X?(this.enable(t.CULL_FACE),e!==this.currentCullFace&&(e===J?t.cullFace(t.BACK):e===oe?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)}setBlending(e,t,n,r,o,a,c,u){const{gl:d}=this;if(e===Ae){this.currentBlendingEnabled===!0&&(this.disable(d.BLEND),this.currentBlendingEnabled=!1);return}if(this.currentBlendingEnabled===!1&&(this.enable(d.BLEND),this.currentBlendingEnabled=!0),e!==St){if(e!==this.currentBlending||u!==this.currentPremultipledAlpha){if((this.currentBlendEquation!==Ot||this.currentBlendEquationAlpha!==Ot)&&(d.blendEquation(d.FUNC_ADD),this.currentBlendEquation=Ot,this.currentBlendEquationAlpha=Ot),u)switch(e){case qe:d.blendFuncSeparate(d.ONE,d.ONE_MINUS_SRC_ALPHA,d.ONE,d.ONE_MINUS_SRC_ALPHA);break;case et:d.blendFunc(d.ONE,d.ONE);break;case rt:d.blendFuncSeparate(d.ZERO,d.ONE_MINUS_SRC_COLOR,d.ZERO,d.ONE);break;case at:d.blendFuncSeparate(d.DST_COLOR,d.ONE_MINUS_SRC_ALPHA,d.ZERO,d.ONE);break;default:console.error("THREE.WebGLState: Invalid blending: ",e);break}else switch(e){case qe:d.blendFuncSeparate(d.SRC_ALPHA,d.ONE_MINUS_SRC_ALPHA,d.ONE,d.ONE_MINUS_SRC_ALPHA);break;case et:d.blendFuncSeparate(d.SRC_ALPHA,d.ONE,d.ONE,d.ONE);break;case rt:console.error("THREE.WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case at:console.error("THREE.WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:console.error("THREE.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(OM[t],OM[o]),this.currentBlendEquation=t,this.currentBlendEquationAlpha=o),(n!==this.currentBlendSrc||r!==this.currentBlendDst||a!==this.currentBlendSrcAlpha||c!==this.currentBlendDstAlpha)&&(d.blendFuncSeparate(z_[n],z_[r],z_[a],z_[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 Wu:t.depthFunc(t.NEVER);break;case Sn:t.depthFunc(t.ALWAYS);break;case yi:t.depthFunc(t.LESS);break;case Jr:t.depthFunc(t.LEQUAL);break;case Ec:t.depthFunc(t.EQUAL);break;case Cc:t.depthFunc(t.GEQUAL);break;case pp:t.depthFunc(t.GREATER);break;case mp: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?t.enable(t.SCISSOR_TEST):t.disable(t.SCISSOR_TEST)}setStencilTest(e){const{gl:t}=this;e?this.enable(t.STENCIL_TEST):this.disable(t.STENCIL_TEST)}setStencilMask(e){this.currentStencilMask!==e&&(this.gl.stencilMask(e),this.currentStencilMask=e)}setStencilFunc(e,t,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===ke?this.disable(r.CULL_FACE):this.enable(r.CULL_FACE);let o=e.side===Ee;t&&(o=!o),this.setFlipSided(o),e.blending===qe&&e.transparent===!1?this.setBlending(Ae):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.samples>1?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 A${constructor(e){this.backend=e,this.gl=this.backend.gl,this.extensions=e.extensions}convert(e,t=br){const{gl:n,extensions:r}=this;let o;const a=pn.getTransfer(t);if(e===Ui)return n.UNSIGNED_BYTE;if(e===yp)return n.UNSIGNED_SHORT_4_4_4_4;if(e===_p)return n.UNSIGNED_SHORT_5_5_5_1;if(e===xp)return n.UNSIGNED_INT_5_9_9_9_REV;if(e===vp)return n.UNSIGNED_INT_10F_11F_11F_REV;if(e===Lc)return n.BYTE;if(e===Dc)return n.SHORT;if(e===Go)return n.UNSIGNED_SHORT;if(e===Ws)return n.INT;if(e===pi)return n.UNSIGNED_INT;if(e===mi)return n.FLOAT;if(e===Ts)return n.HALF_FLOAT;if(e===cg)return n.ALPHA;if(e===bd)return n.RGB;if(e===_i)return n.RGBA;if(e===Or)return n.DEPTH_COMPONENT;if(e===eo)return n.DEPTH_STENCIL;if(e===Fc)return n.RED;if(e===Dl)return n.RED_INTEGER;if(e===rl)return n.RG;if(e===qu)return n.RG_INTEGER;if(e===Xu)return n.RGBA_INTEGER;if(e===Fl||e===Bl||e===Ol||e===Ul)if(a===Dt)if(o=r.get("WEBGL_compressed_texture_s3tc_srgb"),o!==null){if(e===Fl)return o.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(e===Bl)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(e===Ol)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(e===Ul)return o.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(o=r.get("WEBGL_compressed_texture_s3tc"),o!==null){if(e===Fl)return o.COMPRESSED_RGB_S3TC_DXT1_EXT;if(e===Bl)return o.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(e===Ol)return o.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(e===Ul)return o.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(e===Sd||e===Td||e===wd||e===Md)if(o=r.get("WEBGL_compressed_texture_pvrtc"),o!==null){if(e===Sd)return o.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(e===Td)return o.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(e===wd)return o.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(e===Md)return o.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(e===ju||e===Yu||e===Zu)if(o=r.get("WEBGL_compressed_texture_etc"),o!==null){if(e===ju||e===Yu)return a===Dt?o.COMPRESSED_SRGB8_ETC2:o.COMPRESSED_RGB8_ETC2;if(e===Zu)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:o.COMPRESSED_RGBA8_ETC2_EAC}else return null;if(e===Ku||e===Ju||e===Qu||e===eh||e===th||e===nh||e===ih||e===sh||e===rh||e===oh||e===ah||e===lh||e===ch||e===uh)if(o=r.get("WEBGL_compressed_texture_astc"),o!==null){if(e===Ku)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:o.COMPRESSED_RGBA_ASTC_4x4_KHR;if(e===Ju)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:o.COMPRESSED_RGBA_ASTC_5x4_KHR;if(e===Qu)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:o.COMPRESSED_RGBA_ASTC_5x5_KHR;if(e===eh)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:o.COMPRESSED_RGBA_ASTC_6x5_KHR;if(e===th)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:o.COMPRESSED_RGBA_ASTC_6x6_KHR;if(e===nh)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:o.COMPRESSED_RGBA_ASTC_8x5_KHR;if(e===ih)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:o.COMPRESSED_RGBA_ASTC_8x6_KHR;if(e===sh)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:o.COMPRESSED_RGBA_ASTC_8x8_KHR;if(e===rh)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:o.COMPRESSED_RGBA_ASTC_10x5_KHR;if(e===oh)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:o.COMPRESSED_RGBA_ASTC_10x6_KHR;if(e===ah)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:o.COMPRESSED_RGBA_ASTC_10x8_KHR;if(e===lh)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:o.COMPRESSED_RGBA_ASTC_10x10_KHR;if(e===ch)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:o.COMPRESSED_RGBA_ASTC_12x10_KHR;if(e===uh)return a===Dt?o.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:o.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(e===hh)if(o=r.get("EXT_texture_compression_bptc"),o!==null){if(e===hh)return a===Dt?o.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:o.COMPRESSED_RGBA_BPTC_UNORM_EXT}else return null;if(e===dh||e===fh||e===ph||e===mh)if(o=r.get("EXT_texture_compression_rgtc"),o!==null){if(e===dh)return o.COMPRESSED_RED_RGTC1_EXT;if(e===fh)return o.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(e===ph)return o.COMPRESSED_RED_GREEN_RGTC2_EXT;if(e===mh)return o.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return e===mo?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 S2=!1,Gv,UM,T2;class E${constructor(e){this.backend=e,this.gl=e.gl,this.extensions=e.extensions,this.defaultTextures={},S2===!1&&(this._init(),S2=!0)}_init(){const e=this.gl;Gv={[ba]:e.REPEAT,[Ki]:e.CLAMP_TO_EDGE,[Sa]:e.MIRRORED_REPEAT},UM={[Jn]:e.NEAREST,[gp]:e.NEAREST_MIPMAP_NEAREST,[Ta]:e.NEAREST_MIPMAP_LINEAR,[Yn]:e.LINEAR,[Ic]:e.LINEAR_MIPMAP_NEAREST,[Ds]:e.LINEAR_MIPMAP_LINEAR},T2={[Q_]:e.NEVER,[s0]:e.ALWAYS,[fg]:e.LESS,[pg]:e.LEQUAL,[e0]:e.EQUAL,[i0]:e.GEQUAL,[t0]:e.GREATER,[n0]: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];console.warn("THREE.WebGLRenderer: 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?Uc:pn.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===Dt?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?Uc:pn.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===Dt?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=pn.getPrimaries(pn.workingColorSpace),c=t.colorSpace===br?null:pn.getPrimaries(t.colorSpace),u=t.colorSpace===br||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,Gv[t.wrapS]),n.texParameteri(e,n.TEXTURE_WRAP_T,Gv[t.wrapT]),(e===n.TEXTURE_3D||e===n.TEXTURE_2D_ARRAY)&&(t.isArrayTexture||n.texParameteri(e,n.TEXTURE_WRAP_R,Gv[t.wrapR])),n.texParameteri(e,n.TEXTURE_MAG_FILTER,UM[t.magFilter]);const d=t.mipmaps!==void 0&&t.mipmaps.length>0,p=t.minFilter===Yn&&d?Ds:t.minFilter;if(n.texParameteri(e,n.TEXTURE_MIN_FILTER,UM[p]),t.compareFunction&&(n.texParameteri(e,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(e,n.TEXTURE_COMPARE_FUNC,T2[t.compareFunction])),r.has("EXT_texture_filter_anisotropic")===!0){if(t.magFilter===Jn||t.minFilter!==Ta&&t.minFilter!==Ds||t.type===mi&&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,isDefault:!0})}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):console.warn("THREE.WebGLRenderer: 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):console.warn("Unsupported compressed texture format")}}else if(e.isCubeTexture){const m=t.images,y=e.mipmaps;for(let x=0;x<6;x++){const v=Hv(m[x]);n.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+x,0,0,0,r,o,u,d,v);for(let M=0;M<y.length;M++){const T=y[M],S=Hv(T.images[x]);n.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+x,M+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=Ly(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],M=Hv(v);n.texSubImage2D(c,y,0,0,v.width,v.height,u,d,M)}else{const y=Hv(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){const{gl:t,backend:n}=this,{textureGPU:r,renderTarget:o}=n.get(e);this.deallocateRenderBuffers(o),t.deleteTexture(r),n.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,M,T,S,N,R,P,B,F;const k=e.isCompressedTexture?e.mipmaps[a]:e.image;if(n!==null)v=n.max.x-n.min.x,M=n.max.y-n.min.y,T=n.isBox3?n.max.z-n.min.z:1,S=n.min.x,N=n.min.y,R=n.isBox3?n.min.z:0;else{const be=Math.pow(2,-o);v=Math.floor(k.width*be),M=Math.floor(k.height*be),e.isDataArrayTexture||e.isArrayTexture?T=k.depth:e.isData3DTexture?T=Math.floor(k.depth*be):T=1,S=0,N=0,R=0}r!==null?(P=r.x,B=r.y,F=r.z):(P=0,B=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 V=c.getParameter(c.UNPACK_ROW_LENGTH),U=c.getParameter(c.UNPACK_IMAGE_HEIGHT),z=c.getParameter(c.UNPACK_SKIP_PIXELS),j=c.getParameter(c.UNPACK_SKIP_ROWS),se=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,N),c.pixelStorei(c.UNPACK_SKIP_IMAGES,R);const pe=t.isDataArrayTexture||t.isData3DTexture||t.isArrayTexture;if(e.isRenderTargetTexture||e.isDepthTexture){const be=u.get(e),Pe=u.get(t),Ce=u.get(be.renderTarget),nt=u.get(Pe.renderTarget),Le=Ce.framebuffers[be.cacheKey],ht=nt.framebuffers[Pe.cacheKey];d.bindFramebuffer(c.READ_FRAMEBUFFER,Le),d.bindFramebuffer(c.DRAW_FRAMEBUFFER,ht);let De=c.COLOR_BUFFER_BIT;e.isDepthTexture&&(De=c.DEPTH_BUFFER_BIT),c.blitFramebuffer(S,N,v,M,P,B,v,M,De,c.NEAREST),d.bindFramebuffer(c.READ_FRAMEBUFFER,null),d.bindFramebuffer(c.DRAW_FRAMEBUFFER,null)}else pe?e.isDataTexture||e.isData3DTexture?c.texSubImage3D(m,a,P,B,F,v,M,T,x,y,k.data):t.isCompressedArrayTexture?c.compressedTexSubImage3D(m,a,P,B,F,v,M,T,x,k.data):c.texSubImage3D(m,a,P,B,F,v,M,T,x,y,k):e.isDataTexture?c.texSubImage2D(m,a,P,B,v,M,x,y,k.data):e.isCompressedTexture?c.compressedTexSubImage2D(m,a,P,B,k.width,k.height,x,k.data):c.texSubImage2D(m,a,P,B,v,M,x,y,k);c.pixelStorei(c.UNPACK_ROW_LENGTH,V),c.pixelStorei(c.UNPACK_IMAGE_HEIGHT,U),c.pixelStorei(c.UNPACK_SKIP_PIXELS,z),c.pixelStorei(c.UNPACK_SKIP_ROWS,j),c.pixelStorei(c.UNPACK_SKIP_IMAGES,se),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,M;if(e.isDepthTexture===!0?(v=r.DEPTH_BUFFER_BIT,M=r.DEPTH_ATTACHMENT,t.stencil&&(v|=r.STENCIL_BUFFER_BIT)):(v=r.COLOR_BUFFER_BIT,M=r.COLOR_ATTACHMENT0),x){const T=this.backend.get(t.renderTarget),S=T.framebuffers[t.getCacheKey()],N=T.msaaFrameBuffer;o.bindFramebuffer(r.DRAW_FRAMEBUFFER,S),o.bindFramebuffer(r.READ_FRAMEBUFFER,N);const R=y-u-p;r.blitFramebuffer(c,R,c+d,R+p,c,R,c+d,R+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,R,d,p),o.unbindTexture()}else{const T=r.createFramebuffer();o.bindFramebuffer(r.DRAW_FRAMEBUFFER,T),r.framebufferTexture2D(r.DRAW_FRAMEBUFFER,M,r.TEXTURE_2D,a,0),r.blitFramebuffer(0,0,d,p,0,0,d,p,v,r.NEAREST),r.deleteFramebuffer(T)}}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 en(this,null,function*(){const{backend:c,gl:u}=this,{textureGPU:d,glFormat:p,glType:m}=this.backend.get(e),y=u.createFramebuffer();u.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),M=this._getBytesPerTexel(m,p),S=r*o*M,N=u.createBuffer();u.bindBuffer(u.PIXEL_PACK_BUFFER,N),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 R=new v(S/v.BYTES_PER_ELEMENT);return u.bindBuffer(u.PIXEL_PACK_BUFFER,N),u.getBufferSubData(u.PIXEL_PACK_BUFFER,0,R),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),u.deleteFramebuffer(y),R})}_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}}function Hv(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 C${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",WEBKIT_WEBGL_compressed_texture_pvrtc:"texture-compression-pvrtc",WEBGL_compressed_texture_s3tc:"texture-compression-bc",EXT_texture_compression_bptc:"texture-compression-bptc",EXT_disjoint_timer_query_webgl2:"timestamp-query",OVR_multiview2:"OVR_multiview2"};class N${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 M2{constructor(e=256){this.trackTimestamp=!0,this.maxQueries=e,this.currentQueryIndex=0,this.queryOffsets=new Map,this.isDisposed=!1,this.lastValue=0,this.pendingResolve=!1}allocateQueriesForContext(){}resolveQueriesAsync(){return en(this,null,function*(){})}dispose(){}}class P$ extends M2{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){console.warn("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 wr(`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){console.error("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){console.error("Error in endQuery:",n),this.queryStates.set(t,"inactive"),this.activeQuery=null}}resolveQueriesAsync(){return en(this,null,function*(){if(!this.trackTimestamp||this.pendingResolve)return this.lastValue;this.pendingResolve=!0;try{const e=[];for(const[r,o]of this.queryStates)if(o==="ended"){const a=this.queries[r];e.push(this.resolveQuery(a))}if(e.length===0)return this.lastValue;const n=(yield Promise.all(e)).reduce((r,o)=>r+o,0);return this.lastValue=n,this.currentQueryIndex=0,this.queryOffsets.clear(),this.queryStates.clear(),this.activeQuery=null,n}catch(e){return console.error("Error resolving queries:",e),this.lastValue}finally{this.pendingResolve=!1}})}resolveQuery(e){return en(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){console.error("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 A2 extends b2{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.samples>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 C$(this),this.capabilities=new R$(this),this.attributeUtils=new w$(this),this.textureUtils=new E$(this),this.bufferRenderer=new N$(this),this.state=new M$(this),this.utils=new A$(this),this.extensions.get("EXT_color_buffer_float"),this.extensions.get("WEBGL_clip_cull_distance"),this.extensions.get("OES_texture_float_linear"),this.extensions.get("EXT_color_buffer_half_float"),this.extensions.get("WEBGL_multisampled_render_to_texture"),this.extensions.get("WEBGL_render_shared_exponent"),this.extensions.get("WEBGL_multi_draw"),this.extensions.get("OVR_multiview2"),this.disjoint=this.extensions.get("EXT_disjoint_timer_query_webgl2"),this.parallel=this.extensions.get("KHR_parallel_shader_compile")}get coordinateSystem(){return ki}getArrayBufferAsync(e){return en(this,null,function*(){return yield this.attributeUtils.getArrayBufferAsync(e)})}waitForGPU(){return en(this,null,function*(){yield this.utils._clientWaitAsync()})}makeXRCompatible(){return en(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&&console.warn("THREE.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 P$(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(n.frameCalls=this.renderer.info.render.frameCalls,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(Nd.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(Nd.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,r=this.get(e);r.frameCalls=this.renderer.info.compute.frameCalls,t.bindFramebuffer(n.FRAMEBUFFER,null),this.initTimestampQuery(Nd.COMPUTE,this.getTimestampUID(e))}compute(e,t,n,r,o=null){const{state:a,gl:c}=this;this.discard===!1&&(c.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)&&(wr("WebGLBackend.compute(): The count parameter must be a single number, not an array."),o=o[0]),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 M=d[v];M.pbo&&this.has(M.pbo)&&this.textureUtils.copyBufferToTexture(M.transformBuffer,M.pbo),M.switchBuffers()}}finishCompute(e){const t=this.gl;this.discard=!1,t.disable(t.RASTERIZER_DISCARD),this.prepareTimestampBuffer(Nd.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),d.useProgram(c);const x=e.getAttributes(),v=this.get(x);let M=v.vaoGPU;if(M===void 0){const V=this._getVaoKey(x);M=this.vaoCache[V],M===void 0&&(M=this._createVao(x),this.vaoCache[V]=M,v.vaoGPU=M)}const T=e.getIndex(),S=T!==null?this.get(T).bufferGPU:null;d.setVertexState(M,S);const N=p.lastOcclusionObject;if(N!==t&&N!==void 0){if(N!==null&&N.occlusionTest===!0&&(u.endQuery(u.ANY_SAMPLES_PASSED),p.occlusionQueryIndex++),t.occlusionTest===!0){const V=u.createQuery();u.beginQuery(u.ANY_SAMPLES_PASSED,V),p.occlusionQueries[p.occlusionQueryIndex]=V,p.occlusionQueryObjects[p.occlusionQueryIndex]=t}p.lastOcclusionObject=t}const R=this.bufferRenderer;t.isPoints?R.mode=u.POINTS:t.isLineSegments?R.mode=u.LINES:t.isLine?R.mode=u.LINE_STRIP:t.isLineLoop?R.mode=u.LINE_LOOP:r.wireframe===!0?(d.setLineWidth(r.wireframeLinewidth*this.renderer.getPixelRatio()),R.mode=u.LINES):R.mode=u.TRIANGLES;const{vertexCount:P,instanceCount:B}=m;let{firstVertex:F}=m;if(R.object=t,T!==null){F*=T.array.BYTES_PER_ELEMENT;const V=this.get(T);R.index=T.count,R.type=V.type}else R.index=0;const k=()=>{t.isBatchedMesh?t._multiDrawInstances!==null?(wr("THREE.WebGLBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection."),R.renderMultiDrawInstances(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount,t._multiDrawInstances)):this.hasFeature("WEBGL_multi_draw")?R.renderMultiDraw(t._multiDrawStarts,t._multiDrawCounts,t._multiDrawCount):wr("THREE.WebGLRenderer: WEBGL_multi_draw not supported."):B>1?R.renderInstances(F,P,B):R.render(F,P)};if(e.camera.isArrayCamera===!0&&e.camera.cameras.length>0&&e.camera.isMultiViewCamera===!1){const V=this.get(e.camera),U=e.camera.cameras,z=e.getBindingGroup("cameraIndex").bindings[0];if(V.indexesGPU===void 0||V.indexesGPU.length!==U.length){const Ce=new Uint32Array([0,0,0,0]),nt=[];for(let Le=0,ht=U.length;Le<ht;Le++){const De=u.createBuffer();Ce[0]=Le,u.bindBuffer(u.UNIFORM_BUFFER,De),u.bufferData(u.UNIFORM_BUFFER,Ce,u.STATIC_DRAW),nt.push(De)}V.indexesGPU=nt}const j=this.get(z),se=this.renderer.getPixelRatio(),pe=this._currentContext.renderTarget,be=this._isRenderCameraDepthArray(this._currentContext),Pe=this._currentContext.activeCubeFace;if(be){const Ce=this.get(pe.depthTexture);if(Ce.clearedRenderId!==this.renderer._nodes.nodeFrame.renderId){Ce.clearedRenderId=this.renderer._nodes.nodeFrame.renderId;const{stencilBuffer:nt}=pe;for(let Le=0,ht=U.length;Le<ht;Le++)this.renderer._activeCubeFace=Le,this._currentContext.activeCubeFace=Le,this._setFramebuffer(this._currentContext),this.clear(!1,!0,nt,this._currentContext,!1,!1);this.renderer._activeCubeFace=Pe,this._currentContext.activeCubeFace=Pe}}for(let Ce=0,nt=U.length;Ce<nt;Ce++){const Le=U[Ce];if(t.layers.test(Le.layers)){be&&(this.renderer._activeCubeFace=Ce,this._currentContext.activeCubeFace=Ce,this._setFramebuffer(this._currentContext));const ht=Le.viewport;if(ht!==void 0){const De=ht.x*se,Je=ht.y*se,wt=ht.width*se,Xt=ht.height*se;d.viewport(Math.floor(De),Math.floor(e.context.height-Xt-Je),Math.floor(wt),Math.floor(Xt))}d.bindBufferBase(u.UNIFORM_BUFFER,j.index,V.indexesGPU[Ce]),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){this.textureUtils.destroyTexture(e)}copyTextureToBuffer(e,t,n,r,o,a){return en(this,null,function*(){return this.textureUtils.copyTextureToBuffer(e,t,n,r,o,a)})}createSampler(){}destroySampler(){}createNodeBuilder(e,t){return new b$(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");console.error("THREE.WebGLProgram: Shader Error "+r.getError()+" - VALIDATE_STATUS "+r.getProgramParameter(e,r.VALIDATE_STATUS)+`
|
|
|
|
Program Info Log: `+a+`
|
|
`+c+`
|
|
`+u)}else a!==""&&console.warn("THREE.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 T=0;T<p.length;T++){const S=p[T];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=[],M=[];for(let T=0;T<x.length;T++){const S=x[T].node.attribute;v.push(S),this.has(S)||this.attributeUtils.createAttribute(S,r.ARRAY_BUFFER)}for(let T=0;T<y.length;T++){const S=y[T].attribute;this.has(S)||this.attributeUtils.createAttribute(S,r.ARRAY_BUFFER);const N=this.get(S);M.push(N)}this.set(e,{programGPU:c,transformBuffers:M,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,t.DYNAMIC_DRAW),this.set(u,{bufferGPU:d})):(t.bindBuffer(t.UNIFORM_BUFFER,d),t.bufferSubData(t.UNIFORM_BUFFER,0,u)),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;t.bindBuffer(t.UNIFORM_BUFFER,r),t.bufferData(t.UNIFORM_BUFFER,o,t.DYNAMIC_DRAW)}}createIndexAttribute(e){const t=this.gl;this.attributeUtils.createAttribute(e,t.ELEMENT_ARRAY_BUFFER)}createAttribute(e){if(this.has(e))return;const t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}createStorageAttribute(e){if(this.has(e))return;const t=this.gl;this.attributeUtils.createAttribute(e,t.ARRAY_BUFFER)}updateAttribute(e){this.attributeUtils.updateAttribute(e)}destroyAttribute(e){this.attributeUtils.destroyAttribute(e)}hasFeature(e){const t=Object.keys(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 M=a.msaaFrameBuffer,T=a.depthRenderbuffer;const S=this.extensions.get("WEBGL_multisampled_render_to_texture"),N=this.extensions.get("OVR_multiview2"),R=this._useMultisampledExtension(o),P=WP(e);let B;if(p?(a.cubeFramebuffers||(a.cubeFramebuffers={}),B=a.cubeFramebuffers[P]):x&&v===!1?B=this._xrFramebuffer:(a.framebuffers||(a.framebuffers={}),B=a.framebuffers[P]),B===void 0){B=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,B);const F=e.textures,k=[];if(p){a.cubeFramebuffers[P]=B;const{textureGPU:U}=this.get(F[0]),z=this.renderer._activeCubeFace,j=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_CUBE_MAP_POSITIVE_X+z,U,j)}else{a.framebuffers[P]=B;for(let U=0;U<F.length;U++){const z=F[U],j=this.get(z);j.renderTarget=e.renderTarget,j.cacheKey=P;const se=t.COLOR_ATTACHMENT0+U;if(o.multiview)N.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,se,j.textureGPU,0,c,0,2);else if(m||y){const pe=this.renderer._activeCubeFace,be=this.renderer._activeMipmapLevel;t.framebufferTextureLayer(t.FRAMEBUFFER,se,j.textureGPU,be,pe)}else if(R)S.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,se,t.TEXTURE_2D,j.textureGPU,0,c);else{const pe=this.renderer._activeMipmapLevel;t.framebufferTexture2D(t.FRAMEBUFFER,se,t.TEXTURE_2D,j.textureGPU,pe)}}}const V=d?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(o._autoAllocateDepthBuffer===!0){const U=t.createRenderbuffer();this.textureUtils.setupRenderBufferStorage(U,e,0,R),a.xrDepthRenderbuffer=U,k.push(d?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT),t.bindRenderbuffer(t.RENDERBUFFER,U),t.framebufferRenderbuffer(t.FRAMEBUFFER,V,t.RENDERBUFFER,U)}else if(e.depthTexture!==null){k.push(d?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT);const U=this.get(e.depthTexture);if(U.renderTarget=e.renderTarget,U.cacheKey=P,o.multiview)N.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,V,U.textureGPU,0,c,0,2);else if(v&&R)S.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,V,t.TEXTURE_2D,U.textureGPU,0,c);else if(e.depthTexture.isArrayTexture){const z=this.renderer._activeCubeFace;t.framebufferTextureLayer(t.FRAMEBUFFER,V,U.textureGPU,0,z)}else t.framebufferTexture2D(t.FRAMEBUFFER,V,t.TEXTURE_2D,U.textureGPU,0)}a.depthInvalidationArray=k}else{if(this._isRenderCameraDepthArray(e)){n.bindFramebuffer(t.FRAMEBUFFER,B);const k=this.renderer._activeCubeFace,V=this.get(e.depthTexture),U=d?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;t.framebufferTextureLayer(t.FRAMEBUFFER,U,V.textureGPU,0,k)}if((x||R||o.multiview)&&o._isOpaqueFramebuffer!==!0){n.bindFramebuffer(t.FRAMEBUFFER,B);const k=this.get(e.textures[0]);o.multiview?N.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,k.textureGPU,0,c,0,2):R?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 V=d?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;if(o._autoAllocateDepthBuffer===!0){const U=a.xrDepthRenderbuffer;t.bindRenderbuffer(t.RENDERBUFFER,U),t.framebufferRenderbuffer(t.FRAMEBUFFER,V,t.RENDERBUFFER,U)}else{const U=this.get(e.depthTexture);o.multiview?N.framebufferTextureMultisampleMultiviewOVR(t.FRAMEBUFFER,V,U.textureGPU,0,c,0,2):R?S.framebufferTexture2DMultisampleEXT(t.FRAMEBUFFER,V,t.TEXTURE_2D,U.textureGPU,0,c):t.framebufferTexture2D(t.FRAMEBUFFER,V,t.TEXTURE_2D,U.textureGPU,0)}}}if(c>0&&R===!1&&!o.multiview){if(M===void 0){const F=[];M=t.createFramebuffer(),n.bindFramebuffer(t.FRAMEBUFFER,M);const k=[],V=e.textures;for(let U=0;U<V.length;U++){k[U]=t.createRenderbuffer(),t.bindRenderbuffer(t.RENDERBUFFER,k[U]),F.push(t.COLOR_ATTACHMENT0+U);const z=e.textures[U],j=this.get(z);t.renderbufferStorageMultisample(t.RENDERBUFFER,c,j.glInternalFormat,e.width,e.height),t.framebufferRenderbuffer(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0+U,t.RENDERBUFFER,k[U])}if(t.bindRenderbuffer(t.RENDERBUFFER,null),a.msaaFrameBuffer=M,a.msaaRenderbuffers=k,u&&T===void 0){T=t.createRenderbuffer(),this.textureUtils.setupRenderBufferStorage(T,e,c),a.depthRenderbuffer=T;const U=d?t.DEPTH_STENCIL_ATTACHMENT:t.DEPTH_ATTACHMENT;F.push(U)}a.invalidationArray=F}r=a.msaaFrameBuffer}else r=B;n.drawBuffers(e,B)}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:M,height:T}=e.scissorValue,S=e.height-T-v;t.blitFramebuffer(x,S,x+M,S+T,x,S,x+M,S+T,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(){const e=this.extensions.get("WEBGL_lose_context");e&&e.loseContext(),this.renderer.domElement.removeEventListener("webglcontextlost",this._onContextLost)}}const eg={PointList:"point-list",LineList:"line-list",LineStrip:"line-strip",TriangleList:"triangle-list",TriangleStrip:"triangle-strip"},Fr={Never:"never",Less:"less",Equal:"equal",LessEqual:"less-equal",Greater:"greater",NotEqual:"not-equal",GreaterEqual:"greater-equal",Always:"always"},fo={Store:"store"},Mi={Load:"load",Clear:"clear"},E2={CCW:"ccw",CW:"cw"},C2={None:"none",Back:"back"},tg={Uint16:"uint16",Uint32:"uint32"},ce={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"},kM={ClampToEdge:"clamp-to-edge",Repeat:"repeat",MirrorRepeat:"mirror-repeat"},sp={Linear:"linear",Nearest:"nearest"},si={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"},rp={Add:"add",Subtract:"subtract",ReverseSubtract:"reverse-subtract",Min:"min",Max:"max"},R2={None:0,All:15},_d={Keep:"keep",Zero:"zero",Replace:"replace",Invert:"invert",IncrementClamp:"increment-clamp",DecrementClamp:"decrement-clamp",IncrementWrap:"increment-wrap",DecrementWrap:"decrement-wrap"},zM={Storage:"storage",ReadOnlyStorage:"read-only-storage"},VM={WriteOnly:"write-only",ReadOnly:"read-only",ReadWrite:"read-write"},N2={NonFiltering:"non-filtering",Comparison:"comparison"},op={Float:"float",UnfilterableFloat:"unfilterable-float",Depth:"depth",SInt:"sint",UInt:"uint"},P2={TwoD:"2d",ThreeD:"3d"},er={TwoD:"2d",TwoDArray:"2d-array",Cube:"cube",ThreeD:"3d"},I$={All:"all"},Wv={Vertex:"vertex",Instance:"instance"},GM={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"};class L$ extends p2{constructor(e,t,n){super(e,t?t.value:null),this.textureNode=t,this.groupNode=n}update(){this.texture=this.textureNode.value}}class D$ extends u2{constructor(e,t){super(e,t?t.array:null),this.attribute=t,this.isStorageBuffer=!0}}let F$=0;class B$ extends D${constructor(e,t){super("StorageBuffer_"+F$++,e?e.value:null),this.nodeUniform=e,this.access=e?e.access:Ir.READ_WRITE,this.groupNode=t}get buffer(){return this.nodeUniform.value}}class O$ extends pd{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:sp.Linear}),this.flipYSampler=e.createSampler({minFilter:sp.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:eg.TriangleStrip,stripIndexFormat:tg.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:eg.TriangleStrip,stripIndexFormat:tg.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:er.TwoD,baseArrayLayer:n}),m=d.createView({baseMipLevel:0,mipLevelCount:1,dimension:er.TwoD,baseArrayLayer:0}),y=this.device.createCommandEncoder({}),x=(v,M,T)=>{const S=v.getBindGroupLayout(0),N=this.device.createBindGroup({layout:S,entries:[{binding:0,resource:this.flipYSampler},{binding:1,resource:M}]}),R=y.beginRenderPass({colorAttachments:[{view:T,loadOp:Mi.Clear,storeOp:fo.Store,clearValue:[0,0,0,0]}]});R.setPipeline(v),R.setBindGroup(0,N),R.draw(4,1,0,0),R.end()};x(c,p,m),x(u,m,p),this.device.queue.submit([y.finish()]),d.destroy()}generateMipmaps(e,t,n=0){const r=this.get(e);r.useCount===void 0&&(r.useCount=0,r.layers=[]);const o=r.layers[n]||this._mipmapCreateBundles(e,t,n),a=this.device.createCommandEncoder({});this._mipmapRunBundles(a,o),this.device.queue.submit([a.finish()]),r.useCount!==0&&(r.layers[n]=o),r.useCount++}_mipmapCreateBundles(e,t,n){const r=this.getTransferPipeline(t.format),o=r.getBindGroupLayout(0);let a=e.createView({baseMipLevel:0,mipLevelCount:1,dimension:er.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:er.TwoD,baseArrayLayer:n}),m={colorAttachments:[{view:p,loadOp:Mi.Clear,storeOp:fo.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 U$={[Q_]:"never",[fg]:"less",[e0]:"equal",[pg]:"less-equal",[t0]:"greater",[i0]:"greater-equal",[s0]:"always",[n0]:"not-equal"},k$=[0,1,3,2,4,5];class z${constructor(e){this.backend=e,this._passUtils=null,this.defaultTexture={},this.defaultCubeTexture={},this.defaultVideoFrame=null,this.colorBuffer=null,this.depthTexture=new Ao,this.depthTexture.name="depthBuffer"}createSampler(e){const t=this.backend,n=t.device,r=t.get(e),o={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};o.magFilter===sp.Linear&&o.minFilter===sp.Linear&&o.mipmapFilter===sp.Linear&&(o.maxAnisotropy=e.anisotropy),e.isDepthTexture&&e.compareFunction!==null&&(o.compare=U$[e.compareFunction]),r.sampler=n.createSampler(o)}createDefaultTexture(e){let t;const n=HM(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||HM(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!==ce.RGB9E5UFloat&&(v|=GPUTextureUsage.RENDER_ATTACHMENT);const M={label:e.name,size:{width:o,height:a,depthOrArrayLayers:c},mipLevelCount:u,sampleCount:y,dimension:d,format:p,usage:v};if(p===void 0){console.warn("WebGPURenderer: Texture format not supported."),this.createDefaultTexture(e);return}if(e.isCubeTexture&&(M.textureBindingViewDimension=er.Cube),r.texture=n.device.createTexture(M),x){const T=Object.assign({},M);T.label=T.label+"-msaa",T.sampleCount=m,T.mipLevelCount=1,r.msaaTexture=n.device.createTexture(T)}r.initialized=!0,r.textureDescriptorGPU=M}destroyTexture(e){const t=this.backend,n=t.get(e);n.texture!==void 0&&n.texture.destroy(),n.msaaTexture!==void 0&&n.msaaTexture.destroy(),t.delete(e)}destroySampler(e){const n=this.backend.get(e);delete n.sampler}generateMipmaps(e){const t=this.backend.get(e);if(e.isCubeTexture)for(let n=0;n<6;n++)this._generateMipmaps(t.texture,t.textureDescriptorGPU,n);else{const n=e.image.depth||1;for(let r=0;r<n;r++)this._generateMipmaps(t.texture,t.textureDescriptorGPU,r)}}getColorBuffer(){this.colorBuffer&&this.colorBuffer.destroy();const e=this.backend,{width:t,height:n}=e.getDrawingBufferSize();return this.colorBuffer=e.device.createTexture({label:"colorBuffer",size:{width:t,height:n,depthOrArrayLayers:1},sampleCount:e.utils.getSampleCount(e.renderer.samples),format:e.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC}),this.colorBuffer}getDepthBuffer(e=!0,t=!1){const n=this.backend,{width:r,height:o}=n.getDrawingBufferSize(),a=this.depthTexture,c=n.get(a).texture;let u,d;if(t?(u=eo,d=mo):e&&(u=Or,d=pi),c!==void 0){if(a.image.width===r&&a.image.height===o&&a.format===u&&a.type===d)return c;this.destroyTexture(a)}return a.name="depthBuffer",a.format=u,a.type=d,a.image.width=r,a.image.height=o,this.createTexture(a,{width:r,height:o}),n.get(a).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 en(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 M=this._getTypedArrayType(p);c.queue.submit([v.finish()]),yield x.mapAsync(GPUMapMode.READ);const T=x.getMappedRange();return new M(T)})}_getDefaultTextureGPU(e){let t=this.defaultTexture[e];if(t===void 0){const n=new ds;n.minFilter=Jn,n.magFilter=Jn,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.defaultTexture[e];if(t===void 0){const n=new jl;n.minFilter=Jn,n.magFilter=Jn,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?k$[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;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})}_getPassUtils(){let e=this._passUtils;return e===null&&(this._passUtils=e=new O$(this.backend.device)),e}_generateMipmaps(e,t,n=0){this._getPassUtils().generateMipmaps(e,t,n)}_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===ce.BC1RGBAUnorm||e===ce.BC1RGBAUnormSRGB)return{byteLength:8,width:4,height:4};if(e===ce.BC2RGBAUnorm||e===ce.BC2RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===ce.BC3RGBAUnorm||e===ce.BC3RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===ce.BC4RUnorm||e===ce.BC4RSnorm)return{byteLength:8,width:4,height:4};if(e===ce.BC5RGUnorm||e===ce.BC5RGSnorm)return{byteLength:16,width:4,height:4};if(e===ce.BC6HRGBUFloat||e===ce.BC6HRGBFloat)return{byteLength:16,width:4,height:4};if(e===ce.BC7RGBAUnorm||e===ce.BC7RGBAUnormSRGB)return{byteLength:16,width:4,height:4};if(e===ce.ETC2RGB8Unorm||e===ce.ETC2RGB8UnormSRGB)return{byteLength:8,width:4,height:4};if(e===ce.ETC2RGB8A1Unorm||e===ce.ETC2RGB8A1UnormSRGB)return{byteLength:8,width:4,height:4};if(e===ce.ETC2RGBA8Unorm||e===ce.ETC2RGBA8UnormSRGB)return{byteLength:16,width:4,height:4};if(e===ce.EACR11Unorm)return{byteLength:8,width:4,height:4};if(e===ce.EACR11Snorm)return{byteLength:8,width:4,height:4};if(e===ce.EACRG11Unorm)return{byteLength:16,width:4,height:4};if(e===ce.EACRG11Snorm)return{byteLength:16,width:4,height:4};if(e===ce.ASTC4x4Unorm||e===ce.ASTC4x4UnormSRGB)return{byteLength:16,width:4,height:4};if(e===ce.ASTC5x4Unorm||e===ce.ASTC5x4UnormSRGB)return{byteLength:16,width:5,height:4};if(e===ce.ASTC5x5Unorm||e===ce.ASTC5x5UnormSRGB)return{byteLength:16,width:5,height:5};if(e===ce.ASTC6x5Unorm||e===ce.ASTC6x5UnormSRGB)return{byteLength:16,width:6,height:5};if(e===ce.ASTC6x6Unorm||e===ce.ASTC6x6UnormSRGB)return{byteLength:16,width:6,height:6};if(e===ce.ASTC8x5Unorm||e===ce.ASTC8x5UnormSRGB)return{byteLength:16,width:8,height:5};if(e===ce.ASTC8x6Unorm||e===ce.ASTC8x6UnormSRGB)return{byteLength:16,width:8,height:6};if(e===ce.ASTC8x8Unorm||e===ce.ASTC8x8UnormSRGB)return{byteLength:16,width:8,height:8};if(e===ce.ASTC10x5Unorm||e===ce.ASTC10x5UnormSRGB)return{byteLength:16,width:10,height:5};if(e===ce.ASTC10x6Unorm||e===ce.ASTC10x6UnormSRGB)return{byteLength:16,width:10,height:6};if(e===ce.ASTC10x8Unorm||e===ce.ASTC10x8UnormSRGB)return{byteLength:16,width:10,height:8};if(e===ce.ASTC10x10Unorm||e===ce.ASTC10x10UnormSRGB)return{byteLength:16,width:10,height:10};if(e===ce.ASTC12x10Unorm||e===ce.ASTC12x10UnormSRGB)return{byteLength:16,width:12,height:10};if(e===ce.ASTC12x12Unorm||e===ce.ASTC12x12UnormSRGB)return{byteLength:16,width:12,height:12}}_convertAddressMode(e){let t=kM.ClampToEdge;return e===ba?t=kM.Repeat:e===Sa&&(t=kM.MirrorRepeat),t}_convertFilterMode(e){let t=sp.Linear;return(e===Jn||e===gp||e===Ta)&&(t=sp.Nearest),t}_getBytesPerTexel(e){if(e===ce.R8Unorm||e===ce.R8Snorm||e===ce.R8Uint||e===ce.R8Sint)return 1;if(e===ce.R16Uint||e===ce.R16Sint||e===ce.R16Float||e===ce.RG8Unorm||e===ce.RG8Snorm||e===ce.RG8Uint||e===ce.RG8Sint)return 2;if(e===ce.R32Uint||e===ce.R32Sint||e===ce.R32Float||e===ce.RG16Uint||e===ce.RG16Sint||e===ce.RG16Float||e===ce.RGBA8Unorm||e===ce.RGBA8UnormSRGB||e===ce.RGBA8Snorm||e===ce.RGBA8Uint||e===ce.RGBA8Sint||e===ce.BGRA8Unorm||e===ce.BGRA8UnormSRGB||e===ce.RGB9E5UFloat||e===ce.RGB10A2Unorm||e===ce.RG11B10UFloat||e===ce.Depth32Float||e===ce.Depth24Plus||e===ce.Depth24PlusStencil8||e===ce.Depth32FloatStencil8)return 4;if(e===ce.RG32Uint||e===ce.RG32Sint||e===ce.RG32Float||e===ce.RGBA16Uint||e===ce.RGBA16Sint||e===ce.RGBA16Float)return 8;if(e===ce.RGBA32Uint||e===ce.RGBA32Sint||e===ce.RGBA32Float)return 16}_getTypedArrayType(e){if(e===ce.R8Uint)return Uint8Array;if(e===ce.R8Sint)return Int8Array;if(e===ce.R8Unorm)return Uint8Array;if(e===ce.R8Snorm)return Int8Array;if(e===ce.RG8Uint)return Uint8Array;if(e===ce.RG8Sint)return Int8Array;if(e===ce.RG8Unorm)return Uint8Array;if(e===ce.RG8Snorm)return Int8Array;if(e===ce.RGBA8Uint)return Uint8Array;if(e===ce.RGBA8Sint)return Int8Array;if(e===ce.RGBA8Unorm||e===ce.RGBA8UnormSRGB)return Uint8Array;if(e===ce.RGBA8Snorm)return Int8Array;if(e===ce.R16Uint)return Uint16Array;if(e===ce.R16Sint)return Int16Array;if(e===ce.RG16Uint)return Uint16Array;if(e===ce.RG16Sint)return Int16Array;if(e===ce.RGBA16Uint)return Uint16Array;if(e===ce.RGBA16Sint)return Int16Array;if(e===ce.R16Float||e===ce.RG16Float||e===ce.RGBA16Float)return Uint16Array;if(e===ce.R32Uint)return Uint32Array;if(e===ce.R32Sint)return Int32Array;if(e===ce.R32Float)return Float32Array;if(e===ce.RG32Uint)return Uint32Array;if(e===ce.RG32Sint)return Int32Array;if(e===ce.RG32Float)return Float32Array;if(e===ce.RGBA32Uint)return Uint32Array;if(e===ce.RGBA32Sint)return Int32Array;if(e===ce.RGBA32Float)return Float32Array;if(e===ce.BGRA8Unorm||e===ce.BGRA8UnormSRGB)return Uint8Array;if(e===ce.RGB10A2Unorm||e===ce.RGB9E5UFloat||e===ce.RG11B10UFloat)return Uint32Array;if(e===ce.Depth32Float)return Float32Array;if(e===ce.Depth24Plus||e===ce.Depth24PlusStencil8)return Uint32Array;if(e===ce.Depth32FloatStencil8)return Float32Array}_getDimension(e){let t;return e.is3DTexture||e.isData3DTexture?t=P2.ThreeD:t=P2.TwoD,t}}function HM(i,e=null){const t=i.format,n=i.type,r=i.colorSpace,o=pn.getTransfer(r);let a;if(i.isCompressedTexture===!0||i.isCompressedArrayTexture===!0)switch(t){case Fl:case Bl:a=o===Dt?ce.BC1RGBAUnormSRGB:ce.BC1RGBAUnorm;break;case Ol:a=o===Dt?ce.BC2RGBAUnormSRGB:ce.BC2RGBAUnorm;break;case Ul:a=o===Dt?ce.BC3RGBAUnormSRGB:ce.BC3RGBAUnorm;break;case dh:a=ce.BC4RUnorm;break;case fh:a=ce.BC4RSnorm;break;case ph:a=ce.BC5RGUnorm;break;case mh:a=ce.BC5RGSnorm;break;case hh:a=o===Dt?ce.BC7RGBAUnormSRGB:ce.BC7RGBAUnorm;break;case Yu:case ju:a=o===Dt?ce.ETC2RGB8UnormSRGB:ce.ETC2RGB8Unorm;break;case Zu:a=o===Dt?ce.ETC2RGBA8UnormSRGB:ce.ETC2RGBA8Unorm;break;case Ku:a=o===Dt?ce.ASTC4x4UnormSRGB:ce.ASTC4x4Unorm;break;case Ju:a=o===Dt?ce.ASTC5x4UnormSRGB:ce.ASTC5x4Unorm;break;case Qu:a=o===Dt?ce.ASTC5x5UnormSRGB:ce.ASTC5x5Unorm;break;case eh:a=o===Dt?ce.ASTC6x5UnormSRGB:ce.ASTC6x5Unorm;break;case th:a=o===Dt?ce.ASTC6x6UnormSRGB:ce.ASTC6x6Unorm;break;case nh:a=o===Dt?ce.ASTC8x5UnormSRGB:ce.ASTC8x5Unorm;break;case ih:a=o===Dt?ce.ASTC8x6UnormSRGB:ce.ASTC8x6Unorm;break;case sh:a=o===Dt?ce.ASTC8x8UnormSRGB:ce.ASTC8x8Unorm;break;case rh:a=o===Dt?ce.ASTC10x5UnormSRGB:ce.ASTC10x5Unorm;break;case oh:a=o===Dt?ce.ASTC10x6UnormSRGB:ce.ASTC10x6Unorm;break;case ah:a=o===Dt?ce.ASTC10x8UnormSRGB:ce.ASTC10x8Unorm;break;case lh:a=o===Dt?ce.ASTC10x10UnormSRGB:ce.ASTC10x10Unorm;break;case ch:a=o===Dt?ce.ASTC12x10UnormSRGB:ce.ASTC12x10Unorm;break;case uh:a=o===Dt?ce.ASTC12x12UnormSRGB:ce.ASTC12x12Unorm;break;case _i:a=o===Dt?ce.RGBA8UnormSRGB:ce.RGBA8Unorm;break;default:console.error("WebGPURenderer: Unsupported texture format.",t)}else switch(t){case _i:switch(n){case Lc:a=ce.RGBA8Snorm;break;case Dc:a=ce.RGBA16Sint;break;case Go:a=ce.RGBA16Uint;break;case pi:a=ce.RGBA32Uint;break;case Ws:a=ce.RGBA32Sint;break;case Ui:a=o===Dt?ce.RGBA8UnormSRGB:ce.RGBA8Unorm;break;case Ts:a=ce.RGBA16Float;break;case mi:a=ce.RGBA32Float;break;default:console.error("WebGPURenderer: Unsupported texture type with RGBAFormat.",n)}break;case bd:switch(n){case xp:a=ce.RGB9E5UFloat;break;case vp:a=ce.RG11B10UFloat;break;default:console.error("WebGPURenderer: Unsupported texture type with RGBFormat.",n)}break;case Fc:switch(n){case Lc:a=ce.R8Snorm;break;case Dc:a=ce.R16Sint;break;case Go:a=ce.R16Uint;break;case pi:a=ce.R32Uint;break;case Ws:a=ce.R32Sint;break;case Ui:a=ce.R8Unorm;break;case Ts:a=ce.R16Float;break;case mi:a=ce.R32Float;break;default:console.error("WebGPURenderer: Unsupported texture type with RedFormat.",n)}break;case rl:switch(n){case Lc:a=ce.RG8Snorm;break;case Dc:a=ce.RG16Sint;break;case Go:a=ce.RG16Uint;break;case pi:a=ce.RG32Uint;break;case Ws:a=ce.RG32Sint;break;case Ui:a=ce.RG8Unorm;break;case Ts:a=ce.RG16Float;break;case mi:a=ce.RG32Float;break;default:console.error("WebGPURenderer: Unsupported texture type with RGFormat.",n)}break;case Or:switch(n){case Go:a=ce.Depth16Unorm;break;case pi:a=ce.Depth24Plus;break;case mi:a=ce.Depth32Float;break;default:console.error("WebGPURenderer: Unsupported texture type with DepthFormat.",n)}break;case eo:switch(n){case mo:a=ce.Depth24PlusStencil8;break;case mi:e&&e.features.has(GM.Depth32FloatStencil8)===!1&&console.error('WebGPURenderer: Depth textures with DepthStencilFormat + FloatType can only be used with the "depth32float-stencil8" GPU feature.'),a=ce.Depth32FloatStencil8;break;default:console.error("WebGPURenderer: Unsupported texture type with DepthStencilFormat.",n)}break;case Dl:switch(n){case Ws:a=ce.R32Sint;break;case pi:a=ce.R32Uint;break;default:console.error("WebGPURenderer: Unsupported texture type with RedIntegerFormat.",n)}break;case qu:switch(n){case Ws:a=ce.RG32Sint;break;case pi:a=ce.RG32Uint;break;default:console.error("WebGPURenderer: Unsupported texture type with RGIntegerFormat.",n)}break;case Xu:switch(n){case Ws:a=ce.RGBA32Sint;break;case pi:a=ce.RGBA32Uint;break;default:console.error("WebGPURenderer: Unsupported texture type with RGBAIntegerFormat.",n)}break;default:console.error("WebGPURenderer: Unsupported texture format.",t)}return a}const V$=/^[fn]*\s*([a-z_0-9]+)?\s*\(([\s\S]*?)\)\s*[\-\>]*\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/i,G$=/([a-z_0-9]+)\s*:\s*([a-z_0-9]+(?:<[\s\S]+?>)?)/ig,I2={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"},H$=i=>{i=i.trim();const e=i.match(V$);if(e!==null&&e.length===4){const t=e[2],n=[];let r=null;for(;(r=G$.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=I2[x]),o.push(new EM(x,m))}const a=i.substring(e[0].length),c=e[3]||"void",u=e[1]!==void 0?e[1]:"";return{type:I2[c]||c,inputs:o,name:u,inputsCode:t,blockCode:a,outputType:c}}else throw new Error("FunctionNode: Function is not a WGSL code.")};class W$ extends NM{constructor(e){const{type:t,inputs:n,name:r,inputsCode:o,blockCode:a,outputType:c}=H$(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 $$ extends t2{parseFunction(e){return new W$(e)}}const ng=typeof self!="undefined"?self.GPUShaderStage:{VERTEX:1,FRAGMENT:2,COMPUTE:4},q$={[Ir.READ_ONLY]:"read",[Ir.WRITE_ONLY]:"write",[Ir.READ_WRITE]:"read_write"},L2={[ba]:"repeat",[Ki]:"clamp",[Sa]:"mirror"},$v={vertex:ng?ng.VERTEX:1,fragment:ng?ng.FRAGMENT:2,compute:ng?ng.COMPUTE:4},D2={instance:!0,swizzleAssign:!1,storageBuffer:!0},X$={"^^":"tsl_xor"},j$={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>"},F2={},V_={tsl_xor:new jr("fn tsl_xor( a : bool, b : bool ) -> bool { return ( a || b ) && !( a && b ); }"),mod_float:new jr("fn tsl_mod_float( x : f32, y : f32 ) -> f32 { return x - y * floor( x / y ); }"),mod_vec2:new jr("fn tsl_mod_vec2( x : vec2f, y : vec2f ) -> vec2f { return x - y * floor( x / y ); }"),mod_vec3:new jr("fn tsl_mod_vec3( x : vec3f, y : vec3f ) -> vec3f { return x - y * floor( x / y ); }"),mod_vec4:new jr("fn tsl_mod_vec4( x : vec4f, y : vec4f ) -> vec4f { return x - y * floor( x / y ); }"),equals_bool:new jr("fn tsl_equals_bool( a : bool, b : bool ) -> bool { return a == b; }"),equals_bvec2:new jr("fn tsl_equals_bvec2( a : vec2f, b : vec2f ) -> vec2<bool> { return vec2<bool>( a.x == b.x, a.y == b.y ); }"),equals_bvec3:new jr("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 jr("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 jr("fn tsl_repeatWrapping_float( coord: f32 ) -> f32 { return fract( coord ); }"),mirrorWrapping_float:new jr("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 jr("fn tsl_clampWrapping_float( coord: f32 ) -> f32 { return clamp( coord, 0.0, 1.0 ); }"),biquadraticTexture:new jr(`
|
|
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 );
|
|
|
|
}
|
|
`)},Y$={dFdx:"dpdx",dFdy:"- dpdy",mod_float:"tsl_mod_float",mod_vec2:"tsl_mod_vec2",mod_vec3:"tsl_mod_vec3",mod_vec4:"tsl_mod_vec4",equals_bool:"tsl_equals_bool",equals_bvec2:"tsl_equals_bvec2",equals_bvec3:"tsl_equals_bvec3",equals_bvec4:"tsl_equals_bvec4",inversesqrt:"inverseSqrt",bitcast:"bitcast<f32>"};let B2="";(typeof navigator!="undefined"&&/Firefox|Deno/g.test(navigator.userAgent))!==!0&&(B2+=`diagnostic( off, derivative_uniformity );
|
|
`);class Z$ extends QI{constructor(e,t){super(e,t,new $$),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_${L2[e.wrapS]}S_${L2[e.wrapT]}_${e.isData3DTexture?"3d":"2d"}T`;let n=F2[t];if(n===void 0){const r=[],o=e.isData3DTexture?"vec3f":"vec2f";let a=`fn ${t}( coord : ${o} ) -> ${o} {
|
|
|
|
return ${o}(
|
|
`;const c=(u,d)=>{u===ba?(r.push(V_.repeatWrapping_float),a+=` tsl_repeatWrapping_float( coord.${d} )`):u===Ki?(r.push(V_.clampWrapping_float),a+=` tsl_clampWrapping_float( coord.${d} )`):u===Sa?(r.push(V_.mirrorWrapping_float),a+=` tsl_mirrorWrapping_float( coord.${d} )`):(a+=` coord.${d}`,console.warn(`WebGPURenderer: Unsupported texture wrap type "${u}" for vertex shader.`))};c(e.wrapS,"x"),a+=`,
|
|
`,c(e.wrapT,"y"),e.isData3DTexture&&(a+=`,
|
|
`,c(e.wrapR,"z")),a+=`
|
|
);
|
|
|
|
}
|
|
`,F2[t]=n=new jr(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.isData3DTexture?c="vec3<u32>":c="vec2<u32>",d||e.isStorageTexture?a=t:a=`${t}${n?`, u32( ${n} )`:""}`,o=new Yx(new Jx(`textureDimensions( ${a} )`,c)),r.dimensionsSnippet[n]=o,(e.isArrayTexture||e.isDataArrayTexture||e.isData3DTexture)&&(r.arrayLayerCount=new Yx(new Jx(`textureNumLayers(${t})`,"u32"))),e.isTextureCube&&(r.cubeFaceCount=new Yx(new Jx("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.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,r,null,a)}generateTextureLoad(e,t,n,r,o,a="0u"){let c;return o&&(n=`${n} + ${o}`),r?c=`textureLoad( ${t}, ${n}, ${r}, u32( ${a} ) )`:(c=`textureLoad( ${t}, ${n}, u32( ${a} ) )`,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===mi||this.isSampleCompare(e)===!1&&e.minFilter===Jn&&e.magFilter===Jn||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]} )`;console.error(`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} )`;console.error(`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} )`;console.error(`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==="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=X$[e];return t!==void 0?(this._include(t),t):null}getNodeAccess(e,t){return t!=="compute"?e.isAtomic===!0?(console.warn("WebGPURenderer: Atomic operations are only supported in compute shaders."),Ir.READ_WRITE):Ir.READ_ONLY:e.access}getStorageAccess(e,t){return q$[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==="storageTexture"||t==="texture3D"){let m=null;const y=this.getNodeAccess(e,n);if(t==="texture"||t==="storageTexture"?e.value.is3DTexture===!0?m=new FM(o.name,o.node,u,y):m=new Vv(o.name,o.node,u,y):t==="cubeTexture"?m=new m2(o.name,o.node,u,y):t==="texture3D"&&(m=new FM(o.name,o.node,u,y)),m.store=e.isStorageTextureNode===!0,m.setVisibility($v[n]),this.isUnfilterable(e.value)===!1&&m.store===!1){const x=new L$(`${o.name}_sampler`,o.node,u);x.setVisibility($v[n]),p.push(x,m),c=[x,m]}else p.push(m),c=[m]}else if(t==="buffer"||t==="storageBuffer"||t==="indirectStorageBuffer"){const m=t==="buffer"?d2:B$,y=new m(e,u);y.setVisibility($v[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 f2(d,u),y.setVisibility($v[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==="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)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 M=HM(m),T=this.getStorageAccess(u.node,e),S=u.node.value.is3DTexture,N=u.node.value.isArrayTexture;y=`texture_storage_${S?"3d":`2d${N?"_array":""}`}<${M}, ${T}>`}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 M=this.getComponentTypeFromTexture(m).charAt(0);y=`texture${x}_2d<${M}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:"",M=m.isStorageBufferNode?`storage, ${this.getStorageAccess(m,e)}`:"uniform";if(this.isCustomStruct(u))r.push(`@binding( ${p.binding++} ) @group( ${p.group} ) var<${M}> ${u.name} : ${y};`);else{const S=` value : array< ${m.isAtomic?`atomic<${y}>`:`${y}`}${v} >`;r.push(this._getWGSLStructBinding(u.name,S,M,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))}let c=n.join(`
|
|
`);return c+=r.join(`
|
|
`),c+=o.join(`
|
|
`),c}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)}>`}getTernary(e,t,n){return`select( ${n}, ${t}, ${e} )`}getType(e){return j$[e]||e}isAvailable(e){let t=D2[e];return t===void 0&&(e==="float32Filterable"?t=this.renderer.hasFeature("float32-filterable"):e==="clipDistance"&&(t=this.renderer.hasFeature("clip-distances")),D2[e]=t),t}_getWGSLMethod(e){return V_[e]!==void 0&&this._include(e),Y$[e]}_include(e){const t=V_[e];return t.build(this),this.currentFunctionNode!==null&&this.currentFunctionNode.includes.push(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
|
|
${B2}
|
|
|
|
// 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 K${constructor(e){this.backend=e}getCurrentDepthStencilFormat(e){let t;return e.depthTexture!==null?t=this.getTextureFormatGPU(e.depthTexture):e.depth&&e.stencil?t=ce.Depth24PlusStencil8:e.depth&&(t=ce.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.samples}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}getCurrentColorSpace(e){return e.textures!==null?e.textures[0].colorSpace:this.backend.renderer.outputColorSpace}getPrimitiveTopology(e,t){if(e.isPoints)return eg.PointList;if(e.isLineSegments||e.isMesh&&t.wireframe===!0)return eg.LineList;if(e.isLine)return eg.LineStrip;if(e.isMesh)return eg.TriangleList}getSampleCount(e){return e>=4?4:1}getSampleCountRenderContext(e){return e.textures!==null?this.getSampleCount(e.sampleCount):this.getSampleCount(this.backend.renderer.samples)}getPreferredCanvasFormat(){const e=this.backend.parameters.outputType;if(e===void 0)return navigator.gpu.getPreferredCanvasFormat();if(e===Ui)return ce.BGRA8Unorm;if(e===Ts)return ce.RGBA16Float;throw new Error("Unsupported outputType")}}const O2=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"&&O2.set(Float16Array,["float16"]);const J$=new Map([[Lb,["float16"]]]),Q$=new Map([[Int32Array,"sint32"],[Int16Array,"sint32"],[Uint32Array,"uint32"],[Uint16Array,"uint32"],[Float32Array,"float32"]]);class eq{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 p=0;p<t.count;p++)c.set(t.array.subarray(p*3,p*3+3),p*4);t.array=c}const u=this._isTypedArray(c),d=t.updateRanges;if(d.length===0)r.queue.writeBuffer(a,0,c,0);else{const p=u?1:c.BYTES_PER_ELEMENT;for(let m=0,y=d.length;m<y;m++){const x=d[m];let v,M;if(o._force3to4BytesAlignment===!0){const S=Math.floor(x.start/3),N=Math.ceil(x.count/3);v=S*4*p,M=N*4*p}else v=x.start*p,M=x.count*p;const T=v*(u?c.BYTES_PER_ELEMENT:1);r.queue.writeBuffer(a,T,c,v,M)}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?Wv.Instance:Wv.Vertex):(m=o.itemSize*a,y=o.isInstancedBufferAttribute?Wv.Instance:Wv.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 en(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=Q$.get(r);else{const u=(J$.get(o)||O2.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||console.error("THREE.WebGPUAttributeUtils: Vertex format not supported yet."),a}_isTypedArray(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}_getBufferAttribute(e){return e.isInterleavedBufferAttribute&&(e=e.data),e}}class tq{constructor(e){this.backend=e,this.bindGroupLayoutCache=new WeakMap}createBindingsLayout(e){const t=this.backend,n=t.device,r=[];let o=0;for(const a of e.bindings){const c={binding:o++,visibility:a.visibility};if(a.isUniformBuffer||a.isStorageBuffer){const u={};a.isStorageBuffer&&(a.visibility&4&&(a.access===Ir.READ_WRITE||a.access===Ir.WRITE_ONLY)?u.type=zM.Storage:u.type=zM.ReadOnlyStorage),c.buffer=u}else if(a.isSampledTexture&&a.store){const u={};u.format=this.backend.get(a.texture).texture.format;const d=a.access;d===Ir.READ_WRITE?u.access=VM.ReadWrite:d===Ir.WRITE_ONLY?u.access=VM.WriteOnly:u.access=VM.ReadOnly,a.texture.isArrayTexture?u.viewDimension=er.TwoDArray:a.texture.is3DTexture&&(u.viewDimension=er.ThreeD),c.storageTexture=u}else if(a.isSampledTexture){const u={},{primarySamples:d}=t.utils.getTextureSampleData(a.texture);if(d>1&&(u.multisampled=!0,a.texture.isDepthTexture||(u.sampleType=op.UnfilterableFloat)),a.texture.isDepthTexture)t.compatibilityMode&&a.texture.compareFunction===null?u.sampleType=op.UnfilterableFloat:u.sampleType=op.Depth;else if(a.texture.isDataTexture||a.texture.isDataArrayTexture||a.texture.isData3DTexture){const p=a.texture.type;p===Ws?u.sampleType=op.SInt:p===pi?u.sampleType=op.UInt:p===mi&&(this.backend.hasFeature("float32-filterable")?u.sampleType=op.Float:u.sampleType=op.UnfilterableFloat)}a.isSampledCubeTexture?u.viewDimension=er.Cube:a.texture.isArrayTexture||a.texture.isDataArrayTexture||a.texture.isCompressedArrayTexture?u.viewDimension=er.TwoDArray:a.isSampledTexture3D&&(u.viewDimension=er.ThreeD),c.texture=u}else if(a.isSampler){const u={};a.texture.isDepthTexture&&(a.texture.compareFunction!==null?u.type=N2.Comparison:t.compatibilityMode&&(u.type=N2.NonFiltering)),c.sampler=u}else console.error(`WebGPUBindingUtils: Unsupported binding "${a}".`);r.push(c)}return n.createBindGroupLayout({entries:r})}createBindings(e,t,n,r=0){const{backend:o,bindGroupLayoutCache:a}=this,c=o.get(e);let u=a.get(e.bindingsReference);u===void 0&&(u=this.createBindingsLayout(e),a.set(e.bindingsReference,u));let d;n>0&&(c.groups===void 0&&(c.groups=[],c.versions=[]),c.versions[n]===r&&(d=c.groups[n])),d===void 0&&(d=this.createBindGroup(e,u),n>0&&(c.groups[n]=d,c.versions[n]=r)),c.group=d,c.layout=u}updateBinding(e){const t=this.backend,n=t.device,r=e.buffer,o=t.get(e).buffer;n.queue.writeBuffer(o,0,r,0)}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=r.createBuffer({label:"bindingBuffer_"+c.name,size:d,usage:p});u.buffer=m}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;let m=`view-${u.texture.width}-${u.texture.height}`;if(u.texture.depthOrArrayLayers>1&&(m+=`-${u.texture.depthOrArrayLayers}`),m+=`-${p}`,d=u[m],d===void 0){const y=I$.All;let x;c.isSampledCubeTexture?x=er.Cube:c.isSampledTexture3D?x=er.ThreeD:c.texture.isArrayTexture||c.texture.isDataArrayTexture||c.texture.isCompressedArrayTexture?x=er.TwoDArray:x=er.TwoD,d=u[m]=u.texture.createView({aspect:y,dimension:x,mipLevelCount:p})}}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})}}class nq{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 pe of e.getBindings()){const be=d.get(pe);x.push(be.layout)}const v=d.attributeUtils.createShaderVertexBuffers(e);let M;r.blending!==Ae&&(r.blending!==qe||r.transparent!==!1)&&(M=this._getBlending(r));let T={};r.stencilWrite===!0&&(T={compare:this._getStencilCompare(r),failOp:this._getStencilOperation(r.stencilFail),depthFailOp:this._getStencilOperation(r.stencilZFail),passOp:this._getStencilOperation(r.stencilZPass)});const S=this._getColorWriteMask(r),N=[];if(e.context.textures!==null){const pe=e.context.textures;for(let be=0;be<pe.length;be++){const Pe=m.getTextureFormatGPU(pe[be]);N.push({format:Pe,blend:M,writeMask:S})}}else{const pe=m.getCurrentColorFormat(e.context);N.push({format:pe,blend:M,writeMask:S})}const R=d.get(c).module,P=d.get(u).module,B=this._getPrimitiveState(n,o,r),F=this._getDepthCompare(r),k=m.getCurrentDepthStencilFormat(e.context),V=this._getSampleCount(e.context),U={label:`renderPipeline_${r.name||r.type}_${r.id}`,vertex:Object.assign({},R,{buffers:v}),fragment:Object.assign({},P,{targets:N}),primitive:B,multisample:{count:V,alphaToCoverageEnabled:r.alphaToCoverage&&V>1},layout:p.createPipelineLayout({bindGroupLayouts:x})},z={},j=e.context.depth,se=e.context.stencil;if((j===!0||se===!0)&&(j===!0&&(z.format=k,z.depthWriteEnabled=r.depthWrite,z.depthCompare=F),se===!0&&(z.stencilFront=T,z.stencilBack={},z.stencilReadMask=r.stencilFuncMask,z.stencilWriteMask=r.stencilWriteMask),r.polygonOffset===!0&&(z.depthBias=r.polygonOffsetUnits,z.depthBiasSlopeScale=r.polygonOffsetFactor,z.depthBiasClamp=0),U.depthStencil=z),t===null)y.pipeline=p.createRenderPipeline(U);else{const pe=new Promise(be=>{p.createRenderPipelineAsync(U).then(Pe=>{y.pipeline=Pe,be()})});t.push(pe)}}createBundleEncoder(e,t="renderBundleEncoder"){const n=this.backend,{utils:r,device:o}=n,a=r.getCurrentDepthStencilFormat(e),c=r.getCurrentColorFormat(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);c.push(d.layout)}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===St){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:rp.Add},n={srcFactor:y,dstFactor:x,operation:rp.Add}};if(u)switch(r){case qe:d(si.One,si.OneMinusSrcAlpha,si.One,si.OneMinusSrcAlpha);break;case et:d(si.One,si.One,si.One,si.One);break;case rt:d(si.Zero,si.OneMinusSrc,si.Zero,si.One);break;case at:d(si.Dst,si.OneMinusSrcAlpha,si.Zero,si.One);break}else switch(r){case qe:d(si.SrcAlpha,si.OneMinusSrcAlpha,si.One,si.OneMinusSrcAlpha);break;case et:d(si.SrcAlpha,si.One,si.One,si.One);break;case rt:console.error("THREE.WebGPURenderer: SubtractiveBlending requires material.premultipliedAlpha = true");break;case at:console.error("THREE.WebGPURenderer: MultiplyBlending requires material.premultipliedAlpha = true");break}}if(t!==void 0&&n!==void 0)return{color:t,alpha:n};console.error("THREE.WebGPURenderer: Invalid blending: ",r)}_getBlendFactor(e){let t;switch(e){case ni:t=si.Zero;break;case bs:t=si.One;break;case vr:t=si.Src;break;case Zr:t=si.OneMinusSrc;break;case Kr:t=si.SrcAlpha;break;case Ss:t=si.OneMinusSrcAlpha;break;case Tt:t=si.Dst;break;case rn:t=si.OneMinusDst;break;case xa:t=si.DstAlpha;break;case va:t=si.OneMinusDstAlpha;break;case On:t=si.SrcAlphaSaturated;break;case t5:t=si.Constant;break;case n5:t=si.OneMinusConstant;break;default:console.error("THREE.WebGPURenderer: Blend factor not supported.",e)}return t}_getStencilCompare(e){let t;const n=e.stencilFunc;switch(n){case U1:t=Fr.Never;break;case bp:t=Fr.Always;break;case k1:t=Fr.Less;break;case V1:t=Fr.LessEqual;break;case z1:t=Fr.Equal;break;case W1:t=Fr.GreaterEqual;break;case G1:t=Fr.Greater;break;case H1:t=Fr.NotEqual;break;default:console.error("THREE.WebGPURenderer: Invalid stencil function.",n)}return t}_getStencilOperation(e){let t;switch(e){case go:t=_d.Keep;break;case P1:t=_d.Zero;break;case I1:t=_d.Replace;break;case O1:t=_d.Invert;break;case L1:t=_d.IncrementClamp;break;case D1:t=_d.DecrementClamp;break;case F1:t=_d.IncrementWrap;break;case B1:t=_d.DecrementWrap;break;default:console.error("THREE.WebGPURenderer: Invalid stencil operation.",t)}return t}_getBlendOperation(e){let t;switch(e){case Ot:t=rp.Add;break;case Fn:t=rp.Subtract;break;case os:t=rp.ReverseSubtract;break;case Bn:t=rp.Min;break;case ei:t=rp.Max;break;default:console.error("THREE.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?tg.Uint16:tg.Uint32);let a=n.side===Ee;return e.isMesh&&e.matrixWorld.determinant()<0&&(a=!a),r.frontFace=a===!0?E2.CW:E2.CCW,r.cullMode=n.side===ke?C2.None:C2.Back,r}_getColorWriteMask(e){return e.colorWrite===!0?R2.All:R2.None}_getDepthCompare(e){let t;if(e.depthTest===!1)t=Fr.Always;else{const n=e.depthFunc;switch(n){case Wu:t=Fr.Never;break;case Sn:t=Fr.Always;break;case yi:t=Fr.Less;break;case Jr:t=Fr.LessEqual;break;case Ec:t=Fr.Equal;break;case Cc:t=Fr.GreaterEqual;break;case pp:t=Fr.Greater;break;case mp:t=Fr.NotEqual;break;default:console.error("THREE.WebGPUPipelineUtils: Invalid depth function.",n)}}return t}}class iq extends M2{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 wr(`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 en(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 en(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));let c=0;for(const[,u]of e){const d=a[u],p=a[u+1],m=Number(p-d)/1e6;c+=m}return this.resultBuffer.unmap(),this.lastValue=c,c}catch(e){return console.error("Error resolving queries:",e),this.resultBuffer.mapState==="mapped"&&this.resultBuffer.unmap(),this.lastValue}})}dispose(){return en(this,null,function*(){if(!this.isDisposed){if(this.isDisposed=!0,this.pendingResolve)try{yield this.pendingResolve}catch(e){console.error("Error waiting for pending resolve:",e)}if(this.resultBuffer&&this.resultBuffer.mapState==="mapped")try{this.resultBuffer.unmap()}catch(e){console.error("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 WM extends b2{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.context=null,this.colorBuffer=null,this.defaultRenderPassdescriptor=null,this.utils=new K$(this),this.attributeUtils=new eq(this),this.bindingUtils=new tq(this),this.pipelineUtils=new nq(this),this.textureUtils=new z$(this),this.occludedResolveCache=new Map}init(e){return en(this,null,function*(){yield uD(WM.prototype,this,"init").call(this,e);const t=this.parameters;let n;if(t.device===void 0){const c={powerPreference:t.powerPreference,featureLevel:t.compatibilityMode?"compatibility":void 0},u=typeof navigator!="undefined"?yield navigator.gpu.requestAdapter(c):null;if(u===null)throw new Error("WebGPUBackend: Unable to create WebGPU adapter.");const d=Object.values(GM),p=[];for(const y of d)u.features.has(y)&&p.push(y);const m={requiredFeatures:p,requiredLimits:t.requiredLimits};n=yield u.requestDevice(m)}else n=t.device;n.lost.then(c=>{const u={api:"WebGPU",message:c.message||"Unknown reason",reason:c.reason||null,originalEvent:c};e.onDeviceLost(u)});const r=t.context!==void 0?t.context:e.domElement.getContext("webgpu");this.device=n,this.context=r;const o=t.alpha?"premultiplied":"opaque",a=pn.getToneMappingMode(this.renderer.outputColorSpace);this.context.configure({device:this.device,format:this.utils.getPreferredCanvasFormat(),usage:GPUTextureUsage.RENDER_ATTACHMENT|GPUTextureUsage.COPY_SRC,alphaMode:o,toneMapping:{mode:a}}),this.trackTimestamp=this.trackTimestamp&&this.hasFeature(GM.TimestampQuery),this.updateSize()})}get coordinateSystem(){return Sr}getArrayBufferAsync(e){return en(this,null,function*(){return yield this.attributeUtils.getArrayBufferAsync(e)})}getContext(){return this.context}_getDefaultRenderPassDescriptor(){let e=this.defaultRenderPassdescriptor;if(e===null){const n=this.renderer;e={colorAttachments:[{view:null}]},(this.renderer.depth===!0||this.renderer.stencil===!0)&&(e.depthStencilAttachment={view:this.textureUtils.getDepthBuffer(n.depth,n.stencil).createView()});const r=e.colorAttachments[0];this.renderer.samples>0?r.view=this.colorBuffer.createView():r.resolveTarget=void 0,this.defaultRenderPassdescriptor=e}const t=e.colorAttachments[0];return this.renderer.samples>0?t.resolveTarget=this.context.getCurrentTexture().createView():t.view=this.context.getCurrentTexture().createView(),e}_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]),M={label:`colorAttachment_${x}`,baseMipLevel:e.activeMipmapLevel,mipLevelCount:1,baseArrayLayer:e.activeCubeFace,arrayLayerCount:1,dimension:er.TwoD};if(n.isRenderTarget3D)m=e.activeCubeFace,M.baseArrayLayer=0,M.dimension=er.ThreeD,M.depthOrArrayLayers=d[x].image.depth;else if(n.isRenderTarget&&d[x].image.depth>1)if(y===!0){const T=e.camera.cameras;for(let S=0;S<T.length;S++){const N=_a(Ii({},M),{baseArrayLayer:S,arrayLayerCount:1,dimension:er.TwoD}),R=v.texture.createView(N);p.push({view:R,resolveTarget:void 0,depthSlice:void 0})}}else M.dimension=er.TwoDArray,M.depthOrArrayLayers=d[x].image.depth;if(y!==!0){const T=v.texture.createView(M);let S,N;v.msaaTexture!==void 0?(S=v.msaaTexture.createView(),N=T):(S=T,N=void 0),p.push({view:S,resolveTarget:N,depthSlice:m})}}if(c={textureViews:p},e.depth){const x=this.get(e.depthTexture),v={};e.depthTexture.isArrayTexture&&(v.dimension=er.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||Mi.Load,storeOp:t.storeOp||fo.Store,clearValue:m})}return c.depthStencilView&&(u.depthStencilAttachment={view:c.depthStencilView}),u}beginRender(e){const t=this.get(e);t.frameCalls=this.renderer.info.render.frameCalls;const 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:Mi.Load}),this.initTimestampQuery(Nd.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=Mi.Clear):m.loadOp=Mi.Load,m.storeOp=fo.Store}}else{const d=a.colorAttachments[0];e.clearColor?(d.clearValue=e.clearColorValue,d.loadOp=Mi.Clear):d.loadOp=Mi.Load,d.storeOp=fo.Store}e.depth&&(e.clearDepth?(c.depthClearValue=e.clearDepthValue,c.depthLoadOp=Mi.Clear):c.depthLoadOp=Mi.Load,c.depthStoreOp=fo.Store),e.stencil&&(e.clearStencil?(c.stencilClearValue=e.clearStencilValue,c.stencilLoadOp=Mi.Clear):c.stencilLoadOp=Mi.Load,c.stencilStoreOp=fo.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);if(t.currentPass=d,e.viewport&&this.updateViewport(e),e.scissor){const{x:p,y:m,width:y,height:x}=e.scissorValue;d.setScissorRect(p,m,y,x)}}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=_a(Ii({},n),{colorAttachments:[_a(Ii({},n.colorAttachments[0]),{view:n.colorAttachments[c].view})]});if(n.depthStencilAttachment){const d=c;a.viewCache[d]||(a.viewCache[d]=a.texture.createView({dimension:er.TwoD,baseArrayLayer:c,arrayLayerCount:1})),u.depthStencilAttachment={view:a.viewCache[d],depthLoadOp:o.depthLoadOp||Mi.Clear,depthStoreOp:o.depthStoreOp||fo.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=Ii({},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=Mi.Clear):a.depthLoadOp=Mi.Load),e.stencil&&(e.clearStencil?(a.stencilClearValue=e.clearStencilValue,a.stencilLoadOp=Mi.Clear):a.stencilLoadOp=Mi.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 en(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)}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 M=c[0];M.clearValue=d,M.loadOp=Mi.Clear,M.storeOp=fo.Store}(p||m)&&(u=v.depthStencilAttachment)}else{p=r.depth,m=r.stencil;const v={loadOp:e?Mi.Clear:Mi.Load,clearValue:e?d:void 0};p&&(v.depthLoadOp=t?Mi.Clear:Mi.Load,v.depthClearValue=t?a.getClearDepth():void 0,v.depthStoreOp=fo.Store),m&&(v.stencilLoadOp=n?Mi.Clear:Mi.Load,v.stencilClearValue=n?a.getClearStencil():void 0,v.stencilStoreOp=fo.Store);const M=this._getRenderPassDescriptor(r,v);c=M.colorAttachments,u=M.depthStencilAttachment}p&&u&&(t?(u.depthLoadOp=Mi.Clear,u.depthClearValue=a.getClearDepth(),u.depthStoreOp=fo.Store):(u.depthLoadOp=Mi.Load,u.depthStoreOp=fo.Store)),m&&u&&(n?(u.stencilLoadOp=Mi.Clear,u.stencilClearValue=a.getClearStencil(),u.stencilStoreOp=fo.Store):(u.stencilLoadOp=Mi.Load,u.stencilStoreOp=fo.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);t.frameCalls=this.renderer.info.compute.frameCalls;const n={label:"computeGroup_"+e.id};this.initTimestampQuery(Nd.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 p=0,m=n.length;p<m;p++){const y=n[p],x=this.get(y);c.setBindGroup(p,x.group)}let d;if(o===null&&(o=t.count),typeof o=="number"){const p=o;if(a.dispatchSize===void 0||a.count!==p){a.dispatchSize=[0,1,1],a.count=p;const m=t.workgroupSize;let y=m[0];for(let M=1;M<m.length;M++)y*=m[M];const x=Math.ceil(p/y),v=this.device.limits.maxComputeWorkgroupsPerDimension;d=[x,1,1],x>v&&(d[0]=Math.min(x,v),d[1]=Math.ceil(x/v)),a.dispatchSize=d}d=a.dispatchSize}else d=o;c.dispatchWorkgroups(d[0],d[1]||1,d[2]||1)}finishCompute(e){const t=this.get(e);t.passEncoderGPU.end(),this.device.queue.submit([t.cmdEncoderGPU.finish()])}waitForGPU(){return en(this,null,function*(){yield this.device.queue.onSubmittedWorkDone()})}draw(e,t){const{object:n,material:r,context:o,pipeline:a}=e,c=e.getBindings(),u=this.get(o),d=this.get(a).pipeline,p=e.getIndex(),m=p!==null,y=e.getDrawParameters();if(y===null)return;const x=(M,T)=>{this.pipelineUtils.setPipeline(M,d),T.pipeline=d;const S=T.bindingGroups;for(let R=0,P=c.length;R<P;R++){const B=c[R],F=this.get(B);S[B.index]!==B.id&&(M.setBindGroup(B.index,F.group),S[B.index]=B.id)}if(m===!0&&T.index!==p){const R=this.get(p).buffer,P=p.array instanceof Uint16Array?tg.Uint16:tg.Uint32;M.setIndexBuffer(R,P),T.index=p}const N=e.getVertexBuffers();for(let R=0,P=N.length;R<P;R++){const B=N[R];if(T.attributes[R]!==B){const F=this.get(B).buffer;M.setVertexBuffer(R,F),T.attributes[R]=B}}o.stencil===!0&&r.stencilWrite===!0&&u.currentStencilRef!==r.stencilRef&&(M.setStencilReference(r.stencilRef),u.currentStencilRef=r.stencilRef)},v=(M,T)=>{if(x(M,T),n.isBatchedMesh===!0){const S=n._multiDrawStarts,N=n._multiDrawCounts,R=n._multiDrawCount,P=n._multiDrawInstances;P!==null&&wr("THREE.WebGPUBackend: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.");for(let B=0;B<R;B++){const F=P?P[B]:1,k=F>1?0:B;m===!0?M.drawIndexed(N[B],F,S[B]/p.array.BYTES_PER_ELEMENT,0,k):M.draw(N[B],F,S[B],k),t.update(n,N[B],F)}}else if(m===!0){const{vertexCount:S,instanceCount:N,firstVertex:R}=y,P=e.getIndirect();if(P!==null){const B=this.get(P).buffer;M.drawIndexedIndirect(B,0)}else M.drawIndexed(S,N,R,0,0);t.update(n,S,N)}else{const{vertexCount:S,instanceCount:N,firstVertex:R}=y,P=e.getIndirect();if(P!==null){const B=this.get(P).buffer;M.drawIndirect(B,0)}else M.draw(S,N,R,0);t.update(n,S,N)}};if(e.camera.isArrayCamera&&e.camera.cameras.length>0){const M=this.get(e.camera),T=e.camera.cameras,S=e.getBindingGroup("cameraIndex");if(M.indexesGPU===void 0||M.indexesGPU.length!==T.length){const R=this.get(S),P=[],B=new Uint32Array([0,0,0,0]);for(let F=0,k=T.length;F<k;F++){B[0]=F;const V=this.bindingUtils.createBindGroupIndex(B,R.layout);P.push(V)}M.indexesGPU=P}const N=this.renderer.getPixelRatio();for(let R=0,P=T.length;R<P;R++){const B=T[R];if(n.layers.test(B.layers)){const F=B.viewport;let k=u.currentPass,V=u.currentSets;if(u.bundleEncoders){const U=u.bundleEncoders[R],z=u.bundleSets[R];k=U,V=z}F&&k.setViewport(Math.floor(F.x*N),Math.floor(F.y*N),Math.floor(F.width*N),Math.floor(F.height*N),o.viewportValue.minDepth,o.viewportValue.maxDepth),S&&M.indexesGPU&&(k.setBindGroup(S.index,M.indexesGPU[R]),V.bindingGroups[S.index]=S.id),v(k,V)}}}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)}v(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()}createSampler(e){this.textureUtils.createSampler(e)}destroySampler(e){this.textureUtils.destroySampler(e)}createDefaultTexture(e){this.textureUtils.createDefaultTexture(e)}createTexture(e,t){this.textureUtils.createTexture(e,t)}updateTexture(e,t){this.textureUtils.updateTexture(e,t)}generateMipmaps(e){this.textureUtils.generateMipmaps(e)}destroyTexture(e){this.textureUtils.destroyTexture(e)}copyTextureToBuffer(e,t,n,r,o,a){return en(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 iq(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 Z$(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)}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.colorBuffer=this.textureUtils.getColorBuffer(),this.defaultRenderPassdescriptor=null}getMaxAnisotropy(){return 16}hasFeature(e){return 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,M=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,M=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,M=1)),r!==null&&(c=r.x,u=r.y,d=r.z||0);const T=this.device.createCommandEncoder({label:"copyTextureToTexture_"+e.id+"_"+t.id}),S=this.get(e).texture,N=this.get(t).texture;T.copyTextureToTexture({texture:S,mipLevel:o,origin:{x:p,y:m,z:y}},{texture:N,mipLevel:a,origin:{x:c,y:u,z:d}},[x,v,M]),this.device.queue.submit([T.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){console.error("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]),r.currentPass){const{descriptor:u}=r;for(let d=0;d<u.colorAttachments.length;d++)u.colorAttachments[d].loadOp=Mi.Load;if(t.depth&&(u.depthStencilAttachment.depthLoadOp=Mi.Load),t.stencil&&(u.depthStencilAttachment.stencilLoadOp=Mi.Load),r.currentPass=c.beginRenderPass(u),r.currentSets={attributes:{},bindingGroups:[],pipeline:null,index:null},t.viewport&&this.updateViewport(t),t.scissor){const{x:d,y:p,width:m,height:y}=t.scissorValue;r.currentPass.setScissorRect(d,p,m,y)}}else this.device.queue.submit([c.finish()]);e.generateMipmaps&&this.textureUtils.generateMipmaps(e)}}class sq extends lm{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 rq extends lm{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 oq extends s2{constructor(){super(),this.addMaterial(qG,"MeshPhongMaterial"),this.addMaterial(DP,"MeshStandardMaterial"),this.addMaterial(I4,"MeshPhysicalMaterial"),this.addMaterial(O4,"MeshToonMaterial"),this.addMaterial(kG,"MeshBasicMaterial"),this.addMaterial(WG,"MeshLambertMaterial"),this.addMaterial(DG,"MeshNormalMaterial"),this.addMaterial(k4,"MeshMatcapMaterial"),this.addMaterial(EG,"LineBasicMaterial"),this.addMaterial(RG,"LineDashedMaterial"),this.addMaterial(W4,"PointsMaterial"),this.addMaterial(BP,"SpriteMaterial"),this.addMaterial(j4,"ShadowMaterial"),this.addLight(u6,X0),this.addLight(k8,_u),this.addLight(z8,Y0),this.addLight(RM,lm),this.addLight(W8,Mf),this.addLight($8,yu),this.addLight(q8,fy),this.addLight(V8,sq),this.addLight(H8,rq),this.addToneMapping(lI,pb),this.addToneMapping(cI,mb),this.addToneMapping(uI,gb),this.addToneMapping(hI,yb),this.addToneMapping(dI,_b),this.addToneMapping(fI,xb)}}class aq extends h${constructor(e={}){let t;e.forceWebGL?t=A2:(t=WM,e.getFallback=()=>(console.warn("THREE.WebGPURenderer: WebGPU is not available, running under WebGL2 backend."),new A2(e)));const n=new t(e);super(n,e),this.library=new oq,this.isWebGPURenderer=!0,typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}}class YZ extends null{constructor(){super(),this.isBundleGroup=!0,this.type="BundleGroup",this.static=!0,this.version=0}set needsUpdate(e){e===!0&&this.version++}}class ZZ{constructor(e,t=Lt(0,0,1,1)){this.renderer=e,this.outputNode=t,this.outputColorTransform=!0,this.needsUpdate=!0;const n=new _s;n.name="PostProcessing",this._quadMesh=new E_(n),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=QT(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 en(this,null,function*(){this._update(),this._context.onBeforePostProcessing!==null&&this._context.onBeforePostProcessing();const e=this.renderer,t=e.toneMapping,n=e.outputColorSpace;e.toneMapping=NoToneMapping,e.outputColorSpace=ColorManagement.workingColorSpace;const r=e.xr.enabled;e.xr.enabled=!1,yield this._quadMesh.renderAsync(e),e.xr.enabled=r,e.toneMapping=t,e.outputColorSpace=n,this._context.onAfterPostProcessing!==null&&this._context.onAfterPostProcessing()})}}class KZ extends null{constructor(e=1,t=1){super(),this.image={width:e,height:t},this.magFilter=LinearFilter,this.minFilter=LinearFilter,this.isStorageTexture=!0}setSize(e,t){(this.image.width!==e||this.image.height!==t)&&(this.image.width=e,this.image.height=t,this.dispose())}}class JZ 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 QZ 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 eK extends null{constructor(e,t){super(e,t,Uint32Array),this.isIndirectStorageBufferAttribute=!0}}class lq 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):console.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?(console.error("THREE.NodeLoader: Node type not found:",e),$()):Ge(new this.nodes[e])}}class cq 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 tK 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 lq;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 cq;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 nK extends null{constructor(){super(),this.isClippingGroup=!0,this.clippingPlanes=[],this.enabled=!0,this.clipIntersection=!1,this.clipShadows=!1}}const $M={type:"change"},qM={type:"start"},XM={type:"end"},U2=1e-6,Ai={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4},qv=new Ie,xd=new Ie,uq=new W,Xv=new W,jM=new W,ig=new Fs,k2=new W,jv=new W,YM=new W,Yv=new W;class hq extends If{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:ye.ROTATE,MIDDLE:ye.DOLLY,RIGHT:ye.PAN},this.target=new W,this.state=Ai.NONE,this.keyState=Ai.NONE,this._lastPosition=new W,this._lastZoom=1,this._touchZoomDistanceStart=0,this._touchZoomDistanceEnd=0,this._lastAngle=0,this._eye=new W,this._movePrev=new Ie,this._moveCurr=new Ie,this._lastAxis=new W,this._zoomStart=new Ie,this._zoomEnd=new Ie,this._panStart=new Ie,this._panEnd=new Ie,this._pointers=[],this._pointerPositions={},this._onPointerMove=fq.bind(this),this._onPointerDown=dq.bind(this),this._onPointerUp=pq.bind(this),this._onPointerCancel=mq.bind(this),this._onContextMenu=Sq.bind(this),this._onMouseWheel=bq.bind(this),this._onKeyDown=yq.bind(this),this._onKeyUp=gq.bind(this),this._onTouchStart=Tq.bind(this),this._onTouchMove=wq.bind(this),this._onTouchEnd=Mq.bind(this),this._onMouseDown=_q.bind(this),this._onMouseMove=xq.bind(this),this._onMouseUp=vq.bind(this),this._target0=this.target.clone(),this._position0=this.object.position.clone(),this._up0=this.object.up.clone(),this._zoom0=this.object.zoom,t!==null&&(this.connect(t),this.handleResize()),this.update()}connect(e){super.connect(e),window.addEventListener("keydown",this._onKeyDown),window.addEventListener("keyup",this._onKeyUp),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerCancel),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="none"}disconnect(){window.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("keyup",this._onKeyUp),this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerCancel),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}handleResize(){const e=this.domElement.getBoundingClientRect(),t=this.domElement.ownerDocument.documentElement;this.screen.left=e.left+window.pageXOffset-t.clientLeft,this.screen.top=e.top+window.pageYOffset-t.clientTop,this.screen.width=e.width,this.screen.height=e.height}update(){this._eye.subVectors(this.object.position,this.target),this.noRotate||this._rotateCamera(),this.noZoom||this._zoomCamera(),this.noPan||this._panCamera(),this.object.position.addVectors(this.target,this._eye),this.object.isPerspectiveCamera?(this._checkDistances(),this.object.lookAt(this.target),this._lastPosition.distanceToSquared(this.object.position)>U2&&(this.dispatchEvent($M),this._lastPosition.copy(this.object.position))):this.object.isOrthographicCamera?(this.object.lookAt(this.target),(this._lastPosition.distanceToSquared(this.object.position)>U2||this._lastZoom!==this.object.zoom)&&(this.dispatchEvent($M),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom)):console.warn("THREE.TrackballControls: Unsupported camera type.")}reset(){this.state=Ai.NONE,this.keyState=Ai.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($M),this._lastPosition.copy(this.object.position),this._lastZoom=this.object.zoom}_panCamera(){if(xd.copy(this._panEnd).sub(this._panStart),xd.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;xd.x*=e,xd.y*=t}xd.multiplyScalar(this._eye.length()*this.panSpeed),Xv.copy(this._eye).cross(this.object.up).setLength(xd.x),Xv.add(uq.copy(this.object.up).setLength(xd.y)),this.object.position.add(Xv),this.target.add(Xv),this.staticMoving?this._panStart.copy(this._panEnd):this._panStart.add(xd.subVectors(this._panEnd,this._panStart).multiplyScalar(this.dynamicDampingFactor))}}_rotateCamera(){Yv.set(this._moveCurr.x-this._movePrev.x,this._moveCurr.y-this._movePrev.y,0);let e=Yv.length();e?(this._eye.copy(this.object.position).sub(this.target),k2.copy(this._eye).normalize(),jv.copy(this.object.up).normalize(),YM.crossVectors(jv,k2).normalize(),jv.setLength(this._moveCurr.y-this._movePrev.y),YM.setLength(this._moveCurr.x-this._movePrev.x),Yv.copy(jv.add(YM)),jM.crossVectors(Yv,this._eye).normalize(),e*=this.rotateSpeed,ig.setFromAxisAngle(jM,e),this._eye.applyQuaternion(ig),this.object.up.applyQuaternion(ig),this._lastAxis.copy(jM),this._lastAngle=e):!this.staticMoving&&this._lastAngle&&(this._lastAngle*=Math.sqrt(1-this.dynamicDampingFactor),this._eye.copy(this.object.position).sub(this.target),ig.setFromAxisAngle(this._lastAxis,this._lastAngle),this._eye.applyQuaternion(ig),this.object.up.applyQuaternion(ig)),this._movePrev.copy(this._moveCurr)}_zoomCamera(){let e;this.state===Ai.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=Ld.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=Ld.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 qv.set((e-this.screen.left)/this.screen.width,(t-this.screen.top)/this.screen.height),qv}_getMouseOnCircle(e,t){return qv.set((e-this.screen.width*.5-this.screen.left)/(this.screen.width*.5),(this.screen.height+2*(this.screen.top-t))/this.screen.width),qv}_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 Ie,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 dq(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i))}function fq(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function pq(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchEnd(i):this._onMouseUp(),this._removePointer(i),this._pointers.length===0&&(this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp)))}function mq(i){this._removePointer(i)}function gq(){this.enabled!==!1&&(this.keyState=Ai.NONE,window.addEventListener("keydown",this._onKeyDown))}function yq(i){this.enabled!==!1&&(window.removeEventListener("keydown",this._onKeyDown),this.keyState===Ai.NONE&&(i.code===this.keys[Ai.ROTATE]&&!this.noRotate?this.keyState=Ai.ROTATE:i.code===this.keys[Ai.ZOOM]&&!this.noZoom?this.keyState=Ai.ZOOM:i.code===this.keys[Ai.PAN]&&!this.noPan&&(this.keyState=Ai.PAN)))}function _q(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 ye.DOLLY:this.state=Ai.ZOOM;break;case ye.ROTATE:this.state=Ai.ROTATE;break;case ye.PAN:this.state=Ai.PAN;break;default:this.state=Ai.NONE}const t=this.keyState!==Ai.NONE?this.keyState:this.state;t===Ai.ROTATE&&!this.noRotate?(this._moveCurr.copy(this._getMouseOnCircle(i.pageX,i.pageY)),this._movePrev.copy(this._moveCurr)):t===Ai.ZOOM&&!this.noZoom?(this._zoomStart.copy(this._getMouseOnScreen(i.pageX,i.pageY)),this._zoomEnd.copy(this._zoomStart)):t===Ai.PAN&&!this.noPan&&(this._panStart.copy(this._getMouseOnScreen(i.pageX,i.pageY)),this._panEnd.copy(this._panStart)),this.dispatchEvent(qM)}function xq(i){const e=this.keyState!==Ai.NONE?this.keyState:this.state;e===Ai.ROTATE&&!this.noRotate?(this._movePrev.copy(this._moveCurr),this._moveCurr.copy(this._getMouseOnCircle(i.pageX,i.pageY))):e===Ai.ZOOM&&!this.noZoom?this._zoomEnd.copy(this._getMouseOnScreen(i.pageX,i.pageY)):e===Ai.PAN&&!this.noPan&&this._panEnd.copy(this._getMouseOnScreen(i.pageX,i.pageY))}function vq(){this.state=Ai.NONE,this.dispatchEvent(XM)}function bq(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(qM),this.dispatchEvent(XM)}}function Sq(i){this.enabled!==!1&&i.preventDefault()}function Tq(i){switch(this._trackPointer(i),this._pointers.length){case 1:this.state=Ai.TOUCH_ROTATE,this._moveCurr.copy(this._getMouseOnCircle(this._pointers[0].pageX,this._pointers[0].pageY)),this._movePrev.copy(this._moveCurr);break;default:this.state=Ai.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(qM)}function wq(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 Mq(i){switch(this._pointers.length){case 0:this.state=Ai.NONE;break;case 1:this.state=Ai.TOUCH_ROTATE,this._moveCurr.copy(this._getMouseOnCircle(i.pageX,i.pageY)),this._movePrev.copy(this._moveCurr);break;case 2:this.state=Ai.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(XM)}const z2={type:"change"},ZM={type:"start"},V2={type:"end"},Zv=new Hl,G2=new Rr,Aq=Math.cos(70*Ld.DEG2RAD),lr=new W,Uo=2*Math.PI,Bi={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},KM=1e-6;class Eq extends If{constructor(e,t=null){super(e,t),this.state=Bi.NONE,this.target=new W,this.cursor=new W,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:ye.ROTATE,MIDDLE:ye.DOLLY,RIGHT:ye.PAN},this.touches={ONE:fe.ROTATE,TWO:fe.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new W,this._lastQuaternion=new Fs,this._lastTargetPosition=new W,this._quat=new Fs().setFromUnitVectors(e.up,new W(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new wy,this._sphericalDelta=new wy,this._scale=1,this._panOffset=new W,this._rotateStart=new Ie,this._rotateEnd=new Ie,this._rotateDelta=new Ie,this._panStart=new Ie,this._panEnd=new Ie,this._panDelta=new Ie,this._dollyStart=new Ie,this._dollyEnd=new Ie,this._dollyDelta=new Ie,this._dollyDirection=new W,this._mouse=new Ie,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Rq.bind(this),this._onPointerDown=Cq.bind(this),this._onPointerUp=Nq.bind(this),this._onContextMenu=Oq.bind(this),this._onMouseWheel=Lq.bind(this),this._onKeyDown=Dq.bind(this),this._onTouchStart=Fq.bind(this),this._onTouchMove=Bq.bind(this),this._onMouseDown=Pq.bind(this),this._onMouseMove=Iq.bind(this),this._interceptControlDown=Uq.bind(this),this._interceptControlUp=kq.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(z2),this.update(),this.state=Bi.NONE}update(e=null){const t=this.object.position;lr.copy(t).sub(this.target),lr.applyQuaternion(this._quat),this._spherical.setFromVector3(lr),this.autoRotate&&this.state===Bi.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,r=this.maxAzimuthAngle;isFinite(n)&&isFinite(r)&&(n<-Math.PI?n+=Uo:n>Math.PI&&(n-=Uo),r<-Math.PI?r+=Uo:r>Math.PI&&(r-=Uo),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(lr.setFromSpherical(this._spherical),lr.applyQuaternion(this._quatInverse),t.copy(this.target).add(lr),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=lr.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 W(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 W(this._mouse.x,this._mouse.y,0);d.unproject(this.object),this.object.position.sub(d).add(c),this.object.updateMatrixWorld(),a=lr.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):(Zv.origin.copy(this.object.position),Zv.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Zv.direction))<Aq?this.object.lookAt(this.target):(G2.setFromNormalAndCoplanarPoint(this.object.up,this.target),Zv.intersectPlane(G2,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)>KM||8*(1-this._lastQuaternion.dot(this.object.quaternion))>KM||this._lastTargetPosition.distanceToSquared(this.target)>KM?(this.dispatchEvent(z2),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Uo/60*this.autoRotateSpeed*e:Uo/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){lr.setFromMatrixColumn(t,0),lr.multiplyScalar(-e),this._panOffset.add(lr)}_panUp(e,t){this.screenSpacePanning===!0?lr.setFromMatrixColumn(t,1):(lr.setFromMatrixColumn(t,0),lr.crossVectors(this.object.up,lr)),lr.multiplyScalar(e),this._panOffset.add(lr)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const r=this.object.position;lr.copy(r).sub(this.target);let o=lr.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(Uo*this._rotateDelta.x/t.clientHeight),this._rotateUp(Uo*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(Uo*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(-Uo*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(Uo*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(-Uo*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(Uo*this._rotateDelta.x/t.clientHeight),this._rotateUp(Uo*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 Ie,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 Cq(i){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(i.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(i)&&(this._addPointer(i),i.pointerType==="touch"?this._onTouchStart(i):this._onMouseDown(i)))}function Rq(i){this.enabled!==!1&&(i.pointerType==="touch"?this._onTouchMove(i):this._onMouseMove(i))}function Nq(i){switch(this._removePointer(i),this._pointers.length){case 0:this.domElement.releasePointerCapture(i.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(V2),this.state=Bi.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function Pq(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 ye.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(i),this.state=Bi.DOLLY;break;case ye.ROTATE:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Bi.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Bi.ROTATE}break;case ye.PAN:if(i.ctrlKey||i.metaKey||i.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(i),this.state=Bi.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(i),this.state=Bi.PAN}break;default:this.state=Bi.NONE}this.state!==Bi.NONE&&this.dispatchEvent(ZM)}function Iq(i){switch(this.state){case Bi.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(i);break;case Bi.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(i);break;case Bi.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(i);break}}function Lq(i){this.enabled===!1||this.enableZoom===!1||this.state!==Bi.NONE||(i.preventDefault(),this.dispatchEvent(ZM),this._handleMouseWheel(this._customWheelEvent(i)),this.dispatchEvent(V2))}function Dq(i){this.enabled!==!1&&this._handleKeyDown(i)}function Fq(i){switch(this._trackPointer(i),this._pointers.length){case 1:switch(this.touches.ONE){case fe.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(i),this.state=Bi.TOUCH_ROTATE;break;case fe.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(i),this.state=Bi.TOUCH_PAN;break;default:this.state=Bi.NONE}break;case 2:switch(this.touches.TWO){case fe.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(i),this.state=Bi.TOUCH_DOLLY_PAN;break;case fe.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(i),this.state=Bi.TOUCH_DOLLY_ROTATE;break;default:this.state=Bi.NONE}break;default:this.state=Bi.NONE}this.state!==Bi.NONE&&this.dispatchEvent(ZM)}function Bq(i){switch(this._trackPointer(i),this.state){case Bi.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(i),this.update();break;case Bi.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(i),this.update();break;case Bi.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(i),this.update();break;case Bi.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(i),this.update();break;default:this.state=Bi.NONE}}function Oq(i){this.enabled!==!1&&i.preventDefault()}function Uq(i){i.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function kq(i){i.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const zq={type:"change"},H2=1e-6,W2=new Fs;class Vq extends If{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 W(0,0,0),this._rotationVector=new W(0,0,0),this._lastQuaternion=new Fs,this._lastPosition=new W,this._status=0,this._onKeyDown=Gq.bind(this),this._onKeyUp=Hq.bind(this),this._onPointerMove=$q.bind(this),this._onPointerDown=Wq.bind(this),this._onPointerUp=qq.bind(this),this._onPointerCancel=Xq.bind(this),this._onContextMenu=jq.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),W2.set(this._rotationVector.x*r,this._rotationVector.y*r,this._rotationVector.z*r,1).normalize(),t.quaternion.multiply(W2),(this._lastPosition.distanceToSquared(t.position)>H2||8*(1-this._lastQuaternion.dot(t.quaternion))>H2)&&(this.dispatchEvent(zq),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 Gq(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 Hq(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 Wq(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 $q(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 qq(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 Xq(){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 jq(i){this.enabled!==!1&&i.preventDefault()}const Yq={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 Kv{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 Zq=new Jh(-1,1,1,-1,0,1);class Kq extends gn{constructor(){super(),this.setAttribute("position",new $t([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new $t([0,2,0,0,2,0],2))}}const Jq=new Kq;class Qq{constructor(e){this._mesh=new vi(Jq,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Zq)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class e9 extends Kv{constructor(e,t="tDiffuse"){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof Jo?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=Hd.clone(e.uniforms),this.material=new Jo({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 Qq(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 $2 extends Kv{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 t9 extends Kv{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class n9{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const n=e.getSize(new Ie);this._width=n.width,this._height=n.height,t=new Aa(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:Ts}),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 e9(Yq),this.copyPass.material.blending=Ae,this.clock=new J0}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()}$2!==void 0&&(a instanceof $2?n=!0:a instanceof t9&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){const t=this.renderer.getSize(new Ie);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 i9 extends Kv{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._oldClearColor=new At}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}}function ko(){return ko=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(i[n]=t[n])}return i},ko.apply(null,arguments)}function s9(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function G_(i,e){return G_=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},G_(i,e)}function r9(i,e){i.prototype=Object.create(e.prototype),i.prototype.constructor=i,G_(i,e)}function JM(i){return JM=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},JM(i)}function o9(i){try{return Function.toString.call(i).indexOf("[native code]")!==-1}catch(e){return typeof i=="function"}}function q2(){try{var i=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(q2=function(){return!!i})()}function a9(i,e,t){if(q2())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,e);var r=new(i.bind.apply(i,n));return t&&G_(r,t.prototype),r}function QM(i){var e=typeof Map=="function"?new Map:void 0;return QM=function(n){if(n===null||!o9(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 a9(n,arguments,JM(this).constructor)}return r.prototype=Object.create(n.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),G_(r,n)},QM(i)}function X2(){var i;return i=arguments.length-1,i<0||arguments.length<=i?void 0:arguments[i]}function l9(i){return-i}function c9(i,e){return i+e}function u9(i,e){return i-e}function h9(i,e){return i*e}function d9(i,e){return i/e}function f9(){return Math.max.apply(Math,arguments)}function p9(){return Math.min.apply(Math,arguments)}function m9(){return Array.of.apply(Array,arguments)}var iK={symbols:{"*":{infix:{symbol:"*",f:h9,notation:"infix",precedence:4,rightToLeft:0,argCount:2},symbol:"*",regSymbol:"\\*"},"/":{infix:{symbol:"/",f:d9,notation:"infix",precedence:4,rightToLeft:0,argCount:2},symbol:"/",regSymbol:"/"},"+":{infix:{symbol:"+",f:c9,notation:"infix",precedence:2,rightToLeft:0,argCount:2},prefix:{symbol:"+",f:X2,notation:"prefix",precedence:3,rightToLeft:0,argCount:1},symbol:"+",regSymbol:"\\+"},"-":{infix:{symbol:"-",f:u9,notation:"infix",precedence:2,rightToLeft:0,argCount:2},prefix:{symbol:"-",f:l9,notation:"prefix",precedence:3,rightToLeft:0,argCount:1},symbol:"-",regSymbol:"-"},",":{infix:{symbol:",",f:m9,notation:"infix",precedence:1,rightToLeft:0,argCount:2},symbol:",",regSymbol:","},"(":{prefix:{symbol:"(",f:X2,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:p9,notation:"func",precedence:0,rightToLeft:0,argCount:1},symbol:"min",regSymbol:"min\\b"},max:{func:{symbol:"max",f:f9,notation:"func",precedence:0,rightToLeft:0,argCount:1},symbol:"max",regSymbol:"max\\b"}}},j2=null,sK={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 rK(){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 bn=function(i){r9(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 s9(n)}return e}(QM(Error)),Y2=/((?!\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 g9(i){var e={};return e.symbols=i?_extends({},j2.symbols,i.symbols):_extends({},j2.symbols),e}function Z2(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 y9(i,e){var t=g9(e),n,r=[t.symbols["("].prefix],o=[],a=new RegExp("\\d+(?:\\.\\d+)?|"+Object.keys(t.symbols).map(function(T){return t.symbols[T]}).sort(function(T,S){return S.symbol.length-T.symbol.length}).map(function(T){return T.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 bn(37,n?n.index:i.length,i);if(c){var v=m.postfix||m.infix;do{var M=r[r.length-1];if((v.precedence-M.precedence||M.rightToLeft)>0)break}while(Z2(r,o));c=v.notation==="postfix",v.symbol!==")"&&(r.push(v),c&&Z2(r,o))}else if(m){if(r.push(m.prefix||m.func),m.func&&(n=a.exec(i),!n||n[0]!=="("))throw new bn(38,n?n.index:i.length,i)}else o.push(+d),c=!0}while(n&&r.length);if(r.length)throw new bn(39,n?n.index:i.length,i);if(n)throw new bn(40,n?n.index:i.length,i);return o.pop()}function e1(i){return i.split("").reverse().join("")}function oK(i,e){var t=e1(i),n=t.match(Y2);if(n&&!n.every(function(o){return o===n[0]}))throw new bn(41);var r=e1(t.replace(Y2,""));return""+y9(r,e)+(n?e1(n[0]):"")}var _9=/--[\S]*/g;function aK(i,e){if(!i||!i.match(_9))throw new bn(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 bn(74)}function H_(i){return i.charAt(0).toUpperCase()+i.slice(1)}var x9=null;function v9(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+H_(o)});var n=i.replace(/([a-z])([A-Z])/g,"$1"+e+"$2");return i===n?""+i+e:n}function b9(i,e){for(var t={},n=0;n<e.length;n+=1)(e[n]||e[n]===0)&&(t[v9(i,x9[n])]=e[n]);return t}function ap(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 b9(i,m)}function K2(i,e){return i.substr(-e.length)===e}var S9=/^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/;function J2(i){if(typeof i!="string")return i;var e=i.match(S9);return e?parseFloat(i):i}var T9=function(e){return function(t,n){n===void 0&&(n="16px");var r=t,o=n;if(typeof t=="string"){if(!K2(t,"px"))throw new bn(69,e,t);r=J2(t)}if(typeof n=="string"){if(!K2(n,"px"))throw new bn(70,e,n);o=J2(n)}if(typeof r=="string")throw new bn(71,t,e);if(typeof o=="string")throw new bn(72,n,e);return""+r/o+e}},Q2=T9,lK=Q2("em"),cK=null,w9=/^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/;function ku(i){if(typeof i!="string")return[i,""];var e=i.match(w9);return e?[parseFloat(i),e[2]]:[i,void 0]}function M9(i,e){if(typeof i!="object"||i===null)throw new bn(75,typeof i);var t={};return Object.keys(i).forEach(function(n){typeof i[n]=="object"&&i[n]!==null?t[n]=M9(i[n],e):!e||e&&(e===n||e.indexOf(n)>=0)?t[n]=i[n]+" !important":t[n]=i[n]}),t}var eL={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 A9(i){return eL[i]}function uK(i,e,t){if(e===void 0&&(e="1em"),t===void 0&&(t=1.333),typeof i!="number")throw new bn(42);if(typeof t=="string"&&!eL[t])throw new bn(43);var n=typeof e=="string"?ku(e):[e,""],r=n[0],o=n[1],a=typeof t=="string"?A9(t):t;if(typeof r=="string")throw new bn(44,e);return""+r*Math.pow(a,i)+(o||"")}var hK=Q2("rem"),dK=null,t1=16;function tL(i){var e=ku(i);if(e[1]==="px")return parseFloat(i);if(e[1]==="%")return parseFloat(i)/100*t1;throw new bn(78,e[1])}function E9(){if(typeof document!="undefined"&&document.documentElement!==null){var i=getComputedStyle(document.documentElement).fontSize;return i?tL(i):t1}return t1}function fK(i,e){var t=ku(i);if(t[1]!=="rem"&&t[1]!=="")throw new bn(77,t[1]);var n=e?tL(e):E9();return t[0]*n+"px"}var C9={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 pK(i){return C9[i.toLowerCase().trim()]}var R9={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 mK(i){return R9[i.toLowerCase().trim()]}var N9={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 gK(i){return N9[i.toLowerCase().trim()]}function nL(i,e,t,n){t===void 0&&(t="320px"),n===void 0&&(n="1200px");var r=ku(i),o=r[0],a=r[1],c=ku(e),u=c[0],d=c[1],p=ku(t),m=p[0],y=p[1],x=ku(n),v=x[0],M=x[1];if(typeof m!="number"||typeof v!="number"||!y||!M||y!==M)throw new bn(47);if(typeof o!="number"||typeof u!="number"||a!==d)throw new bn(48);if(a!==y||d!==M)throw new bn(76);var T=(o-u)/(m-v),S=u-T*v;return"calc("+S.toFixed(2)+(a||"")+" + "+(100*T).toFixed(2)+"vw)"}function yK(i){var e;i===void 0&&(i="&");var t=i+"::after";return e={},e[t]={clear:"both",content:'""',display:"table"},e}function _K(i){return i===void 0&&(i=0),{position:"absolute",top:i,right:i,bottom:i,left:i}}function xK(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 P9(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=I9(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 I9(i,e){if(i){if(typeof i=="string")return iL(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 iL(i,e)}}function iL(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 vK(i,e,t){if(e===void 0&&(e="320px"),t===void 0&&(t="1200px"),!Array.isArray(i)&&typeof i!="object"||i===null)throw new bn(49);if(Array.isArray(i)){for(var n={},r={},o=P9(i),a;!(a=o()).done;){var c,u,d=a.value;if(!d.prop||!d.fromSize||!d.toSize)throw new bn(50);r[d.prop]=d.fromSize,n["@media (min-width: "+e+")"]=_extends({},n["@media (min-width: "+e+")"],(c={},c[d.prop]=nL(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 bn(51);return y={},y[i.prop]=i.fromSize,y["@media (min-width: "+e+")"]=(p={},p[i.prop]=nL(i.fromSize,i.toSize,e,t),p),y["@media (min-width: "+t+")"]=(m={},m[i.prop]=i.toSize,m),y}}var L9=/^\s*data:([a-z]+\/[a-z-]+(;[a-z-]+=[a-z-]+)?)?(;charset=[a-z0-9-]+)?(;base64)?,[a-z0-9!$&',()*+,;=\-._~:@/?%\s]*\s*$/i,D9={woff:"woff",woff2:"woff2",ttf:"truetype",otf:"opentype",eot:"embedded-opentype",svg:"svg",svgz:"svg"};function sL(i,e){return e?' format("'+D9[i]+'")':""}function F9(i){return!!i.replace(/\s+/g," ").match(L9)}function B9(i,e,t){if(F9(i))return'url("'+i+'")'+sL(e[0],t);var n=e.map(function(r){return'url("'+i+"."+r+'")'+sL(r,t)});return n.join(", ")}function O9(i){var e=i.map(function(t){return'local("'+t+'")'});return e.join(", ")}function U9(i,e,t,n){var r=[];return e&&r.push(O9(e)),i&&r.push(B9(i,t,n)),r.join(", ")}function bK(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,M=i.fontVariationSettings,T=i.fontFeatureSettings;if(!e)throw new bn(55);if(!t&&!y)throw new bn(52);if(y&&!Array.isArray(y))throw new bn(53);if(!Array.isArray(u))throw new bn(54);var S={"@font-face":{fontFamily:e,src:U9(t,y,u,p),unicodeRange:x,fontStretch:n,fontStyle:r,fontVariant:o,fontWeight:a,fontDisplay:v,fontVariationSettings:M,fontFeatureSettings:T}};return JSON.parse(JSON.stringify(S))}function SK(){return{textIndent:"101%",overflow:"hidden",whiteSpace:"nowrap"}}function TK(){return{border:"0",clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:"0",position:"absolute",whiteSpace:"nowrap",width:"1px"}}function k9(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 rL(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 oL;function wK(i){var e=i.colorStops,t=i.fallback,n=i.toDirection,r=n===void 0?"":n;if(!e||e.length<2)throw new bn(56);return{backgroundColor:t||e[0].replace(/,\s+/g,",").split(" ")[0].replace(/,(?=\S)/g,", "),backgroundImage:rL(oL||(oL=_taggedTemplateLiteralLoose(["linear-gradient(","",")"])),r,e.join(", ").replace(/,(?=\S)/g,", "))}}function MK(){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 aL;function AK(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 bn(57);return{backgroundColor:r||e[0].split(" ")[0],backgroundImage:rL(aL||(aL=_taggedTemplateLiteralLoose(["radial-gradient(","","","",")"])),a,u,n,e.join(", "))}}function EK(i,e,t,n,r){var o;if(t===void 0&&(t="png"),r===void 0&&(r="_2x"),!i)throw new bn(58);var a=t.replace(/^\./,""),c=n?n+"."+a:""+i+r+"."+a;return o={backgroundImage:"url("+i+"."+a+")"},o[k9()]=_extends({backgroundImage:"url("+c+")"},e?{backgroundSize:e}:{}),o}var z9={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 V9(i){return z9[i]}function CK(i){return V9(i)}var G9=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"}},H9=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 bn(59)}};function RK(i){var e=i.pointingDirection,t=i.height,n=i.width,r=i.foregroundColor,o=i.backgroundColor,a=o===void 0?"transparent":o,c=ku(n),u=ku(t);if(isNaN(u[0])||isNaN(c[0]))throw new bn(60);return _extends({width:"0",height:"0",borderColor:a},H9(e,r),{borderStyle:"solid",borderWidth:G9(e,u,c)})}function NK(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 W9(i,e,t){return n1(i)+","+n1(e)+","+n1(t)}function W_(i,e,t,n){if(n===void 0&&(n=W9),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 lL={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 $9(i){if(typeof i!="string")return i;var e=i.toLowerCase();return lL[e]?"#"+lL[e]:i}var q9=/^#[a-fA-F0-9]{6}$/,X9=/^#[a-fA-F0-9]{8}$/,j9=/^#[a-fA-F0-9]{3}$/,Y9=/^#[a-fA-F0-9]{4}$/,i1=/^rgb\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*\)$/i,Z9=/^rgb(?:a)?\(\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,)?\s*(\d{1,3})\s*(?:,|\/)\s*([-+]?\d*[.]?\d+[%]?)\s*\)$/i,K9=/^hsl\(\s*(\d{0,3}[.]?[0-9]+(?:deg)?)\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*(?:,)?\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,J9=/^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 zu(i){if(typeof i!="string")throw new bn(3);var e=$9(i);if(e.match(q9))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(X9)){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(j9))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(Y9)){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=i1.exec(e);if(r)return{red:parseInt(""+r[1],10),green:parseInt(""+r[2],10),blue:parseInt(""+r[3],10)};var o=Z9.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=K9.exec(e);if(a){var c=parseInt(""+a[1],10),u=parseInt(""+a[2],10)/100,d=parseInt(""+a[3],10)/100,p="rgb("+W_(c,u,d)+")",m=i1.exec(p);if(!m)throw new bn(4,e,p);return{red:parseInt(""+m[1],10),green:parseInt(""+m[2],10),blue:parseInt(""+m[3],10)}}var y=J9.exec(e.substring(0,50));if(y){var x=parseInt(""+y[1],10),v=parseInt(""+y[2],10)/100,M=parseInt(""+y[3],10)/100,T="rgb("+W_(x,v,M)+")",S=i1.exec(T);if(!S)throw new bn(4,e,T);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 bn(5)}function Q9(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 Tc(i){return Q9(zu(i))}var eX=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},s1=eX;function lp(i){var e=i.toString(16);return e.length===1?"0"+e:e}function r1(i){return lp(Math.round(i*255))}function tX(i,e,t){return s1("#"+r1(i)+r1(e)+r1(t))}function Jv(i,e,t){return W_(i,e,t,tX)}function cL(i,e,t){if(typeof i=="number"&&typeof e=="number"&&typeof t=="number")return Jv(i,e,t);if(typeof i=="object"&&e===void 0&&t===void 0)return Jv(i.hue,i.saturation,i.lightness);throw new bn(1)}function uL(i,e,t,n){if(typeof i=="number"&&typeof e=="number"&&typeof t=="number"&&typeof n=="number")return n>=1?Jv(i,e,t):"rgba("+W_(i,e,t)+","+n+")";if(typeof i=="object"&&e===void 0&&t===void 0&&n===void 0)return i.alpha>=1?Jv(i.hue,i.saturation,i.lightness):"rgba("+W_(i.hue,i.saturation,i.lightness)+","+i.alpha+")";throw new bn(2)}function Qv(i,e,t){if(typeof i=="number"&&typeof e=="number"&&typeof t=="number")return s1("#"+lp(i)+lp(e)+lp(t));if(typeof i=="object"&&e===void 0&&t===void 0)return s1("#"+lp(i.red)+lp(i.green)+lp(i.blue));throw new bn(6)}function $_(i,e,t,n){if(typeof i=="string"&&typeof e=="number"){var r=zu(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?Qv(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?Qv(i.red,i.green,i.blue):"rgba("+i.red+","+i.green+","+i.blue+","+i.alpha+")"}throw new bn(7)}var nX=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&(typeof e.alpha!="number"||typeof e.alpha=="undefined")},iX=function(e){return typeof e.red=="number"&&typeof e.green=="number"&&typeof e.blue=="number"&&typeof e.alpha=="number"},sX=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&(typeof e.alpha!="number"||typeof e.alpha=="undefined")},rX=function(e){return typeof e.hue=="number"&&typeof e.saturation=="number"&&typeof e.lightness=="number"&&typeof e.alpha=="number"};function Pl(i){if(typeof i!="object")throw new bn(8);if(iX(i))return $_(i);if(nX(i))return Qv(i);if(rX(i))return uL(i);if(sX(i))return cL(i);throw new bn(8)}function hL(i,e,t){return function(){var r=t.concat(Array.prototype.slice.call(arguments));return r.length>=e?i.apply(this,r):hL(i,e,r)}}function pa(i){return hL(i,i.length,[])}function oX(i,e){if(e==="transparent")return e;var t=Tc(e);return Pl(ko({},t,{hue:t.hue+parseFloat(i)}))}var PK=pa(oX),IK=null;function LK(i){if(i==="transparent")return i;var e=Tc(i);return Pl(_extends({},e,{hue:(e.hue+180)%360}))}function sg(i,e,t){return Math.max(i,Math.min(e,t))}function aX(i,e){if(e==="transparent")return e;var t=Tc(e);return Pl(ko({},t,{lightness:sg(0,1,t.lightness-parseFloat(i))}))}var DK=pa(aX),FK=null;function lX(i,e){if(e==="transparent")return e;var t=Tc(e);return Pl(ko({},t,{saturation:sg(0,1,t.saturation-parseFloat(i))}))}var BK=pa(lX),OK=null;function o1(i){if(i==="transparent")return 0;var e=zu(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 dL(i,e){var t=o1(i),n=o1(e);return parseFloat((t>n?(t+.05)/(n+.05):(n+.05)/(t+.05)).toFixed(2))}function UK(i){return i==="transparent"?i:Pl(_extends({},Tc(i),{saturation:0}))}function kK(i){if(typeof i=="object"&&typeof i.hue=="number"&&typeof i.saturation=="number"&&typeof i.lightness=="number")return i.alpha&&typeof i.alpha=="number"?uL({hue:i.hue,saturation:i.saturation,lightness:i.lightness,alpha:i.alpha}):cL({hue:i.hue,saturation:i.saturation,lightness:i.lightness});throw new bn(45)}function zK(i){if(i==="transparent")return i;var e=zu(i);return Pl(_extends({},e,{red:255-e.red,green:255-e.green,blue:255-e.blue}))}function cX(i,e){if(e==="transparent")return e;var t=Tc(e);return Pl(ko({},t,{lightness:sg(0,1,t.lightness+parseFloat(i))}))}var VK=pa(cX),GK=null;function HK(i,e){var t=dL(i,e);return{AA:t>=4.5,AALarge:t>=3,AAA:t>=7,AAALarge:t>=4.5}}function uX(i,e,t){if(e==="transparent")return t;if(t==="transparent")return e;if(i===0)return t;var n=zu(e),r=ko({},n,{alpha:typeof n.alpha=="number"?n.alpha:1}),o=zu(t),a=ko({},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 $_(x)}var hX=pa(uX),fL=hX;function dX(i,e){if(e==="transparent")return e;var t=zu(e),n=typeof t.alpha=="number"?t.alpha:1,r=ko({},t,{alpha:sg(0,1,(n*100+parseFloat(i)*100)/100)});return $_(r)}var fX=pa(dX),pX=fX,pL="#000",mL="#fff";function WK(i,e,t,n){e===void 0&&(e=pL),t===void 0&&(t=mL),n===void 0&&(n=!0);var r=o1(i)>.179,o=r?e:t;return!n||dL(i,o)>=4.5?o:r?pL:mL}function $K(i){if(typeof i=="object"&&typeof i.red=="number"&&typeof i.green=="number"&&typeof i.blue=="number")return typeof i.alpha=="number"?$_({red:i.red,green:i.green,blue:i.blue,alpha:i.alpha}):Qv({red:i.red,green:i.green,blue:i.blue});throw new bn(46)}function mX(i,e){if(e==="transparent")return e;var t=Tc(e);return Pl(ko({},t,{saturation:sg(0,1,t.saturation+parseFloat(i))}))}var qK=pa(mX),XK=null;function gX(i,e){return e==="transparent"?e:Pl(ko({},Tc(e),{hue:parseFloat(i)}))}var jK=pa(gX),YK=null;function yX(i,e){return e==="transparent"?e:Pl(ko({},Tc(e),{lightness:parseFloat(i)}))}var ZK=pa(yX),KK=null;function _X(i,e){return e==="transparent"?e:Pl(ko({},Tc(e),{saturation:parseFloat(i)}))}var JK=pa(_X),QK=null;function xX(i,e){return e==="transparent"?e:fL(parseFloat(i),"rgb(0, 0, 0)",e)}var eJ=pa(xX),tJ=null;function vX(i,e){return e==="transparent"?e:fL(parseFloat(i),"rgb(255, 255, 255)",e)}var nJ=pa(vX),iJ=null;function bX(i,e){if(e==="transparent")return e;var t=zu(e),n=typeof t.alpha=="number"?t.alpha:1,r=ko({},t,{alpha:sg(0,1,+(n*100-parseFloat(i)*100).toFixed(2)/100)});return $_(r)}var sJ=pa(bX),rJ=null;function oJ(){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 bn(64);var r=e.map(function(o){if(n&&!Array.isArray(o)||!n&&Array.isArray(o))throw new bn(65);if(Array.isArray(o)&&o.length>8)throw new bn(66);return Array.isArray(o)?o.join(" "):o}).join(", ");return{animation:r}}function aJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return{backgroundImage:e.join(", ")}}function lJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return{background:e.join(", ")}}var SX=null;function cJ(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"&&SX.indexOf(i)>=0){var r;return r={},r["border"+H_(i)+"Width"]=t[0],r["border"+H_(i)+"Style"]=t[1],r["border"+H_(i)+"Color"]=t[2],r}else return t.unshift(i),{borderWidth:t[0],borderStyle:t[1],borderColor:t[2]}}function uJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return ap.apply(void 0,["borderColor"].concat(e))}function hJ(i,e){var t=H_(i);if(!e&&e!==0)throw new bn(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 bn(63)}function dJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return ap.apply(void 0,["borderStyle"].concat(e))}function fJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return ap.apply(void 0,["borderWidth"].concat(e))}function gL(i,e){var t=e?":"+e:"";return i(t)}function yL(i,e,t){if(!e)throw new bn(67);if(i.length===0)return gL(e,null);for(var n=[],r=0;r<i.length;r+=1){if(t&&t.indexOf(i[r])<0)throw new bn(68);n.push(gL(e,i[r]))}return n=n.join(","),n}var TX=null;function wX(i){return"button"+i+`,
|
|
input[type="button"]`+i+`,
|
|
input[type="reset"]`+i+`,
|
|
input[type="submit"]`+i}function pJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return yL(e,wX,TX)}function mJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return ap.apply(void 0,["margin"].concat(e))}function gJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return ap.apply(void 0,["padding"].concat(e))}var MX=null;function yJ(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 MX.indexOf(i)>=0&&i?_extends({},ap.apply(void 0,[""].concat(t)),{position:i}):ap.apply(void 0,["",i].concat(t))}function _J(i,e){return e===void 0&&(e=i),{height:i,width:e}}var AX=null;function EX(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 xJ(){for(var i=arguments.length,e=new Array(i),t=0;t<i;t++)e[t]=arguments[t];return yL(e,EX,AX)}function vJ(){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 bn(61);var r=e[0].map(function(o){return o+" "+n}).join(", ");return{transition:r}}else return{transition:e.join(", ")}}var vd=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-vd.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?vd.Bounce.In(i*2)*.5:vd.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}}}}),rg=function(){return performance.now()},a1=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=rg()),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}(),cp={Linear:function(i,e){var t=i.length-1,n=t*e,r=Math.floor(n),o=cp.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=cp.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=cp.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=cp.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}}},l1=function(){function i(){}return i.nextId=function(){return i._nextId++},i._nextId=0,i}(),c1=new a1,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=vd.Linear.None,this._interpolationFunction=cp.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=l1.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=c1,c1.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=rg()),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 M=this._handleRelativeValue(c,m[x]);if(isNaN(M)){p=!1,console.warn("Found invalid interpolation list. Skipping.");break}y.push(M)}p&&(n[a]=y)}if((d==="object"||u)&&c&&!p){t[a]=u?[]:{};var T=c;for(var S in T)t[a][S]=T[S];r[a]=u?[]:{};var m=n[a];if(!this._isDynamic){var N={};for(var S in m)N[S]=m[S];n[a]=m=N}this._setupProperties(T,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=rg()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this)},i.prototype.resume=function(e){return e===void 0&&(e=rg()),!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=vd.Linear.None),this._easingFunction=e,this},i.prototype.interpolation=function(e){return e===void 0&&(e=cp.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=rg()),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 M=Math.trunc(a/c),T=a-M*c,S=Math.min(T/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}(),CX="25.0.0",RX=l1.nextId,wc=c1,NX=wc.getAll.bind(wc),PX=wc.removeAll.bind(wc),IX=wc.add.bind(wc),LX=wc.remove.bind(wc),DX=wc.update.bind(wc),bJ={Easing:vd,Group:a1,Interpolation:cp,now:rg,Sequence:l1,nextId:RX,Tween:u1,VERSION:CX,getAll:NX,removeAll:PX,add:IX,remove:LX,update:DX};function FX(){}function _L(i){return i==null?FX:function(){return this.querySelector(i)}}function BX(i){typeof i!="function"&&(i=_L(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 OX(i){return i==null?[]:Array.isArray(i)?i:Array.from(i)}function UX(){return[]}function kX(i){return i==null?UX:function(){return this.querySelectorAll(i)}}function zX(i){return function(){return OX(i.apply(this,arguments))}}function VX(i){typeof i=="function"?i=zX(i):i=kX(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 GX(i){return function(){return this.matches(i)}}function xL(i){return function(e){return e.matches(i)}}var HX=Array.prototype.find;function WX(i){return function(){return HX.call(this.children,i)}}function $X(){return this.firstElementChild}function qX(i){return this.select(i==null?$X:WX(typeof i=="function"?i:xL(i)))}var XX=Array.prototype.filter;function jX(){return Array.from(this.children)}function YX(i){return function(){return XX.call(this.children,i)}}function ZX(i){return this.selectAll(i==null?jX:YX(typeof i=="function"?i:xL(i)))}function KX(i){typeof i!="function"&&(i=GX(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 vL(i){return new Array(i.length)}function JX(){return new ma(this._enter||this._groups.map(vL),this._parents)}function eb(i,e){this.ownerDocument=i.ownerDocument,this.namespaceURI=i.namespaceURI,this._next=null,this._parent=i,this.__data__=e}eb.prototype={constructor:eb,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 QX(i){return function(){return i}}function e7(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 eb(i,o[a]);for(;a<u;++a)(c=e[a])&&(r[a]=c)}function t7(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 eb(i,o[c]);for(c=0;c<p;++c)(u=e[c])&&d.get(y[c])===u&&(r[c]=u)}function n7(i){return i.__data__}function i7(i,e){if(!arguments.length)return Array.from(this,n7);var t=e?t7:e7,n=this._parents,r=this._groups;typeof i!="function"&&(i=QX(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=s7(i.call(p,p&&p.__data__,d,n)),v=x.length,M=c[d]=new Array(v),T=a[d]=new Array(v),S=u[d]=new Array(y);t(p,m,M,T,S,x,e);for(var N=0,R=0,P,B;N<v;++N)if(P=M[N]){for(N>=R&&(R=N+1);!(B=T[R])&&++R<v;);P._next=B||null}}return a=new ma(a,n),a._enter=c,a._exit=u,a}function s7(i){return typeof i=="object"&&"length"in i?i:Array.from(i)}function r7(){return new ma(this._exit||this._groups.map(vL),this._parents)}function o7(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 a7(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 l7(){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 c7(i){i||(i=u7);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 u7(i,e){return i<e?-1:i>e?1:i>=e?0:NaN}function h7(){var i=arguments[0];return arguments[0]=this,i.apply(null,arguments),this}function d7(){return Array.from(this)}function f7(){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 p7(){let i=0;for(const e of this)++i;return i}function m7(){return!this.node()}function g7(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 h1="http://www.w3.org/1999/xhtml",bL={svg:"http://www.w3.org/2000/svg",xhtml:h1,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function SL(i){var e=i+="",t=e.indexOf(":");return t>=0&&(e=i.slice(0,t))!=="xmlns"&&(i=i.slice(t+1)),bL.hasOwnProperty(e)?{space:bL[e],local:i}:i}function y7(i){return function(){this.removeAttribute(i)}}function _7(i){return function(){this.removeAttributeNS(i.space,i.local)}}function x7(i,e){return function(){this.setAttribute(i,e)}}function v7(i,e){return function(){this.setAttributeNS(i.space,i.local,e)}}function b7(i,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(i):this.setAttribute(i,t)}}function S7(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 T7(i,e){var t=SL(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?_7:y7:typeof e=="function"?t.local?S7:b7:t.local?v7:x7)(t,e))}function TL(i){return i.ownerDocument&&i.ownerDocument.defaultView||i.document&&i||i.defaultView}function w7(i){return function(){this.style.removeProperty(i)}}function M7(i,e,t){return function(){this.style.setProperty(i,e,t)}}function A7(i,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(i):this.style.setProperty(i,n,t)}}function E7(i,e,t){return arguments.length>1?this.each((e==null?w7:typeof e=="function"?A7:M7)(i,e,t==null?"":t)):C7(this.node(),i)}function C7(i,e){return i.style.getPropertyValue(e)||TL(i).getComputedStyle(i,null).getPropertyValue(e)}function R7(i){return function(){delete this[i]}}function N7(i,e){return function(){this[i]=e}}function P7(i,e){return function(){var t=e.apply(this,arguments);t==null?delete this[i]:this[i]=t}}function I7(i,e){return arguments.length>1?this.each((e==null?R7:typeof e=="function"?P7:N7)(i,e)):this.node()[i]}function wL(i){return i.trim().split(/^|\s+/)}function d1(i){return i.classList||new ML(i)}function ML(i){this._node=i,this._names=wL(i.getAttribute("class")||"")}ML.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 AL(i,e){for(var t=d1(i),n=-1,r=e.length;++n<r;)t.add(e[n])}function EL(i,e){for(var t=d1(i),n=-1,r=e.length;++n<r;)t.remove(e[n])}function L7(i){return function(){AL(this,i)}}function D7(i){return function(){EL(this,i)}}function F7(i,e){return function(){(e.apply(this,arguments)?AL:EL)(this,i)}}function B7(i,e){var t=wL(i+"");if(arguments.length<2){for(var n=d1(this.node()),r=-1,o=t.length;++r<o;)if(!n.contains(t[r]))return!1;return!0}return this.each((typeof e=="function"?F7:e?L7:D7)(t,e))}function O7(){this.textContent=""}function U7(i){return function(){this.textContent=i}}function k7(i){return function(){var e=i.apply(this,arguments);this.textContent=e==null?"":e}}function z7(i){return arguments.length?this.each(i==null?O7:(typeof i=="function"?k7:U7)(i)):this.node().textContent}function V7(){this.innerHTML=""}function G7(i){return function(){this.innerHTML=i}}function H7(i){return function(){var e=i.apply(this,arguments);this.innerHTML=e==null?"":e}}function W7(i){return arguments.length?this.each(i==null?V7:(typeof i=="function"?H7:G7)(i)):this.node().innerHTML}function $7(){this.nextSibling&&this.parentNode.appendChild(this)}function q7(){return this.each($7)}function X7(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function j7(){return this.each(X7)}function Y7(i){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===h1&&e.documentElement.namespaceURI===h1?e.createElement(i):e.createElementNS(t,i)}}function Z7(i){return function(){return this.ownerDocument.createElementNS(i.space,i.local)}}function CL(i){var e=SL(i);return(e.local?Z7:Y7)(e)}function K7(i){var e=typeof i=="function"?i:CL(i);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function J7(){return null}function Q7(i,e){var t=typeof i=="function"?i:CL(i),n=e==null?J7:typeof e=="function"?e:_L(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})}function ej(){var i=this.parentNode;i&&i.removeChild(this)}function tj(){return this.each(ej)}function nj(){var i=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(i,this.nextSibling):i}function ij(){var i=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(i,this.nextSibling):i}function sj(i){return this.select(i?ij:nj)}function rj(i){return arguments.length?this.property("__data__",i):this.node().__data__}function oj(i){return function(e){i.call(this,e,this.__data__)}}function aj(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 lj(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 cj(i,e,t){return function(){var n=this.__on,r,o=oj(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 uj(i,e,t){var n=aj(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?cj:lj,r=0;r<o;++r)this.each(c(n[r],e,t));return this}function RL(i,e,t){var n=TL(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 RL(this,i,e)}}function dj(i,e){return function(){return RL(this,i,e.apply(this,arguments))}}function fj(i,e){return this.each((typeof e=="function"?dj:hj)(i,e))}function*pj(){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 NL=[null];function ma(i,e){this._groups=i,this._parents=e}function mj(){return new ma([[document.documentElement]],NL)}function gj(){return this}ma.prototype=mj.prototype={constructor:ma,select:BX,selectAll:VX,selectChild:qX,selectChildren:ZX,filter:KX,data:i7,enter:JX,exit:r7,join:o7,merge:a7,selection:gj,order:l7,sort:c7,call:h7,nodes:d7,node:f7,size:p7,empty:m7,each:g7,attr:T7,style:E7,property:I7,classed:B7,text:z7,html:W7,raise:q7,lower:j7,append:K7,insert:Q7,remove:tj,clone:sj,datum:rj,on:uj,dispatch:fj,[Symbol.iterator]:pj};var SJ=null;function yj(i){return typeof i=="string"?new ma([[document.querySelector(i)]],[document.documentElement]):new ma([[i]],NL)}function _j(i){let e;for(;e=i.sourceEvent;)i=e;return i}function xj(i,e){if(i=_j(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 q_,cs,PL,IL,up,LL,DL,FL,BL,f1,p1,m1,OL,X_={},UL=[],vj=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,j_=Array.isArray;function Mc(i,e){for(var t in e)i[t]=e[t];return i}function g1(i){i&&i.parentNode&&i.parentNode.removeChild(i)}function bj(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?q_.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 Y_(i,a,n,r,null)}function Y_(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?++PL:r,__i:-1,__u:0};return r==null&&cs.vnode!=null&&cs.vnode(o),o}function TJ(){return{current:null}}function tb(i){return i.children}function nb(i,e){this.props=i,this.context=e}function og(i,e){if(e==null)return i.__?og(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"?og(i):null}function kL(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 kL(i)}}function y1(i){(!i.__d&&(i.__d=!0)&&up.push(i)&&!ib.__r++||LL!=cs.debounceRendering)&&((LL=cs.debounceRendering)||DL)(ib)}function ib(){for(var i,e,t,n,r,o,a,c=1;up.length;)up.length>c&&up.sort(FL),i=up.shift(),c=up.length,i.__d&&(t=void 0,n=void 0,r=(n=(e=i).__v).__e,o=[],a=[],e.__P&&((t=Mc({},n)).__v=n.__v+1,cs.vnode&&cs.vnode(t),_1(e.__P,t,n,e.__n,e.__P.namespaceURI,32&n.__u?[r]:null,o,r==null?og(n):r,!!(32&n.__u),a),t.__v=n.__v,t.__.__k[t.__i]=t,WL(o,t,a),n.__e=n.__=null,t.__e!=r&&kL(t)));ib.__r=0}function zL(i,e,t,n,r,o,a,c,u,d,p){var m,y,x,v,M,T,S,N=n&&n.__k||UL,R=e.length;for(u=Sj(t,e,N,u,R),m=0;m<R;m++)(x=t.__k[m])!=null&&(y=x.__i==-1?X_:N[x.__i]||X_,x.__i=m,T=_1(i,x,y,r,o,a,c,u,d,p),v=x.__e,x.ref&&y.ref!=x.ref&&(y.ref&&v1(y.ref,null,x),p.push(x.ref,x.__c||v,x)),M==null&&v!=null&&(M=v),(S=!!(4&x.__u))||y.__k===x.__k?u=VL(x,u,i,S):typeof x.type=="function"&&T!==void 0?u=T:v&&(u=v.nextSibling),x.__u&=-7);return t.__e=M,u}function Sj(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"?(u=o+y,(a=i.__k[o]=typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?Y_(null,a,null,null,null):j_(a)?Y_(tb,{children:a},null,null,null):a.constructor==null&&a.__b>0?Y_(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):a).__=i,a.__b=i.__b+1,c=null,(d=a.__i=wj(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=og(c)),qL(c,c));return n}function VL(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=VL(r[o],e,t,n));return e}i.__e!=e&&(n&&(e&&i.type&&!e.parentNode&&(e=og(i)),t.insertBefore(i.__e,e||null)),e=i.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function Tj(i,e){return e=e||[],i==null||typeof i=="boolean"||(j_(i)?i.some(function(t){Tj(t,e)}):e.push(i)),e}function wj(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&&i.key==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 GL(i,e,t){e[0]=="-"?i.setProperty(e,t==null?"":t):i[e]=t==null?"":typeof t!="number"||vj.test(e)?t:t+"px"}function sb(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||GL(i.style,e,"");if(t)for(e in t)n&&t[e]==n[e]||GL(i.style,e,t[e])}else if(e[0]=="o"&&e[1]=="n")o=e!=(e=e.replace(BL,"$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=f1,i.addEventListener(e,o?m1:p1,o)):i.removeEventListener(e,o?m1:p1,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 HL(i){return function(e){if(this.l){var t=this.l[e.type+i];if(e.t==null)e.t=f1++;else if(e.t<t.u)return;return t(cs.event?cs.event(e):e)}}}function _1(i,e,t,n,r,o,a,c,u,d){var p,m,y,x,v,M,T,S,N,R,P,B,F,k,V,U,z,j=e.type;if(e.constructor!=null)return null;128&t.__u&&(u=!!(32&t.__u),o=[c=e.__e=t.__e]),(p=cs.__b)&&p(e);e:if(typeof j=="function")try{if(S=e.props,N="prototype"in j&&j.prototype.render,R=(p=j.contextType)&&n[p.__c],P=p?R?R.props.value:p.__:n,t.__c?T=(m=e.__c=t.__c).__=m.__E:(N?e.__c=m=new j(S,P):(e.__c=m=new nb(S,P),m.constructor=j,m.render=Aj),R&&R.sub(m),m.props=S,m.state||(m.state={}),m.context=P,m.__n=n,y=m.__d=!0,m.__h=[],m._sb=[]),N&&m.__s==null&&(m.__s=m.state),N&&j.getDerivedStateFromProps!=null&&(m.__s==m.state&&(m.__s=Mc({},m.__s)),Mc(m.__s,j.getDerivedStateFromProps(S,m.__s))),x=m.props,v=m.state,m.__v=e,y)N&&j.getDerivedStateFromProps==null&&m.componentWillMount!=null&&m.componentWillMount(),N&&m.componentDidMount!=null&&m.__h.push(m.componentDidMount);else{if(N&&j.getDerivedStateFromProps==null&&S!==x&&m.componentWillReceiveProps!=null&&m.componentWillReceiveProps(S,P),!m.__e&&m.shouldComponentUpdate!=null&&m.shouldComponentUpdate(S,m.__s,P)===!1||e.__v==t.__v){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(se){se&&(se.__=e)}),B=0;B<m._sb.length;B++)m.__h.push(m._sb[B]);m._sb=[],m.__h.length&&a.push(m);break e}m.componentWillUpdate!=null&&m.componentWillUpdate(S,m.__s,P),N&&m.componentDidUpdate!=null&&m.__h.push(function(){m.componentDidUpdate(x,v,M)})}if(m.context=P,m.props=S,m.__P=i,m.__e=!1,F=cs.__r,k=0,N){for(m.state=m.__s,m.__d=!1,F&&F(e),p=m.render(m.props,m.state,m.context),V=0;V<m._sb.length;V++)m.__h.push(m._sb[V]);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=Mc(Mc({},n),m.getChildContext())),N&&!y&&m.getSnapshotBeforeUpdate!=null&&(M=m.getSnapshotBeforeUpdate(x,v)),U=p,p!=null&&p.type===tb&&p.key==null&&(U=$L(p.props.children)),c=zL(i,j_(U)?U:[U],e,t,n,r,o,a,c,u,d),m.base=e.__e,e.__u&=-161,m.__h.length&&a.push(m),T&&(m.__E=m.__=null)}catch(se){if(e.__v=null,u||o!=null)if(se.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--;)g1(o[z]);x1(e)}else e.__e=t.__e,e.__k=t.__k,se.then||x1(e);cs.__e(se,e,t)}else o==null&&e.__v==t.__v?(e.__k=t.__k,e.__e=t.__e):c=e.__e=Mj(t.__e,e,t,n,r,o,a,u,d);return(p=cs.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 WL(i,e,t){for(var n=0;n<t.length;n++)v1(t[n],t[++n],t[++n]);cs.__c&&cs.__c(e,i),i.some(function(r){try{i=r.__h,r.__h=[],i.some(function(o){o.call(r)})}catch(o){cs.__e(o,r.__v)}})}function $L(i){return typeof i!="object"||i==null||i.__b&&i.__b>0?i:j_(i)?i.map($L):Mc({},i)}function Mj(i,e,t,n,r,o,a,c,u){var d,p,m,y,x,v,M,T=t.props,S=e.props,N=e.type;if(N=="svg"?r="http://www.w3.org/2000/svg":N=="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==!!N&&(N?x.localName==N:x.nodeType==3)){i=x,o[d]=null;break}}if(i==null){if(N==null)return document.createTextNode(S);i=document.createElementNS(r,N,S.is&&S),c&&(cs.__m&&cs.__m(e,o),c=!1),o=null}if(N==null)T===S||c&&i.data==S||(i.data=S);else{if(o=o&&q_.call(i.childNodes),T=t.props||X_,!c&&o!=null)for(T={},d=0;d<i.attributes.length;d++)T[(x=i.attributes[d]).name]=x.value;for(d in T)if(x=T[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;sb(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"?M=x:c&&typeof x!="function"||T[d]===x||sb(i,d,x,T[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=""),zL(e.type=="template"?i.content:i,j_(y)?y:[y],e,t,n,N=="foreignObject"?"http://www.w3.org/1999/xhtml":r,o,a,o?o[0]:t.__k&&og(t,0),c,u),o!=null)for(d=o.length;d--;)g1(o[d]);c||(d="value",N=="progress"&&v==null?i.removeAttribute("value"):v!=null&&(v!==i[d]||N=="progress"&&!v||N=="option"&&v!=T[d])&&sb(i,d,v,T[d],r),d="checked",M!=null&&M!=i[d]&&sb(i,d,M,T[d],r))}return i}function v1(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){cs.__e(r,t)}}function qL(i,e,t){var n,r;if(cs.unmount&&cs.unmount(i),(n=i.ref)&&(n.current&&n.current!=i.__e||v1(n,null,e)),(n=i.__c)!=null){if(n.componentWillUnmount)try{n.componentWillUnmount()}catch(o){cs.__e(o,e)}n.base=n.__P=null}if(n=i.__k)for(r=0;r<n.length;r++)n[r]&&qL(n[r],e,t||typeof i.type!="function");t||g1(i.__e),i.__c=i.__=i.__e=void 0}function Aj(i,e,t){return this.constructor(i,t)}function XL(i,e,t){var n,r,o,a;e==document&&(e=document.documentElement),cs.__&&cs.__(i,e),r=(n=typeof t=="function")?null:t&&t.__k||e.__k,o=[],a=[],_1(e,i=(!n&&t||e).__k=bj(tb,null,[i]),r||X_,X_,e.namespaceURI,!n&&t?[t]:r?null:e.firstChild?q_.call(e.childNodes):null,o,!n&&t?t:r?r.__e:e.firstChild,n,a),WL(o,i,a)}function Ej(i,e){XL(i,e,Ej)}function jL(i,e,t){var n,r,o,a,c=Mc({},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?q_.call(arguments,2):t),Y_(i.type,c,n||i.key,r||i.ref,null)}function wJ(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,y1(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"+OL++,e.__=i,e.Provider=e.__l=(e.Consumer=function(t,n){return t.children(n)}).contextType=e,e}q_=UL.slice,cs={__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}},PL=0,IL=function(i){return i!=null&&i.constructor==null},nb.prototype.setState=function(i,e){var t;t=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=Mc({},this.state),typeof i=="function"&&(i=i(Mc({},t),this.props)),i&&Mc(t,i),i!=null&&this.__v&&(e&&this._sb.push(e),y1(this))},nb.prototype.forceUpdate=function(i){this.__v&&(this.__e=!0,i&&this.__h.push(i),y1(this))},nb.prototype.render=tb,up=[],DL=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,FL=function(i,e){return i.__v.__b-e.__v.__b},ib.__r=0,BL=/(PointerCapture)$|Capture$/i,f1=0,p1=HL(!1),m1=HL(!0),OL=0;function YL(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 Cj(i){if(Array.isArray(i))return i}function Rj(i,e,t){return(e=Fj(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Nj(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 Pj(){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 ZL(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 Ij(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ZL(Object(t),!0).forEach(function(n){Rj(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):ZL(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function Lj(i,e){return Cj(i)||Nj(i,e)||Bj(i,e)||Pj()}function Dj(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 Fj(i){var e=Dj(i,"string");return typeof e=="symbol"?e:e+""}function rb(i){"@babel/helpers - typeof";return rb=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},rb(i)}function Bj(i,e){if(i){if(typeof i=="string")return YL(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)?YL(i,e):void 0}}var b1=function(e){if(rb(e)!=="object")return e;var t=jL(e);if(t.props){var n;t.props=Ij({},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(b1):b1(t.props.children))}return t},Oj=function(e){return IL(jL(e))},Uj=function(e,t){delete t.__k,XL(b1(e),t)};function kj(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 zj=`.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;
|
|
}
|
|
`;kj(zj);var Vj=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&&rb(e)==="object"&&!!e.node&&typeof e.node=="function",c=yj(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=Lj(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=xj(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):Oj(e.content)?(e.tooltipEl.text(""),Uj(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 Gj(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 Hj=`.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;
|
|
}`;Gj(Hj);function S1(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 Wj(i){if(Array.isArray(i))return i}function $j(i){if(Array.isArray(i))return S1(i)}function qj(i,e,t){return(e=Qj(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Xj(i){if(typeof Symbol!="undefined"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function jj(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 Yj(){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 Zj(){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 Kj(i,e){return Wj(i)||jj(i,e)||KL(i,e)||Yj()}function hp(i){return $j(i)||Xj(i)||KL(i)||Zj()}function Jj(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 Qj(i){var e=Jj(i,"string");return typeof e=="symbol"?e:e+""}function KL(i,e){if(i){if(typeof i=="string")return S1(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)?S1(i,e):void 0}}var us=window.THREE?window.THREE:{WebGLRenderer:Jk,Scene:Bp,PerspectiveCamera:ps,Raycaster:Ty,SRGBColorSpace:Ei,TextureLoader:J1,Vector2:Ie,Vector3:W,Box3:dr,Color:At,Mesh:vi,SphereGeometry:gl,MeshBasicMaterial:js,BackSide:Ee,Clock:J0},JL=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&&ii(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(vd.Quadratic.Out).onUpdate(p).start()),e.tweenGroup.add(new u1(d).to(c,r/3).easing(vd.Quadratic.Out).onUpdate(m).start())}return this}return Object.assign({},o.position,{lookAt:y()});function p(x){var v=x.x,M=x.y,T=x.z;v!==void 0&&(o.position.x=v),M!==void 0&&(o.position.y=M),T!==void 0&&(o.position.z=T)}function m(x){var v=new us.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 us.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 us.Vector3(0,0,0),c=Math.max.apply(Math,hp(Object.entries(t).map(function(x){var v=Kj(x,2),M=v[0],T=v[1];return Math.max.apply(Math,hp(T.map(function(S){return Math.abs(a[M]-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 us.Box3(new us.Vector3(0,0,0),new us.Vector3(0,0,0)),r=e.objects.filter(t);return r.length?(r.forEach(function(o){return n.expandByObject(o)}),Object.assign.apply(Object,hp(["x","y","z"].map(function(o){return qj({},o,[n.min[o],n.max[o]])})))):null},getScreenCoords:function(e,t,n,r){var o=new us.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 us.Vector2(t/e.width*2-1,-(n/e.height)*2+1),a=new us.Raycaster;return a.setFromCamera(o,e.camera),Object.assign({},a.ray.at(r,new us.Vector3))},intersectingObjects:function(e,t,n){var r=new us.Vector2(t/e.width*2-1,-(n/e.height)*2+1),o=new us.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 us.Scene,camera:new us.PerspectiveCamera,clock:new us.Clock,tweenGroup:new a1,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 Vj(t.container),t.pointerPos=new us.Vector2,t.pointerPos.x=-2,t.pointerPos.y=-2,["pointermove","pointerdown"].forEach(function(v){return t.container.addEventListener(v,function(M){if(v==="pointerdown"&&(t.isPointerPressed=!0),!t.isPointerDragging&&M.type==="pointermove"&&(M.pressure>0||t.isPointerPressed)&&(M.pointerType==="mouse"||M.movementX===void 0||[M.movementX,M.movementY].some(function(N){return Math.abs(N)>1}))&&(t.isPointerDragging=!0),t.enablePointerInteraction){var T=S(t.container);t.pointerPos.x=M.pageX-T.left,t.pointerPos.y=M.pageY-T.top}function S(N){var R=N.getBoundingClientRect(),P=window.pageXOffset||document.documentElement.scrollLeft,B=window.pageYOffset||document.documentElement.scrollTop;return{top:R.top+B,left:R.left+P}}},{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?aq:us.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 n9(t.renderer),t.postProcessingComposer.addPass(new i9(t.scene,t.camera)),t.controls=new{trackball:hq,orbit:Eq,fly:Vq}[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(hp(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 us.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(hp(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(hp(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(hp(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 us.SphereGeometry(e.skyRadius)),t.hasOwnProperty("backgroundColor")){var m=zu(e.backgroundColor).alpha;m===void 0&&(m=1),e.renderer.setClearColor(new us.Color(pX(1,e.backgroundColor)),m)}t.hasOwnProperty("backgroundImageUrl")&&(e.backgroundImageUrl?new us.TextureLoader().load(e.backgroundImageUrl,function(x){x.colorSpace=us.SRGBColorSpace,e.skysphere.material=new us.MeshBasicMaterial({map:x,side:us.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 eY(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 tY=`.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;
|
|
}`;eY(tY);function T1(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 nY(i){if(Array.isArray(i))return T1(i)}function Z_(i,e,t){return(e=oY(e))in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function iY(i){if(typeof Symbol!="undefined"&&i[Symbol.iterator]!=null||i["@@iterator"]!=null)return Array.from(i)}function sY(){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 QL(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 ob(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?QL(Object(t),!0).forEach(function(n){Z_(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):QL(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function ab(i){return nY(i)||iY(i)||aY(i)||sY()}function rY(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 oY(i){var e=rY(i,"string");return typeof e=="symbol"?e:e+""}function aY(i,e){if(i){if(typeof i=="string")return T1(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)?T1(i,e):void 0}}function eD(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 w1=window.THREE?window.THREE:{AmbientLight:Mf,DirectionalLight:_u,REVISION:_e},lY=170,tD=eD("forceGraph",eE),cY=Object.assign.apply(Object,ab(["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 Z_({},i,tD.linkProp(i))}))),uY=Object.assign.apply(Object,ab(["refresh","getGraphBbox","d3Force","d3ReheatSimulation","emitParticle"].map(function(i){return Z_({},i,tD.linkMethod(i))}))),lb=eD("renderObjs",JL),hY=Object.assign.apply(Object,ab(["width","height","backgroundColor","showNavInfo","enablePointerInteraction"].map(function(i){return Z_({},i,lb.linkProp(i))}))),dY=Object.assign.apply(Object,ab(["lights","cameraPosition","postProcessingComposer"].map(function(i){return Z_({},i,lb.linkMethod(i))})).concat([{graph2ScreenCoords:lb.linkMethod("getScreenCoords"),screen2GraphCoords:lb.linkMethod("getSceneCoords")}])),fY=gx({props:ob(ob({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}},cY),hY),methods:ob(ob({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:[]})}},uY),dY),stateInit:function(e){var t=e.controlType,n=e.rendererConfig,r=e.extraRenderers,o=new eE;return{forceGraph:o,renderObjs:JL({controlType:t,rendererConfig:n,extraRenderers:r}).objects([o]).lights([new w1.AmbientLight(13421772,Math.PI),new w1.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)*lY)}).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 w(t.graphData.nodes.map(function(p){return p.__threeObj}).filter(function(p){return p}),r,o.domElement);d.addEventListener("dragstart",function(p){var m=Vu(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=Vu(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 M=m.__data,T=m.position,S={x:T.x-M.x,y:T.y-M.y,z:T.z-M.z};["x","y","z"].forEach(function(N){return M["f".concat(N)]=M[N]=T[N]}),t.forceGraph.d3AlphaTarget(.3).resetCountdown(),M.__dragged=!0,t.onNodeDrag(M,S)}}),d.addEventListener("dragend",function(p){var m=Vu(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,M={x:v.x-y.x,y:v.y-y.y,z:v.z-y.z};if(x&&(["x","y","z"].forEach(function(S){var N="f".concat(S);x[N]===void 0&&delete y[N]}),delete y.__initialFixedPos,delete y.__initialPos,y.__dragged&&(delete y.__dragged,t.onNodeDragEnd(y,M))),t.forceGraph.d3AlphaTarget(0).resetCountdown(),t.enableNavigationControls){var T;a.enabled=!0,a._status&&((T=a._onPointerCancel)===null||T===void 0||T.call(a)),a.domElement&&a.domElement.ownerDocument&&a.domElement.ownerDocument.dispatchEvent(new PointerEvent("pointerup",{pointerType:"touch"}))}o.domElement.classList.remove("grabbable")}})}}),w1.REVISION<155&&(t.renderObjs.renderer().useLegacyLights=!1),t.renderObjs.hoverOrderComparator(function(u,d){var p=Vu(u);if(!p)return 1;var m=Vu(d);if(!m)return-1;var y=function(v){return v.__graphObjType==="node"};return y(m)-y(p)}).tooltipContent(function(u){var d=Vu(u);return d&&ii(t["".concat(d.__graphObjType,"Label")])(d.__data)||""}).hoverDuringDrag(!1).onHover(function(u){var d=Vu(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 M=t["on".concat(y==="node"?"Node":"Link","Hover")];M&&M(x,p===y?m:null)}o.domElement.classList[(d&&t["on".concat(y==="node"?"Node":"Link","Click")]||!d&&t.onBackgroundClick)&&ii(t.showPointerCursor)(x)?"add":"remove"]("clickable"),t.hoverObj=d}}).clickAfterDrag(!1).onClick(function(u,d){var p=Vu(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=Vu(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 Vu(i){for(var e=i;e&&!e.hasOwnProperty("__graphObjType");)e=e.parent;return e}},51598:function(lt,Ze,he){"use strict";he.d(Ze,{H:function(){return fe},Z:function(){return _e}});function _e(X){const J=+this._x.call(null,X);return ye(this.cover(J),J,X)}function ye(X,J,oe){if(isNaN(J))return X;var te,me=X._root,Me={data:oe},Ne=X._x0,le=X._x1,Be,Ee,ke,Ae,qe;if(!me)return X._root=Me,X;for(;me.length;)if((ke=J>=(Be=(Ne+le)/2))?Ne=Be:le=Be,te=me,!(me=me[Ae=+ke]))return te[Ae]=Me,X;if(Ee=+X._x.call(null,me.data),J===Ee)return Me.next=me,te?te[Ae]=Me:X._root=Me,X;do te=te?te[Ae]=new Array(2):X._root=new Array(2),(ke=J>=(Be=(Ne+le)/2))?Ne=Be:le=Be;while((Ae=+ke)==(qe=+(Ee>=Be)));return te[qe]=me,te[Ae]=Me,X}function fe(X){Array.isArray(X)||(X=Array.from(X));const J=X.length,oe=new Float64Array(J);let te=1/0,me=-1/0;for(let Me=0,Ne;Me<J;++Me)isNaN(Ne=+this._x.call(null,X[Me]))||(oe[Me]=Ne,Ne<te&&(te=Ne),Ne>me&&(me=Ne));if(te>me)return this;this.cover(te).cover(me);for(let Me=0;Me<J;++Me)ye(this,oe[Me],X[Me]);return this}},20928:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return Be}});var _e=he(51598),ye=he(50654),fe=he(97164),X=he(7138),J=he(8779),oe=he(5115),te=he(42308),me=he(57670),Me=he(60972),Ne=he(46032),le=he(83402);function Be(qe,et){var rt=new Ee(et==null?le.P:et,NaN,NaN);return qe==null?rt:rt.addAll(qe)}function Ee(qe,et,rt){this._x=qe,this._x0=et,this._x1=rt,this._root=void 0}function ke(qe){for(var et={data:qe.data},rt=et;qe=qe.next;)rt=rt.next={data:qe.data};return et}var Ae=Be.prototype=Ee.prototype;Ae.copy=function(){var qe=new Ee(this._x,this._x0,this._x1),et=this._root,rt,at;if(!et)return qe;if(!et.length)return qe._root=ke(et),qe;for(rt=[{source:et,target:qe._root=new Array(2)}];et=rt.pop();)for(var St=0;St<2;++St)(at=et.source[St])&&(at.length?rt.push({source:at,target:et.target[St]=new Array(2)}):et.target[St]=ke(at));return qe},Ae.add=_e.Z,Ae.addAll=_e.H,Ae.cover=ye.Z,Ae.data=fe.Z,Ae.extent=X.Z,Ae.find=J.Z,Ae.remove=oe.Z,Ae.removeAll=oe.x,Ae.root=te.Z,Ae.size=me.Z,Ae.visit=Me.Z,Ae.visitAfter=Ne.Z,Ae.x=le.Z},50654:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return _e}});function _e(ye){if(isNaN(ye=+ye))return this;var fe=this._x0,X=this._x1;if(isNaN(fe))X=(fe=Math.floor(ye))+1;else{for(var J=X-fe||1,oe=this._root,te,me;fe>ye||ye>=X;)switch(me=+(ye<fe),te=new Array(2),te[me]=oe,oe=te,J*=2,me){case 0:X=fe+J;break;case 1:fe=X-J;break}this._root&&this._root.length&&(this._root=oe)}return this._x0=fe,this._x1=X,this}},97164:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return _e}});function _e(){var ye=[];return this.visit(function(fe){if(!fe.length)do ye.push(fe.data);while(fe=fe.next)}),ye}},7138:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return _e}});function _e(ye){return arguments.length?this.cover(+ye[0][0]).cover(+ye[1][0]):isNaN(this._x0)?void 0:[[this._x0],[this._x1]]}},8779:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return ye}});var _e=he(66519);function ye(fe,X){var J,oe=this._x0,te,me,Me=this._x1,Ne=[],le=this._root,Be,Ee;for(le&&Ne.push(new _e.Z(le,oe,Me)),X==null?X=1/0:(oe=fe-X,Me=fe+X);Be=Ne.pop();)if(!(!(le=Be.node)||(te=Be.x0)>Me||(me=Be.x1)<oe))if(le.length){var ke=(te+me)/2;Ne.push(new _e.Z(le[1],ke,me),new _e.Z(le[0],te,ke)),(Ee=+(fe>=ke))&&(Be=Ne[Ne.length-1],Ne[Ne.length-1]=Ne[Ne.length-1-Ee],Ne[Ne.length-1-Ee]=Be)}else{var Ae=Math.abs(fe-+this._x.call(null,le.data));Ae<X&&(X=Ae,oe=fe-Ae,Me=fe+Ae,J=le.data)}return J}},66519:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return _e}});function _e(ye,fe,X){this.node=ye,this.x0=fe,this.x1=X}},5115:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return _e},x:function(){return ye}});function _e(fe){if(isNaN(le=+this._x.call(null,fe)))return this;var X,J=this._root,oe,te,me,Me=this._x0,Ne=this._x1,le,Be,Ee,ke,Ae;if(!J)return this;if(J.length)for(;;){if((Ee=le>=(Be=(Me+Ne)/2))?Me=Be:Ne=Be,X=J,!(J=J[ke=+Ee]))return this;if(!J.length)break;X[ke+1&1]&&(oe=X,Ae=ke)}for(;J.data!==fe;)if(te=J,!(J=J.next))return this;return(me=J.next)&&delete J.next,te?(me?te.next=me:delete te.next,this):X?(me?X[ke]=me:delete X[ke],(J=X[0]||X[1])&&J===(X[1]||X[0])&&!J.length&&(oe?oe[Ae]=J:this._root=J),this):(this._root=me,this)}function ye(fe){for(var X=0,J=fe.length;X<J;++X)this.remove(fe[X]);return this}},42308:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return _e}});function _e(){return this._root}},57670:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return _e}});function _e(){var ye=0;return this.visit(function(fe){if(!fe.length)do++ye;while(fe=fe.next)}),ye}},60972:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return ye}});var _e=he(66519);function ye(fe){var X=[],J,oe=this._root,te,me,Me;for(oe&&X.push(new _e.Z(oe,this._x0,this._x1));J=X.pop();)if(!fe(oe=J.node,me=J.x0,Me=J.x1)&&oe.length){var Ne=(me+Me)/2;(te=oe[1])&&X.push(new _e.Z(te,Ne,Me)),(te=oe[0])&&X.push(new _e.Z(te,me,Ne))}return this}},46032:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return ye}});var _e=he(66519);function ye(fe){var X=[],J=[],oe;for(this._root&&X.push(new _e.Z(this._root,this._x0,this._x1));oe=X.pop();){var te=oe.node;if(te.length){var me,Me=oe.x0,Ne=oe.x1,le=(Me+Ne)/2;(me=te[0])&&X.push(new _e.Z(me,Me,le)),(me=te[1])&&X.push(new _e.Z(me,le,Ne))}J.push(oe)}for(;oe=J.pop();)fe(oe.node,oe.x0,oe.x1);return this}},83402:function(lt,Ze,he){"use strict";he.d(Ze,{P:function(){return _e},Z:function(){return ye}});function _e(fe){return fe[0]}function ye(fe){return arguments.length?(this._x=fe,this):this._x}},23473:function(lt,Ze,he){"use strict";he.d(Ze,{H:function(){return fe},Z:function(){return _e}});function _e(X){const J=+this._x.call(null,X),oe=+this._y.call(null,X),te=+this._z.call(null,X);return ye(this.cover(J,oe,te),J,oe,te,X)}function ye(X,J,oe,te,me){if(isNaN(J)||isNaN(oe)||isNaN(te))return X;var Me,Ne=X._root,le={data:me},Be=X._x0,Ee=X._y0,ke=X._z0,Ae=X._x1,qe=X._y1,et=X._z1,rt,at,St,Ot,Fn,os,Bn,ei,ni,bs,vr;if(!Ne)return X._root=le,X;for(;Ne.length;)if((Bn=J>=(rt=(Be+Ae)/2))?Be=rt:Ae=rt,(ei=oe>=(at=(Ee+qe)/2))?Ee=at:qe=at,(ni=te>=(St=(ke+et)/2))?ke=St:et=St,Me=Ne,!(Ne=Ne[bs=ni<<2|ei<<1|Bn]))return Me[bs]=le,X;if(Ot=+X._x.call(null,Ne.data),Fn=+X._y.call(null,Ne.data),os=+X._z.call(null,Ne.data),J===Ot&&oe===Fn&&te===os)return le.next=Ne,Me?Me[bs]=le:X._root=le,X;do Me=Me?Me[bs]=new Array(8):X._root=new Array(8),(Bn=J>=(rt=(Be+Ae)/2))?Be=rt:Ae=rt,(ei=oe>=(at=(Ee+qe)/2))?Ee=at:qe=at,(ni=te>=(St=(ke+et)/2))?ke=St:et=St;while((bs=ni<<2|ei<<1|Bn)===(vr=(os>=St)<<2|(Fn>=at)<<1|Ot>=rt));return Me[vr]=Ne,Me[bs]=le,X}function fe(X){Array.isArray(X)||(X=Array.from(X));const J=X.length,oe=new Float64Array(J),te=new Float64Array(J),me=new Float64Array(J);let Me=1/0,Ne=1/0,le=1/0,Be=-1/0,Ee=-1/0,ke=-1/0;for(let Ae=0,qe,et,rt,at;Ae<J;++Ae)isNaN(et=+this._x.call(null,qe=X[Ae]))||isNaN(rt=+this._y.call(null,qe))||isNaN(at=+this._z.call(null,qe))||(oe[Ae]=et,te[Ae]=rt,me[Ae]=at,et<Me&&(Me=et),et>Be&&(Be=et),rt<Ne&&(Ne=rt),rt>Ee&&(Ee=rt),at<le&&(le=at),at>ke&&(ke=at));if(Me>Be||Ne>Ee||le>ke)return this;this.cover(Me,Ne,le).cover(Be,Ee,ke);for(let Ae=0;Ae<J;++Ae)ye(this,oe[Ae],te[Ae],me[Ae],X[Ae]);return this}},55802:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return _e}});function _e(ye,fe,X){if(isNaN(ye=+ye)||isNaN(fe=+fe)||isNaN(X=+X))return this;var J=this._x0,oe=this._y0,te=this._z0,me=this._x1,Me=this._y1,Ne=this._z1;if(isNaN(J))me=(J=Math.floor(ye))+1,Me=(oe=Math.floor(fe))+1,Ne=(te=Math.floor(X))+1;else{for(var le=me-J||1,Be=this._root,Ee,ke;J>ye||ye>=me||oe>fe||fe>=Me||te>X||X>=Ne;)switch(ke=(X<te)<<2|(fe<oe)<<1|ye<J,Ee=new Array(8),Ee[ke]=Be,Be=Ee,le*=2,ke){case 0:me=J+le,Me=oe+le,Ne=te+le;break;case 1:J=me-le,Me=oe+le,Ne=te+le;break;case 2:me=J+le,oe=Me-le,Ne=te+le;break;case 3:J=me-le,oe=Me-le,Ne=te+le;break;case 4:me=J+le,Me=oe+le,te=Ne-le;break;case 5:J=me-le,Me=oe+le,te=Ne-le;break;case 6:me=J+le,oe=Me-le,te=Ne-le;break;case 7:J=me-le,oe=Me-le,te=Ne-le;break}this._root&&this._root.length&&(this._root=Be)}return this._x0=J,this._y0=oe,this._z0=te,this._x1=me,this._y1=Me,this._z1=Ne,this}},65587:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return _e}});function _e(){var ye=[];return this.visit(function(fe){if(!fe.length)do ye.push(fe.data);while(fe=fe.next)}),ye}},31756:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return _e}});function _e(ye){return arguments.length?this.cover(+ye[0][0],+ye[0][1],+ye[0][2]).cover(+ye[1][0],+ye[1][1],+ye[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]}},60444:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return ye}});var _e=he(14086);function ye(fe,X,J,oe){var te,me=this._x0,Me=this._y0,Ne=this._z0,le,Be,Ee,ke,Ae,qe,et=this._x1,rt=this._y1,at=this._z1,St=[],Ot=this._root,Fn,os;for(Ot&&St.push(new _e.Z(Ot,me,Me,Ne,et,rt,at)),oe==null?oe=1/0:(me=fe-oe,Me=X-oe,Ne=J-oe,et=fe+oe,rt=X+oe,at=J+oe,oe*=oe);Fn=St.pop();)if(!(!(Ot=Fn.node)||(le=Fn.x0)>et||(Be=Fn.y0)>rt||(Ee=Fn.z0)>at||(ke=Fn.x1)<me||(Ae=Fn.y1)<Me||(qe=Fn.z1)<Ne))if(Ot.length){var Bn=(le+ke)/2,ei=(Be+Ae)/2,ni=(Ee+qe)/2;St.push(new _e.Z(Ot[7],Bn,ei,ni,ke,Ae,qe),new _e.Z(Ot[6],le,ei,ni,Bn,Ae,qe),new _e.Z(Ot[5],Bn,Be,ni,ke,ei,qe),new _e.Z(Ot[4],le,Be,ni,Bn,ei,qe),new _e.Z(Ot[3],Bn,ei,Ee,ke,Ae,ni),new _e.Z(Ot[2],le,ei,Ee,Bn,Ae,ni),new _e.Z(Ot[1],Bn,Be,Ee,ke,ei,ni),new _e.Z(Ot[0],le,Be,Ee,Bn,ei,ni)),(os=(J>=ni)<<2|(X>=ei)<<1|fe>=Bn)&&(Fn=St[St.length-1],St[St.length-1]=St[St.length-1-os],St[St.length-1-os]=Fn)}else{var bs=fe-+this._x.call(null,Ot.data),vr=X-+this._y.call(null,Ot.data),Zr=J-+this._z.call(null,Ot.data),Kr=bs*bs+vr*vr+Zr*Zr;if(Kr<oe){var Ss=Math.sqrt(oe=Kr);me=fe-Ss,Me=X-Ss,Ne=J-Ss,et=fe+Ss,rt=X+Ss,at=J+Ss,te=Ot.data}}return te}},14086:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return _e}});function _e(ye,fe,X,J,oe,te,me){this.node=ye,this.x0=fe,this.y0=X,this.z0=J,this.x1=oe,this.y1=te,this.z1=me}},67217:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return ke}});var _e=he(23473),ye=he(55802),fe=he(65587),X=he(31756),J=he(60444),oe=he(44576),te=he(76077),me=he(53212),Me=he(56173),Ne=he(36427),le=he(79853),Be=he(79840),Ee=he(87325);function ke(rt,at,St,Ot){var Fn=new Ae(at==null?le.P:at,St==null?Be.q:St,Ot==null?Ee.i:Ot,NaN,NaN,NaN,NaN,NaN,NaN);return rt==null?Fn:Fn.addAll(rt)}function Ae(rt,at,St,Ot,Fn,os,Bn,ei,ni){this._x=rt,this._y=at,this._z=St,this._x0=Ot,this._y0=Fn,this._z0=os,this._x1=Bn,this._y1=ei,this._z1=ni,this._root=void 0}function qe(rt){for(var at={data:rt.data},St=at;rt=rt.next;)St=St.next={data:rt.data};return at}var et=ke.prototype=Ae.prototype;et.copy=function(){var rt=new Ae(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),at=this._root,St,Ot;if(!at)return rt;if(!at.length)return rt._root=qe(at),rt;for(St=[{source:at,target:rt._root=new Array(8)}];at=St.pop();)for(var Fn=0;Fn<8;++Fn)(Ot=at.source[Fn])&&(Ot.length?St.push({source:Ot,target:at.target[Fn]=new Array(8)}):at.target[Fn]=qe(Ot));return rt},et.add=_e.Z,et.addAll=_e.H,et.cover=ye.Z,et.data=fe.Z,et.extent=X.Z,et.find=J.Z,et.remove=oe.Z,et.removeAll=oe.x,et.root=te.Z,et.size=me.Z,et.visit=Me.Z,et.visitAfter=Ne.Z,et.x=le.Z,et.y=Be.Z,et.z=Ee.Z},44576:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return _e},x:function(){return ye}});function _e(fe){if(isNaN(Ae=+this._x.call(null,fe))||isNaN(qe=+this._y.call(null,fe))||isNaN(et=+this._z.call(null,fe)))return this;var X,J=this._root,oe,te,me,Me=this._x0,Ne=this._y0,le=this._z0,Be=this._x1,Ee=this._y1,ke=this._z1,Ae,qe,et,rt,at,St,Ot,Fn,os,Bn,ei;if(!J)return this;if(J.length)for(;;){if((Ot=Ae>=(rt=(Me+Be)/2))?Me=rt:Be=rt,(Fn=qe>=(at=(Ne+Ee)/2))?Ne=at:Ee=at,(os=et>=(St=(le+ke)/2))?le=St:ke=St,X=J,!(J=J[Bn=os<<2|Fn<<1|Ot]))return this;if(!J.length)break;(X[Bn+1&7]||X[Bn+2&7]||X[Bn+3&7]||X[Bn+4&7]||X[Bn+5&7]||X[Bn+6&7]||X[Bn+7&7])&&(oe=X,ei=Bn)}for(;J.data!==fe;)if(te=J,!(J=J.next))return this;return(me=J.next)&&delete J.next,te?(me?te.next=me:delete te.next,this):X?(me?X[Bn]=me:delete X[Bn],(J=X[0]||X[1]||X[2]||X[3]||X[4]||X[5]||X[6]||X[7])&&J===(X[7]||X[6]||X[5]||X[4]||X[3]||X[2]||X[1]||X[0])&&!J.length&&(oe?oe[ei]=J:this._root=J),this):(this._root=me,this)}function ye(fe){for(var X=0,J=fe.length;X<J;++X)this.remove(fe[X]);return this}},76077:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return _e}});function _e(){return this._root}},53212:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return _e}});function _e(){var ye=0;return this.visit(function(fe){if(!fe.length)do++ye;while(fe=fe.next)}),ye}},56173:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return ye}});var _e=he(14086);function ye(fe){var X=[],J,oe=this._root,te,me,Me,Ne,le,Be,Ee;for(oe&&X.push(new _e.Z(oe,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));J=X.pop();)if(!fe(oe=J.node,me=J.x0,Me=J.y0,Ne=J.z0,le=J.x1,Be=J.y1,Ee=J.z1)&&oe.length){var ke=(me+le)/2,Ae=(Me+Be)/2,qe=(Ne+Ee)/2;(te=oe[7])&&X.push(new _e.Z(te,ke,Ae,qe,le,Be,Ee)),(te=oe[6])&&X.push(new _e.Z(te,me,Ae,qe,ke,Be,Ee)),(te=oe[5])&&X.push(new _e.Z(te,ke,Me,qe,le,Ae,Ee)),(te=oe[4])&&X.push(new _e.Z(te,me,Me,qe,ke,Ae,Ee)),(te=oe[3])&&X.push(new _e.Z(te,ke,Ae,Ne,le,Be,qe)),(te=oe[2])&&X.push(new _e.Z(te,me,Ae,Ne,ke,Be,qe)),(te=oe[1])&&X.push(new _e.Z(te,ke,Me,Ne,le,Ae,qe)),(te=oe[0])&&X.push(new _e.Z(te,me,Me,Ne,ke,Ae,qe))}return this}},36427:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return ye}});var _e=he(14086);function ye(fe){var X=[],J=[],oe;for(this._root&&X.push(new _e.Z(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));oe=X.pop();){var te=oe.node;if(te.length){var me,Me=oe.x0,Ne=oe.y0,le=oe.z0,Be=oe.x1,Ee=oe.y1,ke=oe.z1,Ae=(Me+Be)/2,qe=(Ne+Ee)/2,et=(le+ke)/2;(me=te[0])&&X.push(new _e.Z(me,Me,Ne,le,Ae,qe,et)),(me=te[1])&&X.push(new _e.Z(me,Ae,Ne,le,Be,qe,et)),(me=te[2])&&X.push(new _e.Z(me,Me,qe,le,Ae,Ee,et)),(me=te[3])&&X.push(new _e.Z(me,Ae,qe,le,Be,Ee,et)),(me=te[4])&&X.push(new _e.Z(me,Me,Ne,et,Ae,qe,ke)),(me=te[5])&&X.push(new _e.Z(me,Ae,Ne,et,Be,qe,ke)),(me=te[6])&&X.push(new _e.Z(me,Me,qe,et,Ae,Ee,ke)),(me=te[7])&&X.push(new _e.Z(me,Ae,qe,et,Be,Ee,ke))}J.push(oe)}for(;oe=J.pop();)fe(oe.node,oe.x0,oe.y0,oe.z0,oe.x1,oe.y1,oe.z1);return this}},79853:function(lt,Ze,he){"use strict";he.d(Ze,{P:function(){return _e},Z:function(){return ye}});function _e(fe){return fe[0]}function ye(fe){return arguments.length?(this._x=fe,this):this._x}},79840:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return ye},q:function(){return _e}});function _e(fe){return fe[1]}function ye(fe){return arguments.length?(this._y=fe,this):this._y}},87325:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return ye},i:function(){return _e}});function _e(fe){return fe[2]}function ye(fe){return arguments.length?(this._z=fe,this):this._z}},59715:function(lt,Ze,he){"use strict";he.d(Ze,{H:function(){return fe},Z:function(){return _e}});function _e(X){const J=+this._x.call(null,X),oe=+this._y.call(null,X);return ye(this.cover(J,oe),J,oe,X)}function ye(X,J,oe,te){if(isNaN(J)||isNaN(oe))return X;var me,Me=X._root,Ne={data:te},le=X._x0,Be=X._y0,Ee=X._x1,ke=X._y1,Ae,qe,et,rt,at,St,Ot,Fn;if(!Me)return X._root=Ne,X;for(;Me.length;)if((at=J>=(Ae=(le+Ee)/2))?le=Ae:Ee=Ae,(St=oe>=(qe=(Be+ke)/2))?Be=qe:ke=qe,me=Me,!(Me=Me[Ot=St<<1|at]))return me[Ot]=Ne,X;if(et=+X._x.call(null,Me.data),rt=+X._y.call(null,Me.data),J===et&&oe===rt)return Ne.next=Me,me?me[Ot]=Ne:X._root=Ne,X;do me=me?me[Ot]=new Array(4):X._root=new Array(4),(at=J>=(Ae=(le+Ee)/2))?le=Ae:Ee=Ae,(St=oe>=(qe=(Be+ke)/2))?Be=qe:ke=qe;while((Ot=St<<1|at)===(Fn=(rt>=qe)<<1|et>=Ae));return me[Fn]=Me,me[Ot]=Ne,X}function fe(X){var J,oe,te=X.length,me,Me,Ne=new Array(te),le=new Array(te),Be=1/0,Ee=1/0,ke=-1/0,Ae=-1/0;for(oe=0;oe<te;++oe)isNaN(me=+this._x.call(null,J=X[oe]))||isNaN(Me=+this._y.call(null,J))||(Ne[oe]=me,le[oe]=Me,me<Be&&(Be=me),me>ke&&(ke=me),Me<Ee&&(Ee=Me),Me>Ae&&(Ae=Me));if(Be>ke||Ee>Ae)return this;for(this.cover(Be,Ee).cover(ke,Ae),oe=0;oe<te;++oe)ye(this,Ne[oe],le[oe],X[oe]);return this}},86290:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return _e}});function _e(ye,fe){if(isNaN(ye=+ye)||isNaN(fe=+fe))return this;var X=this._x0,J=this._y0,oe=this._x1,te=this._y1;if(isNaN(X))oe=(X=Math.floor(ye))+1,te=(J=Math.floor(fe))+1;else{for(var me=oe-X||1,Me=this._root,Ne,le;X>ye||ye>=oe||J>fe||fe>=te;)switch(le=(fe<J)<<1|ye<X,Ne=new Array(4),Ne[le]=Me,Me=Ne,me*=2,le){case 0:oe=X+me,te=J+me;break;case 1:X=oe-me,te=J+me;break;case 2:oe=X+me,J=te-me;break;case 3:X=oe-me,J=te-me;break}this._root&&this._root.length&&(this._root=Me)}return this._x0=X,this._y0=J,this._x1=oe,this._y1=te,this}},11145:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return _e}});function _e(){var ye=[];return this.visit(function(fe){if(!fe.length)do ye.push(fe.data);while(fe=fe.next)}),ye}},57059:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return _e}});function _e(ye){return arguments.length?this.cover(+ye[0][0],+ye[0][1]).cover(+ye[1][0],+ye[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]}},13297:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return ye}});var _e=he(92936);function ye(fe,X,J){var oe,te=this._x0,me=this._y0,Me,Ne,le,Be,Ee=this._x1,ke=this._y1,Ae=[],qe=this._root,et,rt;for(qe&&Ae.push(new _e.Z(qe,te,me,Ee,ke)),J==null?J=1/0:(te=fe-J,me=X-J,Ee=fe+J,ke=X+J,J*=J);et=Ae.pop();)if(!(!(qe=et.node)||(Me=et.x0)>Ee||(Ne=et.y0)>ke||(le=et.x1)<te||(Be=et.y1)<me))if(qe.length){var at=(Me+le)/2,St=(Ne+Be)/2;Ae.push(new _e.Z(qe[3],at,St,le,Be),new _e.Z(qe[2],Me,St,at,Be),new _e.Z(qe[1],at,Ne,le,St),new _e.Z(qe[0],Me,Ne,at,St)),(rt=(X>=St)<<1|fe>=at)&&(et=Ae[Ae.length-1],Ae[Ae.length-1]=Ae[Ae.length-1-rt],Ae[Ae.length-1-rt]=et)}else{var Ot=fe-+this._x.call(null,qe.data),Fn=X-+this._y.call(null,qe.data),os=Ot*Ot+Fn*Fn;if(os<J){var Bn=Math.sqrt(J=os);te=fe-Bn,me=X-Bn,Ee=fe+Bn,ke=X+Bn,oe=qe.data}}return oe}},92936:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return _e}});function _e(ye,fe,X,J,oe){this.node=ye,this.x0=fe,this.y0=X,this.x1=J,this.y1=oe}},46632:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return Ee}});var _e=he(59715),ye=he(86290),fe=he(11145),X=he(57059),J=he(13297),oe=he(85854),te=he(39033),me=he(56590),Me=he(61034),Ne=he(88020),le=he(40220),Be=he(88792);function Ee(et,rt,at){var St=new ke(rt==null?le.P:rt,at==null?Be.q:at,NaN,NaN,NaN,NaN);return et==null?St:St.addAll(et)}function ke(et,rt,at,St,Ot,Fn){this._x=et,this._y=rt,this._x0=at,this._y0=St,this._x1=Ot,this._y1=Fn,this._root=void 0}function Ae(et){for(var rt={data:et.data},at=rt;et=et.next;)at=at.next={data:et.data};return rt}var qe=Ee.prototype=ke.prototype;qe.copy=function(){var et=new ke(this._x,this._y,this._x0,this._y0,this._x1,this._y1),rt=this._root,at,St;if(!rt)return et;if(!rt.length)return et._root=Ae(rt),et;for(at=[{source:rt,target:et._root=new Array(4)}];rt=at.pop();)for(var Ot=0;Ot<4;++Ot)(St=rt.source[Ot])&&(St.length?at.push({source:St,target:rt.target[Ot]=new Array(4)}):rt.target[Ot]=Ae(St));return et},qe.add=_e.Z,qe.addAll=_e.H,qe.cover=ye.Z,qe.data=fe.Z,qe.extent=X.Z,qe.find=J.Z,qe.remove=oe.Z,qe.removeAll=oe.x,qe.root=te.Z,qe.size=me.Z,qe.visit=Me.Z,qe.visitAfter=Ne.Z,qe.x=le.Z,qe.y=Be.Z},85854:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return _e},x:function(){return ye}});function _e(fe){if(isNaN(Ee=+this._x.call(null,fe))||isNaN(ke=+this._y.call(null,fe)))return this;var X,J=this._root,oe,te,me,Me=this._x0,Ne=this._y0,le=this._x1,Be=this._y1,Ee,ke,Ae,qe,et,rt,at,St;if(!J)return this;if(J.length)for(;;){if((et=Ee>=(Ae=(Me+le)/2))?Me=Ae:le=Ae,(rt=ke>=(qe=(Ne+Be)/2))?Ne=qe:Be=qe,X=J,!(J=J[at=rt<<1|et]))return this;if(!J.length)break;(X[at+1&3]||X[at+2&3]||X[at+3&3])&&(oe=X,St=at)}for(;J.data!==fe;)if(te=J,!(J=J.next))return this;return(me=J.next)&&delete J.next,te?(me?te.next=me:delete te.next,this):X?(me?X[at]=me:delete X[at],(J=X[0]||X[1]||X[2]||X[3])&&J===(X[3]||X[2]||X[1]||X[0])&&!J.length&&(oe?oe[St]=J:this._root=J),this):(this._root=me,this)}function ye(fe){for(var X=0,J=fe.length;X<J;++X)this.remove(fe[X]);return this}},39033:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return _e}});function _e(){return this._root}},56590:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return _e}});function _e(){var ye=0;return this.visit(function(fe){if(!fe.length)do++ye;while(fe=fe.next)}),ye}},61034:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return ye}});var _e=he(92936);function ye(fe){var X=[],J,oe=this._root,te,me,Me,Ne,le;for(oe&&X.push(new _e.Z(oe,this._x0,this._y0,this._x1,this._y1));J=X.pop();)if(!fe(oe=J.node,me=J.x0,Me=J.y0,Ne=J.x1,le=J.y1)&&oe.length){var Be=(me+Ne)/2,Ee=(Me+le)/2;(te=oe[3])&&X.push(new _e.Z(te,Be,Ee,Ne,le)),(te=oe[2])&&X.push(new _e.Z(te,me,Ee,Be,le)),(te=oe[1])&&X.push(new _e.Z(te,Be,Me,Ne,Ee)),(te=oe[0])&&X.push(new _e.Z(te,me,Me,Be,Ee))}return this}},88020:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return ye}});var _e=he(92936);function ye(fe){var X=[],J=[],oe;for(this._root&&X.push(new _e.Z(this._root,this._x0,this._y0,this._x1,this._y1));oe=X.pop();){var te=oe.node;if(te.length){var me,Me=oe.x0,Ne=oe.y0,le=oe.x1,Be=oe.y1,Ee=(Me+le)/2,ke=(Ne+Be)/2;(me=te[0])&&X.push(new _e.Z(me,Me,Ne,Ee,ke)),(me=te[1])&&X.push(new _e.Z(me,Ee,Ne,le,ke)),(me=te[2])&&X.push(new _e.Z(me,Me,ke,Ee,Be)),(me=te[3])&&X.push(new _e.Z(me,Ee,ke,le,Be))}J.push(oe)}for(;oe=J.pop();)fe(oe.node,oe.x0,oe.y0,oe.x1,oe.y1);return this}},40220:function(lt,Ze,he){"use strict";he.d(Ze,{P:function(){return _e},Z:function(){return ye}});function _e(fe){return fe[0]}function ye(fe){return arguments.length?(this._x=fe,this):this._x}},88792:function(lt,Ze,he){"use strict";he.d(Ze,{Z:function(){return ye},q:function(){return _e}});function _e(fe){return fe[1]}function ye(fe){return arguments.length?(this._y=fe,this):this._y}},38870:function(lt,Ze,he){"use strict";he.d(Ze,{KI_:function(){return Ei},Kj0:function(){return Xl},ROQ:function(){return of},TlE:function(){return pr},ZAu:function(){return fl},ehD:function(){return ke},jyi:function(){return Lg},u9r:function(){return Gn},vBJ:function(){return Di},xeV:function(){return Jc},xo$:function(){return qh},xoR:function(){return ly}});const _e="181",ye={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2},fe={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},X=0,J=1,oe=2,te=3,me=0,Me=1,Ne=2,le=3,Be=0,Ee=1,ke=2,Ae=0,qe=1,et=2,rt=3,at=4,St=5,Ot=100,Fn=101,os=102,Bn=103,ei=104,ni=200,bs=201,vr=202,Zr=203,Kr=204,Ss=205,xa=206,va=207,Tt=208,rn=209,On=210,hs=211,Il=212,Hu=213,J_=214,Wu=0,Sn=1,yi=2,Jr=3,Ec=4,Cc=5,pp=6,mp=7,Rc=0,db=1,fb=2,Qr=0,pb=1,mb=2,gb=3,yb=4,E1=5,_b=6,xb=7,lg="attached",vb="detached",$u=300,Br=301,Vo=302,Nc=303,Pc=304,Ll=306,ba=1e3,Ki=1001,Sa=1002,Jn=1003,gp=1004,hD=1004,Ta=1005,dD=1005,Yn=1006,Ic=1007,fD=1007,Ds=1008,C1=1008,Ui=1009,Lc=1010,Dc=1011,Go=1012,Ws=1013,pi=1014,mi=1015,Ts=1016,yp=1017,_p=1018,mo=1020,xp=35902,vp=35899,cg=1021,bd=1022,_i=1023,Or=1026,eo=1027,Fc=1028,Dl=1029,rl=1030,qu=1031,R1=1032,Xu=1033,Fl=33776,Bl=33777,Ol=33778,Ul=33779,Sd=35840,Td=35841,wd=35842,Md=35843,ju=36196,Yu=37492,Zu=37496,Ku=37808,Ju=37809,Qu=37810,eh=37811,th=37812,nh=37813,ih=37814,sh=37815,rh=37816,oh=37817,ah=37818,lh=37819,ch=37820,uh=37821,hh=36492,ug=36494,hg=36495,dh=36283,fh=36284,ph=36285,mh=36286,bb=2200,Sb=2201,Tb=2202,Bc=2300,Ad=2301,Ed=2302,Ho=2400,Wo=2401,Oc=2402,Cd=2500,dg=2501,pD=0,mD=1,gD=2,wb=3200,N1=3201,yD=3202,_D=3203,Ur=0,Mb=1,br="",Ei="srgb",ol="srgb-linear",Uc="linear",Dt="srgb",P1=0,go=7680,I1=7681,L1=7682,D1=7683,F1=34055,B1=34056,O1=5386,U1=512,k1=513,z1=514,V1=515,G1=516,H1=517,W1=518,bp=519,Q_=512,fg=513,e0=514,pg=515,t0=516,n0=517,i0=518,s0=519,kl=35044,Rd=35048,xD=35040,vD=35045,bD=35049,SD=35041,TD=35046,wD=35050,MD=35042,AD="100",Ab="300 es",ki=2e3,Sr=2001,Nd={COMPUTE:"compute",RENDER:"render"},ED={PERSPECTIVE:"perspective",LINEAR:"linear",FLAT:"flat"},CD={NORMAL:"normal",CENTROID:"centroid",SAMPLE:"sample",FIRST:"first",EITHER:"either"};function wa(E){for(let s=E.length-1;s>=0;--s)if(E[s]>=65535)return!0;return!1}const cr={Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array};function kc(E,s){return new cr[E](s)}function Ma(E){return document.createElementNS("http://www.w3.org/1999/xhtml",E)}function gh(){const E=Ma("canvas");return E.style.display="block",E}const kr={};let fn=null;function r0(E){fn=E}function $1(){return fn}function o0(...E){const s="THREE."+E.shift();fn?fn("log",s,...E):console.log(s,...E)}function _n(...E){const s="THREE."+E.shift();fn?fn("warn",s,...E):console.warn(s,...E)}function ci(...E){const s="THREE."+E.shift();fn?fn("error",s,...E):console.error(s,...E)}function a0(...E){const s=E.join(" ");s in kr||(kr[s]=!0,_n(...E))}function q1(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 Sp{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 ur=["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 l0=1234567;const zc=Math.PI/180,Pd=180/Math.PI;function to(){const E=Math.random()*4294967295|0,s=Math.random()*4294967295|0,l=Math.random()*4294967295|0,h=Math.random()*4294967295|0;return(ur[E&255]+ur[E>>8&255]+ur[E>>16&255]+ur[E>>24&255]+"-"+ur[s&255]+ur[s>>8&255]+"-"+ur[s>>16&15|64]+ur[s>>24&255]+"-"+ur[l&63|128]+ur[l>>8&255]+"-"+ur[l>>16&255]+ur[l>>24&255]+ur[h&255]+ur[h>>8&255]+ur[h>>16&255]+ur[h>>24&255]).toLowerCase()}function Tn(E,s,l){return Math.max(s,Math.min(l,E))}function mg(E,s){return(E%s+s)%s}function Eb(E,s,l,h,f){return h+(E-s)*(f-h)/(l-s)}function Cb(E,s,l){return E!==s?(l-E)/(s-E):0}function Id(E,s,l){return(1-l)*E+l*s}function Tr(E,s,l,h){return Id(E,s,1-Math.exp(-l*h))}function Vn(E,s=1){return s-Math.abs(mg(E,s*2)-s)}function Ld(E,s,l){return E<=s?0:E>=l?1:(E=(E-s)/(l-s),E*E*(3-2*E))}function Ie(E,s,l){return E<=s?0:E>=l?1:(E=(E-s)/(l-s),E*E*E*(E*(E*6-15)+10))}function Fs(E,s){return E+Math.floor(Math.random()*(s-E+1))}function W(E,s){return E+Math.random()*(s-E)}function gg(E){return E*(.5-Math.random())}function c0(E){E!==void 0&&(l0=E);let s=l0+=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 Cn(E){return E*zc}function yg(E){return E*Pd}function _g(E){return(E&E-1)===0&&E!==0}function Rb(E){return Math.pow(2,Math.ceil(Math.log(E)/Math.LN2))}function yh(E){return Math.pow(2,Math.floor(Math.log(E)/Math.LN2))}function Dd(E,s,l,h,f){const g=Math.cos,_=Math.sin,b=g(l/2),w=_(l/2),A=g((s+h)/2),C=_((s+h)/2),I=g((s-h)/2),L=_((s-h)/2),D=g((h-s)/2),O=_((h-s)/2);switch(f){case"XYX":E.set(b*C,w*I,w*L,b*A);break;case"YZY":E.set(w*L,b*C,w*I,b*A);break;case"ZXZ":E.set(w*I,w*L,b*C,b*A);break;case"XZX":E.set(b*C,w*O,w*D,b*A);break;case"YXY":E.set(w*D,b*C,w*O,b*A);break;case"ZYZ":E.set(w*O,w*D,b*C,b*A);break;default:_n("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+f)}}function hr(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 kn(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 wr={DEG2RAD:zc,RAD2DEG:Pd,generateUUID:to,clamp:Tn,euclideanModulo:mg,mapLinear:Eb,inverseLerp:Cb,lerp:Id,damp:Tr,pingpong:Vn,smoothstep:Ld,smootherstep:Ie,randInt:Fs,randFloat:W,randFloatSpread:gg,seededRandom:c0,degToRad:Cn,radToDeg:yg,isPowerOfTwo:_g,ceilPowerOfTwo:Rb,floorPowerOfTwo:yh,setQuaternionFromProperEuler:Dd,normalize:kn,denormalize:hr};class pt{constructor(s=0,l=0){pt.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=Tn(this.x,s.x,l.x),this.y=Tn(this.y,s.y,l.y),this}clampScalar(s,l){return this.x=Tn(this.x,s,l),this.y=Tn(this.y,s,l),this}clampLength(s,l){const h=this.length();return this.divideScalar(h||1).multiplyScalar(Tn(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(Tn(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 zr{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 w=h[f+0],A=h[f+1],C=h[f+2],I=h[f+3],L=g[_+0],D=g[_+1],O=g[_+2],G=g[_+3];if(b<=0){s[l+0]=w,s[l+1]=A,s[l+2]=C,s[l+3]=I;return}if(b>=1){s[l+0]=L,s[l+1]=D,s[l+2]=O,s[l+3]=G;return}if(I!==G||w!==L||A!==D||C!==O){let Z=w*L+A*D+C*O+I*G;Z<0&&(L=-L,D=-D,O=-O,G=-G,Z=-Z);let Y=1-b;if(Z<.9995){const Q=Math.acos(Z),ee=Math.sin(Q);Y=Math.sin(Y*Q)/ee,b=Math.sin(b*Q)/ee,w=w*Y+L*b,A=A*Y+D*b,C=C*Y+O*b,I=I*Y+G*b}else{w=w*Y+L*b,A=A*Y+D*b,C=C*Y+O*b,I=I*Y+G*b;const Q=1/Math.sqrt(w*w+A*A+C*C+I*I);w*=Q,A*=Q,C*=Q,I*=Q}}s[l]=w,s[l+1]=A,s[l+2]=C,s[l+3]=I}static multiplyQuaternionsFlat(s,l,h,f,g,_){const b=h[f],w=h[f+1],A=h[f+2],C=h[f+3],I=g[_],L=g[_+1],D=g[_+2],O=g[_+3];return s[l]=b*O+C*I+w*D-A*L,s[l+1]=w*O+C*L+A*I-b*D,s[l+2]=A*O+C*D+b*L-w*I,s[l+3]=C*O-b*I-w*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,w=Math.sin,A=b(h/2),C=b(f/2),I=b(g/2),L=w(h/2),D=w(f/2),O=w(g/2);switch(_){case"XYZ":this._x=L*C*I+A*D*O,this._y=A*D*I-L*C*O,this._z=A*C*O+L*D*I,this._w=A*C*I-L*D*O;break;case"YXZ":this._x=L*C*I+A*D*O,this._y=A*D*I-L*C*O,this._z=A*C*O-L*D*I,this._w=A*C*I+L*D*O;break;case"ZXY":this._x=L*C*I-A*D*O,this._y=A*D*I+L*C*O,this._z=A*C*O+L*D*I,this._w=A*C*I-L*D*O;break;case"ZYX":this._x=L*C*I-A*D*O,this._y=A*D*I+L*C*O,this._z=A*C*O-L*D*I,this._w=A*C*I+L*D*O;break;case"YZX":this._x=L*C*I+A*D*O,this._y=A*D*I+L*C*O,this._z=A*C*O-L*D*I,this._w=A*C*I-L*D*O;break;case"XZY":this._x=L*C*I-A*D*O,this._y=A*D*I-L*C*O,this._z=A*C*O+L*D*I,this._w=A*C*I+L*D*O;break;default:_n("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],w=l[9],A=l[2],C=l[6],I=l[10],L=h+b+I;if(L>0){const D=.5/Math.sqrt(L+1);this._w=.25/D,this._x=(C-w)*D,this._y=(g-A)*D,this._z=(_-f)*D}else if(h>b&&h>I){const D=2*Math.sqrt(1+h-b-I);this._w=(C-w)/D,this._x=.25*D,this._y=(f+_)/D,this._z=(g+A)/D}else if(b>I){const D=2*Math.sqrt(1+b-h-I);this._w=(g-A)/D,this._x=(f+_)/D,this._y=.25*D,this._z=(w+C)/D}else{const D=2*Math.sqrt(1+I-h-b);this._w=(_-f)/D,this._x=(g+A)/D,this._y=(w+C)/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(Tn(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,w=l._y,A=l._z,C=l._w;return this._x=h*C+_*b+f*A-g*w,this._y=f*C+_*w+g*b-h*A,this._z=g*C+_*A+h*w-f*b,this._w=_*C-h*b-f*w-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 w=1-l;if(b<.9995){const A=Math.acos(b),C=Math.sin(A);w=Math.sin(w*A)/C,l=Math.sin(l*A)/C,this._x=this._x*w+h*l,this._y=this._y*w+f*l,this._z=this._z*w+g*l,this._w=this._w*w+_*l,this._onChangeCallback()}else this._x=this._x*w+h*l,this._y=this._y*w+f*l,this._z=this._z*w+g*l,this._w=this._w*w+_*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 ne{constructor(s=0,l=0,h=0){ne.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(pn.setFromEuler(s))}applyAxisAngle(s,l){return this.applyQuaternion(pn.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,w=s.w,A=2*(_*f-b*h),C=2*(b*l-g*f),I=2*(g*h-_*l);return this.x=l+w*A+_*I-b*C,this.y=h+w*C+b*A-g*I,this.z=f+w*I+g*C-_*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=Tn(this.x,s.x,l.x),this.y=Tn(this.y,s.y,l.y),this.z=Tn(this.z,s.z,l.z),this}clampScalar(s,l){return this.x=Tn(this.x,s,l),this.y=Tn(this.y,s,l),this.z=Tn(this.z,s,l),this}clampLength(s,l){const h=this.length();return this.divideScalar(h||1).multiplyScalar(Tn(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,w=l.z;return this.x=f*w-g*b,this.y=g*_-h*w,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 xg.copy(this).projectOnVector(s),this.sub(xg)}reflect(s){return this.sub(xg.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(Tn(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 xg=new ne,pn=new zr;class $s{constructor(s,l,h,f,g,_,b,w,A){$s.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,w,A)}set(s,l,h,f,g,_,b,w,A){const C=this.elements;return C[0]=s,C[1]=f,C[2]=b,C[3]=l,C[4]=g,C[5]=w,C[6]=h,C[7]=_,C[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],w=h[6],A=h[1],C=h[4],I=h[7],L=h[2],D=h[5],O=h[8],G=f[0],Z=f[3],Y=f[6],Q=f[1],ee=f[4],ae=f[7],Re=f[2],Oe=f[5],je=f[8];return g[0]=_*G+b*Q+w*Re,g[3]=_*Z+b*ee+w*Oe,g[6]=_*Y+b*ae+w*je,g[1]=A*G+C*Q+I*Re,g[4]=A*Z+C*ee+I*Oe,g[7]=A*Y+C*ae+I*je,g[2]=L*G+D*Q+O*Re,g[5]=L*Z+D*ee+O*Oe,g[8]=L*Y+D*ae+O*je,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],w=s[6],A=s[7],C=s[8];return l*_*C-l*b*A-h*g*C+h*b*w+f*g*A-f*_*w}invert(){const s=this.elements,l=s[0],h=s[1],f=s[2],g=s[3],_=s[4],b=s[5],w=s[6],A=s[7],C=s[8],I=C*_-b*A,L=b*w-C*g,D=A*g-_*w,O=l*I+h*L+f*D;if(O===0)return this.set(0,0,0,0,0,0,0,0,0);const G=1/O;return s[0]=I*G,s[1]=(f*A-C*h)*G,s[2]=(b*h-f*_)*G,s[3]=L*G,s[4]=(C*l-f*w)*G,s[5]=(f*g-b*l)*G,s[6]=D*G,s[7]=(h*w-A*l)*G,s[8]=(_*l-h*g)*G,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 w=Math.cos(g),A=Math.sin(g);return this.set(h*w,h*A,-h*(w*_+A*b)+_+s,-f*A,f*w,-f*(-A*_+w*b)+b+l,0,0,1),this}scale(s,l){return this.premultiply(zl.makeScale(s,l)),this}rotate(s){return this.premultiply(zl.makeRotation(-s)),this}translate(s,l){return this.premultiply(zl.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 zl=new $s,Vc=new $s().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),u0=new $s().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Nb(){const E={enabled:!0,workingColorSpace:ol,spaces:{},convert:function(f,g,_){return this.enabled===!1||g===_||!g||!_||(this.spaces[g].transfer===Dt&&(f.r=$o(f.r),f.g=$o(f.g),f.b=$o(f.b)),this.spaces[g].primaries!==this.spaces[_].primaries&&(f.applyMatrix3(this.spaces[g].toXYZ),f.applyMatrix3(this.spaces[_].fromXYZ)),this.spaces[_].transfer===Dt&&(f.r=_h(f.r),f.g=_h(f.g),f.b=_h(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===br?Uc: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 a0("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),E.workingToColorSpace(f,g)},toWorkingColorSpace:function(f,g){return a0("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({[ol]:{primaries:s,whitePoint:h,transfer:Uc,toXYZ:Vc,fromXYZ:u0,luminanceCoefficients:l,workingColorSpaceConfig:{unpackColorSpace:Ei},outputColorSpaceConfig:{drawingBufferColorSpace:Ei}},[Ei]:{primaries:s,whitePoint:h,transfer:Dt,toXYZ:Vc,fromXYZ:u0,luminanceCoefficients:l,outputColorSpaceConfig:{drawingBufferColorSpace:Ei}}}),E}const Bs=Nb();function $o(E){return E<.04045?E*.0773993808:Math.pow(E*.9478672986+.0521327014,2.4)}function _h(E){return E<.0031308?E*12.92:1.055*Math.pow(E,.41666)-.055}let Vl;class ds{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{Vl===void 0&&(Vl=Ma("canvas")),Vl.width=s.width,Vl.height=s.height;const f=Vl.getContext("2d");s instanceof ImageData?f.putImageData(s,0,0):f.drawImage(s,0,0,s.width,s.height),h=Vl}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=Ma("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[_]=$o(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($o(l[h]/255)*255):l[h]=$o(l[h]);return{data:l,width:s.width,height:s.height}}else return _n("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),s}}let an=0;class Mr{constructor(s=null){this.isSource=!0,Object.defineProperty(this,"id",{value:an++}),this.uuid=to(),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(Aa(f[_].image)):g.push(Aa(f[_]))}else g=Aa(f);h.url=g}return l||(s.images[this.uuid]=h),h}}function Aa(E){return typeof HTMLImageElement!="undefined"&&E instanceof HTMLImageElement||typeof HTMLCanvasElement!="undefined"&&E instanceof HTMLCanvasElement||typeof ImageBitmap!="undefined"&&E instanceof ImageBitmap?ds.getDataURL(E):E.data?{data:Array.from(E.data),width:E.width,height:E.height,type:E.data.constructor.name}:(_n("Texture: Unable to serialize Texture."),{})}let Tp=0;const h0=new ne;class no extends Sp{constructor(s=no.DEFAULT_IMAGE,l=no.DEFAULT_MAPPING,h=Ki,f=Ki,g=Yn,_=Ds,b=_i,w=Ui,A=no.DEFAULT_ANISOTROPY,C=br){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Tp++}),this.uuid=to(),this.name="",this.source=new Mr(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=w,this.offset=new pt(0,0),this.repeat=new pt(1,1),this.center=new pt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new $s,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=C,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(h0).x}get height(){return this.source.getSize(h0).y}get depth(){return this.source.getSize(h0).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){_n(`Texture.setValues(): parameter '${l}' has value of undefined.`);continue}const f=this[l];if(f===void 0){_n(`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!==$u)return s;if(s.applyMatrix3(this.matrix),s.x<0||s.x>1)switch(this.wrapS){case ba:s.x=s.x-Math.floor(s.x);break;case Ki:s.x=s.x<0?0:1;break;case Sa: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 ba:s.y=s.y-Math.floor(s.y);break;case Ki:s.y=s.y<0?0:1;break;case Sa: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++}}no.DEFAULT_IMAGE=null,no.DEFAULT_MAPPING=$u,no.DEFAULT_ANISOTROPY=1;class tr{constructor(s=0,l=0,h=0,f=1){tr.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 w=s.elements,A=w[0],C=w[4],I=w[8],L=w[1],D=w[5],O=w[9],G=w[2],Z=w[6],Y=w[10];if(Math.abs(C-L)<.01&&Math.abs(I-G)<.01&&Math.abs(O-Z)<.01){if(Math.abs(C+L)<.1&&Math.abs(I+G)<.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 ee=(A+1)/2,ae=(D+1)/2,Re=(Y+1)/2,Oe=(C+L)/4,je=(I+G)/4,He=(O+Z)/4;return ee>ae&&ee>Re?ee<.01?(h=0,f=.707106781,g=.707106781):(h=Math.sqrt(ee),f=Oe/h,g=je/h):ae>Re?ae<.01?(h=.707106781,f=0,g=.707106781):(f=Math.sqrt(ae),h=Oe/f,g=He/f):Re<.01?(h=.707106781,f=.707106781,g=0):(g=Math.sqrt(Re),h=je/g,f=He/g),this.set(h,f,g,l),this}let Q=Math.sqrt((Z-O)*(Z-O)+(I-G)*(I-G)+(L-C)*(L-C));return Math.abs(Q)<.001&&(Q=1),this.x=(Z-O)/Q,this.y=(I-G)/Q,this.z=(L-C)/Q,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=Tn(this.x,s.x,l.x),this.y=Tn(this.y,s.y,l.y),this.z=Tn(this.z,s.z,l.z),this.w=Tn(this.w,s.w,l.w),this}clampScalar(s,l){return this.x=Tn(this.x,s,l),this.y=Tn(this.y,s,l),this.z=Tn(this.z,s,l),this.w=Tn(this.w,s,l),this}clampLength(s,l){const h=this.length();return this.divideScalar(h||1).multiplyScalar(Tn(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 dr 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 tr(0,0,s,l),this.scissorTest=!1,this.viewport=new tr(0,0,s,l);const f={width:s,height:l,depth:h.depth},g=new no(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 Mr(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 Gl extends null{constructor(s=1,l=1,h={}){super(s,l,h),this.isWebGLRenderTarget=!0}}class qo 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=Jn,this.minFilter=Jn,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 vg extends null{constructor(s=1,l=1,h=1,f={}){super(s,l,f),this.isWebGLArrayRenderTarget=!0,this.depth=h,this.texture=new qo(null,s,l,h),this._setTextureOptions(f),this.texture.isRenderTargetTexture=!0}}class Gc 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=Jn,this.minFilter=Jn,this.wrapR=Ki,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Fd extends null{constructor(s=1,l=1,h=1,f={}){super(s,l,f),this.isWebGL3DRenderTarget=!0,this.depth=h,this.texture=new Gc(null,s,l,h),this._setTextureOptions(f),this.texture.isRenderTargetTexture=!0}}class ws{constructor(s=new ne(1/0,1/0,1/0),l=new ne(-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(qs.fromArray(s,l));return this}setFromBufferAttribute(s){this.makeEmpty();for(let l=0,h=s.count;l<h;l++)this.expandByPoint(qs.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=qs.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(_,qs):qs.fromBufferAttribute(g,_),qs.applyMatrix4(s.matrixWorld),this.expandByPoint(qs);else s.boundingBox!==void 0?(s.boundingBox===null&&s.computeBoundingBox(),Ea.copy(s.boundingBox)):(h.boundingBox===null&&h.computeBoundingBox(),Ea.copy(h.boundingBox)),Ea.applyMatrix4(s.matrixWorld),this.union(Ea)}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,qs),qs.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(cl),xh.subVectors(this.max,cl),Ca.subVectors(s.a,cl),al.subVectors(s.b,cl),ll.subVectors(s.c,cl),Vr.subVectors(al,Ca),Ra.subVectors(ll,al),Hc.subVectors(Ca,ll);let l=[0,-Vr.z,Vr.y,0,-Ra.z,Ra.y,0,-Hc.z,Hc.y,Vr.z,0,-Vr.x,Ra.z,0,-Ra.x,Hc.z,0,-Hc.x,-Vr.y,Vr.x,0,-Ra.y,Ra.x,0,-Hc.y,Hc.x,0];return!Bd(l,Ca,al,ll,xh)||(l=[1,0,0,0,1,0,0,0,1],!Bd(l,Ca,al,ll,xh))?!1:(Ms.crossVectors(Vr,Ra),l=[Ms.x,Ms.y,Ms.z],Bd(l,Ca,al,ll,xh))}clampPoint(s,l){return l.copy(s).clamp(this.min,this.max)}distanceToPoint(s){return this.clampPoint(s,qs).distanceTo(s)}getBoundingSphere(s){return this.isEmpty()?s.makeEmpty():(this.getCenter(s.center),s.radius=this.getSize(qs).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:(fr[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(s),fr[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(s),fr[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(s),fr[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(s),fr[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(s),fr[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(s),fr[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(s),fr[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(s),this.setFromPoints(fr),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 fr=[new ne,new ne,new ne,new ne,new ne,new ne,new ne,new ne],qs=new ne,Ea=new ws,Ca=new ne,al=new ne,ll=new ne,Vr=new ne,Ra=new ne,Hc=new ne,cl=new ne,xh=new ne,Ms=new ne,Ar=new ne;function Bd(E,s,l,h,f){for(let g=0,_=E.length-3;g<=_;g+=3){Ar.fromArray(E,g);const b=f.x*Math.abs(Ar.x)+f.y*Math.abs(Ar.y)+f.z*Math.abs(Ar.z),w=s.dot(Ar),A=l.dot(Ar),C=h.dot(Ar);if(Math.max(-Math.max(w,A,C),Math.min(w,A,C))>b)return!1}return!0}const wp=new ws,yo=new ne,Od=new ne;class Os{constructor(s=new ne,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):wp.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;yo.subVectors(s,this.center);const l=yo.lengthSq();if(l>this.radius*this.radius){const h=Math.sqrt(l),f=(h-this.radius)*.5;this.center.addScaledVector(yo,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):(Od.subVectors(s.center,this.center).setLength(s.radius),this.expandByPoint(yo.copy(s.center).add(Od)),this.expandByPoint(yo.copy(s.center).sub(Od))),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 Xo=new ne,Hl=new ne,Vt=new ne,io=new ne,so=new ne,Mp=new ne,bg=new ne;class _o{constructor(s=new ne,l=new ne(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,Xo)),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=Xo.subVectors(s,this.origin).dot(this.direction);return l<0?this.origin.distanceToSquared(s):(Xo.copy(this.origin).addScaledVector(this.direction,l),Xo.distanceToSquared(s))}distanceSqToSegment(s,l,h,f){Hl.copy(s).add(l).multiplyScalar(.5),Vt.copy(l).sub(s).normalize(),io.copy(this.origin).sub(Hl);const g=s.distanceTo(l)*.5,_=-this.direction.dot(Vt),b=io.dot(this.direction),w=-io.dot(Vt),A=io.lengthSq(),C=Math.abs(1-_*_);let I,L,D,O;if(C>0)if(I=_*w-b,L=_*b-w,O=g*C,I>=0)if(L>=-O)if(L<=O){const G=1/C;I*=G,L*=G,D=I*(I+_*L+2*b)+L*(_*I+L+2*w)+A}else L=g,I=Math.max(0,-(_*L+b)),D=-I*I+L*(L+2*w)+A;else L=-g,I=Math.max(0,-(_*L+b)),D=-I*I+L*(L+2*w)+A;else L<=-O?(I=Math.max(0,-(-_*g+b)),L=I>0?-g:Math.min(Math.max(-g,-w),g),D=-I*I+L*(L+2*w)+A):L<=O?(I=0,L=Math.min(Math.max(-g,-w),g),D=L*(L+2*w)+A):(I=Math.max(0,-(_*g+b)),L=I>0?g:Math.min(Math.max(-g,-w),g),D=-I*I+L*(L+2*w)+A);else L=_>0?-g:g,I=Math.max(0,-(_*L+b)),D=-I*I+L*(L+2*w)+A;return h&&h.copy(this.origin).addScaledVector(this.direction,I),f&&f.copy(Hl).addScaledVector(Vt,L),D}intersectSphere(s,l){Xo.subVectors(s.center,this.origin);const h=Xo.dot(this.direction),f=Xo.dot(Xo)-h*h,g=s.radius*s.radius;if(f>g)return null;const _=Math.sqrt(g-f),b=h-_,w=h+_;return w<0?null:b<0?this.at(w,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,w;const A=1/this.direction.x,C=1/this.direction.y,I=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),C>=0?(g=(s.min.y-L.y)*C,_=(s.max.y-L.y)*C):(g=(s.max.y-L.y)*C,_=(s.min.y-L.y)*C),h>_||g>f||((g>h||isNaN(h))&&(h=g),(_<f||isNaN(f))&&(f=_),I>=0?(b=(s.min.z-L.z)*I,w=(s.max.z-L.z)*I):(b=(s.max.z-L.z)*I,w=(s.min.z-L.z)*I),h>w||b>f)||((b>h||h!==h)&&(h=b),(w<f||f!==f)&&(f=w),f<0)?null:this.at(h>=0?h:f,l)}intersectsBox(s){return this.intersectBox(s,Xo)!==null}intersectTriangle(s,l,h,f,g){so.subVectors(l,s),Mp.subVectors(h,s),bg.crossVectors(so,Mp);let _=this.direction.dot(bg),b;if(_>0){if(f)return null;b=1}else if(_<0)b=-1,_=-_;else return null;io.subVectors(this.origin,s);const w=b*this.direction.dot(Mp.crossVectors(io,Mp));if(w<0)return null;const A=b*this.direction.dot(so.cross(io));if(A<0||w+A>_)return null;const C=-b*io.dot(bg);return C<0?null:this.at(C/_,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 Pn{constructor(s,l,h,f,g,_,b,w,A,C,I,L,D,O,G,Z){Pn.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,w,A,C,I,L,D,O,G,Z)}set(s,l,h,f,g,_,b,w,A,C,I,L,D,O,G,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]=w,Y[2]=A,Y[6]=C,Y[10]=I,Y[14]=L,Y[3]=D,Y[7]=O,Y[11]=G,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 Pn().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/Xs.setFromMatrixColumn(s,0).length(),g=1/Xs.setFromMatrixColumn(s,1).length(),_=1/Xs.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),w=Math.cos(f),A=Math.sin(f),C=Math.cos(g),I=Math.sin(g);if(s.order==="XYZ"){const L=_*C,D=_*I,O=b*C,G=b*I;l[0]=w*C,l[4]=-w*I,l[8]=A,l[1]=D+O*A,l[5]=L-G*A,l[9]=-b*w,l[2]=G-L*A,l[6]=O+D*A,l[10]=_*w}else if(s.order==="YXZ"){const L=w*C,D=w*I,O=A*C,G=A*I;l[0]=L+G*b,l[4]=O*b-D,l[8]=_*A,l[1]=_*I,l[5]=_*C,l[9]=-b,l[2]=D*b-O,l[6]=G+L*b,l[10]=_*w}else if(s.order==="ZXY"){const L=w*C,D=w*I,O=A*C,G=A*I;l[0]=L-G*b,l[4]=-_*I,l[8]=O+D*b,l[1]=D+O*b,l[5]=_*C,l[9]=G-L*b,l[2]=-_*A,l[6]=b,l[10]=_*w}else if(s.order==="ZYX"){const L=_*C,D=_*I,O=b*C,G=b*I;l[0]=w*C,l[4]=O*A-D,l[8]=L*A+G,l[1]=w*I,l[5]=G*A+L,l[9]=D*A-O,l[2]=-A,l[6]=b*w,l[10]=_*w}else if(s.order==="YZX"){const L=_*w,D=_*A,O=b*w,G=b*A;l[0]=w*C,l[4]=G-L*I,l[8]=O*I+D,l[1]=I,l[5]=_*C,l[9]=-b*C,l[2]=-A*C,l[6]=D*I+O,l[10]=L-G*I}else if(s.order==="XZY"){const L=_*w,D=_*A,O=b*w,G=b*A;l[0]=w*C,l[4]=-I,l[8]=A*C,l[1]=L*I+G,l[5]=_*C,l[9]=D*I-O,l[2]=O*I-D,l[6]=b*C,l[10]=G*I+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(d0,s,Gr)}lookAt(s,l,h){const f=this.elements;return Hr.subVectors(s,l),Hr.lengthSq()===0&&(Hr.z=1),Hr.normalize(),Na.crossVectors(h,Hr),Na.lengthSq()===0&&(Math.abs(h.z)===1?Hr.x+=1e-4:Hr.z+=1e-4,Hr.normalize(),Na.crossVectors(h,Hr)),Na.normalize(),Ap.crossVectors(Hr,Na),f[0]=Na.x,f[4]=Ap.x,f[8]=Hr.x,f[1]=Na.y,f[5]=Ap.y,f[9]=Hr.y,f[2]=Na.z,f[6]=Ap.z,f[10]=Hr.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],w=h[8],A=h[12],C=h[1],I=h[5],L=h[9],D=h[13],O=h[2],G=h[6],Z=h[10],Y=h[14],Q=h[3],ee=h[7],ae=h[11],Re=h[15],Oe=f[0],je=f[4],He=f[8],ct=f[12],dt=f[1],tn=f[5],Mn=f[9],qn=f[13],di=f[2],bi=f[6],Es=f[10],ir=f[14],lo=f[3],es=f[7],Cs=f[11],ts=f[15];return g[0]=_*Oe+b*dt+w*di+A*lo,g[4]=_*je+b*tn+w*bi+A*es,g[8]=_*He+b*Mn+w*Es+A*Cs,g[12]=_*ct+b*qn+w*ir+A*ts,g[1]=C*Oe+I*dt+L*di+D*lo,g[5]=C*je+I*tn+L*bi+D*es,g[9]=C*He+I*Mn+L*Es+D*Cs,g[13]=C*ct+I*qn+L*ir+D*ts,g[2]=O*Oe+G*dt+Z*di+Y*lo,g[6]=O*je+G*tn+Z*bi+Y*es,g[10]=O*He+G*Mn+Z*Es+Y*Cs,g[14]=O*ct+G*qn+Z*ir+Y*ts,g[3]=Q*Oe+ee*dt+ae*di+Re*lo,g[7]=Q*je+ee*tn+ae*bi+Re*es,g[11]=Q*He+ee*Mn+ae*Es+Re*Cs,g[15]=Q*ct+ee*qn+ae*ir+Re*ts,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],w=s[9],A=s[13],C=s[2],I=s[6],L=s[10],D=s[14],O=s[3],G=s[7],Z=s[11],Y=s[15];return O*(+g*w*I-f*A*I-g*b*L+h*A*L+f*b*D-h*w*D)+G*(+l*w*D-l*A*L+g*_*L-f*_*D+f*A*C-g*w*C)+Z*(+l*A*I-l*b*D-g*_*I+h*_*D+g*b*C-h*A*C)+Y*(-f*b*C-l*w*I+l*b*L+f*_*I-h*_*L+h*w*C)}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],w=s[6],A=s[7],C=s[8],I=s[9],L=s[10],D=s[11],O=s[12],G=s[13],Z=s[14],Y=s[15],Q=I*Z*A-G*L*A+G*w*D-b*Z*D-I*w*Y+b*L*Y,ee=O*L*A-C*Z*A-O*w*D+_*Z*D+C*w*Y-_*L*Y,ae=C*G*A-O*I*A+O*b*D-_*G*D-C*b*Y+_*I*Y,Re=O*I*w-C*G*w-O*b*L+_*G*L+C*b*Z-_*I*Z,Oe=l*Q+h*ee+f*ae+g*Re;if(Oe===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const je=1/Oe;return s[0]=Q*je,s[1]=(G*L*g-I*Z*g-G*f*D+h*Z*D+I*f*Y-h*L*Y)*je,s[2]=(b*Z*g-G*w*g+G*f*A-h*Z*A-b*f*Y+h*w*Y)*je,s[3]=(I*w*g-b*L*g-I*f*A+h*L*A+b*f*D-h*w*D)*je,s[4]=ee*je,s[5]=(C*Z*g-O*L*g+O*f*D-l*Z*D-C*f*Y+l*L*Y)*je,s[6]=(O*w*g-_*Z*g-O*f*A+l*Z*A+_*f*Y-l*w*Y)*je,s[7]=(_*L*g-C*w*g+C*f*A-l*L*A-_*f*D+l*w*D)*je,s[8]=ae*je,s[9]=(O*I*g-C*G*g-O*h*D+l*G*D+C*h*Y-l*I*Y)*je,s[10]=(_*G*g-O*b*g+O*h*A-l*G*A-_*h*Y+l*b*Y)*je,s[11]=(C*b*g-_*I*g-C*h*A+l*I*A+_*h*D-l*b*D)*je,s[12]=Re*je,s[13]=(C*G*f-O*I*f+O*h*L-l*G*L-C*h*Z+l*I*Z)*je,s[14]=(O*b*f-_*G*f-O*h*w+l*G*w+_*h*Z-l*b*Z)*je,s[15]=(_*I*f-C*b*f+C*h*w-l*I*w-_*h*L+l*b*L)*je,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,w=s.z,A=g*_,C=g*b;return this.set(A*_+h,A*b-f*w,A*w+f*b,0,A*b+f*w,C*b+h,C*w-f*_,0,A*w-f*b,C*w+f*_,g*w*w+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,w=l._w,A=g+g,C=_+_,I=b+b,L=g*A,D=g*C,O=g*I,G=_*C,Z=_*I,Y=b*I,Q=w*A,ee=w*C,ae=w*I,Re=h.x,Oe=h.y,je=h.z;return f[0]=(1-(G+Y))*Re,f[1]=(D+ae)*Re,f[2]=(O-ee)*Re,f[3]=0,f[4]=(D-ae)*Oe,f[5]=(1-(L+Y))*Oe,f[6]=(Z+Q)*Oe,f[7]=0,f[8]=(O+ee)*je,f[9]=(Z-Q)*je,f[10]=(1-(L+G))*je,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=Xs.set(f[0],f[1],f[2]).length();const _=Xs.set(f[4],f[5],f[6]).length(),b=Xs.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],xo.copy(this);const A=1/g,C=1/_,I=1/b;return xo.elements[0]*=A,xo.elements[1]*=A,xo.elements[2]*=A,xo.elements[4]*=C,xo.elements[5]*=C,xo.elements[6]*=C,xo.elements[8]*=I,xo.elements[9]*=I,xo.elements[10]*=I,l.setFromRotationMatrix(xo),h.x=g,h.y=_,h.z=b,this}makePerspective(s,l,h,f,g,_,b=ki,w=!1){const A=this.elements,C=2*g/(l-s),I=2*g/(h-f),L=(l+s)/(l-s),D=(h+f)/(h-f);let O,G;if(w)O=g/(_-g),G=_*g/(_-g);else if(b===ki)O=-(_+g)/(_-g),G=-2*_*g/(_-g);else if(b===Sr)O=-_/(_-g),G=-_*g/(_-g);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+b);return A[0]=C,A[4]=0,A[8]=L,A[12]=0,A[1]=0,A[5]=I,A[9]=D,A[13]=0,A[2]=0,A[6]=0,A[10]=O,A[14]=G,A[3]=0,A[7]=0,A[11]=-1,A[15]=0,this}makeOrthographic(s,l,h,f,g,_,b=ki,w=!1){const A=this.elements,C=2/(l-s),I=2/(h-f),L=-(l+s)/(l-s),D=-(h+f)/(h-f);let O,G;if(w)O=1/(_-g),G=_/(_-g);else if(b===ki)O=-2/(_-g),G=-(_+g)/(_-g);else if(b===Sr)O=-1/(_-g),G=-g/(_-g);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+b);return A[0]=C,A[4]=0,A[8]=0,A[12]=L,A[1]=0,A[5]=I,A[9]=0,A[13]=D,A[2]=0,A[6]=0,A[10]=O,A[14]=G,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 Xs=new ne,xo=new Pn,d0=new ne(0,0,0),Gr=new ne(1,1,1),Na=new ne,Ap=new ne,Hr=new ne,Wc=new Pn,Pa=new zr;class ro{constructor(s=0,l=0,h=0,f=ro.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],w=f[1],A=f[5],C=f[9],I=f[2],L=f[6],D=f[10];switch(l){case"XYZ":this._y=Math.asin(Tn(b,-1,1)),Math.abs(b)<.9999999?(this._x=Math.atan2(-C,D),this._z=Math.atan2(-_,g)):(this._x=Math.atan2(L,A),this._z=0);break;case"YXZ":this._x=Math.asin(-Tn(C,-1,1)),Math.abs(C)<.9999999?(this._y=Math.atan2(b,D),this._z=Math.atan2(w,A)):(this._y=Math.atan2(-I,g),this._z=0);break;case"ZXY":this._x=Math.asin(Tn(L,-1,1)),Math.abs(L)<.9999999?(this._y=Math.atan2(-I,D),this._z=Math.atan2(-_,A)):(this._y=0,this._z=Math.atan2(w,g));break;case"ZYX":this._y=Math.asin(-Tn(I,-1,1)),Math.abs(I)<.9999999?(this._x=Math.atan2(L,D),this._z=Math.atan2(w,g)):(this._x=0,this._z=Math.atan2(-_,A));break;case"YZX":this._z=Math.asin(Tn(w,-1,1)),Math.abs(w)<.9999999?(this._x=Math.atan2(-C,A),this._y=Math.atan2(-I,g)):(this._x=0,this._y=Math.atan2(b,D));break;case"XZY":this._z=Math.asin(-Tn(_,-1,1)),Math.abs(_)<.9999999?(this._x=Math.atan2(L,A),this._y=Math.atan2(b,g)):(this._x=Math.atan2(-C,D),this._y=0);break;default:_n("Euler: .setFromRotationMatrix() encountered an unknown order: "+l)}return this._order=l,h===!0&&this._onChangeCallback(),this}setFromQuaternion(s,l,h){return Wc.makeRotationFromQuaternion(s),this.setFromRotationMatrix(Wc,l,h)}setFromVector3(s,l=this._order){return this.set(s.x,s.y,s.z,l)}reorder(s){return Pa.setFromEuler(this),this.setFromQuaternion(Pa,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}}ro.DEFAULT_ORDER="XYZ";class vh{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 Pb=0;const f0=new ne,$c=new zr,Ia=new Pn,Ud=new ne,bh=new ne,Ib=new ne,Sh=new zr,Ep=new ne(1,0,0),Hi=new ne(0,1,0),vo=new ne(0,0,1),La={type:"added"},Sg={type:"removed"},Wr={type:"childadded",child:null},Wl={type:"childremoved",child:null};class Wi extends Sp{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Pb++}),this.uuid=to(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Wi.DEFAULT_UP.clone();const s=new ne,l=new ro,h=new zr,f=new ne(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 Pn},normalMatrix:{value:new $s}}),this.matrix=new Pn,this.matrixWorld=new Pn,this.matrixAutoUpdate=Wi.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Wi.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new vh,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 $c.setFromAxisAngle(s,l),this.quaternion.multiply($c),this}rotateOnWorldAxis(s,l){return $c.setFromAxisAngle(s,l),this.quaternion.premultiply($c),this}rotateX(s){return this.rotateOnAxis(Ep,s)}rotateY(s){return this.rotateOnAxis(Hi,s)}rotateZ(s){return this.rotateOnAxis(vo,s)}translateOnAxis(s,l){return f0.copy(s).applyQuaternion(this.quaternion),this.position.add(f0.multiplyScalar(l)),this}translateX(s){return this.translateOnAxis(Ep,s)}translateY(s){return this.translateOnAxis(Hi,s)}translateZ(s){return this.translateOnAxis(vo,s)}localToWorld(s){return this.updateWorldMatrix(!0,!1),s.applyMatrix4(this.matrixWorld)}worldToLocal(s){return this.updateWorldMatrix(!0,!1),s.applyMatrix4(Ia.copy(this.matrixWorld).invert())}lookAt(s,l,h){s.isVector3?Ud.copy(s):Ud.set(s,l,h);const f=this.parent;this.updateWorldMatrix(!0,!1),bh.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Ia.lookAt(bh,Ud,this.up):Ia.lookAt(Ud,bh,this.up),this.quaternion.setFromRotationMatrix(Ia),f&&(Ia.extractRotation(f.matrixWorld),$c.setFromRotationMatrix(Ia),this.quaternion.premultiply($c.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(La),Wr.child=s,this.dispatchEvent(Wr),Wr.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(Sg),Wl.child=s,this.dispatchEvent(Wl),Wl.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),Ia.copy(this.matrixWorld).invert(),s.parent!==null&&(s.parent.updateWorldMatrix(!0,!1),Ia.multiply(s.parent.matrixWorld)),s.applyMatrix4(Ia),s.removeFromParent(),s.parent=this,this.children.push(s),s.updateWorldMatrix(!1,!0),s.dispatchEvent(La),Wr.child=s,this.dispatchEvent(Wr),Wr.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(bh,s,Ib),s}getWorldScale(s){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(bh,Sh,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=>_a(Ii({},b),{boundingBox:b.boundingBox?b.boundingBox.toJSON():void 0,boundingSphere:b.boundingSphere?b.boundingSphere.toJSON():void 0})),f.instanceInfo=this._instanceInfo.map(b=>Ii({},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,w){return b[w.uuid]===void 0&&(b[w.uuid]=w.toJSON(s)),w.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 w=b.shapes;if(Array.isArray(w))for(let A=0,C=w.length;A<C;A++){const I=w[A];g(s.shapes,I)}else g(s.shapes,w)}}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 w=0,A=this.material.length;w<A;w++)b.push(g(s.materials,this.material[w]));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 w=this.animations[b];f.animations.push(g(s.animations,w))}}if(l){const b=_(s.geometries),w=_(s.materials),A=_(s.textures),C=_(s.images),I=_(s.shapes),L=_(s.skeletons),D=_(s.animations),O=_(s.nodes);b.length>0&&(h.geometries=b),w.length>0&&(h.materials=w),A.length>0&&(h.textures=A),C.length>0&&(h.images=C),I.length>0&&(h.shapes=I),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 w=[];for(const A in b){const C=b[A];delete C.metadata,w.push(C)}return w}}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}}Wi.DEFAULT_UP=new ne(0,1,0),Wi.DEFAULT_MATRIX_AUTO_UPDATE=!0,Wi.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const bo=new ne,jo=new ne,kd=new ne,Yo=new ne,$l=new ne,ql=new ne,Cp=new ne,Er=new ne,Rp=new ne,Da=new ne,Th=new tr,zd=new tr,At=new tr;class Ci{constructor(s=new ne,l=new ne,h=new ne){this.a=s,this.b=l,this.c=h}static getNormal(s,l,h,f){f.subVectors(h,l),bo.subVectors(s,l),f.cross(bo);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){bo.subVectors(f,l),jo.subVectors(h,l),kd.subVectors(s,l);const _=bo.dot(bo),b=bo.dot(jo),w=bo.dot(kd),A=jo.dot(jo),C=jo.dot(kd),I=_*A-b*b;if(I===0)return g.set(0,0,0),null;const L=1/I,D=(A*w-b*C)*L,O=(_*C-b*w)*L;return g.set(1-D-O,O,D)}static containsPoint(s,l,h,f){return this.getBarycoord(s,l,h,f,Yo)===null?!1:Yo.x>=0&&Yo.y>=0&&Yo.x+Yo.y<=1}static getInterpolation(s,l,h,f,g,_,b,w){return this.getBarycoord(s,l,h,f,Yo)===null?(w.x=0,w.y=0,"z"in w&&(w.z=0),"w"in w&&(w.w=0),null):(w.setScalar(0),w.addScaledVector(g,Yo.x),w.addScaledVector(_,Yo.y),w.addScaledVector(b,Yo.z),w)}static getInterpolatedAttribute(s,l,h,f,g,_){return Th.setScalar(0),zd.setScalar(0),At.setScalar(0),Th.fromBufferAttribute(s,l),zd.fromBufferAttribute(s,h),At.fromBufferAttribute(s,f),_.setScalar(0),_.addScaledVector(Th,g.x),_.addScaledVector(zd,g.y),_.addScaledVector(At,g.z),_}static isFrontFacing(s,l,h,f){return bo.subVectors(h,l),jo.subVectors(s,l),bo.cross(jo).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 bo.subVectors(this.c,this.b),jo.subVectors(this.a,this.b),bo.cross(jo).length()*.5}getMidpoint(s){return s.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(s){return Ci.getNormal(this.a,this.b,this.c,s)}getPlane(s){return s.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(s,l){return Ci.getBarycoord(s,this.a,this.b,this.c,l)}getInterpolation(s,l,h,f,g){return Ci.getInterpolation(s,this.a,this.b,this.c,l,h,f,g)}containsPoint(s){return Ci.containsPoint(s,this.a,this.b,this.c)}isFrontFacing(s){return Ci.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;$l.subVectors(f,h),ql.subVectors(g,h),Er.subVectors(s,h);const w=$l.dot(Er),A=ql.dot(Er);if(w<=0&&A<=0)return l.copy(h);Rp.subVectors(s,f);const C=$l.dot(Rp),I=ql.dot(Rp);if(C>=0&&I<=C)return l.copy(f);const L=w*I-C*A;if(L<=0&&w>=0&&C<=0)return _=w/(w-C),l.copy(h).addScaledVector($l,_);Da.subVectors(s,g);const D=$l.dot(Da),O=ql.dot(Da);if(O>=0&&D<=O)return l.copy(g);const G=D*A-w*O;if(G<=0&&A>=0&&O<=0)return b=A/(A-O),l.copy(h).addScaledVector(ql,b);const Z=C*O-D*I;if(Z<=0&&I-C>=0&&D-O>=0)return Cp.subVectors(g,f),b=(I-C)/(I-C+(D-O)),l.copy(f).addScaledVector(Cp,b);const Y=1/(Z+G+L);return _=G*Y,b=L*Y,l.copy(h).addScaledVector($l,_).addScaledVector(ql,b)}equals(s){return s.a.equals(this.a)&&s.b.equals(this.b)&&s.c.equals(this.c)}}const p0={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},$i={h:0,s:0,l:0},js={h:0,s:0,l:0};function Zo(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 Un{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=Ei){return s=Math.floor(s),this.r=(s>>16&255)/255,this.g=(s>>8&255)/255,this.b=(s&255)/255,Bs.colorSpaceToWorking(this,l),this}setRGB(s,l,h,f=Bs.workingColorSpace){return this.r=s,this.g=l,this.b=h,Bs.colorSpaceToWorking(this,f),this}setHSL(s,l,h,f=Bs.workingColorSpace){if(s=mg(s,1),l=Tn(l,0,1),h=Tn(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=Zo(_,g,s+1/3),this.g=Zo(_,g,s),this.b=Zo(_,g,s-1/3)}return Bs.colorSpaceToWorking(this,f),this}setStyle(s,l=Ei){function h(g){g!==void 0&&parseFloat(g)<1&&_n("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:_n("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);_n("Color: Invalid hex color "+s)}else if(s&&s.length>0)return this.setColorName(s,l);return this}setColorName(s,l=Ei){const h=p0[s.toLowerCase()];return h!==void 0?this.setHex(h,l):_n("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=$o(s.r),this.g=$o(s.g),this.b=$o(s.b),this}copyLinearToSRGB(s){return this.r=_h(s.r),this.g=_h(s.g),this.b=_h(s.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(s=Ei){return Bs.workingToColorSpace(xi.copy(this),s),Math.round(Tn(xi.r*255,0,255))*65536+Math.round(Tn(xi.g*255,0,255))*256+Math.round(Tn(xi.b*255,0,255))}getHexString(s=Ei){return("000000"+this.getHex(s).toString(16)).slice(-6)}getHSL(s,l=Bs.workingColorSpace){Bs.workingToColorSpace(xi.copy(this),l);const h=xi.r,f=xi.g,g=xi.b,_=Math.max(h,f,g),b=Math.min(h,f,g);let w,A;const C=(b+_)/2;if(b===_)w=0,A=0;else{const I=_-b;switch(A=C<=.5?I/(_+b):I/(2-_-b),_){case h:w=(f-g)/I+(f<g?6:0);break;case f:w=(g-h)/I+2;break;case g:w=(h-f)/I+4;break}w/=6}return s.h=w,s.s=A,s.l=C,s}getRGB(s,l=Bs.workingColorSpace){return Bs.workingToColorSpace(xi.copy(this),l),s.r=xi.r,s.g=xi.g,s.b=xi.b,s}getStyle(s=Ei){Bs.workingToColorSpace(xi.copy(this),s);const l=xi.r,h=xi.g,f=xi.b;return s!==Ei?`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($i),this.setHSL($i.h+s,$i.s+l,$i.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($i),s.getHSL(js);const h=Id($i.h,js.h,l),f=Id($i.s,js.s,l),g=Id($i.l,js.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 xi=new Un;Un.NAMES=p0;let Vd=0;class Tg extends Sp{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Vd++}),this.uuid=to(),this.name="",this.type="Material",this.blending=qe,this.side=Be,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Kr,this.blendDst=Ss,this.blendEquation=Ot,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Un(0,0,0),this.blendAlpha=0,this.depthFunc=Jr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=bp,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=go,this.stencilZFail=go,this.stencilZPass=go,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){_n(`Material: parameter '${l}' has value of undefined.`);continue}const f=this[l];if(f===void 0){_n(`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!==qe&&(h.blending=this.blending),this.side!==Be&&(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!==Kr&&(h.blendSrc=this.blendSrc),this.blendDst!==Ss&&(h.blendDst=this.blendDst),this.blendEquation!==Ot&&(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!==Jr&&(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!==bp&&(h.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(h.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(h.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==go&&(h.stencilFail=this.stencilFail),this.stencilZFail!==go&&(h.stencilZFail=this.stencilZFail),this.stencilZPass!==go&&(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 w=g[b];delete w.metadata,_.push(w)}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 Di extends Tg{constructor(s){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Un(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 ro,this.combine=Rc,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 So=null;function X1(){const E=new ArrayBuffer(4),s=new Float32Array(E),l=new Uint32Array(E),h=new Uint32Array(512),f=new Uint32Array(512);for(let w=0;w<256;++w){const A=w-127;A<-27?(h[w]=0,h[w|256]=32768,f[w]=24,f[w|256]=24):A<-14?(h[w]=1024>>-A-14,h[w|256]=1024>>-A-14|32768,f[w]=-A-1,f[w|256]=-A-1):A<=15?(h[w]=A+15<<10,h[w|256]=A+15<<10|32768,f[w]=13,f[w|256]=13):A<128?(h[w]=31744,h[w|256]=64512,f[w]=24,f[w|256]=24):(h[w]=31744,h[w|256]=64512,f[w]=13,f[w|256]=13)}const g=new Uint32Array(2048),_=new Uint32Array(64),b=new Uint32Array(64);for(let w=1;w<1024;++w){let A=w<<13,C=0;for(;!(A&8388608);)A<<=1,C-=8388608;A&=-8388609,C+=947912704,g[w]=A|C}for(let w=1024;w<2048;++w)g[w]=939524096+(w-1024<<13);for(let w=1;w<31;++w)_[w]=w<<23;_[31]=1199570944,_[32]=2147483648;for(let w=33;w<63;++w)_[w]=2147483648+(w-32<<23);_[63]=3347054592;for(let w=1;w<64;++w)w!==32&&(b[w]=1024);return{floatView:s,uint32View:l,baseTable:h,shiftTable:f,mantissaTable:g,exponentTable:_,offsetTable:b}}function $n(E){Math.abs(E)>65504&&_n("DataUtils.toHalfFloat(): Value out of range."),E=Tn(E,-65504,65504),So.floatView[0]=E;const s=So.uint32View[0],l=s>>23&511;return So.baseTable[l]+((s&8388607)>>So.shiftTable[l])}function Np(E){const s=E>>10;return So.uint32View[0]=So.mantissaTable[So.offsetTable[s]+(E&1023)]+So.exponentTable[s],So.floatView[0]}class RD{static toHalfFloat(s){return $n(s)}static fromHalfFloat(s){return Np(s)}}const Us=new ne,wg=new pt;let Mg=0;class pr{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:Mg++}),this.name="",this.array=s,this.itemSize=l,this.count=s!==void 0?s.length/l:0,this.normalized=h,this.usage=kl,this.updateRanges=[],this.gpuType=mi,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++)wg.fromBufferAttribute(this,l),wg.applyMatrix3(s),this.setXY(l,wg.x,wg.y);else if(this.itemSize===3)for(let l=0,h=this.count;l<h;l++)Us.fromBufferAttribute(this,l),Us.applyMatrix3(s),this.setXYZ(l,Us.x,Us.y,Us.z);return this}applyMatrix4(s){for(let l=0,h=this.count;l<h;l++)Us.fromBufferAttribute(this,l),Us.applyMatrix4(s),this.setXYZ(l,Us.x,Us.y,Us.z);return this}applyNormalMatrix(s){for(let l=0,h=this.count;l<h;l++)Us.fromBufferAttribute(this,l),Us.applyNormalMatrix(s),this.setXYZ(l,Us.x,Us.y,Us.z);return this}transformDirection(s){for(let l=0,h=this.count;l<h;l++)Us.fromBufferAttribute(this,l),Us.transformDirection(s),this.setXYZ(l,Us.x,Us.y,Us.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=hr(h,this.array)),h}setComponent(s,l,h){return this.normalized&&(h=kn(h,this.array)),this.array[s*this.itemSize+l]=h,this}getX(s){let l=this.array[s*this.itemSize];return this.normalized&&(l=hr(l,this.array)),l}setX(s,l){return this.normalized&&(l=kn(l,this.array)),this.array[s*this.itemSize]=l,this}getY(s){let l=this.array[s*this.itemSize+1];return this.normalized&&(l=hr(l,this.array)),l}setY(s,l){return this.normalized&&(l=kn(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=hr(l,this.array)),l}setZ(s,l){return this.normalized&&(l=kn(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=hr(l,this.array)),l}setW(s,l){return this.normalized&&(l=kn(l,this.array)),this.array[s*this.itemSize+3]=l,this}setXY(s,l,h){return s*=this.itemSize,this.normalized&&(l=kn(l,this.array),h=kn(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=kn(l,this.array),h=kn(h,this.array),f=kn(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=kn(l,this.array),h=kn(h,this.array),f=kn(f,this.array),g=kn(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!==kl&&(s.usage=this.usage),s}}class m0 extends null{constructor(s,l,h){super(new Int8Array(s),l,h)}}class Lb extends null{constructor(s,l,h){super(new Uint8Array(s),l,h)}}class $t extends null{constructor(s,l,h){super(new Uint8ClampedArray(s),l,h)}}class j1 extends null{constructor(s,l,h){super(new Int16Array(s),l,h)}}class To extends pr{constructor(s,l,h){super(new Uint16Array(s),l,h)}}class g0 extends null{constructor(s,l,h){super(new Int32Array(s),l,h)}}class wh extends pr{constructor(s,l,h){super(new Uint32Array(s),l,h)}}class wo extends null{constructor(s,l,h){super(new Uint16Array(s),l,h),this.isFloat16BufferAttribute=!0}getX(s){let l=Np(this.array[s*this.itemSize]);return this.normalized&&(l=hr(l,this.array)),l}setX(s,l){return this.normalized&&(l=kn(l,this.array)),this.array[s*this.itemSize]=$n(l),this}getY(s){let l=Np(this.array[s*this.itemSize+1]);return this.normalized&&(l=hr(l,this.array)),l}setY(s,l){return this.normalized&&(l=kn(l,this.array)),this.array[s*this.itemSize+1]=$n(l),this}getZ(s){let l=Np(this.array[s*this.itemSize+2]);return this.normalized&&(l=hr(l,this.array)),l}setZ(s,l){return this.normalized&&(l=kn(l,this.array)),this.array[s*this.itemSize+2]=$n(l),this}getW(s){let l=Np(this.array[s*this.itemSize+3]);return this.normalized&&(l=hr(l,this.array)),l}setW(s,l){return this.normalized&&(l=kn(l,this.array)),this.array[s*this.itemSize+3]=$n(l),this}setXY(s,l,h){return s*=this.itemSize,this.normalized&&(l=kn(l,this.array),h=kn(h,this.array)),this.array[s+0]=$n(l),this.array[s+1]=$n(h),this}setXYZ(s,l,h,f){return s*=this.itemSize,this.normalized&&(l=kn(l,this.array),h=kn(h,this.array),f=kn(f,this.array)),this.array[s+0]=$n(l),this.array[s+1]=$n(h),this.array[s+2]=$n(f),this}setXYZW(s,l,h,f,g){return s*=this.itemSize,this.normalized&&(l=kn(l,this.array),h=kn(h,this.array),f=kn(f,this.array),g=kn(g,this.array)),this.array[s+0]=$n(l),this.array[s+1]=$n(h),this.array[s+2]=$n(f),this.array[s+3]=$n(g),this}}class Wt extends pr{constructor(s,l,h){super(new Float32Array(s),l,h)}}let Ys=0;const gn=new Pn,Pp=new Wi,Mo=new ne,mr=new ws,Mh=new ws,fs=new ne;class Gn extends Sp{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Ys++}),this.uuid=to(),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(wa(s)?wh:To)(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 $s().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 gn.makeRotationFromQuaternion(s),this.applyMatrix4(gn),this}rotateX(s){return gn.makeRotationX(s),this.applyMatrix4(gn),this}rotateY(s){return gn.makeRotationY(s),this.applyMatrix4(gn),this}rotateZ(s){return gn.makeRotationZ(s),this.applyMatrix4(gn),this}translate(s,l,h){return gn.makeTranslation(s,l,h),this.applyMatrix4(gn),this}scale(s,l,h){return gn.makeScale(s,l,h),this.applyMatrix4(gn),this}lookAt(s){return Pp.lookAt(s),Pp.updateMatrix(),this.applyMatrix4(Pp.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Mo).negate(),this.translate(Mo.x,Mo.y,Mo.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 Wt(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&&_n("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 ws);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 ne(-1/0,-1/0,-1/0),new ne(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];mr.setFromBufferAttribute(g),this.morphTargetsRelative?(fs.addVectors(this.boundingBox.min,mr.min),this.boundingBox.expandByPoint(fs),fs.addVectors(this.boundingBox.max,mr.max),this.boundingBox.expandByPoint(fs)):(this.boundingBox.expandByPoint(mr.min),this.boundingBox.expandByPoint(mr.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 Os);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 ne,1/0);return}if(s){const h=this.boundingSphere.center;if(mr.setFromBufferAttribute(s),l)for(let g=0,_=l.length;g<_;g++){const b=l[g];Mh.setFromBufferAttribute(b),this.morphTargetsRelative?(fs.addVectors(mr.min,Mh.min),mr.expandByPoint(fs),fs.addVectors(mr.max,Mh.max),mr.expandByPoint(fs)):(mr.expandByPoint(Mh.min),mr.expandByPoint(Mh.max))}mr.getCenter(h);let f=0;for(let g=0,_=s.count;g<_;g++)fs.fromBufferAttribute(s,g),f=Math.max(f,h.distanceToSquared(fs));if(l)for(let g=0,_=l.length;g<_;g++){const b=l[g],w=this.morphTargetsRelative;for(let A=0,C=b.count;A<C;A++)fs.fromBufferAttribute(b,A),w&&(Mo.fromBufferAttribute(s,A),fs.add(Mo)),f=Math.max(f,h.distanceToSquared(fs))}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 pr(new Float32Array(4*h.count),4));const _=this.getAttribute("tangent"),b=[],w=[];for(let He=0;He<h.count;He++)b[He]=new ne,w[He]=new ne;const A=new ne,C=new ne,I=new ne,L=new pt,D=new pt,O=new pt,G=new ne,Z=new ne;function Y(He,ct,dt){A.fromBufferAttribute(h,He),C.fromBufferAttribute(h,ct),I.fromBufferAttribute(h,dt),L.fromBufferAttribute(g,He),D.fromBufferAttribute(g,ct),O.fromBufferAttribute(g,dt),C.sub(A),I.sub(A),D.sub(L),O.sub(L);const tn=1/(D.x*O.y-O.x*D.y);isFinite(tn)&&(G.copy(C).multiplyScalar(O.y).addScaledVector(I,-D.y).multiplyScalar(tn),Z.copy(I).multiplyScalar(D.x).addScaledVector(C,-O.x).multiplyScalar(tn),b[He].add(G),b[ct].add(G),b[dt].add(G),w[He].add(Z),w[ct].add(Z),w[dt].add(Z))}let Q=this.groups;Q.length===0&&(Q=[{start:0,count:s.count}]);for(let He=0,ct=Q.length;He<ct;++He){const dt=Q[He],tn=dt.start,Mn=dt.count;for(let qn=tn,di=tn+Mn;qn<di;qn+=3)Y(s.getX(qn+0),s.getX(qn+1),s.getX(qn+2))}const ee=new ne,ae=new ne,Re=new ne,Oe=new ne;function je(He){Re.fromBufferAttribute(f,He),Oe.copy(Re);const ct=b[He];ee.copy(ct),ee.sub(Re.multiplyScalar(Re.dot(ct))).normalize(),ae.crossVectors(Oe,ct);const tn=ae.dot(w[He])<0?-1:1;_.setXYZW(He,ee.x,ee.y,ee.z,tn)}for(let He=0,ct=Q.length;He<ct;++He){const dt=Q[He],tn=dt.start,Mn=dt.count;for(let qn=tn,di=tn+Mn;qn<di;qn+=3)je(s.getX(qn+0)),je(s.getX(qn+1)),je(s.getX(qn+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 pr(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 ne,g=new ne,_=new ne,b=new ne,w=new ne,A=new ne,C=new ne,I=new ne;if(s)for(let L=0,D=s.count;L<D;L+=3){const O=s.getX(L+0),G=s.getX(L+1),Z=s.getX(L+2);f.fromBufferAttribute(l,O),g.fromBufferAttribute(l,G),_.fromBufferAttribute(l,Z),C.subVectors(_,g),I.subVectors(f,g),C.cross(I),b.fromBufferAttribute(h,O),w.fromBufferAttribute(h,G),A.fromBufferAttribute(h,Z),b.add(C),w.add(C),A.add(C),h.setXYZ(O,b.x,b.y,b.z),h.setXYZ(G,w.x,w.y,w.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),C.subVectors(_,g),I.subVectors(f,g),C.cross(I),h.setXYZ(L+0,C.x,C.y,C.z),h.setXYZ(L+1,C.x,C.y,C.z),h.setXYZ(L+2,C.x,C.y,C.z);this.normalizeNormals(),h.needsUpdate=!0}}normalizeNormals(){const s=this.attributes.normal;for(let l=0,h=s.count;l<h;l++)fs.fromBufferAttribute(s,l),fs.normalize(),s.setXYZ(l,fs.x,fs.y,fs.z)}toNonIndexed(){function s(b,w){const A=b.array,C=b.itemSize,I=b.normalized,L=new A.constructor(w.length*C);let D=0,O=0;for(let G=0,Z=w.length;G<Z;G++){b.isInterleavedBufferAttribute?D=w[G]*b.data.stride+b.offset:D=w[G]*C;for(let Y=0;Y<C;Y++)L[O++]=A[D++]}return new pr(L,C,I)}if(this.index===null)return _n("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const l=new Gn,h=this.index.array,f=this.attributes;for(const b in f){const w=f[b],A=s(w,h);l.setAttribute(b,A)}const g=this.morphAttributes;for(const b in g){const w=[],A=g[b];for(let C=0,I=A.length;C<I;C++){const L=A[C],D=s(L,h);w.push(D)}l.morphAttributes[b]=w}l.morphTargetsRelative=this.morphTargetsRelative;const _=this.groups;for(let b=0,w=_.length;b<w;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 w=this.parameters;for(const A in w)w[A]!==void 0&&(s[A]=w[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 w in h){const A=h[w];s.data.attributes[w]=A.toJSON(s.data)}const f={};let g=!1;for(const w in this.morphAttributes){const A=this.morphAttributes[w],C=[];for(let I=0,L=A.length;I<L;I++){const D=A[I];C.push(D.toJSON(s.data))}C.length>0&&(f[w]=C,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 C=f[A];this.setAttribute(A,C.clone(l))}const g=s.morphAttributes;for(const A in g){const C=[],I=g[A];for(let L=0,D=I.length;L<D;L++)C.push(I[L].clone(l));this.morphAttributes[A]=C}this.morphTargetsRelative=s.morphTargetsRelative;const _=s.groups;for(let A=0,C=_.length;A<C;A++){const I=_[A];this.addGroup(I.start,I.count,I.materialIndex)}const b=s.boundingBox;b!==null&&(this.boundingBox=b.clone());const w=s.boundingSphere;return w!==null&&(this.boundingSphere=w.clone()),this.drawRange.start=s.drawRange.start,this.drawRange.count=s.drawRange.count,this.userData=s.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const Gd=new Pn,ul=new _o,qc=new Os,Ag=new ne,Xc=new ne,vi=new ne,Ip=new ne,Ah=new ne,Ko=new ne,jc=new ne,Zs=new ne;class Xl extends Wi{constructor(s=new Gn,l=new Di){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){Ko.set(0,0,0);for(let w=0,A=g.length;w<A;w++){const C=b[w],I=g[w];C!==0&&(Ah.fromBufferAttribute(I,s),_?Ko.addScaledVector(Ah,C):Ko.addScaledVector(Ah.sub(l),C))}l.add(Ko)}return l}raycast(s,l){const h=this.geometry,f=this.material,g=this.matrixWorld;f!==void 0&&(h.boundingSphere===null&&h.computeBoundingSphere(),qc.copy(h.boundingSphere),qc.applyMatrix4(g),ul.copy(s.ray).recast(s.near),!(qc.containsPoint(ul.origin)===!1&&(ul.intersectSphere(qc,Ag)===null||ul.origin.distanceToSquared(Ag)>hb(s.far-s.near,2)))&&(Gd.copy(g).invert(),ul.copy(s.ray).applyMatrix4(Gd),!(h.boundingBox!==null&&ul.intersectsBox(h.boundingBox)===!1)&&this._computeIntersections(s,l,ul)))}_computeIntersections(s,l,h){let f;const g=this.geometry,_=this.material,b=g.index,w=g.attributes.position,A=g.attributes.uv,C=g.attributes.uv1,I=g.attributes.normal,L=g.groups,D=g.drawRange;if(b!==null)if(Array.isArray(_))for(let O=0,G=L.length;O<G;O++){const Z=L[O],Y=_[Z.materialIndex],Q=Math.max(Z.start,D.start),ee=Math.min(b.count,Math.min(Z.start+Z.count,D.start+D.count));for(let ae=Q,Re=ee;ae<Re;ae+=3){const Oe=b.getX(ae),je=b.getX(ae+1),He=b.getX(ae+2);f=Hd(this,Y,s,h,A,C,I,Oe,je,He),f&&(f.faceIndex=Math.floor(ae/3),f.face.materialIndex=Z.materialIndex,l.push(f))}}else{const O=Math.max(0,D.start),G=Math.min(b.count,D.start+D.count);for(let Z=O,Y=G;Z<Y;Z+=3){const Q=b.getX(Z),ee=b.getX(Z+1),ae=b.getX(Z+2);f=Hd(this,_,s,h,A,C,I,Q,ee,ae),f&&(f.faceIndex=Math.floor(Z/3),l.push(f))}}else if(w!==void 0)if(Array.isArray(_))for(let O=0,G=L.length;O<G;O++){const Z=L[O],Y=_[Z.materialIndex],Q=Math.max(Z.start,D.start),ee=Math.min(w.count,Math.min(Z.start+Z.count,D.start+D.count));for(let ae=Q,Re=ee;ae<Re;ae+=3){const Oe=ae,je=ae+1,He=ae+2;f=Hd(this,Y,s,h,A,C,I,Oe,je,He),f&&(f.faceIndex=Math.floor(ae/3),f.face.materialIndex=Z.materialIndex,l.push(f))}}else{const O=Math.max(0,D.start),G=Math.min(w.count,D.start+D.count);for(let Z=O,Y=G;Z<Y;Z+=3){const Q=Z,ee=Z+1,ae=Z+2;f=Hd(this,_,s,h,A,C,I,Q,ee,ae),f&&(f.faceIndex=Math.floor(Z/3),l.push(f))}}}}function y0(E,s,l,h,f,g,_,b){let w;if(s.side===Ee?w=h.intersectTriangle(_,g,f,!0,b):w=h.intersectTriangle(f,g,_,s.side===Be,b),w===null)return null;Zs.copy(b),Zs.applyMatrix4(E.matrixWorld);const A=l.ray.origin.distanceTo(Zs);return A<l.near||A>l.far?null:{distance:A,point:Zs.clone(),object:E}}function Hd(E,s,l,h,f,g,_,b,w,A){E.getVertexPosition(b,Xc),E.getVertexPosition(w,vi),E.getVertexPosition(A,Ip);const C=y0(E,s,l,h,Xc,vi,Ip,jc);if(C){const I=new ne;Ci.getBarycoord(jc,Xc,vi,Ip,I),f&&(C.uv=Ci.getInterpolatedAttribute(f,b,w,A,I,new pt)),g&&(C.uv1=Ci.getInterpolatedAttribute(g,b,w,A,I,new pt)),_&&(C.normal=Ci.getInterpolatedAttribute(_,b,w,A,I,new ne),C.normal.dot(h.direction)>0&&C.normal.multiplyScalar(-1));const L={a:b,b:w,c:A,normal:new ne,materialIndex:0};Ci.getNormal(Xc,vi,Ip,L.normal),C.face=L,C.barycoord=I}return C}class Lp extends Gn{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 w=[],A=[],C=[],I=[];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(w),this.setAttribute("position",new Wt(A,3)),this.setAttribute("normal",new Wt(C,3)),this.setAttribute("uv",new Wt(I,2));function O(G,Z,Y,Q,ee,ae,Re,Oe,je,He,ct){const dt=ae/je,tn=Re/He,Mn=ae/2,qn=Re/2,di=Oe/2,bi=je+1,Es=He+1;let ir=0,lo=0;const es=new ne;for(let Cs=0;Cs<Es;Cs++){const ts=Cs*tn-qn;for(let ra=0;ra<bi;ra++){const Io=ra*dt-Mn;es[G]=Io*Q,es[Z]=ts*ee,es[Y]=di,A.push(es.x,es.y,es.z),es[G]=0,es[Z]=0,es[Y]=Oe>0?1:-1,C.push(es.x,es.y,es.z),I.push(ra/je),I.push(1-Cs/He),ir+=1}}for(let Cs=0;Cs<He;Cs++)for(let ts=0;ts<je;ts++){const ra=L+ts+bi*Cs,Io=L+ts+bi*(Cs+1),oc=L+(ts+1)+bi*(Cs+1),Lf=L+(ts+1)+bi*Cs;w.push(ra,Io,Lf),w.push(Io,oc,Lf),lo+=6}b.addGroup(D,lo,ct),D+=lo,L+=ir}}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}static fromJSON(s){return new Lp(s.width,s.height,s.depth,s.widthSegments,s.heightSegments,s.depthSegments)}}function Dp(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?(_n("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 Jo(E){const s={};for(let l=0;l<E.length;l++){const h=Dp(E[l]);for(const f in h)s[f]=h[f]}return s}function Fp(E){const s=[];for(let l=0;l<E.length;l++)s.push(E[l].clone());return s}function Yc(E){const s=E.getRenderTarget();return s===null?E.outputColorSpace:s.isXRRenderTarget===!0?s.texture.colorSpace:Bs.workingColorSpace}const Db={clone:Dp,merge:Jo};var _0=`void main() {
|
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
}`,ps=`void main() {
|
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
}`;class Zc extends null{constructor(s){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=_0,this.fragmentShader=ps,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=Dp(s.uniforms),this.uniformsGroups=Fp(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 Eh extends Wi{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Pn,this.projectionMatrix=new Pn,this.projectionMatrixInverse=new Pn,this.coordinateSystem=ki,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 hl=new ne,jl=new pt,Eg=new pt;class nr 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=Pd*2*Math.atan(l),this.updateProjectionMatrix()}getFocalLength(){const s=Math.tan(zc*.5*this.fov);return .5*this.getFilmHeight()/s}getEffectiveFOV(){return Pd*2*Math.atan(Math.tan(zc*.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){hl.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),l.set(hl.x,hl.y).multiplyScalar(-s/hl.z),hl.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),h.set(hl.x,hl.y).multiplyScalar(-s/hl.z)}getViewSize(s,l){return this.getViewBounds(s,jl,Eg),l.subVectors(Eg,jl)}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(zc*.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 w=_.fullWidth,A=_.fullHeight;g+=_.offsetX*f/w,l-=_.offsetY*h/A,f*=_.width/w,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 Ch=null,dl=1;class Cg extends null{constructor(s,l,h){super(),this.type="CubeCamera",this.renderTarget=h,this.coordinateSystem=null,this.activeMipmapLevel=0;const f=new nr(Ch,dl,s,l);f.layers=this.layers,this.add(f);const g=new nr(Ch,dl,s,l);g.layers=this.layers,this.add(g);const _=new nr(Ch,dl,s,l);_.layers=this.layers,this.add(_);const b=new nr(Ch,dl,s,l);b.layers=this.layers,this.add(b);const w=new nr(Ch,dl,s,l);w.layers=this.layers,this.add(w);const A=new nr(Ch,dl,s,l);A.layers=this.layers,this.add(A)}updateCoordinateSystem(){const s=this.coordinateSystem,l=this.children.concat(),[h,f,g,_,b,w]=l;for(const A of l)this.remove(A);if(s===ki)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),w.up.set(0,1,0),w.lookAt(0,0,-1);else if(s===Sr)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),w.up.set(0,-1,0),w.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,w,A,C]=this.children,I=s.getRenderTarget(),L=s.getActiveCubeFace(),D=s.getActiveMipmapLevel(),O=s.xr.enabled;s.xr.enabled=!1;const G=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,w),s.setRenderTarget(h,4,f),s.render(l,A),h.texture.generateMipmaps=G,s.setRenderTarget(h,5,f),s.render(l,C),s.setRenderTarget(I,L,D),s.xr.enabled=O,h.texture.needsPMREMUpdate=!0}}class Wd extends null{constructor(s=[],l=Br,h,f,g,_,b,w,A,C){super(s,l,h,f,g,_,b,w,A,C),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(s){this.image=s}}class Bp 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 Wd(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 Lp(5,5,5),g=new Zc({name:"CubemapFromEquirect",uniforms:Dp(h.uniforms),vertexShader:h.vertexShader,fragmentShader:h.fragmentShader,side:Ee,blending:Ae});g.uniforms.tEquirect.value=l;const _=new Xl(f,g),b=l.minFilter;return l.minFilter===Ds&&(l.minFilter=Yn),new Cg(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 fl extends Wi{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Cr={type:"move"};class Rh{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new fl,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 fl,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new ne,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new ne),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new fl,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new ne,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new ne),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,w=this._grip,A=this._hand;if(s&&l.session.visibilityState!=="visible-blurred"){if(A&&s.hand){_=!0;for(const G of s.hand.values()){const Z=l.getJointPose(G,h),Y=this._getHandJoint(A,G);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 C=A.joints["index-finger-tip"],I=A.joints["thumb-tip"],L=C.position.distanceTo(I.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 w!==null&&s.gripSpace&&(g=l.getPose(s.gripSpace,h),g!==null&&(w.matrix.fromArray(g.transform.matrix),w.matrix.decompose(w.position,w.rotation,w.scale),w.matrixWorldNeedsUpdate=!0,g.linearVelocity?(w.hasLinearVelocity=!0,w.linearVelocity.copy(g.linearVelocity)):w.hasLinearVelocity=!1,g.angularVelocity?(w.hasAngularVelocity=!0,w.angularVelocity.copy(g.angularVelocity)):w.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(Cr)))}return b!==null&&(b.visible=f!==null),w!==null&&(w.visible=g!==null),A!==null&&(A.visible=_!==null),this}_getHandJoint(s,l){if(s.joints[l.jointName]===void 0){const h=new fl;h.matrixAutoUpdate=!1,h.visible=!1,s.joints[l.jointName]=h,s.add(h)}return s.joints[l.jointName]}}class $d{constructor(s,l=25e-5){this.isFogExp2=!0,this.name="",this.color=new Un(s),this.density=l}clone(){return new $d(this.color,this.density)}toJSON(){return{type:"FogExp2",name:this.name,color:this.color.getHex(),density:this.density}}}class Yl{constructor(s,l=1,h=1e3){this.isFog=!0,this.name="",this.color=new Un(s),this.near=l,this.far=h}clone(){return new Yl(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class qd 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 ro,this.environmentIntensity=1,this.environmentRotation=new ro,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 Kc{constructor(s,l){this.isInterleavedBuffer=!0,this.array=s,this.stride=l,this.count=s!==void 0?s.length/l:0,this.usage=kl,this.updateRanges=[],this.version=0,this.uuid=to()}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=to()),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=to()),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 As=new ne;class Qo{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++)As.fromBufferAttribute(this,l),As.applyMatrix4(s),this.setXYZ(l,As.x,As.y,As.z);return this}applyNormalMatrix(s){for(let l=0,h=this.count;l<h;l++)As.fromBufferAttribute(this,l),As.applyNormalMatrix(s),this.setXYZ(l,As.x,As.y,As.z);return this}transformDirection(s){for(let l=0,h=this.count;l<h;l++)As.fromBufferAttribute(this,l),As.transformDirection(s),this.setXYZ(l,As.x,As.y,As.z);return this}getComponent(s,l){let h=this.array[s*this.data.stride+this.offset+l];return this.normalized&&(h=hr(h,this.array)),h}setComponent(s,l,h){return this.normalized&&(h=kn(h,this.array)),this.data.array[s*this.data.stride+this.offset+l]=h,this}setX(s,l){return this.normalized&&(l=kn(l,this.array)),this.data.array[s*this.data.stride+this.offset]=l,this}setY(s,l){return this.normalized&&(l=kn(l,this.array)),this.data.array[s*this.data.stride+this.offset+1]=l,this}setZ(s,l){return this.normalized&&(l=kn(l,this.array)),this.data.array[s*this.data.stride+this.offset+2]=l,this}setW(s,l){return this.normalized&&(l=kn(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=hr(l,this.array)),l}getY(s){let l=this.data.array[s*this.data.stride+this.offset+1];return this.normalized&&(l=hr(l,this.array)),l}getZ(s){let l=this.data.array[s*this.data.stride+this.offset+2];return this.normalized&&(l=hr(l,this.array)),l}getW(s){let l=this.data.array[s*this.data.stride+this.offset+3];return this.normalized&&(l=hr(l,this.array)),l}setXY(s,l,h){return s=s*this.data.stride+this.offset,this.normalized&&(l=kn(l,this.array),h=kn(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=kn(l,this.array),h=kn(h,this.array),f=kn(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=kn(l,this.array),h=kn(h,this.array),f=kn(f,this.array),g=kn(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){o0("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 pr(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 Qo(s.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(s){if(s===void 0){o0("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 Jc extends Tg{constructor(s){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Un(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 Qc;const Zl=new ne,Fa=new ne,pl=new ne,eu=new pt,tu=new pt,Rg=new Pn,Op=new ne,Kl=new ne,nu=new ne,Ng=new pt,Pg=new pt,Ig=new pt;class Lg extends Wi{constructor(s=new Jc){if(super(),this.isSprite=!0,this.type="Sprite",Qc===void 0){Qc=new Gn;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 Kc(l,5);Qc.setIndex([0,1,2,0,2,3]),Qc.setAttribute("position",new Qo(h,3,0,!1)),Qc.setAttribute("uv",new Qo(h,2,3,!1))}this.geometry=Qc,this.material=s,this.center=new pt(.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.'),Fa.setFromMatrixScale(this.matrixWorld),Rg.copy(s.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(s.camera.matrixWorldInverse,this.matrixWorld),pl.setFromMatrixPosition(this.modelViewMatrix),s.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Fa.multiplyScalar(-pl.z);const h=this.material.rotation;let f,g;h!==0&&(g=Math.cos(h),f=Math.sin(h));const _=this.center;Xd(Op.set(-.5,-.5,0),pl,_,Fa,f,g),Xd(Kl.set(.5,-.5,0),pl,_,Fa,f,g),Xd(nu.set(.5,.5,0),pl,_,Fa,f,g),Ng.set(0,0),Pg.set(1,0),Ig.set(1,1);let b=s.ray.intersectTriangle(Op,Kl,nu,!1,Zl);if(b===null&&(Xd(Kl.set(-.5,.5,0),pl,_,Fa,f,g),Pg.set(0,1),b=s.ray.intersectTriangle(Op,nu,Kl,!1,Zl),b===null))return;const w=s.ray.origin.distanceTo(Zl);w<s.near||w>s.far||l.push({distance:w,point:Zl.clone(),uv:Ci.getInterpolation(Zl,Op,Kl,nu,Ng,Pg,Ig,new pt),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 Xd(E,s,l,h,f,g){eu.subVectors(E,l).addScalar(.5).multiply(h),f!==void 0?(tu.x=g*eu.x-f*eu.y,tu.y=f*eu.x+g*eu.y):tu.copy(eu),E.copy(s),E.x+=tu.x,E.y+=tu.y,E.applyMatrix4(Rg)}const Up=new ne,Dg=new ne;class kp 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){Up.setFromMatrixPosition(this.matrixWorld);const f=s.ray.origin.distanceTo(Up);this.getObjectForDistance(f).raycast(s,l)}}update(s){const l=this.levels;if(l.length>1){Up.setFromMatrixPosition(s.matrixWorld),Dg.setFromMatrixPosition(this.matrixWorld);const h=Up.distanceTo(Dg)/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 zp=new ne,Fg=new tr,Vp=new tr,Fb=new ne,Bg=new Pn,oo=new ne,Gp=new Os,x0=new Pn,jd=new _o;class ea extends null{constructor(s,l){super(s,l),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=lg,this.bindMatrix=new Pn,this.bindMatrixInverse=new Pn,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const s=this.geometry;this.boundingBox===null&&(this.boundingBox=new ws),this.boundingBox.makeEmpty();const l=s.getAttribute("position");for(let h=0;h<l.count;h++)this.getVertexPosition(h,oo),this.boundingBox.expandByPoint(oo)}computeBoundingSphere(){const s=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Os),this.boundingSphere.makeEmpty();const l=s.getAttribute("position");for(let h=0;h<l.count;h++)this.getVertexPosition(h,oo),this.boundingSphere.expandByPoint(oo)}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(),Gp.copy(this.boundingSphere),Gp.applyMatrix4(f),s.ray.intersectsSphere(Gp)!==!1&&(x0.copy(f).invert(),jd.copy(s.ray).applyMatrix4(x0),!(this.boundingBox!==null&&jd.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(s,l,jd)))}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 tr,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===lg?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===vb?this.bindMatrixInverse.copy(this.bindMatrix).invert():_n("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(s,l){const h=this.skeleton,f=this.geometry;Fg.fromBufferAttribute(f.attributes.skinIndex,s),Vp.fromBufferAttribute(f.attributes.skinWeight,s),zp.copy(l).applyMatrix4(this.bindMatrix),l.set(0,0,0);for(let g=0;g<4;g++){const _=Vp.getComponent(g);if(_!==0){const b=Fg.getComponent(g);Bg.multiplyMatrices(h.bones[b].matrixWorld,h.boneInverses[b]),l.addScaledVector(Fb.copy(zp).applyMatrix4(Bg),_)}}return l.applyMatrix4(this.bindMatrixInverse)}}class iu extends null{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Ba extends null{constructor(s=null,l=1,h=1,f,g,_,b,w,A=Jn,C=Jn,I,L){super(null,_,b,w,A,C,f,g,I,L),this.isDataTexture=!0,this.image={data:s,width:l,height:h},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Yd=new Pn,v0=new Pn;class Og{constructor(s=[],l=[]){this.uuid=to(),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){_n("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 Pn)}}calculateInverses(){this.boneInverses.length=0;for(let s=0,l=this.bones.length;s<l;s++){const h=new Pn;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:v0;Yd.multiplyMatrices(b,l[g]),Yd.toArray(h,g*16)}f!==null&&(f.needsUpdate=!0)}clone(){return new Og(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 Ba(l,s,s,_i,mi);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&&(_n("Skeleton: No bone found with UUID:",g),_=new iu),this.bones.push(_),this.boneInverses.push(new Pn().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 ml 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 Oa=new Pn,b0=new Pn,Nh=null,S0=new ws,Bb=new Pn,Rr=new Xl,ta=new Os;class Ob extends null{constructor(s,l,h){super(s,l),this.isInstancedMesh=!0,this.instanceMatrix=new ml(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,Bb)}computeBoundingBox(){const s=this.geometry,l=this.count;this.boundingBox===null&&(this.boundingBox=new ws),s.boundingBox===null&&s.computeBoundingBox(),this.boundingBox.makeEmpty();for(let h=0;h<l;h++)this.getMatrixAt(h,Oa),S0.copy(s.boundingBox).applyMatrix4(Oa),this.boundingBox.union(S0)}computeBoundingSphere(){const s=this.geometry,l=this.count;this.boundingSphere===null&&(this.boundingSphere=new Os),s.boundingSphere===null&&s.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let h=0;h<l;h++)this.getMatrixAt(h,Oa),ta.copy(s.boundingSphere).applyMatrix4(Oa),this.boundingSphere.union(ta)}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(Rr.geometry=this.geometry,Rr.material=this.material,Rr.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ta.copy(this.boundingSphere),ta.applyMatrix4(h),s.ray.intersectsSphere(ta)!==!1))for(let g=0;g<f;g++){this.getMatrixAt(g,Oa),b0.multiplyMatrices(h,Oa),Rr.matrixWorld=b0,Rr.raycast(s,Nh);for(let _=0,b=Nh.length;_<b;_++){const w=Nh[_];w.instanceId=g,w.object=this,l.push(w)}Nh.length=0}}setColorAt(s,l){this.instanceColor===null&&(this.instanceColor=new ml(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 Ba(new Float32Array(f*this.count),f,this.count,Fc,mi));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-_,w=f*s;g[w]=b,g.set(h,w+1)}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Ph=new ne,Ih=new ne,Ua=new $s;class Nr{constructor(s=new ne(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=Ph.subVectors(h,l).cross(Ih.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(Ph),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||Ua.getNormalMatrix(s),f=this.coplanarPoint(Ph).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 ka=new Os,Ug=new pt(.5,.5),Hp=new ne;class kg{constructor(s=new Nr,l=new Nr,h=new Nr,f=new Nr,g=new Nr,_=new Nr){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=ki,h=!1){const f=this.planes,g=s.elements,_=g[0],b=g[1],w=g[2],A=g[3],C=g[4],I=g[5],L=g[6],D=g[7],O=g[8],G=g[9],Z=g[10],Y=g[11],Q=g[12],ee=g[13],ae=g[14],Re=g[15];if(f[0].setComponents(A-_,D-C,Y-O,Re-Q).normalize(),f[1].setComponents(A+_,D+C,Y+O,Re+Q).normalize(),f[2].setComponents(A+b,D+I,Y+G,Re+ee).normalize(),f[3].setComponents(A-b,D-I,Y-G,Re-ee).normalize(),h)f[4].setComponents(w,L,Z,ae).normalize(),f[5].setComponents(A-w,D-L,Y-Z,Re-ae).normalize();else if(f[4].setComponents(A-w,D-L,Y-Z,Re-ae).normalize(),l===ki)f[5].setComponents(A+w,D+L,Y+Z,Re+ae).normalize();else if(l===Sr)f[5].setComponents(w,L,Z,ae).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(),ka.copy(s.boundingSphere).applyMatrix4(s.matrixWorld);else{const l=s.geometry;l.boundingSphere===null&&l.computeBoundingSphere(),ka.copy(l.boundingSphere).applyMatrix4(s.matrixWorld)}return this.intersectsSphere(ka)}intersectsSprite(s){ka.center.set(0,0,0);const l=Ug.distanceTo(s.center);return ka.radius=.7071067811865476+l,ka.applyMatrix4(s.matrixWorld),this.intersectsSphere(ka)}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(Hp.x=f.normal.x>0?s.max.x:s.min.x,Hp.y=f.normal.y>0?s.max.y:s.min.y,Hp.z=f.normal.z>0?s.max.z:s.min.z,f.distanceToPoint(Hp)<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 za=new Pn,Ji=new kg;class zg{constructor(){this.coordinateSystem=ki}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(za.multiplyMatrices(f.projectionMatrix,f.matrixWorldInverse),Ji.setFromProjectionMatrix(za,f.coordinateSystem,f.reversedDepth),Ji.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(za.multiplyMatrices(f.projectionMatrix,f.matrixWorldInverse),Ji.setFromProjectionMatrix(za,f.coordinateSystem,f.reversedDepth),Ji.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(za.multiplyMatrices(f.projectionMatrix,f.matrixWorldInverse),Ji.setFromProjectionMatrix(za,f.coordinateSystem,f.reversedDepth),Ji.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(za.multiplyMatrices(f.projectionMatrix,f.matrixWorldInverse),Ji.setFromProjectionMatrix(za,f.coordinateSystem,f.reversedDepth),Ji.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(za.multiplyMatrices(f.projectionMatrix,f.matrixWorldInverse),Ji.setFromProjectionMatrix(za,f.coordinateSystem,f.reversedDepth),Ji.containsPoint(s))return!0}return!1}clone(){return new zg}}function Wp(E,s){return E-s}function Ub(E,s){return E.z-s.z}function $p(E,s){return s.z-E.z}class su{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 Ks=new Pn,T0=new Un(1,1,1),w0=new kg,Vg=new zg,ks=new ws,Va=new Os,Zd=new ne,Jl=new ne,kb=new ne,Js=new su,zs=new Xl,ru=null;function M0(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 na(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 qp extends null{constructor(s,l,h=l*2,f){super(new Gn,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 Ba(l,s,s,_i,mi);this._matricesTexture=h}_initIndirectTexture(){let s=Math.sqrt(this._maxInstanceCount);s=Math.ceil(s);const l=new Uint32Array(s*s),h=new Ba(l,s,s,Dl,pi);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 Ba(l,s,s,_i,mi);h.colorSpace=Bs.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:w,normalized:A}=_,C=new b.constructor(h*w),I=new pr(C,w,A);l.setAttribute(g,I)}if(s.getIndex()!==null){const g=h>65535?new Uint32Array(f):new Uint16Array(f);l.setIndex(new pr(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 ws);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,Ks),this.getBoundingBoxAt(g,ks).applyMatrix4(Ks),s.union(ks)}}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new Os);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,Ks),this.getBoundingSphereAt(g,Va).applyMatrix4(Ks),s.union(Va)}}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(Wp),f=this._availableInstanceIds.shift(),this._instanceInfo[f]=h):(f=this._instanceInfo.length,this._instanceInfo.push(h));const g=this._matricesTexture;Ks.identity().toArray(g.image.data,f*16),g.needsUpdate=!0;const _=this._colorsTexture;return _&&(T0.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 w;return this._availableGeometryIds.length>0?(this._availableGeometryIds.sort(Wp),w=this._availableGeometryIds.shift(),g[w]=f):(w=this._geometryCount,this._geometryCount++,g.push(f)),this.setGeometryAt(w,s),this._nextIndexStart=f.indexStart+f.reservedIndexCount,this._nextVertexStart=f.vertexStart+f.reservedVertexCount,w}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 w=b.vertexStart,A=b.reservedVertexCount;b.vertexCount=l.getAttribute("position").count;for(const C in h.attributes){const I=l.getAttribute(C),L=h.getAttribute(C);M0(I,L,w);const D=I.itemSize;for(let O=I.count,G=A;O<G;O++){const Z=w+O;for(let Y=0;Y<D;Y++)L.setComponent(Z,Y,0)}L.needsUpdate=!0,L.addUpdateRange(w*D,A*D)}if(f){const C=b.indexStart,I=b.reservedIndexCount;b.indexCount=l.getIndex().count;for(let L=0;L<_.count;L++)g.setX(C+L,w+_.getX(L));for(let L=_.count,D=I;L<D;L++)g.setX(C+L,w);g.needsUpdate=!0,g.addUpdateRange(C,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 w=f[_],A=h[w];if(A.active!==!1){if(g.index!==null){if(A.indexStart!==l){const{indexStart:C,vertexStart:I,reservedIndexCount:L}=A,D=g.index,O=D.array,G=s-I;for(let Z=C;Z<C+L;Z++)O[Z]=O[Z]+G;D.array.copyWithin(l,C,C+L),D.addUpdateRange(l,L),A.indexStart=l}l+=A.reservedIndexCount}if(A.vertexStart!==s){const{vertexStart:C,reservedVertexCount:I}=A,L=g.attributes;for(const D in L){const O=L[D],{array:G,itemSize:Z}=O;G.copyWithin(s*Z,C*Z,(C+I)*Z),O.addUpdateRange(s*Z,I*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 ws,_=h.index,b=h.attributes.position;for(let w=f.start,A=f.start+f.count;w<A;w++){let C=w;_&&(C=_.getX(C)),g.expandByPoint(Zd.fromBufferAttribute(b,C))}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 Os;this.getBoundingBoxAt(s,ks),ks.getCenter(g.center);const _=h.index,b=h.attributes.position;let w=0;for(let A=f.start,C=f.start+f.count;A<C;A++){let I=A;_&&(I=_.getX(I)),Zd.fromBufferAttribute(b,I),w=Math.max(w,g.center.distanceToSquared(Zd))}g.radius=Math.sqrt(w),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(Wp);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);na(this._multiDrawCounts,f),na(this._multiDrawStarts,g),this._multiDrawCounts=f,this._multiDrawStarts=g,this._maxInstanceCount=s;const _=this._indirectTexture,b=this._matricesTexture,w=this._colorsTexture;_.dispose(),this._initIndirectTexture(),na(_.image.data,this._indirectTexture.image.data),b.dispose(),this._initMatricesTexture(),na(b.image.data,this._matricesTexture.image.data),w&&(w.dispose(),this._initColorsTexture(),na(w.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(w=>w.indexStart+w.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 Gn,this._initializeGeometry(g));const _=this.geometry;g.index&&na(g.index.array,_.index.array);for(const b in g.attributes)na(g.attributes[b].array,_.attributes[b].array)}raycast(s,l){const h=this._instanceInfo,f=this._geometryInfo,g=this.matrixWorld,_=this.geometry;zs.material=this.material,zs.geometry.index=_.index,zs.geometry.attributes=_.attributes,zs.geometry.boundingBox===null&&(zs.geometry.boundingBox=new ws),zs.geometry.boundingSphere===null&&(zs.geometry.boundingSphere=new Os);for(let b=0,w=h.length;b<w;b++){if(!h[b].visible||!h[b].active)continue;const A=h[b].geometryIndex,C=f[A];zs.geometry.setDrawRange(C.start,C.count),this.getMatrixAt(b,zs.matrixWorld).premultiply(g),this.getBoundingBoxAt(A,zs.geometry.boundingBox),this.getBoundingSphereAt(A,zs.geometry.boundingSphere),zs.raycast(s,ru);for(let I=0,L=ru.length;I<L;I++){const D=ru[I];D.object=this,D.batchId=b,l.push(D)}ru.length=0}zs.material=null,zs.geometry.index=null,zs.geometry.attributes={},zs.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=>_a(Ii({},l),{boundingBox:l.boundingBox!==null?l.boundingBox.clone():null,boundingSphere:l.boundingSphere!==null?l.boundingSphere.clone():null})),this._instanceInfo=s._instanceInfo.map(l=>Ii({},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,w=this._instanceInfo,A=this._multiDrawStarts,C=this._multiDrawCounts,I=this._geometryInfo,L=this.perObjectFrustumCulled,D=this._indirectTexture,O=D.image.data,G=h.isArrayCamera?Vg:w0;L&&!h.isArrayCamera&&(Ks.multiplyMatrices(h.projectionMatrix,h.matrixWorldInverse).multiply(this.matrixWorld),w0.setFromProjectionMatrix(Ks,h.coordinateSystem,h.reversedDepth));let Z=0;if(this.sortObjects){Ks.copy(this.matrixWorld).invert(),Zd.setFromMatrixPosition(h.matrixWorld).applyMatrix4(Ks),Jl.set(0,0,-1).transformDirection(h.matrixWorld).transformDirection(Ks);for(let ee=0,ae=w.length;ee<ae;ee++)if(w[ee].visible&&w[ee].active){const Re=w[ee].geometryIndex;this.getMatrixAt(ee,Ks),this.getBoundingSphereAt(Re,Va).applyMatrix4(Ks);let Oe=!1;if(L&&(Oe=!G.intersectsSphere(Va,h)),!Oe){const je=I[Re],He=kb.subVectors(Va.center,Zd).dot(Jl);Js.push(je.start,je.count,He,ee)}}const Y=Js.list,Q=this.customSort;Q===null?Y.sort(g.transparent?$p:Ub):Q.call(this,Y,h);for(let ee=0,ae=Y.length;ee<ae;ee++){const Re=Y[ee];A[Z]=Re.start*b,C[Z]=Re.count,O[Z]=Re.index,Z++}Js.reset()}else for(let Y=0,Q=w.length;Y<Q;Y++)if(w[Y].visible&&w[Y].active){const ee=w[Y].geometryIndex;let ae=!1;if(L&&(this.getMatrixAt(Y,Ks),this.getBoundingSphereAt(ee,Va).applyMatrix4(Ks),ae=!G.intersectsSphere(Va,h)),!ae){const Re=I[ee];A[Z]=Re.start*b,C[Z]=Re.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 Pr extends null{constructor(s){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Un(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 Kd=new ne,Ql=new ne,Jd=new Pn,Lh=new _o,Qd=new Os,Xp=new ne,A0=new ne;class Dh extends null{constructor(s=new Gn,l=new Pr){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++)Kd.fromBufferAttribute(l,f-1),Ql.fromBufferAttribute(l,f),h[f]=h[f-1],h[f]+=Kd.distanceTo(Ql);s.setAttribute("lineDistance",new Wt(h,1))}else _n("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(),Qd.copy(h.boundingSphere),Qd.applyMatrix4(f),Qd.radius+=g,s.ray.intersectsSphere(Qd)===!1)return;Jd.copy(f).invert(),Lh.copy(s.ray).applyMatrix4(Jd);const b=g/((this.scale.x+this.scale.y+this.scale.z)/3),w=b*b,A=this.isLineSegments?2:1,C=h.index,L=h.attributes.position;if(C!==null){const D=Math.max(0,_.start),O=Math.min(C.count,_.start+_.count);for(let G=D,Z=O-1;G<Z;G+=A){const Y=C.getX(G),Q=C.getX(G+1),ee=ef(this,s,Lh,w,Y,Q,G);ee&&l.push(ee)}if(this.isLineLoop){const G=C.getX(O-1),Z=C.getX(D),Y=ef(this,s,Lh,w,G,Z,O-1);Y&&l.push(Y)}}else{const D=Math.max(0,_.start),O=Math.min(L.count,_.start+_.count);for(let G=D,Z=O-1;G<Z;G+=A){const Y=ef(this,s,Lh,w,G,G+1,G);Y&&l.push(Y)}if(this.isLineLoop){const G=ef(this,s,Lh,w,O-1,D,O-1);G&&l.push(G)}}}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 ef(E,s,l,h,f,g,_){const b=E.geometry.attributes.position;if(Kd.fromBufferAttribute(b,f),Ql.fromBufferAttribute(b,g),l.distanceSqToSegment(Kd,Ql,Xp,A0)>h)return;Xp.applyMatrix4(E.matrixWorld);const A=s.ray.origin.distanceTo(Xp);if(!(A<s.near||A>s.far))return{distance:A,point:A0.clone().applyMatrix4(E.matrixWorld),index:_,face:null,faceIndex:null,barycoord:null,object:E}}const jp=new ne,tf=new ne;class nf 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)jp.fromBufferAttribute(l,f),tf.fromBufferAttribute(l,f+1),h[f]=f===0?0:h[f-1],h[f+1]=h[f]+jp.distanceTo(tf);s.setAttribute("lineDistance",new Wt(h,1))}else _n("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class zb extends null{constructor(s,l){super(s,l),this.isLineLoop=!0,this.type="LineLoop"}}class Gg extends null{constructor(s){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Un(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 Vb=new Pn,E0=new _o,sf=new Os,Yp=new ne;class Y1 extends null{constructor(s=new Gn,l=new Gg){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(),sf.copy(h.boundingSphere),sf.applyMatrix4(f),sf.radius+=g,s.ray.intersectsSphere(sf)===!1)return;Vb.copy(f).invert(),E0.copy(s.ray).applyMatrix4(Vb);const b=g/((this.scale.x+this.scale.y+this.scale.z)/3),w=b*b,A=h.index,I=h.attributes.position;if(A!==null){const L=Math.max(0,_.start),D=Math.min(A.count,_.start+_.count);for(let O=L,G=D;O<G;O++){const Z=A.getX(O);Yp.fromBufferAttribute(I,Z),Gb(Yp,Z,w,f,s,l,this)}}else{const L=Math.max(0,_.start),D=Math.min(I.count,_.start+_.count);for(let O=L,G=D;O<G;O++)Yp.fromBufferAttribute(I,O),Gb(Yp,O,w,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 Gb(E,s,l,h,f,g,_){const b=E0.distanceSqToPoint(E);if(b<l){const w=new ne;E0.closestPointToPoint(E,w),w.applyMatrix4(h);const A=f.ray.origin.distanceTo(w);if(A<f.near||A>f.far)return;g.push({distance:A,distanceToRay:Math.sqrt(b),point:w,index:s,face:null,faceIndex:null,barycoord:null,object:_})}}class ND extends null{constructor(s,l,h,f,g=Yn,_=Yn,b,w,A){super(s,l,h,f,g,_,b,w,A),this.isVideoTexture=!0,this.generateMipmaps=!1,this._requestVideoFrameCallbackId=0;const C=this;function I(){C.needsUpdate=!0,C._requestVideoFrameCallbackId=s.requestVideoFrameCallback(I)}"requestVideoFrameCallback"in s&&(this._requestVideoFrameCallbackId=s.requestVideoFrameCallback(I))}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 Ao extends null{constructor(s,l,h,f,g,_,b,w){super({},s,l,h,f,g,_,b,w),this.isVideoFrameTexture=!0}update(){}clone(){return new this.constructor().copy(this)}setFrame(s){this.image=s,this.needsUpdate=!0}}class Hb extends null{constructor(s,l){super({width:s,height:l}),this.isFramebufferTexture=!0,this.magFilter=Jn,this.minFilter=Jn,this.generateMipmaps=!1,this.needsUpdate=!0}}class Hg extends null{constructor(s,l,h,f,g,_,b,w,A,C,I,L){super(null,_,b,w,A,C,f,g,I,L),this.isCompressedTexture=!0,this.image={width:l,height:h},this.mipmaps=s,this.flipY=!1,this.generateMipmaps=!1}}class C0 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 rf extends null{constructor(s,l,h){super(void 0,s[0].width,s[0].height,l,h,Br),this.isCompressedCubeTexture=!0,this.isCubeTexture=!0,this.image=s}}class of extends no{constructor(s,l,h,f,g,_,b,w,A){super(s,l,h,f,g,_,b,w,A),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Fh extends null{constructor(s,l,h=pi,f,g,_,b=Jn,w=Jn,A,C=Or,I=1){if(C!==Or&&C!==eo)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const L={width:s,height:l,depth:I};super(L,f,g,_,b,w,C,h,A),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(s){return super.copy(s),this.source=new Mr(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 R0 extends null{constructor(s=null){super(),this.sourceTexture=s,this.isExternalTexture=!0}copy(s){return super.copy(s),this.sourceTexture=s.sourceTexture,this}}class Bh extends Gn{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=[],w=[],A=[],C=l/2,I=Math.PI/2*s,L=l,D=2*I+L,O=h*2+g,G=f+1,Z=new ne,Y=new ne;for(let Q=0;Q<=O;Q++){let ee=0,ae=0,Re=0,Oe=0;if(Q<=h){const ct=Q/h,dt=ct*Math.PI/2;ae=-C-s*Math.cos(dt),Re=s*Math.sin(dt),Oe=-s*Math.cos(dt),ee=ct*I}else if(Q<=h+g){const ct=(Q-h)/g;ae=-C+ct*l,Re=s,Oe=0,ee=I+ct*L}else{const ct=(Q-h-g)/h,dt=ct*Math.PI/2;ae=C+s*Math.sin(dt),Re=s*Math.cos(dt),Oe=s*Math.sin(dt),ee=I+L+ct*I}const je=Math.max(0,Math.min(1,ee/D));let He=0;Q===0?He=.5/f:Q===O&&(He=-.5/f);for(let ct=0;ct<=f;ct++){const dt=ct/f,tn=dt*Math.PI*2,Mn=Math.sin(tn),qn=Math.cos(tn);Y.x=-Re*qn,Y.y=ae,Y.z=Re*Mn,b.push(Y.x,Y.y,Y.z),Z.set(-Re*qn,Oe,Re*Mn),Z.normalize(),w.push(Z.x,Z.y,Z.z),A.push(dt+He,je)}if(Q>0){const ct=(Q-1)*G;for(let dt=0;dt<f;dt++){const tn=ct+dt,Mn=ct+dt+1,qn=Q*G+dt,di=Q*G+dt+1;_.push(tn,Mn,qn),_.push(Mn,di,qn)}}}this.setIndex(_),this.setAttribute("position",new Wt(b,3)),this.setAttribute("normal",new Wt(w,3)),this.setAttribute("uv",new Wt(A,2))}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}static fromJSON(s){return new Bh(s.radius,s.height,s.capSegments,s.radialSegments,s.heightSegments)}}class Oh extends Gn{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=[],w=[],A=new ne,C=new pt;_.push(0,0,0),b.push(0,0,1),w.push(.5,.5);for(let I=0,L=3;I<=l;I++,L+=3){const D=h+I/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),C.x=(_[L]/s+1)/2,C.y=(_[L+1]/s+1)/2,w.push(C.x,C.y)}for(let I=1;I<=l;I++)g.push(I,I+1,0);this.setIndex(g),this.setAttribute("position",new Wt(_,3)),this.setAttribute("normal",new Wt(b,3)),this.setAttribute("uv",new Wt(w,2))}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}static fromJSON(s){return new Oh(s.radius,s.segments,s.thetaStart,s.thetaLength)}}class Uh extends Gn{constructor(s=1,l=1,h=1,f=32,g=1,_=!1,b=0,w=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:s,radiusBottom:l,height:h,radialSegments:f,heightSegments:g,openEnded:_,thetaStart:b,thetaLength:w};const A=this;f=Math.floor(f),g=Math.floor(g);const C=[],I=[],L=[],D=[];let O=0;const G=[],Z=h/2;let Y=0;Q(),_===!1&&(s>0&&ee(!0),l>0&&ee(!1)),this.setIndex(C),this.setAttribute("position",new Wt(I,3)),this.setAttribute("normal",new Wt(L,3)),this.setAttribute("uv",new Wt(D,2));function Q(){const ae=new ne,Re=new ne;let Oe=0;const je=(l-s)/h;for(let He=0;He<=g;He++){const ct=[],dt=He/g,tn=dt*(l-s)+s;for(let Mn=0;Mn<=f;Mn++){const qn=Mn/f,di=qn*w+b,bi=Math.sin(di),Es=Math.cos(di);Re.x=tn*bi,Re.y=-dt*h+Z,Re.z=tn*Es,I.push(Re.x,Re.y,Re.z),ae.set(bi,je,Es).normalize(),L.push(ae.x,ae.y,ae.z),D.push(qn,1-dt),ct.push(O++)}G.push(ct)}for(let He=0;He<f;He++)for(let ct=0;ct<g;ct++){const dt=G[ct][He],tn=G[ct+1][He],Mn=G[ct+1][He+1],qn=G[ct][He+1];(s>0||ct!==0)&&(C.push(dt,tn,qn),Oe+=3),(l>0||ct!==g-1)&&(C.push(tn,Mn,qn),Oe+=3)}A.addGroup(Y,Oe,0),Y+=Oe}function ee(ae){const Re=O,Oe=new pt,je=new ne;let He=0;const ct=ae===!0?s:l,dt=ae===!0?1:-1;for(let Mn=1;Mn<=f;Mn++)I.push(0,Z*dt,0),L.push(0,dt,0),D.push(.5,.5),O++;const tn=O;for(let Mn=0;Mn<=f;Mn++){const di=Mn/f*w+b,bi=Math.cos(di),Es=Math.sin(di);je.x=ct*Es,je.y=Z*dt,je.z=ct*bi,I.push(je.x,je.y,je.z),L.push(0,dt,0),Oe.x=bi*.5+.5,Oe.y=Es*.5*dt+.5,D.push(Oe.x,Oe.y),O++}for(let Mn=0;Mn<f;Mn++){const qn=Re+Mn,di=tn+Mn;ae===!0?C.push(di,di+1,qn):C.push(di+1,di,qn),He+=3}A.addGroup(Y,He,ae===!0?1:2),Y+=He}}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}static fromJSON(s){return new Uh(s.radiusTop,s.radiusBottom,s.height,s.radialSegments,s.heightSegments,s.openEnded,s.thetaStart,s.thetaLength)}}class ou extends Uh{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 ou(s.radius,s.height,s.radialSegments,s.heightSegments,s.openEnded,s.thetaStart,s.thetaLength)}}class au extends Gn{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),C(),this.setAttribute("position",new Wt(g,3)),this.setAttribute("normal",new Wt(g.slice(),3)),this.setAttribute("uv",new Wt(_,2)),f===0?this.computeVertexNormals():this.normalizeNormals();function b(Q){const ee=new ne,ae=new ne,Re=new ne;for(let Oe=0;Oe<l.length;Oe+=3)D(l[Oe+0],ee),D(l[Oe+1],ae),D(l[Oe+2],Re),w(ee,ae,Re,Q)}function w(Q,ee,ae,Re){const Oe=Re+1,je=[];for(let He=0;He<=Oe;He++){je[He]=[];const ct=Q.clone().lerp(ae,He/Oe),dt=ee.clone().lerp(ae,He/Oe),tn=Oe-He;for(let Mn=0;Mn<=tn;Mn++)Mn===0&&He===Oe?je[He][Mn]=ct:je[He][Mn]=ct.clone().lerp(dt,Mn/tn)}for(let He=0;He<Oe;He++)for(let ct=0;ct<2*(Oe-He)-1;ct++){const dt=Math.floor(ct/2);ct%2===0?(L(je[He][dt+1]),L(je[He+1][dt]),L(je[He][dt])):(L(je[He][dt+1]),L(je[He+1][dt+1]),L(je[He+1][dt]))}}function A(Q){const ee=new ne;for(let ae=0;ae<g.length;ae+=3)ee.x=g[ae+0],ee.y=g[ae+1],ee.z=g[ae+2],ee.normalize().multiplyScalar(Q),g[ae+0]=ee.x,g[ae+1]=ee.y,g[ae+2]=ee.z}function C(){const Q=new ne;for(let ee=0;ee<g.length;ee+=3){Q.x=g[ee+0],Q.y=g[ee+1],Q.z=g[ee+2];const ae=Z(Q)/2/Math.PI+.5,Re=Y(Q)/Math.PI+.5;_.push(ae,1-Re)}O(),I()}function I(){for(let Q=0;Q<_.length;Q+=6){const ee=_[Q+0],ae=_[Q+2],Re=_[Q+4],Oe=Math.max(ee,ae,Re),je=Math.min(ee,ae,Re);Oe>.9&&je<.1&&(ee<.2&&(_[Q+0]+=1),ae<.2&&(_[Q+2]+=1),Re<.2&&(_[Q+4]+=1))}}function L(Q){g.push(Q.x,Q.y,Q.z)}function D(Q,ee){const ae=Q*3;ee.x=s[ae+0],ee.y=s[ae+1],ee.z=s[ae+2]}function O(){const Q=new ne,ee=new ne,ae=new ne,Re=new ne,Oe=new pt,je=new pt,He=new pt;for(let ct=0,dt=0;ct<g.length;ct+=9,dt+=6){Q.set(g[ct+0],g[ct+1],g[ct+2]),ee.set(g[ct+3],g[ct+4],g[ct+5]),ae.set(g[ct+6],g[ct+7],g[ct+8]),Oe.set(_[dt+0],_[dt+1]),je.set(_[dt+2],_[dt+3]),He.set(_[dt+4],_[dt+5]),Re.copy(Q).add(ee).add(ae).divideScalar(3);const tn=Z(Re);G(Oe,dt+0,Q,tn),G(je,dt+2,ee,tn),G(He,dt+4,ae,tn)}}function G(Q,ee,ae,Re){Re<0&&Q.x===1&&(_[ee]=Q.x-1),ae.x===0&&ae.z===0&&(_[ee]=Re/2/Math.PI+.5)}function Z(Q){return Math.atan2(Q.z,-Q.x)}function Y(Q){return Math.atan2(-Q.y,Math.sqrt(Q.x*Q.x+Q.z*Q.z))}}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}static fromJSON(s){return new au(s.vertices,s.indices,s.radius,s.details)}}class Eo extends au{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 Eo(s.radius,s.detail)}}const kh=new ne,Zp=new ne,af=new ne,lu=new Ci;class Wg extends Gn{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(zc*l),_=s.getIndex(),b=s.getAttribute("position"),w=_?_.count:b.count,A=[0,0,0],C=["a","b","c"],I=new Array(3),L={},D=[];for(let O=0;O<w;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:G,b:Z,c:Y}=lu;if(G.fromBufferAttribute(b,A[0]),Z.fromBufferAttribute(b,A[1]),Y.fromBufferAttribute(b,A[2]),lu.getNormal(af),I[0]=`${Math.round(G.x*f)},${Math.round(G.y*f)},${Math.round(G.z*f)}`,I[1]=`${Math.round(Z.x*f)},${Math.round(Z.y*f)},${Math.round(Z.z*f)}`,I[2]=`${Math.round(Y.x*f)},${Math.round(Y.y*f)},${Math.round(Y.z*f)}`,!(I[0]===I[1]||I[1]===I[2]||I[2]===I[0]))for(let Q=0;Q<3;Q++){const ee=(Q+1)%3,ae=I[Q],Re=I[ee],Oe=lu[C[Q]],je=lu[C[ee]],He=`${ae}_${Re}`,ct=`${Re}_${ae}`;ct in L&&L[ct]?(af.dot(L[ct].normal)<=g&&(D.push(Oe.x,Oe.y,Oe.z),D.push(je.x,je.y,je.z)),L[ct]=null):He in L||(L[He]={index0:A[Q],index1:A[ee],normal:af.clone()})}}for(const O in L)if(L[O]){const{index0:G,index1:Z}=L[O];kh.fromBufferAttribute(b,G),Zp.fromBufferAttribute(b,Z),D.push(kh.x,kh.y,kh.z),D.push(Zp.x,Zp.y,Zp.z)}this.setAttribute("position",new Wt(D,3))}}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}}class Co{constructor(){this.type="Curve",this.arcLengthDivisions=200,this.needsUpdate=!1,this.cacheArcLengths=null}getPoint(){_n("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,w=g-1,A;for(;b<=w;)if(f=Math.floor(b+(w-b)/2),A=h[f]-_,A<0)b=f+1;else if(A>0)w=f-1;else{w=f;break}if(f=w,h[f]===_)return f/(g-1);const C=h[f],L=h[f+1]-C,D=(_-C)/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),w=l||(_.isVector2?new pt:new ne);return w.copy(b).sub(_).normalize(),w}getTangentAt(s,l){const h=this.getUtoTmapping(s);return this.getTangent(h,l)}computeFrenetFrames(s,l=!1){const h=new ne,f=[],g=[],_=[],b=new ne,w=new Pn;for(let D=0;D<=s;D++){const O=D/s;f[D]=this.getTangentAt(O,new ne)}g[0]=new ne,_[0]=new ne;let A=Number.MAX_VALUE;const C=Math.abs(f[0].x),I=Math.abs(f[0].y),L=Math.abs(f[0].z);C<=A&&(A=C,h.set(1,0,0)),I<=A&&(A=I,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(Tn(f[D-1].dot(f[D]),-1,1));g[D].applyMatrix4(w.makeRotationAxis(b,O))}_[D].crossVectors(f[D],g[D])}if(l===!0){let D=Math.acos(Tn(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(w.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 lf extends Co{constructor(s=0,l=0,h=1,f=1,g=0,_=Math.PI*2,b=!1,w=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=w}getPoint(s,l=new pt){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 w=this.aX+this.xRadius*Math.cos(b),A=this.aY+this.yRadius*Math.sin(b);if(this.aRotation!==0){const C=Math.cos(this.aRotation),I=Math.sin(this.aRotation),L=w-this.aX,D=A-this.aY;w=L*C-D*I+this.aX,A=L*I+D*C+this.aY}return h.set(w,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 Wb extends lf{constructor(s,l,h,f,g,_){super(s,l,h,h,f,g,_),this.isArcCurve=!0,this.type="ArcCurve"}}function Kp(){let E=0,s=0,l=0,h=0;function f(g,_,b,w){E=g,s=b,l=-3*g+3*_-2*b-w,h=2*g-2*_+b+w}return{initCatmullRom:function(g,_,b,w,A){f(_,b,A*(b-g),A*(w-_))},initNonuniformCatmullRom:function(g,_,b,w,A,C,I){let L=(_-g)/A-(b-g)/(A+C)+(b-_)/C,D=(b-_)/C-(w-_)/(C+I)+(w-b)/I;L*=C,D*=C,f(_,b,L,D)},calc:function(g){const _=g*g,b=_*g;return E+s*g+l*_+h*b}}}const Jp=new ne,$g=new Kp,qg=new Kp,cu=new Kp;class $b extends Co{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 ne){const h=l,f=this.points,g=f.length,_=(g-(this.closed?0:1))*s;let b=Math.floor(_),w=_-b;this.closed?b+=b>0?0:(Math.floor(Math.abs(b)/g)+1)*g:w===0&&b===g-1&&(b=g-2,w=1);let A,C;this.closed||b>0?A=f[(b-1)%g]:(Jp.subVectors(f[0],f[1]).add(f[0]),A=Jp);const I=f[b%g],L=f[(b+1)%g];if(this.closed||b+2<g?C=f[(b+2)%g]:(Jp.subVectors(f[g-1],f[g-2]).add(f[g-1]),C=Jp),this.curveType==="centripetal"||this.curveType==="chordal"){const D=this.curveType==="chordal"?.5:.25;let O=Math.pow(A.distanceToSquared(I),D),G=Math.pow(I.distanceToSquared(L),D),Z=Math.pow(L.distanceToSquared(C),D);G<1e-4&&(G=1),O<1e-4&&(O=G),Z<1e-4&&(Z=G),$g.initNonuniformCatmullRom(A.x,I.x,L.x,C.x,O,G,Z),qg.initNonuniformCatmullRom(A.y,I.y,L.y,C.y,O,G,Z),cu.initNonuniformCatmullRom(A.z,I.z,L.z,C.z,O,G,Z)}else this.curveType==="catmullrom"&&($g.initCatmullRom(A.x,I.x,L.x,C.x,this.tension),qg.initCatmullRom(A.y,I.y,L.y,C.y,this.tension),cu.initCatmullRom(A.z,I.z,L.z,C.z,this.tension));return h.set($g.calc(w),qg.calc(w),cu.calc(w)),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 ne().fromArray(f))}return this.closed=s.closed,this.curveType=s.curveType,this.tension=s.tension,this}}function N0(E,s,l,h,f){const g=(h-s)*.5,_=(f-l)*.5,b=E*E,w=E*b;return(2*l-2*h+g+_)*w+(-3*l+3*h-2*g-_)*b+g*E+l}function qb(E,s){const l=1-E;return l*l*s}function Xb(E,s){return 2*(1-E)*E*s}function cf(E,s){return E*E*s}function zh(E,s,l,h){return qb(E,s)+Xb(E,l)+cf(E,h)}function P0(E,s){const l=1-E;return l*l*l*s}function I0(E,s){const l=1-E;return 3*l*l*E*s}function jb(E,s){return 3*(1-E)*E*E*s}function L0(E,s){return E*E*E*s}function uu(E,s,l,h,f){return P0(E,s)+I0(E,l)+jb(E,h)+L0(E,f)}class Xg extends Co{constructor(s=new pt,l=new pt,h=new pt,f=new pt){super(),this.isCubicBezierCurve=!0,this.type="CubicBezierCurve",this.v0=s,this.v1=l,this.v2=h,this.v3=f}getPoint(s,l=new pt){const h=l,f=this.v0,g=this.v1,_=this.v2,b=this.v3;return h.set(uu(s,f.x,g.x,_.x,b.x),uu(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 Qp extends Co{constructor(s=new ne,l=new ne,h=new ne,f=new ne){super(),this.isCubicBezierCurve3=!0,this.type="CubicBezierCurve3",this.v0=s,this.v1=l,this.v2=h,this.v3=f}getPoint(s,l=new ne){const h=l,f=this.v0,g=this.v1,_=this.v2,b=this.v3;return h.set(uu(s,f.x,g.x,_.x,b.x),uu(s,f.y,g.y,_.y,b.y),uu(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 D0 extends Co{constructor(s=new pt,l=new pt){super(),this.isLineCurve=!0,this.type="LineCurve",this.v1=s,this.v2=l}getPoint(s,l=new pt){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 pt){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 jg extends Co{constructor(s=new ne,l=new ne){super(),this.isLineCurve3=!0,this.type="LineCurve3",this.v1=s,this.v2=l}getPoint(s,l=new ne){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 ne){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 hu extends Co{constructor(s=new pt,l=new pt,h=new pt){super(),this.isQuadraticBezierCurve=!0,this.type="QuadraticBezierCurve",this.v0=s,this.v1=l,this.v2=h}getPoint(s,l=new pt){const h=l,f=this.v0,g=this.v1,_=this.v2;return h.set(zh(s,f.x,g.x,_.x),zh(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 F0 extends Co{constructor(s=new ne,l=new ne,h=new ne){super(),this.isQuadraticBezierCurve3=!0,this.type="QuadraticBezierCurve3",this.v0=s,this.v1=l,this.v2=h}getPoint(s,l=new ne){const h=l,f=this.v0,g=this.v1,_=this.v2;return h.set(zh(s,f.x,g.x,_.x),zh(s,f.y,g.y,_.y),zh(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 Yg extends Co{constructor(s=[]){super(),this.isSplineCurve=!0,this.type="SplineCurve",this.points=s}getPoint(s,l=new pt){const h=l,f=this.points,g=(f.length-1)*s,_=Math.floor(g),b=g-_,w=f[_===0?_:_-1],A=f[_],C=f[_>f.length-2?f.length-1:_+1],I=f[_>f.length-3?f.length-1:_+2];return h.set(N0(b,w.x,A.x,C.x,I.x),N0(b,w.y,A.y,C.y,I.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 pt().fromArray(f))}return this}}var Ga=Object.freeze({__proto__:null,ArcCurve:Wb,CatmullRomCurve3:$b,CubicBezierCurve:Xg,CubicBezierCurve3:Qp,EllipseCurve:lf,LineCurve:D0,LineCurve3:jg,QuadraticBezierCurve:hu,QuadraticBezierCurve3:F0,SplineCurve:Yg});class uf extends Co{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 Ga[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],w=b.getLength(),A=w===0?0:1-_/w;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,w=_.getPoints(b);for(let A=0;A<w.length;A++){const C=w[A];h&&h.equals(C)||(l.push(C),h=C)}}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 Ga[f.type]().fromJSON(f))}return this}}class Zg extends uf{constructor(s){super(),this.type="Path",this.currentPoint=new pt,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 D0(this.currentPoint.clone(),new pt(s,l));return this.curves.push(h),this.currentPoint.set(s,l),this}quadraticCurveTo(s,l,h,f){const g=new hu(this.currentPoint.clone(),new pt(s,l),new pt(h,f));return this.curves.push(g),this.currentPoint.set(h,f),this}bezierCurveTo(s,l,h,f,g,_){const b=new Xg(this.currentPoint.clone(),new pt(s,l),new pt(h,f),new pt(g,_));return this.curves.push(b),this.currentPoint.set(g,_),this}splineThru(s){const l=[this.currentPoint.clone()].concat(s),h=new Yg(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,w=this.currentPoint.y;return this.absarc(s+b,l+w,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,w){const A=this.currentPoint.x,C=this.currentPoint.y;return this.absellipse(s+A,l+C,h,f,g,_,b,w),this}absellipse(s,l,h,f,g,_,b,w){const A=new lf(s,l,h,f,g,_,b,w);if(this.curves.length>0){const I=A.getPoint(0);I.equals(this.currentPoint)||this.lineTo(I.x,I.y)}this.curves.push(A);const C=A.getPoint(1);return this.currentPoint.copy(C),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 Vh extends Zg{constructor(s){super(s),this.uuid=to(),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 Zg().fromJSON(f))}return this}}function Yb(E,s,l=2){const h=s&&s.length,f=h?s[0]*l:E.length;let g=B0(E,0,f,l,!0);const _=[];if(!g||g.next===g.prev)return _;let b,w,A;if(h&&(g=eS(E,s,g,l)),E.length>80*l){b=E[0],w=E[1];let C=b,I=w;for(let L=l;L<f;L+=l){const D=E[L],O=E[L+1];D<b&&(b=D),O<w&&(w=O),D>C&&(C=D),O>I&&(I=O)}A=Math.max(C-b,I-w),A=A!==0?32767/A:0}return hf(g,_,l,b,w,A,0),_}function B0(E,s,l,h,f){let g;if(f===rS(E,s,l,h)>0)for(let _=s;_<l;_+=h)g=ey(_/h|0,E[_],E[_+1],g);else for(let _=l-h;_>=s;_-=h)g=ey(_/h|0,E[_],E[_+1],g);return g&&Gh(g,g.next)&&(Hh(g),g=g.next),g}function du(E,s){if(!E)return E;s||(s=E);let l=E,h;do if(h=!1,!l.steiner&&(Gh(l,l.next)||Li(l.prev,l,l.next)===0)){if(Hh(l),l=s=l.prev,l===l.next)break;h=!0}else l=l.next;while(h||l!==s);return s}function hf(E,s,l,h,f,g,_){if(!E)return;!_&&g&&nS(E,h,f,g);let b=E;for(;E.prev!==E.next;){const w=E.prev,A=E.next;if(g?Kb(E,h,f,g):Zb(E)){s.push(w.i,E.i,A.i),Hh(E),E=A.next,b=A.next;continue}if(E=A,E===b){_?_===1?(E=Jb(du(E),s),hf(E,s,l,h,f,g,2)):_===2&&Qb(E,s,l,h,f,g):hf(du(E),s,l,h,f,g,1);break}}}function Zb(E){const s=E.prev,l=E,h=E.next;if(Li(s,l,h)>=0)return!1;const f=s.x,g=l.x,_=h.x,b=s.y,w=l.y,A=h.y,C=Math.min(f,g,_),I=Math.min(b,w,A),L=Math.max(f,g,_),D=Math.max(b,w,A);let O=h.next;for(;O!==s;){if(O.x>=C&&O.x<=L&&O.y>=I&&O.y<=D&&tc(f,b,g,w,_,A,O.x,O.y)&&Li(O.prev,O,O.next)>=0)return!1;O=O.next}return!0}function Kb(E,s,l,h){const f=E.prev,g=E,_=E.next;if(Li(f,g,_)>=0)return!1;const b=f.x,w=g.x,A=_.x,C=f.y,I=g.y,L=_.y,D=Math.min(b,w,A),O=Math.min(C,I,L),G=Math.max(b,w,A),Z=Math.max(C,I,L),Y=ec(D,O,s,l,h),Q=ec(G,Z,s,l,h);let ee=E.prevZ,ae=E.nextZ;for(;ee&&ee.z>=Y&&ae&&ae.z<=Q;){if(ee.x>=D&&ee.x<=G&&ee.y>=O&&ee.y<=Z&&ee!==f&&ee!==_&&tc(b,C,w,I,A,L,ee.x,ee.y)&&Li(ee.prev,ee,ee.next)>=0||(ee=ee.prevZ,ae.x>=D&&ae.x<=G&&ae.y>=O&&ae.y<=Z&&ae!==f&&ae!==_&&tc(b,C,w,I,A,L,ae.x,ae.y)&&Li(ae.prev,ae,ae.next)>=0))return!1;ae=ae.nextZ}for(;ee&&ee.z>=Y;){if(ee.x>=D&&ee.x<=G&&ee.y>=O&&ee.y<=Z&&ee!==f&&ee!==_&&tc(b,C,w,I,A,L,ee.x,ee.y)&&Li(ee.prev,ee,ee.next)>=0)return!1;ee=ee.prevZ}for(;ae&&ae.z<=Q;){if(ae.x>=D&&ae.x<=G&&ae.y>=O&&ae.y<=Z&&ae!==f&&ae!==_&&tc(b,C,w,I,A,L,ae.x,ae.y)&&Li(ae.prev,ae,ae.next)>=0)return!1;ae=ae.nextZ}return!0}function Jb(E,s){let l=E;do{const h=l.prev,f=l.next.next;!Gh(h,f)&&Jg(h,l,l.next,f)&&mf(h,f)&&mf(f,h)&&(s.push(h.i,l.i,f.i),Hh(l),Hh(l.next),l=E=f),l=l.next}while(l!==E);return du(l)}function Qb(E,s,l,h,f,g){let _=E;do{let b=_.next.next;for(;b!==_.prev;){if(_.i!==b.i&&iS(_,b)){let w=ia(_,b);_=du(_,_.next),w=du(w,w.next),hf(_,s,l,h,f,g,0),hf(w,s,l,h,f,g,0);return}b=b.next}_=_.next}while(_!==E)}function eS(E,s,l,h){const f=[];for(let g=0,_=s.length;g<_;g++){const b=s[g]*h,w=g<_-1?s[g+1]*h:E.length,A=B0(E,b,w,h,!1);A===A.next&&(A.steiner=!0),f.push(U0(A))}f.sort(Kg);for(let g=0;g<f.length;g++)l=tS(f[g],l);return l}function Kg(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 tS(E,s){const l=O0(E,s);if(!l)return s;const h=ia(l,E);return du(h,h.next),du(l,l.next)}function O0(E,s){let l=s;const h=E.x,f=E.y;let g=-1/0,_;if(Gh(E,l))return l;do{if(Gh(E,l.next))return l.next;if(f<=l.y&&f>=l.next.y&&l.next.y!==l.y){const I=l.x+(f-l.y)*(l.next.x-l.x)/(l.next.y-l.y);if(I<=h&&I>g&&(g=I,_=l.x<l.next.x?l:l.next,I===h))return _}l=l.next}while(l!==s);if(!_)return null;const b=_,w=_.x,A=_.y;let C=1/0;l=_;do{if(h>=l.x&&l.x>=w&&h!==l.x&&ff(f<A?h:g,f,w,A,f<A?g:h,f,l.x,l.y)){const I=Math.abs(f-l.y)/(h-l.x);mf(l,E)&&(I<C||I===C&&(l.x>_.x||l.x===_.x&&df(_,l)))&&(_=l,C=I)}l=l.next}while(l!==b);return _}function df(E,s){return Li(E.prev,E,s.prev)<0&&Li(s.next,E,E.next)<0}function nS(E,s,l,h){let f=E;do f.z===0&&(f.z=ec(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,Qi(f)}function Qi(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 w=l;for(;b>0||w>0&&_;)b!==0&&(w===0||!_||h.z<=_.z)?(f=h,h=h.nextZ,b--):(f=_,_=_.nextZ,w--),g?g.nextZ=f:E=f,f.prevZ=g,g=f;h=_}g.nextZ=null,l*=2}while(s>1);return E}function ec(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 U0(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 ff(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 tc(E,s,l,h,f,g,_,b){return!(E===_&&s===b)&&ff(E,s,l,h,f,g,_,b)}function iS(E,s){return E.next.i!==s.i&&E.prev.i!==s.i&&!Qg(E,s)&&(mf(E,s)&&mf(s,E)&&sS(E,s)&&(Li(E.prev,E,s.prev)||Li(E,s.prev,s))||Gh(E,s)&&Li(E.prev,E,E.next)>0&&Li(s.prev,s,s.next)>0)}function Li(E,s,l){return(s.y-E.y)*(l.x-s.x)-(s.x-E.x)*(l.y-s.y)}function Gh(E,s){return E.x===s.x&&E.y===s.y}function Jg(E,s,l,h){const f=nc(Li(E,s,l)),g=nc(Li(E,s,h)),_=nc(Li(l,h,E)),b=nc(Li(l,h,s));return!!(f!==g&&_!==b||f===0&&pf(E,l,s)||g===0&&pf(E,h,s)||_===0&&pf(l,E,h)||b===0&&pf(l,s,h))}function pf(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 nc(E){return E>0?1:E<0?-1:0}function Qg(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&&Jg(l,l.next,E,s))return!0;l=l.next}while(l!==E);return!1}function mf(E,s){return Li(E.prev,E,E.next)<0?Li(E,s,E.next)>=0&&Li(E,E.prev,s)>=0:Li(E,s,E.prev)<0||Li(E,E.next,s)<0}function sS(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 ia(E,s){const l=gf(E.i,E.x,E.y),h=gf(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 ey(E,s,l,h){const f=gf(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 Hh(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 gf(E,s,l){return{i:E,x:s,y:l,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function rS(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 oS{static triangulate(s,l,h=2){return Yb(s,l,h)}}class Ro{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 Ro.area(s)<0}static triangulateShape(s,l){const h=[],f=[],g=[];em(s),yf(h,s);let _=s.length;l.forEach(em);for(let w=0;w<l.length;w++)f.push(_),_+=l[w].length,yf(h,l[w]);const b=oS.triangulate(h,f);for(let w=0;w<b.length;w+=3)g.push(b.slice(w,w+3));return g}}function em(E){const s=E.length;s>2&&E[s-1].equals(E[0])&&E.pop()}function yf(E,s){for(let l=0;l<s.length;l++)E.push(s[l].x),E.push(s[l].y)}class ic extends Gn{constructor(s=new Vh([new pt(.5,.5),new pt(-.5,.5),new pt(-.5,-.5),new pt(.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,w=s.length;b<w;b++){const A=s[b];_(A)}this.setAttribute("position",new Wt(f,3)),this.setAttribute("uv",new Wt(g,2)),this.computeVertexNormals();function _(b){const w=[],A=l.curveSegments!==void 0?l.curveSegments:12,C=l.steps!==void 0?l.steps:1,I=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,G=l.bevelOffset!==void 0?l.bevelOffset:0,Z=l.bevelSegments!==void 0?l.bevelSegments:3;const Y=l.extrudePath,Q=l.UVGenerator!==void 0?l.UVGenerator:ty;let ee,ae=!1,Re,Oe,je,He;Y&&(ee=Y.getSpacedPoints(C),ae=!0,L=!1,Re=Y.computeFrenetFrames(C,!1),Oe=new ne,je=new ne,He=new ne),L||(Z=0,D=0,O=0,G=0);const ct=b.extractPoints(A);let dt=ct.shape;const tn=ct.holes;if(!Ro.isClockWise(dt)){dt=dt.reverse();for(let Ft=0,qt=tn.length;Ft<qt;Ft++){const jt=tn[Ft];Ro.isClockWise(jt)&&(tn[Ft]=jt.reverse())}}function qn(Ft){const jt=10000000000000001e-36;let nn=Ft[0];for(let Kt=1;Kt<=Ft.length;Kt++){const hi=Kt%Ft.length,Xn=Ft[hi],ji=Xn.x-nn.x,ns=Xn.y-nn.y,Vs=ji*ji+ns*ns,co=Math.max(Math.abs(Xn.x),Math.abs(Xn.y),Math.abs(nn.x),Math.abs(nn.y)),wu=jt*co*co;if(Vs<=wu){Ft.splice(hi,1),Kt--;continue}nn=Xn}}qn(dt),tn.forEach(qn);const di=tn.length,bi=dt;for(let Ft=0;Ft<di;Ft++){const qt=tn[Ft];dt=dt.concat(qt)}function Es(Ft,qt,jt){return qt||ci("ExtrudeGeometry: vec does not exist"),Ft.clone().addScaledVector(qt,jt)}const ir=dt.length;function lo(Ft,qt,jt){let nn,Kt,hi;const Xn=Ft.x-qt.x,ji=Ft.y-qt.y,ns=jt.x-Ft.x,Vs=jt.y-Ft.y,co=Xn*Xn+ji*ji,wu=Xn*Vs-ji*ns;if(Math.abs(wu)>Number.EPSILON){const uo=Math.sqrt(co),cx=Math.sqrt(ns*ns+Vs*Vs),ux=qt.x-ji/uo,hx=qt.y+Xn/uo,DS=jt.x-Vs/cx,FS=jt.y+ns/cx,dx=((DS-ux)*Vs-(FS-hx)*ns)/(Xn*Vs-ji*ns);nn=ux+Xn*dx-Ft.x,Kt=hx+ji*dx-Ft.y;const fx=nn*nn+Kt*Kt;if(fx<=2)return new pt(nn,Kt);hi=Math.sqrt(fx/2)}else{let uo=!1;Xn>Number.EPSILON?ns>Number.EPSILON&&(uo=!0):Xn<-Number.EPSILON?ns<-Number.EPSILON&&(uo=!0):Math.sign(ji)===Math.sign(Vs)&&(uo=!0),uo?(nn=-ji,Kt=Xn,hi=Math.sqrt(co)):(nn=Xn,Kt=ji,hi=Math.sqrt(co/2))}return new pt(nn/hi,Kt/hi)}const es=[];for(let Ft=0,qt=bi.length,jt=qt-1,nn=Ft+1;Ft<qt;Ft++,jt++,nn++)jt===qt&&(jt=0),nn===qt&&(nn=0),es[Ft]=lo(bi[Ft],bi[jt],bi[nn]);const Cs=[];let ts,ra=es.concat();for(let Ft=0,qt=di;Ft<qt;Ft++){const jt=tn[Ft];ts=[];for(let nn=0,Kt=jt.length,hi=Kt-1,Xn=nn+1;nn<Kt;nn++,hi++,Xn++)hi===Kt&&(hi=0),Xn===Kt&&(Xn=0),ts[nn]=lo(jt[nn],jt[hi],jt[Xn]);Cs.push(ts),ra=ra.concat(ts)}let Io;if(Z===0)Io=Ro.triangulateShape(bi,tn);else{const Ft=[],qt=[];for(let jt=0;jt<Z;jt++){const nn=jt/Z,Kt=D*Math.cos(nn*Math.PI/2),hi=O*Math.sin(nn*Math.PI/2)+G;for(let Xn=0,ji=bi.length;Xn<ji;Xn++){const ns=Es(bi[Xn],es[Xn],hi);Wa(ns.x,ns.y,-Kt),nn===0&&Ft.push(ns)}for(let Xn=0,ji=di;Xn<ji;Xn++){const ns=tn[Xn];ts=Cs[Xn];const Vs=[];for(let co=0,wu=ns.length;co<wu;co++){const uo=Es(ns[co],ts[co],hi);Wa(uo.x,uo.y,-Kt),nn===0&&Vs.push(uo)}nn===0&&qt.push(Vs)}}Io=Ro.triangulateShape(Ft,qt)}const oc=Io.length,Lf=O+G;for(let Ft=0;Ft<ir;Ft++){const qt=L?Es(dt[Ft],ra[Ft],Lf):dt[Ft];ae?(je.copy(Re.normals[0]).multiplyScalar(qt.x),Oe.copy(Re.binormals[0]).multiplyScalar(qt.y),He.copy(ee[0]).add(je).add(Oe),Wa(He.x,He.y,He.z)):Wa(qt.x,qt.y,0)}for(let Ft=1;Ft<=C;Ft++)for(let qt=0;qt<ir;qt++){const jt=L?Es(dt[qt],ra[qt],Lf):dt[qt];ae?(je.copy(Re.normals[Ft]).multiplyScalar(jt.x),Oe.copy(Re.binormals[Ft]).multiplyScalar(jt.y),He.copy(ee[Ft]).add(je).add(Oe),Wa(He.x,He.y,He.z)):Wa(jt.x,jt.y,I/C*Ft)}for(let Ft=Z-1;Ft>=0;Ft--){const qt=Ft/Z,jt=D*Math.cos(qt*Math.PI/2),nn=O*Math.sin(qt*Math.PI/2)+G;for(let Kt=0,hi=bi.length;Kt<hi;Kt++){const Xn=Es(bi[Kt],es[Kt],nn);Wa(Xn.x,Xn.y,I+jt)}for(let Kt=0,hi=tn.length;Kt<hi;Kt++){const Xn=tn[Kt];ts=Cs[Kt];for(let ji=0,ns=Xn.length;ji<ns;ji++){const Vs=Es(Xn[ji],ts[ji],nn);ae?Wa(Vs.x,Vs.y+ee[C-1].y,ee[C-1].x+jt):Wa(Vs.x,Vs.y,I+jt)}}}LS(),ox();function LS(){const Ft=f.length/3;if(L){let qt=0,jt=ir*qt;for(let nn=0;nn<oc;nn++){const Kt=Io[nn];rd(Kt[2]+jt,Kt[1]+jt,Kt[0]+jt)}qt=C+Z*2,jt=ir*qt;for(let nn=0;nn<oc;nn++){const Kt=Io[nn];rd(Kt[0]+jt,Kt[1]+jt,Kt[2]+jt)}}else{for(let qt=0;qt<oc;qt++){const jt=Io[qt];rd(jt[2],jt[1],jt[0])}for(let qt=0;qt<oc;qt++){const jt=Io[qt];rd(jt[0]+ir*C,jt[1]+ir*C,jt[2]+ir*C)}}h.addGroup(Ft,f.length/3-Ft,0)}function ox(){const Ft=f.length/3;let qt=0;ax(bi,qt),qt+=bi.length;for(let jt=0,nn=tn.length;jt<nn;jt++){const Kt=tn[jt];ax(Kt,qt),qt+=Kt.length}h.addGroup(Ft,f.length/3-Ft,1)}function ax(Ft,qt){let jt=Ft.length;for(;--jt>=0;){const nn=jt;let Kt=jt-1;Kt<0&&(Kt=Ft.length-1);for(let hi=0,Xn=C+Z*2;hi<Xn;hi++){const ji=ir*hi,ns=ir*(hi+1),Vs=qt+nn+ji,co=qt+Kt+ji,wu=qt+Kt+ns,uo=qt+nn+ns;lx(Vs,co,wu,uo)}}}function Wa(Ft,qt,jt){w.push(Ft),w.push(qt),w.push(jt)}function rd(Ft,qt,jt){Sl(Ft),Sl(qt),Sl(jt);const nn=f.length/3,Kt=Q.generateTopUV(h,f,nn-3,nn-2,nn-1);Tl(Kt[0]),Tl(Kt[1]),Tl(Kt[2])}function lx(Ft,qt,jt,nn){Sl(Ft),Sl(qt),Sl(nn),Sl(qt),Sl(jt),Sl(nn);const Kt=f.length/3,hi=Q.generateSideWallUV(h,f,Kt-6,Kt-3,Kt-2,Kt-1);Tl(hi[0]),Tl(hi[1]),Tl(hi[3]),Tl(hi[1]),Tl(hi[2]),Tl(hi[3])}function Sl(Ft){f.push(w[Ft*3+0]),f.push(w[Ft*3+1]),f.push(w[Ft*3+2])}function Tl(Ft){g.push(Ft.x),g.push(Ft.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 ny(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 Ga[f.type]().fromJSON(f)),new ic(h,s.options)}}const ty={generateTopUV:function(E,s,l,h,f){const g=s[l*3],_=s[l*3+1],b=s[h*3],w=s[h*3+1],A=s[f*3],C=s[f*3+1];return[new pt(g,_),new pt(b,w),new pt(A,C)]},generateSideWallUV:function(E,s,l,h,f,g){const _=s[l*3],b=s[l*3+1],w=s[l*3+2],A=s[h*3],C=s[h*3+1],I=s[h*3+2],L=s[f*3],D=s[f*3+1],O=s[f*3+2],G=s[g*3],Z=s[g*3+1],Y=s[g*3+2];return Math.abs(b-C)<Math.abs(_-A)?[new pt(_,1-w),new pt(A,1-I),new pt(L,1-O),new pt(G,1-Y)]:[new pt(b,1-w),new pt(C,1-I),new pt(D,1-O),new pt(Z,1-Y)]}};function ny(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 iy extends au{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 iy(s.radius,s.detail)}}class gl extends Gn{constructor(s=[new pt(0,-.5),new pt(.5,0),new pt(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=Tn(f,0,Math.PI*2);const g=[],_=[],b=[],w=[],A=[],C=1/l,I=new ne,L=new pt,D=new ne,O=new ne,G=new ne;let Z=0,Y=0;for(let Q=0;Q<=s.length-1;Q++)switch(Q){case 0:Z=s[Q+1].x-s[Q].x,Y=s[Q+1].y-s[Q].y,D.x=Y*1,D.y=-Z,D.z=Y*0,G.copy(D),D.normalize(),w.push(D.x,D.y,D.z);break;case s.length-1:w.push(G.x,G.y,G.z);break;default:Z=s[Q+1].x-s[Q].x,Y=s[Q+1].y-s[Q].y,D.x=Y*1,D.y=-Z,D.z=Y*0,O.copy(D),D.x+=G.x,D.y+=G.y,D.z+=G.z,D.normalize(),w.push(D.x,D.y,D.z),G.copy(O)}for(let Q=0;Q<=l;Q++){const ee=h+Q*C*f,ae=Math.sin(ee),Re=Math.cos(ee);for(let Oe=0;Oe<=s.length-1;Oe++){I.x=s[Oe].x*ae,I.y=s[Oe].y,I.z=s[Oe].x*Re,_.push(I.x,I.y,I.z),L.x=Q/l,L.y=Oe/(s.length-1),b.push(L.x,L.y);const je=w[3*Oe+0]*ae,He=w[3*Oe+1],ct=w[3*Oe+0]*Re;A.push(je,He,ct)}}for(let Q=0;Q<l;Q++)for(let ee=0;ee<s.length-1;ee++){const ae=ee+Q*s.length,Re=ae,Oe=ae+s.length,je=ae+s.length+1,He=ae+1;g.push(Re,Oe,He),g.push(je,He,Oe)}this.setIndex(g),this.setAttribute("position",new Wt(_,3)),this.setAttribute("uv",new Wt(b,2)),this.setAttribute("normal",new Wt(A,3))}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}static fromJSON(s){return new gl(s.points,s.segments,s.phiStart,s.phiLength)}}class Wh extends au{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 Wh(s.radius,s.detail)}}class _f extends Gn{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),w=Math.floor(f),A=b+1,C=w+1,I=s/b,L=l/w,D=[],O=[],G=[],Z=[];for(let Y=0;Y<C;Y++){const Q=Y*L-_;for(let ee=0;ee<A;ee++){const ae=ee*I-g;O.push(ae,-Q,0),G.push(0,0,1),Z.push(ee/b),Z.push(1-Y/w)}}for(let Y=0;Y<w;Y++)for(let Q=0;Q<b;Q++){const ee=Q+A*Y,ae=Q+A*(Y+1),Re=Q+1+A*(Y+1),Oe=Q+1+A*Y;D.push(ee,ae,Oe),D.push(ae,Re,Oe)}this.setIndex(D),this.setAttribute("position",new Wt(O,3)),this.setAttribute("normal",new Wt(G,3)),this.setAttribute("uv",new Wt(Z,2))}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}static fromJSON(s){return new _f(s.width,s.height,s.widthSegments,s.heightSegments)}}class xf extends Gn{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=[],w=[],A=[],C=[];let I=s;const L=(l-s)/f,D=new ne,O=new pt;for(let G=0;G<=f;G++){for(let Z=0;Z<=h;Z++){const Y=g+Z/h*_;D.x=I*Math.cos(Y),D.y=I*Math.sin(Y),w.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,C.push(O.x,O.y)}I+=L}for(let G=0;G<f;G++){const Z=G*(h+1);for(let Y=0;Y<h;Y++){const Q=Y+Z,ee=Q,ae=Q+h+1,Re=Q+h+2,Oe=Q+1;b.push(ee,ae,Oe),b.push(ae,Re,Oe)}}this.setIndex(b),this.setAttribute("position",new Wt(w,3)),this.setAttribute("normal",new Wt(A,3)),this.setAttribute("uv",new Wt(C,2))}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}static fromJSON(s){return new xf(s.innerRadius,s.outerRadius,s.thetaSegments,s.phiSegments,s.thetaStart,s.thetaLength)}}class $h extends Gn{constructor(s=new Vh([new pt(0,.5),new pt(-.5,-.5),new pt(.5,-.5)]),l=12){super(),this.type="ShapeGeometry",this.parameters={shapes:s,curveSegments:l};const h=[],f=[],g=[],_=[];let b=0,w=0;if(Array.isArray(s)===!1)A(s);else for(let C=0;C<s.length;C++)A(s[C]),this.addGroup(b,w,C),b+=w,w=0;this.setIndex(h),this.setAttribute("position",new Wt(f,3)),this.setAttribute("normal",new Wt(g,3)),this.setAttribute("uv",new Wt(_,2));function A(C){const I=f.length/3,L=C.extractPoints(l);let D=L.shape;const O=L.holes;Ro.isClockWise(D)===!1&&(D=D.reverse());for(let Z=0,Y=O.length;Z<Y;Z++){const Q=O[Z];Ro.isClockWise(Q)===!0&&(O[Z]=Q.reverse())}const G=Ro.triangulateShape(D,O);for(let Z=0,Y=O.length;Z<Y;Z++){const Q=O[Z];D=D.concat(Q)}for(let Z=0,Y=D.length;Z<Y;Z++){const Q=D[Z];f.push(Q.x,Q.y,0),g.push(0,0,1),_.push(Q.x,Q.y)}for(let Z=0,Y=G.length;Z<Y;Z++){const Q=G[Z],ee=Q[0]+I,ae=Q[1]+I,Re=Q[2]+I;h.push(ee,ae,Re),w+=3}}}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}toJSON(){const s=super.toJSON(),l=this.parameters.shapes;return aS(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 $h(h,s.curveSegments)}}function aS(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 qh extends Gn{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 w=Math.min(_+b,Math.PI);let A=0;const C=[],I=new ne,L=new ne,D=[],O=[],G=[],Z=[];for(let Y=0;Y<=h;Y++){const Q=[],ee=Y/h;let ae=0;Y===0&&_===0?ae=.5/l:Y===h&&w===Math.PI&&(ae=-.5/l);for(let Re=0;Re<=l;Re++){const Oe=Re/l;I.x=-s*Math.cos(f+Oe*g)*Math.sin(_+ee*b),I.y=s*Math.cos(_+ee*b),I.z=s*Math.sin(f+Oe*g)*Math.sin(_+ee*b),O.push(I.x,I.y,I.z),L.copy(I).normalize(),G.push(L.x,L.y,L.z),Z.push(Oe+ae,1-ee),Q.push(A++)}C.push(Q)}for(let Y=0;Y<h;Y++)for(let Q=0;Q<l;Q++){const ee=C[Y][Q+1],ae=C[Y][Q],Re=C[Y+1][Q],Oe=C[Y+1][Q+1];(Y!==0||_>0)&&D.push(ee,ae,Oe),(Y!==h-1||w<Math.PI)&&D.push(ae,Re,Oe)}this.setIndex(D),this.setAttribute("position",new Wt(O,3)),this.setAttribute("normal",new Wt(G,3)),this.setAttribute("uv",new Wt(Z,2))}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}static fromJSON(s){return new qh(s.radius,s.widthSegments,s.heightSegments,s.phiStart,s.phiLength,s.thetaStart,s.thetaLength)}}class tm extends au{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 tm(s.radius,s.detail)}}class nm extends Gn{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=[],w=[],A=[],C=new ne,I=new ne,L=new ne;for(let D=0;D<=h;D++)for(let O=0;O<=f;O++){const G=O/f*g,Z=D/h*Math.PI*2;I.x=(s+l*Math.cos(Z))*Math.cos(G),I.y=(s+l*Math.cos(Z))*Math.sin(G),I.z=l*Math.sin(Z),b.push(I.x,I.y,I.z),C.x=s*Math.cos(G),C.y=s*Math.sin(G),L.subVectors(I,C).normalize(),w.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 G=(f+1)*D+O-1,Z=(f+1)*(D-1)+O-1,Y=(f+1)*(D-1)+O,Q=(f+1)*D+O;_.push(G,Z,Q),_.push(Z,Y,Q)}this.setIndex(_),this.setAttribute("position",new Wt(b,3)),this.setAttribute("normal",new Wt(w,3)),this.setAttribute("uv",new Wt(A,2))}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}static fromJSON(s){return new nm(s.radius,s.tube,s.radialSegments,s.tubularSegments,s.arc)}}class sy extends Gn{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=[],w=[],A=[],C=[],I=new ne,L=new ne,D=new ne,O=new ne,G=new ne,Z=new ne,Y=new ne;for(let ee=0;ee<=h;++ee){const ae=ee/h*g*Math.PI*2;Q(ae,g,_,s,D),Q(ae+.01,g,_,s,O),Z.subVectors(O,D),Y.addVectors(O,D),G.crossVectors(Z,Y),Y.crossVectors(G,Z),G.normalize(),Y.normalize();for(let Re=0;Re<=f;++Re){const Oe=Re/f*Math.PI*2,je=-l*Math.cos(Oe),He=l*Math.sin(Oe);I.x=D.x+(je*Y.x+He*G.x),I.y=D.y+(je*Y.y+He*G.y),I.z=D.z+(je*Y.z+He*G.z),w.push(I.x,I.y,I.z),L.subVectors(I,D).normalize(),A.push(L.x,L.y,L.z),C.push(ee/h),C.push(Re/f)}}for(let ee=1;ee<=h;ee++)for(let ae=1;ae<=f;ae++){const Re=(f+1)*(ee-1)+(ae-1),Oe=(f+1)*ee+(ae-1),je=(f+1)*ee+ae,He=(f+1)*(ee-1)+ae;b.push(Re,Oe,He),b.push(Oe,je,He)}this.setIndex(b),this.setAttribute("position",new Wt(w,3)),this.setAttribute("normal",new Wt(A,3)),this.setAttribute("uv",new Wt(C,2));function Q(ee,ae,Re,Oe,je){const He=Math.cos(ee),ct=Math.sin(ee),dt=Re/ae*ee,tn=Math.cos(dt);je.x=Oe*(2+tn)*.5*He,je.y=Oe*(2+tn)*ct*.5,je.z=Oe*Math.sin(dt)*.5}}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}static fromJSON(s){return new sy(s.radius,s.tube,s.tubularSegments,s.radialSegments,s.p,s.q)}}class vf extends Gn{constructor(s=new F0(new ne(-1,-1,0),new ne(-1,1,0),new ne(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 ne,w=new ne,A=new pt;let C=new ne;const I=[],L=[],D=[],O=[];G(),this.setIndex(O),this.setAttribute("position",new Wt(I,3)),this.setAttribute("normal",new Wt(L,3)),this.setAttribute("uv",new Wt(D,2));function G(){for(let ee=0;ee<l;ee++)Z(ee);Z(g===!1?l:0),Q(),Y()}function Z(ee){C=s.getPointAt(ee/l,C);const ae=_.normals[ee],Re=_.binormals[ee];for(let Oe=0;Oe<=f;Oe++){const je=Oe/f*Math.PI*2,He=Math.sin(je),ct=-Math.cos(je);w.x=ct*ae.x+He*Re.x,w.y=ct*ae.y+He*Re.y,w.z=ct*ae.z+He*Re.z,w.normalize(),L.push(w.x,w.y,w.z),b.x=C.x+h*w.x,b.y=C.y+h*w.y,b.z=C.z+h*w.z,I.push(b.x,b.y,b.z)}}function Y(){for(let ee=1;ee<=l;ee++)for(let ae=1;ae<=f;ae++){const Re=(f+1)*(ee-1)+(ae-1),Oe=(f+1)*ee+(ae-1),je=(f+1)*ee+ae,He=(f+1)*(ee-1)+ae;O.push(Re,Oe,He),O.push(Oe,je,He)}}function Q(){for(let ee=0;ee<=l;ee++)for(let ae=0;ae<=f;ae++)A.x=ee/l,A.y=ae/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 vf(new Ga[s.path.type]().fromJSON(s.path),s.tubularSegments,s.radius,s.radialSegments,s.closed)}}class k0 extends Gn{constructor(s=null){if(super(),this.type="WireframeGeometry",this.parameters={geometry:s},s!==null){const l=[],h=new Set,f=new ne,g=new ne;if(s.index!==null){const _=s.attributes.position,b=s.index;let w=s.groups;w.length===0&&(w=[{start:0,count:b.count,materialIndex:0}]);for(let A=0,C=w.length;A<C;++A){const I=w[A],L=I.start,D=I.count;for(let O=L,G=L+D;O<G;O+=3)for(let Z=0;Z<3;Z++){const Y=b.getX(O+Z),Q=b.getX(O+(Z+1)%3);f.fromBufferAttribute(_,Y),g.fromBufferAttribute(_,Q),ry(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,w=_.count/3;b<w;b++)for(let A=0;A<3;A++){const C=3*b+A,I=3*b+(A+1)%3;f.fromBufferAttribute(_,C),g.fromBufferAttribute(_,I),ry(f,g,h)===!0&&(l.push(f.x,f.y,f.z),l.push(g.x,g.y,g.z))}}this.setAttribute("position",new Wt(l,3))}}copy(s){return super.copy(s),this.parameters=Object.assign({},s.parameters),this}}function ry(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 oy=Object.freeze({__proto__:null,BoxGeometry:Lp,CapsuleGeometry:Bh,CircleGeometry:Oh,ConeGeometry:ou,CylinderGeometry:Uh,DodecahedronGeometry:Eo,EdgesGeometry:Wg,ExtrudeGeometry:ic,IcosahedronGeometry:iy,LatheGeometry:gl,OctahedronGeometry:Wh,PlaneGeometry:_f,PolyhedronGeometry:au,RingGeometry:xf,ShapeGeometry:$h,SphereGeometry:qh,TetrahedronGeometry:tm,TorusGeometry:nm,TorusKnotGeometry:sy,TubeGeometry:vf,WireframeGeometry:k0});class z0 extends null{constructor(s){super(),this.isShadowMaterial=!0,this.type="ShadowMaterial",this.color=new Un(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 ay extends null{constructor(s){super(s),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class V0 extends null{constructor(s){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new Un(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 Un(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ur,this.normalScale=new pt(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 ro,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 G0 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 pt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Tn(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 Un(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 Un(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new Un(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 ly extends Tg{constructor(s){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new Un(16777215),this.specular=new Un(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Un(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ur,this.normalScale=new pt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ro,this.combine=Rc,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 cy extends null{constructor(s){super(),this.isMeshToonMaterial=!0,this.defines={TOON:""},this.type="MeshToonMaterial",this.color=new Un(16777215),this.map=null,this.gradientMap=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Un(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ur,this.normalScale=new pt(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 fu extends null{constructor(s){super(),this.isMeshNormalMaterial=!0,this.type="MeshNormalMaterial",this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ur,this.normalScale=new pt(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 H0 extends null{constructor(s){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Un(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Un(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ur,this.normalScale=new pt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new ro,this.combine=Rc,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 W0 extends null{constructor(s){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=wb,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 uy 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 hy extends null{constructor(s){super(),this.isMeshMatcapMaterial=!0,this.defines={MATCAP:""},this.type="MeshMatcapMaterial",this.color=new Un(16777215),this.matcap=null,this.map=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ur,this.normalScale=new pt(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 lS 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 pu(E,s){return!E||E.constructor===s?E:typeof s.BYTES_PER_ELEMENT=="number"?new s(E):Array.prototype.slice.call(E)}function cS(E){return ArrayBuffer.isView(E)&&!(E instanceof DataView)}function bf(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 dy(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 w=0;w!==s;++w)f[_++]=E[b+w]}return f}function im(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 uS(E,s,l,h,f=30){const g=E.clone();g.name=s;const _=[];for(let w=0;w<g.tracks.length;++w){const A=g.tracks[w],C=A.getValueSize(),I=[],L=[];for(let D=0;D<A.times.length;++D){const O=A.times[D]*f;if(!(O<l||O>=h)){I.push(A.times[D]);for(let G=0;G<C;++G)L.push(A.values[D*C+G])}}I.length!==0&&(A.times=pu(I,A.times.constructor),A.values=pu(L,A.values.constructor),_.push(A))}g.tracks=_;let b=1/0;for(let w=0;w<g.tracks.length;++w)b>g.tracks[w].times[0]&&(b=g.tracks[w].times[0]);for(let w=0;w<g.tracks.length;++w)g.tracks[w].shift(-1*b);return g.resetDuration(),g}function sa(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[_],w=b.ValueTypeName;if(w==="bool"||w==="string")continue;const A=E.tracks.find(function(Y){return Y.name===b.name&&Y.ValueTypeName===w});if(A===void 0)continue;let C=0;const I=b.getValueSize();b.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(C=I/3);let L=0;const D=A.getValueSize();A.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline&&(L=D/3);const O=b.times.length-1;let G;if(g<=b.times[0]){const Y=C,Q=I-C;G=b.values.slice(Y,Q)}else if(g>=b.times[O]){const Y=O*I+C,Q=Y+I-C;G=b.values.slice(Y,Q)}else{const Y=b.createInterpolant(),Q=C,ee=I-C;Y.evaluate(g),G=Y.resultBuffer.slice(Q,ee)}w==="quaternion"&&new zr().fromArray(G).normalize().conjugate().toArray(G);const Z=A.times.length;for(let Y=0;Y<Z;++Y){const Q=Y*D+L;if(w==="quaternion")zr.multiplyQuaternionsFlat(A.values,Q,G,0,A.values,Q);else{const ee=D-L*2;for(let ae=0;ae<ee;++ae)A.values[Q+ae]-=G[ae]}}}return E.blendMode=dg,E}class Sf{static convertArray(s,l){return pu(s,l)}static isTypedArray(s){return cS(s)}static getKeyframeOrder(s){return bf(s)}static sortedArray(s,l,h){return dy(s,l,h)}static flattenJSON(s,l,h,f){im(s,l,h,f)}static subclip(s,l,h,f,g=30){return uS(s,l,h,f,g)}static makeClipAdditive(s,l=0,h=s,f=30){return sa(s,l,h,f)}}class Tf{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 w=h-2;;){if(g===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(h===w)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 sm extends Tf{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:Ho,endingEnd:Ho}}intervalChanged_(s,l,h){const f=this.parameterPositions;let g=s-2,_=s+1,b=f[g],w=f[_];if(b===void 0)switch(this.getSettings_().endingStart){case Wo:g=s,b=2*l-h;break;case Oc:g=f.length-2,b=l+f[g]-f[g+1];break;default:g=s,b=h}if(w===void 0)switch(this.getSettings_().endingEnd){case Wo:_=s,w=2*h-l;break;case Oc:_=1,w=h+f[1]-f[0];break;default:_=s-1,w=l}const A=(h-l)*.5,C=this.valueSize;this._weightPrev=A/(l-b),this._weightNext=A/(w-h),this._offsetPrev=g*C,this._offsetNext=_*C}interpolate_(s,l,h,f){const g=this.resultBuffer,_=this.sampleValues,b=this.valueSize,w=s*b,A=w-b,C=this._offsetPrev,I=this._offsetNext,L=this._weightPrev,D=this._weightNext,O=(h-l)/(f-l),G=O*O,Z=G*O,Y=-L*Z+2*L*G-L*O,Q=(1+L)*Z+(-1.5-2*L)*G+(-.5+L)*O+1,ee=(-1-D)*Z+(1.5+D)*G+.5*O,ae=D*Z-D*G;for(let Re=0;Re!==b;++Re)g[Re]=Y*_[C+Re]+Q*_[A+Re]+ee*_[w+Re]+ae*_[I+Re];return g}}class $0 extends Tf{constructor(s,l,h,f){super(s,l,h,f)}interpolate_(s,l,h,f){const g=this.resultBuffer,_=this.sampleValues,b=this.valueSize,w=s*b,A=w-b,C=(h-l)/(f-l),I=1-C;for(let L=0;L!==b;++L)g[L]=_[A+L]*I+_[w+L]*C;return g}}class rm extends Tf{constructor(s,l,h,f){super(s,l,h,f)}interpolate_(s){return this.copySampleValue_(s-1)}}class gr{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=pu(l,this.TimeBufferType),this.values=pu(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:pu(s.times,Array),values:pu(s.values,Array)};const f=s.getInterpolation();f!==s.DefaultInterpolation&&(h.interpolation=f)}return h.type=s.ValueTypeName,h}InterpolantFactoryMethodDiscrete(s){return new rm(this.times,this.values,this.getValueSize(),s)}InterpolantFactoryMethodLinear(s){return new $0(this.times,this.values,this.getValueSize(),s)}InterpolantFactoryMethodSmooth(s){return new sm(this.times,this.values,this.getValueSize(),s)}setInterpolation(s){let l;switch(s){case Bc:l=this.InterpolantFactoryMethodDiscrete;break;case Ad:l=this.InterpolantFactoryMethodLinear;break;case Ed: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 _n("KeyframeTrack:",h),this}return this.createInterpolant=l,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Bc;case this.InterpolantFactoryMethodLinear:return Ad;case this.InterpolantFactoryMethodSmooth:return Ed}}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 w=h[b];if(typeof w=="number"&&isNaN(w)){ci("KeyframeTrack: Time is not a valid number.",this,b,w),s=!1;break}if(_!==null&&_>w){ci("KeyframeTrack: Out of order keys.",this,b,w,_),s=!1;break}_=w}if(f!==void 0&&cS(f))for(let b=0,w=f.length;b!==w;++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()===Ed,g=s.length-1;let _=1;for(let b=1;b<g;++b){let w=!1;const A=s[b],C=s[b+1];if(A!==C&&(b!==1||A!==s[0]))if(f)w=!0;else{const I=b*h,L=I-h,D=I+h;for(let O=0;O!==h;++O){const G=l[I+O];if(G!==l[L+O]||G!==l[D+O]){w=!0;break}}}if(w){if(b!==_){s[_]=s[b];const I=b*h,L=_*h;for(let D=0;D!==h;++D)l[L+D]=l[I+D]}++_}}if(g>0){s[_]=s[g];for(let b=g*h,w=_*h,A=0;A!==h;++A)l[w+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}}gr.prototype.ValueTypeName="",gr.prototype.TimeBufferType=Float32Array,gr.prototype.ValueBufferType=Float32Array,gr.prototype.DefaultInterpolation=Ad;class yl extends gr{constructor(s,l,h){super(s,l,h)}}yl.prototype.ValueTypeName="bool",yl.prototype.ValueBufferType=Array,yl.prototype.DefaultInterpolation=Bc,yl.prototype.InterpolantFactoryMethodLinear=void 0,yl.prototype.InterpolantFactoryMethodSmooth=void 0;class wf extends gr{constructor(s,l,h,f){super(s,l,h,f)}}wf.prototype.ValueTypeName="color";class om extends gr{constructor(s,l,h,f){super(s,l,h,f)}}om.prototype.ValueTypeName="number";class hS extends Tf{constructor(s,l,h,f){super(s,l,h,f)}interpolate_(s,l,h,f){const g=this.resultBuffer,_=this.sampleValues,b=this.valueSize,w=(h-l)/(f-l);let A=s*b;for(let C=A+b;A!==C;A+=4)zr.slerpFlat(g,0,_,A-b,_,A,w);return g}}class No extends gr{constructor(s,l,h,f){super(s,l,h,f)}InterpolantFactoryMethodLinear(s){return new hS(this.times,this.values,this.getValueSize(),s)}}No.prototype.ValueTypeName="quaternion",No.prototype.InterpolantFactoryMethodSmooth=void 0;class mu extends gr{constructor(s,l,h){super(s,l,h)}}mu.prototype.ValueTypeName="string",mu.prototype.ValueBufferType=Array,mu.prototype.DefaultInterpolation=Bc,mu.prototype.InterpolantFactoryMethodLinear=void 0,mu.prototype.InterpolantFactoryMethodSmooth=void 0;class am extends gr{constructor(s,l,h,f){super(s,l,h,f)}}am.prototype.ValueTypeName="vector";class Xh{constructor(s="",l=-1,h=[],f=Cd){this.name=s,this.tracks=h,this.duration=l,this.blendMode=f,this.uuid=to(),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(dS(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(gr.toJSON(h[g]));return f}static CreateFromMorphTargetSequence(s,l,h,f){const g=l.length,_=[];for(let b=0;b<g;b++){let w=[],A=[];w.push((b+g-1)%g,b,(b+1)%g),A.push(0,1,0);const C=bf(w);w=dy(w,1,C),A=dy(A,1,C),!f&&w[0]===0&&(w.push(g),A.push(A[0])),_.push(new om(".morphTargetInfluences["+l[b].name+"]",w,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,w=s.length;b<w;b++){const A=s[b],C=A.name.match(g);if(C&&C.length>1){const I=C[1];let L=f[I];L||(f[I]=L=[]),L.push(A)}}const _=[];for(const b in f)_.push(this.CreateFromMorphTargetSequence(b,f[b],l,h));return _}static parseAnimation(s,l){if(_n("AnimationClip: parseAnimation() is deprecated and will be removed with r185"),!s)return ci("AnimationClip: No animation in JSONLoader data."),null;const h=function(I,L,D,O,G){if(D.length!==0){const Z=[],Y=[];im(D,Z,Y,O),Z.length!==0&&G.push(new I(L,Z,Y))}},f=[],g=s.name||"default",_=s.fps||30,b=s.blendMode;let w=s.length||-1;const A=s.hierarchy||[];for(let I=0;I<A.length;I++){const L=A[I].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 G=0;G<L[O].morphTargets.length;G++)D[L[O].morphTargets[G]]=-1;for(const G in D){const Z=[],Y=[];for(let Q=0;Q!==L[O].morphTargets.length;++Q){const ee=L[O];Z.push(ee.time),Y.push(ee.morphTarget===G?1:0)}f.push(new om(".morphTargetInfluence["+G+"]",Z,Y))}w=D.length*_}else{const D=".bones["+l[I].name+"]";h(am,D+".position",L,"pos",f),h(No,D+".quaternion",L,"rot",f),h(am,D+".scale",L,"scl",f)}}return f.length===0?null:new this(g,w,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 _l(E){switch(E.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return om;case"vector":case"vector2":case"vector3":case"vector4":return am;case"color":return wf;case"quaternion":return No;case"bool":case"boolean":return yl;case"string":return mu}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+E)}function dS(E){if(E.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const s=_l(E.type);if(E.times===void 0){const l=[],h=[];im(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 yr={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 fS{constructor(s,l,h){const f=this;let g=!1,_=0,b=0,w;const A=[];this.onStart=void 0,this.onLoad=s,this.onProgress=l,this.onError=h,this._abortController=null,this.itemStart=function(C){b++,g===!1&&f.onStart!==void 0&&f.onStart(C,_,b),g=!0},this.itemEnd=function(C){_++,f.onProgress!==void 0&&f.onProgress(C,_,b),_===b&&(g=!1,f.onLoad!==void 0&&f.onLoad())},this.itemError=function(C){f.onError!==void 0&&f.onError(C)},this.resolveURL=function(C){return w?w(C):C},this.setURLModifier=function(C){return w=C,this},this.addHandler=function(C,I){return A.push(C,I),this},this.removeHandler=function(C){const I=A.indexOf(C);return I!==-1&&A.splice(I,2),this},this.getHandler=function(C){for(let I=0,L=A.length;I<L;I+=2){const D=A[I],O=A[I+1];if(D.global&&(D.lastIndex=0),D.test(C))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 Z1=new fS;class jh{constructor(s){this.manager=s!==void 0?s:Z1,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}}jh.DEFAULT_MATERIAL_NAME="__DEFAULT";const Po={};class K1 extends null{constructor(s,l){super(s),this.response=l}}class gu 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=yr.get(`file:${s}`);if(g!==void 0)return this.manager.itemStart(s),setTimeout(()=>{l&&l(g),this.manager.itemEnd(s)},0),g;if(Po[s]!==void 0){Po[s].push({onLoad:l,onProgress:h,onError:f});return}Po[s]=[],Po[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,w=this.responseType;fetch(_).then(A=>{if(A.status===200||A.status===0){if(A.status===0&&_n("FileLoader: HTTP Status 0 received."),typeof ReadableStream=="undefined"||A.body===void 0||A.body.getReader===void 0)return A;const C=Po[s],I=A.body.getReader(),L=A.headers.get("X-File-Size")||A.headers.get("Content-Length"),D=L?parseInt(L):0,O=D!==0;let G=0;const Z=new ReadableStream({start(Y){Q();function Q(){I.read().then(({done:ee,value:ae})=>{if(ee)Y.close();else{G+=ae.byteLength;const Re=new ProgressEvent("progress",{lengthComputable:O,loaded:G,total:D});for(let Oe=0,je=C.length;Oe<je;Oe++){const He=C[Oe];He.onProgress&&He.onProgress(Re)}Y.enqueue(ae),Q()}},ee=>{Y.error(ee)})}}});return new Response(Z)}else throw new K1(`fetch for "${A.url}" responded with ${A.status}: ${A.statusText}`,A)}).then(A=>{switch(w){case"arraybuffer":return A.arrayBuffer();case"blob":return A.blob();case"document":return A.text().then(C=>new DOMParser().parseFromString(C,b));case"json":return A.json();default:if(b==="")return A.text();{const I=/charset="?([^;"\s]*)"?/i.exec(b),L=I&&I[1]?I[1].toLowerCase():void 0,D=new TextDecoder(L);return A.arrayBuffer().then(O=>D.decode(O))}}}).then(A=>{yr.add(`file:${s}`,A);const C=Po[s];delete Po[s];for(let I=0,L=C.length;I<L;I++){const D=C[I];D.onLoad&&D.onLoad(A)}}).catch(A=>{const C=Po[s];if(C===void 0)throw this.manager.itemError(s),A;delete Po[s];for(let I=0,L=C.length;I<L;I++){const D=C[I];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 J1 extends null{constructor(s){super(s)}load(s,l,h,f){const g=this,_=new gu(this.manager);_.setPath(this.path),_.setRequestHeader(this.requestHeader),_.setWithCredentials(this.withCredentials),_.load(s,function(b){try{l(g.parse(JSON.parse(b)))}catch(w){f?f(w):ci(w),g.manager.itemError(s)}},h,f)}parse(s){const l=[];for(let h=0;h<s.length;h++){const f=Xh.parse(s[h]);l.push(f)}return l}}class Yh extends null{constructor(s){super(s)}load(s,l,h,f){const g=this,_=[],b=new Hg,w=new gu(this.manager);w.setPath(this.path),w.setResponseType("arraybuffer"),w.setRequestHeader(this.requestHeader),w.setWithCredentials(g.withCredentials);let A=0;function C(I){w.load(s[I],function(L){const D=g.parse(L,!0);_[I]={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 I=0,L=s.length;I<L;++I)C(I);else w.load(s,function(I){const L=g.parse(I,!0);if(L.isCubemap){const D=L.mipmaps.length/L.mipmapCount;for(let O=0;O<D;O++){_[O]={mipmaps:[]};for(let G=0;G<L.mipmapCount;G++)_[O].mipmaps.push(L.mipmaps[O*L.mipmapCount+G]),_[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 yu=new WeakMap;class Zh 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,_=yr.get(`image:${s}`);if(_!==void 0){if(_.complete===!0)g.manager.itemStart(s),setTimeout(function(){l&&l(_),g.manager.itemEnd(s)},0);else{let I=yu.get(_);I===void 0&&(I=[],yu.set(_,I)),I.push({onLoad:l,onError:f})}return _}const b=Ma("img");function w(){C(),l&&l(this);const I=yu.get(this)||[];for(let L=0;L<I.length;L++){const D=I[L];D.onLoad&&D.onLoad(this)}yu.delete(this),g.manager.itemEnd(s)}function A(I){C(),f&&f(I),yr.remove(`image:${s}`);const L=yu.get(this)||[];for(let D=0;D<L.length;D++){const O=L[D];O.onError&&O.onError(I)}yu.delete(this),g.manager.itemError(s),g.manager.itemEnd(s)}function C(){b.removeEventListener("load",w,!1),b.removeEventListener("error",A,!1)}return b.addEventListener("load",w,!1),b.addEventListener("error",A,!1),s.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(b.crossOrigin=this.crossOrigin),yr.add(`image:${s}`,b),g.manager.itemStart(s),b.src=s,b}}class pS extends null{constructor(s){super(s)}load(s,l,h,f){const g=new Wd;g.colorSpace=Ei;const _=new Zh(this.manager);_.setCrossOrigin(this.crossOrigin),_.setPath(this.path);let b=0;function w(A){_.load(s[A],function(C){g.images[A]=C,b++,b===6&&(g.needsUpdate=!0,l&&l(g))},void 0,f)}for(let A=0;A<s.length;++A)w(A);return g}}class mS extends null{constructor(s){super(s)}load(s,l,h,f){const g=this,_=new Ba,b=new gu(this.manager);return b.setResponseType("arraybuffer"),b.setRequestHeader(this.requestHeader),b.setPath(this.path),b.setWithCredentials(g.withCredentials),b.load(s,function(w){let A;try{A=g.parse(w)}catch(C){if(f!==void 0)f(C);else{C(C);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=Ds),A.mipmapCount===1&&(_.minFilter=Yn),A.generateMipmaps!==void 0&&(_.generateMipmaps=A.generateMipmaps),_.needsUpdate=!0,l&&l(_,A)},h,f),_}}class q0 extends null{constructor(s){super(s)}load(s,l,h,f){const g=new no,_=new Zh(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 Q1 extends null{constructor(s,l=1){super(),this.isLight=!0,this.type="Light",this.color=new Un(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 lm extends null{constructor(s,l,h){super(s,h),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Wi.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Un(l)}copy(s,l){return super.copy(s,l),this.groundColor.copy(s.groundColor),this}}const cm=new Pn,Kh=new ne,um=new ne;class eA{constructor(s){this.camera=s,this.intensity=1,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new pt(512,512),this.mapType=Ui,this.map=null,this.mapPass=null,this.matrix=new Pn,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new kg,this._frameExtents=new pt(1,1),this._viewportCount=1,this._viewports=[new tr(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(s){const l=this.camera,h=this.matrix;Kh.setFromMatrixPosition(s.matrixWorld),l.position.copy(Kh),um.setFromMatrixPosition(s.target.matrixWorld),l.lookAt(um),l.updateMatrixWorld(),cm.multiplyMatrices(l.projectionMatrix,l.matrixWorldInverse),this._frustum.setFromProjectionMatrix(cm,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(cm)}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 X0 extends null{constructor(){super(new nr(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(s){const l=this.camera,h=Pd*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 Jh 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(Wi.DEFAULT_UP),this.updateMatrix(),this.target=new Wi,this.distance=h,this.angle=f,this.penumbra=g,this.decay=_,this.map=null,this.shadow=new X0}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 j0=new Pn,_u=new ne,Mf=new ne;class Y0 extends null{constructor(){super(new nr(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new pt(4,2),this._viewportCount=6,this._viewports=[new tr(2,1,1,1),new tr(0,1,1,1),new tr(3,1,1,1),new tr(1,1,1,1),new tr(3,0,1,1),new tr(1,0,1,1)],this._cubeDirections=[new ne(1,0,0),new ne(-1,0,0),new ne(0,0,1),new ne(0,0,-1),new ne(0,1,0),new ne(0,-1,0)],this._cubeUps=[new ne(0,1,0),new ne(0,1,0),new ne(0,1,0),new ne(0,1,0),new ne(0,0,1),new ne(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()),_u.setFromMatrixPosition(s.matrixWorld),h.position.copy(_u),Mf.copy(h.position),Mf.add(this._cubeDirections[l]),h.up.copy(this._cubeUps[l]),h.lookAt(Mf),h.updateMatrixWorld(),f.makeTranslation(-_u.x,-_u.y,-_u.z),j0.multiplyMatrices(h.projectionMatrix,h.matrixWorldInverse),this._frustum.setFromProjectionMatrix(j0,h.coordinateSystem,h.reversedDepth)}}class gS 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 Y0}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 fy 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,w=f-l;if(this.view!==null&&this.view.enabled){const A=(this.right-this.left)/this.view.fullWidth/this.zoom,C=(this.top-this.bottom)/this.view.fullHeight/this.zoom;g+=A*this.view.offsetX,_=g+A*this.view.width,b-=C*this.view.offsetY,w=b-C*this.view.height}this.projectionMatrix.makeOrthographic(g,_,b,w,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 py extends null{constructor(){super(new fy(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Z0 extends null{constructor(s,l){super(s,l),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Wi.DEFAULT_UP),this.updateMatrix(),this.target=new Wi,this.shadow=new py}dispose(){this.shadow.dispose()}copy(s){return super.copy(s),this.target=s.target.clone(),this.shadow=s.shadow.clone(),this}}class yS extends null{constructor(s,l){super(s,l),this.isAmbientLight=!0,this.type="AmbientLight"}}class _S 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 tA{constructor(){this.isSphericalHarmonics3=!0,this.coefficients=[];for(let s=0;s<9;s++)this.coefficients.push(new ne)}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 xS extends null{constructor(s=new tA,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 hm extends null{constructor(s){super(s),this.textures={}}load(s,l,h,f){const g=this,_=new gu(g.manager);_.setPath(g.path),_.setRequestHeader(g.requestHeader),_.setWithCredentials(g.withCredentials),_.load(s,function(b){try{l(g.parse(JSON.parse(b)))}catch(w){f?f(w):ci(w),g.manager.itemError(s)}},h,f)}parse(s){const l=this.textures;function h(g){return l[g]===void 0&&_n("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 Un().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 Un().setHex(_.value);break;case"v2":f.uniforms[g].value=new pt().fromArray(_.value);break;case"v3":f.uniforms[g].value=new ne().fromArray(_.value);break;case"v4":f.uniforms[g].value=new tr().fromArray(_.value);break;case"m3":f.uniforms[g].value=new $s().fromArray(_.value);break;case"m4":f.uniforms[g].value=new Pn().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 pt().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 pt().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 hm.createMaterialFromType(s)}static createMaterialFromType(s){const l={ShadowMaterial:z0,SpriteMaterial:Jc,RawShaderMaterial:ay,ShaderMaterial:Zc,PointsMaterial:Gg,MeshPhysicalMaterial:G0,MeshStandardMaterial:V0,MeshPhongMaterial:ly,MeshToonMaterial:cy,MeshNormalMaterial:fu,MeshLambertMaterial:H0,MeshDepthMaterial:W0,MeshDistanceMaterial:uy,MeshBasicMaterial:Di,MeshMatcapMaterial:hy,LineDashedMaterial:lS,LineBasicMaterial:Pr,Material:Tg};return new l[s]}}class my{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 gy 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 nA extends null{constructor(s){super(s)}load(s,l,h,f){const g=this,_=new gu(g.manager);_.setPath(g.path),_.setRequestHeader(g.requestHeader),_.setWithCredentials(g.withCredentials),_.load(s,function(b){try{l(g.parse(JSON.parse(b)))}catch(w){f?f(w):ci(w),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),Q=kc(Z.type,Y),ee=new Kc(Q,Z.stride);return ee.uuid=Z.uuid,l[O]=ee,ee}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 gy:new Gn,b=s.data.index;if(b!==void 0){const D=kc(b.type,b.array);_.setIndex(new pr(D,1))}const w=s.data.attributes;for(const D in w){const O=w[D];let G;if(O.isInterleavedBufferAttribute){const Z=f(s.data,O.data);G=new Qo(Z,O.itemSize,O.offset,O.normalized)}else{const Z=kc(O.type,O.array),Y=O.isInstancedBufferAttribute?ml:pr;G=new Y(Z,O.itemSize,O.normalized)}O.name!==void 0&&(G.name=O.name),O.usage!==void 0&&G.setUsage(O.usage),_.setAttribute(D,G)}const A=s.data.morphAttributes;if(A)for(const D in A){const O=A[D],G=[];for(let Z=0,Y=O.length;Z<Y;Z++){const Q=O[Z];let ee;if(Q.isInterleavedBufferAttribute){const ae=f(s.data,Q.data);ee=new Qo(ae,Q.itemSize,Q.offset,Q.normalized)}else{const ae=kc(Q.type,Q.array);ee=new pr(ae,Q.itemSize,Q.normalized)}Q.name!==void 0&&(ee.name=Q.name),G.push(ee)}_.morphAttributes[D]=G}s.data.morphTargetsRelative&&(_.morphTargetsRelative=!0);const I=s.data.groups||s.data.drawcalls||s.data.offsets;if(I!==void 0)for(let D=0,O=I.length;D!==O;++D){const G=I[D];_.addGroup(G.start,G.count,G.materialIndex)}const L=s.data.boundingSphere;return L!==void 0&&(_.boundingSphere=new Os().fromJSON(L)),s.name&&(_.name=s.name),s.userData&&(_.userData=s.userData),_}}class yy extends null{constructor(s){super(s)}load(s,l,h,f){const g=this,_=this.path===""?my.extractUrlBase(s):this.path;this.resourcePath=this.resourcePath||_;const b=new gu(this.manager);b.setPath(this.path),b.setRequestHeader(this.requestHeader),b.setWithCredentials(this.withCredentials),b.load(s,function(w){let A=null;try{A=JSON.parse(w)}catch(I){f!==void 0&&f(I),I("ObjectLoader: Can't parse "+s+".",I.message);return}const C=A.metadata;if(C===void 0||C.type===void 0||C.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 en(this,null,function*(){const h=this,f=this.path===""?my.extractUrlBase(s):this.path;this.resourcePath=this.resourcePath||f;const g=new gu(this.manager);g.setPath(this.path),g.setRequestHeader(this.requestHeader),g.setWithCredentials(this.withCredentials);const _=yield g.loadAsync(s,l),b=JSON.parse(_),w=b.metadata;if(w===void 0||w.type===void 0||w.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,_),w=this.parseMaterials(s.materials,b),A=this.parseObject(s.object,g,w,b,h),C=this.parseSkeletons(s.skeletons,A);if(this.bindSkeletons(A,C),this.bindLightTargets(A),l!==void 0){let I=!1;for(const L in _)if(_[L].data instanceof HTMLImageElement){I=!0;break}I===!1&&l(A)}return A}parseAsync(s){return en(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,_),w=this.parseObject(s.object,f,b,_,l),A=this.parseSkeletons(s.skeletons,w);return this.bindSkeletons(w,A),this.bindLightTargets(w),w})}parseShapes(s){const l={};if(s!==void 0)for(let h=0,f=s.length;h<f;h++){const g=new Vh().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 Og().fromJSON(s[g],f);h[b.uuid]=b}return h}parseGeometries(s,l){const h={};if(s!==void 0){const f=new nA;for(let g=0,_=s.length;g<_;g++){let b;const w=s[g];switch(w.type){case"BufferGeometry":case"InstancedBufferGeometry":b=f.parse(w);break;default:w.type in oy?b=oy[w.type].fromJSON(w,l):_n(`ObjectLoader: Unsupported geometry type "${w.type}"`)}b.uuid=w.uuid,w.name!==void 0&&(b.name=w.name),w.userData!==void 0&&(b.userData=w.userData),h[w.uuid]=b}}return h}parseMaterials(s,l){const h={},f={};if(s!==void 0){const g=new hm;g.setTextures(l);for(let _=0,b=s.length;_<b;_++){const w=s[_];h[w.uuid]===void 0&&(h[w.uuid]=g.parse(w)),f[w.uuid]=h[w.uuid]}}return f}parseAnimations(s){const l={};if(s!==void 0)for(let h=0;h<s.length;h++){const f=s[h],g=Xh.parse(f);l[g.uuid]=g}return l}parseImages(s,l){const h=this,f={};let g;function _(w){return h.manager.itemStart(w),g.load(w,function(){h.manager.itemEnd(w)},void 0,function(){h.manager.itemError(w),h.manager.itemEnd(w)})}function b(w){if(typeof w=="string"){const A=w,C=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(A)?A:h.resourcePath+A;return _(C)}else return w.data?{data:kc(w.type,w.data),width:w.width,height:w.height}:null}if(s!==void 0&&s.length>0){const w=new fS(l);g=new Zh(w),g.setCrossOrigin(this.crossOrigin);for(let A=0,C=s.length;A<C;A++){const I=s[A],L=I.url;if(Array.isArray(L)){const D=[];for(let O=0,G=L.length;O<G;O++){const Z=L[O],Y=b(Z);Y!==null&&(Y instanceof HTMLImageElement?D.push(Y):D.push(new Ba(Y.data,Y.width,Y.height)))}f[I.uuid]=new Mr(D)}else{const D=b(I.url);f[I.uuid]=new Mr(D)}}}return f}parseImagesAsync(s){return en(this,null,function*(){const l=this,h={};let f;function g(_){return en(this,null,function*(){if(typeof _=="string"){const b=_,w=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(b)?b:l.resourcePath+b;return yield f.loadAsync(w)}else return _.data?{data:kc(_.type,_.data),width:_.width,height:_.height}:null})}if(s!==void 0&&s.length>0){f=new Zh(this.manager),f.setCrossOrigin(this.crossOrigin);for(let _=0,b=s.length;_<b;_++){const w=s[_],A=w.url;if(Array.isArray(A)){const C=[];for(let I=0,L=A.length;I<L;I++){const D=A[I],O=yield g(D);O!==null&&(O instanceof HTMLImageElement?C.push(O):C.push(new Ba(O.data,O.width,O.height)))}h[w.uuid]=new Mr(C)}else{const C=yield g(w.url);h[w.uuid]=new Mr(C)}}}return h})}parseTextures(s,l){function h(g,_){return typeof g=="number"?g:(_n("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&&_n('ObjectLoader: No "image" specified for',b.uuid),l[b.image]===void 0&&_n("ObjectLoader: Undefined image",b.image);const w=l[b.image],A=w.data;let C;Array.isArray(A)?(C=new Wd,A.length===6&&(C.needsUpdate=!0)):(A&&A.data?C=new Ba:C=new no,A&&(C.needsUpdate=!0)),C.source=w,C.uuid=b.uuid,b.name!==void 0&&(C.name=b.name),b.mapping!==void 0&&(C.mapping=h(b.mapping,K0)),b.channel!==void 0&&(C.channel=b.channel),b.offset!==void 0&&C.offset.fromArray(b.offset),b.repeat!==void 0&&C.repeat.fromArray(b.repeat),b.center!==void 0&&C.center.fromArray(b.center),b.rotation!==void 0&&(C.rotation=b.rotation),b.wrap!==void 0&&(C.wrapS=h(b.wrap[0],vS),C.wrapT=h(b.wrap[1],vS)),b.format!==void 0&&(C.format=b.format),b.internalFormat!==void 0&&(C.internalFormat=b.internalFormat),b.type!==void 0&&(C.type=b.type),b.colorSpace!==void 0&&(C.colorSpace=b.colorSpace),b.minFilter!==void 0&&(C.minFilter=h(b.minFilter,_y)),b.magFilter!==void 0&&(C.magFilter=h(b.magFilter,_y)),b.anisotropy!==void 0&&(C.anisotropy=b.anisotropy),b.flipY!==void 0&&(C.flipY=b.flipY),b.generateMipmaps!==void 0&&(C.generateMipmaps=b.generateMipmaps),b.premultiplyAlpha!==void 0&&(C.premultiplyAlpha=b.premultiplyAlpha),b.unpackAlignment!==void 0&&(C.unpackAlignment=b.unpackAlignment),b.compareFunction!==void 0&&(C.compareFunction=b.compareFunction),b.userData!==void 0&&(C.userData=b.userData),f[b.uuid]=C}return f}parseObject(s,l,h,f,g){let _;function b(L){return l[L]===void 0&&_n("ObjectLoader: Undefined geometry",L),l[L]}function w(L){if(L!==void 0){if(Array.isArray(L)){const D=[];for(let O=0,G=L.length;O<G;O++){const Z=L[O];h[Z]===void 0&&_n("ObjectLoader: Undefined material",Z),D.push(h[Z])}return D}return h[L]===void 0&&_n("ObjectLoader: Undefined material",L),h[L]}}function A(L){return f[L]===void 0&&_n("ObjectLoader: Undefined texture",L),f[L]}let C,I;switch(s.type){case"Scene":_=new qd,s.background!==void 0&&(Number.isInteger(s.background)?_.background=new Un(s.background):_.background=A(s.background)),s.environment!==void 0&&(_.environment=A(s.environment)),s.fog!==void 0&&(s.fog.type==="Fog"?_.fog=new Yl(s.fog.color,s.fog.near,s.fog.far):s.fog.type==="FogExp2"&&(_.fog=new $d(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 nr(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 fy(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 yS(s.color,s.intensity);break;case"DirectionalLight":_=new Z0(s.color,s.intensity),_.target=s.target||"";break;case"PointLight":_=new gS(s.color,s.intensity,s.distance,s.decay);break;case"RectAreaLight":_=new _S(s.color,s.intensity,s.width,s.height);break;case"SpotLight":_=new Jh(s.color,s.intensity,s.distance,s.angle,s.penumbra,s.decay),_.target=s.target||"";break;case"HemisphereLight":_=new lm(s.color,s.groundColor,s.intensity);break;case"LightProbe":_=new xS().fromJSON(s);break;case"SkinnedMesh":C=b(s.geometry),I=w(s.material),_=new ea(C,I),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":C=b(s.geometry),I=w(s.material),_=new Xl(C,I);break;case"InstancedMesh":C=b(s.geometry),I=w(s.material);const L=s.count,D=s.instanceMatrix,O=s.instanceColor;_=new Ob(C,I,L),_.instanceMatrix=new ml(new Float32Array(D.array),16),O!==void 0&&(_.instanceColor=new ml(new Float32Array(O.array),O.itemSize));break;case"BatchedMesh":C=b(s.geometry),I=w(s.material),_=new qp(s.maxInstanceCount,s.maxVertexCount,s.maxIndexCount,I),_.geometry=C,_.perObjectFrustumCulled=s.perObjectFrustumCulled,_.sortObjects=s.sortObjects,_._drawRanges=s.drawRanges,_._reservedRanges=s.reservedRanges,_._geometryInfo=s.geometryInfo.map(G=>{let Z=null,Y=null;return G.boundingBox!==void 0&&(Z=new ws().fromJSON(G.boundingBox)),G.boundingSphere!==void 0&&(Y=new Os().fromJSON(G.boundingSphere)),_a(Ii({},G),{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 Os().fromJSON(s.boundingSphere)),s.boundingBox!==void 0&&(_.boundingBox=new ws().fromJSON(s.boundingBox));break;case"LOD":_=new kp;break;case"Line":_=new Dh(b(s.geometry),w(s.material));break;case"LineLoop":_=new zb(b(s.geometry),w(s.material));break;case"LineSegments":_=new nf(b(s.geometry),w(s.material));break;case"PointCloud":case"Points":_=new Y1(b(s.geometry),w(s.material));break;case"Sprite":_=new Lg(w(s.material));break;case"Group":_=new fl;break;case"Bone":_=new iu;break;default:_=new Wi}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],G=_.getObjectByProperty("uuid",O.object);G!==void 0&&_.addLevel(G,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?_n("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 Wi}})}}const K0={UVMapping:$u,CubeReflectionMapping:Br,CubeRefractionMapping:Vo,EquirectangularReflectionMapping:Nc,EquirectangularRefractionMapping:Pc,CubeUVReflectionMapping:Ll},vS={RepeatWrapping:ba,ClampToEdgeWrapping:Ki,MirroredRepeatWrapping:Sa},_y={NearestFilter:Jn,NearestMipmapNearestFilter:gp,NearestMipmapLinearFilter:Ta,LinearFilter:Yn,LinearMipmapNearestFilter:Ic,LinearMipmapLinearFilter:Ds},dm=new WeakMap;class Qh extends null{constructor(s){super(s),this.isImageBitmapLoader=!0,typeof createImageBitmap=="undefined"&&_n("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch=="undefined"&&_n("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,_=yr.get(`image-bitmap:${s}`);if(_!==void 0){if(g.manager.itemStart(s),_.then){_.then(A=>{if(dm.has(_)===!0)f&&f(dm.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 w=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 yr.add(`image-bitmap:${s}`,A),l&&l(A),g.manager.itemEnd(s),A}).catch(function(A){f&&f(A),dm.set(w,A),yr.remove(`image-bitmap:${s}`),g.manager.itemError(s),g.manager.itemEnd(s)});yr.add(`image-bitmap:${s}`,w),g.manager.itemStart(s)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}let xy;class vy{static getContext(){return xy===void 0&&(xy=new(window.AudioContext||window.webkitAudioContext)),xy}static setContext(s){xy=s}}class J0 extends null{constructor(s){super(s)}load(s,l,h,f){const g=this,_=new gu(this.manager);_.setResponseType("arraybuffer"),_.setPath(this.path),_.setRequestHeader(this.requestHeader),_.setWithCredentials(this.withCredentials),_.load(s,function(w){try{const A=w.slice(0);vy.getContext().decodeAudioData(A,function(I){l(I)}).catch(b)}catch(A){b(A)}},h,f);function b(w){f?f(w):ci(w),g.manager.itemError(s)}}}const sc=new Pn,fm=new Pn,xu=new Pn;class ed{constructor(){this.type="StereoCamera",this.aspect=1,this.eyeSep=.064,this.cameraL=new nr,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new nr,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,xu.copy(s.projectionMatrix);const f=l.eyeSep/2,g=f*l.near/l.focus,_=l.near*Math.tan(zc*l.fov*.5)/l.zoom;let b,w;fm.elements[12]=-f,sc.elements[12]=f,b=-_*l.aspect+g,w=_*l.aspect+g,xu.elements[0]=2*l.near/(w-b),xu.elements[8]=(w+b)/(w-b),this.cameraL.projectionMatrix.copy(xu),b=-_*l.aspect-g,w=_*l.aspect-g,xu.elements[0]=2*l.near/(w-b),xu.elements[8]=(w+b)/(w-b),this.cameraR.projectionMatrix.copy(xu)}this.cameraL.matrixWorld.copy(s.matrixWorld).multiply(fm),this.cameraR.matrixWorld.copy(s.matrixWorld).multiply(sc)}}class td extends null{constructor(s=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=s}}class iA{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 nd=new ne,xl=new zr,Q0=new ne,vu=new ne,ao=new ne;class PD extends null{constructor(){super(),this.type="AudioListener",this.context=vy.getContext(),this.gain=this.context.createGain(),this.gain.connect(this.context.destination),this.filter=null,this.timeDelta=0,this._clock=new iA}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(nd,xl,Q0),vu.set(0,0,-1).applyQuaternion(xl),ao.set(0,1,0).applyQuaternion(xl),l.positionX){const h=this.context.currentTime+this.timeDelta;l.positionX.linearRampToValueAtTime(nd.x,h),l.positionY.linearRampToValueAtTime(nd.y,h),l.positionZ.linearRampToValueAtTime(nd.z,h),l.forwardX.linearRampToValueAtTime(vu.x,h),l.forwardY.linearRampToValueAtTime(vu.y,h),l.forwardZ.linearRampToValueAtTime(vu.z,h),l.upX.linearRampToValueAtTime(ao.x,h),l.upY.linearRampToValueAtTime(ao.y,h),l.upZ.linearRampToValueAtTime(ao.z,h)}else l.setPosition(nd.x,nd.y,nd.z),l.setOrientation(vu.x,vu.y,vu.z,ao.x,ao.y,ao.z)}}class ID 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){_n("Audio: Audio is already playing.");return}if(this.hasPlaybackControl===!1){_n("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){_n("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){_n("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){_n("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?(_n("Audio: this Audio has no playback control."),!1):this.loop}setLoop(s){if(this.hasPlaybackControl===!1){_n("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"?(_n("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 bu=new ne,pm=new zr,bS=new ne,vl=new ne;class sA 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(bu,pm,bS),vl.set(0,0,1).applyQuaternion(pm);const l=this.panner;if(l.positionX){const h=this.context.currentTime+this.listener.timeDelta;l.positionX.linearRampToValueAtTime(bu.x,h),l.positionY.linearRampToValueAtTime(bu.y,h),l.positionZ.linearRampToValueAtTime(bu.z,h),l.orientationX.linearRampToValueAtTime(vl.x,h),l.orientationY.linearRampToValueAtTime(vl.y,h),l.orientationZ.linearRampToValueAtTime(vl.z,h)}else l.setPosition(bu.x,bu.y,bu.z),l.setOrientation(vl.x,vl.y,vl.z)}}class rA{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 SS{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 w=l*this._origIndex;this._mixBufferRegion(h,f,w,1-g,l)}_>0&&this._mixBufferRegionAdditive(h,f,this._addIndex*l,1,l);for(let w=l,A=l+l;w!==A;++w)if(h[w]!==h[w+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){zr.slerpFlat(s,l,s,l,s,h,f)}_slerpAdditive(s,l,h,f,g){const _=this._workIndex*g;zr.multiplyQuaternionsFlat(s,_,s,l,s,h),zr.slerpFlat(s,l,s,l,s,_,f)}_lerp(s,l,h,f,g){const _=1-f;for(let b=0;b!==g;++b){const w=l+b;s[w]=s[w]*_+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 by="\\[\\]\\.:\\/",TS=new RegExp("["+by+"]","g"),Sy="[^"+by+"]",wS="[^"+by.replace("\\.","")+"]",MS=/((?:WC+[\/:])*)/.source.replace("WC",Sy),ui=/(WCOD+)?/.source.replace("WCOD",wS),oA=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Sy),AS=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Sy),ES=new RegExp("^"+MS+ui+oA+AS+"$"),aA=["material","materials","bones","map"];class lA{constructor(s,l,h){const f=h||li.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 li{constructor(s,l,h){this.path=l,this.parsedPath=h||li.parseTrackName(l),this.node=li.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 li.Composite(s,l,h):new li(s,l,h)}static sanitizeNodeName(s){return s.replace(/\s/g,"_").replace(TS,"")}static parseTrackName(s){const l=ES.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);aA.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 w=h(b.children);if(w)return w}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=li.findNode(this.rootNode,l.nodeName),this.node=s),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!s){_n("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 C=0;C<s.length;C++)if(s[C].name===A){A=C;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 w=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])}w=this.BindingType.ArrayElement,this.resolvedProperty=_,this.propertyIndex=g}else _.fromArray!==void 0&&_.toArray!==void 0?(w=this.BindingType.HasFromToArray,this.resolvedProperty=_):Array.isArray(_)?(w=this.BindingType.EntireArray,this.resolvedProperty=_):this.propertyName=f;this.getValue=this.GetterByBindingType[w],this.setValue=this.SetterByBindingTypeAndVersioning[w][b]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}li.Composite=lA,li.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},li.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},li.prototype.GetterByBindingType=[li.prototype._getValue_direct,li.prototype._getValue_array,li.prototype._getValue_arrayElement,li.prototype._getValue_toArray],li.prototype.SetterByBindingTypeAndVersioning=[[li.prototype._setValue_direct,li.prototype._setValue_direct_setNeedsUpdate,li.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[li.prototype._setValue_array,li.prototype._setValue_array_setNeedsUpdate,li.prototype._setValue_array_setMatrixWorldNeedsUpdate],[li.prototype._setValue_arrayElement,li.prototype._setValue_arrayElement_setNeedsUpdate,li.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[li.prototype._setValue_fromArray,li.prototype._setValue_fromArray_setNeedsUpdate,li.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class cA{constructor(){this.isAnimationObjectGroup=!0,this.uuid=to(),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,w=s.length,A=this.nCachedObjects_;for(let C=0,I=arguments.length;C!==I;++C){const L=arguments[C],D=L.uuid;let O=l[D];if(O===void 0){O=w++,l[D]=O,s.push(L);for(let G=0,Z=_;G!==Z;++G)g[G].push(new li(L,h[G],f[G]))}else if(O<A){b=s[O];const G=--A,Z=s[G];l[Z.uuid]=O,s[O]=Z,l[D]=G,s[G]=L;for(let Y=0,Q=_;Y!==Q;++Y){const ee=g[Y],ae=ee[G];let Re=ee[O];ee[O]=ae,Re===void 0&&(Re=new li(L,h[Y],f[Y])),ee[G]=Re}}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 w=arguments[_],A=w.uuid,C=l[A];if(C!==void 0&&C>=g){const I=g++,L=s[I];l[L.uuid]=C,s[C]=L,l[A]=I,s[I]=w;for(let D=0,O=f;D!==O;++D){const G=h[D],Z=G[I],Y=G[C];G[C]=Z,G[I]=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,w=arguments.length;b!==w;++b){const A=arguments[b],C=A.uuid,I=l[C];if(I!==void 0)if(delete l[C],I<g){const L=--g,D=s[L],O=--_,G=s[O];l[D.uuid]=I,s[I]=D,l[G.uuid]=L,s[L]=G,s.pop();for(let Z=0,Y=f;Z!==Y;++Z){const Q=h[Z],ee=Q[L],ae=Q[O];Q[I]=ee,Q[L]=ae,Q.pop()}}else{const L=--_,D=s[L];L>0&&(l[D.uuid]=I),s[I]=D,s.pop();for(let O=0,G=f;O!==G;++O){const Z=h[O];Z[I]=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,w=this._objects,A=w.length,C=this.nCachedObjects_,I=new Array(A);f=g.length,h[s]=f,_.push(s),b.push(l),g.push(I);for(let L=C,D=w.length;L!==D;++L){const O=w[L];I[L]=new li(O,s,l)}return I}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,w=_[b],A=s[b];l[A]=h,_[h]=w,_.pop(),g[h]=g[b],g.pop(),f[h]=f[b],f.pop()}}}class uA{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(_),w={endingStart:Ho,endingEnd:Ho};for(let A=0;A!==_;++A){const C=g[A].createInterpolant(null);b[A]=C,C.settings=w}this._interpolantSettings=w,this._interpolants=b,this._propertyBindings=new Array(_),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._weightInterpolant=null,this.loop=Sb,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 w=b.parameterPositions,A=b.sampleValues;return w[0]=g,w[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 w=(s-g)*h;w<0||h===0?l=0:(this._startTime=null,l=h*w)}l*=this._updateTimeScale(s);const _=this._updateTime(l),b=this._updateWeight(s);if(b>0){const w=this._interpolants,A=this._propertyBindings;switch(this.blendMode){case dg:for(let C=0,I=w.length;C!==I;++C)w[C].evaluate(_),A[C].accumulateAdditive(b);break;case Cd:default:for(let C=0,I=w.length;C!==I;++C)w[C].evaluate(_),A[C].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===Tb;if(s===0)return g===-1?f:_&&(g&1)===1?l-f:f;if(h===bb){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 w=this.repetitions-g;if(w<=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(w===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=Wo,f.endingEnd=Wo):(s?f.endingStart=this.zeroSlopeAtStart?Wo:Ho:f.endingStart=Oc,l?f.endingEnd=this.zeroSlopeAtEnd?Wo:Ho:f.endingEnd=Oc)}_scheduleFading(s,l,h){const f=this._mixer,g=f.time;let _=this._weightInterpolant;_===null&&(_=f._lendControlInterpolant(),this._weightInterpolant=_);const b=_.parameterPositions,w=_.sampleValues;return b[0]=g,w[0]=l,b[1]=g+s,w[1]=h,this}}const CS=new Float32Array(1);class LD 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,w=h.uuid,A=this._bindingsByRootAndName;let C=A[w];C===void 0&&(C={},A[w]=C);for(let I=0;I!==g;++I){const L=f[I],D=L.name;let O=C[D];if(O!==void 0)++O.referenceCount,_[I]=O;else{if(O=_[I],O!==void 0){O._cacheIndex===null&&(++O.referenceCount,this._addInactiveBinding(O,w,D));continue}const G=l&&l._propertyBindings[I].binding.parsedPath;O=new SS(li.create(h,D,G),L.ValueTypeName,L.getValueSize()),++O.referenceCount,this._addInactiveBinding(O,w,D),_[I]=O}b[I].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],w=b.knownActions,A=w[w.length-1],C=s._byClipCacheIndex;A._byClipCacheIndex=C,w[C]=A,w.pop(),s._byClipCacheIndex=null;const I=b.actionByRoot,L=(s._localRoot||this._root).uuid;delete I[L],w.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],w=l[l.length-1],A=s._cacheIndex;w._cacheIndex=A,l[A]=w,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 $0(new Float32Array(2),new Float32Array(2),1,CS),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"?Xh.findByName(f,s):s;const b=_!==null?_.uuid:s,w=this._actionsByClip[b];let A=null;if(h===void 0&&(_!==null?h=_.blendMode:h=Cd),w!==void 0){const I=w.actionByRoot[g];if(I!==void 0&&I.blendMode===h)return I;A=w.knownActions[0],_===null&&(_=A._clip)}if(_===null)return null;const C=new uA(this,_,l,h);return this._bindAction(C,A),this._addInactiveAction(C,b,g),C}existingAction(s,l){const h=l||this._root,f=h.uuid,g=typeof s=="string"?Xh.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,w=this._nActiveBindings;for(let A=0;A!==w;++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,w=_.length;b!==w;++b){const A=_[b];this._deactivateAction(A);const C=A._cacheIndex,I=l[l.length-1];A._cacheIndex=null,A._byClipCacheIndex=null,I._cacheIndex=C,l[C]=I,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,w=b[l];w!==void 0&&(this._deactivateAction(w),this._removeInactiveAction(w))}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 RS extends null{constructor(s=1,l=1,h=1,f={}){super(s,l,f),this.isRenderTarget3D=!0,this.depth=h,this.texture=new Gc(null,s,l,h),this._setTextureOptions(f),this.texture.isRenderTargetTexture=!0}}class Ty{constructor(s){this.value=s}clone(){return new Ty(this.value.clone===void 0?this.value:this.value.clone())}}let ex=0;class tx extends null{constructor(){super(),this.isUniformsGroup=!0,Object.defineProperty(this,"id",{value:ex++}),this.name="",this.usage=kl,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 DD 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 hA{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 wy=new Pn;class FD{constructor(s,l,h=0,f=1/0){this.ray=new _o(s,l),this.near=h,this.far=f,this.camera=null,this.layers=new vh,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 wy.identity().extractRotation(s.matrixWorld),this.ray.origin.setFromMatrixPosition(s.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(wy),this}intersectObject(s,l=!0,h=[]){return mm(s,this,h,l),h.sort(Af),h}intersectObjects(s,l=!0,h=[]){for(let f=0,g=s.length;f<g;f++)mm(s[f],this,h,l);return h.sort(Af),h}}function Af(E,s){return E.distance-s.distance}function mm(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;_++)mm(g[_],s,l,!0)}}class BD{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=nx.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 nx(){this._document.hidden===!1&&this.reset()}class My{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=Tn(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(Tn(l/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}class Ef{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 Su{constructor(s,l,h,f){Su.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 gm=new pt;class dA{constructor(s=new pt(1/0,1/0),l=new pt(-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=gm.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,gm).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 ix=new ne,Ay=new ne,Tu=new ne,Cf=new ne,Ha=new ne,ym=new ne,Ey=new ne;class OD{constructor(s=new ne,l=new ne){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){ix.subVectors(s,this.start),Ay.subVectors(this.end,this.start);const h=Ay.dot(Ay);let g=Ay.dot(ix)/h;return l&&(g=Tn(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=ym,h=Ey){const f=10000000000000001e-32;let g,_;const b=this.start,w=s.start,A=this.end,C=s.end;Tu.subVectors(A,b),Cf.subVectors(C,w),Ha.subVectors(b,w);const I=Tu.dot(Tu),L=Cf.dot(Cf),D=Cf.dot(Ha);if(I<=f&&L<=f)return l.copy(b),h.copy(w),l.sub(h),l.dot(l);if(I<=f)g=0,_=D/L,_=Tn(_,0,1);else{const O=Tu.dot(Ha);if(L<=f)_=0,g=Tn(-O/I,0,1);else{const G=Tu.dot(Cf),Z=I*L-G*G;Z!==0?g=Tn((G*D-O*L)/Z,0,1):g=0,_=(G*g+D)/L,_<0?(_=0,g=Tn(-O/I,0,1)):_>1&&(_=1,g=Tn((G-O)/I,0,1))}}return l.copy(b).add(Tu.multiplyScalar(g)),h.copy(w).add(Cf.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 Cy=new ne;class UD extends null{constructor(s,l){super(),this.light=s,this.matrixAutoUpdate=!1,this.color=l,this.type="SpotLightHelper";const h=new Gn,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,w=32;_<w;_++,b++){const A=_/w*Math.PI*2,C=b/w*Math.PI*2;f.push(Math.cos(A),Math.sin(A),1,Math.cos(C),Math.sin(C),1)}h.setAttribute("position",new Wt(f,3));const g=new Pr({fog:!1,toneMapped:!1});this.cone=new nf(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),Cy.setFromMatrixPosition(this.light.target.matrixWorld),this.cone.lookAt(Cy),this.color!==void 0?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)}}const rc=new ne,Rf=new Pn,_m=new Pn;class kD extends null{constructor(s){const l=NS(s),h=new Gn,f=[],g=[];for(let A=0;A<l.length;A++){const C=l[A];C.parent&&C.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 Wt(f,3)),h.setAttribute("color",new Wt(g,3));const _=new Pr({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 Un(255),w=new Un(65280);this.setColors(b,w)}updateMatrixWorld(s){const l=this.bones,h=this.geometry,f=h.getAttribute("position");_m.copy(this.root.matrixWorld).invert();for(let g=0,_=0;g<l.length;g++){const b=l[g];b.parent&&b.parent.isBone&&(Rf.multiplyMatrices(_m,b.matrixWorld),rc.setFromMatrixPosition(Rf),f.setXYZ(_,rc.x,rc.y,rc.z),Rf.multiplyMatrices(_m,b.parent.matrixWorld),rc.setFromMatrixPosition(Rf),f.setXYZ(_+1,rc.x,rc.y,rc.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 NS(E){const s=[];E.isBone===!0&&s.push(E);for(let l=0;l<E.children.length;l++)s.push(...NS(E.children[l]));return s}class zD extends null{constructor(s,l,h){const f=new qh(l,4,2),g=new Di({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 sx=new ne,Nf=new Un,Ry=new Un;class VD 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 Wh(l);f.rotateY(Math.PI*.5),this.material=new Di({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 pr(_,3)),this.add(new Xl(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");Nf.copy(this.light.color),Ry.copy(this.light.groundColor);for(let h=0,f=l.count;h<f;h++){const g=h<f/2?Nf:Ry;l.setXYZ(h,g.r,g.g,g.b)}l.needsUpdate=!0}this.light.updateWorldMatrix(!0,!1),s.lookAt(sx.setFromMatrixPosition(this.light.matrixWorld).negate())}}class Ny extends null{constructor(s=10,l=10,h=4473924,f=8947848){h=new Un(h),f=new Un(f);const g=l/2,_=s/l,b=s/2,w=[],A=[];for(let L=0,D=0,O=-b;L<=l;L++,O+=_){w.push(-b,0,O,b,0,O),w.push(O,0,-b,O,0,b);const G=L===g?h:f;G.toArray(A,D),D+=3,G.toArray(A,D),D+=3,G.toArray(A,D),D+=3,G.toArray(A,D),D+=3}const C=new Gn;C.setAttribute("position",new Wt(w,3)),C.setAttribute("color",new Wt(A,3));const I=new Pr({vertexColors:!0,toneMapped:!1});super(C,I),this.type="GridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}class ms extends null{constructor(s=10,l=16,h=8,f=64,g=4473924,_=8947848){g=new Un(g),_=new Un(_);const b=[],w=[];if(l>1)for(let I=0;I<l;I++){const L=I/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 G=I&1?g:_;w.push(G.r,G.g,G.b),w.push(G.r,G.g,G.b)}for(let I=0;I<h;I++){const L=I&1?g:_,D=s-s/h*I;for(let O=0;O<f;O++){let G=O/f*(Math.PI*2),Z=Math.sin(G)*D,Y=Math.cos(G)*D;b.push(Z,0,Y),w.push(L.r,L.g,L.b),G=(O+1)/f*(Math.PI*2),Z=Math.sin(G)*D,Y=Math.cos(G)*D,b.push(Z,0,Y),w.push(L.r,L.g,L.b)}}const A=new Gn;A.setAttribute("position",new Wt(b,3)),A.setAttribute("color",new Wt(w,3));const C=new Pr({vertexColors:!0,toneMapped:!1});super(A,C),this.type="PolarGridHelper"}dispose(){this.geometry.dispose(),this.material.dispose()}}const PS=new ne,qi=new ne,Pf=new ne;class GD 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 Gn;f.setAttribute("position",new Wt([-l,l,0,l,l,0,l,-l,0,-l,-l,0,-l,l,0],3));const g=new Pr({fog:!1,toneMapped:!1});this.lightPlane=new Dh(f,g),this.add(this.lightPlane),f=new Gn,f.setAttribute("position",new Wt([0,0,0,0,0,1],3)),this.targetLine=new Dh(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),PS.setFromMatrixPosition(this.light.matrixWorld),qi.setFromMatrixPosition(this.light.target.matrixWorld),Pf.subVectors(qi,PS),this.lightPlane.lookAt(qi),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(qi),this.targetLine.scale.z=Pf.length()}}const Py=new ne,gs=new Eh;class IS extends null{constructor(s){const l=new Gn,h=new Pr({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,G){w(O),w(G)}function w(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 Wt(f,3)),l.setAttribute("color",new Wt(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 Un(16755200),C=new Un(16711680),I=new Un(43775),L=new Un(16777215),D=new Un(3355443);this.setColors(A,C,I,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(gs.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),this.camera.reversedDepth===!0)g=1,_=0;else if(this.camera.coordinateSystem===ki)g=-1,_=1;else if(this.camera.coordinateSystem===Sr)g=0,_=1;else throw new Error("THREE.CameraHelper.update(): Invalid coordinate system: "+this.camera.coordinateSystem);Xi("c",l,s,gs,0,0,g),Xi("t",l,s,gs,0,0,_),Xi("n1",l,s,gs,-h,-f,g),Xi("n2",l,s,gs,h,-f,g),Xi("n3",l,s,gs,-h,f,g),Xi("n4",l,s,gs,h,f,g),Xi("f1",l,s,gs,-h,-f,_),Xi("f2",l,s,gs,h,-f,_),Xi("f3",l,s,gs,-h,f,_),Xi("f4",l,s,gs,h,f,_),Xi("u1",l,s,gs,h*.7,f*1.1,g),Xi("u2",l,s,gs,-h*.7,f*1.1,g),Xi("u3",l,s,gs,0,f*2,g),Xi("cf1",l,s,gs,-h,0,_),Xi("cf2",l,s,gs,h,0,_),Xi("cf3",l,s,gs,0,-f,_),Xi("cf4",l,s,gs,0,f,_),Xi("cn1",l,s,gs,-h,0,g),Xi("cn2",l,s,gs,h,0,g),Xi("cn3",l,s,gs,0,-f,g),Xi("cn4",l,s,gs,0,f,g),s.getAttribute("position").needsUpdate=!0}dispose(){this.geometry.dispose(),this.material.dispose()}}function Xi(E,s,l,h,f,g,_){Py.set(f,g,_).unproject(h);const b=s[E];if(b!==void 0){const w=l.getAttribute("position");for(let A=0,C=b.length;A<C;A++)w.setXYZ(b[A],Py.x,Py.y,Py.z)}}const id=new ws;class HD 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 Gn;g.setIndex(new pr(h,1)),g.setAttribute("position",new pr(f,3)),super(g,new Pr({color:l,toneMapped:!1})),this.object=s,this.type="BoxHelper",this.matrixAutoUpdate=!1,this.update()}update(){if(this.object!==void 0&&id.setFromObject(this.object),id.isEmpty())return;const s=id.min,l=id.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 WD 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 Gn;g.setIndex(new pr(h,1)),g.setAttribute("position",new Wt(f,3)),super(g,new Pr({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 $D 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 Gn;_.setAttribute("position",new Wt(g,3)),_.computeBoundingSphere(),super(_,new Pr({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],w=new Gn;w.setAttribute("position",new Wt(b,3)),w.computeBoundingSphere(),this.add(new Xl(w,new Di({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 If=new ne;let xm,Iy;class fA extends null{constructor(s=new ne(0,0,1),l=new ne(0,0,0),h=1,f=16776960,g=h*.2,_=g*.2){super(),this.type="ArrowHelper",xm===void 0&&(xm=new Gn,xm.setAttribute("position",new Wt([0,0,0,0,1,0],3)),Iy=new ou(.5,1,5,1),Iy.translate(0,-.5,0)),this.position.copy(l),this.line=new Dh(xm,new Pr({color:f,toneMapped:!1})),this.line.matrixAutoUpdate=!1,this.add(this.line),this.cone=new Xl(Iy,new Di({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{If.set(s.z,0,-s.x).normalize();const l=Math.acos(s.y);this.quaternion.setFromAxisAngle(If,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 Ly 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 Gn;f.setAttribute("position",new Wt(l,3)),f.setAttribute("color",new Wt(h,3));const g=new Pr({vertexColors:!0,toneMapped:!1});super(f,g),this.type="AxesHelper"}setColors(s,l,h){const f=new Un,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 pA{constructor(){this.type="ShapePath",this.color=new Un,this.subPaths=[],this.currentPath=null}moveTo(s,l){return this.currentPath=new Zg,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 Q=[];for(let ee=0,ae=Y.length;ee<ae;ee++){const Re=Y[ee],Oe=new Vh;Oe.curves=Re.curves,Q.push(Oe)}return Q}function h(Y,Q){const ee=Q.length;let ae=!1;for(let Re=ee-1,Oe=0;Oe<ee;Re=Oe++){let je=Q[Re],He=Q[Oe],ct=He.x-je.x,dt=He.y-je.y;if(Math.abs(dt)>Number.EPSILON){if(dt<0&&(je=Q[Oe],ct=-ct,He=Q[Re],dt=-dt),Y.y<je.y||Y.y>He.y)continue;if(Y.y===je.y){if(Y.x===je.x)return!0}else{const tn=dt*(Y.x-je.x)-ct*(Y.y-je.y);if(tn===0)return!0;if(tn<0)continue;ae=!ae}}else{if(Y.y!==je.y)continue;if(He.x<=Y.x&&Y.x<=je.x||je.x<=Y.x&&Y.x<=He.x)return!0}}return ae}const f=Ro.isClockWise,g=this.subPaths;if(g.length===0)return[];let _,b,w;const A=[];if(g.length===1)return b=g[0],w=new Vh,w.curves=b.curves,A.push(w),A;let C=!f(g[0].getPoints());C=s?!C:C;const I=[],L=[];let D=[],O=0,G;L[O]=void 0,D[O]=[];for(let Y=0,Q=g.length;Y<Q;Y++)b=g[Y],G=b.getPoints(),_=f(G),_=s?!_:_,_?(!C&&L[O]&&O++,L[O]={s:new Vh,p:G},L[O].s.curves=b.curves,C&&O++,D[O]=[]):D[O].push({h:b,p:G[0]});if(!L[0])return l(g);if(L.length>1){let Y=!1,Q=0;for(let ee=0,ae=L.length;ee<ae;ee++)I[ee]=[];for(let ee=0,ae=L.length;ee<ae;ee++){const Re=D[ee];for(let Oe=0;Oe<Re.length;Oe++){const je=Re[Oe];let He=!0;for(let ct=0;ct<L.length;ct++)h(je.p,L[ct].p)&&(ee!==ct&&Q++,He?(He=!1,I[ct].push(je)):Y=!0);He&&I[ee].push(je)}}Q>0&&Y===!1&&(D=I)}let Z;for(let Y=0,Q=L.length;Y<Q;Y++){w=L[Y].s,A.push(w),Z=D[Y];for(let ee=0,ae=Z.length;ee<ae;ee++)w.holes.push(Z[ee].h)}return A}}class qD 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){_n("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=s}disconnect(){}dispose(){}update(){}}function sd(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 bl(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 rx(E){return E.repeat.x=1,E.repeat.y=1,E.offset.x=0,E.offset.y=0,E}function Dy(E,s,l,h){const f=vm(h);switch(l){case cg:return E*s;case Fc:return E*s/f.components*f.byteLength;case Dl:return E*s/f.components*f.byteLength;case rl:return E*s*2/f.components*f.byteLength;case qu:return E*s*2/f.components*f.byteLength;case bd:return E*s*3/f.components*f.byteLength;case _i:return E*s*4/f.components*f.byteLength;case Xu:return E*s*4/f.components*f.byteLength;case Fl:case Bl:return Math.floor((E+3)/4)*Math.floor((s+3)/4)*8;case Ol:case Ul:return Math.floor((E+3)/4)*Math.floor((s+3)/4)*16;case Td:case Md:return Math.max(E,16)*Math.max(s,8)/4;case Sd:case wd:return Math.max(E,8)*Math.max(s,8)/2;case ju:case Yu:return Math.floor((E+3)/4)*Math.floor((s+3)/4)*8;case Zu:return Math.floor((E+3)/4)*Math.floor((s+3)/4)*16;case Ku:return Math.floor((E+3)/4)*Math.floor((s+3)/4)*16;case Ju:return Math.floor((E+4)/5)*Math.floor((s+3)/4)*16;case Qu:return Math.floor((E+4)/5)*Math.floor((s+4)/5)*16;case eh:return Math.floor((E+5)/6)*Math.floor((s+4)/5)*16;case th:return Math.floor((E+5)/6)*Math.floor((s+5)/6)*16;case nh:return Math.floor((E+7)/8)*Math.floor((s+4)/5)*16;case ih:return Math.floor((E+7)/8)*Math.floor((s+5)/6)*16;case sh:return Math.floor((E+7)/8)*Math.floor((s+7)/8)*16;case rh:return Math.floor((E+9)/10)*Math.floor((s+4)/5)*16;case oh:return Math.floor((E+9)/10)*Math.floor((s+5)/6)*16;case ah:return Math.floor((E+9)/10)*Math.floor((s+7)/8)*16;case lh:return Math.floor((E+9)/10)*Math.floor((s+9)/10)*16;case ch:return Math.floor((E+11)/12)*Math.floor((s+9)/10)*16;case uh:return Math.floor((E+11)/12)*Math.floor((s+11)/12)*16;case hh:case ug:case hg:return Math.ceil(E/4)*Math.ceil(s/4)*16;case dh:case fh:return Math.ceil(E/4)*Math.ceil(s/4)*8;case ph:case mh:return Math.ceil(E/4)*Math.ceil(s/4)*16}throw new Error(`Unable to determine texture byte length for ${l} format.`)}function vm(E){switch(E){case Ui:case Lc:return{byteLength:1,components:1};case Go:case Dc:case Ts:return{byteLength:2,components:1};case yp:case _p:return{byteLength:2,components:4};case pi:case Ws:case mi:return{byteLength:4,components:1};case xp:case vp:return{byteLength:4,components:3}}throw new Error(`Unknown texture type ${E}.`)}class Fy{static contain(s,l){return sd(s,l)}static cover(s,l){return bl(s,l)}static fill(s){return rx(s)}static getByteLength(s,l,h,f){return Dy(s,l,h,f)}}typeof __THREE_DEVTOOLS__!="undefined"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:_e}})),typeof window!="undefined"&&(window.__THREE__?_n("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=_e)}}]);
|
|
}()); |