<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>3D Minecraft Web Edition</title>
<style>
body {
margin: 0;
overflow: hidden;
background-color: #000;
font-family: 'Arial', sans-serif;
image-rendering: pixelated;
}
#welcome-screen {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(135deg, #87CEEB 0%, #B0E2FF 100%);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
z-index: 1000;
transition: opacity 0.5s ease-out;
}
.game-title {
font-size: 5rem;
color: #228B22;
text-shadow: 4px 4px 0 #000;
margin-bottom: 20px;
letter-spacing: 2px;
font-weight: bold;
}
.game-subtitle {
font-size: 1.2rem;
color: #fff;
text-shadow: 2px 2px 0 #000;
margin-bottom: 40px;
text-align: center;
max-width: 600px;
}
.mode-selection {
display: flex;
gap: 20px;
margin-bottom: 30px;
}
.mode-button {
padding: 10px 25px;
font-size: 1.2rem;
background-color: #4CAF50;
color: white;
border: 4px solid #388E3C;
border-radius: 5px;
cursor: pointer;
transition: all 0.2s ease;
text-shadow: 2px 2px 0 #000;
box-shadow: 0 4px 0 #2E7D32;
}
.mode-button:hover {
background-color: #81C784;
transform: translateY(-2px);
box-shadow: 0 6px 0 #2E7D32;
}
.mode-button.selected {
background-color: #FFC107;
border-color: #FFA000;
box-shadow: 0 4px 0 #F57C00;
}
.start-button {
padding: 15px 40px;
font-size: 1.5rem;
background-color: #4CAF50;
color: white;
border: 4px solid #388E3C;
border-radius: 5px;
cursor: pointer;
transition: all 0.2s ease;
text-shadow: 2px 2px 0 #000;
box-shadow: 0 4px 0 #2E7D32;
}
.start-button:hover {
background-color: #81C784;
transform: translateY(-2px);
box-shadow: 0 6px 0 #2E7D32;
}
.start-button:active {
transform: translateY(2px);
box-shadow: 0 2px 0 #2E7D32;
}
.controls-preview {
position: absolute;
bottom: 30px;
background-color: rgba(0, 0, 0, 0.5);
padding: 15px;
border-radius: 5px;
color: white;
max-width: 800px;
}
.controls-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 10px;
}
.control-item {
display: flex;
align-items: center;
gap: 10px;
}
.control-key {
background-color: #333;
padding: 3px 8px;
border-radius: 3px;
border: 1px solid #666;
}
#crosshair {
position: fixed;
top: 50%;
left: 50%;
width: 10px;
height: 10px;
border: 2px solid white;
border-radius: 50%;
transform: translate(-50%, -50%);
pointer-events: none;
z-index: 100;
display: none;
}
#info {
position: fixed;
top: 10px;
left: 10px;
color: white;
background-color: rgba(0, 0, 0, 0.5);
padding: 10px;
border-radius: 5px;
z-index: 100;
display: none;
}
#hotbar {
position: fixed;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
display: flex;
gap: 2px;
background-color: rgba(0, 0, 0, 0.5);
padding: 5px;
border-radius: 3px;
z-index: 100;
display: none;
}
#inventory {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 550px;
height: 400px;
background-color: rgba(0, 0, 0, 0.8);
border: 2px solid #555;
border-radius: 5px;
padding: 10px;
z-index: 200;
display: none;
grid-template-columns: repeat(9, 1fr);
grid-template-rows: repeat(4, 1fr);
gap: 2px;
}
.item-slot {
width: 50px;
height: 50px;
background-color: rgba(100, 100, 100, 0.5);
border: 2px solid #333;
position: relative;
overflow: hidden;
}
.item-slot.hotbar-slot {
width: 50px;
height: 50px;
}
.item-slot.active {
border-color: #ffff00;
outline: 2px solid rgba(255, 255, 0, 0.5);
}
.item-icon {
width: 100%;
height: 100%;
background-size: contain;
background-repeat: no-repeat;
background-position: center;
}
.item-count {
position: absolute;
bottom: 2px;
right: 2px;
color: white;
font-size: 14px;
font-weight: bold;
text-shadow: 1px 1px 0 #000;
}
.durability-bar {
position: absolute;
bottom: 0;
left: 0;
height: 3px;
background-color: #ff3333;
width: 100%;
}
.health-display {
position: fixed;
top: 10px;
right: 10px;
display: flex;
gap: 2px;
z-index: 100;
display: none;
}
.heart {
width: 16px;
height: 16px;
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="red"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/></svg>');
background-size: contain;
background-repeat: no-repeat;
}
.heart.empty {
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="gray"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/></svg>');
}
.heart.half {
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09V3c0-.55.45-1 1-1s1 .45 1 1v2.09c1.09-1.28 2.76-2.09 4.5-2.09 3.08 0 5.5 2.42 5.5 5.5 0 3.78-3.4 6.86-8.55 11.54L12 21.35z" fill="red"/><path d="M22 8.5c0-3.78-3.4-6.86-8.55-11.54L12 2.65l1.45 1.32C18.6 5.64 22 8.72 22 12.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35l-1.45-1.32C5.4 19.36 2 16.28 2 12.5 2 8.72 5.4 5.64 10.55 1.96L12 2.65l-1.45 1.32C5.4 5.64 2 8.72 2 12.5c0 3.78 3.4 6.86 8.55 11.54L12 21.35l1.45-1.32C18.6 19.36 22 16.28 22 12.5c0-1.53-.36-3-.99-4.33l-1.74 1.74c.41.91.65 1.93.65 3.01 0 3.31-2.69 6-6 6s-6-2.69-6-6 2.69-6 6-6c1.08 0 2.1.24 3.01.65l1.74-1.74C15 5.36 13.47 5 12 5 8.13 5 5 8.13 5 12s3.13 7 7 7 7-3.13 7-7c0-3.78-3.4-6.86-8.55-11.54L12 2.65l1.45 1.32C18.6 5.64 22 8.72 22 12.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35V8.5h10z" fill="gray"/></svg>');
}
.hunger-display {
position: fixed;
top: 30px;
right: 10px;
display: flex;
gap: 2px;
z-index: 100;
display: none;
}
.hunger-icon {
width: 16px;
height: 16px;
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="#FFC107"><path d="M11 9H9V2H7v7H5V2H3v7c0 2.12 1.66 3.84 3.75 3.97V22h2.5v-9.03C11.34 12.84 13 11.12 13 9V2h-2v7zm5-3v8h2.5v8H21V2c-2.76 0-5 2.24-5 4z"/></svg>');
background-size: contain;
background-repeat: no-repeat;
}
.hunger-icon.empty {
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="gray"><path d="M11 9H9V2H7v7H5V2H3v7c0 2.12 1.66 3.84 3.75 3.97V22h2.5v-9.03C11.34 12.84 13 11.12 13 9V2h-2v7zm5-3v8h2.5v8H21V2c-2.76 0-5 2.24-5 4z"/></svg>');
}
.hunger-icon.half {
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M11 9H9V2H7v9H5V2H3v7c0 2.12 1.66 3.84 3.75 3.97V14h1.5v-1.03c1.05-.1 1.8-.99 1.8-2.04V2h-2v7zm5-3v2c0 1.05.75 1.94 1.8 2.04V14h1.5v-2.03c2.09-.13 3.75-1.85 3.75-3.97V6c0-2.21-2.24-4-5-4s-5 1.79-5 4z" fill="#FFC107"/><path d="M16 2v8h2.5v8H21V2c-2.76 0-5 2.24-5 4zm-5 9H9V2H7v9H5V2H3v9c0 2.12 1.66 3.84 3.75 3.97V22h2.5v-9.03C11.34 12.84 13 11.12 13 9V2h-2v9z" fill="gray"/></svg>');
}
.entity-health {
position: absolute;
width: 60px;
height: 5px;
background-color: rgba(0, 0, 0, 0.5);
transform: translate(-50%, -20px);
z-index: 50;
}
.entity-health-fill {
height: 100%;
background-color: #ff3333;
transition: width 0.3s ease;
}
#death-screen {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.8);
display: none;
flex-direction: column;
justify-content: center;
align-items: center;
z-index: 900;
color: white;
}
#death-message {
font-size: 3rem;
margin-bottom: 20px;
text-align: center;
}
#respawn-button {
padding: 10px 30px;
font-size: 1.2rem;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
margin-top: 20px;
}
.loading-animation {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 1001;
display: none;
}
.loading-cube {
width: 20px;
height: 20px;
background-color: #7CFC00;
animation: bounce 1.4s infinite ease-in-out both;
}
.loading-cube:nth-child(1) {
animation-delay: -0.32s;
}
.loading-cube:nth-child(2) {
animation-delay: -0.16s;
}
@keyframes bounce {
0%, 80%, 100% { transform: scale(0); }
40% { transform: scale(1); }
}
.hurt-effect {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(255, 0, 0, 0.2);
pointer-events: none;
z-index: 800;
display: none;
}
.inventory-title {
position: absolute;
top: -25px;
left: 0;
color: white;
font-size: 18px;
}
.time-display {
position: fixed;
top: 10px;
left: 50%;
transform: translateX(-50%);
color: white;
background-color: rgba(0, 0, 0, 0.5);
padding: 5px 10px;
border-radius: 3px;
font-size: 14px;
z-index: 100;
display: none;
}
.mode-display {
position: fixed;
top: 10px;
left: 10px;
color: white;
background-color: rgba(0, 0, 0, 0.5);
padding: 5px 10px;
border-radius: 3px;
font-size: 14px;
z-index: 100;
display: none;
}
.breaking-progress {
position: fixed;
top: 50%;
left: 50%;
width: 30px;
height: 30px;
transform: translate(-50%, -50%);
border: 2px solid white;
border-radius: 50%;
pointer-events: none;
z-index: 101;
display: none;
}
.breaking-progress-bar {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 50%;
border: 2px solid #ffaa00;
border-top-color: transparent;
transform: rotate(0deg);
transition: transform 0.1s linear;
}
</style>
</head>
<body>
<div id="welcome-screen">
<h1 class="game-title">Minecraft 3D Web</h1>
<p class="game-subtitle">新增工具系统!使用不同的稿子挖掘特定方块,支持离线游戏。</p>
<div class="mode-selection">
<button class="mode-button selected" data-mode="survival">生存模式</button>
<button class="mode-button" data-mode="creative">创造模式</button>
</div>
<button class="start-button" id="start-game">开始游戏</button>
<div class="controls-preview">
<h3>游戏控制</h3>
<div class="controls-grid">
<div class="control-item"><span class="control-key">WASD</span> <span>移动</span></div>
<div class="control-item"><span class="control-key">空格</span> <span>跳跃/上升(创造模式)</span></div>
<div class="control-item"><span class="control-key">鼠标</span> <span>控制视角</span></div>
<div class="control-item"><span class="control-key">左Ctrl</span> <span>下降(创造模式)</span></div>
<div class="control-item"><span class="control-key">左键</span> <span>破坏方块/攻击</span></div>
<div class="control-item"><span class="control-key">右键</span> <span>放置方块/使用物品</span></div>
<div class="control-item"><span class="control-key">1-9</span> <span>选择快捷栏物品</span></div>
<div class="control-item"><span class="control-key">E</span> <span>打开/关闭背包</span></div>
<div class="control-item"><span class="control-key">R</span> <span>恢复生命值</span></div>
<div class="control-item"><span class="control-key">F</span> <span>切换飞行(创造模式)</span></div>
</div>
</div>
</div>
<div id="death-screen">
<div id="death-message">你死了!</div>
<p>可能是被僵尸击败或饿死了...</p>
<button id="respawn-button">重生</button>
</div>
<div class="hurt-effect" id="hurt-effect"></div>
<div class="loading-animation" id="loading">
<div class="loading-cube"></div>
<div class="loading-cube"></div>
<div class="loading-cube"></div>
</div>
<div id="crosshair"></div>
<div class="breaking-progress">
<div class="breaking-progress-bar"></div>
</div>
<div id="info">
<p>WASD - 移动</p>
<p>空格 - 跳跃/上升(创造模式)</p>
<p>左Ctrl - 下降(创造模式)</p>
<p>鼠标 - 视角</p>
<p>左键 - 破坏方块/攻击</p>
<p>右键 - 放置方块/使用物品</p>
<p>1-9 - 选择快捷栏物品</p>
<p>E - 打开/关闭背包</p>
<p>R - 恢复生命值</p>
<p>F - 切换飞行(创造模式)</p>
</div>
<div id="hotbar">
<!-- 9个快捷栏格子 -->
</div>
<div id="inventory">
<div class="inventory-title">背包</div>
<!-- 36个物品格子 (4行×9列) -->
</div>
<div class="health-display" id="player-health">
<!-- 心形血条会通过JS动态生成 -->
</div>
<div class="hunger-display" id="player-hunger">
<!-- 鸡腿图标会通过JS动态生成 -->
</div>
<div class="time-display" id="time-display">白天</div>
<div class="mode-display" id="mode-display">生存模式</div>
<script>
// Three.js库和相关组件内嵌,确保离线可用
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).THREE=e()}(this,(function(){"use strict";const t="0.132.2";function e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}class n{constructor(t,e){this.isVector2=!0,this.x=t||0,this.y=e||0}set(t,e){return this.x=t,this.y=e,this}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.x/=t,this.y/=t,this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e,n){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(n,Math.min(e,this.y)),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Math.max(t,Math.min(e,n))),this}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.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),this}angle(){return Math.atan2(this.y,this.x)}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t),this}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t,e=0){return t||(t=[]),t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}clone(){return new n(this.x,this.y)}}class i{constructor(t,e,n){this.isVector3=!0,this.x=t||0,this.y=e||0,this.z=n||0}set(t,e,n){return this.x=t,this.y=e,this.z=n,this}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyMatrix3(t){const e=this.x,n=this.y,i=this.z;return this.x=t[0]*e+t[3]*n+t[6]*i,this.y=t[1]*e+t[4]*n+t[7]*i,this.z=t[2]*e+t[5]*n+t[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize(),this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,a=t[3]*e+t[7]*n+t[11]*i+t[15];a!==1&&(a=1/a),this.x=(t[0]*e+t[4]*n+t[8]*i+t[12])*a,this.y=(t[1]*e+t[5]*n+t[9]*i+t[13])*a,this.z=(t[2]*e+t[6]*n+t[10]*i+t[14])*a,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,a=t.x,s=t.y,r=t.z,o=t.w,u=2*a*e+2*s*n+2*r*i+2*o*o*e-2*a*a*e-2*s*s*e-2*r*r*e;return this.y=2*a*n+2*s*i+2*r*o+2*o*o*n-2*a*a*n-2*s*s*n-2*r*r*n,this.z=2*a*o+2*s*a+2*r*n+2*o*o*i-2*a*a*i-2*s*s*i-2*r*r*i,this.x=u,this}project(t){const e=t.projectionMatrix,a=new n;this.copy(this).applyMatrix4(e),a.x=this.x/a.z,a.y=this.y/a.z,this.x=a.x,this.y=a.y,this}unproject(t){const e=t.projectionMatrix,a=new n(this.x,this.y,this.z);return this.copy(a).applyMatrix4(e.invert()),this}transformDirection(t){const e=this.x,n=this.y,i=this.z;this.x=t[0]*e+t[4]*n+t[8]*i,this.y=t[1]*e+t[5]*n+t[9]*i,this.z=t[2]*e+t[6]*n+t[10]*i,this.normalize(),this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.x/=t,this.y/=t,this.z/=t,this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}cross(t){const e=this.x,n=this.y,i=this.z;return this.x=n*t.z-i*t.y,this.y=i*t.x-e*t.z,this.z=e*t.y-n*t.x,this}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),this}setLength(t){return this.normalize().multiplyScalar(t),this}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t,e=0){return t||(t=[]),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}clone(){return new i(this.x,this.y,this.z)}}class r{constructor(t,e,n,i){this.isVector4=!0,this.x=t||0,this.y=e||0,this.z=n||0,this.w=i||1}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i||1,this}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w||1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.x/=t,this.y/=t,this.z/=t,this.w/=t,this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}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=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.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(){return this.divideScalar(this.length()||1),this}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3]||1,this}toArray(t,e=0){return t||(t=[]),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}clone(){return new r(this.x,this.y,this.z,this.w)}}class o{constructor(){this.isMatrix3=!0,this.elements=new Float32Array(9)}set(t){const e=this.elements;return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],this}identity(){const t=this.elements;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){const i=this.elements;t.x=i[0],t.y=i[3],t.z=i[6],e.x=i[1],e.y=i[4],e.z=i[7],n.x=i[2],n.y=i[5],n.z=i[8]}setFromBasis(t,e,n){const i=this.elements;i[0]=t.x,i[3]=t.y,i[6]=t.z,i[1]=e.x,i[4]=e.y,i[7]=e.z,i[2]=n.x,i[5]=n.y,i[8]=n.z,this}multiply(t){return this.multiplyMatrices(this,t),this}multiplyMatrices(t,e){const n=this.elements,i=t.elements,a=e.elements,s=i[0],r=i[1],o=i[2],u=i[3],l=i[4],c=i[5],h=i[6],d=i[7],p=i[8],m=a[0],f=a[1],v=a[2],g=a[3],y=a[4],b=a[5],x=a[6],k=a[7],M=a[8];return n[0]=s*m+r*g+o*x,n[1]=s*f+r*y+o*k,n[2]=s*v+r*b+o*M,n[3]=u*m+l*g+c*x,n[4]=u*f+l*y+c*k,n[5]=u*v+l*b+c*M,n[6]=h*m+d*g+p*x,n[7]=h*f+d*y+p*k,n[8]=h*v+d*b+p*M,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[1]*=t,e[2]*=t,e[3]*=t,e[4]*=t,e[5]*=t,e[6]*=t,e[7]*=t,e[8]*=t,this}determinant(){const t=this.elements;return t[0]*(t[4]*t[8]-t[5]*t[7])-t[1]*(t[3]*t[8]-t[5]*t[6])+t[2]*(t[3]*t[7]-t[4]*t[6])}transpose(){let t=this.elements[1];this.elements[1]=this.elements[3],this.elements[3]=t,t=this.elements[2],this.elements[2]=this.elements[6],this.elements[6]=t,t=this.elements[5],this.elements[5]=this.elements[7],this.elements[7]=t,this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],a=t[3],s=t[4],r=t[5],o=t[6],u=t[7],l=t[8],c=e*(s*l-r*u)-n*(a*l-r*o)+i*(a*u-s*o);if(c===0)return this.identity();const h=1/c;return t[0]=(s*l-r*u)*h,t[1]=(i*u-s*l)*h,t[2]=(n*r-i*s)*h,t[3]=(r*o-a*l)*h,t[4]=(e*l-i*o)*h,t[5]=(i*a-e*r)*h,t[6]=(a*u-s*o)*h,t[7]=(o*n-e*u)*h,t[8]=(e*s-n*a)*h,this}getNormalMatrix(t){this.copy(t).invert().transpose()}setUvTransform(t,e,n,i,a,s){const r=this.elements;return r[0]=n*Math.cos(a),r[1]=n*Math.sin(a),r[2]=t+n*Math.cos(a)*s-n*Math.sin(a)*i,r[3]=-n*Math.sin(a),r[4]=n*Math.cos(a),r[5]=e+n*Math.sin(a)*s+n*Math.cos(a)*i,r[6]=0,r[7]=0,r[8]=1,this}rotate(t){const e=Math.cos(t),n=Math.sin(t);return this.set([e,n,0,-n,e,0,0,0,1]),this}scale(t,e){return this.set([t,0,0,0,e,0,0,0,1]),this}translate(t,e){return this.set([1,0,t,0,1,e,0,0,1]),this}equals(t){const e=this.elements,n=t.elements;for(let i=0;i<9;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[e+n];return this}toArray(t,e=0){t||(t=[]);for(let n=0;n<9;n++)t[e+n]=this.elements[n];return t}clone(){return new o().copy(this)}}class u{constructor(){this.isMatrix4=!0,this.elements=new Float32Array(16),this.identity()}set(t){const e=this.elements;for(let n=0;n<16;n++)e[n]=t[n];return this}identity(){const t=this.elements;return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}copy(t){const e=this.elements,n=t.elements;for(let i=0;i<16;i++)e[i]=n[i];return this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}extractBasis(t,e,n){t.x=this.elements[0],t.y=this.elements[4],t.z=this.elements[8],e.x=this.elements[1],e.y=this.elements[5],e.z=this.elements[9],n.x=this.elements[2],n.y=this.elements[6],n.z=this.elements[10]}makeBasis(t,e,n){const i=this.elements;i[0]=t.x,i[4]=t.y,i[8]=t.z,i[12]=0,i[1]=e.x,i[5]=e.y,i[9]=e.z,i[13]=0,i[2]=n.x,i[6]=n.y,i[10]=n.z,i[14]=0,i[3]=0,i[7]=0,i[11]=0,i[15]=1,this}multiply(t){return this.multiplyMatrices(this,t),this}multiplyMatrices(t,e){const n=this.elements,i=t.elements,a=e.elements,s=i[0],r=i[1],o=i[2],u=i[3],l=i[4],c=i[5],h=i[6],d=i[7],p=i[8],m=i[9],f=i[10],v=i[11],g=i[12],y=i[13],b=i[14],x=i[15],k=a[0],M=a[1],S=a[2],w=a[3],_=a[4],z=a[5],E=a[6],T=a[7],B=a[8],N=a[9],A=a[10],O=a[11],P=a[12],j=a[13],Q=a[14],R=a[15];return n[0]=s*k+r*_+o*B+u*P,n[1]=s*M+r*z+o*N+u*j,n[2]=s*S+r*E+o*A+u*Q,n[3]=s*w+r*T+o*O+u*R,n[4]=l*k+c*_+h*B+d*P,n[5]=l*M+c*z+h*N+d*j,n[6]=l*S+c*E+h*A+d*Q,n[7]=l*w+c*T+h*O+d*R,n[8]=p*k+m*_+f*B+v*P,n[9]=p*M+m*z+f*N+v*j,n[10]=p*S+m*E+f*A+v*Q,n[11]=p*w+m*T+f*O+v*R,n[12]=g*k+y*_+b*B+x*P,n[13]=g*M+y*z+b*N+x*j,n[14]=g*S+y*E+b*A+x*Q,n[15]=g*w+y*T+b*O+x*R,this}multiplyScalar(t){const e=this.elements;for(let n=0;n<16;n++)e[n]*=t;return this}determinant(){const t=this.elements,e=t[0],n=t[1],i=t[2],a=t[3],s=t[4],r=t[5],o=t[6],u=t[7],l=t[8],c=t[9],h=t[10],d=t[11],p=t[12],m=t[13],f=t[14],v=t[15];return e*(r*(h*v-d*f)+o*(d*m-h*p)+u*(h*p-m*f))-n*(s*(h*v-d*f)+o*(d*p-h*l)+u*(h*l-p*f))+i*(s*(c*v-d*m)+r*(d*p-h*l)+u*(c*l-p*m))-a*(s*(c*f-h*m)+r*(h*p-c*l)+o*(c*l-p*m))}transpose(){let t=this.elements[1];this.elements[1]=this.elements[4],this.elements[4]=t,t=this.elements[2],this.elements[2]=this.elements[8],this.elements[8]=t,t=this.elements[6],this.elements[6]=this.elements[9],this.elements[9]=t,t=this.elements[3],this.elements[3]=this.elements[12],this.elements[12]=t,t=this.elements[7],this.elements[7]=this.elements[13],this.elements[13]=t,t=this.elements[11],this.elements[11]=this.elements[14],this.elements[14]=t,this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],a=t[3],s=t[4],r=t[5],o=t[6],u=t[7],l=t[8],c=t[9],h=t[10],d=t[11],p=t[12],m=t[13],f=t[14],v=t[15],g=e*(r*(h*v-d*f)+o*(d*m-h*p)+u*(h*p-m*f))-n*(s*(h*v-d*f)+o*(d*p-h*l)+u*(h*l-p*f))+i*(s*(c*v-d*m)+r*(d*p-h*l)+u*(c*l-p*m))-a*(s*(c*f-h*m)+r*(h*p-c*l)+o*(c*l-p*m));if(g===0)return this.identity();const y=1/g;return t[0]=(r*(h*v-d*f)+o*(d*m-h*p)+u*(h*p-m*f))*y,t[1]=-(n*(h*v-d*f)+o*(d*p-h*l)+u*(h*l-p*f))*y,t[2]=(n*(d*m-c*v)+r*(d*p-h*l)+u*(c*l-p*m))*y,t[3]=-(n*(c*f-h*m)+r*(h*p-c*l)+o*(c*l-p*m))*y,t[4]=-(s*(h*v-d*f)+o*(d*p-h*l)+u*(h*l-p*f))*y,t[5]=(e*(h*v-d*f)+i*(d*p-h*l)+u*(h*l-p*f))*y,t[6]=-(e*(d*m-c*v)+i*(d*p-h*l)+u*(c*l-p*m))*y,t[7]=(e*(c*f-h*m)+i*(h*p-c*l)+o*(c*l-p*m))*y,t[8]=(s*(c*v-d*m)+r*(d*p-h*l)+u*(c*l-p*m))*y,t[9]=-(e*(c*v-d*m)+i*(d*p-h*l)+u*(c*l-p*m))*y,t[10]=(e*(r*(v)-o*d)+i*(s*d-r*p)+a*(s*o-r*_))*y,t[11]=-(e*(r*f-o*m)+i*(s*m-r*p)+a*(s*o-r*_))*y,t[12]=-(s*(o*(m*v-f*d)+u*(h*f-m*h))+r*(i*(d*m-f*c)+u*(p*c-l*m))+u*(e*(f*c-m*h)+i*(l*m-p*c)))*y,t[13]=(n*(o*(m*v-f*d)+u*(h*f-m*h))+i*(s*(d*m-f*c)+u*(p*c-l*m))+u*(e*(f*c-m*h)+s*(l*m-p*c)))*y,t[14]=-(n*(r*(m*v-f*d)+u*(p*f-m*l))+o*(s*(d*m-f*c)+u*(p*c-l*m))+u*(e*(f*c-m*h)+s*(l*m-p*c)))*y,t[15]=(n*(r*(f*m-h*v)+o*(d*m-f*c))+i*(s*(f*c-m*h)+r*(h*p-c*l))+a*(s*(c*h-m*f)+r*(l*m-p*c)+o*(p*f-m*l)))*y,this}setPosition(t,e,n){return"number"==typeof t?this.elements[12]=t,this.elements[13]=e,this.elements[14]=n:this.elements[12]=t.x,this.elements[13]=t.y,this.elements[14]=t.z,this}setRotationFromEuler(t){const e=t.x,n=t.y,i=t.z,a=Math.cos(e),s=Math.sin(e),r=Math.cos(n),o=Math.sin(n),u=Math.cos(i),l=Math.sin(i);return this.elements[0]=r*u,this.elements[1]=r*l,this.elements[2]=-o,this.elements[3]=0,this.elements[4]=s*o*u-a*l,this.elements[5]=s*o*l+a*u,this.elements[6]=s*r,this.elements[7]=0,this.elements[8]=a*o*u+s*l,this.elements[9]=a*o*l-s*u,this.elements[10]=a*r,this.elements[11]=0,this.elements[12]=0,this.elements[13]=0,this.elements[14]=0,this.elements[15]=1,this}setRotationFromQuaternion(t){const e=t.x,n=t.y,i=t.z,a=t.w,s=2*e*e,r=2*e*n,o=2*e*i,u=2*n*n,l=2*n*i,c=2*e*a,h=2*n*a,d=2*i*a,p=1-2*n*n-2*i*i,m=1-2*e*e-2*i*i,f=1-2*e*e-2*n*n;return this.elements[0]=p,this.elements[1]=o+c,this.elements[2]=r-d,this.elements[3]=0,this.elements[4]=o-c,this.elements[5]=m,this.elements[6]=l+c,this.elements[7]=0,this.elements[8]=r+d,this.elements[9]=l-c,this.elements[10]=f,this.elements[11]=0,this.elements[12]=0,this.elements[13]=0,this.elements[14]=0,this.elements[15]=1,this}extractRotation(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=0,e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=0,e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeTranslation(t,e,n){return this.identity(),this.elements[12]=t,this.elements[13]=e,this.elements[14]=n,this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.identity(),this.elements[5]=e,this.elements[6]=-n,this.elements[9]=n,this.elements[10]=e,this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.identity(),this.elements[0]=e,this.elements[2]=n,this.elements[8]=-n,this.elements[10]=e,this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.identity(),this.elements[0]=e,this.elements[1]=-n,this.elements[4]=n,this.elements[5]=e,this}makeScale(t,e,n){return this.identity(),this.elements[0]=t,this.elements[5]=e,this.elements[10]=n,this}lookAt(t,e,n){const a=new i().subVectors(e,t),s=new i().copy(n).normalize(),r=new i().crossVectors(s,a).normalize(),o=new i().crossVectors(r,s);return this.elements[0]=r.x,this.elements[4]=r.y,this.elements[8]=r.z,this.elements[1]=o.x,this.elements[5]=o.y,this.elements[9]=o.z,this.elements[2]=-s.x,this.elements[6]=-s.y,this.elements[10]=-s.z,this.elements[12]=t.x,this.elements[13]=t.y,this.elements[14]=t.z,this}frustum(t,e,n,i,a,s){const r=e-t,o=i-n,u=s-a,l=2*a*r,h=2*a*o,d=a+s,p=t+e,m=n+i;return this.set([l/(e-t),0,0,0,0,h/(i-n),0,0,(p)/r,(m)/o,-d/u,-1,0,0,-2*s*a/u,0]),this}perspective(t,e,n,i){const a=Math.tan(Math.PI*0.5-t*0.5)*n,s=a*e,r=i-n;return this.set([a/s,0,0,0,0,a,0,0,0,0,-(i+n)/r,-1,0,0,-2*i*n/r,0]),this}ortho(t,e,n,i,a,s){const r=1/(e-t),o=1/(i-n),u=1/(s-a);return this.set([2*r,0,0,0,0,2*o,0,0,0,0,-2*u,0,-(e+t)*r,-(i+n)*o,-(s+a)*u,1]),this}equals(t){const e=this.elements,n=t.elements;for(let i=0;i<16;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[e+n];return this}toArray(t,e=0){t||(t=[]);for(let n=0;n<16;n++)t[e+n]=this.elements[n];return t}clone(){return new u().copy(this)}}class l{constructor(t,e,n){this.isEuler=!0,this._x=t||0,this._y=e||0,this._z=n||0,this._order="XYZ",this.onChangeCallback=null}onChange(t){return this.onChangeCallback=t,this}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,i&&(this._order=i),this.onChangeCallback&&this.onChangeCallback(),this}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this.onChangeCallback&&this.onChangeCallback(),this}setFromRotationMatrix(t,e="XYZ"){const n=t.elements,i=n[0],a=n[1],s=n[2],r=n[4],o=n[5],u=n[6],l=n[8],c=n[9],h=n[10];return"XYZ"===e?(this._y=Math.asin(Math.min(Math.max(i, -1), 1)),Math.abs(i)<.9999999?(this._x=Math.atan2(-a, h),this._z=Math.atan2(-r, o)):(this._x=Math.atan2(l, c),this._z=0)):"YZX"===e?(this._z=Math.asin(Math.min(Math.max(-r, -1), 1)),Math.abs(r)<.9999999?(this._y=Math.atan2(i, c),this._x=Math.atan2(s, h)):(this._y=Math.atan2(-l, o),this._x=0)):"ZXY"===e?(this._x=Math.asin(Math.min(Math.max(u, -1), 1)),Math.abs(u)<.9999999?(this._z=Math.atan2(-l, o),this._y=Math.atan2(-s, i)):(this._z=Math.atan2(a, h),this._y=0)):"XZY"===e?(this._z=Math.asin(Math.min(Math.max(-a, -1), 1)),Math.abs(a)<.9999999?(this._x=Math.atan2(l, c),this._y=Math.atan2(s, h)):(this._x=Math.atan2(-u, o),this._y=0)):"YXZ"===e?(this._x=Math.asin(Math.min(Math.max(-u, -1), 1)),Math.abs(u)<.9999999?(this._y=Math.atan2(l, o),this._z=Math.atan2(s, i)):(this._y=Math.atan2(-a, c),this._z=0)):"ZYX"===e?(this._y=Math.asin(Math.min(Math.max(-l, -1), 1)),Math.abs(l)<.9999999?(this._z=Math.atan2(r, i),this._x=Math.atan2(u, h)):(this._z=Math.atan2(-s, o),this._x=0)):void 0,this._order=e,this.onChangeCallback&&this.onChangeCallback(),this}setFromQuaternion(t,e){const n=new u;return n.makeRotationFromQuaternion(t),this.setFromRotationMatrix(n,e),this}setFromVector3(t,e){return this.set(t.x,t.y,t.z,e),this}reorder(t){const e=new l;return e.copy(this),this.set(e.x,e.y,e.z,t),this}get x(){return this._x}set x(t){this._x=t,this.onChangeCallback&&this.onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this.onChangeCallback&&this.onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this.onChangeCallback&&this.onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this.onChangeCallback&&this.onChangeCallback()}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._order=t[e+3]||"XYZ",this.onChangeCallback&&this.onChangeCallback(),this}toArray(t,e=0){return t||(t=[]),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}clone(){return new l(this._x,this._y,this._z,this._order)}}class c{constructor(t,e,n,i){this.isQuaternion=!0,this._x=t||0,this._y=e||0,this._z=n||0,this._w=i!==void 0?i:1,this.onChangeCallback=null}onChange(t){return this.onChangeCallback=t,this}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this.onChangeCallback&&this.onChangeCallback(),this}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._w=t._w,this.onChangeCallback&&this.onChangeCallback(),this}setFromEuler(t,e){let n,i,a,s,r,o,u,l;const c=t.x,h=t.y,d=t.z;if("XYZ"===e||!e&&"XYZ"===t.order){n=Math.sin(c/2),i=Math.cos(c/2),a=Math.sin(h/2),s=Math.cos(h/2),r=Math.sin(d/2),o=Math.cos(d/2),this._x=n*s*o+i*a*r,this._y=i*a*o-n*s*r,this._z=i*s*r+n*a*o,this._w=i*s*o-n*a*r}else if("YXZ"===e||!e&&"YXZ"===t.order){n=Math.sin(c/2),i=Math.cos(c/2),a=Math.sin(h/2),s=Math.cos(h/2),r=Math.sin(d/2),o=Math.cos(d/2),this._x=n*s*o+i*a*r,this._y=i*a*o+n*s*r,this._z=i*s*r-n*a*o,this._w=i*s*o-n*a*r}else if("ZXY"===e||!e&&"ZXY"===t.order){n=Math.sin(c/2),i=Math.cos(c/2),a=Math.sin(h/2),s=Math.cos(h/2),r=Math.sin(d/2),o=Math.cos(d/2),this._x=n*a*o+i*s*r,this._y=i*s*o+n*a*r,this._z=n*s*o-i*a*r,this._w=i*a*o-n*s*r}else if("ZYX"===e||!e&&"ZYX"===t.order){n=Math.sin(c/2),i=Math.cos(c/2),a=Math.sin(h/2),s=Math.cos(h/2),r=Math.sin(d/2),o=Math.cos(d/2),this._x=n*s*o-i*a*r,this._y=i*a*o+n*s*r,this._z=i*s*r-n*a*o,this._w=i*s*o+n*a*r}else if("YZX"===e||!e&&"YZX"===t.order){n=Math.sin(c/2),i=Math.cos(c/2),a=Math.sin(h/2),s=Math.cos(h/2),r=Math.sin(d/2),o=Math.cos(d/2),this._x=n*s*r+i*a*o,this._y=i*a*r+n*s*o,this._z=i*s*o-n*a*r,this._w=i*s*r-n*a*o}else if("XZY"===e||!e&&"XZY"===t.order){n=Math.sin(c/2),i=Math.cos(c/2),a=Math.sin(h/2),s=Math.cos(h/2),r=Math.sin(d/2),o=Math.cos(d/2),this._x=n*a*r+i*s*o,this._y=i*s*r-n*a*o,this._z=n*s*o+i*a*r,this._w=i*a*o-n*s*r}return this.onChangeCallback&&this.onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this.onChangeCallback&&this.onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[1],a=e[2],s=e[4],r=e[5],o=e[6],u=e[8],l=e[9],c=e[10],h=n+r+c,d=Math.sqrt(h+1);if(d>1e-5){const t=0.5/d;this._x=(l-o)*t,this._y=(a-u)*t,this._z=(s-n)*t,this._w=d*0.5}}multiply(t){const e=this._x,n=this._y,i=this._z,a=this._w,s=t._x,r=t._y,o=t._z,u=t._w;return this._x=e*u+n*o-i*r+a*s,this._y=n*u+i*s-e*o+a*r,this._z=i*u+e*r-n*s+a*o,this._w=a*u-e*s-n*r-i*o,this.onChangeCallback&&this.onChangeCallback(),this}multiplyQuaternions(t,e){const n=t._x,i=t._y,a=t._z,s=t._w,r=e._x,o=e._y,u=e._z,l=e._w;return this._x=n*l+i*u-a*o+s*r,this._y=i*l+a*r-n*u+s*o,this._z=a*l+n*o-i*r+s*u,this._w=s*l-n*r-i*o-a*u,this.onChangeCallback&&this.onChangeCallback(),this}inverse(){return this.conjugate(),this.normalize(),this}conjugate(){return this._x=-this._x,this._y=-this._y,this._z=-this._z,this.onChangeCallback&&this.onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._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 t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x*=t,this._y*=t,this._z*=t,this._w*=t),this.onChangeCallback&&this.onChangeCallback(),this}multiplyScalar(t){return this._x*=t,this._y*=t,this._z*=t,this._w*=t,this.onChangeCallback&&this.onChangeCallback(),this}slerp(t,e){let n,i,a,s,r,o,u,l,c,h,d,p,m,f,v;if(e<=0)return this;if(e>=1)return this.copy(t);const g=this.dot(t);g<0?(n=-t._x,i=-t._y,a=-t._z,s=-t._w,r=-g):(n=t._x,i=t._y,a=t._z,s=t._w,r=g);if(r>=1)return this._x=n,this._y=i,this._z=a,this._w=s,this;return o=Math.acos(r),u=Math.sin(o),l=Math.sin((1-e)*o)/u,c=Math.sin(e*o)/u,this._x=this._x*l+n*c,this._y=this._y*l+i*c,this._z=this._z*l+a*c,this._w=this._w*l+s*c,this.onChangeCallback&&this.onChangeCallback(),this}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this.onChangeCallback&&this.onChangeCallback(),this}toArray(t,e=0){return t||(t=[]),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}clone(){return new c(this._x,this._y,this._z,this._w)}}class h{constructor(){this.isBufferAttribute=!0,this.name="",this.array=null,this.itemSize=1,this.count=0,this.normalized=!1,this.dynamic=!1,this.updateRange={offset:0,count:-1},this.version=0}setArray(t){return this.array=t,this.count=t!==null?Math.floor(t.length/this.itemSize):0,this.version++,this}onUpload(t){}clone(t){return t||(t=new h),t.name=this.name,t.array=new this.array.constructor(this.array),t.itemSize=this.itemSize,t.count=this.count,t.normalized=this.normalized,t.dynamic=this.dynamic,t.updateRange={offset:this.updateRange.offset,count:this.updateRange.count},t.version=this.version,t}}class d{constructor(t,e,n){super();this.isFloat32BufferAttribute=!0,this.array=t!==void 0?t:new Float32Array(e*n),this.itemSize=e,this.count=e*n/this.itemSize}}d.prototype=Object.create(h.prototype);class p{constructor(t,e,n){super();this.isUint32BufferAttribute=!0,this.array=t!==void 0?t:new Uint32Array(e*n),this.itemSize=e,this.count=e*n/this.itemSize}}p.prototype=Object.create(h.prototype);class m{constructor(t,e,n){super();this.isUint16BufferAttribute=!0,this.array=t!==void 0?t:new Uint16Array(e*n),this.itemSize=e,this.count=e*n/this.itemSize}}m.prototype=Object.create(h.prototype);class f{constructor(t,e,n){super();this.isUint8BufferAttribute=!0,this.array=t!==void 0?t:new Uint8Array(e*n),this.itemSize=e,this.count=e*n/this.itemSize}}f.prototype=Object.create(h.prototype);class v{constructor(t,e,n){super();this.isInt32BufferAttribute=!0,this.array=t!==void 0?t:new Int32Array(e*n),this.itemSize=e,this.count=e*n/this.itemSize}}v.prototype=Object.create(h.prototype);class g{constructor(t,e,n){super();this.isInt16BufferAttribute=!0,this.array=t!==void 0?t:new Int16Array(e*n),this.itemSize=e,this.count=e*n/this.itemSize}}g.prototype=Object.create(h.prototype);class y{constructor(t,e,n){super();this.isInt8BufferAttribute=!0,this.array=t!==void 0?t:new Int8Array(e*n),this.itemSize=e,this.count=e*n/this.itemSize}}y.prototype=Object.create(h.prototype);class b{constructor(){this.id=Math.floor(1e9*Math.random()),this.uuid=crypto.randomUUID(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=new i(0,1,0),this.position=new i,this.rotation=new l,this.quaternion=new c,this.scale=new i(1,1,1),this.modelViewMatrix=new u,this.normalMatrix=new o,this.matrix=new u,this.matrixAutoUpdate=!0,this.matrixWorld=new u,this.matrixWorldNeedsUpdate=!1,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.userData={},this.layers=new k,this.onBeforeRender=null,this.onAfterRender=null,this._lastMatrixWorldNeedsUpdate=!1,this._matrixWorldNeedsUpdate=function(t){t._matrixWorldNeedsUpdate=!0;for(let e=0,n=t.children.length;e<n;e++)t.children[e]._matrixWorldNeedsUpdate(t.children[e])}}updateMatrix(){this.matrixAutoUpdate&&(this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0)}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrixWorldNeedsUpdate||t||!this.parent&&this.matrixWorld.equals(this.matrix)||(this.parent?this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);for(let e=0,n=this.children.length;e<n;e++)this.children[e].updateMatrixWorld(t)}matrixWorldInverse(){return this._matrixWorldInverse||(this._matrixWorldInverse=new u),this._matrixWorldInverse.copy(this.matrixWorld).invert(),this._matrixWorldInverse}add(...t){for(let e=0,n=t.length;e<n;e++){const i=t[e];if(i.parent)i.parent.remove(i);i.parent=this,this.children.push(i),i._matrixWorldNeedsUpdate(i)}}remove(...t){for(let e=0,n=t.length;e<n;e++){const i=t[e],a=this.children.indexOf(i);a!==-1&&(i.parent=null,this.children.splice(a,1))}}removeFromParent(){this.parent&&this.parent.remove(this)}clear(){for(let t=0,e=this.children.length;t<e;t++)this.children[t].parent=null;this.children.length=0}getObjectById(t){if(this.id===t)return this;for(let e=0,n=this.children.length;e<n;e++){const i=this.children[e].getObjectById(t);if(i)return i}return null}getObjectByName(t){if(this.name===t)return this;for(let e=0,n=this.children.length;e<n;e++){const i=this.children[e].getObjectByName(t);if(i)return i}return null}getWorldPosition(t){return t||(t=new i),this.updateMatrixWorld(),t.setFromMatrixPosition(this.matrixWorld),t}getWorldQuaternion(t){const e=new i,n=new u;return t||(t=new c),this.updateMatrixWorld(),n.extractRotation(this.matrixWorld),t.setFromRotationMatrix(n),t}getWorldScale(t){const e=new u;return t||(t=new i),this.updateMatrixWorld(),e.copy(this.matrixWorld).decompose(new i,t,t),t}getWorldDirection(t){const e=new i;return t||(t=new i),this.getWorldQuaternion(e).multiplyVector3(e.set(0,0,-1)),t.copy(e),t}lookAt(t){const e=new i;return"string"==typeof t?this.parent&&this.parent.getObjectByName(t)&&(e.setFromMatrixPosition(this.parent.getObjectByName(t).matrixWorld),this.lookAt(e)):(e.copy(t),this.parent&&this.parent.matrixWorldNeedsUpdate&&this.parent.updateMatrixWorld(),this.updateMatrixWorld(),e.applyMatrix4(this.matrixWorldInverse()),this.quaternion.setFromRotationMatrix(new u().lookAt(this.position,e,this.up))),this}clone(t){return new this.constructor().copy(this,t)}copy(t,e){this.name=t.name,this.type=t.type,this.position.copy(t.position),this.rotation.copy(t.rotation),this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.up.copy(t.up),this.matrix.copy(t.matrix),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorld.copy(t.matrixWorld),this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.userData=JSON.parse(JSON.stringify(t.userData)),this.layers.mask=t.layers.mask,this.onBeforeRender=t.onBeforeRender,this.onAfterRender=t.onAfterRender;if(!e)for(let n=0,i=t.children.length;n<i;n++)this.add(t.children[n].clone())}traverse(t){t(this);for(let e=0,n=this.children.length;e<n;e++)this.children[e].traverse(t)}traverseVisible(t){this.visible&&(t(this),this.layers.test(camera.layers)&&(this.frustumCulled||camera.frustum.intersectsObject(this))&&this.visible&&this.children.forEach(e=>e.traverseVisible(t)))}traverseAncestors(t){let e=this.parent;while(e)if(t(e),!(e=e.parent))break}dispose(){}}class x{constructor(t){this.isEventDispatcher=!0,this._listeners={},t&&this.copy(t)}addEventListener(t,e){(this._listeners[t]||(this._listeners[t]=[])).push(e)}hasEventListener(t,e){return!!this._listeners[t]&&this._listeners[t].includes(e)}removeEventListener(t,e){const n=this._listeners[t];if(n){const i=n.indexOf(e);i!==-1&&n.splice(i,1)}}dispatchEvent(t){if(!this._listeners[t.type])return;const e=t.type,n=this._listeners[e].slice(0);for(let i=0,a=n.length;i<a;i++)n[i].call(this,t)}copy(t){const e=t._listeners;for(const n in e)for(let i=0,a=e[n].length;i<a;i++)this.addEventListener(n,e[n][i]);return this}removeAllEventListeners(t){t?delete this._listeners[t]:this._listeners={}}}b.prototype=Object.create(x.prototype);b.prototype.constructor=b;class k{constructor(t=1){this.mask=t}set(t){this.mask=1<<t}enable(t){this.mask|=1<<t}disable(t){this.mask&=~(1<<t)}toggle(t){this.mask^=1<<t}test(t){return(t.mask&this.mask)!==0}}class M{constructor(t,e,n){super();this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new u,this.projectionMatrix=new u,this.projectionMatrixInverse=new u,this.aspect=t||1,this.near=e||0.1,this.far=n||2e3,this.view=null,this.layers=new k,this.zoom=1,this.focus=10,this.filmGauge=35,this.filmOffset=new n,this.viewport=null,this.scissor=null,this.scissorTest=!1}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateProjectionMatrix(){throw"Camera.updateProjectionMatrix() is not implemented."}clone(){return new this.constructor().copy(this)}}M.prototype=Object.create(b.prototype);M.prototype.constructor=M;M.prototype.copy=function(t,e){super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.aspect=t.aspect,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view?Object.assign({},t.view):null,this.focus=t.focus,this.filmGauge=t.filmGauge,this.filmOffset.copy(t.filmOffset),this.viewport=t.viewport?Object.assign({},t.viewport):null,this.scissor=t.scissor?Object.assign({},t.scissor):null,this.scissorTest=t.scissorTest,this.layers.mask=t.layers.mask;return this};class S{constructor(t,e,n){super(t,e,n),this.type="PerspectiveCamera",this.fov=t||50,this.updateProjectionMatrix()}setFocalLength(t){const e=0.5*this.filmGauge*0.001;this.fov=2*Math.atan(e/t)*180/Math.PI,this.updateProjectionMatrix()}getFocalLength(){const t=0.5*this.filmGauge*0.001;return t/Math.tan(0.5*this.fov*Math.PI/180)}updateProjectionMatrix(){const t=Math.tan(Math.PI*this.fov/360)*this.near,e=t*this.aspect,n=-t,i=-e,a=this.far-t;let s,r;this.view?this.projectionMatrix.setFromFrustum(this.view.left*this.zoom,this.view.right*this.zoom,this.view.bottom*this.zoom,this.view.top*this.zoom,this.near,this.far):this.projectionMatrix.makePerspective(i,e,n,t,this.near,this.far),this.focus!==10&&(s=1/this.focus,r=new u,r.makeTranslation(0,0,-s),this.projectionMatrix.multiplyMatrices(this.projectionMatrix,r)),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}setViewOffset(t,e,n,i,a,s){this.view={fullWidth:t,fullHeight:e,offsetX:n,offsetY:i,width:a,height:s},this.updateProjectionMatrix()}clearViewOffset(){this.view=null,this.updateProjectionMatrix()}clone(){return new S().copy(this)}}S.prototype=Object.create(M.prototype);S.prototype.constructor=S;class w{constructor(t,e,n,i,a,s){super(),this.isWebGLRenderer=!0,this._alpha=t?.alpha||!1,this._premultipliedAlpha=t?.premultipliedAlpha||!0,this._antialias=t?.antialias||!1,this._stencilBuffer=t?.stencilBuffer!==void 0?t.stencilBuffer:!0,this._depthBuffer=t?.depthBuffer!==void 0?t.depthBuffer:!0,this._powerPreference=t?.powerPreference||"default",this._failIfMajorPerformanceCaveat=t?.failIfMajorPerformanceCaveat||!1,this._canvas=t?.canvas||document.createElement("canvas"),this._context=null,this._pixelRatio=1,this._width=1,this._height=1,this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.info={memory:{geometries:0,textures:0},render:{calls:0,triangles:0,points:0,lines:0}},this.shadowMap={enabled:!1,type:1,autoUpdate:!0,needsUpdate:!1},this.capabilities=null,this.extensions={},this.state=null,this.compileCallbacks=[],this.clippingPlanes=null,this.localClippingEnabled=!1,this.sortObjects=!0,this.physicallyCorrectLights=!1,this.outputEncoding=3000,this.toneMapping=0,this.toneMappingExposure=1,this.toneMappingWhitePoint=1,this.debug={checkShaderErrors:!0},this._initContext()}get context(){return this._context}get domElement(){return this._canvas}get pixelRatio(){return this._pixelRatio}set pixelRatio(t){this._pixelRatio=t,this.setSize(this._width,this._height)}get width(){return this._width}get height(){return this._height}setSize(t,e,n=!0){this._width=t,this._height=e,this._canvas.width=t*this._pixelRatio,this._canvas.height=e*this._pixelRatio;if(!n){this._canvas.style.width=t+"px",this._canvas.style.height=e+"px"}this.state.viewport(0,0,this._canvas.width,this._canvas.height)}getClearColor(){return this._clearColor}setClearColor(t,e=1){this._clearColor=t,this._clearAlpha=e,this._updateClearColor()}getClearAlpha(){return this._clearAlpha}setClearAlpha(t){this._clearAlpha=t,this._updateClearColor()}clear(t=!1){let e=0;t||(this.autoClearColor&&(e|=16384),this.autoClearDepth&&(e|=256),this.autoClearStencil&&(e|=1024)),this.state.clear(e,this._clearColor,this._clearAlpha)}render(t,e){this.info.render.calls=0,this.info.render.triangles=0,this.info.render.points=0,this.info.render.lines=0;const n=e.viewport;if(n)this.state.viewport(n.x,n.y,n.width,n.height);else{const t=this._canvas.width,i=this._canvas.height;this.state.viewport(0,0,t,i)}const i=e.scissor,a=i&&e.scissorTest;if(a)this.state.scissor(i.x,i.y,i.width,i.height),this.state.enable(3089);else if(e.scissorTest)this.state.disable(3089);this.autoClear&&this.clear();const s=[],r=[];t.traverseVisible(o=>{o.isLight?r.push(o):o.isMesh&&(o.material&&s.push(o))}),this.sortObjects&&s.sort((t,e)=>{const n=t.renderOrder-e.renderOrder;return n!==0?n:t.material.transparent?-1:1}),this._renderObjects(s,e,r),a&&this.state.disable(3089),n&&this.state.viewport(0,0,this._canvas.width,this._canvas.height)}_initContext(){const t={alpha:this._alpha,premultipliedAlpha:this._premultipliedAlpha,antialias:this._antialias,stencil:this._stencilBuffer,depth:this._depthBuffer,powerPreference:this._powerPreference,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat};try{this._context=this._canvas.getContext("webgl",t)||this._canvas.getContext("experimental-webgl",t)}catch(e){throw e}if(!this._context)throw new Error("WebGLRenderer: Unable to create WebGL context.");this._clearColor=new r(0,0,0),this._clearAlpha=1,this._updateClearColor(),this.capabilities=new (class{constructor(t){this.precision="highp",this.maxTextures=0,this.maxTextureSize=0,this.maxAttributes=0,this.maxVaryings=0,this.maxVertexUniforms=0,this.maxFragmentUniforms=0,this.supportsVertexTextures=!1,this.supportsFloatTextures=!1,this.supportsHalfFloatTextures=!1,this.supportsStandardDerivatives=!1,this.supportsFragmentShaderTextureLOD=!1,this.supportsDrawBuffers=!1,this.supportsWebGL2=!1,this._init(t)}_init(t){const e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.maxTextures=e,this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),this.maxAttributes=t.getParameter(t.MAX_VERTEX_ATTRIBS),this.maxVaryings=t.getParameter(t.MAX_VARYING_VECTORS),this.maxVertexUniforms=t.getParameter(t.MAX_VERTEX_UNIFORM_VECTORS),this.maxFragmentUniforms=t.getParameter(t.MAX_FRAGMENT_UNIFORM_VECTORS),this.supportsVertexTextures="OES_vertex_texture_uniform"in t.getExtension("OES_vertex_texture_uniform"),this.supportsStandardDerivatives="OES_standard_derivatives"in t.getExtension("OES_standard_derivatives"),this.supportsFragmentShaderTextureLOD="EXT_shader_texture_lod"in t.getExtension("EXT_shader_texture_lod"),this.supportsDrawBuffers="WEBGL_draw_buffers"in t.getExtension("WEBGL_draw_buffers"),this.supportsWebGL2="WebGL2RenderingContext"in window&&t instanceof WebGL2RenderingContext,this.supportsWebGL2?(this.supportsFloatTextures=!0,this.supportsHalfFloatTextures=!0):(this.supportsFloatTextures="OES_texture_float"in t.getExtension("OES_texture_float"),this.supportsHalfFloatTextures="OES_texture_half_float"in t.getExtension("OES_texture_half_float"))}})(this._context),this.state=new (class{constructor(t){this._gl=t,this._currentBlendEquation={rgb:32774,alpha:32774},this._currentBlendSrc={rgb:1,alpha:1},this._currentBlendDst={rgb:0,alpha:0},this._currentBlendColor=[0,0,0,0],this._currentPolygonOffset={factor:0,units:0},this._currentScissor={x:0,y:0,width:0,height:0},this._currentViewport={x:0,y:0,width:0,height:0},this._enabled={},this._init()}_init(){this.disable(2884),this.disable(2929),this.disable(3042),this.disable(3089),this.disable(32823),this.disable(32926),this._currentBlendEquation.rgb=32774,this._currentBlendEquation.alpha=32774,this._currentBlendSrc.rgb=1,this._currentBlendSrc.alpha=1,this._currentBlendDst.rgb=0,this._currentBlendDst.alpha=0,this._currentBlendColor=[0,0,0,0],this._currentPolygonOffset.factor=0,this._currentPolygonOffset.units=0,this._currentScissor.x=0,this._currentScissor.y=0,this._currentScissor.width=0,this._currentScissor.height=0,this._currentViewport.x=0,this._currentViewport.y=0,this._currentViewport.width=0,this._currentViewport.height=0} enable(t){this._enabled[t]||(this._gl.enable(t),this._enabled[t]=!0)}disable(t){this._enabled[t]&&(this._gl.disable(t),this._enabled[t]=!1)}bindTexture(t,e){this._gl.bindTexture(t,e)}activeTexture(t){this._gl.activeTexture(t)}blendEquation(t,e=t){t!==this._currentBlendEquation.rgb&&(this._gl.blendEquationSeparate(t,e),this._currentBlendEquation.rgb=t,this._currentBlendEquation.alpha=e)}blendFunc(t,e,n=t,i=e){t!==this._currentBlendSrc.rgb||e!==this._currentBlendDst.rgb||n!==this._currentBlendSrc.alpha||i!==this._currentBlendDst.alpha||(this._gl.blendFuncSeparate(t,e,n,i),this._currentBlendSrc.rgb=t,this._currentBlendDst.rgb=e,this._currentBlendSrc.alpha=n,this._currentBlendDst.alpha=i)}blendColor(t,e,n,i){t!==this._currentBlendColor[0]||e!==this._currentBlendColor[1]||n!==this._currentBlendColor[2]||i!==this._currentBlendColor[3]||(this._gl.blendColor(t,e,n,i),this._currentBlendColor[0]=t,this._currentBlendColor[1]=e,this._currentBlendColor[2]=n,this._currentBlendColor[3]=i)}polygonOffset(t,e){t!==this._currentPolygonOffset.factor||e!==this._currentPolygonOffset.units||(this._gl.polygonOffset(t,e),this._currentPolygonOffset.factor=t,this._currentPolygonOffset.units=e)}scissor(t,e,n,i){t!==this._currentScissor.x||e!==this._currentScissor.y||n!==this._currentScissor.width||i!==this._currentScissor.height||(this._gl.scissor(t,e,n,i),this._currentScissor.x=t,this._currentScissor.y=e,this._currentScissor.width=n,this._currentScissor.height=i)}viewport(t,e,n,i){t!==this._currentViewport.x||e!==this._currentViewport.y||n!==this._currentViewport.width||i!==this._currentViewport.height||(this._gl.viewport(t,e,n,i),this._currentViewport.x=t,this._currentViewport.y=e,this._currentViewport.width=n,this._currentViewport.height=i)}clear(t,e,n){this._gl.clearColor(e.r,e.g,e.b,n),this._gl.clear(t)}})(this._context)}_updateClearColor(){this._context.clearColor(this._clearColor.r,this._clearColor.g,this._clearColor.b,this._clearAlpha)}_renderObjects(t,e,n){const i=this._context,a=e.matrixWorldInverse,s=e.projectionMatrix;for(let r=0,o=t.length;r<o;r++){const u=t[r];if(u.visible&&u.material){this.info.render.calls++,u.onBeforeRender&&u.onBeforeRender(this,u,e),this._renderMesh(u,a,s),u.onAfterRender&&u.onAfterRender(this,u,e)}}}_renderMesh(t,e,n){const i=t.geometry,a=t.material,s=i.attributes;if(s.position){const r=this._createShaderProgram(a),o=i.index;r.use(),r.setUniform("modelViewMatrix",t.matrixWorld.multiply(e).elements),r.setUniform("projectionMatrix",n.elements),r.setAttribute("position",s.position),i.drawRange.count>0?o?this._drawElements(r,i,o):this._drawArrays(r,i):console.warn("Rendering empty geometry")}}_createShaderProgram(t){return new (class{constructor(t,e){this.uniforms={},this.attributes={},this.program=null,this._init(t,e)}_init(t,e){const n=e.createShader(e.VERTEX_SHADER);e.shaderSource(n,t.vertexShader),e.compileShader(n);const i=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(i,t.fragmentShader),e.compileShader(i);const a=e.createProgram();e.attachShader(a,n),e.attachShader(a,i),e.linkProgram(a),this.program=a}use(){e.useProgram(this.program)}setUniform(t,n){const i=e.getUniformLocation(this.program,t);i&&e.uniformMatrix4fv(i,!1,n)}setAttribute(t,n){const i=e.getAttribLocation(this.program,t);if(i!==-1){e.enableVertexAttribArray(i);const a=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,a),e.bufferData(e.ARRAY_BUFFER,n.array,e.STATIC_DRAW),e.vertexAttribPointer(i,n.itemSize,e.FLOAT,!1,0,0)}}})(t,this._context)}_drawArrays(t,e){this._context.drawArrays(this._getDrawMode(e),e.drawRange.start,e.drawRange.count)}_drawElements(t,e,n){this._context.drawElements(this._getDrawMode(e),n.count||n.array.length,this._getIndexType(n),n.drawRange.start*this._getIndexTypeSize(n))}_getDrawMode(t){switch(t.drawMode){case 4:return 4;case 5:return 5;case 6:return 6;default:return 4}}_getIndexType(t){return t.array instanceof Uint16Array?5123:5125}_getIndexTypeSize(t){return this._getIndexType(t)===5123?2:4}}class _ extends b{constructor(t,e){super(),this.isGeometry=!0,this.type="Geometry",this.uuid=crypto.randomUUID(),this.name="",this.attributes={},this.morphAttributes={},this.indices=null,this.morphTargetsRelative=!1,this.groups=[{start:0,count:0,materialIndex:0}],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:Infinity},this.userData={},t&&this.fromBufferGeometry(t),e&&this.mergeVertices()}fromBufferGeometry(t){this.attributes.position=new d(new Float32Array(t.attributes.position.array),3),t.attributes.normal&&(this.attributes.normal=new d(new Float32Array(t.attributes.normal.array),3)),t.attributes.uv&&(this.attributes.uv=new d(new Float32Array(t.attributes.uv.array),2)),t.index&&(this.indices=new m(new Uint16Array(t.index.array),1))}mergeVertices(t=1e-4){const e=this.attributes.position.array,n=this.indices?this.indices.array:null,i=[];let a=0,s=[];for(let r=0;r<e.length;r+=3){const o=e[r],u=e[r+1],l=e[r+2],c=function(t,e,n,i){for(let a=0,s=t.length;a<s;a+=3)if(Math.abs(t[a]-e)<=i&&Math.abs(t[a+1]-n)<=i)return a/3;return-1}(e